Skip to content

Commit 231d755

Browse files
committed
Move INVLPG to pmap_quick_enter_page() from pmap_quick_remove_page().
If processor prefetches neighboring TLB entries to the one being accessed (as some have been reported to do), then the spin lock does not prevent the situation described in the "AMD64 Architecture Programmer's Manual Volume 2: System Programming" rev. 3.23, "7.3.1 Special Coherency Considerations". Reported and reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37770
1 parent cde70e3 commit 231d755

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

sys/amd64/amd64/pmap.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -10423,6 +10423,13 @@ pmap_quick_enter_page(vm_page_t m)
1042310423
return (PHYS_TO_DMAP(paddr));
1042410424
mtx_lock_spin(&qframe_mtx);
1042510425
KASSERT(*vtopte(qframe) == 0, ("qframe busy"));
10426+
10427+
/*
10428+
* Since qframe is exclusively mapped by us, and we do not set
10429+
* PG_G, we can use INVLPG here.
10430+
*/
10431+
invlpg(qframe);
10432+
1042610433
pte_store(vtopte(qframe), paddr | X86_PG_RW | X86_PG_V | X86_PG_A |
1042710434
X86_PG_M | pmap_cache_bits(kernel_pmap, m->md.pat_mode, 0));
1042810435
return (qframe);
@@ -10435,14 +10442,6 @@ pmap_quick_remove_page(vm_offset_t addr)
1043510442
if (addr != qframe)
1043610443
return;
1043710444
pte_store(vtopte(qframe), 0);
10438-
10439-
/*
10440-
* Since qframe is exclusively mapped by
10441-
* pmap_quick_enter_page() and that function doesn't set PG_G,
10442-
* we can use INVLPG here.
10443-
*/
10444-
invlpg(qframe);
10445-
1044610445
mtx_unlock_spin(&qframe_mtx);
1044710446
}
1044810447

0 commit comments

Comments
 (0)