git: 9d9063e123da - stable/14 - amd64/pmap: Return la57 in amd nested page
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Sep 2026 14:49:23 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=9d9063e123daa9dab485f01d9087b5c7b984f6e1
commit 9d9063e123daa9dab485f01d9087b5c7b984f6e1
Author: ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2026-09-11 08:22:39 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-09-22 13:01:16 +0000
amd64/pmap: Return la57 in amd nested page
AMD doesn't encode page depth in eptp. As a result, the page level is
decided by the host la57 value. Without this, it uses 4 level page and
therefore cause machine enable la57 have garbage page translation.
PR: 291768
Reviewed by: kib
Tested by: Antranig Vartanian <antranigv@freebsd.am>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D57978
(cherry picked from commit ef26f64c11220ea303de16d088c585f9d2908b0f)
---
sys/amd64/amd64/pmap.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index bae3735eeafe..af0bb5cea262 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -448,7 +448,19 @@ pmap_is_la57(pmap_t pmap)
{
if (pmap->pm_type == PT_X86)
return (la57);
- return (false); /* XXXKIB handle EPT */
+ if (pmap->pm_type == PT_RVI) {
+ /*
+ * AMD nested paging has no field to specify the nested
+ * page table walk length; the hardware derives it from
+ * the host CR4.LA57 setting (see svm.c, where nCR3 is
+ * loaded directly from pm_pmltop with no level encoding).
+ * The NPT must therefore have the same number of levels
+ * as the host page tables, otherwise guest-physical
+ * translations are walked at the wrong depth.
+ */
+ return (la57);
+ }
+ return (false); /* Intel EPT encodes its own walk length. */
}
#define PAT_INDEX_SIZE 8