The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ef26f64c11220ea303de16d088c585f9d2908b0f
commit ef26f64c11220ea303de16d088c585f9d2908b0f Author: ShengYi Hung <[email protected]> AuthorDate: 2026-09-11 08:22:39 +0000 Commit: Mark Johnston <[email protected]> CommitDate: 2026-09-11 13:01:44 +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 <[email protected]> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D57978 --- 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 eee310cc44b8..8f8d91c768b7 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -443,7 +443,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
