Home Home > GIT Browse > SLE12-SP3-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2019-02-18 09:24:52 +0100
committerJuergen Gross <jgross@suse.com>2019-02-18 09:25:38 +0100
commit8da491ba457b27b186020cd6c2525fb10cc73bcd (patch)
treed286f434dbda44f871fb1c07a6f387591817788f
parentbd8264a92268bb2d070427f37ae5727997298810 (diff)
x86: respect memory size limiting via mem= parameter
(bsc#1117645).
-rw-r--r--patches.fixes/0001-x86-respect-memory-size-limiting-via-mem-paramete.patch109
-rw-r--r--series.conf1
2 files changed, 110 insertions, 0 deletions
diff --git a/patches.fixes/0001-x86-respect-memory-size-limiting-via-mem-paramete.patch b/patches.fixes/0001-x86-respect-memory-size-limiting-via-mem-paramete.patch
new file mode 100644
index 0000000000..ae0250d205
--- /dev/null
+++ b/patches.fixes/0001-x86-respect-memory-size-limiting-via-mem-paramete.patch
@@ -0,0 +1,109 @@
+From: Juergen Gross <jgross@suse.com>
+Date: Mon, 21 Jan 2019 11:26:02 +0100
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git
+Git-commit: 357b4da50a62e2fd70eacee21cdbd22d4c7a7b60
+References: bsc#1117645
+Subject: x86: respect memory size limiting via mem= parameter
+
+When limiting memory size via kernel parameter "mem=" this should be
+respected even in case of memory made accessible via a PCI card.
+
+Today this kind of memory won't be made usable in initial memory
+setup as the memory won't be visible in E820 map, but it might be
+added when adding PCI devices due to corresponding ACPI table entries.
+
+Not respecting "mem=" can be corrected by adding a global max_mem_size
+variable set by parse_memopt() which will result in rejecting adding
+memory areas resulting in a memory size above the allowed limit.
+
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Acked-by: Ingo Molnar <mingo@kernel.org>
+Reviewed-by: William Kucharski <william.kucharski@oracle.com>
+Signed-off-by: Juergen Gross <jgross@suse.com>
+---
+ arch/x86/kernel/e820.c | 5 +++++
+ include/linux/memory_hotplug.h | 2 ++
+ mm/memory_hotplug.c | 6 ++++++
+ 3 files changed, 13 insertions(+)
+
+diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
+index 50895c2f937d..e67513e2cbbb 100644
+--- a/arch/x86/kernel/e820.c
++++ b/arch/x86/kernel/e820.c
+@@ -20,6 +20,7 @@
+ #include <linux/firmware-map.h>
+ #include <linux/memblock.h>
+ #include <linux/sort.h>
++#include <linux/memory_hotplug.h>
+
+ #include <asm/e820.h>
+ #include <asm/proto.h>
+@@ -831,6 +832,10 @@ static int __init parse_memopt(char *p)
+ return -EINVAL;
+ e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
+
++#ifdef CONFIG_MEMORY_HOTPLUG
++ max_mem_size = mem_size;
++#endif
++
+ return 0;
+ }
+ early_param("mem", parse_memopt);
+diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
+index 07da5c6c5ba0..fb6bd0022d41 100644
+--- a/include/linux/memory_hotplug.h
++++ b/include/linux/memory_hotplug.h
+@@ -100,6 +100,8 @@ extern void __online_page_free(struct page *page);
+
+ extern int try_online_node(int nid);
+
++extern u64 max_mem_size;
++
+ #ifdef CONFIG_MEMORY_HOTREMOVE
+ extern bool is_pageblock_removable_nolock(struct page *page);
+ extern int arch_remove_memory(u64 start, u64 size);
+diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
+index b9a667d36c55..94f81c596151 100644
+--- a/mm/memory_hotplug.c
++++ b/mm/memory_hotplug.c
+@@ -128,10 +128,16 @@ void mem_hotplug_done(void)
+ memhp_lock_release();
+ }
+
++u64 max_mem_size = U64_MAX;
++
+ /* add this memory to iomem resource */
+ static struct resource *register_memory_resource(u64 start, u64 size)
+ {
+ struct resource *res;
++
++ if (start + size > max_mem_size)
++ return ERR_PTR(-E2BIG);
++
+ res = kzalloc(sizeof(struct resource), GFP_KERNEL);
+ BUG_ON(!res);
+
+@@ -148,7 +154,7 @@ void mem_hotplug_done(void)
+ if (request_resource(&iomem_resource, res) < 0) {
+ pr_debug("System RAM resource %pR cannot be added\n", res);
+ kfree(res);
+- res = NULL;
++ res = ERR_PTR(-EEXIST);
+ }
+ return res;
+ }
+@@ -1359,8 +1365,8 @@ int __ref add_memory(int nid, u64 start, u64 size)
+ int ret;
+
+ res = register_memory_resource(start, size);
+- if (!res)
+- return -EEXIST;
++ if (IS_ERR(res))
++ return PTR_ERR(res);
+
+ ret = add_memory_resource(nid, res);
+ if (ret < 0)
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 08dc52d312..f666dfc4cb 100644
--- a/series.conf
+++ b/series.conf
@@ -24678,6 +24678,7 @@
# Xen
patches.fixes/xen-hold-lock_device_hotplug-throughout-vcpu-hotplug.patch
patches.fixes/xen-netback-dont-overflow-meta-array.patch
+ patches.fixes/0001-x86-respect-memory-size-limiting-via-mem-paramete.patch
# bsc#1025461 - Slow throughput on SLES 12 SP2 compared to SLES 11 SP3
patches.fixes/0001-smartpqi-limit-transfer-length-to-1MB.patch