lkml.org 
[lkml]   [2022]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 16/19] KVM: x86: Explicitly track all possibilities for APIC map's logical modes
    On Wed, Aug 31, 2022, Maxim Levitsky wrote:
    > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
    > > index 8209caffe3ab..3b6ef36b3963 100644
    > > --- a/arch/x86/kvm/lapic.c
    > > +++ b/arch/x86/kvm/lapic.c
    > > @@ -168,7 +168,12 @@ static bool kvm_use_posted_timer_interrupt(struct kvm_vcpu *vcpu)
    > >
    > > static inline bool kvm_apic_map_get_logical_dest(struct kvm_apic_map *map,
    > > u32 dest_id, struct kvm_lapic ***cluster, u16 *mask) {
    > > - switch (map->mode) {
    > > + switch (map->logical_mode) {
    > > + case KVM_APIC_MODE_SW_DISABLED:
    > > + /* Arbitrarily use the flat map so that @cluster isn't NULL. */
    > > + *cluster = map->xapic_flat_map;
    > > + *mask = 0;
    > > + return true;
    > Could you explain why this is needed? I probably missed something.

    If all vCPUs leave their APIC software disabled, or leave LDR=0, then the overall
    mode will be KVM_APIC_MODE_SW_DISABLED. In this case, the effective "mask" is '0'
    because there are no targets. And this returns %true because there are no targets,
    i.e. there's no need to go down the slow path after kvm_apic_map_get_dest_lapic().

    > > @@ -993,7 +1011,7 @@ static bool kvm_apic_is_broadcast_dest(struct kvm *kvm, struct kvm_lapic **src,
    > > {
    > > if (kvm->arch.x2apic_broadcast_quirk_disabled) {
    > > if ((irq->dest_id == APIC_BROADCAST &&
    > > - map->mode != KVM_APIC_MODE_X2APIC))
    > > + map->logical_mode != KVM_APIC_MODE_X2APIC))
    > > return true;
    > > if (irq->dest_id == X2APIC_BROADCAST)
    > > return true;
    >
    > To be honest I would put that patch first, and then do all the other patches,
    > this way you would avoid all of the hacks they do and removed here.

    I did it this way so that I could test this patch for correctness. Without the
    bug fixes in place it's not really possible to verify this patch is 100% correct.

    I completely agree that it would be a lot easier to read/understand/review if
    this came first, but I'd rather not sacrifice the ability to easily test this patch.

    \
     
     \ /
      Last update: 2022-08-31 18:58    [W:3.442 / U:0.500 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site