* [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM
@ 2016-06-20 7:33 Yigal Korman
2016-06-20 14:44 ` Dan Williams
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yigal Korman @ 2016-06-20 7:33 UTC (permalink / raw)
To: tglx, mingo, hpa, x86, linux-kernel
Cc: linux-nvdimm, dan.j.williams, elliott, jmoyer, toshi.kani, Yigal Korman
Before this patch, passing a range that is beyond the physical memory
range will succeed, the user will see a /dev/pmem0 and will be able to
access it. Reads will always return 0 and writes will be silently
ignored.
I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml
failing that were eventually tracked down to be wrong values passed to
memmap.
This patch prevents the above issue by instead of adding a new memory
range, only update a RAM memory range with the PRAM type. This way,
passing the wrong memmap will either not give you a pmem at all or give
you a smaller one that actually has RAM behind it.
And if someone still needs to fake a pmem that doesn't have RAM behind
it, they can simply do memmap=XX@YY,XX!YY.
Signed-off-by: Yigal Korman <yigal@plexistor.com>
---
arch/x86/kernel/e820.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 621b501..4bd4207 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -878,7 +878,7 @@ static int __init parse_memmap_one(char *p)
e820_add_region(start_at, mem_size, E820_RESERVED);
} else if (*p == '!') {
start_at = memparse(p+1, &p);
- e820_add_region(start_at, mem_size, E820_PRAM);
+ e820_update_range(start_at, mem_size, E820_RAM, E820_PRAM);
} else
e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM
2016-06-20 7:33 [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM Yigal Korman
@ 2016-06-20 14:44 ` Dan Williams
2016-06-21 12:56 ` Johannes Thumshirn
2016-06-23 11:52 ` Boaz Harrosh
2 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2016-06-20 14:44 UTC (permalink / raw)
To: Yigal Korman
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, X86 ML,
linux-kernel, linux-nvdimm@lists.01.org, Elliott,
Robert (Persistent Memory),
jmoyer, Toshi Kani
On Mon, Jun 20, 2016 at 12:33 AM, Yigal Korman <yigal@plexistor.com> wrote:
> Before this patch, passing a range that is beyond the physical memory
> range will succeed, the user will see a /dev/pmem0 and will be able to
> access it. Reads will always return 0 and writes will be silently
> ignored.
>
> I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml
> failing that were eventually tracked down to be wrong values passed to
> memmap.
>
> This patch prevents the above issue by instead of adding a new memory
> range, only update a RAM memory range with the PRAM type. This way,
> passing the wrong memmap will either not give you a pmem at all or give
> you a smaller one that actually has RAM behind it.
>
> And if someone still needs to fake a pmem that doesn't have RAM behind
> it, they can simply do memmap=XX@YY,XX!YY.
>
> Signed-off-by: Yigal Korman <yigal@plexistor.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM
2016-06-20 7:33 [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM Yigal Korman
2016-06-20 14:44 ` Dan Williams
@ 2016-06-21 12:56 ` Johannes Thumshirn
2016-06-23 11:52 ` Boaz Harrosh
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2016-06-21 12:56 UTC (permalink / raw)
To: Yigal Korman; +Cc: tglx, mingo, hpa, x86, linux-kernel, linux-nvdimm
On Mon, Jun 20, 2016 at 10:33:59AM +0300, Yigal Korman wrote:
> Before this patch, passing a range that is beyond the physical memory
> range will succeed, the user will see a /dev/pmem0 and will be able to
> access it. Reads will always return 0 and writes will be silently
> ignored.
>
> I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml
> failing that were eventually tracked down to be wrong values passed to
> memmap.
>
> This patch prevents the above issue by instead of adding a new memory
> range, only update a RAM memory range with the PRAM type. This way,
> passing the wrong memmap will either not give you a pmem at all or give
> you a smaller one that actually has RAM behind it.
>
> And if someone still needs to fake a pmem that doesn't have RAM behind
> it, they can simply do memmap=XX@YY,XX!YY.
>
> Signed-off-by: Yigal Korman <yigal@plexistor.com>
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM
2016-06-20 7:33 [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM Yigal Korman
2016-06-20 14:44 ` Dan Williams
2016-06-21 12:56 ` Johannes Thumshirn
@ 2016-06-23 11:52 ` Boaz Harrosh
2 siblings, 0 replies; 4+ messages in thread
From: Boaz Harrosh @ 2016-06-23 11:52 UTC (permalink / raw)
To: Yigal Korman, tglx, mingo, hpa, x86, linux-kernel; +Cc: linux-nvdimm
On 06/20/2016 10:33 AM, Yigal Korman wrote:
> Before this patch, passing a range that is beyond the physical memory
> range will succeed, the user will see a /dev/pmem0 and will be able to
> access it. Reads will always return 0 and writes will be silently
> ignored.
>
> I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml
> failing that were eventually tracked down to be wrong values passed to
> memmap.
>
> This patch prevents the above issue by instead of adding a new memory
> range, only update a RAM memory range with the PRAM type. This way,
> passing the wrong memmap will either not give you a pmem at all or give
> you a smaller one that actually has RAM behind it.
>
> And if someone still needs to fake a pmem that doesn't have RAM behind
> it, they can simply do memmap=XX@YY,XX!YY.
>
We are running with this patch for a while in the lab and it does
solve the problem above with no maleffects so:
Tested-by: Boaz Harrosh <boaz@plexistor.com>
> Signed-off-by: Yigal Korman <yigal@plexistor.com>
> ---
> arch/x86/kernel/e820.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index 621b501..4bd4207 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -878,7 +878,7 @@ static int __init parse_memmap_one(char *p)
> e820_add_region(start_at, mem_size, E820_RESERVED);
> } else if (*p == '!') {
> start_at = memparse(p+1, &p);
> - e820_add_region(start_at, mem_size, E820_PRAM);
> + e820_update_range(start_at, mem_size, E820_RAM, E820_PRAM);
> } else
> e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-23 11:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20 7:33 [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM Yigal Korman
2016-06-20 14:44 ` Dan Williams
2016-06-21 12:56 ` Johannes Thumshirn
2016-06-23 11:52 ` Boaz Harrosh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).