From 92f10c9019a000d39ae6a122012b17d264586ac0 Mon Sep 17 00:00:00 2001 From: gkoehler Date: Tue, 21 Feb 2023 04:49:43 +0000 Subject: [PATCH] Set the current pmap in macppc's pmap_activate This fixes a possible freeze in execve(2). It sometimes froze when a dual-cpu macppc started daemons during boot. There is a chance that uvm_map.c uvmspace_exec sees ovm->vm_refcnt != 1 and switches curproc to a new pmap. If this happened, then execve froze by trying to copyout to the wrong pmap; curpcb->pcb_pm was old. Fix by setting pointers when uvmspace_exec calls pmap_activate. ok miod@ --- sys/arch/powerpc/powerpc/pmap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c index e47eafa9829..f160e2e7ed8 100644 --- a/sys/arch/powerpc/powerpc/pmap.c +++ b/sys/arch/powerpc/powerpc/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.181 2023/02/06 06:41:38 gkoehler Exp $ */ +/* $OpenBSD: pmap.c,v 1.182 2023/02/21 04:49:43 gkoehler Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -81,6 +81,7 @@ #include #include #include +#include #include @@ -1646,12 +1647,19 @@ pmap_enable_mmu(void) /* * activate a pmap entry - * NOOP on powerpc, all PTE entries exist in the same hash table. + * All PTE entries exist in the same hash table. * Segment registers are filled on exit to user mode. */ void pmap_activate(struct proc *p) { + struct pcb *pcb = &p->p_addr->u_pcb; + + /* Set the current pmap. */ + pcb->pcb_pm = p->p_vmspace->vm_map.pmap; + pmap_extract(pmap_kernel(), + (vaddr_t)pcb->pcb_pm, (paddr_t *)&pcb->pcb_pmreal); + curcpu()->ci_curpm = pcb->pcb_pmreal; } /* -- 2.20.1