[Linux PPC] KVM PR and KVM HV do not work if the kernel was compiled with PREEMPT
From: Christian Zigotzky <hidden>
Date: 2026-02-21 05:30:33
On 17/02/26 12:34, Shrikanth Hegde wrote:
quoted hunk ↗ jump to hunk
On 2/17/26 3:56 PM, Christian Zigotzky wrote:quoted
On 17/02/26 11:17 Madhavan Srinivasan wrote:quoted
On 2/17/26 3:14 PM, Christian Zigotzky wrote:quoted
On 17/02/26 10:03, Shrikanth Hegde wrote:quoted
On 2/17/26 2:22 PM, Christian Zigotzky wrote:quoted
Hi, Thank you for your patch. I tested the latest git kernel with your patch today. Unfortunately the system freezes while booting the VM with KVM HV. Cheers, ChristianWould it be possible to share the console log or boot log of KVM to the point it freezes?Unfortunately there aren't any error messages. I also tried it with: gdb --args qemu-system-ppc64 -M ppce500 -cpu e5500 -m 1024 -kernel uImage-7.0-preempt -drive format=raw,file=void-live-powerpc-20230317- updated2.img,index=0,if=virtio -netdev user,id=mynet0 -device virtio- net,netdev=mynet0 -append "rw root=/dev/vda" -device virtio-gpu-pci - device virtio-mouse-pci -device virtio-keyboard-pci -enable-kvm -smp 4 and with gdb in the guest: qemu-system-ppc64 -s -S -M ppce500 -cpu e5500 -m 1024 -kernel uImage-7.0-preempt -drive format=raw,file=void-live-powerpc-20230317- updated2.img,index=0,if=virtio -netdev user,id=mynet0 -device virtio- net,netdev=mynet0 -append "rw root=/dev/vda" -device virtio-gpu-pci - device virtio-mouse-pci -device virtio-keyboard-pci -enable-kvm -smp 4 The system freezed without any error messages.Anything on host console?quoted
quoted
can you please share the config. I tried kvm-hv in my power8/power9 and seems to boot fine without any issues with today's upstream MaddyHere are the configs. With PREEMPT: https://github.com/chzigotzky/kernels/blob/ d50d259ca63dd2b3b9a9eaabc82e5cc69c8cc9f0/configs/e5500_defconfig Without PREEMPT: https://github.com/chzigotzky/kernels/blob/main/ configs/e5500_defconfig - ChristianI looked at the code. there was one more place where cond_resched was there. If possible give the below try. (Note: Didn;t replicate your issue) ---diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 7667563fb9ff..bf0ca49c9915 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c@@ -4825,10 +4825,13 @@ static int kvmppc_run_vcpu(struct kvm_vcpu *vcpu)vc->runner = vcpu; if (n_ceded == vc->n_runnable) { kvmppc_vcore_blocked(vc); - } else if (need_resched()) { + } else if (need_resched() || spin_needbreak(&vc->lock)) { kvmppc_vcore_preempt(vc); /* Let something else run */ - cond_resched_lock(&vc->lock); + spin_unlock(&vc->lock); + schedule(); + //cond_resched_lock(&vc->lock); + spin_lock(&vc->lock); if (vc->vcore_state == VCORE_PREEMPT) kvmppc_vcore_end_preempt(vc); } else {@@ -4901,7 +4904,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu,u64 time_limit, } if (need_resched()) - cond_resched(); + schedule(); kvmppc_update_vpas(vcpu);diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 9a89a6d98f97..54963c1d8b58 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c@@ -86,7 +86,7 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)while (true) { if (need_resched()) { local_irq_enable(); - cond_resched(); + schedule(); hard_irq_disable(); continue; }
Hello Shrikanth, I tested your patch today. The patched preempt kernel boots on my e5500 host and in an e5500 VM. Unfortunately my guest and host freeze after loading the VirtIO-GPU. Thanks for your help, Christian -- Sent with BrassMonkey 33.9.1 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_33.9.1)