Date: Tue, 4 Sep 2018 19:26:54 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338459 - head/sys/amd64/amd64 Message-ID: <201809041926.w84JQsun077719@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue Sep 4 19:26:54 2018 New Revision: 338459 URL: https://svnweb.freebsd.org/changeset/base/338459 Log: amd64: For non-PTI mode, do not initialize PCPU kcr3 to KPML4phys. Non-PTI mode does not switch kcr3, which means that kcr3 is almost always stale. This is important for the NMI handler, which reloads %cr3 with PCPU(kcr3) if the value is different from PMAP_NO_CR3. The end result is that curpmap in NMI handler does not match the page table loaded into hardware. The manifestation was copyin(9) looping forever when a usermode access page fault cannot be resolved by vm_fault() updating a different page table. Reported by: mmacy Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 3 days Approved by: re (gjb) Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Tue Sep 4 19:22:31 2018 (r338458) +++ head/sys/amd64/amd64/pmap.c Tue Sep 4 19:26:54 2018 (r338459) @@ -7582,9 +7582,13 @@ pmap_activate_boot(pmap_t pmap) CPU_SET(cpuid, &pmap->pm_active); #endif PCPU_SET(curpmap, pmap); - kcr3 = pmap->pm_cr3; - if (pmap_pcid_enabled) - kcr3 |= pmap->pm_pcids[cpuid].pm_pcid | CR3_PCID_SAVE; + if (pti) { + kcr3 = pmap->pm_cr3; + if (pmap_pcid_enabled) + kcr3 |= pmap->pm_pcids[cpuid].pm_pcid | CR3_PCID_SAVE; + } else { + kcr3 = PMAP_NO_CR3; + } PCPU_SET(kcr3, kcr3); PCPU_SET(ucr3, PMAP_NO_CR3); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809041926.w84JQsun077719>