lkml.org 
[lkml]   [2019]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.1 016/405] kvm: svm/avic: fix off-by-one in checking host APIC ID
    Date
    From: Suthikulpanit, Suravee <Suravee.Suthikulpanit@amd.com>

    commit c9bcd3e3335d0a29d89fabd2c385e1b989e6f1b0 upstream.

    Current logic does not allow VCPU to be loaded onto CPU with
    APIC ID 255. This should be allowed since the host physical APIC ID
    field in the AVIC Physical APIC table entry is an 8-bit value,
    and APIC ID 255 is valid in system with x2APIC enabled.
    Instead, do not allow VCPU load if the host APIC ID cannot be
    represented by an 8-bit value.

    Also, use the more appropriate AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK
    instead of AVIC_MAX_PHYSICAL_ID_COUNT.

    Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    arch/x86/kvm/svm.c | 6 +++++-
    1 file changed, 5 insertions(+), 1 deletion(-)

    --- a/arch/x86/kvm/svm.c
    +++ b/arch/x86/kvm/svm.c
    @@ -2024,7 +2024,11 @@ static void avic_vcpu_load(struct kvm_vc
    if (!kvm_vcpu_apicv_active(vcpu))
    return;

    - if (WARN_ON(h_physical_id >= AVIC_MAX_PHYSICAL_ID_COUNT))
    + /*
    + * Since the host physical APIC id is 8 bits,
    + * we can support host APIC ID upto 255.
    + */
    + if (WARN_ON(h_physical_id > AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
    return;

    entry = READ_ONCE(*(svm->avic_physical_id_cache));

    \
     
     \ /
      Last update: 2019-05-30 07:02    [W:4.034 / U:0.928 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site