git: 64a8ac8c63d3 - stable/14 - amd64: make LA57 mode for a process opt-in by default
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 03 May 2025 15:20:10 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=64a8ac8c63d3b84b5da8042e5e314aa7938f5b10
commit 64a8ac8c63d3b84b5da8042e5e314aa7938f5b10
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-04-19 10:55:18 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-05-03 15:19:41 +0000
amd64: make LA57 mode for a process opt-in by default
(cherry picked from commit 7a8440bf0894f910f871e91a660a9f66dbb23f0b)
---
sys/amd64/amd64/elf_machdep.c | 4 +++-
sys/amd64/amd64/pmap.c | 9 +++++++++
sys/amd64/include/md_var.h | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index fc25decc64a2..e45d45860c9c 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -171,11 +171,13 @@ freebsd_brand_info_la57_img_compat(struct image_params *imgp,
{
if ((imgp->proc->p_md.md_flags & P_MD_LA57) != 0)
return (true);
+ if (fctl0 != NULL && (*fctl0 & NT_FREEBSD_FCTL_LA57) != 0)
+ return (true);
if (fctl0 == NULL || (*fctl0 & NT_FREEBSD_FCTL_LA48) != 0)
return (false);
if ((imgp->proc->p_md.md_flags & P_MD_LA48) != 0)
return (false);
- return (true);
+ return (!prefer_uva_la48);
}
static Elf64_Brandinfo freebsd_brand_info_la48 = {
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 406ff7744e5b..1456cee62aeb 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -433,6 +433,15 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, la57, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
&la57, 0,
"5-level paging for host is enabled");
+/*
+ * The default value is needed in order to preserve compatibility with
+ * some userspace programs that put tags into sign-extended bits.
+ */
+int prefer_uva_la48 = 1;
+SYSCTL_INT(_vm_pmap, OID_AUTO, prefer_uva_la48, CTLFLAG_RDTUN,
+ &prefer_uva_la48, 0,
+ "Userspace maps are limited to LA48 unless otherwise configured");
+
static bool
pmap_is_la57(pmap_t pmap)
{
diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h
index ce6f05fa1739..b6ddc6eaaebe 100644
--- a/sys/amd64/include/md_var.h
+++ b/sys/amd64/include/md_var.h
@@ -50,6 +50,7 @@ extern vm_paddr_t intel_graphics_stolen_base;
extern vm_paddr_t intel_graphics_stolen_size;
extern int la57;
+extern int prefer_uva_la48;
extern vm_paddr_t kernphys;
extern vm_paddr_t KERNend;