From 8801df34f0f3a0655d8952be97f22faaf9a5253d Mon Sep 17 00:00:00 2001 From: Brandon Bergren Date: Sun, 8 Nov 2020 23:34:06 +0000 Subject: [PATCH] [PowerPC] Fix powerpc64le boot after HPT superpages addition The HPT is always stored in big-endian, as it is accessed directly by the hardware as well as the kernel. As such, it is necessary to convert values to and from native endian when running on LE. Some unconverted accesses snuck in accidentally with r367417. Apply the appropriate conversions to fix boot hanging on powerpc64le. Sponsored by: Tag1 Consulting, Inc. --- sys/powerpc/aim/moea64_native.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/powerpc/aim/moea64_native.c b/sys/powerpc/aim/moea64_native.c index 4e729709bf3..a5837886a2a 100644 --- a/sys/powerpc/aim/moea64_native.c +++ b/sys/powerpc/aim/moea64_native.c @@ -384,7 +384,7 @@ moea64_pte_clear_native(struct pvo_entry *pvo, uint64_t ptebit) static __always_inline int64_t moea64_pte_unset_locked(volatile struct lpte *pt, uint64_t vpn) { - uint64_t ptelo; + uint64_t ptelo, ptehi; /* * Invalidate the pte, briefly locking it to collect RC bits. No @@ -392,9 +392,10 @@ moea64_pte_unset_locked(volatile struct lpte *pt, uint64_t vpn) */ isync(); critical_enter(); - pt->pte_hi = htobe64((be64toh(pt->pte_hi) & ~LPTE_VALID) | LPTE_LOCKED); + ptehi = (be64toh(pt->pte_hi) & ~LPTE_VALID) | LPTE_LOCKED; + pt->pte_hi = htobe64(ptehi); PTESYNC(); - TLBIE(vpn, pt->pte_hi); + TLBIE(vpn, ptehi); ptelo = be64toh(pt->pte_lo); *((volatile int32_t *)(&pt->pte_hi) + 1) = 0; /* Release lock */ critical_exit(); @@ -416,7 +417,7 @@ moea64_pte_unset_native(struct pvo_entry *pvo) rw_rlock(&moea64_eviction_lock); - if ((be64toh(pt->pte_hi & LPTE_AVPN_MASK)) != pvo_ptevpn) { + if ((be64toh(pt->pte_hi) & LPTE_AVPN_MASK) != pvo_ptevpn) { /* Evicted */ STAT_MOEA64(moea64_pte_overflow--); ret = -1; @@ -433,7 +434,7 @@ moea64_pte_replace_inval_native(struct pvo_entry *pvo, volatile struct lpte *pt) { struct lpte properpt; - uint64_t ptelo; + uint64_t ptelo, ptehi; moea64_pte_from_pvo(pvo, &properpt); @@ -452,9 +453,10 @@ moea64_pte_replace_inval_native(struct pvo_entry *pvo, */ isync(); critical_enter(); - pt->pte_hi = htobe64((be64toh(pt->pte_hi) & ~LPTE_VALID) | LPTE_LOCKED); + ptehi = (be64toh(pt->pte_hi) & ~LPTE_VALID) | LPTE_LOCKED; + pt->pte_hi = htobe64(ptehi); PTESYNC(); - TLBIE(pvo->pvo_vpn, pt->pte_hi); + TLBIE(pvo->pvo_vpn, ptehi); ptelo = be64toh(pt->pte_lo); EIEIO(); pt->pte_lo = htobe64(properpt.pte_lo);