diff mbox series

[v2,2/2] arch/powerpc/kvm: Fix doorbell emulation for v2 API

Message ID 20240605113913.83715-3-gautam@linux.ibm.com (mailing list archive)
State Accepted
Commit 54ec2bd9e0173b75daf84675d07c56584f96564b
Headers show
Series Fix doorbell emulation for v2 API on PPC | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.

Commit Message

Gautam Menghani June 5, 2024, 11:39 a.m. UTC
Doorbell emulation is broken for KVM on PAPR guests as support for
DPDES was not added in the initial patch series. Due to this, a KVM on
PAPR guest with SMT > 1 cannot be booted with the XICS interrupt
controller as doorbells are setup in the initial probe path when using XICS
(pSeries_smp_probe()).

Command to replicate the above bug:

qemu-system-ppc64 \
	-drive file=rhel.qcow2,format=qcow2 \
	-m 20G \
	-smp 8,cores=1,threads=8 \
	-cpu  host \
	-nographic \
	-machine pseries,ic-mode=xics -accel kvm

Add doorbell state handling support in the host
KVM code to fix doorbell emulation.

Fixes: 19d31c5f1157 ("KVM: PPC: Add support for nestedv2 guests")
Cc: stable@vger.kernel.org # v6.7
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
 arch/powerpc/kvm/book3s_hv.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Nicholas Piggin June 6, 2024, 2:59 a.m. UTC | #1
On Wed Jun 5, 2024 at 9:39 PM AEST, Gautam Menghani wrote:
> Doorbell emulation is broken for KVM on PAPR guests as support for
> DPDES was not added in the initial patch series. Due to this, a KVM on
> PAPR guest with SMT > 1 cannot be booted with the XICS interrupt
> controller as doorbells are setup in the initial probe path when using XICS
> (pSeries_smp_probe()).
>
> Command to replicate the above bug:
>
> qemu-system-ppc64 \
> 	-drive file=rhel.qcow2,format=qcow2 \
> 	-m 20G \
> 	-smp 8,cores=1,threads=8 \
> 	-cpu  host \
> 	-nographic \
> 	-machine pseries,ic-mode=xics -accel kvm
>
> Add doorbell state handling support in the host
> KVM code to fix doorbell emulation.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

>
> Fixes: 19d31c5f1157 ("KVM: PPC: Add support for nestedv2 guests")
> Cc: stable@vger.kernel.org # v6.7
> Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
> ---
>  arch/powerpc/kvm/book3s_hv.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 35cb014a0c51..21c69647d27c 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -4116,6 +4116,11 @@ static int kvmhv_vcpu_entry_nestedv2(struct kvm_vcpu *vcpu, u64 time_limit,
>  	int trap;
>  	long rc;
>  
> +	if (vcpu->arch.doorbell_request) {
> +		vcpu->arch.doorbell_request = 0;
> +		kvmppc_set_dpdes(vcpu, 1);
> +	}
> +
>  	io = &vcpu->arch.nestedv2_io;
>  
>  	msr = mfmsr();
diff mbox series

Patch

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 35cb014a0c51..21c69647d27c 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4116,6 +4116,11 @@  static int kvmhv_vcpu_entry_nestedv2(struct kvm_vcpu *vcpu, u64 time_limit,
 	int trap;
 	long rc;
 
+	if (vcpu->arch.doorbell_request) {
+		vcpu->arch.doorbell_request = 0;
+		kvmppc_set_dpdes(vcpu, 1);
+	}
+
 	io = &vcpu->arch.nestedv2_io;
 
 	msr = mfmsr();