diff options
author | Anton Blanchard <anton@samba.org> | 2011-08-10 16:44:24 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-09-20 01:53:23 -0400 |
commit | a11940978bd598e65996b4f807cf4904793f7025 (patch) | |
tree | 95a62b555abb28b0334f8eea8c856a3c0c0c5991 /arch | |
parent | dfbe93a222e74b6f96ad84eff2b04a0f864fac65 (diff) |
powerpc: Fix oops when echoing bad values to /sys/devices/system/memory/probe
If we echo an address the hypervisor doesn't like to
/sys/devices/system/memory/probe we oops the box:
# echo 0x10000000000 > /sys/devices/system/memory/probe
kernel BUG at arch/powerpc/mm/hash_utils_64.c:541!
The backtrace is:
create_section_mapping
arch_add_memory
add_memory
memory_probe_store
sysdev_class_store
sysfs_write_file
vfs_write
SyS_write
In create_section_mapping we BUG if htab_bolt_mapping returned
an error. A better approach is to return an error which will
propagate back to userspace.
Rerunning the test with this patch applied:
# echo 0x10000000000 > /sys/devices/system/memory/probe
-bash: echo: write error: Invalid argument
Signed-off-by: Anton Blanchard <anton@samba.org>
Cc: stable@kernel.org
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/sparsemem.h | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/hash_utils_64.c | 6 | ||||
-rw-r--r-- | arch/powerpc/mm/mem.c | 3 |
3 files changed, 6 insertions, 5 deletions
diff --git a/arch/powerpc/include/asm/sparsemem.h b/arch/powerpc/include/asm/sparsemem.h index 54a47ea2c3aa..0c5fa3145615 100644 --- a/arch/powerpc/include/asm/sparsemem.h +++ b/arch/powerpc/include/asm/sparsemem.h | |||
@@ -16,7 +16,7 @@ | |||
16 | #endif /* CONFIG_SPARSEMEM */ | 16 | #endif /* CONFIG_SPARSEMEM */ |
17 | 17 | ||
18 | #ifdef CONFIG_MEMORY_HOTPLUG | 18 | #ifdef CONFIG_MEMORY_HOTPLUG |
19 | extern void create_section_mapping(unsigned long start, unsigned long end); | 19 | extern int create_section_mapping(unsigned long start, unsigned long end); |
20 | extern int remove_section_mapping(unsigned long start, unsigned long end); | 20 | extern int remove_section_mapping(unsigned long start, unsigned long end); |
21 | #ifdef CONFIG_NUMA | 21 | #ifdef CONFIG_NUMA |
22 | extern int hot_add_scn_to_nid(unsigned long scn_addr); | 22 | extern int hot_add_scn_to_nid(unsigned long scn_addr); |
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 1f8b2a05e3d0..1628201c8cea 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c | |||
@@ -531,11 +531,11 @@ static unsigned long __init htab_get_table_size(void) | |||
531 | } | 531 | } |
532 | 532 | ||
533 | #ifdef CONFIG_MEMORY_HOTPLUG | 533 | #ifdef CONFIG_MEMORY_HOTPLUG |
534 | void create_section_mapping(unsigned long start, unsigned long end) | 534 | int create_section_mapping(unsigned long start, unsigned long end) |
535 | { | 535 | { |
536 | BUG_ON(htab_bolt_mapping(start, end, __pa(start), | 536 | return htab_bolt_mapping(start, end, __pa(start), |
537 | pgprot_val(PAGE_KERNEL), mmu_linear_psize, | 537 | pgprot_val(PAGE_KERNEL), mmu_linear_psize, |
538 | mmu_kernel_ssize)); | 538 | mmu_kernel_ssize); |
539 | } | 539 | } |
540 | 540 | ||
541 | int remove_section_mapping(unsigned long start, unsigned long end) | 541 | int remove_section_mapping(unsigned long start, unsigned long end) |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index ad9cf49dfb89..5db316cad47b 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -123,7 +123,8 @@ int arch_add_memory(int nid, u64 start, u64 size) | |||
123 | pgdata = NODE_DATA(nid); | 123 | pgdata = NODE_DATA(nid); |
124 | 124 | ||
125 | start = (unsigned long)__va(start); | 125 | start = (unsigned long)__va(start); |
126 | create_section_mapping(start, start + size); | 126 | if (create_section_mapping(start, start + size)) |
127 | return -EINVAL; | ||
127 | 128 | ||
128 | /* this should work for most non-highmem platforms */ | 129 | /* this should work for most non-highmem platforms */ |
129 | zone = pgdata->node_zones; | 130 | zone = pgdata->node_zones; |