From nobody Wed Feb 11 05:45:07 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D52A7580D; Fri, 17 May 2024 14:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715955611; cv=none; b=aKNW583Fp9ekvt2pbSvlZRpGakfl2tUhnLrrlwsK/k6Kwn6gZE1KifQVjv5x1EcVcRehzjvL0Doqdav3Zt+cSDG8BFxgRipQqTQ9qNrN9mtU/XLcDqIzrYTxbkPBtPQUMoOHNdJvr4s5R1jiDXsTdgdhQ/XtQJ44iMT6vP1YIbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715955611; c=relaxed/simple; bh=le6yIb+KkrwbWU/kef10H7UOenEhvxZ9rTsGqSJuqRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUePCu9cjVbAjQucJsmCJ6/JT7UaKzy9zzPyr9qGv1ZhPKwSlsT6YEDB4Ru5fPivW+eVRZzxueEVeSfPSVlBkHKR7gBqW4TM3sxy+R2n40FOxtWf8uBZzbBaybpfa4GceUbYbiKzB01GJax32NcRM6StodyRtiLYU5HMMpG0dj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RURYOxlF; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RURYOxlF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715955609; x=1747491609; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=le6yIb+KkrwbWU/kef10H7UOenEhvxZ9rTsGqSJuqRQ=; b=RURYOxlFawyAhJ4YY7UuHe/LjILJuNLfMOV3pAdn2rfi21NPpi8KAMQg aDwdxEsZsdXwWCGrl+sIo8wA8Y7STLXY3w4g4NXgQvaIEPytlUP4T+92Y UjTDk6FqNzctXlP3Yxd0/qi8/Mt0bkf/zuyineeCoRgWLULrZ/2SGu/Fy PhgGm8v2PNSBpY4JUXVUiyc2tOTE5ync05+faSvDUb/RdB9JkFwp4QUvH WEe2jM8vVN9AX0cRkyq+pt6E0+/rfojNGW4tvk+mFKzBYxjVmSEUUH1Dx O3MejvTax5r2ud4d6Fbh68UPchDoYaBecPVBOFK1z6mnA9sw3lQbeU/YP A==; X-CSE-ConnectionGUID: aFyu5bW+QCixFcncv4lcJA== X-CSE-MsgGUID: uhM4qc6VT5mCowsVpz82rg== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="22808782" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="22808782" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 07:20:05 -0700 X-CSE-ConnectionGUID: 8b0g7edORxeleq05MX/vxg== X-CSE-MsgGUID: pFaPFft6R127eW8Oa6P7+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="69253428" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 17 May 2024 07:20:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id A86DD125F; Fri, 17 May 2024 17:19:50 +0300 (EEST) From: "Kirill A. Shutemov" To: Sean Christopherson , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Josh Poimboeuf , Peter Zijlstra Cc: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 20/20] x86/tdx: Remove old TDCALL wrappers Date: Fri, 17 May 2024 17:19:38 +0300 Message-ID: <20240517141938.4177174-21-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240517141938.4177174-1-kirill.shutemov@linux.intel.com> References: <20240517141938.4177174-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All code has been converted to new TDCALL wrappers. Drop the old wrappers. Signed-off-by: Kirill A. Shutemov --- arch/x86/boot/compressed/tdx.c | 6 ---- arch/x86/coco/tdx/tdcall.S | 60 ++----------------------------- arch/x86/coco/tdx/tdx-shared.c | 20 ----------- arch/x86/coco/tdx/tdx.c | 18 ---------- arch/x86/include/asm/shared/tdx.h | 43 +--------------------- arch/x86/virt/vmx/tdx/tdxcall.S | 29 +++++---------- tools/objtool/noreturns.h | 1 - 7 files changed, 12 insertions(+), 165 deletions(-) diff --git a/arch/x86/boot/compressed/tdx.c b/arch/x86/boot/compressed/tdx.c index 0ae05edc7d42..b74084a46f2f 100644 --- a/arch/x86/boot/compressed/tdx.c +++ b/arch/x86/boot/compressed/tdx.c @@ -10,12 +10,6 @@ =20 #include =20 -/* Called from __tdx_hypercall() for unrecoverable failure */ -void __tdx_hypercall_failed(void) -{ - error("TDVMCALL failed. TDX module bug?"); -} - static inline unsigned int tdx_io_in(int size, u16 port) { u64 out; diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S index 5b60b9c8799f..407e2b7ae515 100644 --- a/arch/x86/coco/tdx/tdcall.S +++ b/arch/x86/coco/tdx/tdcall.S @@ -1,66 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include #include +#include =20 #include -#include =20 -#include "../../virt/vmx/tdx/tdxcall.S" - -.section .noinstr.text, "ax" - -/* - * __tdcall() - Used by TDX guests to request services from the TDX - * module (does not include VMM services) using TDCALL instruction. - * - * __tdcall() function ABI: - * - * @fn (RDI) - TDCALL Leaf ID, moved to RAX - * @args (RSI) - struct tdx_module_args for input - * - * Only RCX/RDX/R8-R11 are used as input registers. - * - * Return status of TDCALL via RAX. - */ -SYM_FUNC_START(__tdcall) - TDX_MODULE_CALL host=3D0 -SYM_FUNC_END(__tdcall) - -/* - * __tdcall_ret() - Used by TDX guests to request services from the TDX - * module (does not include VMM services) using TDCALL instruction, with - * saving output registers to the 'struct tdx_module_args' used as input. - * - * __tdcall_ret() function ABI: - * - * @fn (RDI) - TDCALL Leaf ID, moved to RAX - * @args (RSI) - struct tdx_module_args for input and output - * - * Only RCX/RDX/R8-R11 are used as input/output registers. - * - * Return status of TDCALL via RAX. - */ -SYM_FUNC_START(__tdcall_ret) - TDX_MODULE_CALL host=3D0 ret=3D1 -SYM_FUNC_END(__tdcall_ret) - -/* - * __tdcall_saved_ret() - Used by TDX guests to request services from the - * TDX module (including VMM services) using TDCALL instruction, with - * saving output registers to the 'struct tdx_module_args' used as input. - * - * __tdcall_saved_ret() function ABI: - * - * @fn (RDI) - TDCALL leaf ID, moved to RAX - * @args (RSI) - struct tdx_module_args for input/output - * - * All registers in @args are used as input/output registers. - * - * On successful completion, return the hypercall error code. - */ -SYM_FUNC_START(__tdcall_saved_ret) - TDX_MODULE_CALL host=3D0 ret=3D1 saved=3D1 -SYM_FUNC_END(__tdcall_saved_ret) +/* TDCALL is supported in Binutils >=3D 2.36 */ +#define tdcall .byte 0x66,0x0f,0x01,0xcc =20 /* * tdvmcall_trampoline() - Wrapper for TDG.VP.VMCALL. Covers common cases:= up diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c index 9104e96eeefd..b181f7d4d3b9 100644 --- a/arch/x86/coco/tdx/tdx-shared.c +++ b/arch/x86/coco/tdx/tdx-shared.c @@ -69,23 +69,3 @@ bool tdx_accept_memory(phys_addr_t start, phys_addr_t en= d) =20 return true; } - -noinstr u64 __tdx_hypercall(struct tdx_module_args *args) -{ - /* - * For TDVMCALL explicitly set RCX to the bitmap of shared registers. - * The caller isn't expected to set @args->rcx anyway. - */ - args->rcx =3D TDVMCALL_EXPOSE_REGS_MASK; - - /* - * Failure of __tdcall_saved_ret() indicates a failure of the TDVMCALL - * mechanism itself and that something has gone horribly wrong with - * the TDX module. __tdx_hypercall_failed() never returns. - */ - if (__tdcall_saved_ret(TDG_VP_VMCALL, args)) - __tdx_hypercall_failed(); - - /* TDVMCALL leaf return code is in R10 */ - return args->r10; -} diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 45be53d5eeb4..7d9306bd67af 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -38,13 +38,6 @@ =20 static atomic_long_t nr_shared; =20 -/* Called from __tdx_hypercall() for unrecoverable failure */ -noinstr void __noreturn __tdx_hypercall_failed(void) -{ - instrumentation_begin(); - panic("TDVMCALL failed. TDX module bug?"); -} - #ifdef CONFIG_KVM_GUEST long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2, unsigned long p3, unsigned long p4) @@ -62,17 +55,6 @@ long tdx_kvm_hypercall(unsigned int nr, unsigned long p1= , unsigned long p2, EXPORT_SYMBOL_GPL(tdx_kvm_hypercall); #endif =20 -/* - * Used for TDX guests to make calls directly to the TD module. This - * should only be used for calls that have no legitimate reason to fail - * or where the kernel can not survive the call failing. - */ -static inline void tdcall(u64 fn, struct tdx_module_args *args) -{ - if (__tdcall_ret(fn, args)) - panic("TDCALL %lld failed (Buggy TDX module!)\n", fn); -} - /* Read TD-scoped metadata */ static inline u64 tdg_vm_rd(u64 field, u64 *value) { diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/share= d/tdx.h index 70190ebc63ca..cbbc679d64a2 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -55,17 +55,6 @@ #define TDX_R14 BIT(14) #define TDX_R15 BIT(15) =20 -/* - * These registers are clobbered to hold arguments for each - * TDVMCALL. They are safe to expose to the VMM. - * Each bit in this mask represents a register ID. Bit field - * details can be found in TDX GHCI specification, section - * titled "TDCALL [TDG.VP.VMCALL] leaf". - */ -#define TDVMCALL_EXPOSE_REGS_MASK \ - (TDX_RDX | TDX_RBX | TDX_RSI | TDX_RDI | TDX_R8 | TDX_R9 | \ - TDX_R10 | TDX_R11 | TDX_R12 | TDX_R13 | TDX_R14 | TDX_R15) - /* TDX supported page sizes from the TDX module ABI. */ #define TDX_PS_4K 0 #define TDX_PS_2M 1 @@ -193,7 +182,7 @@ }) =20 /* - * Used in __tdcall*() to gather the input/output registers' values of the + * Used in __seamcall*() to gather the input/output registers' values of t= he * TDCALL instruction when requesting services from the TDX module. This i= s a * software only structure and not part of the TDX module/VMM ABI */ @@ -216,36 +205,6 @@ struct tdx_module_args { u64 rsi; }; =20 -/* Used to communicate with the TDX module */ -u64 __tdcall(u64 fn, struct tdx_module_args *args); -u64 __tdcall_ret(u64 fn, struct tdx_module_args *args); -u64 __tdcall_saved_ret(u64 fn, struct tdx_module_args *args); - -/* Used to request services from the VMM */ -u64 __tdx_hypercall(struct tdx_module_args *args); - -/* - * Wrapper for standard use of __tdx_hypercall with no output aside from - * return code. - */ -static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r1= 5) -{ - struct tdx_module_args args =3D { - .r10 =3D TDX_HYPERCALL_STANDARD, - .r11 =3D fn, - .r12 =3D r12, - .r13 =3D r13, - .r14 =3D r14, - .r15 =3D r15, - }; - - return __tdx_hypercall(&args); -} - - -/* Called from __tdx_hypercall() for unrecoverable failure */ -void __noreturn __tdx_hypercall_failed(void); - bool tdx_accept_memory(phys_addr_t start, phys_addr_t end); =20 /* diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcal= l.S index 016a2a1ec1d6..7ad2fc6ba9c8 100644 --- a/arch/x86/virt/vmx/tdx/tdxcall.S +++ b/arch/x86/virt/vmx/tdx/tdxcall.S @@ -4,33 +4,28 @@ #include #include =20 -/* - * TDCALL and SEAMCALL are supported in Binutils >=3D 2.36. - */ -#define tdcall .byte 0x66,0x0f,0x01,0xcc +/* SEAMCALL is supported in Binutils >=3D 2.36 */ #define seamcall .byte 0x66,0x0f,0x01,0xcf =20 /* * TDX_MODULE_CALL - common helper macro for both * TDCALL and SEAMCALL instructions. * - * TDCALL - used by TDX guests to make requests to the - * TDX module and hypercalls to the VMM. * SEAMCALL - used by TDX hosts to make requests to the * TDX module. * *------------------------------------------------------------------------- - * TDCALL/SEAMCALL ABI: + * SEAMCALL ABI: *------------------------------------------------------------------------- * Input Registers: * - * RAX - TDCALL/SEAMCALL Leaf number. - * RCX,RDX,RDI,RSI,RBX,R8-R15 - TDCALL/SEAMCALL Leaf specific input regist= ers. + * RAX - SEAMCALL Leaf number. + * RCX,RDX,RDI,RSI,RBX,R8-R15 - SEAMCALL Leaf specific input registers. * * Output Registers: * - * RAX - TDCALL/SEAMCALL instruction error code. - * RCX,RDX,RDI,RSI,RBX,R8-R15 - TDCALL/SEAMCALL Leaf specific output regis= ters. + * RAX - SEAMCALL instruction error code. + * RCX,RDX,RDI,RSI,RBX,R8-R15 - SEAMCALL Leaf specific output registers. * *------------------------------------------------------------------------- * @@ -42,7 +37,7 @@ * also tramples on RDI,RSI. This isn't strictly true, see for example * TDH.EXPORT.MEM. */ -.macro TDX_MODULE_CALL host:req ret=3D0 saved=3D0 +.macro TDX_MODULE_CALL ret=3D0 saved=3D0 FRAME_BEGIN =20 /* Move Leaf ID to RAX */ @@ -85,7 +80,6 @@ movq TDX_MODULE_rsi(%rsi), %rsi .endif /* \saved */ =20 -.if \host .Lseamcall\@: seamcall /* @@ -100,9 +94,6 @@ * it is from the Reserved status code class. */ jc .Lseamcall_vmfailinvalid\@ -.else - tdcall -.endif =20 .if \ret .if \saved @@ -172,11 +163,9 @@ xorl %r15d, %r15d xorl %ebx, %ebx xorl %edi, %edi -.endif /* \ret && \host */ +.endif /* \saved && \ret */ =20 -.if \host .Lout\@: -.endif =20 .if \saved /* Restore callee-saved GPRs as mandated by the x86_64 ABI */ @@ -190,7 +179,6 @@ FRAME_END RET =20 -.if \host .Lseamcall_vmfailinvalid\@: mov $TDX_SEAMCALL_VMFAILINVALID, %rax jmp .Lseamcall_fail\@ @@ -215,6 +203,5 @@ jmp .Lout\@ =20 _ASM_EXTABLE_FAULT(.Lseamcall\@, .Lseamcall_trap\@) -.endif /* \host */ =20 .endm diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 0670cacf0734..1e82a96ba960 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -11,7 +11,6 @@ NORETURN(__kunit_abort) NORETURN(__module_put_and_kthread_exit) NORETURN(__reiserfs_panic) NORETURN(__stack_chk_fail) -NORETURN(__tdx_hypercall_failed) NORETURN(__ubsan_handle_builtin_unreachable) NORETURN(arch_cpu_idle_dead) NORETURN(bch2_trans_in_restart_error) --=20 2.43.0