From owner-svn-src-all@freebsd.org Sun Aug 23 20:37:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9CAEB3C9A54; Sun, 23 Aug 2020 20:37:22 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BZRrf3Z0Jz4SZH; Sun, 23 Aug 2020 20:37:22 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C807CD71; Sun, 23 Aug 2020 20:37:22 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07NKbMrZ028603; Sun, 23 Aug 2020 20:37:22 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07NKbLou028599; Sun, 23 Aug 2020 20:37:21 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202008232037.07NKbLou028599@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 23 Aug 2020 20:37:21 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head: sys/amd64/include sys/amd64/vmm sys/amd64/vmm/intel usr.sbin/bhyve X-SVN-Commit-Revision: 364531 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2020 20:37:22 -0000 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);