kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes
@ 2020-04-07  6:13 Suravee Suthikulpanit
  2020-04-30 17:44 ` Suravee Suthikulpanit
  2020-05-02 13:13 ` Maxim Levitsky
  0 siblings, 2 replies; 4+ messages in thread
From: Suravee Suthikulpanit @ 2020-04-07  6:13 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: pbonzini, joro, jon.grimm, Suravee Suthikulpanit, Alexander Graf

Current logic incorrectly uses the enum ioapic_irq_destination_types
to check the posted interrupt destination types. However, the value was
set using APIC_DM_XXX macros, which are left-shifted by 8 bits.

Fixes by using the APIC_DM_FIXED and APIC_DM_LOWEST instead.

Fixes: (fdcf75621375 'KVM: x86: Disable posted interrupts for non-standard IRQs delivery modes')
Cc: Alexander Graf <graf@amazon.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 arch/x86/include/asm/kvm_host.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 98959e8..f15e5b3 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1664,8 +1664,8 @@ void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
 static inline bool kvm_irq_is_postable(struct kvm_lapic_irq *irq)
 {
 	/* We can only post Fixed and LowPrio IRQs */
-	return (irq->delivery_mode == dest_Fixed ||
-		irq->delivery_mode == dest_LowestPrio);
+	return (irq->delivery_mode == APIC_DM_FIXED ||
+		irq->delivery_mode == APIC_DM_LOWEST);
 }
 
 static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu)
-- 
1.8.3.1


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

* Re: [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes
  2020-04-07  6:13 [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes Suravee Suthikulpanit
@ 2020-04-30 17:44 ` Suravee Suthikulpanit
  2020-05-02 13:13 ` Maxim Levitsky
  1 sibling, 0 replies; 4+ messages in thread
From: Suravee Suthikulpanit @ 2020-04-30 17:44 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: pbonzini, joro, jon.grimm, Alexander Graf

Ping.

Thanks,
Suravee

On 4/7/20 1:13 PM, Suravee Suthikulpanit wrote:
> Current logic incorrectly uses the enum ioapic_irq_destination_types
> to check the posted interrupt destination types. However, the value was
> set using APIC_DM_XXX macros, which are left-shifted by 8 bits.
> 
> Fixes by using the APIC_DM_FIXED and APIC_DM_LOWEST instead.
> 
> Fixes: (fdcf75621375 'KVM: x86: Disable posted interrupts for non-standard IRQs delivery modes')
> Cc: Alexander Graf <graf@amazon.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>   arch/x86/include/asm/kvm_host.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 98959e8..f15e5b3 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1664,8 +1664,8 @@ void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
>   static inline bool kvm_irq_is_postable(struct kvm_lapic_irq *irq)
>   {
>   	/* We can only post Fixed and LowPrio IRQs */
> -	return (irq->delivery_mode == dest_Fixed ||
> -		irq->delivery_mode == dest_LowestPrio);
> +	return (irq->delivery_mode == APIC_DM_FIXED ||
> +		irq->delivery_mode == APIC_DM_LOWEST);
>   }
>   
>   static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu)
> 

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

* Re: [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes
  2020-04-07  6:13 [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes Suravee Suthikulpanit
  2020-04-30 17:44 ` Suravee Suthikulpanit
@ 2020-05-02 13:13 ` Maxim Levitsky
  2020-05-04 16:17   ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Maxim Levitsky @ 2020-05-02 13:13 UTC (permalink / raw)
  To: Suravee Suthikulpanit, linux-kernel, kvm
  Cc: pbonzini, joro, jon.grimm, Alexander Graf

On Tue, 2020-04-07 at 01:13 -0500, Suravee Suthikulpanit wrote:
> Current logic incorrectly uses the enum ioapic_irq_destination_types
> to check the posted interrupt destination types. However, the value
> was
> set using APIC_DM_XXX macros, which are left-shifted by 8 bits.
> 
> Fixes by using the APIC_DM_FIXED and APIC_DM_LOWEST instead.
> 
> Fixes: (fdcf75621375 'KVM: x86: Disable posted interrupts for non-
> standard IRQs delivery modes')
> Cc: Alexander Graf <graf@amazon.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>  arch/x86/include/asm/kvm_host.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_host.h
> b/arch/x86/include/asm/kvm_host.h
> index 98959e8..f15e5b3 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1664,8 +1664,8 @@ void kvm_set_msi_irq(struct kvm *kvm, struct
> kvm_kernel_irq_routing_entry *e,
>  static inline bool kvm_irq_is_postable(struct kvm_lapic_irq *irq)
>  {
>  	/* We can only post Fixed and LowPrio IRQs */
> -	return (irq->delivery_mode == dest_Fixed ||
> -		irq->delivery_mode == dest_LowestPrio);
> +	return (irq->delivery_mode == APIC_DM_FIXED ||
> +		irq->delivery_mode == APIC_DM_LOWEST);
>  }
>  
>  static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu)

I confirm that this patch fixes AVIC posted interrupts on my 3970X.
Low byte of the delivery mode is the vector, while high byte is the
delivery mode, and the vector is masked in 
kvm_set_msi_irq, thus indeed the delivery mode is in high 8 bytes.


Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Tested-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky


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

* Re: [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes
  2020-05-02 13:13 ` Maxim Levitsky
@ 2020-05-04 16:17   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-05-04 16:17 UTC (permalink / raw)
  To: Maxim Levitsky, Suravee Suthikulpanit, linux-kernel, kvm
  Cc: joro, jon.grimm, Alexander Graf

On 02/05/20 15:13, Maxim Levitsky wrote:
> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
> Tested-by: Maxim Levitsky <mlevitsk@redhat.com>

Queued, thanks.

Paolo


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

end of thread, other threads:[~2020-05-04 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07  6:13 [PATCH] KVM: x86: Fixes posted interrupt check for IRQs delivery modes Suravee Suthikulpanit
2020-04-30 17:44 ` Suravee Suthikulpanit
2020-05-02 13:13 ` Maxim Levitsky
2020-05-04 16:17   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).