Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp951625lqb; Fri, 15 Mar 2024 10:45:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyBf8i8GyvqpwQ+/8VgS2RyF/C18lUfSlXr8jA3RBJ6A7LLhpRMJsCwsG/XO5F2z6v6bW+j6JvZvLulVcc1mGvnp0HYiVH0uAiaaaYBQ== X-Google-Smtp-Source: AGHT+IFQYsXQ4GeH5fLTuftau5t7axfU7qw1K55WKwmzrrP1QKjsrJMlGIjRikrFtAeXbsb+litH X-Received: by 2002:a17:90b:30c6:b0:299:1777:134c with SMTP id hi6-20020a17090b30c600b002991777134cmr5250838pjb.33.1710524718109; Fri, 15 Mar 2024 10:45:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710524718; cv=pass; d=google.com; s=arc-20160816; b=OZx+YVTwL3pPr/7avkPQgKpaDWRB39/Fwc6/YuJVebito8j9CygFgYl9Ji0D4ne2Ep OnrBwUkUDMbswNGkrDV0TCR1W4xUB4DnQ1P8RTri3IiYUg97M89wAvDyScIBD4EJ8z0Z p6kVt9UcUUv8yg2DHYZj3xGhzHVxycnuzxUX/8wjvVyAqNYSbJUuoJ9R+lgY5GTeY/nR zfbJ1QkAQUvGld5yyf1/yQuaCqZeZdfJoUY7ZZmXYoZbZ4MHSoYPQvuP7CyoO6JmZaBp COL+JuxOYPAMY7pmMO1eZIOhBHQ7qJrHyQJ1qmk29guxLQk+0LrV4RUZHbvN4h14rz1Y bZLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=Fa79Oatca6zQP0uWiPqrWcQ+HA0jbKoi5WIlc5XFVOI=; fh=18vI8dgeALKpWooljJvyk6e39LimxLbeu8VONWjaPy0=; b=adRW0vivKHUMG/JzAg+Xw+vxIyan6eT45l6lr2hcOjrRg9llA0esSAVxWgYN6H1Ccr MrNTSxLX8MKyKj0F+PyiR/Vv8i1JsffO2TcFpOaUTCICkE5PnzwqoxDCEMBpyIpdj1U8 BH7oRnWrm4vIDFj4GBYoEVoL8Zui4v4himMEmL8xLpgLRMHVcZuZhywZjhnIX1rq33ow 6K7UaRzrtNAPCk0WHhrVRJRf5md533BmSIqIXzJ6Gqw1o9lyiVx27LvZgYmbsVgaeqwo 4SUv7hquJH6WC0BRIi3yYWPtT2vl9aBqtaQP0Q7axzRZIEmDEKGRiJamacyshEkp2D4t Ql5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jtfBDkSI; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-104740-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104740-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y2-20020a17090aa40200b0029c0776adbcsi2987050pjp.169.2024.03.15.10.45.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 10:45:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104740-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jtfBDkSI; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-104740-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104740-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B87DA2833AF for ; Fri, 15 Mar 2024 17:45:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58D244CB4E; Fri, 15 Mar 2024 17:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jtfBDkSI" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F6E040BE6 for ; Fri, 15 Mar 2024 17:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710524708; cv=none; b=qhoG4qCzPTQMdrjFFXkLZ1sTrQuE7s+fBImJnlnmEMkAJbB0GZIxQYclDKoJSqts7tXUhxXSbGwdcSqyiNZ8LeR6srtZaJDqtX7o6Bpjdlk/ps5M3Lxn7YOLJB/9Ntg84rCOA/P1yhCN2cQYYjx8rhJsMDCXDe95/QxACCvEVOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710524708; c=relaxed/simple; bh=INk8cZa0+LsWyZ8N8Wj8NppnFI5IdXvc/S0CKFZ7Zx8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KHLtmg+7EkbNRzFqCwL244rCM8SM1sZMHFcmB/cXv6WlMwVhypzQBZLDcIF3DjANe7Dxk8+xWPK69SWL/7DzFcAGjOsErJGesT44uAr2Hnoa0VMr30XCr0LZnlvbkTHb4hMeZs1CrXsTD5KFGnnpPNBsHYyIITiitep8SrQOnog= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jtfBDkSI; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5e4df21f22dso1826998a12.0 for ; Fri, 15 Mar 2024 10:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710524706; x=1711129506; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Fa79Oatca6zQP0uWiPqrWcQ+HA0jbKoi5WIlc5XFVOI=; b=jtfBDkSI1YprbJcST6or1vIBc40EPQl69MSaZZd+UwEcmBN1Tb0a9AfJsKwcygsmXQ pJsLEoAlE0vVCIgk4lLvbJmwNFujcDMtpKbpTtw/mLubZexGjkZaFNMx5g3OV0pX9srT e9JlNVp1CnTr+guzP5c/DuOWOpEJt4PPWZF89qh5l9GPs8P871iRvO6V8rkp0Fv3flug nKWsGcAl4GzE4g5YQGsIhx8Y12NOjylVFDU4auwN22epnAM2Dl1mjIUhr0AnWIKlumBg oeO5GWDYtE3eMAXI07zboZJnoMt0alrCgYYnuYqpVz4avswKTLYEsgkw4qnUCC/0RzE8 nlbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710524706; x=1711129506; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Fa79Oatca6zQP0uWiPqrWcQ+HA0jbKoi5WIlc5XFVOI=; b=rwU0Zfy6ooXo55r3jGfN18ADq/3rSmYaa89KnmIO8zVH5icvselSvnoSZzv92gGGEi KxrtfIV389orbYeYkLMPMxtc1/4xH2A7UWMnIRpK6EBENu/+XxvsW9i7PCwU+mKBKmzq 0ntlx3rlXwb9LbC1rcGe8irJ7AzDyHbFYaWie8YD8mxpknaKKmhLHhOmbM0gRRpZd4sR Bw1SZ1rQsvmqlqxIOEjWbuUZX2OeXokr1qBCud4TBo4YvfS0yoyBMqwWd07fv9ad4YLa kSbcSqJuWrvLQ4Sxhv+SDL1ZpwtFvXrwSyxQ9t9xN9qHhOctlFmGd9k4tCcxg76qOFcU 6FYQ== X-Forwarded-Encrypted: i=1; AJvYcCUdLLgK58YWqc/DvGO3sBTR58VlQ+OPP0MWX7xm0JcxEUt9S+P70PAFPUFQYZYZaCKxXEPG6wugZD2JoaNN1c9X7SSSicqWdkT8Qnu+ X-Gm-Message-State: AOJu0Ywlsgi9FrPrijIop3sTVUdFtQ7dOTlzoyXaphTNE7v/JtGVznK2 Fo4pvKk/PowGoIc3Ycxxo8arCrgxm5n2OVEBLH+WSTNai49mTwKNKom/r9QjMsbgYcUCwIu3KoS bfw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:e903:0:b0:5dc:4a5f:a5ee with SMTP id i3-20020a63e903000000b005dc4a5fa5eemr18668pgh.1.1710524706415; Fri, 15 Mar 2024 10:45:06 -0700 (PDT) Date: Fri, 15 Mar 2024 10:45:04 -0700 In-Reply-To: <88920c598dcb55c15219642f27d0781af6d0c044.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 References: <88920c598dcb55c15219642f27d0781af6d0c044.1708933498.git.isaku.yamahata@intel.com> Message-ID: Subject: Re: [PATCH v19 098/130] KVM: TDX: Add a place holder to handle TDX VM exit From: Sean Christopherson To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Content-Type: text/plain; charset="us-ascii" On Mon, Feb 26, 2024, isaku.yamahata@intel.com wrote: > +int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath) > +{ > + union tdx_exit_reason exit_reason = to_tdx(vcpu)->exit_reason; > + > + /* See the comment of tdh_sept_seamcall(). */ > + if (unlikely(exit_reason.full == (TDX_OPERAND_BUSY | TDX_OPERAND_ID_SEPT))) > + return 1; > + > + /* > + * TDH.VP.ENTRY checks TD EPOCH which contend with TDH.MEM.TRACK and > + * vcpu TDH.VP.ENTER. > + */ > + if (unlikely(exit_reason.full == (TDX_OPERAND_BUSY | TDX_OPERAND_ID_TD_EPOCH))) > + return 1; > + > + if (unlikely(exit_reason.full == TDX_SEAMCALL_UD)) { > + kvm_spurious_fault(); > + /* > + * In the case of reboot or kexec, loop with TDH.VP.ENTER and > + * TDX_SEAMCALL_UD to avoid unnecessarily activity. > + */ > + return 1; No. This is unnecessarily risky. KVM_BUG_ON() and exit to userspace. The response to "SEAMCALL faulted" should never be, "well, let's try again!". Also, what about #GP on SEAMCALL? In general, the error handling here seems lacking.