From nobody Mon Apr 13 12:17:41 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=1772813782; cv=none; d=zohomail.com; s=zohoarc; b=RQpCj9wuOt93DTftmKetAWpdq5Ubd5qr/exe8orZCCvg6F+4Up9w3SLtciyQ3DVrb2n2pQOqf+8M/8lugaPmeM/XyI7yqtOwsoaRsohNdEcYjSCRswN7PEpevfIbj66B2LKujsVfkjLjLpHkHJMM8aU8mfrCGzDWrhHWxVsTx54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813782; 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=Bv7t7Vy+N3Dr+xwTtt4qH/q/trULmWUOvcHWfy7me0o=; b=bBKu2ml2+7HrmfgeFxjHB68/fTbK6Lxi87U3brUpYoiuGlbdVRr6hWk+qaJAEt7pX66R8/XvBsMvaDXukO6KMk+zVPwzHRLfiUMi+bwqGY9NaY3s4tQhgMyopVBHMevV13nBBw6f+lYnYrYmzwaskrLKzX1GDpddYR8tRssTI6A= 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 1772813781543612.4815238228238; Fri, 6 Mar 2026 08:16:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXpw-000470-LK; Fri, 06 Mar 2026 11:15:36 -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 1vyXpm-00042e-Ao for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:26 -0500 Received: from p-west3-cluster1-host2-snip4-10.eps.apple.com ([57.103.73.151] 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 1vyXpk-00074i-HZ for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:26 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 7E3BA180012D; Fri, 6 Mar 2026 16:15:20 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id B2EBA1800119; Fri, 6 Mar 2026 16:15:17 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813723; x=1775405723; bh=Bv7t7Vy+N3Dr+xwTtt4qH/q/trULmWUOvcHWfy7me0o=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=evMBneXS+U/8Bo2oT14by89mAYbOa18h2XTnOQ8gz8QnhAJ7/or4GOa8gqC+XpUcIks/HscuZ+/T0Uh7/wVHQrY7Jf7pX7sBhUdeVdAHdHpQ93nSr1N8o23cq4RmXBLCx5uHoAASXPnvPnj4iw1dJuA6eShJ9XrKlmaLm5T9TExUUMy/z/HEjUtQeVsxNN9brvzTi6hxG6r0m+VgZ0sI0tds5avrzdlaSq3kGJoeAD+3JDAQZfpo+UrxEl0NqMTh5ZclPX5z8bGIROlJxaFKRJH/OLvBDS8EaYuvq/aGP9RNeTMkTkkU6XJfSSi9TGZKXhnB0CnS5dLWA3ISpIkmzw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 02/17] hvf/arm: expose FEAT_SME2 to guest if available Date: Fri, 6 Mar 2026 17:14:54 +0100 Message-ID: <20260306161509.79712-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=CcYFJbrl c=1 sm=1 tr=0 ts=69aafd99 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=cKmG3w1NXntEKhAjIXMA:9 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: d6att8EZ9eEiAk-o1aFH7PpNYL0bjNK3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX/g5O176wo8pi 7ustFW2EG8Q8IO92Hc149w6oBt4p2RUk1MexVL7BaeZVKxzCm13FCi9M47mycMhU5luHr3SriRf a9DX7gS63kKw0oAcUHn4wxXFb2W4Ewv41SvbPzDwHvyd4Z5XjXxqK1aCJrqp5Avjkm85uaFqxJr Ur/BW+tevSAcVvCFlwumr27AtQoi0+0tbKtK/V//5atTyi9f7j40Tz4xzQUm4eZalk+171KN3b7 Fi4j9hwGlSWcmlLT8ddshLD+uNJmbyQm12oiRJrDCYl3Ug7/44WA93CtWeg37YRUax/wML/2rXa AdJO7UPv4deijmYIVJ1fNHWngc4SqXBK9X9z083bCcZqp2Z731BKisPYy2s/4s= X-Proofpoint-ORIG-GUID: d6att8EZ9eEiAk-o1aFH7PpNYL0bjNK3 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_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1030 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABm6Bnuo0lWMJeDS7w9AWTxhKczQtA2NPtPTvtZdsZSW0h1rm37c7+uH17PQFuk2Jb7MmGjCCSsmq43ENKM/u1bHFURGgPOkx8bfjpy3Hk2PDKi8x0Oq9jtHX01V3i0U8qbPvSEhQTzxtVUt5E25IxX0rRKDLclJ4lO+rffpmh5ywCsfQC13CwEKbfTSemfeGF3iA4Zav2iMl6dvJU8kkAqot2WrQbinTUq+Gfo2uZWUVuEy7vx4VWKxJykOqwzxfbfnioTnz0nO5VFqxOldLm7JW0bSQjr/R5cmNtihOu/uoLXPTN3iG94Obor3J2reP0cbWpEFCQfyMwsi7b5tn26V4MHPMen9a5+yiA/3hXcw27e9LoPm4EFf3iZdpQJYZlM/ZclXEPGFWNI8cNpgEXBuWyYKe/0zHCsi06LryBu1TkWYzuXx/ULGxDqWhjfWbda7/JnnWzF1SBMg9bNPMYP/ZIB8oxS5QwI/A75onRVlpNsaUIOPinzV1VKQ4CxOwoE129rLAWkcWpSlylOBSlLPp+9enr5OmpNmcjZV+HhTtkGo576FNXBqx1yeXHi4NbfTGGNHkFqOwZgqEhNlkOHoxFd2AvbM9FUFTUKIDw5GwzahM1cYALUm+vTr9b21+2/dNKl2nOBP0kGNqEm+EJwDHaOFtXHIWiF99dCk4y3wOcmpI2vuO3u6PGMk6P0DgJwZW9r6kXGys8UmlFjv/z6nqjyBLzHzmzRqVetakoz7PpEzEyT5sV416FznwRU4vsI/SVSWNMCdI= 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.73.151; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1772813784782158500 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis Starting from M4 cores and MacOS 15.2 SDK, HVF can virtualise FEAT_SME2. Signed-off-by: Manos Pitsidianakis Message-Id: <20260306-sme2-hvf-v7-2-e72eeda41ed3@linaro.org> Reviewed-by: Mohamed Mediouni --- target/arm/hvf/hvf.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 21b16dfe42..5fc8f6bbbd 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -315,6 +315,7 @@ typedef struct ARMHostCPUFeatures { uint64_t features; uint64_t midr; uint32_t reset_sctlr; + uint32_t sme_vq_supported; const char *dtb_compatible; } ARMHostCPUFeatures; =20 @@ -1106,6 +1107,24 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) r |=3D hv_vcpu_config_get_feature_reg(config, regs[i].reg, &host_isar.idregs[regs[i].inde= x]); } + + if (__builtin_available(macOS 15.2, *)) { + static const struct sme_isar_regs { + hv_feature_reg_t reg; + ARMIDRegisterIdx index; + } sme_regs[] =3D { + { HV_FEATURE_REG_ID_AA64SMFR0_EL1, ID_AA64SMFR0_EL1_IDX }, + { HV_FEATURE_REG_ID_AA64ZFR0_EL1, ID_AA64ZFR0_EL1_IDX }, + }; + + if (hvf_arm_sme2_supported()) { + for (i =3D 0; i < ARRAY_SIZE(sme_regs); i++) { + r |=3D hv_vcpu_config_get_feature_reg(config, sme_regs[i].= reg, + &host_isar.idregs[sme_= regs[i].index]); + } + } + } + os_release(config); =20 /* @@ -1121,19 +1140,6 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) =20 clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar); =20 - /* - * Disable SME, which is not properly handled by QEMU hvf yet. - * To allow this through we would need to: - * - make sure that the SME state is correctly handled in the - * get_registers/put_registers functions - * - get the SME-specific CPU properties to work with accelerators - * other than TCG - * - fix any assumptions we made that SME implies SVE (since - * on the M4 there is SME but not SVE) - */ - SET_IDREG(&host_isar, ID_AA64PFR1, - GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK= ); - ahcf->isar =3D host_isar; =20 /* @@ -1148,6 +1154,8 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) */ ahcf->reset_sctlr |=3D 0x00800000; =20 + ahcf->sme_vq_supported =3D hvf_arm_sme2_supported() ? hvf_arm_sme2_get= _svl() : 0; + /* Make sure we don't advertise AArch32 support for EL0/EL1 */ if ((GET_IDREG(&host_isar, ID_AA64PFR0) & 0xff) !=3D 0x11) { return false; @@ -1199,6 +1207,7 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) cpu->env.features =3D arm_host_cpu_features.features; cpu->midr =3D arm_host_cpu_features.midr; cpu->reset_sctlr =3D arm_host_cpu_features.reset_sctlr; + cpu->sme_vq.supported =3D arm_host_cpu_features.sme_vq_supported; } =20 void hvf_arch_vcpu_destroy(CPUState *cpu) @@ -1343,6 +1352,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) arm_cpu->isar.idregs[ID_AA64MMFR0_EL1_IDX]); assert_hvf_ok(ret); =20 + aarch64_add_sme_properties(OBJECT(cpu)); return 0; } =20 --=20 2.50.1 (Apple Git-155)