From nobody Tue Apr 7 05:45:11 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=1773666501; cv=none; d=zohomail.com; s=zohoarc; b=ad7n+wSB0KowW9Kmkj6WYcAGoLVCsZ1p1u4UmBD4b0c+KHhlqj6bPm/MZpoAP7cYLZGh3qj7/+Zp/fYY/yHPFLNVxFgjuCjlGRsaXubeCWo12wmBbmhZtzCXWQ/WNgypa/9wy2fxN1nrVbtmYiIMMkcqSP5fVJVb23NMEJJdOAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773666501; 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=l8qCNixKWDIs4ZFboe/DCvI7wmuqMQTueO3DjdZQkLw=; b=DmKliog9BWlvFvr9tRDQD6BlAx+C9b6QQ5N/xXz2xFcall5zsASQJKhUkj7W951LOeSdTRSimm/Bgnin5Aldabz5EruIwYnk4Dochnrt1j8mmxWXH5Ikj0ZTBcdqub3EEYKVSYoqzgS4jZYmqfRFaz2/UHGxyocCDsQe7cbZtw0= 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 1773666501214195.4715717074066; Mon, 16 Mar 2026 06:08:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w27fZ-0000ud-4G; Mon, 16 Mar 2026 09:07:41 -0400 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 1w27fX-0000tX-Et for qemu-devel@nongnu.org; Mon, 16 Mar 2026 09:07:39 -0400 Received: from p-west1-cluster3-host2-snip4-1.eps.apple.com ([57.103.66.104] helo=outbound.pv.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w27fV-0003cj-UZ for qemu-devel@nongnu.org; Mon, 16 Mar 2026 09:07:39 -0400 Received: from outbound.pv.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-1a-100-percent-3 (Postfix) with ESMTPS id A2C1D1803D2F; Mon, 16 Mar 2026 13:07:35 +0000 (UTC) Received: from localhost.localdomain (unknown [17.56.9.36]) by p00-icloudmta-asmtp-us-west-1a-100-percent-3 (Postfix) with ESMTPSA id BD47D180011E; Mon, 16 Mar 2026 13:07:05 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1773666456; x=1776258456; bh=l8qCNixKWDIs4ZFboe/DCvI7wmuqMQTueO3DjdZQkLw=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=dXuhxCbZTGGtYFib3x2EWp05Lky+0Ev7gEpG7B8bGRUSlV+NnjFN5uSUyzTPWY6pJjxg0YVQnJ59ROYJir3xHDp/Q2lXfCw5ndfZciDyMzQrYFGX29LdFES8qdPlDwyybHfFh2qd3gAueCjY7A3UMcGU+EvrAi5tYSn1pB4sg0CPpFLBZliFjDrcn5KaK4c7oWXzkRlFTttMuRTQaWhT2DQRmIJoVpHinx9eqhfe6ItZAIY/c2qmXIR2vC+HG4hSluTE+KgJfL5y/HjFn9WqAZjS/MFK7jAf4KhUwUmJ5j6pBuroxXPrAQj3VT5LhZCfxn/writ+MvTjh2J3BWpR1Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Yanan Wang , Zhao Liu , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , Alexander Graf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Eduardo Habkost , Phil Dennis-Jordan , Mohamed Mediouni Subject: [PATCH v20 07/15] hvf: gate ARM_FEATURE_PMU register emulation when using the Apple vGIC Date: Mon, 16 Mar 2026 14:06:34 +0100 Message-ID: <20260316130642.13246-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260316130642.13246-1-mohamed@unpredictable.fr> References: <20260316130642.13246-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=IKcPywvG c=1 sm=1 tr=0 ts=69b80097 cx=c_apl:c_pps:t_out a=azHRBMxVc17uSn+fyuI/eg==:117 a=azHRBMxVc17uSn+fyuI/eg==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=lOv7bB1OiAV5i3s2B4UA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: aToITCRq3HGFIFwgm3nwzwgiHit4I4Z9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzE2MDA5NyBTYWx0ZWRfX43jAek4vTSVN qdDz2SkQyO2xsibe3OsgH2++7IUYGGapBJ3d84o3zwRmla4/ZIAkZ7bg8qn9miABPG4Iio/Wb4p yxHSPAF+/0E6kqLLj03PQKp6SM/+ZYOmy9U0FolM5/yWkn1PB2SQsdimwlDD+7iw92jLLro3u2a 8dA672mUJ+E5f/1i2WevZNRJDDNZSPbWybAvib13SQ7z5Q6r4hMWTcxgYMVvxUNBVQT7GREvyUy LzDT40flYXTa0IRJY8bwZ2hnRyH/xoVyeQVMg2fVoi1JAcKFVRqU42zWz0hN0OLZffyfN8/bJ80 W1dgV9VXCQ1E5ipewjq5RQ6bS68oxmmJPA2plhFZx52KYET8fEGBi45xTPqOSk= X-Proofpoint-GUID: aToITCRq3HGFIFwgm3nwzwgiHit4I4Z9 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-16_04,2026-03-16_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=928 mlxscore=0 lowpriorityscore=0 clxscore=1030 malwarescore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603160097 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.66.104; envelope-from=mohamed@unpredictable.fr; helo=outbound.pv.icloud.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, 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: 1773666506227158500 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. However, despite what that documentation says this is actually gated on usi= ng the Apple vGIC instead of nested virtualisation per se. Apple introduced both at the same = time. Signed-off-by: Mohamed Mediouni --- 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 04c4106a3e..c971aa8cce 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1601,7 +1601,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_irqchip_in_kernel() && arm_feature(env, ARM_FEATURE_PMU)) { switch (reg) { case SYSREG_PMCR_EL0: *val =3D env->cp15.c9_pmcr; @@ -1862,7 +1862,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_irqchip_in_kernel() && arm_feature(env, ARM_FEATURE_PMU)) { switch (reg) { case SYSREG_PMCCNTR_EL0: pmu_op_start(env); --=20 2.50.1 (Apple Git-155)