Skip to contentSkip to conversation

x86/tdx: Harden exports

PATCH In review Nikolay Borisov 3 participants 6 messages Sep 17 – Sep 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/tdx: Harden exports

tdx_* function aren't supposed to be used by the kernel at large, rather they are mostly used by KVM and a very small number of them are exposed via the tdx-guest/tdx-host drivers. Reflect this fact in their EXPORT_SYMBOL* declarations.

---

V2:
* Drop the change to tdx_kvm_hypercall

 arch/x86/coco/tdx/tdx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/coco/tdx/tdx.c +3 -3
index f904a636d449..a38e44401840 100644
@@ -139,7 +139,7 @@ int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(tdx_mcall_get_report0);
+EXPORT_SYMBOL_FOR_MODULES(tdx_mcall_get_report0, "tdx-guest");
 
 /**
  * tdx_mcall_extend_rtmr() - Wrapper to extend RTMR registers using
@@ -175,7 +175,7 @@ int tdx_mcall_extend_rtmr(u8 index, u8 *data)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(tdx_mcall_extend_rtmr);
+EXPORT_SYMBOL_FOR_MODULES(tdx_mcall_extend_rtmr, "tdx-guest");
 
 /**
  * tdx_hcall_get_quote() - Wrapper to request TD Quote using GetQuote
@@ -196,7 +196,7 @@ u64 tdx_hcall_get_quote(u8 *buf, size_t size)
 	/* Since buf is a shared memory, set the shared (decrypted) bits */
 	return _tdx_hypercall(TDVMCALL_GET_QUOTE, cc_mkdec(virt_to_phys(buf)), size, 0, 0);
 }
-EXPORT_SYMBOL_GPL(tdx_hcall_get_quote);
+EXPORT_SYMBOL_FOR_MODULES(tdx_hcall_get_quote, "tdx-guest");
 
 static void __noreturn tdx_panic(const char *msg)
 {

--
2.55.0

#1 lore raw
Quoted 3 lines · Nikolay Borisov

tdx_* function aren't supposed to be used by the kernel at large, rather they are mostly used by KVM and a very small number of them are exposed via the tdx-guest/tdx-host drivers. Reflect this fact in their

"exposed via" sounds a bit off? Perhaps "exposed to"?

And this patch only touches functions exported to tdx-guest... In fact tdx-host only uses functions from arch/x86/virt/vmx/tdx/ (guest code vs host code). Maybe the log could be a bit more precise.

Quoted 12 lines

EXPORT_SYMBOL* declarations.

---

V2:
* Drop the change to tdx_kvm_hypercall

 arch/x86/coco/tdx/tdx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
#2 lore raw
Quoted 6 lines · Peter Fang
Quoted 3 lines · Nikolay Borisov

tdx_* function aren't supposed to be used by the kernel at large, rather they are mostly used by KVM and a very small number of them are exposed via the tdx-guest/tdx-host drivers. Reflect this fact in their

"exposed via" sounds a bit off? Perhaps "exposed to"?

What I meant was that the functionality of those functions is exposed via the tdx-guest/tdx-host drivers. I.e those drivers present interfaces to userspace to enable them to use the functionality of said functions. I.e those functions are only used by those drivers.

Quoted 4 lines

And this patch only touches functions exported to tdx-guest... In fact tdx-host only uses functions from arch/x86/virt/vmx/tdx/ (guest code vs host code). Maybe the log could be a bit more precise.

Fair point.

Quoted 13 lines
Quoted 13 lines

EXPORT_SYMBOL* declarations.

---

V2:
* Drop the change to tdx_kvm_hypercall

  arch/x86/coco/tdx/tdx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
#3 lore raw
Quoted 8 lines · Nikolay Borisov
Quoted 5 lines · Peter Fang
Quoted 3 lines · Nikolay Borisov

tdx_* function aren't supposed to be used by the kernel at large, rather they are mostly used by KVM and a very small number of them are exposed via the tdx-guest/tdx-host drivers. Reflect this fact in their

Quoted 6 lines
Quoted 1 line

"exposed via" sounds a bit off? Perhaps "exposed to"?

What I meant was that the functionality of those functions is exposed via the tdx-guest/tdx-host drivers. I.e those drivers present interfaces to userspace to enable them to use the functionality of said functions. I.e those functions are only used by those drivers.

Ah I see. Maybe a tiny bit of polishing would be enough. Thanks.

Quoted 10 lines
Quoted 6 lines

And this patch only touches functions exported to tdx-guest... In fact tdx-host only uses functions from arch/x86/virt/vmx/tdx/ (guest code vs host code). Maybe the log could be a bit more precise.

Fair point.

Quoted 1 line
Reviewed-by Kiryl Shutsemau (Meta) on v2 1/1
#5 lore raw
In reply to Nikolay Borisov
Quoted 4 lines · Nikolay Borisov

tdx_* function aren't supposed to be used by the kernel at large, rather they are mostly used by KVM and a very small number of them are exposed via the tdx-guest/tdx-host drivers. Reflect this fact in their EXPORT_SYMBOL* declarations.

Subject could be better. Something like "x86/tdx: Restrict attestation exports to the tdx-guest driver"?

The changelog still talks about KVM and tdx-host. Rewrite it.

Quoted 1 line

Maybe Suggested-by rather than Reported-by? There is no bug here.

Quoted 1 line

With that fixed you can use my:

Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov