From nobody Wed Apr 10 15:19:02 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VF61M3PTYz5HHSB; Wed, 10 Apr 2024 15:19:03 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VF61M1Cwrz4mkL; Wed, 10 Apr 2024 15:19:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sr1hbNBpGD/TjCVUAUJegqLdhxnjBGu7LXzYlsjTYoY=; b=sa5d9Y53oBGTHHr09XRw0c7ZRseNMS+RbkUr4g2LyDSgManatZavauhRszyR07I+X8PFft ynTeBmunlNkLp4culptXhnKU1sB9e1swCtjrOwJMuNhLnuLvqDw5yJKgg1lk2Fw/dsnsrW 11BOJFngIZBa63xyjn2YjhVxYpWy1eGsR9wNyZztRP45ah28PjCJ0lrS1EpFPTjzsRuJAf rFc35pjFXCqufrQRLzwSWxyOI3YChPCiW9GnCTUdUJkmBUBNfp9s0T0mQ9gOkHSkDs2bNd BQYaFWo1m95ITLcr98ZNDFImFLR8MAqTMY7OUihR3xdryf9w1BxTGcKHjVDmog== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712762343; a=rsa-sha256; cv=none; b=lKqP++zb9lkKCUwMHpCqBNl1afhvOdXCmBPI0SqnzTVAMudq1MNMSwZyFd1hz9y1N6XxuV GvwrxLip2NPYxG+Ug5/rz57u7p3Y819o14UwGeYjDtQ2d7IaQynJE3BeOmEG6c+dU85w2l p6OR4brJ1oqKilzhJwErwfCzlXGq7A5qcPKyJZSyG4rYoZqRi7O9V2hBYZOazTzyWPzUka m9fMLLzwQrj5ecU4TWW24nVLdeSZj6j7/Y466lZqWa/zzsth1/hx/WIJ0lCYKwpqpEuWpn HBvfZLfhbWz0q4voPn8amDyxESYeTi1sDTno1OsFy9vmgAVlkuLxERvfyHbw2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sr1hbNBpGD/TjCVUAUJegqLdhxnjBGu7LXzYlsjTYoY=; b=tKY1Un8cj0I29bQUTmsJVv/ymByhZ7tPp6l1xGlTmpgwrqHHm9PXmByC8s55tCPKOgFS/1 yRppM4RDaL+guaVMuJP1DJkH7GzHeaQGGqD/uxco4HEuMLCX7m9EN4cG/qbhFbk2OabF05 yFq3MZHNuNYe+28RGXmJAAnulcXoyxownsWIj9Uan6+wNRMsmjOH7SKqv+VrpB0yMfZWvK RsD5CJE3rpr9PKkIn7vnC+23jPLGk+Bw0kkUrxiChi/rMQ0yEZY0e08fG3GWumexoeDlHv +FVFODQ58peEEU2pw2dPEij/0j0zFn4XnTwxdpIo+mn3l1JeT+yzDXzDn3R3Zg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VF61M0mcbzjlk; Wed, 10 Apr 2024 15:19:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43AFJ3o6092693; Wed, 10 Apr 2024 15:19:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43AFJ2uY092690; Wed, 10 Apr 2024 15:19:02 GMT (envelope-from git) Date: Wed, 10 Apr 2024 15:19:02 GMT Message-Id: <202404101519.43AFJ2uY092690@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 967264cfcd6d - main - libvmmapi: Add a subdirectory for amd64-specific code List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: dev-commits-src-all+owner@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 967264cfcd6d1a42dc0c9f9916320afe90f1faa4 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=967264cfcd6d1a42dc0c9f9916320afe90f1faa4 commit 967264cfcd6d1a42dc0c9f9916320afe90f1faa4 Author: Mark Johnston AuthorDate: 2024-04-03 16:52:00 +0000 Commit: Mark Johnston CommitDate: 2024-04-10 15:17:55 +0000 libvmmapi: Add a subdirectory for amd64-specific code Move vmmapi_freebsd.c there. It contains x86-specific code used only by bhyveload(8). Move vcpu_reset() into vmmapi_machdep.c. It is also x86-specific. No functional change intended. Reviewed by: corvink, jhb MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D40998 --- lib/libvmmapi/Makefile | 10 +- lib/libvmmapi/amd64/Makefile.inc | 2 + .../vmmapi_freebsd_machdep.c} | 0 lib/libvmmapi/amd64/vmmapi_machdep.c | 225 +++++++++++++++++++++ lib/libvmmapi/vmmapi.c | 195 +----------------- 5 files changed, 235 insertions(+), 197 deletions(-) diff --git a/lib/libvmmapi/Makefile b/lib/libvmmapi/Makefile index d871ffef9120..dc7d48183439 100644 --- a/lib/libvmmapi/Makefile +++ b/lib/libvmmapi/Makefile @@ -2,11 +2,15 @@ PACKAGE=lib${LIB} LIB= vmmapi SHLIB_MAJOR= 6 -SRCS= vmmapi.c vmmapi_freebsd.c +SRCS= vmmapi.c INCS= vmmapi.h -LIBADD= util - CFLAGS+= -I${.CURDIR} +.PATH: ${.CURDIR}/${MACHINE_CPUARCH} + +.include "${MACHINE_CPUARCH}/Makefile.inc" + +LIBADD= util + .include diff --git a/lib/libvmmapi/amd64/Makefile.inc b/lib/libvmmapi/amd64/Makefile.inc new file mode 100644 index 000000000000..e51b9f9c2bfa --- /dev/null +++ b/lib/libvmmapi/amd64/Makefile.inc @@ -0,0 +1,2 @@ +SRCS+= vmmapi_machdep.c \ + vmmapi_freebsd_machdep.c diff --git a/lib/libvmmapi/vmmapi_freebsd.c b/lib/libvmmapi/amd64/vmmapi_freebsd_machdep.c similarity index 100% rename from lib/libvmmapi/vmmapi_freebsd.c rename to lib/libvmmapi/amd64/vmmapi_freebsd_machdep.c diff --git a/lib/libvmmapi/amd64/vmmapi_machdep.c b/lib/libvmmapi/amd64/vmmapi_machdep.c new file mode 100644 index 000000000000..e0b592a29b35 --- /dev/null +++ b/lib/libvmmapi/amd64/vmmapi_machdep.c @@ -0,0 +1,225 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2011 NetApp, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include "vmmapi.h" +#include "internal.h" + +/* + * From Intel Vol 3a: + * Table 9-1. IA-32 Processor States Following Power-up, Reset or INIT + */ +int +vcpu_reset(struct vcpu *vcpu) +{ + int error; + uint64_t rflags, rip, cr0, cr4, zero, desc_base, rdx; + uint32_t desc_access, desc_limit; + uint16_t sel; + + zero = 0; + + rflags = 0x2; + error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags); + if (error) + goto done; + + rip = 0xfff0; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip)) != 0) + goto done; + + /* + * According to Intels Software Developer Manual CR0 should be + * initialized with CR0_ET | CR0_NW | CR0_CD but that crashes some + * guests like Windows. + */ + cr0 = CR0_NE; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0) + goto done; + + if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR2, zero)) != 0) + goto done; + + if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR3, zero)) != 0) + goto done; + + cr4 = 0; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4)) != 0) + goto done; + + /* + * CS: present, r/w, accessed, 16-bit, byte granularity, usable + */ + desc_base = 0xffff0000; + desc_limit = 0xffff; + desc_access = 0x0093; + error = vm_set_desc(vcpu, VM_REG_GUEST_CS, + desc_base, desc_limit, desc_access); + if (error) + goto done; + + sel = 0xf000; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, sel)) != 0) + goto done; + + /* + * SS,DS,ES,FS,GS: present, r/w, accessed, 16-bit, byte granularity + */ + desc_base = 0; + desc_limit = 0xffff; + desc_access = 0x0093; + error = vm_set_desc(vcpu, VM_REG_GUEST_SS, + desc_base, desc_limit, desc_access); + if (error) + goto done; + + error = vm_set_desc(vcpu, VM_REG_GUEST_DS, + desc_base, desc_limit, desc_access); + if (error) + goto done; + + error = vm_set_desc(vcpu, VM_REG_GUEST_ES, + desc_base, desc_limit, desc_access); + if (error) + goto done; + + error = vm_set_desc(vcpu, VM_REG_GUEST_FS, + desc_base, desc_limit, desc_access); + if (error) + goto done; + + error = vm_set_desc(vcpu, VM_REG_GUEST_GS, + desc_base, desc_limit, desc_access); + if (error) + goto done; + + sel = 0; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, sel)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, sel)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, sel)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, sel)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, sel)) != 0) + goto done; + + if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, zero)) != 0) + goto done; + + /* General purpose registers */ + rdx = 0xf00; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RAX, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBX, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RCX, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDX, rdx)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSI, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDI, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBP, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R8, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R9, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R10, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R11, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R12, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R13, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R14, zero)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_R15, zero)) != 0) + goto done; + + /* GDTR, IDTR */ + desc_base = 0; + desc_limit = 0xffff; + desc_access = 0; + error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR, + desc_base, desc_limit, desc_access); + if (error != 0) + goto done; + + error = vm_set_desc(vcpu, VM_REG_GUEST_IDTR, + desc_base, desc_limit, desc_access); + if (error != 0) + goto done; + + /* TR */ + desc_base = 0; + desc_limit = 0xffff; + desc_access = 0x0000008b; + error = vm_set_desc(vcpu, VM_REG_GUEST_TR, 0, 0, desc_access); + if (error) + goto done; + + sel = 0; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, sel)) != 0) + goto done; + + /* LDTR */ + desc_base = 0; + desc_limit = 0xffff; + desc_access = 0x00000082; + error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, desc_base, + desc_limit, desc_access); + if (error) + goto done; + + sel = 0; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0) + goto done; + + if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR6, + 0xffff0ff0)) != 0) + goto done; + if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR7, 0x400)) != + 0) + goto done; + + if ((error = vm_set_register(vcpu, VM_REG_GUEST_INTR_SHADOW, + zero)) != 0) + goto done; + + error = 0; +done: + return (error); +} diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 6527cfc48e0d..5f812bcc832b 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -30,8 +30,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -1163,199 +1163,6 @@ vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state state) return (error); } -/* - * From Intel Vol 3a: - * Table 9-1. IA-32 Processor States Following Power-up, Reset or INIT - */ -int -vcpu_reset(struct vcpu *vcpu) -{ - int error; - uint64_t rflags, rip, cr0, cr4, zero, desc_base, rdx; - uint32_t desc_access, desc_limit; - uint16_t sel; - - zero = 0; - - rflags = 0x2; - error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags); - if (error) - goto done; - - rip = 0xfff0; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip)) != 0) - goto done; - - /* - * According to Intels Software Developer Manual CR0 should be - * initialized with CR0_ET | CR0_NW | CR0_CD but that crashes some - * guests like Windows. - */ - cr0 = CR0_NE; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0) - goto done; - - if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR2, zero)) != 0) - goto done; - - if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR3, zero)) != 0) - goto done; - - cr4 = 0; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4)) != 0) - goto done; - - /* - * CS: present, r/w, accessed, 16-bit, byte granularity, usable - */ - desc_base = 0xffff0000; - desc_limit = 0xffff; - desc_access = 0x0093; - error = vm_set_desc(vcpu, VM_REG_GUEST_CS, - desc_base, desc_limit, desc_access); - if (error) - goto done; - - sel = 0xf000; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, sel)) != 0) - goto done; - - /* - * SS,DS,ES,FS,GS: present, r/w, accessed, 16-bit, byte granularity - */ - desc_base = 0; - desc_limit = 0xffff; - desc_access = 0x0093; - error = vm_set_desc(vcpu, VM_REG_GUEST_SS, - desc_base, desc_limit, desc_access); - if (error) - goto done; - - error = vm_set_desc(vcpu, VM_REG_GUEST_DS, - desc_base, desc_limit, desc_access); - if (error) - goto done; - - error = vm_set_desc(vcpu, VM_REG_GUEST_ES, - desc_base, desc_limit, desc_access); - if (error) - goto done; - - error = vm_set_desc(vcpu, VM_REG_GUEST_FS, - desc_base, desc_limit, desc_access); - if (error) - goto done; - - error = vm_set_desc(vcpu, VM_REG_GUEST_GS, - desc_base, desc_limit, desc_access); - if (error) - goto done; - - sel = 0; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, sel)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, sel)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, sel)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, sel)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, sel)) != 0) - goto done; - - if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, zero)) != 0) - goto done; - - /* General purpose registers */ - rdx = 0xf00; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RAX, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBX, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RCX, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDX, rdx)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSI, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDI, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBP, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R8, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R9, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R10, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R11, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R12, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R13, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R14, zero)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_R15, zero)) != 0) - goto done; - - /* GDTR, IDTR */ - desc_base = 0; - desc_limit = 0xffff; - desc_access = 0; - error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR, - desc_base, desc_limit, desc_access); - if (error != 0) - goto done; - - error = vm_set_desc(vcpu, VM_REG_GUEST_IDTR, - desc_base, desc_limit, desc_access); - if (error != 0) - goto done; - - /* TR */ - desc_base = 0; - desc_limit = 0xffff; - desc_access = 0x0000008b; - error = vm_set_desc(vcpu, VM_REG_GUEST_TR, 0, 0, desc_access); - if (error) - goto done; - - sel = 0; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, sel)) != 0) - goto done; - - /* LDTR */ - desc_base = 0; - desc_limit = 0xffff; - desc_access = 0x00000082; - error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, desc_base, - desc_limit, desc_access); - if (error) - goto done; - - sel = 0; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0) - goto done; - - if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR6, - 0xffff0ff0)) != 0) - goto done; - if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR7, 0x400)) != - 0) - goto done; - - if ((error = vm_set_register(vcpu, VM_REG_GUEST_INTR_SHADOW, - zero)) != 0) - goto done; - - error = 0; -done: - return (error); -} - int vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num) {