From nobody Fri Dec 19 21:57:56 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 142B9EB64DD for ; Wed, 12 Jul 2023 08:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233090AbjGLI4X (ORCPT ); Wed, 12 Jul 2023 04:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbjGLI4F (ORCPT ); Wed, 12 Jul 2023 04:56:05 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 778A0E4F; Wed, 12 Jul 2023 01:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689152155; x=1720688155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ikkpu51RPvWM8vb5NBADQ78CpgdFlbX493VUa4jw8tw=; b=WF8CDGOl1UXAE1kyTaMBj3dJs02tu3I1VO+luNP9eO5tL/eX5L3NbLid Z7I1neXn87uNb8aAImbgs4j5V10EZq6YaTqZRY/gtWQ1KU+pJPJpzu5Wl w5u0Hy8SA3SuIMCxOd3yPBWGh87CWJTYsIiWIrQagJUp8r1BhQgKLCAco g3uknjZ+oLnwajHs6vbv2T4r/hMGd1vu+jLbo7IS7mIQQ0l+6XRcG8RsC l//To1AiYYKt4wOn02PykNybpIcJuQ6lojUzMj7dLa5I+O2SqdcMtfPDD a/uoipxc40tICBgcWH1Y7mZPm3KYYoTNufjbB6/SAGYRfsVaChGcW62G4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="344439196" X-IronPort-AV: E=Sophos;i="6.01,199,1684825200"; d="scan'208";a="344439196" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 01:55:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="845573381" X-IronPort-AV: E=Sophos;i="6.01,199,1684825200"; d="scan'208";a="845573381" Received: from mjamatan-mobl2.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.209.168.102]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 01:55:51 -0700 From: Kai Huang To: peterz@infradead.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org Cc: dave.hansen@intel.com, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, isaku.yamahata@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, kai.huang@intel.com Subject: [PATCH 05/10] x86/tdx: Rename __tdx_module_call() to __tdcall() Date: Wed, 12 Jul 2023 20:55:19 +1200 Message-ID: <445bf6aa2f2c068bc542734f2b4bd18f1fee6d1d.1689151537.git.kai.huang@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" __tdx_module_call() is only used by the TDX guest to issue TDCALL to the TDX module. Rename it to __tdcall() to match its behaviour, e.g., it cannot be used to make host-side SEAMCALL. Also rename tdx_module_call() which is a wrapper of __tdx_module_call() to tdcall(). No functional change intended. Signed-off-by: Kai Huang --- arch/x86/coco/tdx/tdcall.S | 10 +++++----- arch/x86/coco/tdx/tdx.c | 20 ++++++++++---------- arch/x86/include/asm/tdx.h | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S index e5d4b7d8ecd4..6aebac08f2bf 100644 --- a/arch/x86/coco/tdx/tdcall.S +++ b/arch/x86/coco/tdx/tdcall.S @@ -40,8 +40,8 @@ .section .noinstr.text, "ax" =20 /* - * __tdx_module_call() - Used by TDX guests to request services from - * the TDX module (does not include VMM services) using TDCALL instruction. + * __tdcall() - Used by TDX guests to request services from the TDX + * module (does not include VMM services) using TDCALL instruction. * * Transforms function call register arguments into the TDCALL register AB= I. * After TDCALL operation, TDX module output is saved in @out (if it is @@ -62,7 +62,7 @@ * *------------------------------------------------------------------------- * - * __tdx_module_call() function ABI: + * __tdcall() function ABI: * * @fn (RDI) - TDCALL Leaf ID, moved to RAX * @rcx (RSI) - Input parameter 1, moved to RCX @@ -77,9 +77,9 @@ * * Return status of TDCALL via RAX. */ -SYM_FUNC_START(__tdx_module_call) +SYM_FUNC_START(__tdcall) TDX_MODULE_CALL host=3D0 -SYM_FUNC_END(__tdx_module_call) +SYM_FUNC_END(__tdcall) =20 /* * TDX_HYPERCALL - Make hypercalls to a TDX VMM using TDVMCALL leaf of TDC= ALL diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index de021df92009..268f812ff595 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -98,10 +98,10 @@ EXPORT_SYMBOL_GPL(tdx_kvm_hypercall); * 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 tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r= 9, - struct tdx_module_output *out) +static inline void tdcall(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, + struct tdx_module_output *out) { - if (__tdx_module_call(fn, rcx, rdx, r8, r9, out)) + if (__tdcall(fn, rcx, rdx, r8, r9, out)) panic("TDCALL %lld failed (Buggy TDX module!)\n", fn); } =20 @@ -123,9 +123,9 @@ int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport) { u64 ret; =20 - ret =3D __tdx_module_call(TDG_MR_REPORT, virt_to_phys(tdreport), - virt_to_phys(reportdata), TDREPORT_SUBTYPE_0, - 0, NULL); + ret =3D __tdcall(TDG_MR_REPORT, virt_to_phys(tdreport), + virt_to_phys(reportdata), TDREPORT_SUBTYPE_0, + 0, NULL); if (ret) { if (TDCALL_RETURN_CODE(ret) =3D=3D TDCALL_INVALID_OPERAND) return -EINVAL; @@ -184,7 +184,7 @@ static void tdx_parse_tdinfo(u64 *cc_mask) * Guest-Host-Communication Interface (GHCI), section 2.4.2 TDCALL * [TDG.VP.INFO]. */ - tdx_module_call(TDG_VP_INFO, 0, 0, 0, 0, &out); + tdcall(TDG_VP_INFO, 0, 0, 0, 0, &out); =20 /* * The highest bit of a guest physical address is the "sharing" bit. @@ -626,7 +626,7 @@ void tdx_get_ve_info(struct ve_info *ve) * Note, the TDX module treats virtual NMIs as inhibited if the #VE * valid flag is set. It means that NMI=3D>#VE will not result in a #DF. */ - tdx_module_call(TDG_VP_VEINFO_GET, 0, 0, 0, 0, &out); + tdcall(TDG_VP_VEINFO_GET, 0, 0, 0, 0, &out); =20 /* Transfer the output parameters */ ve->exit_reason =3D out.rcx; @@ -768,7 +768,7 @@ static bool try_accept_one(phys_addr_t *start, unsigned= long len, } =20 tdcall_rcx =3D *start | page_size; - if (__tdx_module_call(TDG_MEM_PAGE_ACCEPT, tdcall_rcx, 0, 0, 0, NULL)) + if (__tdcall(TDG_MEM_PAGE_ACCEPT, tdcall_rcx, 0, 0, 0, NULL)) return false; =20 *start +=3D accept_size; @@ -870,7 +870,7 @@ void __init tdx_early_init(void) cc_set_mask(cc_mask); =20 /* Kernel does not use NOTIFY_ENABLES and does not need random #VEs */ - tdx_module_call(TDG_VM_WR, 0, TDCS_NOTIFY_ENABLES, 0, -1ULL, NULL); + tdcall(TDG_VM_WR, 0, TDCS_NOTIFY_ENABLES, 0, -1ULL, NULL); =20 /* * All bits above GPA width are reserved and kernel treats shared bit diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 28d889c9aa16..f19e329c4044 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -56,8 +56,8 @@ struct ve_info { void __init tdx_early_init(void); =20 /* Used to communicate with the TDX module */ -u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, - struct tdx_module_output *out); +u64 __tdcall(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, + struct tdx_module_output *out); =20 void tdx_get_ve_info(struct ve_info *ve); =20 --=20 2.41.0