Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp3068339lqz; Wed, 3 Apr 2024 18:16:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWg6boCzxkyGeT6yoCqy6eK50lVwpcWt/XhSVYEiQ20UkEmPyIw7S+gEqBXvBg0fdEvG2wDZvfe5lZ6Hyvisy9azRCmdM1/XeFVoBEl4Q== X-Google-Smtp-Source: AGHT+IF4yxpM7rBmmpJ12+DyvU+j+0nbdqVo4J8RRK1LWAwqisoRtDx3RO9hTa8MRDTRowSebSMy X-Received: by 2002:a05:620a:29cb:b0:78b:c1e6:31d8 with SMTP id s11-20020a05620a29cb00b0078bc1e631d8mr1427108qkp.14.1712193359806; Wed, 03 Apr 2024 18:15:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712193359; cv=pass; d=google.com; s=arc-20160816; b=ZEu0x5eXTz/3z+VLnByGdUsmfh0sTIW8UI4xl/3Tj3prvSqBveqkjNBm4rdLVk3j76 +3VtDTQx2IeTzgUOwACubauSSuTdVI0ONVM+kGLQhIm9kyHhC2rZaE7esY/5JbkqUK33 CimAdPl+SOj0t+bZd7PLRaRUqf6fYFEDH28JuvwB1bhkLD0W0XRNADby5ANsPqP/mbol 6b1UJyLxcKLvKFmJdas+vLtciyMkmHR/QKKBqz4GokEiM52Yd/1Lj4jzxe/MtTrxh8zG ZvPUrFlNNMAXqSTLwkaxuIjWFtQE74bjGEoOt3ydV1WFXRmiI9BYEN+2nARfbbB5bjV0 /ONQ== 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=spLs572tEv/zrjkA1cBC/JtSM4Cf0mzMaDXMe6Fgsuw=; fh=7fnKWflKDkX4OM5vsWHXTld5o7/C69nTyCY4l+diY58=; b=VCFSqVKbddmlS4RBDrI5OxiK0KKMEocd09eqLfKL6/oU79a1bjV2aTPRNWvvbEq94R ktGRRET+2rSwCKE1T36Hcf/7bV1t6wQ/RPNJ5dmhW9LB9TWfhMY/PBDCRnpVrIYTIVaZ LbRMnI49h33yaYIpmv7U792hEUMgm1v9k2j+pkLg6A0lx+Qd/VKK8Fyqy7ojvGI6NFJ9 sDmW9qLm5lj2e5f0Gki+KL/zeHtpeA6ADpjn+tlMHdaNd7yscINe/+x7CGhH4gpo1FyI vXgaRsXrXse4EpZHPzXnvKZtBDmmJqDEeWDUH+sxc0S9YFNfq2/2n30MTUVDk0A7kXUi 3DlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=h+v2n6Ry; 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-130809-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130809-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h11-20020a05620a244b00b0078a1e412169si17104808qkn.709.2024.04.03.18.15.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 18:15:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130809-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=h+v2n6Ry; 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-130809-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130809-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8AAB91C24E14 for ; Thu, 4 Apr 2024 01:15:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21FE2C15B; Thu, 4 Apr 2024 01:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="h+v2n6Ry" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 9EC1F3C30; Thu, 4 Apr 2024 01:15:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712193348; cv=none; b=mSR+7SHSxU2rt9suStrQQy0XZ/M/cJa0v59wICqjJ5zmjlBqu+JACnyzzNFKXclZV8FKt2OaREJlYzNxHW1YFbi24D4EfJmmsd2MbjOteIoCI/mrU6dUgOBiLm50B2QnnUdmlyuz0PooogopoPLwME5yyQsoBMcTcRFwY+YhTcA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712193348; c=relaxed/simple; bh=iV+fYLEUuD3qMKnGQDEMm+oR9vl6EeMmdnznRKNEQ+I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NvtCHKq3qv6Z9E+6IkzvmdjXPEegNJ+aJNCjaQxW70+46Fka077641dClh3MOcLfSp8Yay58pJFExo86RKsq5OEJPjofhpdXbqg/WAo1YgpAy2iXj6dSVzK4yKypTaaJ+69cb6XD6bAGfVyucgHYVocsgJoSxguZNOjH9KLc38M= 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=h+v2n6Ry; arc=none smtp.client-ip=198.175.65.18 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=1712193347; x=1743729347; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=iV+fYLEUuD3qMKnGQDEMm+oR9vl6EeMmdnznRKNEQ+I=; b=h+v2n6Rydh4/WzD9edHnspAYv5u1//8gvmn+PdDCqbUkhNNo4GL0IVAR lHu2XeEPjnSl61kaGBZRMtyMWZSifl3SSWs2IoLwJzBSSuFrTB0Hz1Wbh Axb9NQg5WyiZlYgAO5MCPHrE0lnijg8xaTLx6PlBSkBGUWn5xUfGFbVZA Ihh1aIlntK2rjh6NXNT2RarERcArSRDG1kaVoWvdnpXgLI6uvg740C07o r9H45jfKmppfCL/TrjEK99TM0q/eFI846dxCKkF8uVIJb+RhSx8hrU+7H 7Gn75KhNtuc7U1unMGPZwMj186cXtxmYFIWg2mQspUZW0N1eFVlwhol9T w==; X-CSE-ConnectionGUID: iSV7s0yfSUKRfAWZ394bUg== X-CSE-MsgGUID: JXA9hbjLSjS/74tqn8ao2w== X-IronPort-AV: E=McAfee;i="6600,9927,11033"; a="7628285" X-IronPort-AV: E=Sophos;i="6.07,178,1708416000"; d="scan'208";a="7628285" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2024 18:15:47 -0700 X-CSE-ConnectionGUID: YwN6getFSA+MsprrZH5IDw== X-CSE-MsgGUID: UyC81w+aRRCQF2ecc+pMdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,178,1708416000"; d="scan'208";a="23317387" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2024 18:15:46 -0700 Date: Wed, 3 Apr 2024 18:15:45 -0700 From: Isaku Yamahata To: Chao Gao 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li , Sean Christopherson , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 104/130] KVM: TDX: Add a place holder for handler of TDX hypercalls (TDG.VP.VMCALL) Message-ID: <20240404011545.GO2444378@ls.amr.corp.intel.com> References: <1c66bfde36f08eacbe2f5c50f88adf80e3d87ea7.1708933498.git.isaku.yamahata@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: On Mon, Apr 01, 2024 at 05:59:35PM +0800, Chao Gao wrote: > > static inline bool is_td_vcpu_created(struct vcpu_tdx *tdx) > > { > > return tdx->td_vcpu_created; > >@@ -897,6 +932,11 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu) > > > > tdx_complete_interrupts(vcpu); > > > >+ if (tdx->exit_reason.basic == EXIT_REASON_TDCALL) > >+ tdx->tdvmcall.rcx = vcpu->arch.regs[VCPU_REGS_RCX]; > > kvm_rcx_read()? > > > >+ else > >+ tdx->tdvmcall.rcx = 0; > > RCX on TDVMCALL exit is supposed to be consumed by TDX module. I don't get why > caching it is necessary. Can tdx->tdvmcall be simply dropped? Now it's not used. Will drop tdvmcall. It was originally used to remember a original register mask of TDVMCALL, and tdx_complete_vp_vmcall() used it as a valid value to copy back the output values. The current tdx_complete_vp_vmcall() uses kvm_rcx_read() because even if the user space changes rcx, it doesn't harm to KVM. KVM does what the user space tells. -- Isaku Yamahata