summaryrefslogtreecommitdiff
path: root/kern/percpu.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2014-09-05 23:15:53 +0200
committerRichard Braun <rbraun@sceen.net>2014-09-05 23:15:53 +0200
commite660f1900912a5a446e51f2ab095dd46ab123802 (patch)
treea0d53d986e0c1daf664ea221b6ad83f34c4ec58a /kern/percpu.c
parenteed59b8076e7668b5e0f874bd3ed28230f470bb1 (diff)
kern/percpu: fix setup of BSP percpu area
Relocating percpu data is actually tricky, for the same reason relocating memory in general is. There may be pointers to such variables which then become invalid. Instead, keep using the percpu section as the percpu area for the BSP and store the content of the percpu section in dedicated kernel virtual memory. In addition, remove the notification kludge from the x86 cpu module.
Diffstat (limited to 'kern/percpu.c')
-rw-r--r--kern/percpu.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/kern/percpu.c b/kern/percpu.c
index aab9d064..9a0bdf31 100644
--- a/kern/percpu.c
+++ b/kern/percpu.c
@@ -30,6 +30,7 @@
void *percpu_areas[MAX_CPUS] __read_mostly;
+static void *percpu_area_content __initdata;
static size_t percpu_size __initdata;
static int percpu_skip_warning __initdata;
@@ -55,11 +56,10 @@ percpu_setup(void)
va = vm_kmem_alloc(percpu_size);
if (va == 0)
- panic("percpu: unable to allocate percpu area for BSP");
+ panic("percpu: unable to allocate memory for percpu area content");
- percpu_areas[0] = (void *)va;
- memcpy(percpu_area(0), &_percpu, percpu_size);
- cpu_fixup_bsp_percpu_area();
+ percpu_area_content = (void *)va;
+ memcpy(percpu_area_content, &_percpu, percpu_size);
}
int __init
@@ -93,8 +93,14 @@ percpu_add(unsigned int cpu)
}
percpu_areas[cpu] = (void *)va;
- memcpy(percpu_area(cpu), &_percpu, percpu_size);
+ memcpy(percpu_area(cpu), percpu_area_content, percpu_size);
out:
return 0;
}
+
+void
+percpu_cleanup(void)
+{
+ vm_kmem_free((unsigned long)percpu_area_content, percpu_size);
+}