From 5d2fc474c59d3b58dd23f058306a016de70ff87f Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Mon, 21 Jul 2003 20:59:27 +0000 Subject: [PATCH] Commit Ian Dowse's workaround for acpi resume resetting after the LAZY_SWITCH changes. He pointed out the acpi code sets up an identity mapping in the current vmspace and that got messed up by the %cr3 being out of sync with the current page directory. As a workaround, restore %cr3 across the sleep/resume. A more complete fix would be to undo the lazy state and clear the pm_active bit from the borrowed pmap, but this works and people are currently hurting. I'll clean this up. This is mostly Ian's patch, plus a PAE tweak from me. --- sys/i386/acpica/acpi_wakeup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c index 81a396a5742..472438f8273 100644 --- a/sys/i386/acpica/acpi_wakeup.c +++ b/sys/i386/acpica/acpi_wakeup.c @@ -193,6 +193,7 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) static vm_page_t opage = NULL; int ret = 0; int pteobj_allocated = 0; + u_int32_t cr3; u_long ef; struct proc *p; @@ -209,6 +210,12 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) if ((p = curproc) == NULL) p = &proc0; pm = vmspace_pmap(p->p_vmspace); + cr3 = rcr3(); +#ifdef PAE + load_cr3(vtophys(pm->pm_pdpt)); +#else + load_cr3(vtophys(pm->pm_pdir)); +#endif if (pm->pm_pteobj == NULL) { pm->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI + 1); pteobj_allocated = 1; @@ -295,6 +302,7 @@ out: vm_object_deallocate(pm->pm_pteobj); pm->pm_pteobj = NULL; } + load_cr3(cr3); write_eflags(ef);