Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha/alpha Fix a bug in pmap_tlb_shootdown_all_use...



details:   https://anonhg.NetBSD.org/src/rev/e5729117ed24
branches:  trunk
changeset: 379253:e5729117ed24
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun May 23 19:13:27 2021 +0000

description:
Fix a bug in pmap_tlb_shootdown_all_user(), where it was not
stashing away the pointer to the pmap in the TLB context structure
like pmap_tlb_shootdown() was doing.  This would result in the
following failure scenario:

- Page fault handler calls pmap_enter() to map a page.  Mapping
  is the first one for that L2 PT L3 PT, meaning that an L2 PT
  and an L3 PT must be allocated.
- L2 PT allocation succeeds.
- L3 PT allocation fails under memory pressure.
- pmap_enter() goes to drop the reference on the L2 PT, which, because
  it was the first of its mappings, frees the L2 PT.  Becuse PALcode
  may have already tried to service a TLB miss though that L2 PT, we
  must issue an all-user-VA shootdown, and call pmap_tlb_shootdown_all_user()
  to do so.
- pmap_tlb_shootnow() is called and an assert fires because the TLB
  context structure does not point to a pmap.

This did not fail in the pmap_remove() scenario because the TLB context
would have already had at least one call to pmap_tlb_shootdown(), which
was initializing the pmap pointer properly.

PR port-alpha/56200

diffstat:

 sys/arch/alpha/alpha/pmap.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r b9555305c9db -r e5729117ed24 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Sun May 23 11:56:28 2021 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Sun May 23 19:13:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.276 2021/04/03 15:29:02 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.277 2021/05/23 19:13:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.276 2021/04/03 15:29:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.277 2021/05/23 19:13:27 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -743,6 +743,9 @@ pmap_tlb_shootdown_all_user(pmap_t const
                TLB_CTX_SET_FLAG(tlbctx, TLB_CTX_F_IMB);
        }
 
+       KASSERT(tlbctx->t_pmap == NULL || tlbctx->t_pmap == pmap);
+       tlbctx->t_pmap = pmap;
+
        TLB_CTX_SET_ALLVA(tlbctx);
 }
 



Home | Main Index | Thread Index | Old Index