From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2F1C4446E9; Thu, 30 Jul 2026 16:27:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428846; cv=none; b=WsfkclGn3T/2rnsNczs+4ZhN1/cka4tYBJ1COZnhEPtGpTyBNy8zbmXkZ8eYkZ1L0Dxi0+fApEDCURXK98R3GBO67ulXiXPpAaRktfedKTv+mReHxrlOmsYMmV089yFx9M0ejLec8i4UzMpWu9K1d1hfMYSuuTf6aBr9Qn9Sqi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428846; c=relaxed/simple; bh=W7sxjPN80Ykg7WhBF3MATOx8YI492OEZTOIVgRfL0Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fXiXPrE85xz65/QCrt3VEG4kzWfFsBmCVeCooDEh6iODBsSpFMe6n5X3Tau86hmiTBXYq9hoviteg2uoAR56UmM6pnlbniwUyhyh+vMj76VuCc9rPjVQqq+aJ9DQl/SS8AGQRDc+4yN3oZayZ8ah2Rj2rbzwRpoCKd8OH09bZrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=MAT5lAi/; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="MAT5lAi/" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66UFluSk3424694; Thu, 30 Jul 2026 16:27:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=FLPvJVvI9U9fgnu0x LnJlDwrnaAytQSWPf1zKvPc2fM=; b=MAT5lAi/6yEhwAphD33g3hAY1t2DXxBKG Tr7UvPH0JVGh9twaKnt0+XvsJvbUO4KclfSEgxEOVUph77lCpZ0jOq1c7piopZsf UEii+r1ZT3TeeJvBDYx1cQmL+LfNQpABcCsfIrj6BSjpXdfewR2K2wQZP4pGh3pI DCAaz/3WoMgrLxKd1SN7ZC8NBiFdsagjC0i58Zfj3AgOpuAEmNu9qPwi7J5273ZI UMtUUQZhqksfRedz7UcuvexTvPbDcG11c1psjHgT5QcGGnB9sBQ91WWPLRxGaCHo m2BC5E8Idi8VIK8hcRXbLitp0fMXrsxOAWyXqgcNHCP89onJJgatw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fmuw7rs5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Jul 2026 16:27:22 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66UGQMFN010803; Thu, 30 Jul 2026 16:27:21 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fn8yhm1vg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Jul 2026 16:27:21 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66UGRFIj35127786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2026 16:27:15 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71E142004B; Thu, 30 Jul 2026 16:27:15 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DEB420043; Thu, 30 Jul 2026 16:27:15 +0000 (GMT) Received: from p-imbrenda.ehn-de.ibm.com (unknown [9.224.75.30]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 30 Jul 2026 16:27:15 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, david@kernel.org, seiden@linux.ibm.com, nrb@linux.ibm.com, schlameuss@linux.ibm.com, gra@linux.ibm.com Subject: [PATCH v6 03/14] KVM: s390: Fix overclearing ESCA in case of error Date: Thu, 30 Jul 2026 18:27:03 +0200 Message-ID: <20260730162714.133327-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730162714.133327-1-imbrenda@linux.ibm.com> References: <20260730162714.133327-1-imbrenda@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: V_uvrK3eciR6d9dgkQ9qhNA6Ug7Y_oiY X-Proofpoint-ORIG-GUID: V_uvrK3eciR6d9dgkQ9qhNA6Ug7Y_oiY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzMwMDEyMyBTYWx0ZWRfX/1tAVyLe1CL8 dFvfe0fzYzvQvh4356L7+pV7a3nIhYIlMnbEN2+X75yav8J3BvSMEPsVDBfj21/3rKIfLHm7xe7 W9d/NpV4BjcDdRcdE2Tf5vFYiecR96izlbM7MzarN3wWm8meqRxUEzSkIcbUd4s6WtQe+zxYyrf F2NndUSbUBerCIjuuI7agOmb6v4XC/aRJGvX2j8F/4RsR5LUkhu5vr3obE9HFdSahbdADKYI6P0 4snOZcQVOHTeK7JGBXpFC3HME7FCcy/hboYvy4x1MvLo0OIlG/fRfVOZF29lDpyahmOrIORzV9D sNEUGqLPLZzFKzYxYPZ/kzmocT97Fbd/5NP79tVFuUFj9wIGqQTBPR3F6h4LOcBcPURGHNLWiW+ BAYpqzGNhgJjapGcwG+iKezG2zcM/CDj4bRl9gY8tLLHKqjOMZdRhiyG4rhEFnyCtsLOfUqj05x OH+IJq38zJEunN/U/rg== X-Authority-Analysis: v=2.4 cv=SKFykuvH c=1 sm=1 tr=0 ts=6a6b7b6a cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=OniIQR2WiTFW0jQNa14A:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzMwMDEyMyBTYWx0ZWRfX/pCKGbqgHCSU xev0e/nj5FjYWl378u5OhwC0pzdml3NJ3zE3cFfjxfjUH6yhkLRDOIQFc9PzbF4cNZ93GZbzovF ZqnO/rdL6/aWnp1Kf4b+bn2b2spsjyg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-30_04,2026-07-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607300123 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 pointer to the ESCA in the state description is not set. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- arch/s390/kvm/interrupt.c | 2 +- arch/s390/kvm/kvm-s390.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 9e3e6b0d72ad..2acdff130fa6 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -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); diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 9ec5833a0973..58cec3703c2d 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3461,7 +3461,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); -- 2.55.0