From: "Huang, Kai" <kai.huang@intel.com>
To: "akrowiak@linux.ibm.com" <akrowiak@linux.ibm.com>,
"frankja@linux.ibm.com" <frankja@linux.ibm.com>,
"luto@kernel.org" <luto@kernel.org>,
"jpoimboe@kernel.org" <jpoimboe@kernel.org>,
"borntraeger@linux.ibm.com" <borntraeger@linux.ibm.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"dengler@linux.ibm.com" <dengler@linux.ibm.com>,
"pasic@linux.ibm.com" <pasic@linux.ibm.com>,
"kas@kernel.org" <kas@kernel.org>,
"seanjc@google.com" <seanjc@google.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"maddy@linux.ibm.com" <maddy@linux.ibm.com>,
"freude@linux.ibm.com" <freude@linux.ibm.com>,
"xin@zytor.com" <xin@zytor.com>,
"imbrenda@linux.ibm.com" <imbrenda@linux.ibm.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"vkuznets@redhat.com" <vkuznets@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"acme@kernel.org" <acme@kernel.org>,
"jjherne@linux.ibm.com" <jjherne@linux.ibm.com>,
"jarkko@kernel.org" <jarkko@kernel.org>,
"namhyung@kernel.org" <namhyung@kernel.org>
Cc: "linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>
Subject: Re: [PATCH 6/6] x86: Restrict KVM-induced symbol exports to KVM modules where obvious/possible
Date: Wed, 30 Jul 2025 02:14:14 +0000 [thread overview]
Message-ID: <745fe95bb826db5a1f8bb0723c482e1c68d984dc.camel@intel.com> (raw)
In-Reply-To: <20250729174238.593070-7-seanjc@google.com>
On Tue, 2025-07-29 at 10:42 -0700, Sean Christopherson wrote:
> Extend KVM's export macro framework to provide EXPORT_SYMBOL_GPL_FOR_KVM(),
> and use the helper macro to export symbols for KVM throughout x86 if and
> only if KVM will build one or more modules, and only for those modules.
>
> To avoid unnecessary exports when CONFIG_KVM=m but kvm.ko will not be
> built (because no vendor modules are selected), let arch code #define
> EXPORT_SYMBOL_GPL_FOR_KVM to suppress/override the exports.
>
> Note, the set of symbols to restrict to KVM was generated by manual search
> and audit; any "misses" are due to human error, not some grand plan.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
[...]
> arch/x86/kernel/cpu/sgx/main.c | 3 +-
> arch/x86/kernel/cpu/sgx/virt.c | 5 ++-
>
[...]
> arch/x86/virt/vmx/tdx/tdx.c | 65 +++++++++++++++---------------
> include/linux/kvm_types.h | 14 +++++++
> 31 files changed, 140 insertions(+), 101 deletions(-)
>
[...]
>
> --- a/include/linux/kvm_types.h
> +++ b/include/linux/kvm_types.h
> @@ -11,8 +11,22 @@
> #ifdef KVM_SUB_MODULES
> #define EXPORT_SYMBOL_GPL_FOR_KVM_INTERNAL(symbol) \
> EXPORT_SYMBOL_GPL_FOR_MODULES(symbol, __stringify(KVM_SUB_MODULES))
> +#define EXPORT_SYMBOL_GPL_FOR_KVM(symbol) \
> + EXPORT_SYMBOL_GPL_FOR_MODULES(symbol, "kvm," __stringify(KVM_SUB_MODULES))
>
I was thinking to send out separate patches for SGX and TDX by just
changing to use EXPORT_SYMBOL_GPL_FOR_MODULES(.., "kvm,kvm-intel")
unconditionally, but yeah I agree having EXPORT_SYMBOL_GPL_FOR_KVM() and
only having the actual export when KVM sub module is enabled is better.
I tested that with this series I can still successfully create TDX and SGX
guests, so for TDX and SGX bits:
Acked-by: Kai Huang <kai.huang@intel.com>
Tested-by: Kai Huang <kai.huang@intel.com>
next prev parent reply other threads:[~2025-07-30 2:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 17:42 [PATCH 0/6] KVM: Export KVM-internal symbols for sub-modules only Sean Christopherson
2025-07-29 17:42 ` [PATCH 1/6] KVM: s390/vfio-ap: Use kvm_is_gpa_in_memslot() instead of open coded equivalent Sean Christopherson
2025-08-12 19:40 ` Anthony Krowiak
2025-07-29 17:42 ` [PATCH 2/6] KVM: Export KVM-internal symbols for sub-modules only Sean Christopherson
2025-07-29 17:42 ` [PATCH 3/6] KVM: x86: Move kvm_intr_is_single_vcpu() to lapic.c Sean Christopherson
2025-07-29 17:42 ` [PATCH 4/6] KVM: x86: Drop pointless exports of kvm_arch_xxx() hooks Sean Christopherson
2025-07-29 17:42 ` [PATCH 5/6] KVM: x86: Export KVM-internal symbols for sub-modules only Sean Christopherson
2025-07-29 17:42 ` [PATCH 6/6] x86: Restrict KVM-induced symbol exports to KVM modules where obvious/possible Sean Christopherson
2025-07-30 2:14 ` Huang, Kai [this message]
2025-08-25 13:59 ` [PATCH 0/6] KVM: Export KVM-internal symbols for sub-modules only Vlastimil Babka
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=745fe95bb826db5a1f8bb0723c482e1c68d984dc.camel@intel.com \
--to=kai.huang@intel.com \
--cc=acme@kernel.org \
--cc=akrowiak@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dengler@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=imbrenda@linux.ibm.com \
--cc=jarkko@kernel.org \
--cc=jjherne@linux.ibm.com \
--cc=jpoimboe@kernel.org \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).