git: 7a8440bf0894 - main - amd64: make LA57 mode for a process opt-in by default
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 27 Apr 2025 22:32:49 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7a8440bf0894f910f871e91a660a9f66dbb23f0b commit 7a8440bf0894f910f871e91a660a9f66dbb23f0b Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-04-19 10:55:18 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-04-27 22:31:59 +0000 amd64: make LA57 mode for a process opt-in by default The vm.pmap.prefer_la48 manages the mode. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D49913 --- 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 0e6c8d310dfd..6cc2d58bbbcc 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -170,11 +170,13 @@ freebsd_brand_info_la57_img_compat(const 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 9ff630de5b6e..4ad1335329da 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -431,6 +431,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;