git: b989c1dd1e2e - main - elfctl: add knowledge about the la57 bit

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 27 Apr 2025 22:32:50 UTC
The branch main has been updated by kib:

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

commit b989c1dd1e2edc8cf7597d276625b454b7b72e6d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-04-19 10:47:45 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-04-27 22:31:59 +0000

    elfctl: add knowledge about the la57 bit
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D49913
---
 usr.bin/elfctl/elfctl.1 | 14 ++++++++++++++
 usr.bin/elfctl/elfctl.c |  5 ++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/usr.bin/elfctl/elfctl.1 b/usr.bin/elfctl/elfctl.1
index 5ba016b664a3..e72c6bcf250a 100644
--- a/usr.bin/elfctl/elfctl.1
+++ b/usr.bin/elfctl/elfctl.1
@@ -95,6 +95,20 @@ Features may also be specified as a single combined value:
 .Bd -literal -offset indent
 elfctl -e =0x5 file
 .Ed
+.Sh NOTES
+On amd64, on a machine with LA57 (5-level paging) mode supported and
+enabled, if both
+.Va la57
+and
+.Va la48
+feature flags are specified, the
+.Va la57
+feature has priority over
+.Va la48 .
+The
+.Va vm.pmap.prefer_uva_la48
+sysctl MIB defines the default user address space size for binaries
+which do not set either of these flags.
 .Sh SEE ALSO
 .Xr mitigations 7
 .Sh HISTORY
diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c
index d9cb557bbad4..cacd30b44b2d 100644
--- a/usr.bin/elfctl/elfctl.c
+++ b/usr.bin/elfctl/elfctl.c
@@ -67,7 +67,10 @@ static struct ControlFeatures featurelist[] = {
 	    "Disable implicit PROT_MAX" },
 	{ "nostackgap",	NT_FREEBSD_FCTL_STKGAP_DISABLE, "Disable stack gap" },
 	{ "wxneeded",	NT_FREEBSD_FCTL_WXNEEDED, "Requires W+X mappings" },
-	{ "la48",	NT_FREEBSD_FCTL_LA48, "amd64: Limit user VA to 48bit" },
+	{ "la48",	NT_FREEBSD_FCTL_LA48,
+	    "amd64: Limit user virtual addresses to 48 bits" },
+	{ "la57",	NT_FREEBSD_FCTL_LA57,
+	    "amd64: Allow the use of 57-bit virtual addresses when available" },
 };
 
 static struct option long_opts[] = {