git: e429186184fe - stable/13 - powerpc64: tell kernel when radix is not available

From: Leandro Lupori <luporl_at_FreeBSD.org>
Date: Tue, 04 Oct 2022 16:29:42 UTC
The branch stable/13 has been updated by luporl:

URL: https://cgit.FreeBSD.org/src/commit/?id=e429186184fee12cf3f2bda8a747370987653a9f

commit e429186184fee12cf3f2bda8a747370987653a9f
Author:     Leandro Lupori <luporl@FreeBSD.org>
AuthorDate: 2021-10-22 16:44:21 +0000
Commit:     Leandro Lupori <luporl@FreeBSD.org>
CommitDate: 2022-10-04 16:24:15 +0000

    powerpc64: tell kernel when radix is not available
    
    If CAS detects that radix is not supported, set radix_mmu to 0
    to avoid the kernel trying to use it and panic.
    
    Sponsored by:   Instituto de Pesquisas Eldorado (eldorado.org.br)
    
    (cherry picked from commit a23e18ea545675aca7551ef2395f6df40a3acb29)
---
 stand/powerpc/ofw/cas.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/stand/powerpc/ofw/cas.c b/stand/powerpc/ofw/cas.c
index 0a12f31d1a1a..e95af42762a5 100644
--- a/stand/powerpc/ofw/cas.c
+++ b/stand/powerpc/ofw/cas.c
@@ -234,9 +234,15 @@ ppc64_cas(void)
 		}
 	}
 
-	if ((var = getenv("radix_mmu")) != NULL && var[0] == '0')
+	if (!radix_mmu)
+		/*
+		 * If radix is not supported, set radix_mmu to 0 to avoid
+		 * the kernel trying to use it and panic.
+		 */
+		setenv("radix_mmu", "0", 1);
+	else if ((var = getenv("radix_mmu")) != NULL && var[0] == '0')
 		radix_mmu = 0;
-	if (radix_mmu)
+	else
 		ov5[OV5_MMU_INDEX] = OV5_MMU_RADIX;
 
 	inst = OF_open("/");