All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Nikolay Borisov <nik.borisov@suse.com>, dave.hansen@linux.intel.com
Cc: x86@kernel.org, rick.p.edgecombe@intel.com, seanjc@google.com,
	linux-coco@lists.linux.dev, binbin.wu@linux.intel.com,
	"Michal Koutný" <mkoutny@suse.com>,
	"Fang, Peter" <peter.fang@intel.com>
Subject: Re: [PATCH] x86/tdx: Harden exports
Date: Fri, 11 Sep 2026 21:01:27 +0800	[thread overview]
Message-ID: <bd287f7d-bd80-43d1-8a52-343242233b2a@intel.com> (raw)
In-Reply-To: <20260911113150.1022344-2-nik.borisov@suse.com>

+ 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)
>  {


  reply	other threads:[~2026-09-11 13:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 11:31 [PATCH] x86/tdx: Harden exports Nikolay Borisov
2026-09-11 13:01 ` Xiaoyao Li [this message]
2026-09-11 14:19   ` Nikolay Borisov
2026-09-16  9:13     ` Peter Fang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bd287f7d-bd80-43d1-8a52-343242233b2a@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=mkoutny@suse.com \
    --cc=nik.borisov@suse.com \
    --cc=peter.fang@intel.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.