diff options
author | 2020-08-17 16:55:41 +0000 | |
---|---|---|
committer | 2020-08-17 16:55:41 +0000 | |
commit | 3d73cff41e6a3d60bea06fb1ae581db81112f85c (patch) | |
tree | 57ddc8c29eb2e96e93416491c36948d02309df27 | |
parent | Fix possible leak of ocsp_id. (diff) | |
download | wireguard-openbsd-3d73cff41e6a3d60bea06fb1ae581db81112f85c.tar.xz wireguard-openbsd-3d73cff41e6a3d60bea06fb1ae581db81112f85c.zip |
Switch to a per-proc SLB cache. Seems to make GENERIC.MP kernels
(much more) stable. Probably because we could restore an incoherent
SLB cache since there was no locking in the trap return path.
-rw-r--r-- | sys/arch/powerpc64/include/pcb.h | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/pmap.h | 3 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/machdep.c | 3 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/pmap.c | 19 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/vm_machdep.c | 8 |
5 files changed, 22 insertions, 15 deletions
diff --git a/sys/arch/powerpc64/include/pcb.h b/sys/arch/powerpc64/include/pcb.h index 349707f4eac..3bc8295af49 100644 --- a/sys/arch/powerpc64/include/pcb.h +++ b/sys/arch/powerpc64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.6 2020/07/01 16:05:48 kettenis Exp $ */ +/* $OpenBSD: pcb.h,v 1.7 2020/08/17 16:55:41 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -20,6 +20,7 @@ #define _MACHINE_PCB_H_ #include <machine/reg.h> +#include <machine/pte.h> struct pcb { register_t pcb_sp; @@ -27,6 +28,7 @@ struct pcb { #define PCB_FP 0x000000001 #define PCB_VEC 0x000000002 #define PCB_VSX 0x000000004 + struct slb pcb_slb[32]; vaddr_t pcb_onfault; vaddr_t pcb_userva; struct fpreg pcb_fpstate; diff --git a/sys/arch/powerpc64/include/pmap.h b/sys/arch/powerpc64/include/pmap.h index 50ff0464e9c..14316fe5fd0 100644 --- a/sys/arch/powerpc64/include/pmap.h +++ b/sys/arch/powerpc64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.13 2020/07/23 15:09:09 kettenis Exp $ */ +/* $OpenBSD: pmap.h,v 1.14 2020/08/17 16:55:41 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -36,7 +36,6 @@ struct pmap { int pm_refs; struct pmap_statistics pm_stats; struct mutex pm_mtx; - struct slb pm_slb[32]; }; typedef struct pmap *pmap_t; diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c index fee4cd85e5d..2f36148c222 100644 --- a/sys/arch/powerpc64/powerpc64/machdep.c +++ b/sys/arch/powerpc64/powerpc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.55 2020/07/21 21:36:58 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.56 2020/08/17 16:55:41 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -738,6 +738,7 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack, frame->srr0 = pack->ep_entry; frame->srr1 = PSL_USER; + memset(&pcb->pcb_slb, 0, sizeof(pcb->pcb_slb)); memset(&pcb->pcb_fpstate, 0, sizeof(pcb->pcb_fpstate)); pcb->pcb_flags = 0; } diff --git a/sys/arch/powerpc64/powerpc64/pmap.c b/sys/arch/powerpc64/powerpc64/pmap.c index a67595e6518..eba61982c17 100644 --- a/sys/arch/powerpc64/powerpc64/pmap.c +++ b/sys/arch/powerpc64/powerpc64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.40 2020/08/04 16:28:16 kettenis Exp $ */ +/* $OpenBSD: pmap.c,v 1.41 2020/08/17 16:55:41 kettenis Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -50,6 +50,8 @@ #include <sys/param.h> #include <sys/atomic.h> #include <sys/pool.h> +#include <sys/proc.h> +#include <sys/user.h> #include <uvm/uvm_extern.h> @@ -333,23 +335,24 @@ pmap_slbd_lookup(pmap_t pm, vaddr_t va) void pmap_slbd_cache(pmap_t pm, struct slb_desc *slbd) { + struct pcb *pcb = &curproc->p_addr->u_pcb; uint64_t slbe, slbv; int idx; - PMAP_VP_ASSERT_LOCKED(pm); + KASSERT(curproc->p_vmspace->vm_map.pmap == pm); - for (idx = 0; idx < nitems(pm->pm_slb); idx++) { - if (pm->pm_slb[idx].slb_slbe == 0) + for (idx = 0; idx < nitems(pcb->pcb_slb); idx++) { + if (pcb->pcb_slb[idx].slb_slbe == 0) break; } - if (idx == nitems(pm->pm_slb)) - idx = arc4random_uniform(nitems(pm->pm_slb)); + if (idx == nitems(pcb->pcb_slb)) + idx = arc4random_uniform(nitems(pcb->pcb_slb)); slbe = (slbd->slbd_esid << SLBE_ESID_SHIFT) | SLBE_VALID | idx; slbv = slbd->slbd_vsid << SLBV_VSID_SHIFT; - pm->pm_slb[idx].slb_slbe = slbe; - pm->pm_slb[idx].slb_slbv = slbv; + pcb->pcb_slb[idx].slb_slbe = slbe; + pcb->pcb_slb[idx].slb_slbv = slbv; } int diff --git a/sys/arch/powerpc64/powerpc64/vm_machdep.c b/sys/arch/powerpc64/powerpc64/vm_machdep.c index e872ee5f2da..609593b90be 100644 --- a/sys/arch/powerpc64/powerpc64/vm_machdep.c +++ b/sys/arch/powerpc64/powerpc64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.4 2020/06/30 20:31:54 kettenis Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.5 2020/08/17 16:55:41 kettenis Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -67,7 +67,6 @@ void cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, void (*func)(void *), void *arg) { - pmap_t pm = p2->p_vmspace->vm_map.pmap; struct pcb *pcb = &p2->p_addr->u_pcb; struct trapframe *tf; struct callframe *cf; @@ -77,7 +76,10 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, /* Copy the pcb. */ *pcb = p1->p_addr->u_pcb; - pmap_extract(pmap_kernel(), (vaddr_t)&pm->pm_slb, + /* XXX This should not be necessary but things explodes without it. */ + memset(&pcb->pcb_slb, 0, sizeof(pcb->pcb_slb)); + + pmap_extract(pmap_kernel(), (vaddr_t)&pcb->pcb_slb, &p2->p_md.md_user_slb_pa); pmap_activate(p2); |