From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793109060; b=aJ4mq4GZSdMohSeBhGdvAh6gluR7MSg8txu7+qVMLb7tS1wrpLhRKOECribpdmuVNKIQ NUmTmYDyuWi51YK4+vYbzDI80REMvvVyanIW1MIP1+a5fUWC/KaZigFrNSr9HfeW6u5bu yUiiDAwgCKp+yIrWbrNxoK65U5glZw92HKv43Ye4mhLVt1pzkv0fiOrrSCyRI/T9dwvRo r6ugpGJYfXLY39KAk8H7K8uWqj9W0lEGhFTDsHKCGJhMjdDSDHr3DEct8hmc4sziqVN43 cXM7+O3JlCbQ8bQMf0LphyV4Qy3MA3uGR0/RN0WLcalFzJ3tiDiFJJhrfvlrWEU3Nlg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793109060; 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=iDpeC4vAedQvXqYDjDb5n7gsefa3gXa0pHuyMumuaJg=; b=Uk7Q/zeqJLvvMneZ31rNq64jmupU8W2kEC+G1dpJWlUqsr6BBmtd9HfDfAmAOlhiLWXJ k6FiVbqMCmSEKSIdK4KXHFXKRqXXHqe3Nt6/i9uB/+reuLnKq89DcKw3q42/OnqjjtLzE QENyTAxW6dQWwrYTIstuE0Z7PzJvpv1f83KUU9xguc8p6SvmdBM+4L2rumz7RzuF17kos nUMIfEdpdiL1HTC5sR2g369X9fEUb2qPajEJ9Kx4LjMBEiD3wtRx3nGmWGsx/D1lhd6Ez rShlIZIJWxKI2RbV4qyL25MYwsZcp+gSMU8Nj1x+XhRPUCORqh7xplAIud9XsTcvmzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ea14WwRR; arc=none smtp.remote-ip=198.175.65.14 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 23748606A325 for ; Tue, 27 Oct 2026 13:50:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 23748606A325 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 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=Ea14WwRR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793109058; x=1824645058; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=K44EYJ+tSE+pgxSxW23nPIYPzojqHbOOSxq0BfMNrVI=; b=Ea14WwRR7SqS5KOhieOwmc4O2uh+1oZbUWQj6kH5aItlLizfGhKLUdLd nrhEqaSKvdrgNNEl/mYOh0T0CU0/1XcO0JxBRMO8qdsjzG8gDkdM/hsdz kLQyMeFJOfCwXlJbIg06lItxbr5ZuG9tUv8zamWzOIKOG8LjgIuX4PY2G KBI/u+GtZbWztYqe9or/XkXsdFkWplkF/KmpPQCUPcp7iRPDjcfkoEsCu bvxF1AmoaK5Bjun0VoBJ7JvcYJU2EzY3lxt5QRlbVkEyOuq6JyA3zOs/r Qrt2nYUPavelTFebw59Anylk9pTdE2JAHks/b9jdAdodtynPIpYjAC2QZ g==; X-CSE-ConnectionGUID: Punb/ttkTlKhNXDpCznjrA== X-CSE-MsgGUID: TexFLt8/T1uRKOaf5SKe6w== X-IronPort-AV: E=McAfee;i="6800,10657,11948"; a="1686230" X-IronPort-AV: E=Sophos;i="6.27,181,1787036400"; d="scan'208";a="1686230" Received: from fmviesa011.fm.intel.com ([10.60.135.151]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2026 06:50:58 -0700 X-CSE-ConnectionGUID: fJsaj7XAQDGmmauUEdyIXA== X-CSE-MsgGUID: Ab3HNCNHQya+uxSLtVYLsQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,181,1787036400"; d="scan'208";a="6424319" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.240.140]) ([10.124.240.140]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2026 06:50:55 -0700 Message-ID: <47bbb569-985d-4d48-8193-616685c76fcd@intel.com> Date: Tue, 27 Oct 2026 21:50:52 +0800 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 v3 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 , Kuppuswamy Sathyanarayanan Cc: Jun Miao , x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20261024-tdx-guest-quote-poll-v3-0-6a83bb767314@flashbots.net> <20261024-tdx-guest-quote-poll-v3-1-6a83bb767314@flashbots.net> Content-Language: en-US From: Xiaoyao Li In-Reply-To: <20261024-tdx-guest-quote-poll-v3-1-6a83bb767314@flashbots.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/25/2026 3:17 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") > Cc: stable@vger.kernel.org > Reported-by: Kiryl Shutsemau > Closes: https://lore.kernel.org/all/atoHWgQF-0vlTRK4@thinkstation/ > Reviewed-by: Kiryl Shutsemau (Meta) > Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Xiaoyao Li > Signed-off-by: Moe Mahhouk > --- > 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) >