diff --git a/tools/tests/xen-subpage/Makefile b/tools/tests/xen-subpage/Makefile
new file mode 100644
index 0000000..89b58f2
--- /dev/null
+++ b/tools/tests/xen-subpage/Makefile
@@ -0,0 +1,30 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+CFLAGS += -Werror
+CFLAGS += -DXC_WANT_COMPAT_DEVICEMODEL_API
+
+CFLAGS += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenguest)
+CFLAGS += $(CFLAGS_xeninclude)
+
+TARGETS-y := xen-subpage
+TARGETS := $(TARGETS-y)
+
+.PHONY: all
+all: build
+
+.PHONY: build
+build: $(TARGETS)
+
+.PHONY: clean
+clean:
+	$(RM) *.o $(TARGETS) *~ $(DEPS)
+
+.PHONY: distclean
+distclean: clean
+
+xen-subpage: xen-subpage.o Makefile
+	$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenevtchn)
+
+-include $(DEPS)
diff --git a/tools/tests/xen-subpage/xen-subpage.c b/tools/tests/xen-subpage/xen-subpage.c
new file mode 100644
index 0000000..78e416c
--- /dev/null
+++ b/tools/tests/xen-subpage/xen-subpage.c
@@ -0,0 +1,125 @@
+/*
+ * xen-subpage.c
+ *
+ * Exercises the basic per-page access mechanisms
+ *
+ * Copyright (c) 2011 Virtuata, Inc.
+ * Copyright (c) 2017 by Intel
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <time.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <poll.h>
+
+#include <xenctrl.h>
+
+#define DPRINTF(a, b...) fprintf(stderr, a, ## b)
+#define ERROR(a, b...) fprintf(stderr, a "\n", ## b)
+#define PERROR(a, b...) fprintf(stderr, a ": %s\n", ## b, strerror(errno))
+
+void usage(char* progname)
+{
+    fprintf(stderr, "Usage: %s [-m] <domain_id> get|set [gfn] [bit_map]", progname);
+
+            fprintf(stderr,
+            "\n"
+            "set - set gfn bitmap.\n"
+            "\n"
+            "-m requires this program to run\n");
+}
+
+int main(int argc, char *argv[])
+{
+    domid_t domain_id;
+    xc_interface *xch;
+    xen_pfn_t gfn = 0;
+    uint32_t access = 0;
+    int required = 0;
+    int rc = 0;
+
+    char* progname = argv[0];
+    argv++;
+    argc--;
+
+    if ( argc == 5 && argv[0][0] == '-' )
+    {
+        if ( !strcmp(argv[0], "-m") )
+            required = 1;
+        else
+        {
+            usage(progname);
+            return -1;
+        }
+        argv++;
+        argc--;
+    }
+
+    if ( argc != 4 )
+    {
+        usage(progname);
+        return -1;
+    }
+
+    domain_id = atoi(argv[0]);
+    argv++;
+    argc--;
+
+    if ( !strcmp(argv[0], "set") )
+    {
+        gfn = strtoul(argv[1], 0, 0);
+        access = strtoul(argv[2], 0, 0);
+        DPRINTF("set subpage gfn:0x%lx -- map:0x%x\n", gfn, access);
+        xch = xc_interface_open(NULL, NULL, 0);
+        if ( !xch )
+        {
+            ERROR("get interface error\n");
+            return -1;
+        }
+        xc_mem_set_subpage(xch, domain_id, gfn, access);
+        xc_interface_close(xch);
+    }
+    else
+    {
+        usage(argv[0]);
+        return -1;
+    }
+
+    return rc;
+}
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
