Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp553309lqt; Mon, 18 Mar 2024 16:40:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqWL+eAgS/XfelzyJsZJV5hkgbgs8qCUks31OsNjC0utYkL4CH2WL3UPEc0pKn2fklfK8uqfmCSy4Qzg91aFpRzELMqoQXYueQRkNCXA== X-Google-Smtp-Source: AGHT+IGYm+3q0oHOK5T259K70VAu7L1p187xoB4VKKPHYhQh3teVtFueetjmIWimJMd4OYrMEStt X-Received: by 2002:a05:6402:1f82:b0:567:3ed0:47ec with SMTP id c2-20020a0564021f8200b005673ed047ecmr11831476edc.23.1710805224736; Mon, 18 Mar 2024 16:40:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710805224; cv=pass; d=google.com; s=arc-20160816; b=MHlQs/q4ad0mCtzytoO5wouJOfL8XZq36QvWZsr87HU1tc1rs3f5vUNggP3/Fc+Rq6 kiMSziBQlm+AUVCFqo9Y9YV2pPMBCsumJxvNG3TSPUhgUsG9H3o3V3avxWYD+KRgTKxR MKv9KRQ90IXzbGjxi2sWZJQWGzZaWNzlcvzw67fXmRO8CooQz08j+7Gw+zzo0PzXx/iQ LnsMua2NrzE7Gw/xJHUgodruxaWAvFoMyVKe5yJtEO5la95xbvVmtyzKJeozFoVFqYX9 fa7uOBXcX5hnRSg5d8dTx3hQ508JdvZHbpZq+sDXMO5aGQVyygXHAxZD6QEZzy8kDg87 usNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=31Rm+vt4lPXQxsaGx+3iDmwFk+rG0KzXNQlicu3WE/4=; fh=Vj5trRVmnU8XdLFcSV47Z6Q81f2aWcrI0gBACy/KTKk=; b=r97f8OqwZue9BynkebJmbJ0QaRikdKLPzL5/ypaaLk9g5e8lyqPL2sTcqUMb0bkMwW 2YzCF2Gcr0i1VLkLBDFbuW/cE7YV9aG8blZEH3j2mG56gQR+tiBzJ/TesKxQlRRmJ+gX 0VwdsKxzAkEWnt7zgffVEogiiiiO+opuC7lLn4GGmWOrYIOLnTSWnk29Gg3xEBfxZjHY EhnD+fb7HXyMWDI5MBV3fs8FoL1ff5zkjBfTh0K7+1ZlklGGdVV7Yi5CzGDRP0lHgJJt lyhTFt7SHgX5Ogjoi1G3yghOVswQv5X+EBtetwyKkBGjNSzi0KqRUlgwNNv0m0tBo9Rg beag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g+757ZKW; 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-106822-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106822-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id em2-20020a056402364200b00568a2f5d5fesi4462999edb.182.2024.03.18.16.40.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:40:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106822-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g+757ZKW; 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-106822-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106822-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7817F1F226A5 for ; Mon, 18 Mar 2024 23:40:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C50545FB94; Mon, 18 Mar 2024 23:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g+757ZKW" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 CE84E5FB81; Mon, 18 Mar 2024 23:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710805214; cv=none; b=s0fUsFNRItF3WQ6RaLgaRrnAbUCjq8d0Y7ZDxqcitf2eqFMcrP1Nahwx+bsxqBQhOHTEgEr8fym3EsYDyyq6BnqtvElXipJJ7Ict6QOG9YQejJ2Sh/VGcfUI4WWIdfODOET+IGv3KltOVIJr51aje/Hu8stxn+8iqKxbU26h7L4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710805214; c=relaxed/simple; bh=oyx2Bz+RIgrwhRz3BjJO59HfmzWRjuo3TkptYTef3tM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HILsfOtF/9SH5F94S7Mu+LXFxRz8dyjiQkeBtgfMqDl9pM1fZo84MOSG7XcsIsBQHGg435c4mSyIzK+WCN1gMZBBdeZk+HVf+Q3+2UWjAy4kbEZqZQK6wC9pIOLZPD2UCTSXOByObyUhwm6+nAnVAuprb4Q5v1LQn1hSjK5EmDA= 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=g+757ZKW; arc=none smtp.client-ip=198.175.65.19 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=1710805212; x=1742341212; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=oyx2Bz+RIgrwhRz3BjJO59HfmzWRjuo3TkptYTef3tM=; b=g+757ZKWW3lPOEh1an26YkdfpIhDsEm0d/jHfHG2QUFZ86kCWiqHIqiR be0f1u9LdovmjxtgmS9jbk6kHAxEZ0pVlEU3W2roYjhLw/gdJ4HkoB+WF qlLBSKP/PkzL8NToaoRN6OIdsFItE0kFhv1P0TjQbFjtze0HvCO0GreF3 EELMD0tGKa5u9RkPhoaILdWxrYF1HB1Ro3MVgHdHdmoUFhYzv+J6gj22U V1NKPOwCaiQ+6MT2BmYrSKl1CusuWFdITZxZRjC8Y0vd5XVCZc65598Yu ghA6BV7NTgDNv/sTyisesItSZsmoupR87UMvEN/+pLJJJwWSs0QPVVzK8 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11017"; a="5516812" X-IronPort-AV: E=Sophos;i="6.07,135,1708416000"; d="scan'208";a="5516812" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2024 16:40:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,135,1708416000"; d="scan'208";a="18243367" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2024 16:40:11 -0700 Date: Mon, 18 Mar 2024 16:40:10 -0700 From: Isaku Yamahata To: "Edgecombe, Rick P" Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Yamahata, Isaku" , "Zhang, Tina" , "seanjc@google.com" , "Yuan, Hang" , "Huang, Kai" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "Aktas, Erdem" , "pbonzini@redhat.com" , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 078/130] KVM: TDX: Implement TDX vcpu enter/exit path Message-ID: <20240318234010.GD1645738@ls.amr.corp.intel.com> References: <7a24c01a03f68a87b0bbfa82a5d6ccbf3cbd6f4b.camel@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 Content-Transfer-Encoding: 8bit In-Reply-To: <7a24c01a03f68a87b0bbfa82a5d6ccbf3cbd6f4b.camel@intel.com> On Mon, Mar 18, 2024 at 09:01:05PM +0000, "Edgecombe, Rick P" wrote: > On Mon, 2024-02-26 at 00:26 -0800, isaku.yamahata@intel.com wrote: > > +fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu) > > +{ > > +       struct vcpu_tdx *tdx = to_tdx(vcpu); > > + > > +       if (unlikely(!tdx->initialized)) > > +               return -EINVAL; > > +       if (unlikely(vcpu->kvm->vm_bugged)) { > > +               tdx->exit_reason.full = TDX_NON_RECOVERABLE_VCPU; > > +               return EXIT_FASTPATH_NONE; > > +       } > > + > > Isaku, can you elaborate on why this needs special handling? There is a > check in vcpu_enter_guest() like: > if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) { > r = -EIO; > goto out; > } > > Instead it returns a SEAM error code for something actuated by KVM. But > can it even be reached because of the other check? Not sure if there is > a problem, just sticks out to me and wondering whats going on. The original intention is to get out the inner loop. As Sean pointed it out, the current code does poor job to check error of __seamcall_saved_ret(TDH_VP_ENTER). So it fails to call KVM_BUG_ON() when it returns unexcepted error. The right fix is to properly check an error from TDH_VP_ENTER and call KVM_BUG_ON(). Then the check you pointed out should go away. for // out loop if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) { for // inner loop vcpu_run() kvm_vcpu_exit_request(vcpu). -- Isaku Yamahata