summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2019-02-14 05:42:40 -0500
committerJuergen Gross <jgross@suse.com>2019-02-18 00:52:51 -0500
commit1d988ed46543ca36c010634c97ac32114362ddb1 (patch)
treed135775178bd3a72aff42e7471dff7b8893cd487
parent357b4da50a62e2fd70eacee21cdbd22d4c7a7b60 (diff)
x86/xen: dont add memory above max allowed allocation
Don't allow memory to be added above the allowed maximum allocation limit set by Xen. Trying to do so would result in cases like the following: [ 584.559652] ------------[ cut here ]------------ [ 584.564897] WARNING: CPU: 2 PID: 1 at ../arch/x86/xen/multicalls.c:129 xen_alloc_pte+0x1c7/0x390() [ 584.575151] Modules linked in: [ 584.578643] Supported: Yes [ 584.581750] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.4.120-92.70-default #1 [ 584.590000] Hardware name: Cisco Systems Inc UCSC-C460-M4/UCSC-C460-M4, BIOS C460M4.4.0.1b.0.0629181419 06/29/2018 [ 584.601862] 0000000000000000 ffffffff813175a0 0000000000000000 ffffffff8184777c [ 584.610200] ffffffff8107f4e1 ffff880487eb7000 ffff8801862b79c0 ffff88048608d290 [ 584.618537] 0000000000487eb7 ffffea0000000201 ffffffff81009de7 ffffffff81068561 [ 584.626876] Call Trace: [ 584.629699] [<ffffffff81019ad9>] dump_trace+0x59/0x340 [ 584.635645] [<ffffffff81019eaa>] show_stack_log_lvl+0xea/0x170 [ 584.642391] [<ffffffff8101ac51>] show_stack+0x21/0x40 [ 584.648238] [<ffffffff813175a0>] dump_stack+0x5c/0x7c [ 584.654085] [<ffffffff8107f4e1>] warn_slowpath_common+0x81/0xb0 [ 584.660932] [<ffffffff81009de7>] xen_alloc_pte+0x1c7/0x390 [ 584.667289] [<ffffffff810647f0>] pmd_populate_kernel.constprop.6+0x40/0x80 [ 584.675241] [<ffffffff815ecfe8>] phys_pmd_init+0x210/0x255 [ 584.681587] [<ffffffff815ed207>] phys_pud_init+0x1da/0x247 [ 584.687931] [<ffffffff815edb3b>] kernel_physical_mapping_init+0xf5/0x1d4 [ 584.695682] [<ffffffff815e9bdd>] init_memory_mapping+0x18d/0x380 [ 584.702631] [<ffffffff81064699>] arch_add_memory+0x59/0xf0 Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Juergen Gross <jgross@suse.com>
-rw-r--r--arch/x86/xen/setup.c13
-rw-r--r--drivers/xen/xen-balloon.c11
-rw-r--r--include/xen/xen.h4
3 files changed, 28 insertions, 0 deletions
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index d5f303c0e656..548d1e0a5ba1 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -12,6 +12,7 @@
12#include <linux/memblock.h> 12#include <linux/memblock.h>
13#include <linux/cpuidle.h> 13#include <linux/cpuidle.h>
14#include <linux/cpufreq.h> 14#include <linux/cpufreq.h>
15#include <linux/memory_hotplug.h>
15 16
16#include <asm/elf.h> 17#include <asm/elf.h>
17#include <asm/vdso.h> 18#include <asm/vdso.h>
@@ -589,6 +590,14 @@ static void __init xen_align_and_add_e820_region(phys_addr_t start,
589 if (type == E820_TYPE_RAM) { 590 if (type == E820_TYPE_RAM) {
590 start = PAGE_ALIGN(start); 591 start = PAGE_ALIGN(start);
591 end &= ~((phys_addr_t)PAGE_SIZE - 1); 592 end &= ~((phys_addr_t)PAGE_SIZE - 1);
593#ifdef CONFIG_MEMORY_HOTPLUG
594 /*
595 * Don't allow adding memory not in E820 map while booting the
596 * system. Once the balloon driver is up it will remove that
597 * restriction again.
598 */
599 max_mem_size = end;
600#endif
592 } 601 }
593 602
594 e820__range_add(start, end - start, type); 603 e820__range_add(start, end - start, type);
@@ -748,6 +757,10 @@ char * __init xen_memory_setup(void)
748 memmap.nr_entries = ARRAY_SIZE(xen_e820_table.entries); 757 memmap.nr_entries = ARRAY_SIZE(xen_e820_table.entries);
749 set_xen_guest_handle(memmap.buffer, xen_e820_table.entries); 758 set_xen_guest_handle(memmap.buffer, xen_e820_table.entries);
750 759
760#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON)
761 xen_saved_max_mem_size = max_mem_size;
762#endif
763
751 op = xen_initial_domain() ? 764 op = xen_initial_domain() ?
752 XENMEM_machine_memory_map : 765 XENMEM_machine_memory_map :
753 XENMEM_memory_map; 766 XENMEM_memory_map;
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c
index 2acbfe104e46..a67236b02452 100644
--- a/drivers/xen/xen-balloon.c
+++ b/drivers/xen/xen-balloon.c
@@ -37,6 +37,7 @@
37#include <linux/mm_types.h> 37#include <linux/mm_types.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/capability.h> 39#include <linux/capability.h>
40#include <linux/memory_hotplug.h>
40 41
41#include <xen/xen.h> 42#include <xen/xen.h>
42#include <xen/interface/xen.h> 43#include <xen/interface/xen.h>
@@ -50,6 +51,10 @@
50 51
51#define BALLOON_CLASS_NAME "xen_memory" 52#define BALLOON_CLASS_NAME "xen_memory"
52 53
54#ifdef CONFIG_MEMORY_HOTPLUG
55u64 xen_saved_max_mem_size = 0;
56#endif
57
53static struct device balloon_dev; 58static struct device balloon_dev;
54 59
55static int register_balloon(struct device *dev); 60static int register_balloon(struct device *dev);
@@ -63,6 +68,12 @@ static void watch_target(struct xenbus_watch *watch,
63 static bool watch_fired; 68 static bool watch_fired;
64 static long target_diff; 69 static long target_diff;
65 70
71#ifdef CONFIG_MEMORY_HOTPLUG
72 /* The balloon driver will take care of adding memory now. */
73 if (xen_saved_max_mem_size)
74 max_mem_size = xen_saved_max_mem_size;
75#endif
76
66 err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target); 77 err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target);
67 if (err != 1) { 78 if (err != 1) {
68 /* This is ok (for domain0 at least) - so just return */ 79 /* This is ok (for domain0 at least) - so just return */
diff --git a/include/xen/xen.h b/include/xen/xen.h
index 0e2156786ad2..19d032373de5 100644
--- a/include/xen/xen.h
+++ b/include/xen/xen.h
@@ -46,4 +46,8 @@ struct bio_vec;
46bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, 46bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
47 const struct bio_vec *vec2); 47 const struct bio_vec *vec2);
48 48
49#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON)
50extern u64 xen_saved_max_mem_size;
51#endif
52
49#endif /* _XEN_XEN_H */ 53#endif /* _XEN_XEN_H */