* [PATCH] memory hotplug: Refuse to add unaligned memory regions
@ 2011-09-14 20:26 Anton Blanchard
2011-09-15 6:35 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Anton Blanchard @ 2011-09-14 20:26 UTC (permalink / raw)
To: gregkh, nfont; +Cc: linuxppc-dev, linux-kernel
The sysfs memory probe interface allows unaligned regions
to be added:
# echo 0xffffff > /sys/devices/system/memory/probe
# cat /proc/iomem
00ffffff-01fffffe : System RAM
01ffffff-02fffffe : System RAM
02ffffff-03fffffe : System RAM
03ffffff-04fffffe : System RAM
04ffffff-05fffffe : System RAM
Return -EINVAL instead of creating these bad regions.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
Index: linux-build/drivers/base/memory.c
===================================================================
--- linux-build.orig/drivers/base/memory.c 2011-08-11 08:25:55.005941391 +1000
+++ linux-build/drivers/base/memory.c 2011-08-11 08:28:27.938580440 +1000
@@ -380,9 +380,13 @@ memory_probe_store(struct class *class,
u64 phys_addr;
int nid;
int i, ret;
+ unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;
phys_addr = simple_strtoull(buf, NULL, 0);
+ if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
+ return -EINVAL;
+
for (i = 0; i < sections_per_block; i++) {
nid = memory_add_physaddr_to_nid(phys_addr);
ret = add_memory(nid, phys_addr,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory hotplug: Refuse to add unaligned memory regions
2011-09-14 20:26 [PATCH] memory hotplug: Refuse to add unaligned memory regions Anton Blanchard
@ 2011-09-15 6:35 ` Greg KH
2011-09-15 7:58 ` Andrew Morton
2011-11-09 7:28 ` Chen Gong
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-09-15 6:35 UTC (permalink / raw)
To: Anton Blanchard; +Cc: linuxppc-dev, linux-kernel
On Thu, Sep 15, 2011 at 06:26:15AM +1000, Anton Blanchard wrote:
>
> The sysfs memory probe interface allows unaligned regions
> to be added:
>
> # echo 0xffffff > /sys/devices/system/memory/probe
>
> # cat /proc/iomem
> 00ffffff-01fffffe : System RAM
> 01ffffff-02fffffe : System RAM
> 02ffffff-03fffffe : System RAM
> 03ffffff-04fffffe : System RAM
> 04ffffff-05fffffe : System RAM
>
> Return -EINVAL instead of creating these bad regions.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
Is this something that should go into 3.1 and older kernels to properly
handle this type of error?
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory hotplug: Refuse to add unaligned memory regions
2011-09-14 20:26 [PATCH] memory hotplug: Refuse to add unaligned memory regions Anton Blanchard
2011-09-15 6:35 ` Greg KH
@ 2011-09-15 7:58 ` Andrew Morton
2011-11-09 7:28 ` Chen Gong
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2011-09-15 7:58 UTC (permalink / raw)
To: Anton Blanchard; +Cc: gregkh, linuxppc-dev, linux-kernel
On Thu, 15 Sep 2011 06:26:15 +1000 Anton Blanchard <anton@samba.org> wrote:
>
> The sysfs memory probe interface allows unaligned regions
> to be added:
>
> # echo 0xffffff > /sys/devices/system/memory/probe
>
> # cat /proc/iomem
> 00ffffff-01fffffe : System RAM
> 01ffffff-02fffffe : System RAM
> 02ffffff-03fffffe : System RAM
> 03ffffff-04fffffe : System RAM
> 04ffffff-05fffffe : System RAM
Then don't do that?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory hotplug: Refuse to add unaligned memory regions
2011-09-14 20:26 [PATCH] memory hotplug: Refuse to add unaligned memory regions Anton Blanchard
2011-09-15 6:35 ` Greg KH
2011-09-15 7:58 ` Andrew Morton
@ 2011-11-09 7:28 ` Chen Gong
2 siblings, 0 replies; 4+ messages in thread
From: Chen Gong @ 2011-11-09 7:28 UTC (permalink / raw)
To: Anton Blanchard; +Cc: gregkh, linuxppc-dev, linux-kernel
于 2011/9/15 4:26, Anton Blanchard 写道:
>
> The sysfs memory probe interface allows unaligned regions
> to be added:
>
> # echo 0xffffff> /sys/devices/system/memory/probe
>
> # cat /proc/iomem
> 00ffffff-01fffffe : System RAM
> 01ffffff-02fffffe : System RAM
> 02ffffff-03fffffe : System RAM
> 03ffffff-04fffffe : System RAM
> 04ffffff-05fffffe : System RAM
>
> Return -EINVAL instead of creating these bad regions.
>
> Signed-off-by: Anton Blanchard<anton@samba.org>
> ---
>
> Index: linux-build/drivers/base/memory.c
> ===================================================================
> --- linux-build.orig/drivers/base/memory.c 2011-08-11 08:25:55.005941391 +1000
> +++ linux-build/drivers/base/memory.c 2011-08-11 08:28:27.938580440 +1000
> @@ -380,9 +380,13 @@ memory_probe_store(struct class *class,
> u64 phys_addr;
> int nid;
> int i, ret;
> + unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;
>
> phys_addr = simple_strtoull(buf, NULL, 0);
>
> + if (phys_addr& ((pages_per_block<< PAGE_SHIFT) - 1))
> + return -EINVAL;
> +
> for (i = 0; i< sections_per_block; i++) {
> nid = memory_add_physaddr_to_nid(phys_addr);
> ret = add_memory(nid, phys_addr,
> --
what platform doese it affect? PowerPC or else?
As I know, on x86 platform it should not use this interface: *probe*,
instead of acpi_hotplug_xxx. But PowerPC is RISC so how can you add
such weird address for it? Maybe it is because PowerPC uses 16M as
one section size and you assign a wrong address to it intentionally.
The final result is as you show, isn't it?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-09 7:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-14 20:26 [PATCH] memory hotplug: Refuse to add unaligned memory regions Anton Blanchard
2011-09-15 6:35 ` Greg KH
2011-09-15 7:58 ` Andrew Morton
2011-11-09 7:28 ` Chen Gong
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).