public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] KVM: VMX: add encapsulation kvm_vcpu_pi_need_handle
  2017-09-21 15:14 [PATCH] KVM: VMX: add encapsulation kvm_vcpu_pi_need_handle Peng Hao
@ 2017-09-21  8:16 ` Longpeng (Mike)
  0 siblings, 0 replies; 2+ messages in thread
From: Longpeng (Mike) @ 2017-09-21  8:16 UTC (permalink / raw)
  To: Peng Hao; +Cc: pbonzini, rkrcmar, x86, kvm, linux-kernel

Hi Peng,

There are two bugs in current code and Paolo already fixed them, please see:
https://www.spinics.net/lists/kvm/msg150896.html

-- 
Regards,
Longpeng(Mike)

On 2017/9/21 23:14, Peng Hao wrote:

> use kvm_vcpu_pi_need_handle encapsulation simply coede
> 
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
>  arch/x86/kvm/vmx.c | 27 ++++++++++++---------------
>  1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 4253ade..26b99f4 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -559,6 +559,13 @@ static inline int pi_test_sn(struct pi_desc *pi_desc)
>  			(unsigned long *)&pi_desc->control);
>  }
>  
> +static inline bool kvm_vcpu_pi_need_handle(struct kvm_vcpu *vcpu)
> +{
> +	return kvm_arch_has_assigned_device(vcpu->kvm) &&
> +		irq_remapping_cap(IRQ_POSTING_CAP)  &&
> +		kvm_vcpu_apicv_active(vcpu);
> +}
> +
>  struct vcpu_vmx {
>  	struct kvm_vcpu       vcpu;
>  	unsigned long         host_rsp;
> @@ -2202,9 +2209,7 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
>  	struct pi_desc old, new;
>  	unsigned int dest;
>  
> -	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
> -		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
> -		!kvm_vcpu_apicv_active(vcpu))
> +	if (!kvm_vcpu_pi_need_handle(vcpu))
>  		return;
>  
>  	do {
> @@ -2323,9 +2328,7 @@ static void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
>  {
>  	struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
>  
> -	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
> -		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
> -		!kvm_vcpu_apicv_active(vcpu))
> +	if (!kvm_vcpu_pi_need_handle(vcpu))
>  		return;
>  
>  	/* Set SN when the vCPU is preempted */
> @@ -11691,9 +11694,7 @@ static int pi_pre_block(struct kvm_vcpu *vcpu)
>  	struct pi_desc old, new;
>  	struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
>  
> -	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
> -		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
> -		!kvm_vcpu_apicv_active(vcpu))
> +	if (!kvm_vcpu_pi_need_handle(vcpu))
>  		return 0;
>  
>  	vcpu->pre_pcpu = vcpu->cpu;
> @@ -11769,9 +11770,7 @@ static void pi_post_block(struct kvm_vcpu *vcpu)
>  	unsigned int dest;
>  	unsigned long flags;
>  
> -	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
> -		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
> -		!kvm_vcpu_apicv_active(vcpu))
> +	if (!kvm_vcpu_pi_need_handle(vcpu))
>  		return;
>  
>  	do {
> @@ -11831,9 +11830,7 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
>  	struct vcpu_data vcpu_info;
>  	int idx, ret = -EINVAL;
>  
> -	if (!kvm_arch_has_assigned_device(kvm) ||
> -		!irq_remapping_cap(IRQ_POSTING_CAP) ||
> -		!kvm_vcpu_apicv_active(kvm->vcpus[0]))
> +	if (!kvm_vcpu_pi_need_handle(kvm->vcpus[0]))
>  		return 0;
>  
>  	idx = srcu_read_lock(&kvm->irq_srcu);


-- 
Regards,
Longpeng(Mike)

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

* [PATCH] KVM: VMX: add encapsulation kvm_vcpu_pi_need_handle
@ 2017-09-21 15:14 Peng Hao
  2017-09-21  8:16 ` Longpeng (Mike)
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Hao @ 2017-09-21 15:14 UTC (permalink / raw)
  To: pbonzini, rkrcmar; +Cc: x86, kvm, linux-kernel, Peng Hao

use kvm_vcpu_pi_need_handle encapsulation simply coede

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 arch/x86/kvm/vmx.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 4253ade..26b99f4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -559,6 +559,13 @@ static inline int pi_test_sn(struct pi_desc *pi_desc)
 			(unsigned long *)&pi_desc->control);
 }
 
+static inline bool kvm_vcpu_pi_need_handle(struct kvm_vcpu *vcpu)
+{
+	return kvm_arch_has_assigned_device(vcpu->kvm) &&
+		irq_remapping_cap(IRQ_POSTING_CAP)  &&
+		kvm_vcpu_apicv_active(vcpu);
+}
+
 struct vcpu_vmx {
 	struct kvm_vcpu       vcpu;
 	unsigned long         host_rsp;
@@ -2202,9 +2209,7 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
 	struct pi_desc old, new;
 	unsigned int dest;
 
-	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
-		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
-		!kvm_vcpu_apicv_active(vcpu))
+	if (!kvm_vcpu_pi_need_handle(vcpu))
 		return;
 
 	do {
@@ -2323,9 +2328,7 @@ static void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
 {
 	struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
 
-	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
-		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
-		!kvm_vcpu_apicv_active(vcpu))
+	if (!kvm_vcpu_pi_need_handle(vcpu))
 		return;
 
 	/* Set SN when the vCPU is preempted */
@@ -11691,9 +11694,7 @@ static int pi_pre_block(struct kvm_vcpu *vcpu)
 	struct pi_desc old, new;
 	struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
 
-	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
-		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
-		!kvm_vcpu_apicv_active(vcpu))
+	if (!kvm_vcpu_pi_need_handle(vcpu))
 		return 0;
 
 	vcpu->pre_pcpu = vcpu->cpu;
@@ -11769,9 +11770,7 @@ static void pi_post_block(struct kvm_vcpu *vcpu)
 	unsigned int dest;
 	unsigned long flags;
 
-	if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
-		!irq_remapping_cap(IRQ_POSTING_CAP)  ||
-		!kvm_vcpu_apicv_active(vcpu))
+	if (!kvm_vcpu_pi_need_handle(vcpu))
 		return;
 
 	do {
@@ -11831,9 +11830,7 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
 	struct vcpu_data vcpu_info;
 	int idx, ret = -EINVAL;
 
-	if (!kvm_arch_has_assigned_device(kvm) ||
-		!irq_remapping_cap(IRQ_POSTING_CAP) ||
-		!kvm_vcpu_apicv_active(kvm->vcpus[0]))
+	if (!kvm_vcpu_pi_need_handle(kvm->vcpus[0]))
 		return 0;
 
 	idx = srcu_read_lock(&kvm->irq_srcu);
-- 
1.8.3.1

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

end of thread, other threads:[~2017-09-21 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21 15:14 [PATCH] KVM: VMX: add encapsulation kvm_vcpu_pi_need_handle Peng Hao
2017-09-21  8:16 ` Longpeng (Mike)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox