From: guenther Date: Sun, 9 Sep 2018 22:46:54 +0000 (+0000) Subject: pmap_activate() should match cpu_switchto, so set up ci_{kern,user}_cr3 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=992096868a823a7c114bd06fdc04d53751133290;p=openbsd pmap_activate() should match cpu_switchto, so set up ci_{kern,user}_cr3 if activating for the current thread and meltdown mitigations are in effect. Not clear if it's actually possible to hit the case where this matters, but it's the Right Thing. ok mlarkin@ --- diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c index 85f23f08568..3b13d45d2fa 100644 --- a/sys/arch/amd64/amd64/pmap.c +++ b/sys/arch/amd64/amd64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.117 2018/09/09 22:41:57 guenther Exp $ */ +/* $OpenBSD: pmap.c,v 1.118 2018/09/09 22:46:54 guenther Exp $ */ /* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */ /* @@ -1188,6 +1188,14 @@ pmap_activate(struct proc *p) if (p == curproc) { lcr3(pcb->pcb_cr3); + /* in case we return to userspace without context switching */ + if (cpu_meltdown) { + struct cpu_info *self = curcpu(); + + self->ci_kern_cr3 = pcb->pcb_cr3; + self->ci_user_cr3 = pmap->pm_pdirpa_intel; + } + /* * mark the pmap in use by this processor. */