Confusion in acpi_sleep_machdep().

Ian Dowse iedowse at
Mon Jan 1 18:46:50 PST 2007

In message <200612312043.kBVKhi7t095666 at>, Matthew Dillon w
>    I'm trying to figure out how the acpi_sleep_machdep() code works and
>    there are a couple of lines I just don't understand:
>        pm = vmspace_pmap(p->p_vmspace);
>        cr3 = rcr3();
>#ifdef PAE
>        load_cr3(vtophys(pm->pm_pdpt));
>        load_cr3(vtophys(pm->pm_pdir));
>        page = PHYS_TO_VM_PAGE(sc->acpi_wakephys);
>        pmap_enter(pm, sc->acpi_wakephys, page,
>                   VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, 1);
>    First, why isn't it just using kernel_pmap ?  What's all the load_cr3()
>    stuff for ?
>    Second, why is it entering the physical address sc->acpi_wakephys
>    as the virtual address in the pmap ?  Shouldn't it be using
>    sc->acpi_wakeaddr there?
>    Anybody know ?

I don't know the details, but acpi_sleep_machdep() sets up an
identity mapping in the current process's vmspace (hence using
virtual = physical). Lazy switching of address spaces means that
cr3 may not currently refer to the same vmspace, which would break
the identity mapping, so that's the reason for the load_cr3() calls.
See revision 1.22 for a bit more information.


More information about the freebsd-hackers mailing list