public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba•org>
To: benh@kernel•crashing.org, paulus@samba•org, sfr@ozlabs•org,
	nfont@austin•ibm.com
Cc: linuxppc-dev@lists•ozlabs.org
Subject: [PATCH 4/4] powerpc: Fix oops when echoing bad values to /sys/devices/system/memory/probe
Date: Thu, 11 Aug 2011 16:44:24 +1000	[thread overview]
Message-ID: <20110811064427.775019703@samba.org> (raw)
In-Reply-To: 20110811064427.515781037@samba.org

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
---

Index: linux-build/arch/powerpc/mm/hash_utils_64.c
===================================================================
--- linux-build.orig/arch/powerpc/mm/hash_utils_64.c	2011-08-10 17:00:42.603007554 +1000
+++ linux-build/arch/powerpc/mm/hash_utils_64.c	2011-08-10 17:05:56.338457482 +1000
@@ -534,11 +534,11 @@ static unsigned long __init htab_get_tab
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-void create_section_mapping(unsigned long start, unsigned long end)
+int create_section_mapping(unsigned long start, unsigned long end)
 {
-	BUG_ON(htab_bolt_mapping(start, end, __pa(start),
+	return htab_bolt_mapping(start, end, __pa(start),
 				 pgprot_val(PAGE_KERNEL), mmu_linear_psize,
-				 mmu_kernel_ssize));
+				 mmu_kernel_ssize);
 }
 
 int remove_section_mapping(unsigned long start, unsigned long end)
Index: linux-build/arch/powerpc/include/asm/sparsemem.h
===================================================================
--- linux-build.orig/arch/powerpc/include/asm/sparsemem.h	2011-08-10 17:06:11.948728948 +1000
+++ linux-build/arch/powerpc/include/asm/sparsemem.h	2011-08-10 17:06:21.878901648 +1000
@@ -16,7 +16,7 @@
 #endif /* CONFIG_SPARSEMEM */
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-extern void create_section_mapping(unsigned long start, unsigned long end);
+extern int create_section_mapping(unsigned long start, unsigned long end);
 extern int remove_section_mapping(unsigned long start, unsigned long end);
 #ifdef CONFIG_NUMA
 extern int hot_add_scn_to_nid(unsigned long scn_addr);
Index: linux-build/arch/powerpc/mm/mem.c
===================================================================
--- linux-build.orig/arch/powerpc/mm/mem.c	2011-08-10 17:06:42.539260996 +1000
+++ linux-build/arch/powerpc/mm/mem.c	2011-08-10 17:06:45.269308484 +1000
@@ -123,7 +123,8 @@ int arch_add_memory(int nid, u64 start,
 	pgdata = NODE_DATA(nid);
 
 	start = (unsigned long)__va(start);
-	create_section_mapping(start, start + size);
+	if (create_section_mapping(start, start + size))
+		return -EINVAL;
 
 	/* this should work for most non-highmem platforms */
 	zone = pgdata->node_zones;

      parent reply	other threads:[~2011-08-11  6:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11  6:44 [PATCH 1/4] [PATCH] powerpc: numa: Remove double of_node_put in hot_add_node_scn_to_nid Anton Blanchard
2011-08-11  6:44 ` [PATCH 2/4] [PATCH] powerpc: Use for_each_node_by_type instead of open coding it Anton Blanchard
2011-08-11  6:44 ` [PATCH 3/4] [PATCH] powerpc: Coding style cleanups Anton Blanchard
2011-08-11  6:44 ` Anton Blanchard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110811064427.775019703@samba.org \
    --to=anton@samba$(echo .)org \
    --cc=benh@kernel$(echo .)crashing.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=nfont@austin$(echo .)ibm.com \
    --cc=paulus@samba$(echo .)org \
    --cc=sfr@ozlabs$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox