From 162e371712768248a38646eefa71af38b6e0f8ce Mon Sep 17 00:00:00 2001 From: David Vrabel Date: Fri, 11 Jul 2014 16:42:34 +0100 Subject: x86/xen: safely map and unmap grant frames when in atomic context arch_gnttab_map_frames() and arch_gnttab_unmap_frames() are called in atomic context but were calling alloc_vm_area() which might sleep. Also, if a driver attempts to allocate a grant ref from an interrupt and the table needs expanding, then the CPU may already by in lazy MMU mode and apply_to_page_range() will BUG when it tries to re-enable lazy MMU mode. These two functions are only used in PV guests. Introduce arch_gnttab_init() to allocates the virtual address space in advance. Avoid the use of apply_to_page_range() by using saving and using the array of PTE addresses from the alloc_vm_area() call. N.B. 'alloc_vm_area' pre-allocates the pagetable so there is no need to worry about having to do a PGD/PUD/PMD walk (like apply_to_page_range does) and we can instead do set_pte. Signed-off-by: David Vrabel Signed-off-by: Konrad Rzeszutek Wilk ---- [v2: Add comment about alloc_vm_area] [v3: Fix compile error found by 0-day bot] --- arch/arm/xen/grant-table.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'arch/arm/xen') diff --git a/arch/arm/xen/grant-table.c b/arch/arm/xen/grant-table.c index 859a9bb..91cf08b 100644 --- a/arch/arm/xen/grant-table.c +++ b/arch/arm/xen/grant-table.c @@ -51,3 +51,8 @@ int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, { return -ENOSYS; } + +int arch_gnttab_init(unsigned long nr_shared, unsigned long nr_status) +{ + return 0; +} -- cgit v1.1 From 438b33c7145ca8a5131a30c36d8f59bce119a19a Mon Sep 17 00:00:00 2001 From: David Vrabel Date: Wed, 2 Jul 2014 11:25:29 +0100 Subject: xen/grant-table: remove support for V2 tables Since 11c7ff17c9b6dbf3a4e4f36be30ad531a6cf0ec9 (xen/grant-table: Force to use v1 of grants.) the code for V2 grant tables is not used. Signed-off-by: David Vrabel Signed-off-by: Konrad Rzeszutek Wilk --- arch/arm/xen/grant-table.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'arch/arm/xen') diff --git a/arch/arm/xen/grant-table.c b/arch/arm/xen/grant-table.c index 91cf08b..e437918 100644 --- a/arch/arm/xen/grant-table.c +++ b/arch/arm/xen/grant-table.c @@ -45,14 +45,7 @@ void arch_gnttab_unmap(void *shared, unsigned long nr_gframes) return; } -int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, - unsigned long max_nr_gframes, - grant_status_t **__shared) -{ - return -ENOSYS; -} - -int arch_gnttab_init(unsigned long nr_shared, unsigned long nr_status) +int arch_gnttab_init(unsigned long nr_shared) { return 0; } -- cgit v1.1 From a91c7775e3469821711c1eadf15149b3ba2c82c9 Mon Sep 17 00:00:00 2001 From: Himangi Saraogi Date: Fri, 25 Jul 2014 12:05:39 -0400 Subject: xen/arm: use BUG_ON Use BUG_ON(x) rather than if(x) BUG(); The semantic patch that fixes this problem is as follows: // @@ identifier x; @@ -if (x) BUG(); +BUG_ON(x); // Signed-off-by: Himangi Saraogi Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Stefano Stabellini --- arch/arm/xen/enlighten.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'arch/arm/xen') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 1e63243..98544c5 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -181,8 +181,7 @@ static void xen_restart(enum reboot_mode reboot_mode, const char *cmd) struct sched_shutdown r = { .reason = SHUTDOWN_reboot }; int rc; rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); - if (rc) - BUG(); + BUG_ON(rc); } static void xen_power_off(void) @@ -190,8 +189,7 @@ static void xen_power_off(void) struct sched_shutdown r = { .reason = SHUTDOWN_poweroff }; int rc; rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); - if (rc) - BUG(); + BUG_ON(rc); } static int xen_cpu_notification(struct notifier_block *self, -- cgit v1.1