Skip to content

Commit 94e1cdd

Browse files
committed
amd64: fix TLB invalidation for larger pages
don't trunc_page() the va given to smp_masked_invlpg(). assert that the va is already aligned correctly. fix stride for for TLB range invalidation "invlrng" IPI handlers.
1 parent ab1d95a commit 94e1cdd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sys/amd64/amd64/mp_machdep.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ void
703703
smp_masked_invlpg(vm_offset_t addr, pmap_t pmap, smp_invl_cb_t curcpu_cb)
704704
{
705705
if (invlpgb_works && pmap == kernel_pmap) {
706-
invlpgb(INVLPGB_GLOB | INVLPGB_VA | trunc_page(addr), 0, 0);
706+
KASSERT((addr & PAGE_MASK_PT) == 0, ("unaligned va 0x%lx", addr));
707+
invlpgb(INVLPGB_GLOB | INVLPGB_VA | addr, 0, 0);
707708
tlbsync();
708709
sched_unpin();
709710
return;
@@ -939,7 +940,7 @@ invlrng_handler(vm_offset_t smp_tlb_addr1, vm_offset_t smp_tlb_addr2)
939940
addr = smp_tlb_addr1;
940941
do {
941942
invlpg(addr);
942-
addr += PAGE_SIZE;
943+
addr += PAGE_SIZE_PT;
943944
} while (addr < smp_tlb_addr2);
944945
}
945946

@@ -965,7 +966,7 @@ invlrng_invpcid_handler(pmap_t smp_tlb_pmap, vm_offset_t smp_tlb_addr1,
965966
} else {
966967
do {
967968
invlpg(addr);
968-
addr += PAGE_SIZE;
969+
addr += PAGE_SIZE_PT;
969970
} while (addr < smp_tlb_addr2);
970971
}
971972
if (smp_tlb_pmap == PCPU_GET(curpmap) &&
@@ -976,7 +977,7 @@ invlrng_invpcid_handler(pmap_t smp_tlb_pmap, vm_offset_t smp_tlb_addr1,
976977
d.addr = smp_tlb_addr1;
977978
do {
978979
invpcid(&d, INVPCID_ADDR);
979-
d.addr += PAGE_SIZE;
980+
d.addr += PAGE_SIZE_PT;
980981
} while (d.addr < smp_tlb_addr2);
981982
}
982983
}
@@ -999,7 +1000,7 @@ invlrng_pcid_handler(pmap_t smp_tlb_pmap, vm_offset_t smp_tlb_addr1,
9991000
addr = smp_tlb_addr1;
10001001
do {
10011002
invlpg(addr);
1002-
addr += PAGE_SIZE;
1003+
addr += PAGE_SIZE_PT;
10031004
} while (addr < smp_tlb_addr2);
10041005
if (smp_tlb_pmap == PCPU_GET(curpmap) &&
10051006
(ucr3 = smp_tlb_pmap->pm_ucr3) != PMAP_NO_CR3 &&

0 commit comments

Comments
 (0)