Message ID | 20240111033245.2632484-1-sathyanarayanan.kuppuswamy@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-23033-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1208219dyi; Wed, 10 Jan 2024 19:34:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWJhm+TtP7iPH0wsvqNkop2TDXYyeb1rJ9hPswhP7VAVRvfv8/n72T/lEgLULk8fF8OpN2 X-Received: by 2002:a92:ab03:0:b0:360:2ff:4591 with SMTP id v3-20020a92ab03000000b0036002ff4591mr547569ilh.98.1704944060755; Wed, 10 Jan 2024 19:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704944060; cv=none; d=google.com; s=arc-20160816; b=xguXHwFV05zlwxjdwRmSKt9FrKPyUIkL4FIGrAS4Yyinle7YKmFRuB262MHZLogJ2Y kF8LrCzXXJk5KHEgMHppRxcwUz+8uWVUYQAjv/8ufsdhWo9PH+w2pVy49qd81/x/oYzh RcfoSmW7Apb1827hn2zIanZ3DlTfq8/vyaa+Job17ZleUdcmUZzRNrK9hcHn7h0uYPpN kU31KAyxNobH+EfxpvpWZGGlOaR+q90QF42oUxXiEJ42rGHDxDEjCjBKFrwK8G0dBrCk 1MQoOem7fe83nBMqDfIzH2/+kq9QYLw2WBuTvKWDxB02/8z/IxVfRkDPoHmfJStayHA5 EX/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=AWGinkTMgdiwlqTZo4GAegM0v59tnAxTUdwsZVdKfIs=; fh=fHyqRWIV6DRZtyE6+pV3T+XZVT4is8eNsNQ8QFYiMIE=; b=O57/WY2A5eXfTccnFuNbQviiXX/w1MB9t3uy1TGfXz+eOA5qfp+7DSheNm53AqxwtC EWgoN1CEcoxBeY+nKW292NN9f32PczF+l2uBAgXXytB6AfKIkhuekAD6JbdVhXoAdj77 PwEBzTC5CTHOh3uNdRbiliPPc5VlF0olVbiBm9yhhJVdkz4DGhhuVVWUUhpw9BqJM5z3 xF6M/CKGWl/GMBKZcC6yX1qZO+89P0iucTvG8EwR86sToGdJLqhK1Cm3ccgYhyBmuRrU pNAwEc2j++bd4r2yZTMq9cr5Ux6mEaU4THawlgYp6J7uhS8OwpZQCWerhuYULdODBoH7 p19g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iI008k/x"; spf=pass (google.com: domain of linux-kernel+bounces-23033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b6-20020a63cf46000000b005ce6b79b55dsi194696pgj.165.2024.01.10.19.34.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 19:34:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iI008k/x"; spf=pass (google.com: domain of linux-kernel+bounces-23033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23033-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C47D02876D2 for <ouuuleilei@gmail.com>; Thu, 11 Jan 2024 03:34:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECD251398; Thu, 11 Jan 2024 03:34:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iI008k/x" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 7C653EBC for <linux-kernel@vger.kernel.org>; Thu, 11 Jan 2024 03:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704944043; x=1736480043; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=HL60IJCbg51uCA/Ke8LM4u0ojnLTkmcbUqIywmQAX3Q=; b=iI008k/xNny23jcOq5NqlOJ0Bsvgv4Q0lz/+nrVM1DtMBntbUrXDxUPV eMFTl8Xdq3lE4w8ANtPjYTEyWL56ZET1tLVqLeaRCz9fcPzMyhohAgECr dvL7Ko9WLnitaJ5AhwOLQiOp1lvmYrDzsYaDlaiZnF6/zCp9cxWqaaIVA hdQSkr4jaWCO8FKbk7DaIvUSyzltl3i/wJSOohW6nF33lvdfDp7Djf8SW 3/3Ba0MOvrGB0PL+PaQ2nTwz+5GyZJ+9ilrpEGnI64QHdE07cbO/23MW7 sTg5FFBl31dctrsa3VAYEnBrteJhDjScSV6EuXvD0Pj7JmHVcsxUTW/eb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10949"; a="20209902" X-IronPort-AV: E=Sophos;i="6.04,185,1695711600"; d="scan'208";a="20209902" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 19:34:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10949"; a="905794898" X-IronPort-AV: E=Sophos;i="6.04,185,1695711600"; d="scan'208";a="905794898" Received: from skuppusw-desk2.jf.intel.com ([10.165.154.101]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 19:34:02 -0800 From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> To: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, x86@kernel.org Cc: Dave Hansen <dave.hansen@linux.intel.com>, Dan Williams <dan.j.williams@intel.com>, Xiaoyao Li <xiaoyao.li@intel.com>, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev Subject: [PATCH v2] virt: tdx-guest: Handle GetQuote request error code Date: Thu, 11 Jan 2024 03:32:45 +0000 Message-Id: <20240111033245.2632484-1-sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787763423536273983 X-GMAIL-MSGID: 1787763423536273983 |
Series |
[v2] virt: tdx-guest: Handle GetQuote request error code
|
|
Commit Message
Kuppuswamy Sathyanarayanan
Jan. 11, 2024, 3:32 a.m. UTC
During the TDX guest attestation process, TSM ConfigFS ABI is used by
the user attestation agent to get the signed VM measurement data (a.k.a
Quote), which can be used by a remote verifier to validate the
trustworthiness of the guest. When a user requests for the Quote data
via the ConfigFS ABI, the TDX Quote generation handler
(tdx_report_new()) forwards the request to VMM (or QE) via a hypercall,
and then shares the output with the user.
Currently, when handling the Quote generation request, tdx_report_new()
handler only checks whether the VMM successfully processed the request
and if it is true it returns success and shares the output to the user
without actually validating the output data. Since the VMM can return
error even after processing the Quote request, always returning success
for the processed requests is incorrect and will create confusion to
the user. Although for the failed request, output buffer length will
be zero and can also be used by the user to identify the failure case,
it will be more clear to return error for all failed cases.
Validate the Quote data output status and return error code for all
failed cases.
Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS")
Reported-by: Xiaoyao Li <xiaoyao.li@intel.com>
Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
Changes since v1:
* Updated the commit log (Kirill)
drivers/virt/coco/tdx-guest/tdx-guest.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Thu, Jan 11, 2024 at 03:32:45AM +0000, Kuppuswamy Sathyanarayanan wrote: > During the TDX guest attestation process, TSM ConfigFS ABI is used by > the user attestation agent to get the signed VM measurement data (a.k.a > Quote), which can be used by a remote verifier to validate the > trustworthiness of the guest. When a user requests for the Quote data > via the ConfigFS ABI, the TDX Quote generation handler > (tdx_report_new()) forwards the request to VMM (or QE) via a hypercall, > and then shares the output with the user. > > Currently, when handling the Quote generation request, tdx_report_new() > handler only checks whether the VMM successfully processed the request > and if it is true it returns success and shares the output to the user > without actually validating the output data. Since the VMM can return > error even after processing the Quote request, always returning success > for the processed requests is incorrect and will create confusion to > the user. Although for the failed request, output buffer length will > be zero and can also be used by the user to identify the failure case, > it will be more clear to return error for all failed cases. > > Validate the Quote data output status and return error code for all > failed cases. > > Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") > Reported-by: Xiaoyao Li <xiaoyao.li@intel.com> > Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
On 1/11/2024 11:32 AM, Kuppuswamy Sathyanarayanan wrote: > During the TDX guest attestation process, TSM ConfigFS ABI is used by > the user attestation agent to get the signed VM measurement data (a.k.a > Quote), which can be used by a remote verifier to validate the > trustworthiness of the guest. When a user requests for the Quote data > via the ConfigFS ABI, the TDX Quote generation handler > (tdx_report_new()) forwards the request to VMM (or QE) via a hypercall, > and then shares the output with the user. > > Currently, when handling the Quote generation request, tdx_report_new() > handler only checks whether the VMM successfully processed the request > and if it is true it returns success and shares the output to the user > without actually validating the output data. Since the VMM can return > error even after processing the Quote request, always returning success > for the processed requests is incorrect and will create confusion to > the user. Although for the failed request, output buffer length will > be zero and can also be used by the user to identify the failure case, > it will be more clear to return error for all failed cases. > > Validate the Quote data output status and return error code for all > failed cases. > > Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") > Reported-by: Xiaoyao Li <xiaoyao.li@intel.com> > Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> > --- > > Changes since v1: > * Updated the commit log (Kirill) > > drivers/virt/coco/tdx-guest/tdx-guest.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c > index 1253bf76b570..61368318fa39 100644 > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -228,6 +228,12 @@ static int tdx_report_new(struct tsm_report *report, void *data) > goto done; > } > > + if (quote_buf->status != GET_QUOTE_SUCCESS) { > + pr_err("GetQuote request failed, ret %llx\n", quote_buf->status); > + ret = -EIO; > + goto done; > + } > + > buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL); > if (!buf) { > ret = -ENOMEM;
Although for the failed request, output buffer length will > be zero and can also be used by the user to identify the failure case, > it will be more clear to return error for all failed cases. Nit: If I read correctly, kvmemdup() returns ZERO_SIZE_PTR if you pass the 0 size to it, so w/o this patch it seems the kernel will report ZERO_SIZE_PTR as the buffer to userspace. Not sure whether this is an issue. I guess what I want to say is, should we explicitly check quote_buf->out_len not being 0 even the status shows success? After all the out_len is set by the VMM. Anyway: Acked-by: Kai Huang <kai.huang@intel.com> > > Validate the Quote data output status and return error code for all > failed cases. > > Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") > Reported-by: Xiaoyao Li <xiaoyao.li@intel.com> > Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > --- > > Changes since v1: > * Updated the commit log (Kirill) > > drivers/virt/coco/tdx-guest/tdx-guest.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c > index 1253bf76b570..61368318fa39 100644 > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -228,6 +228,12 @@ static int tdx_report_new(struct tsm_report *report, void *data) > goto done; > } > > + if (quote_buf->status != GET_QUOTE_SUCCESS) { > + pr_err("GetQuote request failed, ret %llx\n", quote_buf->status); > + ret = -EIO; > + goto done; > + } > + > buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL); > if (!buf) { > ret = -ENOMEM;
Hi x86 Maintainers, On 1/10/24 7:32 PM, Kuppuswamy Sathyanarayanan wrote: > During the TDX guest attestation process, TSM ConfigFS ABI is used by > the user attestation agent to get the signed VM measurement data (a.k.a > Quote), which can be used by a remote verifier to validate the > trustworthiness of the guest. When a user requests for the Quote data > via the ConfigFS ABI, the TDX Quote generation handler > (tdx_report_new()) forwards the request to VMM (or QE) via a hypercall, > and then shares the output with the user. > > Currently, when handling the Quote generation request, tdx_report_new() > handler only checks whether the VMM successfully processed the request > and if it is true it returns success and shares the output to the user > without actually validating the output data. Since the VMM can return > error even after processing the Quote request, always returning success > for the processed requests is incorrect and will create confusion to > the user. Although for the failed request, output buffer length will > be zero and can also be used by the user to identify the failure case, > it will be more clear to return error for all failed cases. > > Validate the Quote data output status and return error code for all > failed cases. > > Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") > Reported-by: Xiaoyao Li <xiaoyao.li@intel.com> > Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > --- Can you consider merging this fix? It already got acks from Kirill, Kai and Li. Do you want me rebase it and resend it with updated tags? > > Changes since v1: > * Updated the commit log (Kirill) > > drivers/virt/coco/tdx-guest/tdx-guest.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c > index 1253bf76b570..61368318fa39 100644 > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -228,6 +228,12 @@ static int tdx_report_new(struct tsm_report *report, void *data) > goto done; > } > > + if (quote_buf->status != GET_QUOTE_SUCCESS) { > + pr_err("GetQuote request failed, ret %llx\n", quote_buf->status); > + ret = -EIO; > + goto done; > + } > + > buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL); > if (!buf) { > ret = -ENOMEM;
Kuppuswamy Sathyanarayanan wrote: > During the TDX guest attestation process, TSM ConfigFS ABI is used by > the user attestation agent to get the signed VM measurement data (a.k.a > Quote), which can be used by a remote verifier to validate the > trustworthiness of the guest. When a user requests for the Quote data > via the ConfigFS ABI, the TDX Quote generation handler > (tdx_report_new()) forwards the request to VMM (or QE) via a hypercall, > and then shares the output with the user. > > Currently, when handling the Quote generation request, tdx_report_new() > handler only checks whether the VMM successfully processed the request > and if it is true it returns success and shares the output to the user > without actually validating the output data. Since the VMM can return > error even after processing the Quote request, always returning success > for the processed requests is incorrect and will create confusion to > the user. Although for the failed request, output buffer length will > be zero and can also be used by the user to identify the failure case, > it will be more clear to return error for all failed cases. This is a lot of text. More is not necessarily better. --- The tdx-guest driver marshals requests via hypercall to have a quoting enclave sign attestation evidence about the current state of the TD. There are 2 possible failures, a transport failure (failure to communicate with the quoting agent) and payload failure (a failed quote). The driver only checks the former, update it to consider the latter payload errors as well. --- > > Validate the Quote data output status and return error code for all > failed cases. > > Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") > Reported-by: Xiaoyao Li <xiaoyao.li@intel.com> > Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > --- > > Changes since v1: > * Updated the commit log (Kirill) > > drivers/virt/coco/tdx-guest/tdx-guest.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c > index 1253bf76b570..61368318fa39 100644 > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -228,6 +228,12 @@ static int tdx_report_new(struct tsm_report *report, void *data) > goto done; > } > > + if (quote_buf->status != GET_QUOTE_SUCCESS) { > + pr_err("GetQuote request failed, ret %llx\n", quote_buf->status); Do you really want to spam the log on every error? I would expect pr_err() for events that are fatal to driver operation that might indicate conditions where maybe the TD should give up on the host. Yes, there are other pr_err() in this function and I am kicking myself for not scrutinizing those more closely. It is likely enough to distinguish transport errors vs payload / quote errors with ENXIO and EIO. Otherwise if there is an exceedingly good reason to keep this driver chirping into the kernel log then these likely also want to be rate-limited. If they are "just in case" debug messages, then move them to pr_debug().
On 2/22/24 9:48 PM, Dan Williams wrote: > Kuppuswamy Sathyanarayanan wrote: >> During the TDX guest attestation process, TSM ConfigFS ABI is used by >> the user attestation agent to get the signed VM measurement data (a.k.a >> Quote), which can be used by a remote verifier to validate the >> trustworthiness of the guest. When a user requests for the Quote data >> via the ConfigFS ABI, the TDX Quote generation handler >> (tdx_report_new()) forwards the request to VMM (or QE) via a hypercall, >> and then shares the output with the user. >> >> Currently, when handling the Quote generation request, tdx_report_new() >> handler only checks whether the VMM successfully processed the request >> and if it is true it returns success and shares the output to the user >> without actually validating the output data. Since the VMM can return >> error even after processing the Quote request, always returning success >> for the processed requests is incorrect and will create confusion to >> the user. Although for the failed request, output buffer length will >> be zero and can also be used by the user to identify the failure case, >> it will be more clear to return error for all failed cases. > This is a lot of text. More is not necessarily better. > > --- > The tdx-guest driver marshals requests via hypercall to have a quoting > enclave sign attestation evidence about the current state of the TD. > There are 2 possible failures, a transport failure (failure to > communicate with the quoting agent) and payload failure (a failed > quote). The driver only checks the former, update it to consider the > latter payload errors as well. > --- Looks better. I will use it in next version. > > >> Validate the Quote data output status and return error code for all >> failed cases. >> >> Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") >> Reported-by: Xiaoyao Li <xiaoyao.li@intel.com> >> Closes: https://lore.kernel.org/linux-coco/6bdf569c-684a-4459-af7c-4430691804eb@linux.intel.com/T/#u >> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> >> --- >> >> Changes since v1: >> * Updated the commit log (Kirill) >> >> drivers/virt/coco/tdx-guest/tdx-guest.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c >> index 1253bf76b570..61368318fa39 100644 >> --- a/drivers/virt/coco/tdx-guest/tdx-guest.c >> +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c >> @@ -228,6 +228,12 @@ static int tdx_report_new(struct tsm_report *report, void *data) >> goto done; >> } >> >> + if (quote_buf->status != GET_QUOTE_SUCCESS) { >> + pr_err("GetQuote request failed, ret %llx\n", quote_buf->status); > Do you really want to spam the log on every error? I would expect > pr_err() for events that are fatal to driver operation that might > indicate conditions where maybe the TD should give up on the host. > > Yes, there are other pr_err() in this function and I am kicking myself > for not scrutinizing those more closely. It is likely enough to > distinguish transport errors vs payload / quote errors with ENXIO and > EIO. > > Otherwise if there is an exceedingly good reason to keep this driver > chirping into the kernel log then these likely also want to be > rate-limited. If they are "just in case" debug messages, then move them > to pr_debug(). Ok. Makes sense. I will convert it into a pr_debug. I will submit a separate patch to fix other pr_err usage in this driver. Expect Quote timeout, the rest of the failure does not affect the usage of the driver.
diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c index 1253bf76b570..61368318fa39 100644 --- a/drivers/virt/coco/tdx-guest/tdx-guest.c +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c @@ -228,6 +228,12 @@ static int tdx_report_new(struct tsm_report *report, void *data) goto done; } + if (quote_buf->status != GET_QUOTE_SUCCESS) { + pr_err("GetQuote request failed, ret %llx\n", quote_buf->status); + ret = -EIO; + goto done; + } + buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL); if (!buf) { ret = -ENOMEM;