Date: Sun, 23 Aug 2020 20:37:21 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364531 - in head: sys/amd64/include sys/amd64/vmm sys/amd64/vmm/intel usr.sbin/bhyve Message-ID: <202008232037.07NKbLou028599@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Aug 23 20:37:21 2020 New Revision: 364531 URL: https://svnweb.freebsd.org/changeset/base/364531 Log: Add bhyve support for LA57 guest mode. Noted and reviewed by: grehan Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D25273 Modified: head/sys/amd64/include/vmm.h head/sys/amd64/vmm/intel/vmx.c head/sys/amd64/vmm/vmm_instruction_emul.c head/usr.sbin/bhyve/gdb.c Modified: head/sys/amd64/include/vmm.h ============================================================================== --- head/sys/amd64/include/vmm.h Sun Aug 23 20:32:13 2020 (r364530) +++ head/sys/amd64/include/vmm.h Sun Aug 23 20:37:21 2020 (r364531) @@ -522,6 +522,7 @@ enum vm_paging_mode { PAGING_MODE_32, PAGING_MODE_PAE, PAGING_MODE_64, + PAGING_MODE_64_LA57, }; struct vm_guest_paging { Modified: head/sys/amd64/vmm/intel/vmx.c ============================================================================== --- head/sys/amd64/vmm/intel/vmx.c Sun Aug 23 20:32:13 2020 (r364530) +++ head/sys/amd64/vmm/intel/vmx.c Sun Aug 23 20:37:21 2020 (r364531) @@ -1940,14 +1940,18 @@ vmx_cpu_mode(void) static enum vm_paging_mode vmx_paging_mode(void) { + uint64_t cr4; if (!(vmcs_read(VMCS_GUEST_CR0) & CR0_PG)) return (PAGING_MODE_FLAT); - if (!(vmcs_read(VMCS_GUEST_CR4) & CR4_PAE)) + cr4 = vmcs_read(VMCS_GUEST_CR4); + if (!(cr4 & CR4_PAE)) return (PAGING_MODE_32); - if (vmcs_read(VMCS_GUEST_IA32_EFER) & EFER_LME) - return (PAGING_MODE_64); - else + if (vmcs_read(VMCS_GUEST_IA32_EFER) & EFER_LME) { + if (!(cr4 & CR4_LA57)) + return (PAGING_MODE_64); + return (PAGING_MODE_64_LA57); + } else return (PAGING_MODE_PAE); } Modified: head/sys/amd64/vmm/vmm_instruction_emul.c ============================================================================== --- head/sys/amd64/vmm/vmm_instruction_emul.c Sun Aug 23 20:32:13 2020 (r364530) +++ head/sys/amd64/vmm/vmm_instruction_emul.c Sun Aug 23 20:37:21 2020 (r364531) @@ -2189,8 +2189,12 @@ restart: ptpphys = pte; nlevels = 2; - } else + } else if (paging->paging_mode == PAGING_MODE_64_LA57) { + nlevels = 5; + } else { nlevels = 4; + } + while (--nlevels >= 0) { /* Zero out the lower 12 bits and the upper 12 bits */ ptpphys >>= 12; ptpphys <<= 24; ptpphys >>= 12; Modified: head/usr.sbin/bhyve/gdb.c ============================================================================== --- head/usr.sbin/bhyve/gdb.c Sun Aug 23 20:32:13 2020 (r364530) +++ head/usr.sbin/bhyve/gdb.c Sun Aug 23 20:37:21 2020 (r364531) @@ -251,7 +251,8 @@ guest_paging_info(int vcpu, struct vm_guest_paging *pa else if (!(regs[2] & CR4_PAE)) paging->paging_mode = PAGING_MODE_32; else if (regs[3] & EFER_LME) - paging->paging_mode = PAGING_MODE_64; + paging->paging_mode = (regs[2] & CR4_LA57) ? + PAGING_MODE_64_LA57 : PAGING_MODE_64; else paging->paging_mode = PAGING_MODE_PAE; return (0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008232037.07NKbLou028599>