Re: [PATCH v11 06/20] x86/virt/tdx: Handle SEAMCALL running out of entropy error

From: Nikolay Borisov
Date: Fri Jun 09 2023 - 10:43:05 EST




On 4.06.23 г. 17:27 ч., Kai Huang wrote:
Certain SEAMCALL leaf functions may return error due to running out of
entropy, in which case the SEAMCALL should be retried as suggested by
the TDX spec.

Handle this case in SEAMCALL common function. Mimic the existing
rdrand_long() to retry RDRAND_RETRY_LOOPS times.

Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx>
---

v10 -> v11:
- New patch

---
arch/x86/virt/vmx/tdx/tdx.c | 15 ++++++++++++++-
arch/x86/virt/vmx/tdx/tdx.h | 17 +++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)


<snip>

diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h
index 48ad1a1ba737..55dbb1b8c971 100644
--- a/arch/x86/virt/vmx/tdx/tdx.h
+++ b/arch/x86/virt/vmx/tdx/tdx.h
@@ -4,6 +4,23 @@
#include <linux/types.h>
+/*
+ * This file contains both macros and data structures defined by the TDX
+ * architecture and Linux defined software data structures and functions.
+ * The two should not be mixed together for better readability. The
+ * architectural definitions come first.
+ */
+
+/*
+ * TDX SEAMCALL error codes
+ */
+#define TDX_RND_NO_ENTROPY 0x8000020300000000ULL

Where is this return value documented, in TDX module 1.0 spec there are only: 8000020[123]00000000 specified and there's 80000800 (TDX_KEY_GENERATION_FAILED) and its description mentions the possible failure due to lack of entropy?

<snip>