Subject: module: simplify per-cpu handling a little

Instead of diverting the percpu symbols inside simplify_symbol, just
store the allocated percpu pointer in .sh_addr like every other
address.

This means we need a pointer to the original copy of the section,
which we keep in load_info.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 kernel/module.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -117,6 +117,7 @@ struct load_info {
 	char *secstrings, *strtab;
 	unsigned long *strmap;
 	unsigned long symoffs, stroffs;
+	void *orig_percpu;
 	struct {
 		unsigned int sym, str, mod, vers, info, pcpu;
 	} index;
@@ -1676,11 +1677,7 @@ static int simplify_symbols(struct modul
 			break;
 
 		default:
-			/* Divert to percpu allocation if a percpu var. */
-			if (sym[i].st_shndx == info->index.pcpu)
-				secbase = (unsigned long)mod_percpu(mod);
-			else
-				secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
+			secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
 			sym[i].st_value += secbase;
 			break;
 		}
@@ -2464,6 +2461,8 @@ static struct module *layout_and_allocat
 		if (err)
 			goto out;
 		pcpusec->sh_flags &= ~(unsigned long)SHF_ALLOC;
+		info->orig_percpu = (void *)pcpusec->sh_addr;
+		pcpusec->sh_addr = (unsigned long)mod_percpu(mod);
 	}
 
 	/* Determine total sizes, and put offsets in sh_entsize.  For now
@@ -2558,8 +2557,7 @@ static noinline struct module *load_modu
 	sort_extable(mod->extable, mod->extable + mod->num_exentries);
 
 	/* Finally, copy percpu area over. */
-	percpu_modcopy(mod, (void *)info.sechdrs[info.index.pcpu].sh_addr,
-		       info.sechdrs[info.index.pcpu].sh_size);
+	percpu_modcopy(mod, info.orig_percpu, mod->percpu_size);
 
 	add_kallsyms(mod, &info);
 
