[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V15 8/9] tools/tests: Enable xen-access on ARM
Define the ARM specific test_and_set_bit functions and switch to use maximum gpfn as the limit to setting permissions. Also, move HAS_MEM_ACCESS definition into config. Signed-off-by: Tamas K Lengyel <tklengyel@xxxxxxxxxxxxx> --- v15: - Rebase on staging v6: - Just use xc_domain_maximum_gpfn to get max_gpfn. v5: - Use the new information returned by getdomaininfo, max_gpfn, to set access permissions. On ARM this will include the potential memory hole as well which the hypervisor just loops over. v4: - Take into account multiple guest ram banks on ARM. - Move HAS_MEM_ACCESS definition into config/*.mk and only compile xen-access when it is defined. - Pass CONFIG_X86/CONFIG_ARM flags during compilation in xen-access Makefile. --- tools/tests/xen-access/Makefile | 4 ++-- tools/tests/xen-access/xen-access.c | 38 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/tools/tests/xen-access/Makefile b/tools/tests/xen-access/Makefile index f0e94fd..f810543 100644 --- a/tools/tests/xen-access/Makefile +++ b/tools/tests/xen-access/Makefile @@ -7,8 +7,8 @@ CFLAGS += $(CFLAGS_libxenctrl) CFLAGS += $(CFLAGS_libxenguest) CFLAGS += $(CFLAGS_xeninclude) -TARGETS-y := -TARGETS-$(CONFIG_X86) += xen-access +TARGETS-y := +TARGETS-$(HAS_MEM_ACCESS) := xen-access TARGETS := $(TARGETS-y) .PHONY: all diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index 8a899da..12ab921 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -41,6 +41,13 @@ #include <xenctrl.h> #include <xen/vm_event.h> +#if defined(__arm__) || defined(__aarch64__) +#include <xen/arch-arm.h> +#define START_PFN (GUEST_RAM0_BASE >> 12) +#elif defined(__i386__) || defined(__x86_64__) +#define START_PFN 0ULL +#endif + #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)) @@ -57,7 +64,7 @@ typedef struct vm_event { typedef struct xenaccess { xc_interface *xc_handle; - xc_domaininfo_t *domain_info; + xen_pfn_t max_gpfn; vm_event_t vm_event; } xenaccess_t; @@ -165,7 +172,6 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) } xenaccess->xc_handle = NULL; - free(xenaccess->domain_info); free(xenaccess); return 0; @@ -243,23 +249,18 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id) (vm_event_sring_t *)xenaccess->vm_event.ring_page, XC_PAGE_SIZE); - /* Get domaininfo */ - xenaccess->domain_info = malloc(sizeof(xc_domaininfo_t)); - if ( xenaccess->domain_info == NULL ) - { - ERROR("Error allocating memory for domain info"); - goto err; - } + /* Get max_gpfn */ + rc = xc_domain_maximum_gpfn(xenaccess->xc_handle, + xenaccess->vm_event.domain_id, + &xenaccess->max_gpfn); - rc = xc_domain_getinfolist(xenaccess->xc_handle, domain_id, 1, - xenaccess->domain_info); - if ( rc != 1 ) + if ( rc ) { - ERROR("Error getting domain info"); + ERROR("Failed to get max gpfn"); goto err; } - DPRINTF("max_pages = %"PRIx64"\n", xenaccess->domain_info->max_pages); + DPRINTF("max_gpfn = %"PRIx64"\n", xenaccess->max_gpfn); return xenaccess; @@ -422,8 +423,9 @@ int main(int argc, char *argv[]) goto exit; } - rc = xc_set_mem_access(xch, domain_id, default_access, 0, - xenaccess->domain_info->max_pages); + rc = xc_set_mem_access(xch, domain_id, default_access, START_PFN, + (xenaccess->max_gpfn - START_PFN) ); + if ( rc < 0 ) { ERROR("Error %d setting all memory to access type %d\n", rc, @@ -450,8 +452,8 @@ int main(int argc, char *argv[]) /* Unregister for every event */ rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, ~0ull, 0); - rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, 0, - xenaccess->domain_info->max_pages); + rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, START_PFN, + (xenaccess->max_gpfn - START_PFN) ); rc = xc_monitor_software_breakpoint(xch, domain_id, 0); shutting_down = 1; -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |