On Mon, Jun 13, 2022 at 05:16:48PM +0000, Sean Christopherson wrote: >The shortlog is not at all helpful, it doesn't say anything about what actual >functional change. > > KVM: x86: Don't advertise PV IPI to userspace if IPIs are virtualized > >On Mon, Jun 13, 2022, wangguangju wrote: >> Commit d588bb9be1da ("KVM: VMX: enable IPI virtualization") >> enable IPI virtualization in Intel SPR platform.There is no point >> in using PVIPI if IPIv is supported, it doesn't work less good >> with PVIPI than without it. >> >> So add a bool variable to distinguish whether to use PVIPI. > >Similar complaint with the changelog, it doesn't actually call out why PV IPIs >are unwanted. > > Don't advertise PV IPI support to userspace if IPI virtualization is > supported by the CPU. Hardware virtualization of IPIs more performant > as senders do not need to exit. PVIPI is mainly [*] for sending multi-cast IPIs. Intel IPI virtualization can virtualize only uni-cast IPIs. Their use cases don't overlap. So, I don't think it makes sense to disable PVIPI if intel IPI virtualization is supported. The question actually is how to deal with the exceptional case below. Considering the migration case Sean said below, it is hard to let VM always work in the ideal way unless KVM notifies VM of migration and VM changes its behavior on receiving such notifications. But since x2apic has better performance than xapic, if VM cares about performance, it can simply switch to x2apic mode. All things considered, I think the performance gain isn't worth the complexity added. So, I prefer to leave it as is. [*]: when linux guest is in *xapic* mode, it uses PVIPI to send uni-case IPI. > >That said, I'm not sure that KVM should actually hide PV_SEND_IPI. KVM still >supports the feature, and unlike sched_info_on(), IPI virtualization is platform >dependent and not fully controlled by software. E.g. hiding PV_SEND_IPI could >cause problems when migrating from a platform without IPIv to a platform with IPIv, >as a paranoid VMM might complain that an exposed feature isn't supported by KVM. > >There's also the question of what to do about AVIC. AVIC has many more inhibits >than APICv, e.g. an x2APIC guest running on hardware that doesn't accelerate x2APIC >IPIs will probably be better off with PV IPIs. > >Given that userspace should have read access to the module param, I'm tempted to >say KVM should let userspace make the decision of whether or not to advertise PV >IPIs to the guest.