Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23F98C87FCD for ; Fri, 25 Jul 2025 08:36:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufDtb-0005xo-2v; Fri, 25 Jul 2025 04:35:15 -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 1ufDtP-0005pG-VQ for qemu-devel@nongnu.org; Fri, 25 Jul 2025 04:35:04 -0400 Received: from p-west3-cluster1-host8-snip4-5.eps.apple.com ([57.103.73.206] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufDtN-0003QL-JV for qemu-devel@nongnu.org; Fri, 25 Jul 2025 04:35:03 -0400 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-100-percent-2 (Postfix) with ESMTPS id 6FCF81800161; Fri, 25 Jul 2025 08:34:59 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=o7HSavF17IoPSUVxM9m4KStfJoakR87pLkUftbbgFiA=; h=From:To:Subject:Date:Message-Id:MIME-Version:x-icloud-hme; b=QVVkkIrdF215wdvycl/0nU5Azve6w51rslw2ljsH0uQBc3OEENJnsR6Si6v57x+BYYNi1yNSotu9YRd0bAsguzvqkY8kSY5VTxuxLReX/zDa5PkR+d9hmauC3f3hULp9EnnEsuxPs6B+PdJHBbxeeVBDLE5wRjBlBri34eCn2fufKxrsvEARg+NWNzOi7kk6P+MRG2S26ep9Ss5b+6QLx3WOc/wIdi2CONnuP46Yb64vDd8g5czxIDVgI8ah4YKN+EIK73ZbjI59JSovZUCFKOX9gjo8w/4UsFOXAuoJ4npUn2yihyEbxTjtHjg41LW1048r2UL+RJTSoNrkWZGK9Q== X-Client-IP: 46.189.47.18 Received: from localhost.localdomain (ms-asmtp-me-k8s.p00.prod.me.com [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-100-percent-2 (Postfix) with ESMTPSA id 95AAB1800303; Fri, 25 Jul 2025 08:34:56 +0000 (UTC) From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Igor Mammedov , Mads Ynddal , Alexander Graf , Shannon Zhao , "Michael S. Tsirkin" , Peter Maydell , Cameron Esfahani , Roman Bolshakov , Phil Dennis-Jordan , qemu-arm@nongnu.org, Ani Sinha , Mohamed Mediouni Subject: [PATCH 7/9] target/arm: hvf: pass through CNTHCTL_EL2 and MDCCINT_EL1 Date: Fri, 25 Jul 2025 10:34:29 +0200 Message-Id: <20250725083431.91450-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250725083431.91450-1-mohamed@unpredictable.fr> References: <20250725083431.91450-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: FqefFVQXjgc6OO6PEUQJyYdW1_z9fDyO X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzI1MDA3MiBTYWx0ZWRfX0QzzsoTLnmnW OvV4AFvag2NQqc59LA02SUbKVdZ9/tK/MuG7d8a9CsoVAW/TBIq48JTy0UsM2jL3XvGudNY4NYS JJO72mPcjQ9LvjIoZ7N83j5RqzIcvNOVVdC10tQLLgh2iAOVmNyR8FypVjPFmCHQkpVw6M+saPT kiC6Iyyy0+Kx2b8o+l0mQYXbYZwCFuQgnoJzJLp25bL/Fe+Tet1vKEZYcAOEgQWz2H/H6jqaeqF U2IhLdBMVXvD1vsIk3HHHNPwBP6g9uQkIpon7YaZifUUakP1p8+I3B35JJgwp8dnPziVtiKq8= X-Proofpoint-ORIG-GUID: FqefFVQXjgc6OO6PEUQJyYdW1_z9fDyO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-25_02,2025-07-24_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1030 bulkscore=0 mlxlogscore=770 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2507250072 Received-SPF: pass client-ip=57.103.73.206; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org HVF traps accesses to CNTHCTL_EL2. For nested guests, HVF traps accesses to MDCCINT_EL1. Pass through those accesses to the Hypervisor.framework library. Signed-off-by: Mohamed Mediouni --- target/arm/hvf/hvf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index c32e6ab289..5344e23db1 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -21,6 +21,7 @@ #include "cpregs.h" #include "cpu-sysregs.h" +#include #include #include "system/address-spaces.h" @@ -296,6 +297,10 @@ void hvf_arm_init_debug(void) #define SYSREG_DBGWVR15_EL1 SYSREG(2, 0, 0, 15, 6) #define SYSREG_DBGWCR15_EL1 SYSREG(2, 0, 0, 15, 7) +/* EL2 registers */ +#define SYSREG_CNTHCTL_EL2 SYSREG(3, 4, 14, 1, 0) +#define SYSREG_MDCCINT_EL1 SYSREG(2, 0, 0, 2, 0) + #define WFX_IS_WFE (1 << 0) #define TMR_CTL_ENABLE (1 << 0) @@ -1388,6 +1393,12 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint64_t *val) case SYSREG_OSDLR_EL1: /* Dummy register */ return 0; + case SYSREG_CNTHCTL_EL2: + assert_hvf_ok(hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTHCTL_EL2, val)); + return 0; + case SYSREG_MDCCINT_EL1: + assert_hvf_ok(hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_MDCCINT_EL1, val)); + return 0; case SYSREG_ICC_AP0R0_EL1: case SYSREG_ICC_AP0R1_EL1: case SYSREG_ICC_AP0R2_EL1: @@ -1704,6 +1715,12 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val) case SYSREG_OSDLR_EL1: /* Dummy register */ return 0; + case SYSREG_CNTHCTL_EL2: + assert_hvf_ok(hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTHCTL_EL2, val)); + return 0; + case SYSREG_MDCCINT_EL1: + assert_hvf_ok(hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_MDCCINT_EL1, val)); + return 0; case SYSREG_LORC_EL1: /* Dummy register */ return 0; -- 2.39.5 (Apple Git-154)