Export tdg_vm_rd() to allow the tdx-guest driver module to directly
read TD-scoped metadata fields from the Trust Domain Control Structure
(TDCS) via TDG.VM.RD TDCALL.
Since tdg_vm_rd() is read-only and cannot cause harm, exporting it
directly is simpler and more flexible. This allows the tdx-guest driver
to read any TDCS field it needs.
In a following patch, the tdx-guest driver will use tdg_vm_rd() to read
TDCS_CONFIG_FLAGS field directly.
Signed-off-by: Zhenzhong Duan <redacted>
---
arch/x86/coco/tdx/tdx.c | 3 ++-
arch/x86/include/asm/tdx.h | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index f904a636d449..22cc177a6db4 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -79,7 +79,7 @@ static inline void tdcall(u64 fn, struct tdx_module_args *args)
}
/* Read TD-scoped metadata */
-static inline u64 tdg_vm_rd(u64 field, u64 *value)
+u64 tdg_vm_rd(u64 field, u64 *value)
{
struct tdx_module_args args = {
.rdx = field,@@ -91,6 +91,7 @@ static inline u64 tdg_vm_rd(u64 field, u64 *value)
return ret;
}
+EXPORT_SYMBOL_FOR_MODULES(tdg_vm_rd, "tdx-guest");
/* Write TD-scoped metadata */
static inline u64 tdg_vm_wr(u64 field, u64 value, u64 mask)
diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 89e97d5761d8..884bb8067521 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -77,6 +77,8 @@ void tdx_halt(void);
bool tdx_early_handle_ve(struct pt_regs *regs);
+u64 tdg_vm_rd(u64 field, u64 *value);
+
int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport);
int tdx_mcall_extend_rtmr(u8 index, u8 *data);
--
2.52.0