lkml.org 
[lkml]   [2022]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 14/19] KVM: x86: Honor architectural behavior for aliased 8-bit APIC IDs
    From
    Date
    On Wed, 2022-08-31 at 16:41 +0000, Sean Christopherson wrote:
    > On Wed, Aug 31, 2022, Maxim Levitsky wrote:
    > > On Wed, 2022-08-31 at 00:35 +0000, Sean Christopherson wrote:
    > > > - if (!apic_x2apic_mode(apic) && !new->phys_map[xapic_id])
    > > > - new->phys_map[xapic_id] = apic;
    > > > + if (kvm->arch.x2apic_format) {
    > > > + /* See also kvm_apic_match_physical_addr(). */
    > > > + if ((apic_x2apic_mode(apic) || x2apic_id > 0xff) &&
    > > > + x2apic_id <= new->max_apic_id)
    > > > + new->phys_map[x2apic_id] = apic;
    > > > +
    > > > + if (!apic_x2apic_mode(apic) && !new->phys_map[xapic_id])
    > > > + new->phys_map[xapic_id] = apic;
    > > > + } else {
    > > > + /*
    > > > + * Disable the optimized map if the physical APIC ID is
    > > > + * already mapped, i.e. is aliased to multiple vCPUs.
    > > > + * The optimized map requires a strict 1:1 mapping
    > > > + * between IDs and vCPUs.
    > > > + */
    > > > + if (apic_x2apic_mode(apic))
    > > > + physical_id = x2apic_id;
    > > > + else
    > > > + physical_id = xapic_id;
    > > > +
    > > > + if (new->phys_map[physical_id]) {
    > > > + kvfree(new);
    > > > + new = NULL;
    > > > + goto out;
    > > Why not to use the same KVM_APIC_MODE_XAPIC_FLAT | KVM_APIC_MODE_XAPIC_CLUSTER
    > > hack here?
    >
    > The map's "mode" only covers logical mode (the cleanup patch renames "mode" to
    > "logical_mode" to make this more clear). There is no equivalent for dealing with
    > the physical IDs. Alternatively, a flag to say "physical map is disabled" could
    > be added, but KVM already has to cleanly handle a NULL map and in all likelihood
    > the logical map is also going to be disabled anyways.
    >
    > Not to mention that APIC performance is unlikely to be a priority for any guest
    > that triggers this code :-)
    >

    Thanks for the explanation, that makes sense!

    Best regards,
    Maxim Levitsky

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