All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] svm/avic: Allow avic_vcpu_load logic to support host APIC ID 255
@ 2019-05-14 15:49 Suthikulpanit, Suravee
  2019-05-20 12:57 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Suthikulpanit, Suravee @ 2019-05-14 15:49 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: pbonzini, rkrcmar, joro, graf, Suthikulpanit, Suravee

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>
---

Change in V2:
  * Use AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK instead of
    AVIC_MAX_PHYSICAL_ID_COUNT. 

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

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 687767f..345fe9e 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2071,7 +2071,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 	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));
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] svm/avic: Allow avic_vcpu_load logic to support host APIC ID 255
  2019-05-14 15:49 [PATCH v2] svm/avic: Allow avic_vcpu_load logic to support host APIC ID 255 Suthikulpanit, Suravee
@ 2019-05-20 12:57 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-05-20 12:57 UTC (permalink / raw)
  To: Suthikulpanit, Suravee, linux-kernel, kvm; +Cc: rkrcmar, joro, graf

On 14/05/19 17:49, Suthikulpanit, Suravee wrote:
> 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>

Queued, with Cc to stable and using "kvm: svm/avic: fix off-by-one in
checking host APIC ID" as the subject.

Paolo

> ---
> 
> Change in V2:
>   * Use AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK instead of
>     AVIC_MAX_PHYSICAL_ID_COUNT. 
> 
>  arch/x86/kvm/svm.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 687767f..345fe9e 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -2071,7 +2071,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>  	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));
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-20 12:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14 15:49 [PATCH v2] svm/avic: Allow avic_vcpu_load logic to support host APIC ID 255 Suthikulpanit, Suravee
2019-05-20 12:57 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.