* [PATCH] x86/tdx: Harden exports
@ 2026-09-11 11:31 Nikolay Borisov
2026-09-11 13:01 ` Xiaoyao Li
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2026-09-11 11:31 UTC (permalink / raw)
To: dave.hansen
Cc: x86, rick.p.edgecombe, seanjc, linux-coco, binbin.wu, xiaoyao.li,
Nikolay Borisov, Michal Koutný
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.
Reported-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
---
arch/x86/coco/tdx/tdx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index f904a636d449..3055a76c0dfd 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -64,7 +64,7 @@ long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2,
return __tdx_hypercall(&args);
}
-EXPORT_SYMBOL_GPL(tdx_kvm_hypercall);
+EXPORT_SYMBOL_FOR_KVM(tdx_kvm_hypercall);
#endif
/*
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/tdx: Harden exports
2026-09-11 11:31 [PATCH] x86/tdx: Harden exports Nikolay Borisov
@ 2026-09-11 13:01 ` Xiaoyao Li
2026-09-11 14:19 ` Nikolay Borisov
0 siblings, 1 reply; 3+ messages in thread
From: Xiaoyao Li @ 2026-09-11 13:01 UTC (permalink / raw)
To: Nikolay Borisov, dave.hansen
Cc: x86, rick.p.edgecombe, seanjc, linux-coco, binbin.wu,
Michal Koutný, Fang, Peter
+ Peter,
On 9/11/2026 7:31 PM, Nikolay Borisov wrote:
> 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.
we found this and discussed it in [1]. It was left to Peter's todo list.
Glad to see you do it earlier.
[1] https://lore.kernel.org/all/cdb43316-6535-4f11-9fb0-abdf2adf4568@intel.com/
> Reported-by: Michal Koutný <mkoutny@suse.com>
> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
> ---
> arch/x86/coco/tdx/tdx.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
> index f904a636d449..3055a76c0dfd 100644
> --- a/arch/x86/coco/tdx/tdx.c
> +++ b/arch/x86/coco/tdx/tdx.c
> @@ -64,7 +64,7 @@ long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2,
>
> return __tdx_hypercall(&args);
> }
> -EXPORT_SYMBOL_GPL(tdx_kvm_hypercall);
> +EXPORT_SYMBOL_FOR_KVM(tdx_kvm_hypercall);
tdx_kvm_hypecall() is used by kvm_hypercall{0,1,2,3,4}, which are not used by
KVM modules, but used by guest kernel code when running as a KVM guest.
It seems the reason we need to export is kvm_arch_ptp_init() calls
kvm_hypercall2() and kvm_arch_ptp_init() can be called by guest-side PTP module.
> #endif
>
> /*
> @@ -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)
> {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/tdx: Harden exports
2026-09-11 13:01 ` Xiaoyao Li
@ 2026-09-11 14:19 ` Nikolay Borisov
0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2026-09-11 14:19 UTC (permalink / raw)
To: Xiaoyao Li, dave.hansen
Cc: x86, rick.p.edgecombe, seanjc, linux-coco, binbin.wu,
Michal Koutný, Fang, Peter
On 11.09.26 г. 16:01 ч., Xiaoyao Li wrote:
> + Peter,
>
> On 9/11/2026 7:31 PM, Nikolay Borisov wrote:
>> 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.
>
> we found this and discussed it in [1]. It was left to Peter's todo list.
> Glad to see you do it earlier.
>
> [1] https://lore.kernel.org/all/cdb43316-6535-4f11-9fb0-abdf2adf4568@intel.com/
>
>> Reported-by: Michal Koutný <mkoutny@suse.com>
>> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
>> ---
>> arch/x86/coco/tdx/tdx.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
>> index f904a636d449..3055a76c0dfd 100644
>> --- a/arch/x86/coco/tdx/tdx.c
>> +++ b/arch/x86/coco/tdx/tdx.c
>> @@ -64,7 +64,7 @@ long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2,
>>
>> return __tdx_hypercall(&args);
>> }
>> -EXPORT_SYMBOL_GPL(tdx_kvm_hypercall);
>> +EXPORT_SYMBOL_FOR_KVM(tdx_kvm_hypercall);
>
> tdx_kvm_hypecall() is used by kvm_hypercall{0,1,2,3,4}, which are not used by
> KVM modules, but used by guest kernel code when running as a KVM guest.
>
> It seems the reason we need to export is kvm_arch_ptp_init() calls
> kvm_hypercall2() and kvm_arch_ptp_init() can be called by guest-side PTP module.
So what do you suggest the correct export is?
>
>> #endif
>>
>> /*
>> @@ -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)
>> {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-11 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 11:31 [PATCH] x86/tdx: Harden exports Nikolay Borisov
2026-09-11 13:01 ` Xiaoyao Li
2026-09-11 14:19 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox