Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp85611lqp; Wed, 20 Mar 2024 14:36:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXd6NcMAtRXG8t0/RQFNOy1qJHIMcBV33/FLcD9xgV63zEEGxaaoWgJQpQ3OuJfcd7Ws72CFKfMm/0ieneqhlV08KYC+/nlR60WyIK0rQ== X-Google-Smtp-Source: AGHT+IGvl1M/7PK2vtHhtDQEYmDArAc81JbA4yqIhES6Rc6BckeB2dYBLUqn7CLFy61sdNwk4tpq X-Received: by 2002:a17:90a:d70b:b0:29f:e036:338d with SMTP id y11-20020a17090ad70b00b0029fe036338dmr5390501pju.29.1710970578471; Wed, 20 Mar 2024 14:36:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710970578; cv=pass; d=google.com; s=arc-20160816; b=edQXIROC7arfuri8bUwt6zoafgYf6tz/gkLKRMhQR6eE0rr4jQ+Rp/IhxUAAo0krSM JM1sYmYMvYPuXcuZtDm6qVfkMlqobLnbksdIWsvKGjzm9gmGs5JuGZkWBW7TJvPinqqa g8C5SWjnOryQdsskxvHtLcNolegwkFF2VJk41h5rcAbEaL6jAzq2mw5SXz3shOIDVN0W cicBQ09Qn/hvJ8XcdtOyI1TFU3fDU+MIZj7Dys7ZOPLjlsUjAnesKqxkiCsjFuoTQyL4 EmefKaHOXLcBkqVLFB91CYMP8IqTB2uzvOL6aj1BkXl9sKFbhFXLH7BbIw3qsCfnZDSj uGoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=p0DqgG6hdJ0RHp7xRLt9+TU9Qgkb8YN4XHbqHdEm3pk=; fh=w1+pSYROmS9zmSXlxcWL2K4yXPkBT72FoBEeCL8Wiq0=; b=v5WF+0y3aWzv9rq/S07Q0t9urGYGtHZu1/75ep14cavDMm3Rrs4ck+x6V9QM+N13Nm 3ZNT2MiQqWgYxfKf4SQSAih9eP0ycOXJTk5T5cpSae0B2GMivrB/mvMBlvKOLY9PvIsN ZmHrRqYkCtPbgKJ5kt+5CX+YKTA3n6hnIUlVMw1qV8rkv+LLO0E3saTQa/VlCTDpYJOa 6P1hvS2IvYVB4jKexVnBmnBXG+L/CQmz7/2HxwM9FAq5bW+h8+C8cUGCy3s+Rb+28FpA tFSxo7pqxIGGE5QUr/RjgEvvZFDZ0eSbfi0XL3fpHxQuaSsbHoc9myorTOum1dxjXW9b tipA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XGONm0er; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-109441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109441-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t16-20020a17090a0d1000b0029b64305505si2137516pja.106.2024.03.20.14.36.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 14:36:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XGONm0er; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-109441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109441-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 063BCB21665 for ; Wed, 20 Mar 2024 21:36:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED45785C51; Wed, 20 Mar 2024 21:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XGONm0er" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 4FBA633062; Wed, 20 Mar 2024 21:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710970566; cv=none; b=eTxGCMNJvrp2H/h2GdKSSh8FiQtrmazQnuRaK2ly0OAMXL92UYlGJOXXR2SulE1xZvMVWTWLf/hNNqtocQpYich9XafBNantY7kDivYB1dhp3VARsDp0phxEuXusLCJ8D0sDGy3Rq5uo4FnIXQYWniwTOeL6VCcBW3FYZGZ6s4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710970566; c=relaxed/simple; bh=hX4pslLlcBSoPea9E2mRxNlAbfGvx83GcoZjftStHUw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BLKsK4hj6UwtO6Px5rGwUcZyQK9uQ9nNDwmNgEiCEBTUY1wCRRg/FtT9fm6U1p6hUrOMJTprNOfJKE+D8HxggTnU1vEzkxTnty/sOxlyGDFCd09P6EefeZN73iCDCXolNtwmIdpWFzh+Wq/Y0vDNtJaq4Ch79Q51UlN4y3H+kD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XGONm0er; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710970563; x=1742506563; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hX4pslLlcBSoPea9E2mRxNlAbfGvx83GcoZjftStHUw=; b=XGONm0er79JI42oC0Fi1tKlURM51T8UrS43sYJo8L4FVmHrUk02CM4H9 tn5CXyouSSsi3f0PpZTYrwubVabORvXDxCPljNoZxA+tkSzDv4ashMLaW Nha4twMMDpHJ8lVpbCevsHz+2h3WAAUyPKaixkuQ3jTi0aQA1BVVOBfaN pxfcbclG2SfXlbrPwoU75sxmdz3BlWF2fNj8MiJAmSedZ+B11k8w+zAU8 1UlCU4Ux140avVjqKqSMr1HVBe3TYBtiYdlN5HZIqLskpCbPlFWDSzwff lDwTn3JnW8lJz4SSqDJpJqkdhAsidrPmktaVsw7fNiYxLRW44jsjc9vfA w==; X-IronPort-AV: E=McAfee;i="6600,9927,11019"; a="5783585" X-IronPort-AV: E=Sophos;i="6.07,141,1708416000"; d="scan'208";a="5783585" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2024 14:36:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,141,1708416000"; d="scan'208";a="18869398" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2024 14:36:01 -0700 Date: Wed, 20 Mar 2024 14:36:00 -0700 From: Isaku Yamahata To: "Huang, Kai" Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson , Binbin Wu , Yuan Yao , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 029/130] KVM: TDX: Add C wrapper functions for SEAMCALLs to the TDX module Message-ID: <20240320213600.GI1994522@ls.amr.corp.intel.com> References: <7cfd33d896fce7b49bcf4b7179d0ded22c06b8c2.1708933498.git.isaku.yamahata@intel.com> <579cb765-8a5e-4058-bc1d-9de7ac4b95d1@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <579cb765-8a5e-4058-bc1d-9de7ac4b95d1@intel.com> On Wed, Mar 20, 2024 at 01:03:21PM +1300, "Huang, Kai" wrote: > > +static inline u64 tdx_seamcall(u64 op, struct tdx_module_args *in, > > + struct tdx_module_args *out) > > +{ > > + u64 ret; > > + > > + if (out) { > > + *out = *in; > > + ret = seamcall_ret(op, out); > > + } else > > + ret = seamcall(op, in); > > I think it's silly to have the @out argument in this way. > > What is the main reason to still have it? > > Yeah we used to have the @out in __seamcall() assembly function. The > assembly code checks the @out and skips copying registers to @out when it is > NULL. > > But it got removed when we tried to unify the assembly for TDCALL/TDVMCALL > and SEAMCALL to have a *SINGLE* assembly macro. > > https://lore.kernel.org/lkml/cover.1692096753.git.kai.huang@intel.com/ > > To me that means we should just accept the fact we will always have a valid > @out. > > But there might be some case that you _obviously_ need the @out and I > missed? As I replied at [1], those four wrappers need to return values. The first three on error, the last one on success. [1] https://lore.kernel.org/kvm/20240320202040.GH1994522@ls.amr.corp.intel.com/ tdh_mem_sept_add(kvm_tdx, gpa, tdx_level, hpa, &entry, &level_state); tdh_mem_page_aug(kvm_tdx, gpa, hpa, &entry, &level_state); tdh_mem_page_remove(kvm_tdx, gpa, tdx_level, &entry, &level_state); u64 tdh_vp_rd(struct vcpu_tdx *tdx, u64 field, u64 *value) We can delete out from other wrappers. Because only TDH.MNG.CREATE() and TDH.MNG.ADDCX() can return TDX_RND_NO_ENTROPY, we can use __seamcall(). The TDX spec doesn't guarantee such error code convention. It's very unlikely, though. > > +static inline u64 tdh_sys_lp_shutdown(void) > > +{ > > + struct tdx_module_args in = { > > + }; > > + > > + return tdx_seamcall(TDH_SYS_LP_SHUTDOWN, &in, NULL); > > +} > > As Sean already pointed out, I am sure it's/should not used in this series. > > That being said, I found it's not easy to determine whether one wrapper will > be used by this series or not. The other option is we introduce the > wrapper(s) when they get actally used, but I can see (especially at this > stage) it's also a apple vs orange question that people may have different > preference. > > Perhaps we can say something like below in changelog ... > > " > Note, not all VM-managing related SEAMCALLs have a wrapper here, but only > provide wrappers that are essential to the run the TDX guest with basic > feature set. > " > > ... so that people will at least to pay attention to this during the review? Makes sense. We can split this patch into other patches that first use the wrappers. -- Isaku Yamahata