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

Andrea Arcangeli
2019-09-25T12:13:35Z

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