On Tue, Sep 21, 2021, Borislav Petkov wrote: > On Tue, Sep 21, 2021 at 01:50:09PM +0000, Sean Christopherson wrote: > > apply_alternatives() is a generic helper that can work on any struct alt_instr > > array, e.g. KVM_HYPERCALL can put its alternative into a different section that's > > patched as soon as the VMM is identified. > > Where exactly in the boot process you wanna move it? init_hypervisor_platform(), after x86_init.hyper.init_platform() so that the PV support can set the desired feature flags. Since kvm_hypercall*() is only used by KVM guests, set_cpu_cap(c, X86_FEATURE_VMMCALL) can be moved out of early_init_amd/hygon() and into kvm_init_platform(). > As Ashish says, you need the boot_cpu_data bits properly set before it > runs. Another option would be to refactor apply_alternatives() to allow the caller to provide a different feature check mechanism than boot_cpu_has(), which I think would let us drop X86_FEATURE_VMMCALL, X86_FEATURE_VMCALL, and X86_FEATURE_VMW_VMMCALL from cpufeatures. That might get more than a bit gross though. But like I said, if others think I'm over-engineering this...