From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792788241; b=g84dJ9VYvE+mhYbfOrfkYOjDY8QIyp1aFAsfjbRKaUgkIpltFTZCYKKSgyUjhsczalmv SZaOR+mqf6ARZF2DfqMt5L+2R0adYYv5mWSj+CdrOL0butgD+4p+MZ8aB8TgRKc+BmVBB d19m/3+vw3705eI7Ocg97jmID6mZpUcKIpUMj6hleKc2o7hEUvr+Ktb+6jn8kzUe8vFHC JmkGTcJby90Db5ZAzo4NLg2A3ls5l4nS9ZDLcqZrunkNisHaVaHEmF3FvxPG2g7zLAFQL Pv622RE6F6sC3K4uh4CgLRL42LRwvEc5uoO19wr4J0TGSr3lOcw2mStcYW70a71QIag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792788241; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=Kg5sEdhQ2g+V2nQgohzkE2jL3J0nwWNaN3yyyXVB1Vc=; b=BxoBFhErDZRO8KoHdboRP93I1b8detsUNWIWAc7Yt6uFMHnmqtgHqrykZh3TR67mapNO PzvxnTcv8rR6WbyPofFKPl7f9I0OTnJonatfOXCzia1cZ72A7kEG1WdnZRNjdO5tvqDFr i4ClEwSfMm8JkHLVgtu0nWyD1ZUVrA1ZmX3SkrYoLig9gRWZfJTcBIe/Yqy3o0NO9DWy3 o5zg4/LXVbzdudjBZB0TFZgbtNftsy+fMWsep6MFlHceNB9ZtqUNnHRpscv0jZjqPeCUb sm8oMFBB4UZ4LTR2/kJoTmsSOuEDE1lDVCyjtfTqo0JG5BxxUQjKSN2JDvW7UXmfulg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Rx0m+846; arc=none smtp.remote-ip=192.198.163.11 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CD8B606A31B for ; Fri, 23 Oct 2026 20:44:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8CD8B606A31B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Rx0m+846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1792788241; x=1824324241; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=SdXxGKPsZhSER7+T11B25dIGAkc06IB10PwDrkQUjNI=; b=Rx0m+846FIc23fI1OnjwgPjwBeaqqlTG2+/zGocq5kzxdTMH8FO3kdHv hwuJQaKYdAnFKKjdMd7OP8uzBB0fNFuKq8JfZDWj8pgpdJrE0yC/XGsZe Bc6XqI6pPIwQBO+JB3y+Dx/K+4Ke9WJx78MKu4Bx1ifItd8EL7rcZhchh ef/J+/8rYIQu+TSZS3R5s525COx5VBoOFAKCeqjeSD1SFdEapxNOr3S3q poMut9AkOO9K2BR2a44Gf8dIozhg5W6jDoVYBZLGMfqfj7nAjYhe+50Pw xaPeLKHZdi3PfPBczdAEoZSXXmYnJIRRMmXj8GTcit1jgb7wLJI5PKURu A==; X-CSE-ConnectionGUID: oKiUftT0TO2G65iSODrGnw== X-CSE-MsgGUID: zJfCdYasT2WGhc9enilSBQ== X-IronPort-AV: E=McAfee;i="6800,10657,11944"; a="1455980" X-IronPort-AV: E=Sophos;i="6.27,174,1787036400"; d="scan'208";a="1455980" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2026 13:44:00 -0700 X-CSE-ConnectionGUID: 4Lky41bqRqSvgB3SMkw+dw== X-CSE-MsgGUID: e4UaoCamQPK9VSpUQTONew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,174,1787036400"; d="scan'208";a="3742384" Received: from soc-pf446t5c.clients.intel.com (HELO [10.24.80.90]) ([10.24.80.90]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2026 13:44:00 -0700 Message-ID: <4e8ffa1b-a0bc-4a77-b1f2-cc1c84f9d8ec@linux.intel.com> Date: Fri, 23 Oct 2026 13:43:59 -0700 X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] virt: tdx-guest: Fix timeout detection in wait_for_quote_completion() To: moe@flashbots.net, Kiryl Shutsemau , Rick Edgecombe , Dave Hansen , Erdem Aktas , Tom Lendacky , Dan Williams Cc: Jun Miao , x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261022-tdx-guest-quote-poll-v2-0-7543c6eb2d36@flashbots.net> <20261022-tdx-guest-quote-poll-v2-1-7543c6eb2d36@flashbots.net> Content-Language: en-US From: Kuppuswamy Sathyanarayanan In-Reply-To: <20261022-tdx-guest-quote-poll-v2-1-7543c6eb2d36@flashbots.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, On 10/22/2026 9:31 AM, Moe Mahhouk via B4 Relay wrote: > From: Moe Mahhouk > > wait_for_quote_completion() counts the seconds it has waited in i and > reports a timeout when i == timeout. That gets both outcomes of the > last second wrong: > > - If the request is still in flight after the last sleep, the loop > condition increments i once more before it fails, so the loop ends > with i == timeout + 1 and the function returns 0. The caller then > returns -EIO instead of -ETIMEDOUT, without the "GetQuote request > timedout" message. Before commit 0f409eaea53e ("virt: tdx-guest: > Return error for GetQuote failures") a timed-out request even > returned success with an empty Quote. > > - If the VMM completes the request during the last sleep, the loop ends > on the status check with i == timeout, and the function returns > -ETIMEDOUT for a completed request, discarding the Quote. > > Decide on the Quote buffer instead: the request timed out if it is > still in flight when the wait ends. > > Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") > Reported-by: Kiryl Shutsemau > Closes: https://lore.kernel.org/all/atoHWgQF-0vlTRK4@thinkstation/ > Signed-off-by: Moe Mahhouk > --- Since it can be back ported add Cc: stable@vger.kernel.org Reviewed-by: Kuppuswamy Sathyanarayanan > drivers/virt/coco/tdx-guest/tdx-guest.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c > index 11d741da3b35..a5a53174f9d9 100644 > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -282,7 +282,7 @@ static int wait_for_quote_completion(struct tdx_quote_buf *buf, u32 timeout) > return -EINTR; > } > > - return (i == timeout) ? -ETIMEDOUT : 0; > + return (buf->status == GET_QUOTE_IN_FLIGHT) ? -ETIMEDOUT : 0; > } > > static int tdx_report_new_locked(struct tsm_report *report) > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer