[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v2 12/12] tools/tests: Enable xen-access on ARM
On ARM the guest memory doesn't start from 0, thus we include the required headers and define GUEST_RAM_BASE_PFN in both architecture to be passed to mem_access as the starting pfn. We also define the ARM specific test_and_set_bit function. Signed-off-by: Tamas K Lengyel <tklengyel@xxxxxxxxxxxxx> --- tools/tests/xen-access/Makefile | 4 +-- tools/tests/xen-access/xen-access.c | 55 +++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/tools/tests/xen-access/Makefile b/tools/tests/xen-access/Makefile index 65eef99..698355c 100644 --- a/tools/tests/xen-access/Makefile +++ b/tools/tests/xen-access/Makefile @@ -7,9 +7,7 @@ CFLAGS += $(CFLAGS_libxenctrl) CFLAGS += $(CFLAGS_libxenguest) CFLAGS += $(CFLAGS_xeninclude) -TARGETS-y := -TARGETS-$(CONFIG_X86) += xen-access -TARGETS := $(TARGETS-y) +TARGETS := xen-access .PHONY: all all: build diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index 090df5f..6af6ac3 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -41,22 +41,16 @@ #include <xenctrl.h> #include <xen/mem_event.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)) - -/* Spinlock and mem event definitions */ - -#define SPIN_LOCK_UNLOCKED 0 +#ifdef CONFIG_X86 +#define GUEST_RAM_BASE_PFN 0ULL #define ADDR (*(volatile long *) addr) + /** * test_and_set_bit - Set a bit and return its old value * @nr: Bit to set * @addr: Address to count from * - * This operation is atomic and cannot be reordered. - * It also implies a memory barrier. */ static inline int test_and_set_bit(int nr, volatile void *addr) { @@ -69,6 +63,43 @@ static inline int test_and_set_bit(int nr, volatile void *addr) return oldbit; } +#else /* CONFIG_X86 */ + +#include <xen/arch-arm.h> + +#define PAGE_SHIFT 12 +#define GUEST_RAM_BASE_PFN GUEST_RAM_BASE >> PAGE_SHIFT +#define BITS_PER_WORD 32 +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_WORD)) +#define BIT_WORD(nr) ((nr) / BITS_PER_WORD) + +/** + * test_and_set_bit - Set a bit and return its old value + * @nr: Bit to set + * @addr: Address to count from + * + */ +static inline int test_and_set_bit(int nr, volatile void *addr) +{ + unsigned int mask = BIT_MASK(nr); + volatile unsigned int *p = + ((volatile unsigned int *)addr) + BIT_WORD(nr); + unsigned int old = *p; + + *p = old | mask; + return (old & mask) != 0; +} + +#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)) + +/* Spinlock and mem event definitions */ + +#define SPIN_LOCK_UNLOCKED 0 + typedef int spinlock_t; static inline void spin_lock(spinlock_t *lock) @@ -476,6 +507,7 @@ int main(int argc, char *argv[]) sigaction(SIGINT, &act, NULL); sigaction(SIGALRM, &act, NULL); +#ifdef CONFIG_X86 /* Set whether the access listener is required */ rc = xc_domain_set_access_required(xch, domain_id, required); if ( rc < 0 ) @@ -483,6 +515,7 @@ int main(int argc, char *argv[]) ERROR("Error %d setting mem_access listener required\n", rc); goto exit; } +#endif /* Set the default access type and convert all pages to it */ rc = xc_set_mem_access(xch, domain_id, default_access, ~0ull, 0); @@ -492,7 +525,7 @@ int main(int argc, char *argv[]) goto exit; } - rc = xc_set_mem_access(xch, domain_id, default_access, 0, + rc = xc_set_mem_access(xch, domain_id, default_access, GUEST_RAM_BASE_PFN, xenaccess->domain_info->max_pages); if ( rc < 0 ) { @@ -520,7 +553,7 @@ 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, + rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, GUEST_RAM_BASE_PFN, xenaccess->domain_info->max_pages); rc = xc_hvm_param_set(xch, domain_id, HVM_PARAM_MEMORY_EVENT_INT3, HVMPME_mode_disabled); -- 2.1.0.rc1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |