git: e1d055a71895 - stable/14 - proccontrol: support la52 on powerpc64

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Thu, 26 Nov 2026 06:16:19 UTC
The branch stable/14 has been updated by pkubaj:

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

commit e1d055a7189519ef2d790e9e3205d987c35b5379
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-11-15 20:57:11 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-11-25 20:32:33 +0000

    proccontrol: support la52 on powerpc64
    
    powerpc64 is getting the same PROC_LA_CTL interface as amd64, but calls
    the full address space la52 instead of la57. Take the mode name and the
    constants from whichever one machine/procctl.h defines.
    
    Reviewed by:    kib
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D61331
    
    (cherry picked from commit a637aa182bb1c1dc1e545fc5af2bceff4013affc)
---
 usr.bin/proccontrol/proccontrol.1 |  9 ++++++---
 usr.bin/proccontrol/proccontrol.c | 42 +++++++++++++++++++++++++++------------
 2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/usr.bin/proccontrol/proccontrol.1 b/usr.bin/proccontrol/proccontrol.1
index 73a1eb68fd0d..f9d3579d822e 100644
--- a/usr.bin/proccontrol/proccontrol.1
+++ b/usr.bin/proccontrol/proccontrol.1
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 5, 2023
+.Dd November 9, 2026
 .Dt PROCCONTROL 1
 .Os
 .Sh NAME
@@ -74,8 +74,11 @@ Controls the write exclusive execute mode for mappings.
 .It Ar kpti
 Controls the KPTI enable, AMD64 only.
 .It Ar la48
-Control limiting usermode process address space to 48 bits of address,
-AMD64 only, on machines capable of 57-bit addressing.
+Control limiting usermode process address space to 48 bits of address.
+AMD64, on machines capable of 57-bit addressing, and powerpc64 only.
+.It Ar la52
+Control the use of the full 52-bit address space of the radix MMU,
+powerpc64 only.
 .El
 .Pp
 The
diff --git a/usr.bin/proccontrol/proccontrol.c b/usr.bin/proccontrol/proccontrol.c
index 4b7543d63793..356a569daf22 100644
--- a/usr.bin/proccontrol/proccontrol.c
+++ b/usr.bin/proccontrol/proccontrol.c
@@ -48,11 +48,27 @@ enum {
 	MODE_KPTI,
 #endif
 #ifdef PROC_LA_CTL
-	MODE_LA57,
+	MODE_LA_WIDE,
 	MODE_LA48,
 #endif
 };
 
+#ifdef PROC_LA_CTL
+/*
+ * The wide address space mode is la57 on amd64 and la52 on powerpc64,
+ * the procctl(2) values are the same.
+ */
+#ifdef PROC_LA_CTL_LA57_ON_EXEC
+#define	LA_WIDE_NAME			"la57"
+#define	PROC_LA_CTL_LA_WIDE_ON_EXEC	PROC_LA_CTL_LA57_ON_EXEC
+#define	PROC_LA_STATUS_LA_WIDE		PROC_LA_STATUS_LA57
+#elif defined(PROC_LA_CTL_LA52_ON_EXEC)
+#define	LA_WIDE_NAME			"la52"
+#define	PROC_LA_CTL_LA_WIDE_ON_EXEC	PROC_LA_CTL_LA52_ON_EXEC
+#define	PROC_LA_STATUS_LA_WIDE		PROC_LA_STATUS_LA52
+#endif
+#endif
+
 static pid_t
 str2pid(const char *str)
 {
@@ -73,7 +89,7 @@ str2pid(const char *str)
 #define	KPTI_USAGE
 #endif
 #ifdef PROC_LA_CTL
-#define	LA_USAGE "|la48|la57"
+#define	LA_USAGE "|la48|" LA_WIDE_NAME
 #else
 #define	LA_USAGE
 #endif
@@ -121,8 +137,8 @@ main(int argc, char *argv[])
 				mode = MODE_KPTI;
 #endif
 #ifdef PROC_LA_CTL
-			else if (strcmp(optarg, "la57") == 0)
-				mode = MODE_LA57;
+			else if (strcmp(optarg, LA_WIDE_NAME) == 0)
+				mode = MODE_LA_WIDE;
 			else if (strcmp(optarg, "la48") == 0)
 				mode = MODE_LA48;
 #endif
@@ -190,7 +206,7 @@ main(int argc, char *argv[])
 			break;
 #endif
 #ifdef PROC_LA_CTL
-		case MODE_LA57:
+		case MODE_LA_WIDE:
 		case MODE_LA48:
 			error = procctl(P_PID, pid, PROC_LA_STATUS, &arg);
 			break;
@@ -312,15 +328,15 @@ main(int argc, char *argv[])
 			break;
 #endif
 #ifdef PROC_LA_CTL
-		case MODE_LA57:
+		case MODE_LA_WIDE:
 		case MODE_LA48:
 			switch (arg & ~(PROC_LA_STATUS_LA48 |
-			    PROC_LA_STATUS_LA57)) {
+			    PROC_LA_STATUS_LA_WIDE)) {
 			case PROC_LA_CTL_LA48_ON_EXEC:
 				printf("la48 on exec");
 				break;
-			case PROC_LA_CTL_LA57_ON_EXEC:
-				printf("la57 on exec");
+			case PROC_LA_CTL_LA_WIDE_ON_EXEC:
+				printf(LA_WIDE_NAME " on exec");
 				break;
 			case PROC_LA_CTL_DEFAULT_ON_EXEC:
 				printf("default on exec");
@@ -328,8 +344,8 @@ main(int argc, char *argv[])
 			}
 			if ((arg & PROC_LA_STATUS_LA48) != 0)
 				printf(", la48 active\n");
-			else if ((arg & PROC_LA_STATUS_LA57) != 0)
-				printf(", la57 active\n");
+			else if ((arg & PROC_LA_STATUS_LA_WIDE) != 0)
+				printf(", " LA_WIDE_NAME " active\n");
 			break;
 #endif
 		}
@@ -380,8 +396,8 @@ main(int argc, char *argv[])
 			break;
 #endif
 #ifdef PROC_LA_CTL
-		case MODE_LA57:
-			arg = enable ? PROC_LA_CTL_LA57_ON_EXEC :
+		case MODE_LA_WIDE:
+			arg = enable ? PROC_LA_CTL_LA_WIDE_ON_EXEC :
 			    PROC_LA_CTL_DEFAULT_ON_EXEC;
 			error = procctl(P_PID, pid, PROC_LA_CTL, &arg);
 			break;