diff mbox series

[07/17] KVM: monolithic: x86: adjust the section prefixes

Message ID 20190920212509.2578-8-aarcange@redhat.com (mailing list archive)
State New, archived
Headers show
Series KVM monolithic v1 | expand

Commit Message

Andrea Arcangeli Sept. 20, 2019, 9:24 p.m. UTC
Adjusts the section prefixes of some KVM common code function because
with the monolithic methods the section checker can now do a more
accurate analysis at build time and this allows to build without
CONFIG_SECTION_MISMATCH_WARN_ONLY=n.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
 arch/x86/kvm/svm.c     | 2 +-
 arch/x86/kvm/vmx/vmx.c | 2 +-
 arch/x86/kvm/x86.c     | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Paolo Bonzini Sept. 23, 2019, 10:15 a.m. UTC | #1
On 20/09/19 23:24, Andrea Arcangeli wrote:
> Adjusts the section prefixes of some KVM common code function because
> with the monolithic methods the section checker can now do a more
> accurate analysis at build time and this allows to build without
> CONFIG_SECTION_MISMATCH_WARN_ONLY=n.
> 
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>

I think it's the opposite---the checker is detecting *missing* section
prefixes, for example vmx_exit, kvm_exit, kvm_arch_hardware_unsetup etc.
could be marked __exit.

Paolo
Andrea Arcangeli Sept. 25, 2019, 12:13 p.m. UTC | #2
Hello,

On Mon, Sep 23, 2019 at 12:15:23PM +0200, Paolo Bonzini wrote:
> On 20/09/19 23:24, Andrea Arcangeli wrote:
> > Adjusts the section prefixes of some KVM common code function because
> > with the monolithic methods the section checker can now do a more
> > accurate analysis at build time and this allows to build without
> > CONFIG_SECTION_MISMATCH_WARN_ONLY=n.
> > 
> > Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> 
> I think it's the opposite---the checker is detecting *missing* section
> prefixes, for example vmx_exit, kvm_exit, kvm_arch_hardware_unsetup etc.
> could be marked __exit.

I added the two missing __init.

The __exit removed from unsetup is because kvm_arch_hardware_unsetup
is called by kvm_init, so unless somehow kvm_init can go in the exit
section and be dropped too during the final kernel link (which would
prevent KVM to initialize in the first place at kernel boot), it's not
feasible to call a function located in the exit section and dropped
during the kernel link from there.

As far as I can tell with upstream KVM if you hit the
kvm_arch_hardware_unsetup function during kvm_init error path it'll
crash the kernel at boot because of it.

Removing __exit fixes that potential upstream crash and upstream bug.

The comment header was short, I'll add more commentary to the commit
header to reduce the confusion about why removing __exit is needed.

Thanks,
Andrea
Paolo Bonzini Sept. 25, 2019, 12:32 p.m. UTC | #3
On 25/09/19 14:13, Andrea Arcangeli wrote:
> 
> The __exit removed from unsetup is because kvm_arch_hardware_unsetup
> is called by kvm_init, so unless somehow kvm_init can go in the exit
> section and be dropped too during the final kernel link (which would
> prevent KVM to initialize in the first place at kernel boot), it's not
> feasible to call a function located in the exit section and dropped
> during the kernel link from there.
> 
> As far as I can tell with upstream KVM if you hit the
> kvm_arch_hardware_unsetup function during kvm_init error path it'll
> crash the kernel at boot because of it.
> 
> Removing __exit fixes that potential upstream crash and upstream bug.

You're right.

> The comment header was short, I'll add more commentary to the commit
> header to reduce the confusion about why removing __exit is needed.

Yes, thanks!

Paolo
diff mbox series

Patch

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 3041abbd643b..5a48beb58083 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1407,7 +1407,7 @@  static __init int svm_hardware_setup(void)
 	return r;
 }
 
-static __exit void svm_hardware_unsetup(void)
+static void svm_hardware_unsetup(void)
 {
 	int cpu;
 
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 9fc3969f6443..09e6a477e06f 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -7642,7 +7642,7 @@  static __init int hardware_setup(void)
 	return r;
 }
 
-static __exit void hardware_unsetup(void)
+static void hardware_unsetup(void)
 {
 	if (nested)
 		nested_vmx_hardware_unsetup();
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dfd641243568..c04894b61384 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9206,7 +9206,7 @@  void kvm_arch_hardware_disable(void)
 	drop_user_return_notifiers();
 }
 
-int kvm_arch_hardware_setup(void)
+__init int kvm_arch_hardware_setup(void)
 {
 	int r;
 
@@ -9237,7 +9237,7 @@  void kvm_arch_hardware_unsetup(void)
 	kvm_x86_ops->hardware_unsetup();
 }
 
-int kvm_arch_check_processor_compat(void)
+__init int kvm_arch_check_processor_compat(void)
 {
 	return kvm_x86_ops->check_processor_compatibility();
 }