summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-10-04 14:13:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-10-04 14:13:09 -0400
commit50dfd03d9579cde9150679e90f8f244c626b7a09 (patch)
treed9e15993f024f8c917e20e8585a06b0b5f7f9629
parente524d16e7e324039f2a9f82e302f0a39ac7d5812 (diff)
parenta8fabb38525c51a094607768bac3ba46b3f4a9d5 (diff)
Merge tag 'for-linus-5.4-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes and cleanups from Juergen Gross: - a fix in the Xen balloon driver avoiding hitting a BUG_ON() in some cases, plus a follow-on cleanup series for that driver - a patch for introducing non-blocking EFI callbacks in Xen's EFI driver, plu a cleanup patch for Xen EFI handling merging the x86 and ARM arch specific initialization into the Xen EFI driver - a fix of the Xen xenbus driver avoiding a self-deadlock when cleaning up after a user process has died - a fix for Xen on ARM after removal of ZONE_DMA - a cleanup patch for avoiding build warnings for Xen on ARM * tag 'for-linus-5.4-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/xenbus: fix self-deadlock after killing user process xen/efi: have a common runtime setup function arm: xen: mm: use __GPF_DMA32 for arm64 xen/balloon: Clear PG_offline in balloon_retrieve() xen/balloon: Mark pages PG_offline in balloon_append() xen/balloon: Drop __balloon_append() xen/balloon: Set pages PageOffline() in balloon_add_region() ARM: xen: unexport HYPERVISOR_platform_op function xen/efi: Set nonblocking callbacks
-rw-r--r--arch/arm/include/asm/xen/xen-ops.h6
-rw-r--r--arch/arm/xen/Makefile1
-rw-r--r--arch/arm/xen/efi.c28
-rw-r--r--arch/arm/xen/enlighten.c3
-rw-r--r--arch/arm/xen/mm.c5
-rw-r--r--arch/arm64/include/asm/xen/xen-ops.h7
-rw-r--r--arch/arm64/xen/Makefile1
-rw-r--r--arch/x86/xen/efi.c14
-rw-r--r--drivers/xen/balloon.c24
-rw-r--r--drivers/xen/efi.c84
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c20
-rw-r--r--include/xen/xen-ops.h25
12 files changed, 79 insertions, 139 deletions
diff --git a/arch/arm/include/asm/xen/xen-ops.h b/arch/arm/include/asm/xen/xen-ops.h
deleted file mode 100644
index ec154e719b11..000000000000
--- a/arch/arm/include/asm/xen/xen-ops.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_XEN_OPS_H
2#define _ASM_XEN_OPS_H
3
4void xen_efi_runtime_setup(void);
5
6#endif /* _ASM_XEN_OPS_H */
diff --git a/arch/arm/xen/Makefile b/arch/arm/xen/Makefile
index 7ed28982c4c3..c32d04713ba0 100644
--- a/arch/arm/xen/Makefile
+++ b/arch/arm/xen/Makefile
@@ -1,3 +1,2 @@
1# SPDX-License-Identifier: GPL-2.0-only 1# SPDX-License-Identifier: GPL-2.0-only
2obj-y := enlighten.o hypercall.o grant-table.o p2m.o mm.o 2obj-y := enlighten.o hypercall.o grant-table.o p2m.o mm.o
3obj-$(CONFIG_XEN_EFI) += efi.o
diff --git a/arch/arm/xen/efi.c b/arch/arm/xen/efi.c
deleted file mode 100644
index d687a73044bf..000000000000
--- a/arch/arm/xen/efi.c
+++ /dev/null
@@ -1,28 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2015, Linaro Limited, Shannon Zhao
4 */
5
6#include <linux/efi.h>
7#include <xen/xen-ops.h>
8#include <asm/xen/xen-ops.h>
9
10/* Set XEN EFI runtime services function pointers. Other fields of struct efi,
11 * e.g. efi.systab, will be set like normal EFI.
12 */
13void __init xen_efi_runtime_setup(void)
14{
15 efi.get_time = xen_efi_get_time;
16 efi.set_time = xen_efi_set_time;
17 efi.get_wakeup_time = xen_efi_get_wakeup_time;
18 efi.set_wakeup_time = xen_efi_set_wakeup_time;
19 efi.get_variable = xen_efi_get_variable;
20 efi.get_next_variable = xen_efi_get_next_variable;
21 efi.set_variable = xen_efi_set_variable;
22 efi.query_variable_info = xen_efi_query_variable_info;
23 efi.update_capsule = xen_efi_update_capsule;
24 efi.query_capsule_caps = xen_efi_query_capsule_caps;
25 efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
26 efi.reset_system = xen_efi_reset_system;
27}
28EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 1e57692552d9..dd6804a64f1a 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -15,7 +15,6 @@
15#include <xen/xen-ops.h> 15#include <xen/xen-ops.h>
16#include <asm/xen/hypervisor.h> 16#include <asm/xen/hypervisor.h>
17#include <asm/xen/hypercall.h> 17#include <asm/xen/hypercall.h>
18#include <asm/xen/xen-ops.h>
19#include <asm/system_misc.h> 18#include <asm/system_misc.h>
20#include <asm/efi.h> 19#include <asm/efi.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
@@ -437,7 +436,7 @@ EXPORT_SYMBOL_GPL(HYPERVISOR_memory_op);
437EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); 436EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op);
438EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); 437EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op);
439EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op); 438EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op);
440EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op); 439EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op_raw);
441EXPORT_SYMBOL_GPL(HYPERVISOR_multicall); 440EXPORT_SYMBOL_GPL(HYPERVISOR_multicall);
442EXPORT_SYMBOL_GPL(HYPERVISOR_vm_assist); 441EXPORT_SYMBOL_GPL(HYPERVISOR_vm_assist);
443EXPORT_SYMBOL_GPL(HYPERVISOR_dm_op); 442EXPORT_SYMBOL_GPL(HYPERVISOR_dm_op);
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 2b2c208408bb..38fa917c8585 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -28,7 +28,10 @@ unsigned long xen_get_swiotlb_free_pages(unsigned int order)
28 28
29 for_each_memblock(memory, reg) { 29 for_each_memblock(memory, reg) {
30 if (reg->base < (phys_addr_t)0xffffffff) { 30 if (reg->base < (phys_addr_t)0xffffffff) {
31 flags |= __GFP_DMA; 31 if (IS_ENABLED(CONFIG_ZONE_DMA32))
32 flags |= __GFP_DMA32;
33 else
34 flags |= __GFP_DMA;
32 break; 35 break;
33 } 36 }
34 } 37 }
diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
deleted file mode 100644
index e6e784051932..000000000000
--- a/arch/arm64/include/asm/xen/xen-ops.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_XEN_OPS_H
3#define _ASM_XEN_OPS_H
4
5void xen_efi_runtime_setup(void);
6
7#endif /* _ASM_XEN_OPS_H */
diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
index a4fc65f3928d..b66215e8658e 100644
--- a/arch/arm64/xen/Makefile
+++ b/arch/arm64/xen/Makefile
@@ -1,4 +1,3 @@
1# SPDX-License-Identifier: GPL-2.0-only 1# SPDX-License-Identifier: GPL-2.0-only
2xen-arm-y += $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o) 2xen-arm-y += $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
3obj-y := xen-arm.o hypercall.o 3obj-y := xen-arm.o hypercall.o
4obj-$(CONFIG_XEN_EFI) += $(addprefix ../../arm/xen/, efi.o)
diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
index 0d3365cb64de..a04551ee5568 100644
--- a/arch/x86/xen/efi.c
+++ b/arch/x86/xen/efi.c
@@ -57,19 +57,7 @@ static efi_system_table_t __init *xen_efi_probe(void)
57 return NULL; 57 return NULL;
58 58
59 /* Here we know that Xen runs on EFI platform. */ 59 /* Here we know that Xen runs on EFI platform. */
60 60 xen_efi_runtime_setup();
61 efi.get_time = xen_efi_get_time;
62 efi.set_time = xen_efi_set_time;
63 efi.get_wakeup_time = xen_efi_get_wakeup_time;
64 efi.set_wakeup_time = xen_efi_set_wakeup_time;
65 efi.get_variable = xen_efi_get_variable;
66 efi.get_next_variable = xen_efi_get_next_variable;
67 efi.set_variable = xen_efi_set_variable;
68 efi.query_variable_info = xen_efi_query_variable_info;
69 efi.update_capsule = xen_efi_update_capsule;
70 efi.query_capsule_caps = xen_efi_query_capsule_caps;
71 efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
72 efi.reset_system = xen_efi_reset_system;
73 61
74 efi_systab_xen.tables = info->cfg.addr; 62 efi_systab_xen.tables = info->cfg.addr;
75 efi_systab_xen.nr_tables = info->cfg.nent; 63 efi_systab_xen.nr_tables = info->cfg.nent;
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 4e11de6cde81..5bae515c8e25 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -156,8 +156,10 @@ static DECLARE_DELAYED_WORK(balloon_worker, balloon_process);
156 (GFP_HIGHUSER | __GFP_NOWARN | __GFP_NORETRY | __GFP_NOMEMALLOC) 156 (GFP_HIGHUSER | __GFP_NOWARN | __GFP_NORETRY | __GFP_NOMEMALLOC)
157 157
158/* balloon_append: add the given page to the balloon. */ 158/* balloon_append: add the given page to the balloon. */
159static void __balloon_append(struct page *page) 159static void balloon_append(struct page *page)
160{ 160{
161 __SetPageOffline(page);
162
161 /* Lowmem is re-populated first, so highmem pages go at list tail. */ 163 /* Lowmem is re-populated first, so highmem pages go at list tail. */
162 if (PageHighMem(page)) { 164 if (PageHighMem(page)) {
163 list_add_tail(&page->lru, &ballooned_pages); 165 list_add_tail(&page->lru, &ballooned_pages);
@@ -169,11 +171,6 @@ static void __balloon_append(struct page *page)
169 wake_up(&balloon_wq); 171 wake_up(&balloon_wq);
170} 172}
171 173
172static void balloon_append(struct page *page)
173{
174 __balloon_append(page);
175}
176
177/* balloon_retrieve: rescue a page from the balloon, if it is not empty. */ 174/* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
178static struct page *balloon_retrieve(bool require_lowmem) 175static struct page *balloon_retrieve(bool require_lowmem)
179{ 176{
@@ -192,6 +189,7 @@ static struct page *balloon_retrieve(bool require_lowmem)
192 else 189 else
193 balloon_stats.balloon_low--; 190 balloon_stats.balloon_low--;
194 191
192 __ClearPageOffline(page);
195 return page; 193 return page;
196} 194}
197 195
@@ -377,8 +375,7 @@ static void xen_online_page(struct page *page, unsigned int order)
377 for (i = 0; i < size; i++) { 375 for (i = 0; i < size; i++) {
378 p = pfn_to_page(start_pfn + i); 376 p = pfn_to_page(start_pfn + i);
379 __online_page_set_limits(p); 377 __online_page_set_limits(p);
380 __SetPageOffline(p); 378 balloon_append(p);
381 __balloon_append(p);
382 } 379 }
383 mutex_unlock(&balloon_mutex); 380 mutex_unlock(&balloon_mutex);
384} 381}
@@ -444,7 +441,6 @@ static enum bp_state increase_reservation(unsigned long nr_pages)
444 xenmem_reservation_va_mapping_update(1, &page, &frame_list[i]); 441 xenmem_reservation_va_mapping_update(1, &page, &frame_list[i]);
445 442
446 /* Relinquish the page back to the allocator. */ 443 /* Relinquish the page back to the allocator. */
447 __ClearPageOffline(page);
448 free_reserved_page(page); 444 free_reserved_page(page);
449 } 445 }
450 446
@@ -471,7 +467,6 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
471 state = BP_EAGAIN; 467 state = BP_EAGAIN;
472 break; 468 break;
473 } 469 }
474 __SetPageOffline(page);
475 adjust_managed_page_count(page, -1); 470 adjust_managed_page_count(page, -1);
476 xenmem_reservation_scrub_page(page); 471 xenmem_reservation_scrub_page(page);
477 list_add(&page->lru, &pages); 472 list_add(&page->lru, &pages);
@@ -611,7 +606,6 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
611 while (pgno < nr_pages) { 606 while (pgno < nr_pages) {
612 page = balloon_retrieve(true); 607 page = balloon_retrieve(true);
613 if (page) { 608 if (page) {
614 __ClearPageOffline(page);
615 pages[pgno++] = page; 609 pages[pgno++] = page;
616#ifdef CONFIG_XEN_HAVE_PVMMU 610#ifdef CONFIG_XEN_HAVE_PVMMU
617 /* 611 /*
@@ -653,10 +647,8 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
653 mutex_lock(&balloon_mutex); 647 mutex_lock(&balloon_mutex);
654 648
655 for (i = 0; i < nr_pages; i++) { 649 for (i = 0; i < nr_pages; i++) {
656 if (pages[i]) { 650 if (pages[i])
657 __SetPageOffline(pages[i]);
658 balloon_append(pages[i]); 651 balloon_append(pages[i]);
659 }
660 } 652 }
661 653
662 balloon_stats.target_unpopulated -= nr_pages; 654 balloon_stats.target_unpopulated -= nr_pages;
@@ -674,7 +666,6 @@ static void __init balloon_add_region(unsigned long start_pfn,
674 unsigned long pages) 666 unsigned long pages)
675{ 667{
676 unsigned long pfn, extra_pfn_end; 668 unsigned long pfn, extra_pfn_end;
677 struct page *page;
678 669
679 /* 670 /*
680 * If the amount of usable memory has been limited (e.g., with 671 * If the amount of usable memory has been limited (e.g., with
@@ -684,11 +675,10 @@ static void __init balloon_add_region(unsigned long start_pfn,
684 extra_pfn_end = min(max_pfn, start_pfn + pages); 675 extra_pfn_end = min(max_pfn, start_pfn + pages);
685 676
686 for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) { 677 for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) {
687 page = pfn_to_page(pfn);
688 /* totalram_pages and totalhigh_pages do not 678 /* totalram_pages and totalhigh_pages do not
689 include the boot-time balloon extension, so 679 include the boot-time balloon extension, so
690 don't subtract from it. */ 680 don't subtract from it. */
691 __balloon_append(page); 681 balloon_append(pfn_to_page(pfn));
692 } 682 }
693 683
694 balloon_stats.total_pages += extra_pfn_end - start_pfn; 684 balloon_stats.total_pages += extra_pfn_end - start_pfn;
diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
index 89d60f8e3c18..d1ff2186ebb4 100644
--- a/drivers/xen/efi.c
+++ b/drivers/xen/efi.c
@@ -40,7 +40,7 @@
40 40
41#define efi_data(op) (op.u.efi_runtime_call) 41#define efi_data(op) (op.u.efi_runtime_call)
42 42
43efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) 43static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
44{ 44{
45 struct xen_platform_op op = INIT_EFI_OP(get_time); 45 struct xen_platform_op op = INIT_EFI_OP(get_time);
46 46
@@ -61,9 +61,8 @@ efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
61 61
62 return efi_data(op).status; 62 return efi_data(op).status;
63} 63}
64EXPORT_SYMBOL_GPL(xen_efi_get_time);
65 64
66efi_status_t xen_efi_set_time(efi_time_t *tm) 65static efi_status_t xen_efi_set_time(efi_time_t *tm)
67{ 66{
68 struct xen_platform_op op = INIT_EFI_OP(set_time); 67 struct xen_platform_op op = INIT_EFI_OP(set_time);
69 68
@@ -75,10 +74,10 @@ efi_status_t xen_efi_set_time(efi_time_t *tm)
75 74
76 return efi_data(op).status; 75 return efi_data(op).status;
77} 76}
78EXPORT_SYMBOL_GPL(xen_efi_set_time);
79 77
80efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending, 78static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
81 efi_time_t *tm) 79 efi_bool_t *pending,
80 efi_time_t *tm)
82{ 81{
83 struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time); 82 struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
84 83
@@ -98,9 +97,8 @@ efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
98 97
99 return efi_data(op).status; 98 return efi_data(op).status;
100} 99}
101EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
102 100
103efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) 101static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
104{ 102{
105 struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time); 103 struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
106 104
@@ -117,11 +115,10 @@ efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
117 115
118 return efi_data(op).status; 116 return efi_data(op).status;
119} 117}
120EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
121 118
122efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor, 119static efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
123 u32 *attr, unsigned long *data_size, 120 u32 *attr, unsigned long *data_size,
124 void *data) 121 void *data)
125{ 122{
126 struct xen_platform_op op = INIT_EFI_OP(get_variable); 123 struct xen_platform_op op = INIT_EFI_OP(get_variable);
127 124
@@ -141,11 +138,10 @@ efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
141 138
142 return efi_data(op).status; 139 return efi_data(op).status;
143} 140}
144EXPORT_SYMBOL_GPL(xen_efi_get_variable);
145 141
146efi_status_t xen_efi_get_next_variable(unsigned long *name_size, 142static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
147 efi_char16_t *name, 143 efi_char16_t *name,
148 efi_guid_t *vendor) 144 efi_guid_t *vendor)
149{ 145{
150 struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name); 146 struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
151 147
@@ -165,11 +161,10 @@ efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
165 161
166 return efi_data(op).status; 162 return efi_data(op).status;
167} 163}
168EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
169 164
170efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor, 165static efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
171 u32 attr, unsigned long data_size, 166 u32 attr, unsigned long data_size,
172 void *data) 167 void *data)
173{ 168{
174 struct xen_platform_op op = INIT_EFI_OP(set_variable); 169 struct xen_platform_op op = INIT_EFI_OP(set_variable);
175 170
@@ -186,11 +181,10 @@ efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
186 181
187 return efi_data(op).status; 182 return efi_data(op).status;
188} 183}
189EXPORT_SYMBOL_GPL(xen_efi_set_variable);
190 184
191efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space, 185static efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
192 u64 *remaining_space, 186 u64 *remaining_space,
193 u64 *max_variable_size) 187 u64 *max_variable_size)
194{ 188{
195 struct xen_platform_op op = INIT_EFI_OP(query_variable_info); 189 struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
196 190
@@ -208,9 +202,8 @@ efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
208 202
209 return efi_data(op).status; 203 return efi_data(op).status;
210} 204}
211EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
212 205
213efi_status_t xen_efi_get_next_high_mono_count(u32 *count) 206static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
214{ 207{
215 struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count); 208 struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
216 209
@@ -221,10 +214,9 @@ efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
221 214
222 return efi_data(op).status; 215 return efi_data(op).status;
223} 216}
224EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
225 217
226efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules, 218static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
227 unsigned long count, unsigned long sg_list) 219 unsigned long count, unsigned long sg_list)
228{ 220{
229 struct xen_platform_op op = INIT_EFI_OP(update_capsule); 221 struct xen_platform_op op = INIT_EFI_OP(update_capsule);
230 222
@@ -241,11 +233,9 @@ efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
241 233
242 return efi_data(op).status; 234 return efi_data(op).status;
243} 235}
244EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
245 236
246efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules, 237static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
247 unsigned long count, u64 *max_size, 238 unsigned long count, u64 *max_size, int *reset_type)
248 int *reset_type)
249{ 239{
250 struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities); 240 struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
251 241
@@ -264,10 +254,9 @@ efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
264 254
265 return efi_data(op).status; 255 return efi_data(op).status;
266} 256}
267EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
268 257
269void xen_efi_reset_system(int reset_type, efi_status_t status, 258static void xen_efi_reset_system(int reset_type, efi_status_t status,
270 unsigned long data_size, efi_char16_t *data) 259 unsigned long data_size, efi_char16_t *data)
271{ 260{
272 switch (reset_type) { 261 switch (reset_type) {
273 case EFI_RESET_COLD: 262 case EFI_RESET_COLD:
@@ -281,4 +270,25 @@ void xen_efi_reset_system(int reset_type, efi_status_t status,
281 BUG(); 270 BUG();
282 } 271 }
283} 272}
284EXPORT_SYMBOL_GPL(xen_efi_reset_system); 273
274/*
275 * Set XEN EFI runtime services function pointers. Other fields of struct efi,
276 * e.g. efi.systab, will be set like normal EFI.
277 */
278void __init xen_efi_runtime_setup(void)
279{
280 efi.get_time = xen_efi_get_time;
281 efi.set_time = xen_efi_set_time;
282 efi.get_wakeup_time = xen_efi_get_wakeup_time;
283 efi.set_wakeup_time = xen_efi_set_wakeup_time;
284 efi.get_variable = xen_efi_get_variable;
285 efi.get_next_variable = xen_efi_get_next_variable;
286 efi.set_variable = xen_efi_set_variable;
287 efi.set_variable_nonblocking = xen_efi_set_variable;
288 efi.query_variable_info = xen_efi_query_variable_info;
289 efi.query_variable_info_nonblocking = xen_efi_query_variable_info;
290 efi.update_capsule = xen_efi_update_capsule;
291 efi.query_capsule_caps = xen_efi_query_capsule_caps;
292 efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
293 efi.reset_system = xen_efi_reset_system;
294}
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 08adc590f631..597af455a522 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -55,6 +55,7 @@
55#include <linux/string.h> 55#include <linux/string.h>
56#include <linux/slab.h> 56#include <linux/slab.h>
57#include <linux/miscdevice.h> 57#include <linux/miscdevice.h>
58#include <linux/workqueue.h>
58 59
59#include <xen/xenbus.h> 60#include <xen/xenbus.h>
60#include <xen/xen.h> 61#include <xen/xen.h>
@@ -116,6 +117,8 @@ struct xenbus_file_priv {
116 wait_queue_head_t read_waitq; 117 wait_queue_head_t read_waitq;
117 118
118 struct kref kref; 119 struct kref kref;
120
121 struct work_struct wq;
119}; 122};
120 123
121/* Read out any raw xenbus messages queued up. */ 124/* Read out any raw xenbus messages queued up. */
@@ -300,14 +303,14 @@ static void watch_fired(struct xenbus_watch *watch,
300 mutex_unlock(&adap->dev_data->reply_mutex); 303 mutex_unlock(&adap->dev_data->reply_mutex);
301} 304}
302 305
303static void xenbus_file_free(struct kref *kref) 306static void xenbus_worker(struct work_struct *wq)
304{ 307{
305 struct xenbus_file_priv *u; 308 struct xenbus_file_priv *u;
306 struct xenbus_transaction_holder *trans, *tmp; 309 struct xenbus_transaction_holder *trans, *tmp;
307 struct watch_adapter *watch, *tmp_watch; 310 struct watch_adapter *watch, *tmp_watch;
308 struct read_buffer *rb, *tmp_rb; 311 struct read_buffer *rb, *tmp_rb;
309 312
310 u = container_of(kref, struct xenbus_file_priv, kref); 313 u = container_of(wq, struct xenbus_file_priv, wq);
311 314
312 /* 315 /*
313 * No need for locking here because there are no other users, 316 * No need for locking here because there are no other users,
@@ -333,6 +336,18 @@ static void xenbus_file_free(struct kref *kref)
333 kfree(u); 336 kfree(u);
334} 337}
335 338
339static void xenbus_file_free(struct kref *kref)
340{
341 struct xenbus_file_priv *u;
342
343 /*
344 * We might be called in xenbus_thread().
345 * Use workqueue to avoid deadlock.
346 */
347 u = container_of(kref, struct xenbus_file_priv, kref);
348 schedule_work(&u->wq);
349}
350
336static struct xenbus_transaction_holder *xenbus_get_transaction( 351static struct xenbus_transaction_holder *xenbus_get_transaction(
337 struct xenbus_file_priv *u, uint32_t tx_id) 352 struct xenbus_file_priv *u, uint32_t tx_id)
338{ 353{
@@ -650,6 +665,7 @@ static int xenbus_file_open(struct inode *inode, struct file *filp)
650 INIT_LIST_HEAD(&u->watches); 665 INIT_LIST_HEAD(&u->watches);
651 INIT_LIST_HEAD(&u->read_buffers); 666 INIT_LIST_HEAD(&u->read_buffers);
652 init_waitqueue_head(&u->read_waitq); 667 init_waitqueue_head(&u->read_waitq);
668 INIT_WORK(&u->wq, xenbus_worker);
653 669
654 mutex_init(&u->reply_mutex); 670 mutex_init(&u->reply_mutex);
655 mutex_init(&u->msgbuffer_mutex); 671 mutex_init(&u->msgbuffer_mutex);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 98b30c1613b2..d89969aa9942 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -212,30 +212,7 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
212 212
213bool xen_running_on_version_or_later(unsigned int major, unsigned int minor); 213bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
214 214
215efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc); 215void xen_efi_runtime_setup(void);
216efi_status_t xen_efi_set_time(efi_time_t *tm);
217efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
218 efi_time_t *tm);
219efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
220efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
221 u32 *attr, unsigned long *data_size,
222 void *data);
223efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
224 efi_char16_t *name, efi_guid_t *vendor);
225efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
226 u32 attr, unsigned long data_size,
227 void *data);
228efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
229 u64 *remaining_space,
230 u64 *max_variable_size);
231efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
232efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
233 unsigned long count, unsigned long sg_list);
234efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
235 unsigned long count, u64 *max_size,
236 int *reset_type);
237void xen_efi_reset_system(int reset_type, efi_status_t status,
238 unsigned long data_size, efi_char16_t *data);
239 216
240 217
241#ifdef CONFIG_PREEMPT 218#ifdef CONFIG_PREEMPT