Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4403991ioa; Wed, 27 Apr 2022 03:08:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfIkp9oyQF/hIyDcPlu+iIpTsIcx8+REgICZ9BvRdogUo3PRiko/itHakQiYAR53RZHYms X-Received: by 2002:a17:90b:1d0e:b0:1d2:79e9:21aa with SMTP id on14-20020a17090b1d0e00b001d279e921aamr42458068pjb.153.1651054121484; Wed, 27 Apr 2022 03:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651054121; cv=none; d=google.com; s=arc-20160816; b=lfEag2tTv2h6FE5JvwsAUiJIkR4GowISFquuepUJvnShIjopxFOv7WLtWLRtuucN/n YGz505zyXnEbMSt9cxYn2Vfm9ANVaQ+X/phQTSGhKonRPtYnSiZK1pUFleM8UD2RqIVC 2iOjO/JOHYbdtUHnyf4K8vbrZqsM2CQROCTKMfzh7Pb4yPLZ4yN+8/ftlfSQbFLhGt+5 +2T2AShnWsd8vGnjjEn9jOtoVVjNEM+xWggGOPtQsrxXDWBGRyJTc9DeZYShnB6/meL8 NTih8vy1kYXkNJYdB0cZrdbpzffD3jSlvbi3hVvi9MDLsYmnHGkxUP+aYrrDJ2kHlD1x ERNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=gwlFeA+CS4QmZSnWItCNRPWjYETow68BRIa9um6DTEs=; b=ajivaHp63nmT8ksMUUpB6nesnrBdZskHaOD0CnzfBZdMjEYwPbuNZWrbyzo1DPrfUQ Oig+KCb09Fcs3cPjRjZ8PHW1iN5mnBOLdRK6yuNDxulpFf1T8JSiG25BO7c5QyU8eLO+ AszuFYzhE9HRDJM4ZT5TBcl2ZW1NCWFKwsPYfo2WGBZrWU1dBMaGWM40V8C+yj6NX9L/ aAISx5muPEKWgQyZYn7s8EPn1QxCV8RDYHfpD0tahPwrXDlpnalSG9SMFXm/m2BD8Qj5 uyJoQT+P3ASfMQA20mVRH9kvdVRD2y4vHKu+HRV2/eJCVW1T03JqvfKdNRw9NCQQOWRT tniA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JuKbdpcT; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j64-20020a638b43000000b003ab0e9b4af1si1023645pge.552.2022.04.27.03.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:08:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JuKbdpcT; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A08F2FEF9D; Wed, 27 Apr 2022 02:31:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356103AbiDZXc4 (ORCPT + 99 others); Tue, 26 Apr 2022 19:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240844AbiDZXcz (ORCPT ); Tue, 26 Apr 2022 19:32:55 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E78893E5E7; Tue, 26 Apr 2022 16:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651015786; x=1682551786; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jg6MtdXlvFgENt7ZsabQaNTY1fdrl0LJB7EK7BdY6Q8=; b=JuKbdpcTU+L/+my+COGNJbshMbGxVZrUhT1nxXXDodKa+lFpXjaJNS4i CFLGGoAsEZ3f3zIDgIyvN1jFZN/i8bTpauRoivKelhjRZWyzjtRzDpxCb lgm5nKY8g9/ToE5G50YMk6EFOSpqnpYEuZApSgAtS9xTpnRQP9k2ogFi3 3MTFAZ8o9BzxWieLkbm5mdktL/ZdctisKv5WhPFjN11nd0yixJ8AL4UcB SyPR1aNWbifEPuLUsLi1p8btK8cpfmKDjh/Qf4Qg03aLKYdciVO7b3Sej fSrDbKwcgRiVxIXU156wKT4369X+luitMZGIlCxFcxTjyqX/1VK55rb/c w==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="328695778" X-IronPort-AV: E=Sophos;i="5.90,292,1643702400"; d="scan'208";a="328695778" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 16:29:45 -0700 X-IronPort-AV: E=Sophos;i="5.90,292,1643702400"; d="scan'208";a="532913579" Received: from ssaride-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.0.221]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 16:29:41 -0700 Message-ID: Subject: Re: [PATCH v3 03/21] x86/virt/tdx: Implement the SEAMCALL base function From: Kai Huang To: Dave Hansen , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, isaku.yamahata@intel.com Date: Wed, 27 Apr 2022 11:29:39 +1200 In-Reply-To: <56f368c6-4a60-ea78-2cc7-cd2d57823e3a@intel.com> References: <1c3f555934c73301a9cbf10232500f3d15efe3cc.1649219184.git.kai.huang@intel.com> <56f368c6-4a60-ea78-2cc7-cd2d57823e3a@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-04-26 at 13:37 -0700, Dave Hansen wrote: > On 4/5/22 21:49, Kai Huang wrote: > > Secure Arbitration Mode (SEAM) is an extension of VMX architecture. It > > defines a new VMX root operation (SEAM VMX root) and a new VMX non-root > > operation (SEAM VMX non-root) which are isolated from legacy VMX root > > and VMX non-root mode. > > I feel like this is too much detail for an opening paragraph. > > > A CPU-attested software module (called the 'TDX module') runs in SEAM > > VMX root to manage the crypto-protected VMs running in SEAM VMX non-root. > > SEAM VMX root is also used to host another CPU-attested software module > > (called the 'P-SEAMLDR') to load and update the TDX module. > > > Host kernel transits to either the P-SEAMLDR or the TDX module via the > > new SEAMCALL instruction. SEAMCALL leaf functions are host-side > > interface functions defined by the P-SEAMLDR and the TDX module around > > the new SEAMCALL instruction. They are similar to a hypercall, except > > they are made by host kernel to the SEAM software. > > I think you can get rid of about half of this changelog so farand make > it more clear in the process with this: > > TDX introduces a new CPU mode: Secure Arbitration Mode (SEAM). > This mode runs only the TDX module itself or other code needed > to load the TDX module. > > The host kernel communicates with SEAM software via a new > SEAMCALL instruction. This is conceptually similar to > a guest->host hypercall, except it is made from the host to SEAM > software instead. Thank you! > > This is a technical document, but you're writing too technically for my > taste and focusing on the low-level details rather than the high-level > concepts. What do I care that SEAM is two modes and what their names > are at this juncture? Are those details necesarry to get me to > understand what a SEAMCALL is or what this patch implements? Thanks for the point. I'll revisit this series based on this in next version. > > > SEAMCALL leaf functions use an ABI different from the x86-64 system-v > > ABI. Instead, they share the same ABI with the TDCALL leaf functions. > > %rax is used to carry both the SEAMCALL leaf function number (input) and > > the completion status code (output). Additional GPRs (%rcx, %rdx, > > %r8->%r11) may be further used as both input and output operands in > > individual leaf functions. > > > > Implement a C function __seamcall() > > Your "C function" looks a bit like assembly to me. Will change to (I saw TDX guest patch used similar way): Add a generic interface to do SEAMCALL leaf functions, using the assembly macro used by __tdx_module_call(). > > > to do SEAMCALL leaf functions using > > the assembly macro used by __tdx_module_call() (the implementation of > > TDCALL leaf functions). The only exception not covered here is TDENTER > > leaf function which takes all GPRs and XMM0-XMM15 as both input and > > output. The caller of TDENTER should implement its own logic to call > > TDENTER directly instead of using this function. > > I have no idea why this paragraph is here or what it is trying to tell me. Will get rid of the rest staff. > > > SEAMCALL instruction is essentially a VMExit from VMX root to SEAM VMX > > root, and it can fail with VMfailInvalid, for instance, when the SEAM > > software module is not loaded. The C function __seamcall() returns > > TDX_SEAMCALL_VMFAILINVALID, which doesn't conflict with any actual error > > code of SEAMCALLs, to uniquely represent this case. > > Again, I'm lost. Why is this detail here? I don't even see > TDX_SEAMCALL_VMFAILINVALID in the patch. Will remove. > > > diff --git a/arch/x86/virt/vmx/tdx/Makefile b/arch/x86/virt/vmx/tdx/Makefile > > index 1bd688684716..fd577619620e 100644 > > --- a/arch/x86/virt/vmx/tdx/Makefile > > +++ b/arch/x86/virt/vmx/tdx/Makefile > > @@ -1,2 +1,2 @@ > > # SPDX-License-Identifier: GPL-2.0-only > > -obj-$(CONFIG_INTEL_TDX_HOST) += tdx.o > > +obj-$(CONFIG_INTEL_TDX_HOST) += tdx.o seamcall.o > > diff --git a/arch/x86/virt/vmx/tdx/seamcall.S b/arch/x86/virt/vmx/tdx/seamcall.S > > new file mode 100644 > > index 000000000000..327961b2dd5a > > --- /dev/null > > +++ b/arch/x86/virt/vmx/tdx/seamcall.S > > @@ -0,0 +1,52 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +#include > > +#include > > + > > +#include "tdxcall.S" > > + > > +/* > > + * __seamcall() - Host-side interface functions to SEAM software module > > + * (the P-SEAMLDR or the TDX module) > > + * > > + * Transform function call register arguments into the SEAMCALL register > > + * ABI. Return TDX_SEAMCALL_VMFAILINVALID, or the completion status of > > + * the SEAMCALL. Additional output operands are saved in @out (if it is > > + * provided by caller). > > This needs to say: > > Returns TDX_SEAMCALL_VMFAILINVALID if the SEAMCALL itself fails. OK. -- Thanks, -Kai