From mboxrd@z Thu Jan 1 00:00:00 1970 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 30685C433FE for ; Fri, 4 Mar 2022 20:06:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbiCDUHK (ORCPT ); Fri, 4 Mar 2022 15:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230228AbiCDUGj (ORCPT ); Fri, 4 Mar 2022 15:06:39 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D749A76D2; Fri, 4 Mar 2022 12:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646424083; x=1677960083; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8ferppz4eR2spSd3kgPq7FJIv1ClxuWQHKELTGTPvqk=; b=RiaPsT8eR5i2nhD4tPSBJzFBKYtnkhqw84vQFRubWuIzprurEDGIajJa ghqcBsXbhOhRZin99LZBu9uJcLbleLKqh1ljyUHNBkr1Pv1JIg0jmpWOk svEOyq7OfOhYY2ruCAtEVqzmufKIRSI57D2hPe/t6gt78rtzS8s8az6MF HfgqzzIbZBCtK1OUSyVhsfdUqWfx4AE7qdc/fTR3d7WExE0goLARRljNs Tdqhs2PGXpTpiPfI4gk/U2WQwR+WVH3RPRZBuOczUNfdU3EKycA8mpepV 4XOLFhwTJM72ZVg00/DOsQBg/NBwna4H6ZBOnoRqjO8T7fio06lOYuKiI Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10276"; a="253983348" X-IronPort-AV: E=Sophos;i="5.90,156,1643702400"; d="scan'208";a="253983348" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 11:50:10 -0800 X-IronPort-AV: E=Sophos;i="5.90,156,1643702400"; d="scan'208";a="552344158" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 11:50:10 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Subject: [RFC PATCH v5 015/104] KVM: TDX: add a helper function for KVM to issue SEAMCALL Date: Fri, 4 Mar 2022 11:48:31 -0800 Message-Id: <5cf00a5f5d108443a081ef95db9c7695be99c7d4.1646422845.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaku Yamahata TODO: Consolidate seamcall helper function with TDX host/guest patch series. For now, this is kept to make this patch series compile/work. A VMM interacts with the TDX module using a new instruction (SEAMCALL). A TDX VMM uses SEAMCALLs where a VMX VMM would have directly interacted with VMX instructions. For instance, a TDX VMM does not have full access to the VM control structure corresponding to VMX VMCS. Instead, a VMM induces the TDX module to act on behalf via SEAMCALLs. Add a helper function for KVM C code to execute SEAMCALL instruction to hide its SEAMCALL ABI details. Although the x86 TDX host patch series defines a similar wrapper, the KVM TDX patch series defines its own because KVM TDX case is performance-critical, unlike the x86 TDX one that does one-time initialization. The difference is that the KVM TDX one is defined as a static inline function without an error check that is known to not happen so that compiler can optimize it better. The wrapper fiction in the x86 TDX host patch is defined as a function written in assembly code with error check so that it can detect errors that can occur only during the initialization. Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/seamcall.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 arch/x86/kvm/vmx/seamcall.h diff --git a/arch/x86/kvm/vmx/seamcall.h b/arch/x86/kvm/vmx/seamcall.h new file mode 100644 index 000000000000..604792e9a59f --- /dev/null +++ b/arch/x86/kvm/vmx/seamcall.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __KVM_VMX_SEAMCALL_H +#define __KVM_VMX_SEAMCALL_H + +#ifdef CONFIG_INTEL_TDX_HOST + +#ifdef __ASSEMBLY__ + +.macro seamcall + .byte 0x66, 0x0f, 0x01, 0xcf +.endm + +#else + +struct tdx_module_output; +u64 kvm_seamcall(u64 op, u64 rcx, u64 rdx, u64 r8, u64 r9, u64 r10, + struct tdx_module_output *out); + +#endif /* !__ASSEMBLY__ */ + +#endif /* CONFIG_INTEL_TDX_HOST */ + +#endif /* __KVM_VMX_SEAMCALL_H */ -- 2.25.1