summaryrefslogtreecommitdiff
path: root/sys/src/9/pc64/main.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-11-19 18:42:01 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-11-19 18:42:01 +0100
commit4dee686ca51e20634aa66c989dabbb1cf460e32b (patch)
tree70f6d5d2a679b579b31c81f2e4f8a8eedd275601 /sys/src/9/pc64/main.c
parentb04ed2ae522a0d2f97d8ac7e5f3276223112ebe8 (diff)
pc, pc64: park application processors in rebootcode with mmu off
instead of having application processors spin in mpshutdown() with mmu on, and be subject to reboot() overriding kernel text and modifying page tables, park the application processors in rebootcode idle loop with the mmu off.
Diffstat (limited to 'sys/src/9/pc64/main.c')
-rw-r--r--sys/src/9/pc64/main.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c
index fc1bfeb92..dd9e2d8f2 100644
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -336,18 +336,45 @@ main()
schedinit();
}
+static void
+rebootjump(uintptr entry, uintptr code, ulong size)
+{
+ void (*f)(uintptr, uintptr, ulong);
+
+ splhi();
+ arch->introff();
+
+ /*
+ * This allows the reboot code to turn off the page mapping
+ */
+ *mmuwalk(m->pml4, 0, 3, 0) = *mmuwalk(m->pml4, KZERO, 3, 0);
+ *mmuwalk(m->pml4, 0, 2, 0) = *mmuwalk(m->pml4, KZERO, 2, 0);
+ mmuflushtlb();
+
+ /* setup reboot trampoline function */
+ f = (void*)REBOOTADDR;
+ memmove(f, rebootcode, sizeof(rebootcode));
+
+ /* off we go - never to return */
+ coherence();
+ (*f)(entry, code, size);
+
+ for(;;);
+}
+
+
void
exit(int)
{
cpushutdown();
+ if(m->machno)
+ rebootjump(0, 0, 0);
arch->reset();
}
void
reboot(void *entry, void *code, ulong size)
{
- void (*f)(uintptr, uintptr, ulong);
-
writeconf();
vmxshutdown();
@@ -362,7 +389,7 @@ reboot(void *entry, void *code, ulong size)
sched();
}
cpushutdown();
-
+ delay(1000);
splhi();
/* turn off buffered serial console */
@@ -370,22 +397,8 @@ reboot(void *entry, void *code, ulong size)
/* shutdown devices */
chandevshutdown();
- arch->introff();
-
- /*
- * This allows the reboot code to turn off the page mapping
- */
- *mmuwalk(m->pml4, 0, 3, 0) = *mmuwalk(m->pml4, KZERO, 3, 0);
- *mmuwalk(m->pml4, 0, 2, 0) = *mmuwalk(m->pml4, KZERO, 2, 0);
- mmuflushtlb();
-
- /* setup reboot trampoline function */
- f = (void*)REBOOTADDR;
- memmove(f, rebootcode, sizeof(rebootcode));
- /* off we go - never to return */
- coherence();
- (*f)((uintptr)entry & ~0xF0000000UL, (uintptr)PADDR(code), size);
+ rebootjump((uintptr)entry & ~0xF0000000UL, PADDR(code), size);
}
/*