]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: Fix overclearing ESCA in case of error
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Mon, 3 Aug 2026 12:40:31 +0000 (14:40 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Mon, 3 Aug 2026 14:51:33 +0000 (16:51 +0200)
If an attempt is made to create a vCPU with an already existing ID,
the duplicated vCPU will be destroyed. When destroying a vCPU, its
ESCA entry will be cleared. In the above scenario, the spurious
duplicate vCPU is destroyed, but the ESCA entry corresponding to the
original vCPU is cleared.

Fix by skipping clearing the ESCA entry if the vCPU creation was not
successful, i.e. if the vcpu->arch.initialized is still zero.

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Fixes: abf4a71ed95f ("KVM: s390: Unlink vcpu on destroy - v2")
[ Added Fixes tag while picking -- Claudio ]
Message-ID: <20260803124040.126471-5-imbrenda@linux.ibm.com>

arch/s390/kvm/interrupt.c
arch/s390/kvm/kvm-s390.c

index 7514d9e2403c1bb395af14f5d5b133ffe222d09b..bb4e7246604387b92f752a16d67f75cc2326d8fe 100644 (file)
@@ -86,7 +86,7 @@ static void sca_clear_ext_call(struct kvm_vcpu *vcpu)
        struct esca_block *sca = vcpu->kvm->arch.sca;
        union esca_sigp_ctrl *sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl;
 
-       if (!kvm_s390_use_sca_entries())
+       if (!kvm_s390_use_sca_entries() || !vcpu->arch.initialized)
                return;
        kvm_s390_clear_cpuflags(vcpu, CPUSTAT_ECALL_PEND);
 
index 9be27db0a21e628f7bb7a1891a56232543769aec..5b2727d7dfd12c967afcfb0bd561579ddb5f5298 100644 (file)
@@ -3462,7 +3462,7 @@ static void sca_del_vcpu(struct kvm_vcpu *vcpu)
 {
        struct esca_block *sca = vcpu->kvm->arch.sca;
 
-       if (!kvm_s390_use_sca_entries())
+       if (!kvm_s390_use_sca_entries() || !vcpu->arch.initialized)
                return;
 
        clear_bit_inv(vcpu->vcpu_id, (unsigned long *)sca->mcn);