aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2018-09-04 19:26:54 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2018-09-04 19:26:54 +0000
commite21c5abc2a941c4b8ee2e434f5aea2dcdc7edb36 (patch)
treef6215f3936c406b2646a3e309c44dc15aa7f54cc
parent316086bd6c8be194ae394ae72fa3b70cf8899050 (diff)
downloadsrc-e21c5abc2a941c4b8ee2e434f5aea2dcdc7edb36.tar.gz
src-e21c5abc2a941c4b8ee2e434f5aea2dcdc7edb36.zip
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)
Notes
Notes: svn path=/head/; revision=338459
-rw-r--r--sys/amd64/amd64/pmap.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index cbd76aa48585..8cb09df626be 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -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);
}