Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/oea - In pmap_bootstrap1(), make sure to in...



details:   https://anonhg.NetBSD.org/src/rev/1bf6c3f51452
branches:  trunk
changeset: 960177:1bf6c3f51452
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Mar 10 18:29:07 2021 +0000

description:
- In pmap_bootstrap1(), make sure to initialize pmap_kernel()->pm_vsid
  with the kernel's base VSID.
- In va_to_vsid(), always compute the VSID from the base VSID in the
  pmap and the effective segment ID (ESID), rather than extracting it
  from the pmap's segment register value for that ESID.  Not only does
  this make the code the same between OEA and OEA64, but is also lets
  us compute the correct VSID for that pmap/ESID even if the cached SR
  for that ESID currently contains something else, such as an I/O segment
  mapping (as might be the case on a 601).

With this change, we can temporarily toggle between an I/O segment and
and HTAB-mapped segment if needed (e.g. when calling OpenFirmware on
a 601-based system).

diffstat:

 sys/arch/powerpc/oea/pmap.c |  49 ++++++++++----------------------------------
 1 files changed, 11 insertions(+), 38 deletions(-)

diffs (80 lines):

diff -r 82fe0a8895f4 -r 1bf6c3f51452 sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c       Wed Mar 10 18:26:16 2021 +0000
+++ b/sys/arch/powerpc/oea/pmap.c       Wed Mar 10 18:29:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.101 2021/03/02 01:47:44 thorpej Exp $       */
+/*     $NetBSD: pmap.c,v 1.102 2021/03/10 18:29:07 thorpej Exp $       */
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.101 2021/03/02 01:47:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.102 2021/03/10 18:29:07 thorpej Exp $");
 
 #define        PMAP_NOOPNAMES
 
@@ -595,45 +595,17 @@
 static inline register_t
 va_to_vsid(const struct pmap *pm, vaddr_t addr)
 {
-#if defined (PMAP_OEA) || defined (PMAP_OEA64_BRIDGE)
-       return (pm->pm_sr[addr >> ADDR_SR_SHFT] & SR_VSID) >> SR_VSID_SHFT;
-#else /* PMAP_OEA64 */
-#if 0
-       const struct ste *ste;
-       register_t hash;
-       int i;
-
-       hash = (addr >> ADDR_ESID_SHFT) & ADDR_ESID_HASH;
-
        /*
-        * Try the primary group first
-        */
-       ste = pm->pm_stes[hash].stes;
-       for (i = 0; i < 8; i++, ste++) {
-               if (ste->ste_hi & STE_V) &&
-                  (addr & ~(ADDR_POFF|ADDR_PIDX)) == (ste->ste_hi & STE_ESID))
-                       return ste;
-       }
-
-       /*
-        * Then the secondary group.
-        */
-       ste = pm->pm_stes[hash ^ ADDR_ESID_HASH].stes;
-       for (i = 0; i < 8; i++, ste++) {
-               if (ste->ste_hi & STE_V) &&
-                  (addr & ~(ADDR_POFF|ADDR_PIDX)) == (ste->ste_hi & STE_ESID))
-                       return addr;
-       }
-               
-       return NULL;
-#else
-       /*
-        * Rather than searching the STE groups for the VSID, we know
-        * how we generate that from the ESID and so do that.
+        * Rather than searching the STE groups for the VSID or extracting
+        * it from the SR, we know how we generate that from the ESID and
+        * so do that.
+        *
+        * This makes the code the same for OEA and OEA64, and also allows
+        * us to generate a correct-for-that-address-space VSID even if the
+        * pmap contains a different SR value at any given moment (e.g.
+        * kernel pmap on a 601 that is using I/O segments).
         */
        return VSID_MAKE(addr >> ADDR_SR_SHFT, pm->pm_vsid) >> SR_VSID_SHFT;
-#endif
-#endif /* PMAP_OEA */
 }
 
 static inline register_t
@@ -3419,6 +3391,7 @@
 #endif
                pmap_kernel()->pm_sr[i] = KERNELN_SEGMENT(i)|SR_PRKEY;
        }
+       pmap_kernel()->pm_vsid = KERNEL_VSIDBITS;
 
        pmap_kernel()->pm_sr[KERNEL_SR] = KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY;
 #ifdef KERNEL2_SR



Home | Main Index | Thread Index | Old Index