From e468d4c8d983b8b14e4bbba16f20a2780a5146af Mon Sep 17 00:00:00 2001 From: thorpej Date: Fri, 9 Apr 1999 00:38:10 +0000 Subject: [PATCH] Fix a bug in TBI optimization uncovered by the "access_type" changes. Thanks to Bernd Ernesti for providing crash dumps to Charles Hannum who tracked it down. --- sys/arch/alpha/alpha/pmap.c | 25 +++++++++++++------------ sys/arch/alpha/include/pte.h | 8 +++----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c index dd51da46e8e7..3753343a559c 100644 --- a/sys/arch/alpha/alpha/pmap.c +++ b/sys/arch/alpha/alpha/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.88 1999/03/29 05:31:24 mycroft Exp $ */ +/* $NetBSD: pmap.c,v 1.89 1999/04/09 00:38:10 thorpej Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -155,7 +155,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.88 1999/03/29 05:31:24 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 1999/04/09 00:38:10 thorpej Exp $"); #include #include @@ -1569,7 +1569,7 @@ pmap_enter(pmap, va, pa, prot, wired, access_type) vm_prot_t access_type; { boolean_t managed; - pt_entry_t *pte, npte; + pt_entry_t *pte, npte, opte; paddr_t opa; boolean_t tflush = TRUE; boolean_t hadasm = FALSE; /* XXX gcc -Wuninitialized */ @@ -1663,6 +1663,9 @@ pmap_enter(pmap, va, pa, prot, wired, access_type) pte = pmap_l3pte(pmap, va, l2pte); } + /* Remember all of the old PTE; used for TBI check later. */ + opte = *pte; + /* * Check to see if the old mapping is valid. If not, validate the * new one immediately. @@ -1714,15 +1717,6 @@ pmap_enter(pmap, va, pa, prot, wired, access_type) pmap->pm_stats.wired_count--; } - /* - * Check to see if the PALcode portion of the - * PTE is the same. If so, no TLB invalidation - * is necessary. - */ - if (PG_PALCODE(pmap_pte_prot(pte)) == - PG_PALCODE(pte_prot(pmap, prot))) - tflush = FALSE; - /* * Set the PTE. */ @@ -1802,6 +1796,13 @@ pmap_enter(pmap, va, pa, prot, wired, access_type) printf("pmap_enter: new pte = 0x%lx\n", npte); #endif + /* + * If the PALcode portion of the new PTE is the same as the + * old PTE, no TBI is necessary. + */ + if (PG_PALCODE(opte) == PG_PALCODE(npte)) + tflush = FALSE; + /* * Set the new PTE. */ diff --git a/sys/arch/alpha/include/pte.h b/sys/arch/alpha/include/pte.h index c856364dda7c..63c300f6a8c1 100644 --- a/sys/arch/alpha/include/pte.h +++ b/sys/arch/alpha/include/pte.h @@ -1,4 +1,4 @@ -/* $NetBSD: pte.h,v 1.25 1998/08/14 16:50:03 thorpej Exp $ */ +/* $NetBSD: pte.h,v 1.26 1999/04/09 00:38:11 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -110,11 +110,9 @@ typedef alpha_pt_entry_t pt_entry_t; /* * These are the PALcode PTE bits that we care about when checking to see - * if a PTE has changed in such a way as to require a TBI. We don't care - * about the FOx bits because we always remember the state of those bits and - * set them to mirror what the TB has (they are used for mod/ref emulation). + * if a PTE has changed in such a way as to require a TBI. */ -#define PG_PALCODE(x) ((x) & (ALPHA_PTE_PALCODE & ~(PG_FOR|PG_FOW|PG_FOE))) +#define PG_PALCODE(x) ((x) & ALPHA_PTE_PALCODE) #if defined(_KERNEL) || defined(__KVM_ALPHA_PRIVATE) #define NPTEPG_SHIFT (PAGE_SHIFT - PTESHIFT)