kvm: svm/avic: fix off-by-one in checking host APIC ID
authorSuthikulpanit, Suravee <Suravee.Suthikulpanit@amd.com>
Tue, 14 May 2019 15:49:52 +0000 (15:49 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 May 2019 13:46:01 +0000 (06:46 -0700)
commit709a930541189416dacf863016235c34f40fb603
tree074f558b9df935cbb553e2268a71e908f6ffb2a0
parent5b69ceee219699aac77b761efa484f9d9a8cd4b5
kvm: svm/avic: fix off-by-one in checking host APIC ID

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