From 8b434feedfa9f71b59b9653c9335700abc019c03 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Fri, 5 Mar 2021 10:31:43 -0600 Subject: [PATCH] Only set delayed inval for procs using PTI invltlb_invpcid_pti_handler() was requesting delayed TLB invalidation even for processes that aren't using PTI. With an out-of-tree change to avoid PTI for non-jailed root processes, this caused an assertion failure in pmap_activate_sw_pcid_pti() when context-switching between PTI and non-PTI processes. Reviewed by: bdrewery kib tychon Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29094 --- sys/amd64/amd64/mp_machdep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index aa62c2086fa4..11f2bb8bbfc1 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -851,7 +851,8 @@ invltlb_invpcid_pti_handler(pmap_t smp_tlb_pmap) invpcid(&d, INVPCID_CTXGLOB); } else { invpcid(&d, INVPCID_CTX); - if (smp_tlb_pmap == PCPU_GET(curpmap)) + if (smp_tlb_pmap == PCPU_GET(curpmap) && + smp_tlb_pmap->pm_ucr3 != PMAP_NO_CR3) PCPU_SET(ucr3_load_mask, ~CR3_PCID_SAVE); } }