From nobody Mon Apr 13 14:10:51 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=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772802184; cv=none; d=zohomail.com; s=zohoarc; b=jz7w4Vn35DE/R5WjQlyCQRnWiSu2v2C5phpryoPBVH7ivWWOdx57O+PNsCQZjtVFWwSD8CVSagpEzmURr9d5oCppBXeMnRktdtJAKUxcGn5klhBQGa5btewYTxDitEBTq2cRxW8Ve6PKaTBkKj/Lom3bzaKYPMwFVTm2c2Mg7fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772802184; h=Content-Type: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=ZzINuPCWN3dXEmNZ7pvDXhK4zFfceWgBWNxPKCnclwk=; b=DtN9SDXl66tlnTLo8MigT9SDUSTP/Gm7kQ35hWwGcJirm8hZZhZKDE5wta6DZ0U60OD4Es5Rs/xptVuDipHwZUrFb6qbjO3y9WUeE/QUn2/XTQ6p16VEN20J2MLtv2UQPSZFKeUyHvkRIANSngapdv3xClT2buSd4TttK1LPK9A= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772802184302535.0117214845835; Fri, 6 Mar 2026 05:03:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyUok-0001P4-FN; Fri, 06 Mar 2026 08:02:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyUob-0001Hv-Ty for qemu-devel@nongnu.org; Fri, 06 Mar 2026 08:02:02 -0500 Received: from p-west2-cluster2-host2-snip4-2.eps.apple.com ([57.103.68.195] helo=outbound.mr.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyUoZ-00077s-Rr for qemu-devel@nongnu.org; Fri, 06 Mar 2026 08:02:01 -0500 Received: from outbound.mr.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-2a-10-percent-1 (Postfix) with ESMTPS id 222D11804C48; Fri, 6 Mar 2026 13:01:54 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.152.38]) by p00-icloudmta-asmtp-us-west-2a-10-percent-1 (Postfix) with ESMTPSA id 3CC3F1802E76; Fri, 6 Mar 2026 13:01:39 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772802118; x=1775394118; bh=ZzINuPCWN3dXEmNZ7pvDXhK4zFfceWgBWNxPKCnclwk=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=ZzIOKpYzLZrt3nRD3Yy1m/b2lb5gw7RZMRWl5f2NQlW91erlByaDnXYTXdtr71CjWnedLF67XMhcqkuRY70PynvYZ5j0+NxpEWc89xyFXeZlYF3bfn8sNElnBnQ1/0TCIRWYalNrM1rkoj0IXlzM4pAC64Q8IVjOKAwiXairWq4M6MquVpsAqdA4Ps9paAuSi3YThYHyMjTxg82Ey/Yjs4gUPqlye+VlqZRuODxFi+wEqVIVw9+MgW+rNO2e3Zkvblz4kGE0+ANJIz9cU9QxRCsHiK+DuOe53RxPe6Aq+3S9LtWVNxwFLQjt5FsSIcpL/R9s9GIaFie1IWkFc2X0xA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Cameron Esfahani , Phil Dennis-Jordan , Alexander Graf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , qemu-arm@nongnu.org, Manos Pitsidianakis , Peter Maydell , Roman Bolshakov , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v15 11/17] hvf: gate ARM_FEATURE_PMU register emulation behind not being at EL2 Date: Fri, 6 Mar 2026 14:01:01 +0100 Message-ID: <20260306130107.35359-12-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306130107.35359-1-mohamed@unpredictable.fr> References: <20260306130107.35359-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=TsTrRTXh c=1 sm=1 tr=0 ts=69aad044 cx=c_apl:c_pps:t_out a=9OgfyREA4BUYbbCgc0Y0oA==:117 a=9OgfyREA4BUYbbCgc0Y0oA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=lOv7bB1OiAV5i3s2B4UA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDEyNSBTYWx0ZWRfX0wy2KPTX9NCv N9omPc2zRYmoVXTxyJXSrq/MnWrp/uQZMGIy+Din5R3MZjF2kGRntbP5+N/eHM2i+BOHyMg0K13 BGcx4e0xpWz6kS5SlZNn8ukKdEmEJleBGTUXJIaPnyFMFNdLUE6ubqhLMIpulvc4Di4F0aNq4G6 pYJ3n78J7W87ukNiKsHuMeB6blXqR4G5TEbDbgY0z4TQlu9ffpRfFoOyOkaPrcNONY1esZAe8dp eGFlE5MaaKOUkou4B+mCLfIt+paAkbnMZUxYMo3BIOcVqhnyEaiZKYGE7S0A5arHIzJYb6EyAw9 nfC17zlhS8ECsQkfMCZn/4leB3G/Z0+eranpnw+r8y5q2kn+bb2tqQszaZNFrk= X-Proofpoint-GUID: 6r0l6VkESvLr-XrvW3HBEKYEfvXAECRR X-Proofpoint-ORIG-GUID: 6r0l6VkESvLr-XrvW3HBEKYEfvXAECRR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_04,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 clxscore=1030 adultscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=752 bulkscore=0 malwarescore=0 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060125 X-JNJ: AAAAAAABfgeDZPP3tY4AhBQC/LefFHxLickTPiSneRwEWwShrKQzuhphhwTGcoCK7XCZbp3u3BiOSkBWpdsztdxerG+fhwJBNj0DVkf9W/FWD3A9D6C6A77HfwUbJ+gxmJTXVxcgnP/lXXdhlEjqnAewazOI5Im7fOvbZx63D4+O/CO1JkiLJqvme32Z8/nR8LGG1rAFbJW/je6//yBYwa4s1o64L8WOGr7px8fEmLZ7dD6KzlkzP91JjCzy5My/4R3dqTKX8dXASotJVWyPvsbz1jwum9bk13oCBZw/Phv4NJeFGLu9W7X/xFv6ZPEO9mpJcftvMPuf9JxyYYgHDkM4rAT+3QFMAnUxvOZe0lV6Gi8pA/haMvgtqKqE7KjbxUxqAG28VjY9mXOnz4/So0AR2T/CxLRteb+Q0xCJdkfW2jwibT35VCVcNA4J75UjkQpFehrZb1LYDJ4BRdJb8qvWwoVqNgM8hzq8th1WsNO17YL2j6C2IzjxFvR5RPmKQCJ5/XF5kpFqINTGmSNAYYN/6OFeGL8HM3vSBS1Vt4KvTRx6U/vsrAXXML+atM+z5BSvsGuVOt5FRPbpNSvWIoFbypyEVlP815E+UXeXqt+6q2ythMY26QkJeKFwFExuFReUSLPnAnujNER59v3JvSCWNmF56+6nEKU48cRWGN6wj99198UJ0Mn6SUyhIbAFEG2JQilqFHCad5AActjlpEvlteFi5gYS9plUGVHSurAYJqInQITFvsEANA0pWm+vlTAg9T6fxbYNcBPanOcPSA== 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.68.195; envelope-from=mohamed@unpredictable.fr; helo=outbound.mr.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772802185648158501 From Apple documentation: > When EL2 is disabled, PMU register accesses trigger "Trapped MSR, MRS, or > System Instruction" exceptions. When this happens, hv_vcpu_run()=E2=80=AF= returns, and the > =E2=80=AFhv_vcpu_exit_t=E2=80=AFobject contains the information about thi= s exception. > When EL2 is enabled, the handling of PMU register accesses is determined = by the PMUVer > field of ID_AA64DFR0_EL1=E2=80=AFregister. > If the PMUVer=E2=80=AFfield value is zero or is invalid, PMU register acc= esses generate "Undefined" > exceptions, which are sent to the guest. > If the PMUVer=E2=80=AFfield value is non-zero and valid, PMU register acc= esses are emulated by the framework. > The ID_AA64DFR0_EL1=E2=80=AFregister can be modified via hv_vcpu_set_sys_= reg=E2=80=AFAPI. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 8363e10eff..91bbb2013b 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1589,7 +1589,7 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t re= g, uint64_t *val) ARMCPU *arm_cpu =3D ARM_CPU(cpu); CPUARMState *env =3D &arm_cpu->env; =20 - if (arm_feature(env, ARM_FEATURE_PMU)) { + if (!hvf_nested_virt_enabled() && arm_feature(env, ARM_FEATURE_PMU)) { switch (reg) { case SYSREG_PMCR_EL0: *val =3D env->cp15.c9_pmcr; @@ -1850,7 +1850,7 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t r= eg, uint64_t val) SYSREG_OP2(reg), val); =20 - if (arm_feature(env, ARM_FEATURE_PMU)) { + if (!hvf_nested_virt_enabled() && arm_feature(env, ARM_FEATURE_PMU)) { switch (reg) { case SYSREG_PMCCNTR_EL0: pmu_op_start(env); --=20 2.50.1 (Apple Git-155)