From patchwork Tue Apr 1 22:21:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin X-Patchwork-Id: 14035381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CDA9C36010 for ; Tue, 1 Apr 2025 22:22:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934832.1336435 (Exim 4.92) (envelope-from ) id 1tzjzL-0000kA-0e; Tue, 01 Apr 2025 22:21:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934832.1336435; Tue, 01 Apr 2025 22:21:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzjzK-0000k1-TX; Tue, 01 Apr 2025 22:21:42 +0000 Received: by outflank-mailman (input) for mailman id 934832; Tue, 01 Apr 2025 22:21:42 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzjzK-0008FS-10 for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 22:21:42 +0000 Received: from mail-10631.protonmail.ch (mail-10631.protonmail.ch [79.135.106.31]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id af2da4f7-0f47-11f0-9ffb-bf95429c2676; Wed, 02 Apr 2025 00:21:40 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: af2da4f7-0f47-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1743546099; x=1743805299; bh=ACi96G57+RpQp/2aY30Q6dbZ1Kg2jsTyScAUQdNS6S8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=UNRyWTskDvaSWQUDN6iEwtcQEWqV1uQrQMEJTfC+oaLCO/0CJtOLhD1G6XV0R2pZ+ ribt3Q2B5B/6s2eQ0QVZfP8zgB0/FdSrNNE9SaUVodbdOeeHsPXLNLHD5NWsAgvtBD 4EEXyUhOgDfuquVs1g4G/4k/Nvm2Jt7doATALJ74GIn0evs/34H2cL7awHbPZNaxrg E0exOpP55rLABvY5z8v7w5veaFzB6z8kXJrQtTvCeOCF0DlTtlhgPbZAdb/GUDwOtW V148eXSvwm7yw9QEQeFmHlo6bDicUusIq/65OHOe3Y3wQ/yHWdhPu0qVFqhSo3usya role6lyRYHCEg== Date: Tue, 01 Apr 2025 22:21:34 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 4/5] x86/vmx: remove *_OPCODE Message-ID: <20250401222105.79309-5-dmukhin@ford.com> In-Reply-To: <20250401222105.79309-1-dmukhin@ford.com> References: <20250401222105.79309-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: a105727e2157e3c7085f480a753c9f41cb30c15e MIME-Version: 1.0 From: Denis Mukhin Remove all *_OPCODE definitions from vmx.h now that all used VMX instructions are natively supported by the baseline compiler. Use vmxon and vmxoff instructions directly. Update __vmxon() to account for vmxon use. Resolves: https://gitlab.com/xen-project/xen/-/work_items/202 Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/hvm/vmx/vmx.h | 34 ++++++-------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/asm/hvm/vmx/vmx.h index 10c0619108..1d63e49288 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -257,24 +257,6 @@ typedef union cr_access_qual { #define X86_SEG_AR_GRANULARITY (1u << 15) /* 15, granularity */ #define X86_SEG_AR_SEG_UNUSABLE (1u << 16) /* 16, segment unusable */ -#define VMCALL_OPCODE ".byte 0x0f,0x01,0xc1\n" -#define VMCLEAR_OPCODE ".byte 0x66,0x0f,0xc7\n" /* reg/opcode: /6 */ -#define VMLAUNCH_OPCODE ".byte 0x0f,0x01,0xc2\n" -#define VMPTRLD_OPCODE ".byte 0x0f,0xc7\n" /* reg/opcode: /6 */ -#define VMPTRST_OPCODE ".byte 0x0f,0xc7\n" /* reg/opcode: /7 */ -#define VMREAD_OPCODE ".byte 0x0f,0x78\n" -#define VMRESUME_OPCODE ".byte 0x0f,0x01,0xc3\n" -#define VMWRITE_OPCODE ".byte 0x0f,0x79\n" -#define INVEPT_OPCODE ".byte 0x66,0x0f,0x38,0x80\n" /* m128,r64/32 */ -#define INVVPID_OPCODE ".byte 0x66,0x0f,0x38,0x81\n" /* m128,r64/32 */ -#define VMXOFF_OPCODE ".byte 0x0f,0x01,0xc4\n" -#define VMXON_OPCODE ".byte 0xf3,0x0f,0xc7\n" - -#define MODRM_EAX_08 ".byte 0x08\n" /* ECX, [EAX] */ -#define MODRM_EAX_06 ".byte 0x30\n" /* [EAX], with reg/opcode: /6 */ -#define MODRM_EAX_07 ".byte 0x38\n" /* [EAX], with reg/opcode: /7 */ -#define MODRM_EAX_ECX ".byte 0xc1\n" /* EAX, ECX */ - extern uint8_t posted_intr_vector; #define cpu_has_vmx_ept_exec_only_supported \ @@ -497,9 +479,7 @@ static inline void vpid_sync_all(void) static inline void __vmxoff(void) { - asm volatile ( - VMXOFF_OPCODE - : : : "memory" ); + asm volatile ("vmxoff" : : : "memory"); } static inline int __vmxon(u64 addr) @@ -507,15 +487,17 @@ static inline int __vmxon(u64 addr) int rc; asm volatile ( - "1: " VMXON_OPCODE MODRM_EAX_06 "\n" - " setna %b0 ; neg %0\n" /* CF==1 or ZF==1 --> rc = -1 */ + "1: vmxon (%[addr])\n" + " setna %b[rc]\n" + " neg %[rc]\n" /* CF==1 or ZF==1 --> rc = -1 */ "2:\n" ".section .fixup,\"ax\"\n" - "3: sub $2,%0 ; jmp 2b\n" /* #UD or #GP --> rc = -2 */ + "3: mov $-2, %[rc]\n" + " jmp 2b\n" /* #UD or #GP --> rc = -2 */ ".previous\n" _ASM_EXTABLE(1b, 3b) - : "=q" (rc) - : "0" (0), "a" (&addr) + : [rc] "=q" (rc) + : "0" (0), [addr] "r" (&addr) : "memory"); return rc;