Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796235426; b=rTCVQc+yq+qdNHqzjxSHUuwxXDnp4AZP6FzNfHqgkDT4I8SiXqlXWFcQ/BcEKq7KRSTB +6fVA58Z92Znrx8+o5IgUf8YY39/ljBaz/7lzX1OstPbh+c4+oaEosqqyWHn1Qki5PGxy ogQbCJ2DpPTdQTbXUUTnKKR6yMA5uEozwDOHRYBOzV2S4aXPx8H/mc15rVs/jMSdFSPQg f5p+cayWroH8XQllpIKNl8MMgNAiTZsU2EC1zE3BfBOZROEQpj1eP/OZPtuC18Zad3sJT RfDrDNwjFVqJzngmRuIYtJOSIPWwqnWENYbeiyPgFr5xUsuRztr52V10l4vwFXuDCbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796235426; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-TM-AS-GCONF:X-Proofpoint-Reinject:X-Proofpoint-Spam-Info: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=N1vmqPLH1A1UsUQ5xnyX+uSjbiVdLXK3z8oIbJcI5mI=; b=kvcF9FPo04ue2+lkJtrMJUwCIh/GoHPSf9M9Dm5wXkP7b7bYMjYKYiX8Sk+wFRWNCokG BPwg8K7X0K4AhfSMw5TsepPt+0/WNrX1GrIrf4SCs3V8NzTkVmfBFwJbgjJgboNHx3lPK Ju4luo/cG/vdgEspalG2yyjhCsdvv4qNGQrdb4t8QSMu6TT62t0wq8hEbTFHHol59Lvwd A3Vwr9TEUc0Fv7nCWJ4orBfSUGq+wQrNhclioKDD6ppLySb3Pvm19znnwwMG1ET1hxaD2 1Wi56kjHqdDN9S1BBCIFo4mn1mefwLwImjskNBRojPadrgSrSTR3eM7gkCPe8DCF9zw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=qUCOsioD; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F89F606A322; Wed, 2 Dec 2026 18:17:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5F89F606A322 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, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=qUCOsioD 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 6B2I4igW1333811; Wed, 2 Dec 2026 18:16:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=N1vmqPLH1A1UsUQ5xnyX+uSjbiVdLXK3z8oIbJcI5 mI=; b=qUCOsioDcjVSzhWcBs5mNui8BCzXtH71JfVXli1zW/66yS6JMR703jBvG bldupN7huXfG1If212sOcg0P1NO7uHRtb5Jm0r0PyB2aE8+4UK1xohRB3jamUZ1z OWMtWFKC+1Eko58GgTcEGCrRiGiF2odQC3taZ/41nTWlrnhKVPwoCOZvVddnYmll auuyg0SGm+Qma1VK9/NHFFIUWSXqZijQMjcs0biGDp3z1546Npzqgdn84SgeLFlm nY83PBKM/Kyxr7DZq8JUFx2N8AdTbwXIJpF0+eeUZ0K55ijd48KKvmfX4aLU+8Sh 9IGyF8usTrs12XamdaqfE2vzgYF3A== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pf43cxk-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 18:16:43 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2I7TLQ737126; Wed, 2 Dec 2026 18:16:42 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j9u5fxekx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 18:16:42 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B2IGeNJ30736822 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Dec 2026 18:16:41 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EE9C5805A; Wed, 2 Dec 2026 18:16:40 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 654BB5805E; Wed, 2 Dec 2026 18:16:35 +0000 (GMT) Received: from localhost.localdomain (unknown [9.124.213.56]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Dec 2026 18:16:35 +0000 (GMT) From: Amit Machhiwal To: Madhavan Srinivasan , linuxppc-dev@lists.ozlabs.org Cc: Amit Machhiwal , Gautam Menghani , Harsh Prateek Bora , Nicholas Piggin , Michael Ellerman , "Christophe Leroy (CS GROUP)" , "Ritesh Harjani (IBM)" , Shrikanth Hegde , Jordan Niethe , kvm@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 0/2] KVM: PPC: Don't alias unclassified guest state IDs onto bit 0 Date: Wed, 2 Dec 2026 23:46:28 +0530 Message-ID: <20261202181630.21203-1-amachhiw@linux.ibm.com> X-Mailer: git-send-email 2.54.0 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA3MiBTYWx0ZWRfX1Ado5hk6LrnU 9McVkPcHN70SaL5TPOcpnglnpnv5ttoVvgekZRqHWB5boRUxwYWjELR/W4MQ874A6lOIFsQNDy4 uPXqAQMXgV4d9P2FrLJlj7qnrghiXNQ= X-Proofpoint-ORIG-GUID: dI3WbY__MUexyid1s6vf22eQSY-_FqN4 X-Proofpoint-GUID: xq3D3o6fVDLyonlqKzYhHEjw9WGevlSR X-Authority-Analysis: v=2.4 cv=R6eWitRX c=1 sm=1 tr=0 ts=6b10608b cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=jvz0XqEJj1tBe20BJJ4A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA3MiBTYWx0ZWRfXy88o1uL+qfg9 G77vMelzzFx6imanRXRXTNwUnTXpq+Z4ypRfuJAftJOUFowUvnOS2qrQY1nmKlEIOoK1EWYEf1E J4Os++5hmqA5U2/36nn6oIqVbSvTFLW+OrnwelVJ6C7IOCZf+rnByww+1CM1SiJObcsg027twf5 1xw2udRGFK9MhPso1GSCIwOO6MJGv/+QsPpYdgZkPUQ8fJf9XBbDF2CJJvlC3ObLWfdFFVqGqhP esMS1Ccm8b6OhnjapIIqyY6cpeIWaFS24TEg+8x9RYZLwXOwDmaD7zR7CFw+hCvNOtuKXk80o/k /V/o+M58iYswrMRzYVY2gLsjNRv/tmvzHOzbGJXOe2byLEqooatwXENXpMDP/MbsfUbSumBAT98 IYiNrEQVbzJr1QkvGV+3ylrRUyAjZEryHoc0jIAP12TFWbZxS1/28QCS4JRDSQajKwg45UW+FtJ tZXxngio54sM5sYMCCQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_04,2026-12-02_07,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020072 The Guest State Buffer helpers map a guest state ID to a bitmap position with kvmppc_gse_flatten_iden(). For an ID that does not belong to any guest state class, it returns 0, which is also the valid position of KVMPPC_GSID_BLANK. Such an ID therefore silently aliases bit 0, and because ID 0 is the terminator of the kvmppc_gsbm_for_each() and kvmppc_gsp_for_each() iterators, a stray bit 0 makes them stop before visiting any other element. Nothing reports an error. I found this while debugging an L2 guest that failed to start under a nestedv2 L1 with trap = 0xffffffea (-EINVAL) and an all-zero vCPU state. The cause was a new guest state ID, defined by a change that is not in mainline, without a matching class. Setting the corresponding register marked bit 0 dirty in the vCPU message bitmap, the message iterator then stopped at once, and nothing was flushed to L0. These patches make the helpers fail visibly instead of aliasing bit 0 when an ID has no class, which is easy to hit when adding a new ID. - Patch 1 closes the only path by which an unclassified ID can arrive from L0: kvmppc_gse_parse() accepts a zero-length element with such an ID, because kvmppc_gsid_size() returns 0 for it. It now rejects the element with -EINVAL. - Patch 2 fixes the root cause. kvmppc_gse_flatten_iden() returns -1 instead of 0 for an unclassified ID, and its users handle that. This protects callers that pass IDs chosen by the kernel itself, such as when marking state dirty, where a missing class used to silently corrupt the bitmap. Those cases now warn once and do nothing. The warnings can only come from a kernel bug, because patch 1 filters IDs from L0 before they reach these helpers. That is also why patch 2 must be applied after patch 1. IDs defined in mainline today all have a class, so existing behaviour is unchanged. The series makes a missing class fail visibly instead of silently aliasing bit 0. Testing: with a nestedv2 L1 running under QEMU TCG as L0, the L2 guest fails with trap = 0xffffffea without this series. With it applied, the L2 guest boots and the new WARN_ON_ONCE() reports the ID that has no class. On a Power10 LPAR (PowerVM as L0), with the series applied on top of a mainline kernel, L2 guests boot and reboot normally. A kernel build run as a workload inside the KVM guest completed with no problems seen. Amit Machhiwal (2): KVM: PPC: Reject unknown guest state IDs in kvmppc_gse_parse() KVM: PPC: Don't map unclassified guest state IDs onto bit 0 arch/powerpc/kvm/guest-state-buffer.c | 51 ++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) base-commit: 693c2e04e3f1d4c59af236e1211b7b8cb165a790 -- 2.54.0 (Apple Git-157)