All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close
@ 2019-04-26  6:54 ` Paul Mackerras
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2019-04-26  6:54 UTC (permalink / raw)
  To: kvm, Cédric Le Goater; +Cc: David Gibson, kvm-ppc

This adds code to ensure that after a XIVE or XICS-on-XIVE KVM device
is closed, KVM will not try to enable or disable any of the escalation
interrupts for the VCPUs.  We don't have to worry about races between
clearing the pointers and use of the pointers by the XIVE context
push/pull code, because the callers hold the vcpu->mutex, which is
also taken by the KVM_RUN code.  Therefore the vcpu cannot be entering
or exiting the guest concurrently.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 arch/powerpc/kvm/book3s_xive.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
index 4280cd8..4953957 100644
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1096,6 +1096,21 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu)
 			arch_spin_unlock(&sb->lock);
 		}
 	}
+
+	/* Disable vcpu's escalation interrupt */
+	if (vcpu->arch.xive_esc_on) {
+		__raw_readq((void __iomem *)(vcpu->arch.xive_esc_vaddr +
+					     XIVE_ESB_SET_PQ_01));
+		vcpu->arch.xive_esc_on = false;
+	}
+
+	/*
+	 * Clear pointers to escalation interrupt ESB.
+	 * This is safe because the vcpu->mutex is held, preventing
+	 * any other CPU from concurrently executing a KVM_RUN ioctl.
+	 */
+	vcpu->arch.xive_esc_vaddr = 0;
+	vcpu->arch.xive_esc_raddr = 0;
 }
 
 void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
-- 
2.7.4


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

* [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close
@ 2019-04-26  6:54 ` Paul Mackerras
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2019-04-26  6:54 UTC (permalink / raw)
  To: kvm, Cédric Le Goater; +Cc: David Gibson, kvm-ppc

This adds code to ensure that after a XIVE or XICS-on-XIVE KVM device
is closed, KVM will not try to enable or disable any of the escalation
interrupts for the VCPUs.  We don't have to worry about races between
clearing the pointers and use of the pointers by the XIVE context
push/pull code, because the callers hold the vcpu->mutex, which is
also taken by the KVM_RUN code.  Therefore the vcpu cannot be entering
or exiting the guest concurrently.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 arch/powerpc/kvm/book3s_xive.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
index 4280cd8..4953957 100644
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1096,6 +1096,21 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu)
 			arch_spin_unlock(&sb->lock);
 		}
 	}
+
+	/* Disable vcpu's escalation interrupt */
+	if (vcpu->arch.xive_esc_on) {
+		__raw_readq((void __iomem *)(vcpu->arch.xive_esc_vaddr +
+					     XIVE_ESB_SET_PQ_01));
+		vcpu->arch.xive_esc_on = false;
+	}
+
+	/*
+	 * Clear pointers to escalation interrupt ESB.
+	 * This is safe because the vcpu->mutex is held, preventing
+	 * any other CPU from concurrently executing a KVM_RUN ioctl.
+	 */
+	vcpu->arch.xive_esc_vaddr = 0;
+	vcpu->arch.xive_esc_raddr = 0;
 }
 
 void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
-- 
2.7.4

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

* Re: [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close
  2019-04-26  6:54 ` Paul Mackerras
@ 2019-05-06 15:04   ` Cédric Le Goater
  -1 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2019-05-06 15:04 UTC (permalink / raw)
  To: Paul Mackerras, kvm; +Cc: David Gibson, kvm-ppc

On 4/26/19 8:54 AM, Paul Mackerras wrote:
> This adds code to ensure that after a XIVE or XICS-on-XIVE KVM device
> is closed, KVM will not try to enable or disable any of the escalation
> interrupts for the VCPUs.  

Yes. This is a required cleanup.

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.


> We don't have to worry about races between
> clearing the pointers and use of the pointers by the XIVE context
> push/pull code, because the callers hold the vcpu->mutex, which is
> also taken by the KVM_RUN code.  Therefore the vcpu cannot be entering
> or exiting the guest concurrently.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> ---
>  arch/powerpc/kvm/book3s_xive.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
> index 4280cd8..4953957 100644
> --- a/arch/powerpc/kvm/book3s_xive.c
> +++ b/arch/powerpc/kvm/book3s_xive.c
> @@ -1096,6 +1096,21 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu)
>  			arch_spin_unlock(&sb->lock);
>  		}
>  	}
> +
> +	/* Disable vcpu's escalation interrupt */
> +	if (vcpu->arch.xive_esc_on) {
> +		__raw_readq((void __iomem *)(vcpu->arch.xive_esc_vaddr +
> +					     XIVE_ESB_SET_PQ_01));
> +		vcpu->arch.xive_esc_on = false;
> +	}
> +
> +	/*
> +	 * Clear pointers to escalation interrupt ESB.
> +	 * This is safe because the vcpu->mutex is held, preventing
> +	 * any other CPU from concurrently executing a KVM_RUN ioctl.
> +	 */
> +	vcpu->arch.xive_esc_vaddr = 0;
> +	vcpu->arch.xive_esc_raddr = 0;
>  }
>  
>  void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
> 


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

* Re: [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close
@ 2019-05-06 15:04   ` Cédric Le Goater
  0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2019-05-06 15:04 UTC (permalink / raw)
  To: Paul Mackerras, kvm; +Cc: David Gibson, kvm-ppc

On 4/26/19 8:54 AM, Paul Mackerras wrote:
> This adds code to ensure that after a XIVE or XICS-on-XIVE KVM device
> is closed, KVM will not try to enable or disable any of the escalation
> interrupts for the VCPUs.  

Yes. This is a required cleanup.

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.


> We don't have to worry about races between
> clearing the pointers and use of the pointers by the XIVE context
> push/pull code, because the callers hold the vcpu->mutex, which is
> also taken by the KVM_RUN code.  Therefore the vcpu cannot be entering
> or exiting the guest concurrently.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> ---
>  arch/powerpc/kvm/book3s_xive.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
> index 4280cd8..4953957 100644
> --- a/arch/powerpc/kvm/book3s_xive.c
> +++ b/arch/powerpc/kvm/book3s_xive.c
> @@ -1096,6 +1096,21 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu)
>  			arch_spin_unlock(&sb->lock);
>  		}
>  	}
> +
> +	/* Disable vcpu's escalation interrupt */
> +	if (vcpu->arch.xive_esc_on) {
> +		__raw_readq((void __iomem *)(vcpu->arch.xive_esc_vaddr +
> +					     XIVE_ESB_SET_PQ_01));
> +		vcpu->arch.xive_esc_on = false;
> +	}
> +
> +	/*
> +	 * Clear pointers to escalation interrupt ESB.
> +	 * This is safe because the vcpu->mutex is held, preventing
> +	 * any other CPU from concurrently executing a KVM_RUN ioctl.
> +	 */
> +	vcpu->arch.xive_esc_vaddr = 0;
> +	vcpu->arch.xive_esc_raddr = 0;
>  }
>  
>  void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
> 

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

end of thread, other threads:[~2019-05-06 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26  6:54 [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close Paul Mackerras
2019-04-26  6:54 ` Paul Mackerras
2019-05-06 15:04 ` Cédric Le Goater
2019-05-06 15:04   ` Cédric Le Goater

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.