From nobody Tue Aug 25 11:33:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1786554656; cv=none; d=zohomail.com; s=zohoarc; b=nRtcay507C5bbYDNXpQWBlvTN4bhsXVzs+HRJ+4Zl6p6Ba5tdWAu2CGEWPlqFmoGDEK3EwYZe0QGRlkbtoZZave5/M1rl1e0UDhpw2wIWRVzQ+fS+XkLHIDMj6jmwtGDNwX0+zzINvmSQq7BEz1cxDmDsail8K2V2QbEkuoD33k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786554656; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bKGQvy3K/R/OLvNJq73qPfskEnjdT256gSdKXG2HIwk=; b=aXTiA5R4xzvUONxq3gcnJvhY1TylXOXD/IBrk7lphYsPq03B5aZAwPesQ48cOHX/v99WV+xD8c1CV1091Npt282dpHUaOIaJpB3d1jii9C6PxIVfxNrLsVKpkEsSAoAGQaiJ3SVsE2dbGHLqfrj4LrPK5IN0sJLJNwI+7OAtqdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786554656009804.8059371798839; Wed, 12 Aug 2026 10:10:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wuCSN-0007Zr-3Q; Wed, 12 Aug 2026 13:09:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuCSI-0007Yu-Rn; Wed, 12 Aug 2026 13:09:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuCSF-0007Fa-Go; Wed, 12 Aug 2026 13:09:30 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67CH1ZUC3994359; Wed, 12 Aug 2026 17:09:19 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fwvp32ubv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Aug 2026 17:09:18 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 67CGuoVt006518; Wed, 12 Aug 2026 17:09:17 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4fxhfy6vw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Aug 2026 17:09:17 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 67CH9DDk12845354 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Aug 2026 17:09:13 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9BAAE20043; Wed, 12 Aug 2026 17:09:13 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0EDD2004D; Wed, 12 Aug 2026 17:09:10 +0000 (GMT) Received: from localhost.localdomain (unknown [9.39.26.117]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 12 Aug 2026 17:09:10 +0000 (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=bKGQvy3K/R/OLvNJq 73qPfskEnjdT256gSdKXG2HIwk=; b=FQ/j0q8Im18kYVJXIc1fpcYMLRDjvoD1f mZy1C7bBdcPWL+ENhXNxp4RcMeWKT1J9SJMal2S8JG+LFeQvlcO9BHW2n30jTWvz UPuppYw5ZmzCIxj+2AnBVOGfqI4T5y5XcxR6RfWHEhHelsRkTMJxS4IG1BhoZziT EnieAoZyHjdm6TJDRtuVQXqpXya0B0ik6CE0Acd0P3h8XzITQzs7dSnSWq6pMuUC 0r8vu1I3IqsQE9We9XX4NZkR7eHOuEihm7TslQ94Ujd4TGjAecnnHP9FxQlpTbCV kNyiV4nOZCkqZiV2IvrI8Q2TULl3aBqRptotxseUZz8cBCXleFvag== From: Amit Machhiwal To: qemu-ppc@nongnu.org, Harsh Prateek Bora Cc: Amit Machhiwal , Vaibhav Jain , BALATON Zoltan , Anushree Mathur , Nicholas Piggin , Chinmay Rath , Glenn Miles , Paolo Bonzini , kvm@vger.kernel.org, qemu-devel@nongnu.org, Gautam Menghani Subject: [PATCH v6 1/3] [DO_NOT_MERGE] linux-headers: Add uapi header changes Date: Wed, 12 Aug 2026 22:38:52 +0530 Message-ID: <20260812170854.58709-2-amachhiw@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260812170854.58709-1-amachhiw@linux.ibm.com> References: <20260812170854.58709-1-amachhiw@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=AMtp2X5w c=1 sm=1 tr=0 ts=6a7ca8be cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=MBz6HKjOuQBNVPZFXNsA:9 X-Proofpoint-GUID: HX299jUwSAbbP0ZEeBDz9GvT5WlG0-jY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODEyMDEzOCBTYWx0ZWRfXxEbXiZrmYaUW 2ycUBPx5EcLW+rEWTUX151iFE5jCQwBFWwG/r8ACPGbKoAg3lyNvGF+0jbB5ayqbcIYcxAjXumf /TaGjIOhlQychok2fyG+hBEGj5r+sYghWmxsjdLjYaFmQfhfoGB0MzB9DBw5SFUmIT8jx2PSGHY 7HMCo6JcTFH5GKPuuDNC39MCYf+9rUukPggHEWRbvcIpLSrJa9p5OaNkO3RzKGzMA9g+GivAgD7 8GSk7ONePp+Zz8O80jzjgQ7FcqAjmgOwkeMswfoxQD9h2qRrf0zfATYETvLPSpqgzZ4wzdsqgv7 OzalXQ3LMrlpvr57ETZUaO741HhIWK6UH1OhiDjDHaz4Qq42o8KO4xhOtAxjEM1RdLXkQ8BTtR1 iVij8H8C0rCTWF2QrGqnNRlHxxmTtHfuaitbPPeMyYuA4QefHLWD9nMYGRwahSbO24nrDBSB8QG s+UaziENhVtXgmORJ1w== X-Proofpoint-ORIG-GUID: 3Tuc2kv3Z26UeQlcl1VOfo2fbaWuYnWW X-Proofpoint-Spam-Info: AW1haW4tMjYwODEyMDEzOCBTYWx0ZWRfX8PNlPXgIKlja JsSvJYY9RXkw0DHLYbQb+8JJzRYb/hVHu4SEcRxWBuQPUDKSjzMl97X5e8eUdKOkFxmcg3KoUkG Mo3X4nYAXDXyq9+CUbbtq43JQDGa84w= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-12_05,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 phishscore=0 spamscore=0 bulkscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608120138 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=amachhiw@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1786554656874158500 Content-Type: text/plain; charset="utf-8" This is a temporary patch intended for review and testing purposes only. It syncs the QEMU linux-headers with the kernel v9 changes that introduce the KVM_PPC_GET_COMPAT_CAPS ioctl for querying host CPU compatibility capabilities. The struct kvm_ppc_compat_caps places 'size' as the first field as required by copy_struct_from/to_user() versioning, with KVM_PPC_COMPAT_CAPS_SIZE_VER0 (24) defined as the frozen version-floor constant. The capability number is KVM_CAP_PPC_COMPAT_CAPS (250) and the ioctl is defined as _IO so the ioctl number remains stable if the struct grows in future versions. Capability bit definitions for POWER9, POWER10, and POWER11 compatibility modes are also included. The actual header sync will be done via scripts/update-linux-headers.sh once the kernel changes [1] are merged upstream. [1] https://lore.kernel.org/all/20260808161148.66673-1-amachhiw@linux.ibm.c= om/ Tested-by: Gautam Menghani Reviewed-by: Gautam Menghani Tested-by: Anushree Mathur Signed-off-by: Amit Machhiwal --- No changes in this version. linux-headers/asm-powerpc/kvm.h | 19 +++++++++++++++++++ linux-headers/linux/kvm.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.h index 077c5437f521..2c229fe0562c 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -437,6 +437,25 @@ struct kvm_ppc_cpu_char { __u64 behaviour_mask; /* valid bits in behaviour */ }; =20 +/* For KVM_PPC_GET_COMPAT_CAPS */ +struct kvm_ppc_compat_caps { + __u64 size; /* Size of this structure */ + __u64 flags; /* Reserved for future use */ + __u64 compat_capabilities; /* Capabilities supported by the host */ +}; +#define KVM_PPC_COMPAT_CAPS_SIZE_VER0 24 /* sizeof first published struct = */ + +/* + * Capability bits for compat_capabilities field in kvm_ppc_compat_caps. + * These bits indicate which processor compatibility modes are supported. + */ +#define KVM_PPC_COMPAT_CAP_POWER9 (1ULL << 62) +#define KVM_PPC_COMPAT_CAP_POWER10 (1ULL << 61) +#define KVM_PPC_COMPAT_CAP_POWER11 (1ULL << 60) +#define KVM_PPC_COMPAT_BITMASK (KVM_PPC_COMPAT_CAP_POWER9 | \ + KVM_PPC_COMPAT_CAP_POWER10 | \ + KVM_PPC_COMPAT_CAP_POWER11) + /* * Values for character and character_mask. * These are identical to the values used by H_GET_CPU_CHARACTERISTICS. diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index dd52e2a65bfd..aea4ab5c6953 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -986,6 +986,7 @@ struct kvm_enable_cap { #define KVM_CAP_S390_KEYOP 247 #define KVM_CAP_S390_VSIE_ESAMODE 248 #define KVM_CAP_S390_HPAGE_2G 249 +#define KVM_CAP_PPC_COMPAT_CAPS 250 =20 struct kvm_irq_routing_irqchip { __u32 irqchip; @@ -1330,6 +1331,8 @@ struct kvm_s390_keyop { /* Available with KVM_CAP_COUNTER_OFFSET */ #define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO, 0xb5, struct kvm_arm_count= er_offset) #define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO, 0xb6, struct reg_mask_= range) +/* Available with KVM_CAP_PPC_COMPAT_CAPS */ +#define KVM_PPC_GET_COMPAT_CAPS _IO(KVMIO, 0xb8) =20 /* ioctl for vm fd */ #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) --=20 2.50.1 (Apple Git-155) From nobody Tue Aug 25 11:33:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1786554655; cv=none; d=zohomail.com; s=zohoarc; b=jeDR8uEDA5acIJTwIwUlA3EmgnOBaM4OsVHJOGrzOW1PvqzXQwc4kcQTowLjiNZ2Hg+XB3fRWVL/5LSV5pxcNbw/LCgeXJD/AxiFwXqQHU1+owvPDFQI1o73lCaDWSPAw4Ex5iVubsF2Bz7qLECLYqwugtKRc1LLOngw2oGf6cE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786554655; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/aPAVC/8dDH0mnpSiaHDSqAaFMg2mEKE4CDE5oWOwoA=; b=bbXcz9U05c9wj5Oby8ilaZ0ELXj13cxtqcUyYmAHVcVDDrkt5Pg+RLBUoEBkTlCwUxr+bmWEz6/Bg1kEClcB+TdE9Dx3eb8UCyMy5gpBlWpt9jzj+EE57ZbCRB7lBGUfJBOst4xom8G+IO/OjAhZQICLTzd+6///Hj8gw7Nt/fk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786554655678486.91844788001276; Wed, 12 Aug 2026 10:10:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wuCSW-0007az-1z; Wed, 12 Aug 2026 13:09:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuCSK-0007Z9-FC; Wed, 12 Aug 2026 13:09:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuCSG-0007Ft-MO; Wed, 12 Aug 2026 13:09:32 -0400 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 67CH1ZKF4040803; Wed, 12 Aug 2026 17:09:24 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fwvq9kn57-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Aug 2026 17:09:23 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 67CGumKJ021450; Wed, 12 Aug 2026 17:09:22 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fxf5w772x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Aug 2026 17:09:22 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 67CH9Inb51380546 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Aug 2026 17:09:18 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0CF402004D; Wed, 12 Aug 2026 17:09:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16B5020040; Wed, 12 Aug 2026 17:09:15 +0000 (GMT) Received: from localhost.localdomain (unknown [9.39.26.117]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 12 Aug 2026 17:09:14 +0000 (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=/aPAVC/8dDH0mnpSi aHDSqAaFMg2mEKE4CDE5oWOwoA=; b=R+9S0FCv0wsADGr6RLo+9ah+TLg1s0zNf E9S7s1JsiiHaP1DKew/bi7b0o1zjyduAxmMPzfbYHV3ei76aNgc7tlh1t0QdwIb0 dD9Ewrt8GWbUyS+GsjLQ2DEABprtlytKBeAB1N5/JL/2N9eNFj9zpvZ5n9kW5aIL y3eDlniTbJcoSANAdJ7yjVl/POLvn+mYdDp5QsVx+zVrZbVtgiZrksZO0eFRPCaH ERJ1IuqtBhdlEb3QUlz08S9K2qj7sMWCj0LOiAqfl+qehq5kZLt+U/R1SiK58F+y A0C0eUQz4HALD94HvMTyn6GfSVokndVP86paXk5crkHPkcHph9VWw== From: Amit Machhiwal To: qemu-ppc@nongnu.org, Harsh Prateek Bora Cc: Amit Machhiwal , Vaibhav Jain , BALATON Zoltan , Anushree Mathur , Nicholas Piggin , Chinmay Rath , Glenn Miles , Paolo Bonzini , kvm@vger.kernel.org, qemu-devel@nongnu.org, Gautam Menghani Subject: [PATCH v6 2/3] target/ppc/kvm: Add support for querying host compatibility mode Date: Wed, 12 Aug 2026 22:38:53 +0530 Message-ID: <20260812170854.58709-3-amachhiw@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260812170854.58709-1-amachhiw@linux.ibm.com> References: <20260812170854.58709-1-amachhiw@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: 7lx6V9T1h6uHzN_d2LEYH7P3LyHF65G1 X-Authority-Analysis: v=2.4 cv=PbDPQChd c=1 sm=1 tr=0 ts=6a7ca8c3 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=R_9d5M2Ok3QZz6TfjUMA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODEyMDEzOCBTYWx0ZWRfX3ji5stUKpfNd v9NG4C82YjHkPbjPqj+6PILBwcRr+nSxbXhkd/tF5fQ/QFsdkzIMfpSb19od/dPV32G1CdBxluX teWpUCzf7Erw8PAAuxc7Q7ERoiTpoqsVEfo2WTF5qyrOANCgzyXME+eIF63PgFywzZwIYgJh8Gj LMfWoaAbl3+woR8sz558AywfH87w/olMd41oJRH4r2sW0IHX/6R6Uzn/8ad2vEi5thr6W9hQ5EY laMOYawSLU+dDMzayn3RBTCqnz0dAe/ctb9vK1rqAX+etdZfZaDbrrRWfWWshSFFdwvhyhXleM4 oBs2Rzkb+4T8Kn0kAm/ffu8rXFDWX3W5XaMlXFMr4Rr6qufL0ezT02C9DxMuWduhwetvMPPEd5y eMsxh1fVUSD3ssXLTRHh1WjmT7cyBRbgjX5tJ7SIjSG7ouXQBaYJGoUaluVpWC34Pe4MCkUeOt1 +msr3Gr7kxXBPGLAsJQ== X-Proofpoint-ORIG-GUID: 2S6FJDLOQnjTGDvozDkYB3ySgYPVO9w7 X-Proofpoint-Spam-Info: AW1haW4tMjYwODEyMDEzOCBTYWx0ZWRfX1C5UP3y2HmDd qIrNRSsvCRjXJetN/DZuOqkIh70K6qWnn8jGa71HAFZsPVubu28BBo96EMU2D4w9nJGwVlblSSS U+sv6CruQg0EuwxrhOJYVr7EXChl9Ic= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-12_05,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608120138 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=amachhiw@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1786554656909158500 Content-Type: text/plain; charset="utf-8" Add infrastructure to query the host CPU compatibility mode via the KVM_PPC_GET_COMPAT_CAPS ioctl. This allows QEMU to determine if the host is running in a compatibility mode (e.g., a Power11 processor operating in Power10 compatibility mode). The kvmppc_get_compat_caps() function issues the ioctl and returns the compat_capabilities bitmap. The kvm_ppc_host_compat_pvr() function derives the effective PVR from the bitmap using ctz64() to find the lowest set bit (highest supported compat level in IBM MSB-0 numbering). The struct kvm_ppc_compat_caps places 'size' first and userspace sets it to sizeof(struct kvm_ppc_compat_caps) before calling the ioctl. The kernel uses copy_struct_from/to_user() to handle forward and backward ABI compatibility: an older userspace with a smaller struct gets trailing fields zero-padded. When newer userspace passes a larger struct to an older kernel (usize > ksize), the kernel unconditionally returns -E2BIG and writes its own ksize back into host_compat.size. QEMU detects this, validates the returned size against KVM_PPC_COMPAT_CAPS_SIZE_VER0, and retries with that size. Additionally, cas_check_pvr() in hw/ppc/spapr_hcall.c is updated to prevent fallback to raw mode when the host is running in compatibility mode. This ensures that nested guests cannot exceed the host's compatibility level. The call is guarded with kvm_enabled() since kvm_ppc_host_compat_pvr() invokes kvm_vm_ioctl() which dereferences kvm_state; without the guard, a TCG guest on a CONFIG_KVM=3Dy binary would segfault. If the capability is not supported or the query fails, the functions return 0, allowing fallback to existing behavior. Tested-by: Gautam Menghani Reviewed-by: Gautam Menghani Tested-by: Anushree Mathur Signed-off-by: Amit Machhiwal --- No changes in this version. hw/ppc/spapr_hcall.c | 14 +++++++++ target/ppc/kvm.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ target/ppc/kvm_ppc.h | 7 +++++ 3 files changed, 96 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 23bcd788daf6..708902934cff 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1136,6 +1136,7 @@ static uint32_t cas_check_pvr(PowerPCCPU *cpu, uint32= _t max_compat, { bool explicit_match =3D false; /* Matched the CPU's real PVR */ uint32_t best_compat =3D 0; + uint32_t compat_host_pvr =3D 0; int i; =20 /* @@ -1163,6 +1164,19 @@ static uint32_t cas_check_pvr(PowerPCCPU *cpu, uint3= 2_t max_compat, } } =20 + if (explicit_match && kvm_enabled()) { + compat_host_pvr =3D kvm_ppc_host_compat_pvr(); + /* + * If the host is booted in a compatibility mode, do not try booti= ng in + * the raw mode as it may allow KVM guests to boot with a higher C= PU + * version compared to what host was booted with; which should not= be + * allowed. + */ + if (compat_host_pvr) { + explicit_match =3D false; + } + } + *raw_mode_supported =3D explicit_match; =20 /* Parsing finished */ diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 116b39a00f4e..d4c5601a00c4 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2602,6 +2602,81 @@ bool kvmppc_supports_ail_3(void) return cap_ail_mode_3; } =20 +#if defined(TARGET_PPC64) +static target_ulong kvmppc_get_compat_caps(void) +{ + struct kvm_ppc_compat_caps host_compat; + int ret; + + if (!kvm_check_extension(kvm_state, KVM_CAP_PPC_COMPAT_CAPS)) { + return 0; + } + + /* + * Set size to sizeof(struct kvm_ppc_compat_caps) so the kernel applies + * copy_struct_from/to_user() versioning. size must be >=3D VER0. + */ + memset(&host_compat, 0, sizeof(host_compat)); + host_compat.size =3D sizeof(host_compat); + + ret =3D kvm_vm_ioctl(kvm_state, KVM_PPC_GET_COMPAT_CAPS, &host_compat); + if (ret =3D=3D -E2BIG && host_compat.size >=3D KVM_PPC_COMPAT_CAPS_SIZ= E_VER0) { + /* + * Kernel is older and knows only a smaller struct version. It + * wrote back its ksize into host_compat.size. Retry with that + * size so the kernel accepts the call. + * + * When a VER1 struct is introduced, add a check here: + * if (host_compat.size >=3D KVM_PPC_COMPAT_CAPS_SIZE_VER1) { ..= . } + */ + uint64_t ksize =3D host_compat.size; + memset(&host_compat, 0, sizeof(host_compat)); + host_compat.size =3D ksize; + ret =3D kvm_vm_ioctl(kvm_state, KVM_PPC_GET_COMPAT_CAPS, &host_com= pat); + } + + if (ret < 0) { + error_report("KVM: failed to get host CPU compat capabilities: %s", + strerror(-ret)); + return 0; + } + + return host_compat.compat_capabilities & KVM_PPC_COMPAT_BITMASK; +} + +/* + * Return the effective host PVR based on the CPU compatibility mode + * reported by KVM. Returns 0 if no compat mode is active or the + * capability is not supported, in which case the caller falls back + * to the raw hardware PVR. + */ +uint32_t kvm_ppc_host_compat_pvr(void) +{ + uint32_t compat_host_pvr =3D 0; + uint64_t cap_idx =3D 0; + target_ulong host_caps =3D kvmppc_get_compat_caps(); + + if (host_caps) { + cap_idx =3D 1ULL << ctz64(host_caps); + switch (cap_idx) { + case KVM_PPC_COMPAT_CAP_POWER9: + compat_host_pvr =3D CPU_POWERPC_POWER9_DD22; + break; + case KVM_PPC_COMPAT_CAP_POWER10: + compat_host_pvr =3D CPU_POWERPC_POWER10_DD20; + break; + case KVM_PPC_COMPAT_CAP_POWER11: + compat_host_pvr =3D CPU_POWERPC_POWER11_DD20; + break; + default: + break; + } + } + + return compat_host_pvr; +} +#endif /* TARGET_PPC64 */ + PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) { uint32_t host_pvr =3D mfpvr(); diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 742881231e16..195dbaac5e17 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -81,6 +81,8 @@ bool kvmppc_supports_ail_3(void); int kvmppc_enable_hwrng(void); int kvmppc_put_books_sregs(PowerPCCPU *cpu); PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); + +uint32_t kvm_ppc_host_compat_pvr(void); void kvmppc_check_papr_resize_hpt(Error **errp); int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shi= ft); int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shif= t); @@ -440,6 +442,11 @@ static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_cl= ass(void) return NULL; } =20 +static inline uint32_t kvm_ppc_host_compat_pvr(void) +{ + return 0; +} + static inline void kvmppc_check_papr_resize_hpt(Error **errp) { } --=20 2.50.1 (Apple Git-155) From nobody Tue Aug 25 11:33:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1786554628; cv=none; d=zohomail.com; s=zohoarc; b=NGvytH56E2+B+lotlvhBfWVyV41uJIP1J1jxKNxT5Aw5Trd89xC2TNrqy7RUMDpN43i2PJMg5OfTohXnXOfSlzARqQPoZOTvQDqYLUndfblvSWhydU5XXzvhFuQDAfcQpQ9MGgDla8ZC7scN8Y+WbPDAEaxLgy7Yhe/EHaHR5Pc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786554628; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/T0WS4SIkRcrSpUP38rfnpqeUflQc+kavwNr8Od2Nz0=; b=YmziXtuiU4WXEpTztwhLApF9+e9gaFFGLPN4kMR8YTGHrpLKRUMnzGknceVi0HkT0RPRsaN+0tzdawTveiKvF8uO+Sw08qhUhzGqVZVwWKB0q/1IHqAElBL4Icw6PFq7jqAOWDn4JDZVDj8/GQAfh5yN9EfbyrCe/0beMrh+YxI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786554628062136.66867206013296; Wed, 12 Aug 2026 10:10:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wuCSY-0007bk-Gy; Wed, 12 Aug 2026 13:09:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuCSK-0007ZA-GH; Wed, 12 Aug 2026 13:09:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wuCSI-0007GR-Uj; Wed, 12 Aug 2026 13:09:32 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67CH1gc14120485; Wed, 12 Aug 2026 17:09:28 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fwvnwau7p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Aug 2026 17:09:27 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 67CGuiXW021425; Wed, 12 Aug 2026 17:09:27 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fxf5w7737-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Aug 2026 17:09:26 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 67CH9M7L39780808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Aug 2026 17:09:23 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA3D22004B; Wed, 12 Aug 2026 17:09:22 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C71AC20043; Wed, 12 Aug 2026 17:09:19 +0000 (GMT) Received: from localhost.localdomain (unknown [9.39.26.117]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 12 Aug 2026 17:09:19 +0000 (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=/T0WS4SIkRcrSpUP3 8rfnpqeUflQc+kavwNr8Od2Nz0=; b=pZPthJsTxBsHvjvlLdEwhla1ZjYw+WQcc BfPXOKTn/BdpkK7mh1ixZkLk8Gx6vkm4QtN/YFeHckJgXWNy86pr5yfP9X9/64m7 H2uvpWGPIcjbLr6dYXIohMBCK8K/88VSn01Oja7cU4lh9IFswK2HAN8AkzlG0t1v bAxd1nc6q2Laf223qG8qCwH6efvJmPvadTiNbR75NiOxfI0j1/u3gEctWKG1DOZM 05Rn4NYAsQTJfSzLY+A6suQlP6+qWARtqd2tqPVUhpZVvrJYZC5SHOfVNDaA8vG1 l2UJucgMYTFKrgGsHLzjsJ6Vxfwdbyq5LKuKQncU91uY9cDvtbExA== From: Amit Machhiwal To: qemu-ppc@nongnu.org, Harsh Prateek Bora Cc: Amit Machhiwal , Vaibhav Jain , BALATON Zoltan , Anushree Mathur , Nicholas Piggin , Chinmay Rath , Glenn Miles , Paolo Bonzini , kvm@vger.kernel.org, qemu-devel@nongnu.org, Gautam Menghani Subject: [PATCH v6 3/3] target/ppc/kvm: Use host compatibility mode for nested guests Date: Wed, 12 Aug 2026 22:38:54 +0530 Message-ID: <20260812170854.58709-4-amachhiw@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260812170854.58709-1-amachhiw@linux.ibm.com> References: <20260812170854.58709-1-amachhiw@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=RsP16imK c=1 sm=1 tr=0 ts=6a7ca8c7 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=Me7h5qUP0d1xqhSAURgA:9 X-Proofpoint-GUID: POFFskJEaacGD-eMMRNz_daIFFDQU6lS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODEyMDEzOCBTYWx0ZWRfX3xWsDl1nBKkO Jk4eT2mcHqrxW1rI89QcBmxYpl6h98fjI5MsuG7LExf6LrvM2k3OubRzeFtGlLrSmycgjcf7OV+ gWjjk/6RCCsIiLlWhgTEXI2EgL3Q+X0esmFwKr0CF2jO3MVAqVKI8CaXuiF/IiIGJGbhVtYEJTd mcMFPUooYBTy+x1IRGYPhNunzYflxHNu6EXjJKZMSeU9J7hVVIpIFzQa/Fj0DQuAa1mcHhpxY9d zu5vEdTukDloFZpDj8iAin5jeYwRXL+BECmZhAoI6Tk24c0aTKO3KLlfG92mfgEB6EROQa5N0O0 8yGnQKRiS5rLmYLb0RdK/WyeI1X8Ex7lvcjFF0hBAEVmSuuNyyRbTNm0yTNzzE2rp0ivLIqJNjw Dvuiv4ut9WZVjI1cC31wg55As/fYnCz+pDckqxxyLHomGf3zyEH+DaMLY0P2qEiLalz7nj3GuQT wLxw2ui3Y9hVRp/pK7w== X-Proofpoint-ORIG-GUID: 7rrctBy4iANJzvQ_y_zWgh8zsvcpYO83 X-Proofpoint-Spam-Info: AW1haW4tMjYwODEyMDEzOCBTYWx0ZWRfX2cC9uLqWgZKp suKLq+2e7O3nu7iM5airvENgl7bBbDYVIvVroTa3R39eyzhv6AVnC3o82mqYYdcH8G+yyfSLoqm SngjPvPQ3JfVygh1xDYXImpZQ1jErh4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-12_05,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 suspectscore=0 clxscore=1015 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608120138 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=amachhiw@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1786554628896158500 Content-Type: text/plain; charset="utf-8" On POWER systems, the host CPU may run in a compatibility mode (e.g., a Power11 processor operating in Power10 compatibility mode). When running nested KVM guests, QEMU currently derives the host CPU type using mfpvr(), which reflects the physical processor version. This can result in a mismatch between the CPU model used by QEMU and the compatibility mode enforced by the host, leading to guest boot failures such as "KVM-NESTEDv2: couldn't set guest wide elements". Update kvm_ppc_get_host_cpu_class() to check if the host is running in a compatibility mode using kvm_ppc_host_compat_pvr(). When available, use the compatibility PVR instead of the raw hardware PVR when selecting the CPU model. This ensures that QEMU selects a CPU model consistent with the host compatibility mode, allowing nested guests to boot correctly. The guard uses #if defined(TARGET_PPC64) to prevent build breakage on ppc32 targets where the POWER9/10/11 PVR constants are not defined. Tested-by: Gautam Menghani Reviewed-by: Gautam Menghani Tested-by: Anushree Mathur Signed-off-by: Amit Machhiwal --- Changes in this version: - Drop redundant #ifndef CONFIG_KVM / #error guard; kvm.c is only compiled when CONFIG_KVM is set (enforced by meson.build), so the check can never fire [BALATON] target/ppc/kvm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index d4c5601a00c4..8e89a6c665c8 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2682,6 +2682,15 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) uint32_t host_pvr =3D mfpvr(); PowerPCCPUClass *pvr_pcc; =20 +#if defined(TARGET_PPC64) + uint32_t compat_host_pvr; + + compat_host_pvr =3D kvm_ppc_host_compat_pvr(); + if (compat_host_pvr) { + host_pvr =3D compat_host_pvr; + } +#endif /* TARGET_PPC64 */ + pvr_pcc =3D ppc_cpu_class_by_pvr(host_pvr); if (pvr_pcc =3D=3D NULL) { pvr_pcc =3D ppc_cpu_class_by_pvr_mask(host_pvr); --=20 2.50.1 (Apple Git-155)