Thread (19 messages) 19 messages, 2 authors, 4d ago
COOLING4d

[RFC PATCH 01/15] x86/tdx: Export tdg_vm_rd() for tdx-guest module

From: Zhenzhong Duan <hidden>
Date: 2026-09-24 04:10:50
Also in: lkml
Subsystem: the rest, x86 architecture (32-bit and 64-bit) · Maintainers: Linus Torvalds, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help