From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177453; cv=none; d=zohomail.com; s=zohoarc; b=VX/DbIsrE3k/3i4a/iGr2JcTuCPtGUeDLMinQE6O9D6wRUDnvku055U5PN9Coq+hdvLyLkQ71ftHsMAM6e3b5WT807wW67A1YrUd73tafb0Vw+s6QTXsiAbyk0ICgk0gm1/izthLcus8mT3oLkzfoszDUB2TkRmQVq2Txzja9tQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177453; 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=DKGJxaYCwBv8dhLSz8gkA8y5eKHpB1dn5bXnuAxni/8=; b=ly4c9OOOlqQPhtZzr1FfNEHitbhaPx8QEQpZQV8SHcECL4adb/sAxxdTWPxyTa7XqQXGYJSDA3b0zyWPOAesNLYa9nXmmFdAE6xzU7d/VL3I1nGVqyxSxfs+vBt7scPHefoxbuqfZGOQDxBetYLSatNhw/+XZRFhpdFZYl3tRQM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177453678911.3966869629298; Sat, 2 Aug 2025 16:30:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLga-0006jy-Jq; Sat, 02 Aug 2025 19:30:44 -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 1uiLg4-0006I4-QP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:13 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLg3-0004oK-0K for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:12 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-2cc89c59cc0so3139176fac.0 for ; Sat, 02 Aug 2025 16:30:10 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177409; x=1754782209; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DKGJxaYCwBv8dhLSz8gkA8y5eKHpB1dn5bXnuAxni/8=; b=HTkj5fi4OxRqBDTiN/JzbE9YrPW/ayvQOGwfn6x2akx6qzHEDM7lEyFXD7j769ufY+ PxMO3hE4DXxoHaDD/h22FU5X/cFRmwuUmf0j0zuLi4XgwYgkIgzMrcHjnw7BMVBeqTYV NrpeEBkErAPNQt9TvP/iMq87tGTnIzheO+R0HotLipEiaJdcZiFb38wGVw9uU39KhZKw JN7Qd/uxUAYtG4JlTn8Tzi20edsi9TVbuUBrBlQ/oX5F3h6DH7gYO/s3SftfpJi6Jt3j qgLTVF89eUAjHFLXEkQram5W/lqWZSoT72Y6kIwelHZ4krDpYDD47KBEj7XkxjQH58sc WyNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177409; x=1754782209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DKGJxaYCwBv8dhLSz8gkA8y5eKHpB1dn5bXnuAxni/8=; b=AkRKDNntBR7SHBwDvNHcPvzVQGlduHSXFIwq0/M39AwYvRVzN3EvSpZXV79v1yt4MW 4o727EJ6JDAgLQvCX/tmZg1C0ZN24AMg4BOhh05h2/FZnei+deSxB1pSyj6H8WNir+YG +pMSG59qT8dhZBF9HVdhhBGGAFMW2dbmTKd2+U7C4ouWdT96g0GO+eQJ/bzD2vB4zs/o XZfXqpiFubk/pfZjUd2cg/xQmX55f76uxv+QjAO0b0ue7Jhu43lWJiC/eMqorAqVY5LB EhiimDeJvLoo3pOifgPh67cyIYfhQuc3NC/N9h5nWvnA/W8J7PQ8leVfPoIzyvjrktzt qQUA== X-Gm-Message-State: AOJu0Yw5zrw1kiLdqvuZEpcnIPgZjH/6pr9xG5h6WG0T3D5njSwbKEaJ fM4Vo76meFO8iOfCH11+qA5fJplQR1CGnIzh8RmhKsw+jmElcgsDS1huId15r3zgVZrRi4m19P8 fmUFVdqg= X-Gm-Gg: ASbGncvtkAhUnZ7UBs84Wv3EjvkWt/cpwHTjcxBL2ZI3keXqE92hSmYCmfTagfBlwDL ShTUOAfBNGnvqZpVhdepyolh+mjoXQNvtMkUjnRjGGSceG+FxO4DRhmfsnoIdDfGH5KLRBEYKRV guIFmOzeZzUYDrNlXgLNhvQzbnxNXtgdm25qHmgMTTP4xnDRN6ZWwb4sQ2BOZkkMcyOUs2kpHax wEZex1rops9moY85pvuGwanPUdETOMvr515HuHCeO39FH1R5TBM6XZE5NcPTStOgTCdecD24mw0 WIGrP4ccw0oPn9+VtkU8r9bGobs0KDJfGuFC7w0GgQcRqk8EOTVciD3iNsaYrqfDEuVYBgd3JWN mv7jSEjceJtAyoDoY7KA1e5a+1xtE9M3S3HNbj5YGNXIwHSY0VplnOrYQaFJ78ok= X-Google-Smtp-Source: AGHT+IGIcze9F9GmU2PAssW9dXbPdSb5w6MdKsYUh5KEBe1TxvBXYKQw7vuWhxAAEPatvFCSZ+r55A== X-Received: by 2002:a05:6871:73a3:b0:2f7:53e7:1131 with SMTP id 586e51a60fabf-30b66ad5a19mr3066749fac.10.1754177409544; Sat, 02 Aug 2025 16:30:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 01/85] linux-user/aarch64: Split out signal_for_exception Date: Sun, 3 Aug 2025 09:28:29 +1000 Message-ID: <20250802232953.413294-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::30; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x30.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177455231116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/aarch64/cpu_loop.c | 84 ++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index fea43cefa6..85d455d018 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -27,11 +27,56 @@ #include "target/arm/syndrome.h" #include "target/arm/cpu-features.h" =20 +/* Use the exception syndrome to map a cpu exception to a signal. */ +static void signal_for_exception(CPUARMState *env, vaddr addr) +{ + uint32_t syn =3D env->exception.syndrome; + int si_code, si_signo; + + switch (syn_get_ec(syn)) { + case EC_DATAABORT: + case EC_INSNABORT: + /* Both EC have the same format for FSC, or close enough. */ + switch (extract32(syn, 0, 6)) { + case 0x04 ... 0x07: /* Translation fault, level {0-3} */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_MAPERR; + break; + case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ + case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_ACCERR; + break; + case 0x11: /* Synchronous Tag Check Fault */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_MTESERR; + break; + case 0x21: /* Alignment fault */ + si_signo =3D TARGET_SIGBUS; + si_code =3D TARGET_BUS_ADRALN; + break; + default: + g_assert_not_reached(); + } + break; + + case EC_PCALIGNMENT: + si_signo =3D TARGET_SIGBUS; + si_code =3D TARGET_BUS_ADRALN; + break; + + default: + g_assert_not_reached(); + } + + force_sig_fault(si_signo, si_code, addr); +} + /* AArch64 main loop */ void cpu_loop(CPUARMState *env) { CPUState *cs =3D env_cpu(env); - int trapnr, ec, fsc, si_code, si_signo; + int trapnr; abi_long ret; =20 for (;;) { @@ -67,42 +112,7 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - ec =3D syn_get_ec(env->exception.syndrome); - switch (ec) { - case EC_DATAABORT: - case EC_INSNABORT: - /* Both EC have the same format for FSC, or close enough. = */ - fsc =3D extract32(env->exception.syndrome, 0, 6); - switch (fsc) { - case 0x04 ... 0x07: /* Translation fault, level {0-3} */ - si_signo =3D TARGET_SIGSEGV; - si_code =3D TARGET_SEGV_MAPERR; - break; - case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ - case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ - si_signo =3D TARGET_SIGSEGV; - si_code =3D TARGET_SEGV_ACCERR; - break; - case 0x11: /* Synchronous Tag Check Fault */ - si_signo =3D TARGET_SIGSEGV; - si_code =3D TARGET_SEGV_MTESERR; - break; - case 0x21: /* Alignment fault */ - si_signo =3D TARGET_SIGBUS; - si_code =3D TARGET_BUS_ADRALN; - break; - default: - g_assert_not_reached(); - } - break; - case EC_PCALIGNMENT: - si_signo =3D TARGET_SIGBUS; - si_code =3D TARGET_BUS_ADRALN; - break; - default: - g_assert_not_reached(); - } - force_sig_fault(si_signo, si_code, env->exception.vaddress); + signal_for_exception(env, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177594; cv=none; d=zohomail.com; s=zohoarc; b=Q338vv4ARvp88VuGOmHB8AsHT0BI25eTwealyuMEklaWJaarHDhq1wJWZE59cMqoVvAjaZJ48lUo53Jg/TgM52XCKnTyMoAA3SfhMHkPnZEYmgzi4sQxATbLXLgKrr+38R97Th09Jy45bvQoN87FUJcR8b7gNcnupyuPibYSC1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177594; 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=ZO91750IU39C64Ysfe0nf9paxZYyW7yZCYTpOatYiek=; b=mE45rfPpGnc+nzdKHEFR/XVJ6ZnHYozdR/C0ZhYWoBQYJ1MEArjym1P9Ibsgk3YDucq2vo33tVT3+FdD/B+wzVkS4zvxxrDNgx2U4NZhp2+hV5KMzdfJmHnaRi0C7THU+hikMK+G1aCCGVOLyiJE1PTw4DKMqTEkQNM9sVp7Pfg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177594184227.1806820193076; Sat, 2 Aug 2025 16:33:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLgh-0006tB-3C; Sat, 02 Aug 2025 19:30:51 -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 1uiLg9-0006KW-2u for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:25 -0400 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLg7-0004oy-BT for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:16 -0400 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-61998205433so135568eaf.1 for ; Sat, 02 Aug 2025 16:30:14 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177413; x=1754782213; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZO91750IU39C64Ysfe0nf9paxZYyW7yZCYTpOatYiek=; b=NLUIaId2k8dOFsyLmq9jQ/tQ0E5vsT3Sn31Pygd4FJ05EEFfZr7fuFi1ilsz7bUaWp oSyUyd0sKsMIRA/zIZVVuUPxkZmeIuIsQisB9MGKV/dnhkxmSe3Ok5uUn9oIgl4yLOXG 4xStDhuLuZ3i3Vlvhy+RjxPwTQUALznTqHBbNwHjEncDVcXFbCJ8dxYV2vxfeHDUattC vLicMeB1Ub8bAzvkFtdHybw6MTBANPyCtv1K2zzO/YMdKeRhwPNrXoXfeQgR2tDw167p C4vg407lSnAwFMj+qqdfSw7KPF8RcGALbzixOYKS/4LSkcHq/SuRw75C9ja6uCQPu6dH Dy6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177413; x=1754782213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZO91750IU39C64Ysfe0nf9paxZYyW7yZCYTpOatYiek=; b=GnfC6yfxWnkZaBJVXFgBNh7+T4OfWezlVUxvPn3DYYhOGKbMwPoOrM7BmmswwvJNbq Gb3dcWJmpYwSDciwl9cWy5Ok8660Wf4HbPhg98AwDq/PSzK1hXovWbS7edP2Q8K2dvZq QeYlR8D/grxayHsAP6QkgbtP7RYkgmE6FLLmultzrh4zW8rwjrj/M6ouTzGFGtvTxUUz msVE3Rll59IqO989AgXiPaln/jD/Xc5ZvIIpdnjNltKnTlICMJfgz5CG4J8uJxG3D84o dEJDwDguMmfpx5gRr3RN9TsiqMpzJ6ZaRUKU7ry741BX44S8ZHDk+hrr1zMbLTebXXqh +9zw== X-Gm-Message-State: AOJu0Yzxu6CyZKIgEwhSCBl478jyYDlVqM55oo6pwABkiNL94g76+Gw8 01nA4spUw74mJHSz8R4QCpo7g5jXt395h4EKI8E5sDrusoUoQxg6JZ4Aqo5zW2t2cXyd0AmEQPM qycE4y/E= X-Gm-Gg: ASbGncvNs+B/Eaxlc5XMbx2V/cSjCI8sjV+e8ZLQ8dLT3lWxwzZasJHQQdoLPd61NoX XyTECuLvTuAvhMvslA31laZTOXyI1xiE0ylgx9G7P/Y8YnblhfnhcNpcA2JVpEtnS5/F9WkBnZ2 4889J3npRNrvkGLpZ6Nexj5JOLagV48jHCJPVD+zxeXMJNypXj3nzz0Vpjr6MU6RtDSlFVZDCxK oMCJpCi9klSmHaRS7/4rEDXoDzRmx87panPg+sMGJCwbItEtoNes3U7TuhYjyqatePEPGTnxESD jIWtztKQpJNBdMuXY38JFiiZzsYwXW8ac4SXtsGcqB8drfuhdzLCcwRHDGMvDglcVC2NpKpys+u kqbjAYB7yCJSdoT5RM/2RhVk9nlAguDZNXU+KmwcSNb6RSrvx5m89MwmZVhBXROY= X-Google-Smtp-Source: AGHT+IESz46fEIIeUhfl9lmDOVPJQ5fLDSgl0CbbNblgLjaWHC/6zoKyYigLJ73SMsEqCScEpsLXPw== X-Received: by 2002:a05:6870:a48d:b0:2d6:b7b:a83 with SMTP id 586e51a60fabf-30b67608083mr2383246fac.13.1754177413293; Sat, 02 Aug 2025 16:30:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 02/85] linux-user/aarch64: Check syndrome for EXCP_UDEF Date: Sun, 3 Aug 2025 09:28:30 +1000 Message-ID: <20250802232953.413294-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c32; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc32.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754177596313116600 Content-Type: text/plain; charset="utf-8" Note that we have been passing the incorrect code for most exception codes: uncategorized (do_el0_undef), systemregistertrap (do_el0_sys), smetrap (do_sme_acc), btitrap (do_el0_bti) and illegalstate (bad_el0_sync). Only pacfail uses ILL_ILLOPN (do_el0_fpac). Note that EC_MOP (do_el0_mops) ought not signal at all. For now, preserve existing behavior signalling ILL_ILLOPN. List all other exception codes and document why they do not apply to user-only. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 66 ++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 85d455d018..098578978e 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -65,6 +65,70 @@ static void signal_for_exception(CPUARMState *env, vaddr= addr) si_code =3D TARGET_BUS_ADRALN; break; =20 + case EC_UNCATEGORIZED: /* E.g. undefined instruction */ + case EC_SYSTEMREGISTERTRAP: /* E.g. inaccessible register */ + case EC_SMETRAP: /* E.g. invalid insn in streaming state= */ + case EC_BTITRAP: /* E.g. invalid guarded branch target */ + case EC_ILLEGALSTATE: + /* + * Illegal state happens via an ERET from a privileged mode, + * so is not normally possible from user-only. However, gdbstub + * is not prevented from writing CPSR_IL, aka PSTATE.IL, which + * would generate a trap from the next translated block. + * In the kernel, default case -> el0_inv -> bad_el0_sync. + */ + si_signo =3D TARGET_SIGILL; + si_code =3D TARGET_ILL_ILLOPC; + break; + + case EC_PACFAIL: + si_signo =3D TARGET_SIGILL; + si_code =3D TARGET_ILL_ILLOPN; + break; + + case EC_MOP: + /* + * FIXME: The kernel fixes up wrong-option exceptions. + * In the meantime, preserve previous qemu behavior. + */ + si_signo =3D TARGET_SIGILL; + si_code =3D TARGET_ILL_ILLOPN; + break; + + case EC_WFX_TRAP: /* user-only WFI implemented as NOP */ + case EC_CP15RTTRAP: /* AArch32 */ + case EC_CP15RRTTRAP: /* AArch32 */ + case EC_CP14RTTRAP: /* AArch32 */ + case EC_CP14DTTRAP: /* AArch32 */ + case EC_ADVSIMDFPACCESSTRAP: /* user-only does not disable fpu */ + case EC_FPIDTRAP: /* AArch32 */ + case EC_PACTRAP: /* user-only does not disable pac regs = */ + case EC_BXJTRAP: /* AArch32 */ + case EC_CP14RRTTRAP: /* AArch32 */ + case EC_AA32_SVC: /* AArch32 */ + case EC_AA32_HVC: /* AArch32 */ + case EC_AA32_SMC: /* AArch32 */ + case EC_AA64_SVC: /* generates EXCP_SWI */ + case EC_AA64_HVC: /* user-only generates EC_UNCATEGORIZED= */ + case EC_AA64_SMC: /* user-only generates EC_UNCATEGORIZED= */ + case EC_SVEACCESSTRAP: /* user-only does not disable sve */ + case EC_ERETTRAP: /* user-only generates EC_UNCATEGORIZED= */ + case EC_GPC: /* user-only has no EL3 gpc tables */ + case EC_INSNABORT_SAME_EL: /* el0 cannot trap to el0 */ + case EC_DATAABORT_SAME_EL: /* el0 cannot trap to el0 */ + case EC_SPALIGNMENT: /* sp alignment checks not implemented = */ + case EC_AA32_FPTRAP: /* fp exceptions not implemented */ + case EC_AA64_FPTRAP: /* fp exceptions not implemented */ + case EC_SERROR: /* user-only does not have hw faults */ + case EC_BREAKPOINT: /* user-only does not have hw debug */ + case EC_BREAKPOINT_SAME_EL: /* user-only does not have hw debug */ + case EC_SOFTWARESTEP: /* user-only does not have hw debug */ + case EC_SOFTWARESTEP_SAME_EL: /* user-only does not have hw debug */ + case EC_WATCHPOINT: /* user-only does not have hw debug */ + case EC_WATCHPOINT_SAME_EL: /* user-only does not have hw debug */ + case EC_AA32_BKPT: /* AArch32 */ + case EC_VECTORCATCH: /* AArch32 */ + case EC_AA64_BKPT: /* generates EXCP_BKPT */ default: g_assert_not_reached(); } @@ -108,7 +172,7 @@ void cpu_loop(CPUARMState *env) /* just indicate that signals should be handled asap */ break; case EXCP_UDEF: - force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->pc); + signal_for_exception(env, env->pc); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177493; cv=none; d=zohomail.com; s=zohoarc; b=l88VQANNP/g2YvF1ZX1wccTTsc9zl245nngZAvBQdGQ7mzTU6gCj7TbbVveV81L5HjGbf2T4hGpKx5i44qdlyv/5BGDT3wcXbVR5W1SdGE/ZYeRrjJeqZaCp4BZJSQLptqNXIRJeawO9fqAQU2FRVVnHRdrj33WJtMKLBcAV1c4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177493; 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=BsvBS8RBB7nukj1RPR1Xen8yV7uvDqzTtw/ihslv+1c=; b=jQ9YnIrijPYDSzvBAWwqmqjUe+PtQblZr5+rX/IsUcEAKPAvwb8DtNWSokrAgWzOSio3dN+CxsSfPJqQiyLT9ARKAIg8K1qCKJ9eaxdjqEw6rRIomORmCV8K/EPC6HqRagqs+YZSm+3lQb7tEx+06ROxY2zTGGxZi5AObtgXRGU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177493220324.47788126326645; Sat, 2 Aug 2025 16:31:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLgi-0006vd-08; Sat, 02 Aug 2025 19:30:52 -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 1uiLgB-0006LI-Ul for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:32 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgA-0004pZ-Ee for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:19 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-3004ade907bso1003175fac.0 for ; Sat, 02 Aug 2025 16:30:17 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177417; x=1754782217; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BsvBS8RBB7nukj1RPR1Xen8yV7uvDqzTtw/ihslv+1c=; b=ksKK0yNP5L5s6C7Owr9cOMWbLLy0yJWGjW7RP28X7xqn9Tl205aEpmgjY5DTcc0Lyy V8IF3g8N1E0oRagMvgmmXVNLJd6rgrmZPMiX4CcvPUI/UGNJj/+26YFuD4p0igmcPJGy 7/4FzCw/RLsGgOS/bAKijvFlTDYiviRBmfr7rFmoPx74UhJn0w5uKgwo0Bjs8pr3Zq2Y bzitVuU44GOIUAp9m5lxw2ZzC0dDNd2Qt6n70s/LO0kj0RkHkGiLnPZShwTbJ4kE7+a1 kKDpMO2VWgzoXKOlHJUp6zSQjY6Uqo7SlsAiZ5dnlGZc1YyjVK4ZhTOUTB0h1ZJ0YmAv gsHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177417; x=1754782217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BsvBS8RBB7nukj1RPR1Xen8yV7uvDqzTtw/ihslv+1c=; b=fuMM/IBJX+Tr37CN0DsCQj04f3Mme16dcm9bK9FRF4UjGbrsNqETzXXOC4BaEdNnKB yjHZwY0Piq2EG77uvUIutHFTUiTd45L/X4Nw8NJ1W8Hws/ky7NbicuOd+MDZZw7lhACS I9clAhArcgw915mzwkj6HTPpdFqkp3nIPPsdahvNdGtVgh6YYVVSse2IX6U/a9Q3YGCM NjDU/e3rzLB7bcCx91vBNpADkPID84nNBk7wewMgXa0ohvlvVz20RB3bZmy2ecbqrvca tSJ0hd04R2pD5Cuk3nDYkU4DbNAltPqbckhvXhtGKOEHlK8+Cv2ujZSFbssCwpA9z28b KiBA== X-Gm-Message-State: AOJu0YzxWrGNBR7HWVC0BjRH3vckfr4uZ5Ez7EZ4qjKPyQjmGMj6o97b i92FQ4leSCOFbzlvkqGY/MzoB2PBboKiYIFheQBC8X6Ro0Q42UwwsE8acIbVb/n5neLntkIUsJR R83+sn58= X-Gm-Gg: ASbGncu1yO/WmMF8/OWPbdsZ+h/8x9YhGjaCZTxC+oHIJz4YZh6jysLqp+Km8qZpnVY CULco/rLz3ZxHwSydbTB/XTGDNa7467D7Su3OGT+OeMXsSXEF58lpwBl7X0H35PTxbRUu/jQmEU pNybBrEvOmTJsuNn/5ZSxgBUXwgDI3XDux0oXCCfT6hnbPwwMvT4X1SShrB5r0TFLg64nsNAXYe VTBSdMJv3nXckp7IRENmuis5mZpXVl+FsDGrOxVLF3FJAy0FmVQuLYt6YH+cPfDAS7f4e3AM2tx h0qvj5gTXZAyxSJJ3RHDFM/1iCAwECSOxp6FsxLBHNR8p9g81umiwe1QIGAbbU8qSCstDBzgVJc lbmTioCyLxEhCPGh4VZEOBQvuwv2a/9n8NEct2j3jGadXwsTG29ul X-Google-Smtp-Source: AGHT+IFxQXq89PP0el1O6Y+gX7pjV8DeiRX4UIIBGDHceUmOrEFXpFcyyDXac3RoWa6XLQfGwKbUbA== X-Received: by 2002:a05:6870:a99c:b0:29e:2d18:2718 with SMTP id 586e51a60fabf-30b67a05a9emr2698528fac.28.1754177416974; Sat, 02 Aug 2025 16:30:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 03/85] linux-user/aarch64: Generate ESR signal records Date: Sun, 3 Aug 2025 09:28:31 +1000 Message-ID: <20250802232953.413294-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754177495334124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 3 +++ linux-user/aarch64/signal.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 098578978e..7e9788abfb 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -33,6 +33,9 @@ static void signal_for_exception(CPUARMState *env, vaddr = addr) uint32_t syn =3D env->exception.syndrome; int si_code, si_signo; =20 + /* Let signal delivery see that ESR is live. */ + env->cp15.esr_el[1] =3D syn; + switch (syn_get_ec(syn)) { case EC_DATAABORT: case EC_INSNABORT: diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 668353bbda..ef97be3ac7 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -65,6 +65,13 @@ struct target_fpsimd_context { uint64_t vregs[32 * 2]; /* really uint128_t vregs[32] */ }; =20 +#define TARGET_ESR_MAGIC 0x45535201 + +struct target_esr_context { + struct target_aarch64_ctx head; + uint64_t esr; +}; + #define TARGET_EXTRA_MAGIC 0x45585401 =20 struct target_extra_context { @@ -201,6 +208,14 @@ static void target_setup_fpsimd_record(struct target_f= psimd_context *fpsimd, } } =20 +static void target_setup_esr_record(struct target_esr_context *ctx, + CPUARMState *env) +{ + __put_user(TARGET_ESR_MAGIC, &ctx->head.magic); + __put_user(sizeof(*ctx), &ctx->head.size); + __put_user(env->cp15.esr_el[1], &ctx->esr); +} + static void target_setup_extra_record(struct target_extra_context *extra, uint64_t datap, uint32_t extra_size) { @@ -531,6 +546,9 @@ static int target_restore_sigframe(CPUARMState *env, fpsimd =3D (struct target_fpsimd_context *)ctx; break; =20 + case TARGET_ESR_MAGIC: + break; /* ignore */ + case TARGET_SVE_MAGIC: if (sve || size < sizeof(struct target_sve_context)) { goto err; @@ -683,7 +701,7 @@ static void target_setup_frame(int usig, struct target_= sigaction *ka, uc.tuc_mcontext.__reserved), }; int fpsimd_ofs, fr_ofs, sve_ofs =3D 0, za_ofs =3D 0, tpidr2_ofs =3D 0; - int zt_ofs =3D 0; + int zt_ofs =3D 0, esr_ofs =3D 0; int sve_size =3D 0, za_size =3D 0, tpidr2_size =3D 0, zt_size =3D 0; struct target_rt_sigframe *frame; struct target_rt_frame_record *fr; @@ -693,6 +711,15 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, fpsimd_ofs =3D alloc_sigframe_space(sizeof(struct target_fpsimd_contex= t), &layout); =20 + /* + * In user mode, ESR_EL1 is only set by cpu_loop while queueing the + * signal, and it's only valid for the one sync insn. + */ + if (env->cp15.esr_el[1]) { + esr_ofs =3D alloc_sigframe_space(sizeof(struct target_esr_context), + &layout); + } + /* SVE state needs saving only if it exists. */ if (cpu_isar_feature(aa64_sve, env_archcpu(env)) || cpu_isar_feature(aa64_sme, env_archcpu(env))) { @@ -754,6 +781,11 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, =20 target_setup_general_frame(frame, env, set); target_setup_fpsimd_record((void *)frame + fpsimd_ofs, env); + if (esr_ofs) { + target_setup_esr_record((void *)frame + esr_ofs, env); + /* Leave ESR_EL1 clear while it's not relevant. */ + env->cp15.esr_el[1] =3D 0; + } target_setup_end_record((void *)frame + layout.std_end_ofs); if (layout.extra_ofs) { target_setup_extra_record((void *)frame + layout.extra_ofs, --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177719; cv=none; d=zohomail.com; s=zohoarc; b=ktop+beog0KL3zL6BS9qyCSNwFJQhfHwH3FEyuEG/MXAdmdHR9QnJiwjCPWc9fOHFlLKMZAol/LdkyYUduOESDTObMdY0t7N81PxnYIETwkuHAbgIabPlM5r+NPIORfMQ75GWq7qNmMzQAg4dbGB/ZDuG/CF9nFAsX7u6INf6xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177719; 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=H1X7tRIlbeJs7+JRFY3gIthkRvi/ERSg1idEqFWeh8k=; b=glLqMEM9w8Puw+MO0VzKDWitKo7wDPU2xXqRVJPAwu9p7h55nS5oOGrVFPJoGlt9ZA40shbgY/PWAFCZGf9HXtwWXgCDg2GBZ7dJFnLXk/+b0smEWMb7Q9900iCK6dRlS26iVe04w36CvIDJzawIpoBluvw34C84WnFOfstIRv0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177719403966.9698124065582; Sat, 2 Aug 2025 16:35:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLhh-0008LB-1D; Sat, 02 Aug 2025 19:31:54 -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 1uiLgG-0006NO-HL for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:34 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgE-0004q3-It for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:24 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-741a0ec1a05so314500a34.2 for ; Sat, 02 Aug 2025 16:30:22 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177421; x=1754782221; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H1X7tRIlbeJs7+JRFY3gIthkRvi/ERSg1idEqFWeh8k=; b=jToFdCTNL33DzQYf406yArFDaRlxtkPw6rdhKrz9O3IlphyimUT17GDqfY5tredpF/ wft2sZqr9XHxJ7Xk3IamlyNMX/5HNs7nDkt1ggckKTcCi/uVtJR/yXDwPbu5glOPD4z3 4p2PWu0p8xd0rCLRhaMaqb9UsHglFUn/YN4VTkG+KLalgBr+/8S7kw0TsrZ0cghPo6a1 V6qcKMvPm2bMIi0JAvQuPlp7T6bPu49Ob7DYDLFMcpk1pQxiuImwq/hF6DIPVTF9FZ41 msGIYxRvP5f73M9azSfmbtnpo/rTEqjEiQLa+nZj5epWsvFl3KNLgNFn5ta5vjrdS46n mmUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177421; x=1754782221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H1X7tRIlbeJs7+JRFY3gIthkRvi/ERSg1idEqFWeh8k=; b=YIhQBIWHBwohBhcwIcUyFe5OsyAklEczz9Jyyb3Vluok/sx9xUKjlIEy7tkLy62iQD YBEcuv1s0/mf+Skq4V2tIO6sSCHv6DHLiDUcWukycJjb3Z9tpvGQNGtlMkwbGn8hPMV7 ZuW1ZVzIarpE5L7SLOW3rce3XOLD8WDdx7Pli+zBWCIv197cy4ydU/45OpMV+nie4HXB 5Nu0Ce75adUKS5muGEjaPpuutLPDNuB0KlD3tcAqx9jKzsimrJ5pdRj2byrFvjiaFDkv kO852dhGJhOI7LY9dR7OuwG+DPBxtkonGyAJTyzgJGB80QCZ43E9yFrvtd3t00oyi1v1 kzlQ== X-Gm-Message-State: AOJu0Yxa6z88Rpm3wHMCleTS2ZOsMnNIegINm38rmPU4JTX1kAFawfdR kOzGkxPmKQxmSTElmIlEPYNQBgOtKR+srx+rqHo241W96/4tcikpOmhZOVHKfXJ9RBnVqCEGP7c 1ihrAXm4= X-Gm-Gg: ASbGncvHAQqUJgiCZEiUqS57Z2IQIqh8/6K9mnqszYshs/Ipzg8zwcnPql6cE04Srs4 O+gYmUFZfEoUYBbdrJyS35TkkJLR0OuCUrTuk86EiLGWBjRpn2pvO5koX8kPcUm1F/TOAq1MWFl quDw0HazlD4TkvG+Z2o3KUtWSFeO1syy1FFtL//PJo62WceT6e7soevUf48l5PRtq/6BMt2xtRT eUU1Ekkg0HwATexoPwVLLOFagn1JkuVPYnd+JkR0gFz+MpM8UA1nSLUBE9ueah7+FUUZL9u9LHE h3IvZxK6+Q8Qo8qLai1zu8ohefNzRWaVYMhzs8I7ulw0+am4YiR9mZpsiGS2alGEvNQYAopyxS6 dXukBN6xgSv2Bu6bGwsytFnLRcyUqBWtpiHvDKaNZdv+qXL2I622N X-Google-Smtp-Source: AGHT+IHygjNW+d2R1dy85V2oE9VABBsZH3ztf6vNeH4dc9MrqYXjrdiLEVL7/J02fmLa2jkZywQsbw== X-Received: by 2002:a05:6870:1e8e:b0:2d6:245:a9b3 with SMTP id 586e51a60fabf-30b6755af2amr2513407fac.6.1754177421237; Sat, 02 Aug 2025 16:30:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 04/85] target/arm: Add prot_check parameter to pmsav8_mpu_lookup Date: Sun, 3 Aug 2025 09:28:32 +1000 Message-ID: <20250802232953.413294-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177721212116600 Content-Type: text/plain; charset="utf-8" Separate the access_type from the protection check. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/internals.h | 5 +++-- target/arm/ptw.c | 11 ++++++----- target/arm/tcg/m_helper.c | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 118659815f..326b5a73cf 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1626,8 +1626,9 @@ bool get_phys_addr_with_space_nogpc(CPUARMState *env,= vaddr address, __attribute__((nonnull)); =20 bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - bool is_secure, GetPhysAddrResult *result, + MMUAccessType access_type, unsigned prot_check, + ARMMMUIdx mmu_idx, bool is_secure, + GetPhysAddrResult *result, ARMMMUFaultInfo *fi, uint32_t *mregion); =20 void arm_log_exception(CPUState *cs); diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 561bf2678e..a914e7e23c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2561,8 +2561,9 @@ static uint32_t *regime_rlar(CPUARMState *env, ARMMMU= Idx mmu_idx, } =20 bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - bool secure, GetPhysAddrResult *result, + MMUAccessType access_type, unsigned prot_check, + ARMMMUIdx mmu_idx, bool secure, + GetPhysAddrResult *result, ARMMMUFaultInfo *fi, uint32_t *mregion) { /* @@ -2750,7 +2751,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, if (arm_feature(env, ARM_FEATURE_M)) { fi->level =3D 1; } - return !(result->f.prot & (1 << access_type)); + return (prot_check & ~result->f.prot) !=3D 0; } =20 static bool v8m_is_sau_exempt(CPUARMState *env, @@ -2952,8 +2953,8 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, } } =20 - ret =3D pmsav8_mpu_lookup(env, address, access_type, mmu_idx, secure, - result, fi, NULL); + ret =3D pmsav8_mpu_lookup(env, address, access_type, 1 << access_type, + mmu_idx, secure, result, fi, NULL); if (sattrs.subpage) { result->f.lg_page_size =3D 0; } diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 28307b5615..d856e3bc8e 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -2829,8 +2829,8 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t ad= dr, uint32_t op) ARMMMUFaultInfo fi =3D {}; =20 /* We can ignore the return value as prot is always set */ - pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, targetsec, - &res, &fi, &mregion); + pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, PAGE_READ, mmu_idx, + targetsec, &res, &fi, &mregion); if (mregion =3D=3D -1) { mrvalid =3D false; mregion =3D 0; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177723; cv=none; d=zohomail.com; s=zohoarc; b=haFvT6357nPSvy00MQAQBZTjwPYb2oxAift02HoVcH/LWJB4BBRBX+RKAoRRMAGacTydEBLdCScTgvWa1abaI2VIPrUnCweRDYdMlW02GDWESn5GRNFdFw7wCfxjoXPDs8nAsx20c+6NMm/d63RqVYkHmUVeiNqoxxlDP5K6bkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177723; 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=tT719Yr1a9uhc93zITJ7bwqOfh29BbRAnDJiR12mnEI=; b=FdKDaqgzucBwpoVzPvLVRXLcZnS980cF4jBLOiaYUrU5ptU0NbHErAUF5yoMeJSaLYNIs26ERSZosqo/hE7HtrToahEa2+VyLOvLdUGOxT4q7oZEpGLnnz8a5GEWA1rhc4Xnh7go1SM2immg7ZIKQ7/sgyGachs0BF6HN0fWng0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177723446679.613711991394; Sat, 2 Aug 2025 16:35:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLhU-0007sC-3V; Sat, 02 Aug 2025 19:31:40 -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 1uiLgM-0006RY-Hs for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:37 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgI-0004qi-GV for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:28 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-306db05b292so945652fac.1 for ; Sat, 02 Aug 2025 16:30:26 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177425; x=1754782225; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tT719Yr1a9uhc93zITJ7bwqOfh29BbRAnDJiR12mnEI=; b=CZZMT2Bii3tkQYS/dNdfjUGFzQZUyrJYUO0yLa6Fvy+NqWFrfCO/hJxi+1w/pkVQ7z I/9s2kx8dUbcPEUG87xEx3L1GDJIZGi5lX7ZaWEPS968KyBPKKXRiRmMnTUuJzu89q/o u6dIhS4ffXF4+/0Xko7EqW5ssXnTjaNTGSQmOODny6oYSnr/TY4IKTIletj1tVJVVj6+ 0Eurf/FNCX3r0orqgNv40HOGCRzStp4iDEnOSx/rdhQVd5SyscaJlv1QThRfw7wgmHRP G97ZAK+hkdD1gqOjJ/nZN/cyYozHaIKFbrWkGK1PFq/BTz1JXyrAkOJmFEp0KUjr7uXx WGmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177425; x=1754782225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tT719Yr1a9uhc93zITJ7bwqOfh29BbRAnDJiR12mnEI=; b=c0Z+p1k4kp8cHTlj+KC99CMbdgDUhNvTefsd4Upam5S1VCGb+acowHGG2zA/QZhihf RyY7Zc7kKxelVay/DIMbPcMYM1kl8Embx9AnQqzLXiEsgzf6O6sbfceSrF+veYwU8dIu dnfo64WpAmKZrf72YtFszwg50sXk46rt195rSsx838h3468uY1q1aSWa9SgwksSgBQEz rlKFf/VsUFKMk3QnSnIc7OfT32TODze1rRcooQRVy27m/F8mNci47pVvnjfWqSy2XXeC dw6q82F1VVCmcqzohcKyE0+n+cmCfohaUke09XvV1/UPH6exOToG9Usa8uv4mF9JYQeN nhRw== X-Gm-Message-State: AOJu0YwXkv7ZvjbVOcgv713EIsIV6xXQVBSggHktmnNwen0iPbNMHRJ4 Hv28XFSLscyVVB/fXTy38Qbz6ukK0zofTFivVlJXuyFMXkbpSV/1DDZMZn6sxyp/U6qPy2aAqeB rFGWMTys= X-Gm-Gg: ASbGncvSPulgaugRMeS1O3jEmk2h4FBnBGMrzQkfJERT4kktJYSKCoBbtE7ND72t1nn KwEd7fjWSWGRi6miiSggW9uLYvwRZy0GD1/Wiri+gbNy2P2WSygZSHny5yoZf3a3TmFMJFdecv1 7Z0WPy/ado8nl4p6t/00yPV21YRhXZ5/mAUpLzvYifqEU7DZnm1W3tT6cOmvojm47SUlCL8pt1P ecj9MGHvfdbmg4dI7TBy9v4ojxEwI5DTePRMTGaCA1RDDAgzJDsoJpnHwecQwSx/BAN//KiyvxW VMldzdMazakk157T2FKLDx+hz3nJgYwP2oI4seDRpXkvlZ+9MyD44NmIn8wFvc1vOLl/fSCXjGj SMeCxEIECusLeGVf3rzM2nWW2TzE2wqJ4h0cpExivtx2OLhroWegq X-Google-Smtp-Source: AGHT+IEDXLFDyQ4k6217Nm3UDaXWKgFJEESyRkjATNdGQtW9oJValm//703Cn/O+71alyPVx9UuO5g== X-Received: by 2002:a05:6870:705c:10b0:2ff:a1b9:881d with SMTP id 586e51a60fabf-30b67bb0849mr1718214fac.36.1754177425398; Sat, 02 Aug 2025 16:30:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 05/85] target/arm: Add in_prot_check to S1Translate Date: Sun, 3 Aug 2025 09:28:33 +1000 Message-ID: <20250802232953.413294-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177725324116600 Content-Type: text/plain; charset="utf-8" Separate the access_type from the protection check. Save the trouble of modifying all helper functions by passing the new data in the control structure. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/ptw.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index a914e7e23c..1b90e33f52 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -64,6 +64,12 @@ typedef struct S1Translate { * Stage 2 is indicated by in_mmu_idx set to ARMMMUIdx_Stage2{,_S}. */ bool in_s1_is_el0; + /* + * The set of PAGE_* bits to be use in the permission check. + * This is normally directly related to the access_type, but + * may be suppressed for debug or AT insns. + */ + uint8_t in_prot_check; bool out_rw; bool out_be; ARMSecuritySpace out_space; @@ -581,6 +587,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, .in_ptw_idx =3D ptw_idx_for_stage_2(env, s2_mmu_idx), .in_space =3D s2_space, .in_debug =3D true, + .in_prot_check =3D PAGE_READ, }; GetPhysAddrResult s2 =3D { }; =20 @@ -1089,7 +1096,7 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Tran= slate *ptw, } result->f.prot =3D ap_to_rw_prot(env, ptw->in_mmu_idx, ap, domain_prot= ); result->f.prot |=3D result->f.prot ? PAGE_EXEC : 0; - if (!(result->f.prot & (1 << access_type))) { + if (ptw->in_prot_check & ~result->f.prot) { /* Access permission fault. */ fi->type =3D ARMFault_Permission; goto do_fault; @@ -1243,7 +1250,7 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Tran= slate *ptw, =20 result->f.prot =3D get_S1prot(env, mmu_idx, false, user_rw, prot_r= w, xn, pxn, result->f.attrs.space, out_sp= ace); - if (!(result->f.prot & (1 << access_type))) { + if (ptw->in_prot_check & ~result->f.prot) { /* Access permission fault. */ fi->type =3D ARMFault_Permission; goto do_fault; @@ -2123,7 +2130,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.tlb_fill_flags =3D 0; } =20 - if (!(result->f.prot & (1 << access_type))) { + if (ptw->in_prot_check & ~result->f.prot) { fi->type =3D ARMFault_Permission; goto do_fault; } @@ -2537,7 +2544,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, =20 fi->type =3D ARMFault_Permission; fi->level =3D 1; - return !(result->f.prot & (1 << access_type)); + return (ptw->in_prot_check & ~result->f.prot) !=3D 0; } =20 static uint32_t *regime_rbar(CPUARMState *env, ARMMMUIdx mmu_idx, @@ -2953,7 +2960,7 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, } } =20 - ret =3D pmsav8_mpu_lookup(env, address, access_type, 1 << access_type, + ret =3D pmsav8_mpu_lookup(env, address, access_type, ptw->in_prot_chec= k, mmu_idx, secure, result, fi, NULL); if (sattrs.subpage) { result->f.lg_page_size =3D 0; @@ -3625,6 +3632,7 @@ bool get_phys_addr(CPUARMState *env, vaddr address, S1Translate ptw =3D { .in_mmu_idx =3D mmu_idx, .in_space =3D arm_mmu_idx_to_security_space(env, mmu_idx), + .in_prot_check =3D 1 << access_type, }; =20 return get_phys_addr_gpc(env, &ptw, address, access_type, @@ -3638,6 +3646,7 @@ static hwaddr arm_cpu_get_phys_page(CPUARMState *env,= vaddr addr, .in_mmu_idx =3D mmu_idx, .in_space =3D arm_mmu_idx_to_security_space(env, mmu_idx), .in_debug =3D true, + .in_prot_check =3D PAGE_READ, }; GetPhysAddrResult res =3D {}; ARMMMUFaultInfo fi =3D {}; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179098; cv=none; d=zohomail.com; s=zohoarc; b=LbEDZqTFbfLGMX3dBMCBXStAGgwoDxY/GFv2uK5lZbBfAicISQFF9rD31GTbgoTykjFykn04lueQI9n8W/uio4d3fw9T5fopnsAamm7Jh6b4g0hcvfQeM5aD8P572ULAbdIV0XVb6QhF2QQU4SwOjBNNtheNvyzkL6EJLboAz30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179098; 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=kMQri4iirPxW00R1ccJFExnMIuYM+qTTYK6RBx2pETs=; b=afsSMI9Kj+WYfFCnsyZPJm7lSiRIuSreSgbnt3E1SvZV5K/LqwUSRoaULJ04G2TV3ce15OsrR7QhyeU2dVsiMJs6uc2l8yAVh2ES3l0GhmrBBYzCxb55y9inmyuTmRcsYg5oCRvRBX0pCShbWsKfVxK1xTxbWAs/2+orOEQJWiQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417909809571.4816073860336; Sat, 2 Aug 2025 16:58:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLhn-00007h-Rl; Sat, 02 Aug 2025 19:32:01 -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 1uiLgO-0006Tu-Jn for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:37 -0400 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgN-0004rr-7g for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:32 -0400 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-306b7eb492aso2040833fac.0 for ; Sat, 02 Aug 2025 16:30:30 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177430; x=1754782230; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kMQri4iirPxW00R1ccJFExnMIuYM+qTTYK6RBx2pETs=; b=v8HNIbN+U4CTTmuN5jgT4/dgj8FESShksQGGUD5vCXlSMyClaU2rZWTPyOh7SCgLoO mgFMtJthoPQzKwXr2ygtKxCFZOaqfRzFeSlczTVATzriycKb0sxV1HnUqIVMSEtQzjWt 63LtnLb2iZxpbymOtgG2BZXyP50Y109Te0euXrqFJcgSbV80od3cpuRLRybMbXKUyytm cd3Frb2Qhx6bzJ4Om+aeXG0fzH/FfqBU/qpIm9nF9I8bKJ9twSmI5234iWqWrbegTeCi eYlVVtpGjG35RvOKfRIthmLn+wiawDgHnVdN53BhS8goWDWAGEKb9LWuSKZgjjTMdCCb sAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177430; x=1754782230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kMQri4iirPxW00R1ccJFExnMIuYM+qTTYK6RBx2pETs=; b=nfRAvfPQbFeI8paLOhIAB7wDgXp1dMUfty6/h0YZPH51fPDdpCMMkgMdbf7hfhBF72 J43ho0q1ykmX0/EdJnEDZbpnWrMNgkeCoA4bOiDHu+bLSv5E7TAle/bfaVn5oxWCF/a5 EtjFSeU0tNGwNBjKxsfVVIvNncykYpAjmA20eHJ3tsrzeGr5Wz9geu+c4mqlVeXLfWgw KSxZgIzaUvjKq7AvKbr3oGP6ShuPSkjoLEkFxKl+ZZZ4Eorttxhsn9SYYTSg6YqorakQ WTY2PJvqjr2++6mT38Ff6PmW2rPAKd/du4tuEwNDSKPisNOi0dRjH9RPlwvM7A3QrQ9k GOfw== X-Gm-Message-State: AOJu0YwdykdAQL9Il9nJ76VPzfwKOpki5h1wKQLKDS79bdFrQ58VQQe5 DHkViXAXw8J51malA0L+J+d6PC0XwX6LPDu3ze9ztzIbzzAjduCUk7aHnZDyoPcPfATpKaPwQYb ITNsfxso= X-Gm-Gg: ASbGncs349OISQrUAZp5pDos9Gfin3NsYTHu6mizfZLYA6ZSC5wwIID5/6PesAGj+7H cv6Mz7Iu3fMVina0VkhgdnCq+diG4V9Hfz+ZMo5AhJ8Hp5DjEYm5Md1tkkzcCCBHWlGt+6nJ966 lkPQ5AZfXt/AQZoKsiGVwJNpOKlW2JT2oR7+momzeCjF/WGvSDfvqVn+CVkqBf+mC1t8GSj+r+4 QQAtu47GvHR/EexguMYgX4kQ89GMDcbhCjFmdnQXksjNGSqQH3dfXIz5s3G+OSCsR+mVeTLaiAG kVTLdh0Y0UKyiSTyhvu6hVL/XpZlvJ5jcl+/uJtXeRbonHTABbHyePVDkN3CPlfUQJSIrkuuF32 aDEHEjs5hKqx1Kh018lRxLgWxHj/hKDYnloAMLb6NMy2WIINzWxbb3L18c6j3G0E= X-Google-Smtp-Source: AGHT+IGY/FToaI9Fxd/xqCVVMkIdnVnqNNpQAdXqKF/jyQpvFUtOvYIaYlQeE3PnPQUEogADRJujNA== X-Received: by 2002:a05:6871:741e:b0:2d9:8f98:b0cd with SMTP id 586e51a60fabf-307aa67e16dmr7214228fac.10.1754177430052; Sat, 02 Aug 2025 16:30:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 06/85] target/arm: Skip permission check from arm_cpu_get_phys_page_attrs_debug Date: Sun, 3 Aug 2025 09:28:34 +1000 Message-ID: <20250802232953.413294-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::32; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x32.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179100505124100 Content-Type: text/plain; charset="utf-8" Do not require read permission when translating addresses for debugging purposes. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/ptw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 1b90e33f52..c7db93b95c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3646,7 +3646,7 @@ static hwaddr arm_cpu_get_phys_page(CPUARMState *env,= vaddr addr, .in_mmu_idx =3D mmu_idx, .in_space =3D arm_mmu_idx_to_security_space(env, mmu_idx), .in_debug =3D true, - .in_prot_check =3D PAGE_READ, + .in_prot_check =3D 0, }; GetPhysAddrResult res =3D {}; ARMMMUFaultInfo fi =3D {}; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177621; cv=none; d=zohomail.com; s=zohoarc; b=Q3I4c/AqafAZS25PxvWYNNbUEpt+Fg+H+sBepfIsQEi+JmWjcljTn/0hvowtiRcNtV3HJUG8M5D9XX1kaNdeVX/ln/iVTiR+CdNPCK6ur3QK68tqFF55W3YvPUvPREKHSIXihnoQ+zY0CT6egoRgykUPIVFkyV/c5DjBv6hd5e4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177621; 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=ZozRqgl1Uc77xaTQQdsLXzgeEe/cos7TSzVU6j/Q3E0=; b=KnOTyJ690kNZAk36rBWVkCfZEGbNyBBnMKI1bhHR2i+TAvXNQ7wHuc5b1knUqkXZEpws3UV3Cy5/cm+6TkMXyBDGFW4YIcJtBGcq6q/m0SM7BIQQHMqYrfyhwLpRqZ9XLikxO5y+XwMhlO4msRMSM1iwfBSVdvoqpvIiz6hMqq0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177621903475.04262490036183; Sat, 2 Aug 2025 16:33:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLi6-0000rl-FU; Sat, 02 Aug 2025 19:32:22 -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 1uiLgU-0006bh-WF for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:41 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgR-0004sQ-LM for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:38 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-2eb5cbe41e1so2561244fac.0 for ; Sat, 02 Aug 2025 16:30:35 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177434; x=1754782234; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZozRqgl1Uc77xaTQQdsLXzgeEe/cos7TSzVU6j/Q3E0=; b=MnF4eWivLVIVToT9o7g0bqlw+2eoIwPoJzneJ9g5BQqG7815iOrXm1aR6VIt6tupa7 1CL8JPkFSOYPJcg4RAn3olQnx7Nvtyy7zk5ZdBHkFp2dhtVwMTQa35z28meqAcuKyydp 7UANjrfj4OeKmvVN14Vi51DhvvIKzMWeDN6mwM2tSrBESKvIP1XeIrBWcxFODoiZO2bW LBUx3o1mdnmvKLtoBCoKRw2WLYeA3AYvMBahbOIWZgJ5xDzqpFUnDrOIfw7+bMR7rYv3 xYFBZApAxd441qWDKCGgHgL4jkx7mrHAer34JNY1P5ZLg53alLRzw7iTrOn0IysnE+tj fC3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177434; x=1754782234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZozRqgl1Uc77xaTQQdsLXzgeEe/cos7TSzVU6j/Q3E0=; b=EFYq2g1rRtAsDnrfZbRYm+UWD+wy9E1ctoQl09AYq//lAY/n298S32Bi3I4cn6/nFB Q+S9ATiFA1+uxon56JwO9QNPTrEBMuSv9WpjmkYvqwj9BLkcSsuhLhSQYqp4pM8hZRVh k3Nd4nazjK3fNZzh0mLgeP6fTtdt6r4g80FDBK/JFXAfSrB3pMO9zQoLq7tzQu266IaL OOV6a222fz5JWOEjB1p/O/H+eGCmsmgvNZcV38CGauC9q73bqFv2x/LywPfNMC1UPzYV 19rVs80b6PZenFOoBOdk3nhNfQJMs7ggTq5fjAfdW0HtWg2XvyDKthMpUfYICbzWQAOo eWng== X-Gm-Message-State: AOJu0YxXBRoMV6OpMO+CcUfAahIm9GIbXys3uvSqONWPu4EkR82WnByR 07EjeGfXmFH3z4Qw7LuSGfqXk4WPc6nnyu13/iEtvxweAy2Eqv+r+BjoT8sUAhbs9+MkvZgkcGf K0PggGuY= X-Gm-Gg: ASbGncvO3LsXoNrPqyMwdYynReTUVvkWshHFcaje+ikxOQHKeZZlLzhXSA99sFaCZJc pb8rLawlCpHdm/zXzRTtuT334P3ac7RKDpIDue0BwtVfxfxJ5JBJJ2GPux+uCdE4SIcuN/oeHQt 5qQksAI80HCNS8HCUukhkyrgviH/aSnLbebdGLcB/WTeTtBqtL3EhccuzHpuQpwqDZUerDSfa7W 0c+A2QgHGzX2/X7pGUp1YbwqE4sGYriuDPgO/W1x9ubyG4ALcaH4rHGtOQWlmTqvFTCNDtWMeCZ OdwkztOXxNDe8nC/8C/QpfiLcNM3u4QM5PR3Ah6IUPsVQajsBOoy9Cj9xC53CC6deFk/WoFTevb QVM9Rh7q6YpYGsIr4iN93ZfrO+gknN/tSUHx5PSRGwmCFWMLn7qhY X-Google-Smtp-Source: AGHT+IEsQa8N32uLyrMc9FcxUdKAzuVT8RsbyY1uReLRsbWqGHoq9wzHwuoYx51Dxk69pQwRCbCCJQ== X-Received: by 2002:a05:6870:3328:b0:2d5:296d:4ed4 with SMTP id 586e51a60fabf-30b67a106admr2713043fac.28.1754177434118; Sat, 02 Aug 2025 16:30:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 07/85] target/arm: Introduce get_phys_addr_for_at Date: Sun, 3 Aug 2025 09:28:35 +1000 Message-ID: <20250802232953.413294-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2c; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2c.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177624827124100 Content-Type: text/plain; charset="utf-8" Rename get_phys_addr_with_space_nogpc for its only caller, do_ats_write. Drop the MemOp memop argument as it doesn't make sense in the new context. Replace the access_type parameter with prot_check. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 18 +++++++----------- target/arm/ptw.c | 21 ++++++++++++++------- target/arm/tcg/cpregs-at.c | 11 ++--------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 326b5a73cf..0dd1b214c8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1604,25 +1604,21 @@ bool get_phys_addr(CPUARMState *env, vaddr address, __attribute__((nonnull)); =20 /** - * get_phys_addr_with_space_nogpc: get the physical address for a virtual - * address + * get_phys_addr_for_at: * @env: CPUARMState * @address: virtual address to get physical address for - * @access_type: 0 for read, 1 for write, 2 for execute - * @memop: memory operation feeding this access, or 0 for none + * @prot_check: PAGE_{READ,WRITE,EXEC}, or 0 * @mmu_idx: MMU index indicating required translation regime * @space: security space for the access * @result: set on translation success. * @fi: set to fault info if the translation fails * - * Similar to get_phys_addr, but use the given security space and don't pe= rform - * a Granule Protection Check on the resulting address. + * Similar to get_phys_addr, but for use by AccessType_AT, i.e. + * system instructions for address translation. */ -bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, - MMUAccessType access_type, MemOp memop, - ARMMMUIdx mmu_idx, ARMSecuritySpace sp= ace, - GetPhysAddrResult *result, - ARMMMUFaultInfo *fi) +bool get_phys_addr_for_at(CPUARMState *env, vaddr address, unsigned prot_c= heck, + ARMMMUIdx mmu_idx, ARMSecuritySpace space, + GetPhysAddrResult *result, ARMMMUFaultInfo *fi) __attribute__((nonnull)); =20 bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, diff --git a/target/arm/ptw.c b/target/arm/ptw.c index c7db93b95c..1866c494ef 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3545,18 +3545,25 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1T= ranslate *ptw, return false; } =20 -bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, - MMUAccessType access_type, MemOp memop, - ARMMMUIdx mmu_idx, ARMSecuritySpace sp= ace, - GetPhysAddrResult *result, - ARMMMUFaultInfo *fi) +bool get_phys_addr_for_at(CPUARMState *env, vaddr address, + unsigned prot_check, ARMMMUIdx mmu_idx, + ARMSecuritySpace space, GetPhysAddrResult *resul= t, + ARMMMUFaultInfo *fi) { S1Translate ptw =3D { .in_mmu_idx =3D mmu_idx, .in_space =3D space, + .in_prot_check =3D prot_check, }; - return get_phys_addr_nogpc(env, &ptw, address, access_type, - memop, result, fi); + /* + * I_MXTJT: Granule protection checks are not performed on the final + * address of a successful translation. This is a translation not a + * memory reference, so MMU_DATA_LOAD is arbitrary (the exact protecti= on + * check is handled or bypassed by .in_prot_check) and "memop =3D MO_8" + * bypasses any alignment check. + */ + return get_phys_addr_nogpc(env, &ptw, address, + MMU_DATA_LOAD, MO_8, result, fi); } =20 static ARMSecuritySpace diff --git a/target/arm/tcg/cpregs-at.c b/target/arm/tcg/cpregs-at.c index 398a61d398..2ff0b3e76f 100644 --- a/target/arm/tcg/cpregs-at.c +++ b/target/arm/tcg/cpregs-at.c @@ -27,19 +27,12 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t= value, MMUAccessType access_type, ARMMMUIdx mmu_idx, ARMSecuritySpace ss) { - bool ret; uint64_t par64; bool format64 =3D false; ARMMMUFaultInfo fi =3D {}; GetPhysAddrResult res =3D {}; - - /* - * I_MXTJT: Granule protection checks are not performed on the final - * address of a successful translation. This is a translation not a - * memory reference, so "memop =3D none =3D 0". - */ - ret =3D get_phys_addr_with_space_nogpc(env, value, access_type, 0, - mmu_idx, ss, &res, &fi); + bool ret =3D get_phys_addr_for_at(env, value, 1 << access_type, + mmu_idx, ss, &res, &fi); =20 /* * ATS operations only do S1 or S1+S2 translations, so we never --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177755; cv=none; d=zohomail.com; s=zohoarc; b=gpiR7FgUiZzS7t8NQOdD77lsF17Nq+Tl3XeMTlr2D41DT3+q0bw/Z8RAM24meKfTf58Ytchzsj0MXXmjp9PpHx94DqxjkHSu+MvGY6L9hBAsfG8PFy3+e10mPgRdMXjvMdqrh+3fMZemp0fNGUpoYrUrBMQlsseiUUrnTHjSsGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177755; 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=FnUxL1l7S/Ogxnuq3Rb6QT2pyV+tUJh+XdG2c+057PU=; b=SVbdHHzbyNNQFPHrCjkZuSFnL/UpmArcW9tRSnqj67zQpwwvo/wxCyC1GZyH0rlZeZEZhaiBg3HQaZDVDq0Qykl6bSBWKse9xLXxy0/bzAJUE7R6U4j3LK51n8I4BU2xxVffPxDEz2wy3/osZHtprExh4er9KQ9dB/XDEpj8J2g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177755061720.278121103088; Sat, 2 Aug 2025 16:35:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLhh-0008KX-1S; Sat, 02 Aug 2025 19:31:54 -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 1uiLgX-0006f6-Hq for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:41 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgV-0004sv-TG for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:41 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-301a83477e5so2806322fac.1 for ; Sat, 02 Aug 2025 16:30:39 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177438; x=1754782238; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FnUxL1l7S/Ogxnuq3Rb6QT2pyV+tUJh+XdG2c+057PU=; b=qYnjF8iwUZd+22UOyM/LPOOz3R6DTwT4qypIf+7F0o5EoE3cZukr2PmFqsUIWAO0kr MAJs39QszrvARlcXlNq/H+IlcYDTtVj9CEFBZvAVjzfmOT4X6KbdArCnlDdFWS3eOk/K YNXfzIcS0nX6ECXXXVg4HSO1LjMXIQPhEbxSn9i7MQoB0tlWPXUQ74bwG3/1MPcrObC7 GI9wIZxmWRzHiMGtKvFFOTCE+6QP+ipNn643qGNZ/kapd1NU1cB8j8CPF3LGiGNl0DEK KO5btQmwOg8RJKUaIIdG3n4sdwYO9dkLopYD8/LAHKYPGLjbJmOonJeFaEKIiYNTSx/L 5n1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177438; x=1754782238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FnUxL1l7S/Ogxnuq3Rb6QT2pyV+tUJh+XdG2c+057PU=; b=NvCX++Y2JUUooN33TkH4NDY+1E2ojt0MXdR3pJTIglKguXOcogdVOofEJqcwTWKby/ JEKlbPkmcW/+DzG+LGXY6NFOaxmTI4uW6jbjd2hsTB56uXKUrlzJES/QlJyFUoacYP0C j6TTh5vcmS2/OAYSTF6TYx2xHxGr4nkwlSw+2eX8csz1du8aFJS1IMjIaTGK2y3KSqXW OU1XVWI+LtdI1agRlHEoACwrFrR/0/j4q04AhGENHQYeuHrAgmUdOJxD/TuKG7+UKCra oWgbUKP6pAnkcWxJG2pwSpDLvLFZqbqTrO3RvUm8fxkv+2WRTUfDCiJQZ+HJXZ1D4Dra lLmg== X-Gm-Message-State: AOJu0YyvfIIR4S4cpkwPct23Bk32qYX4isIiMabal6+EwjWIKDyhrUCC DqtblMX5/Iy91Nvv5hpGxCvKUpwvWK75GTGXex+6Rxe2+S7zgKuACFoRMn86NaZu+TBF77EMdmy MSi+eFg8= X-Gm-Gg: ASbGncshNjdcbk7qXZDyAOJBgUpzvetZklbyp0fr45O7lS+8XpdCv3zPThD9+D+Vo8y iq329+kBWkv54GugD1kKHHep2Lx2EbEOSUVC8UHJCx040+VKK55JFodueHRyhqiW/1NpHUOxXCc EyGk6XsSXqlYJ4RFUaVhM0iklMf/cRAFQAEHdIBH3VNWy4WnNfcl8An9Jk39oEomPpaEu1qdupC j1U0NqZyPdzT3VDEDewyW2bfPloaHlIjFmOEBRFAvfxBM31naa7Gq7QdYKndR6PTTkB1/0WSrPe MjqMBvsMTzqqrw+BdlG0fBLF+Tuj5yhIFOp8WdZ3wTzFrBpHjOKagCA+HzvKN/E2iKTgN8kucvi G1FV3cjBX7qCX/7oQIWcFFwVCjIBLcg+5jFSXpjdNvyl4dEhPVeJey581okhQesU= X-Google-Smtp-Source: AGHT+IHoiu6XO5QRvLVQQTNGMtzF4JzaCSclU5xAcnXUA2FCeurFHBRdoFP9byfWuBF8Evciwx1obg== X-Received: by 2002:a05:6871:a701:b0:30b:85a0:eb66 with SMTP id 586e51a60fabf-30b85a14575mr529391fac.12.1754177438431; Sat, 02 Aug 2025 16:30:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 08/85] target/arm: Skip AF and DB updates for AccessType_AT Date: Sun, 3 Aug 2025 09:28:36 +1000 Message-ID: <20250802232953.413294-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177756181124100 Content-Type: text/plain; charset="utf-8" We are required to skip DB update for AT instructions, and we are allowed to skip AF updates. Choose to skip both. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/ptw.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 1866c494ef..efbad7af1f 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -58,6 +58,12 @@ typedef struct S1Translate { * and will not change the state of the softmmu TLBs. */ bool in_debug; + /* + * in_at: is this AccessType_AT? + * This is also set for debug, because at heart that is also + * an address translation, and simplifies a test. + */ + bool in_at; /* * If this is stage 2 of a stage 1+2 page table walk, then this must * be true if stage 1 is an EL0 access; otherwise this is ignored. @@ -1929,7 +1935,12 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); =20 - if (likely(!ptw->in_debug)) { + /* + * For AccessType_AT, DB is not updated (AArch64.SetDirtyFlag), + * and it is IMPLEMENTATION DEFINED whether AF is updated + * (AArch64.SetAccessFlag; qemu chooses to not update). + */ + if (likely(!ptw->in_at)) { /* * Access flag. * If HA is enabled, prepare to update the descriptor below. @@ -3553,6 +3564,7 @@ bool get_phys_addr_for_at(CPUARMState *env, vaddr add= ress, S1Translate ptw =3D { .in_mmu_idx =3D mmu_idx, .in_space =3D space, + .in_at =3D true, .in_prot_check =3D prot_check, }; /* @@ -3653,6 +3665,7 @@ static hwaddr arm_cpu_get_phys_page(CPUARMState *env,= vaddr addr, .in_mmu_idx =3D mmu_idx, .in_space =3D arm_mmu_idx_to_security_space(env, mmu_idx), .in_debug =3D true, + .in_at =3D true, .in_prot_check =3D 0, }; GetPhysAddrResult res =3D {}; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177585; cv=none; d=zohomail.com; s=zohoarc; b=BmEDBH9EhJHAOMDB4T5mHn8Agcx+2UGEzrok6up/aD2n9wxuSWSAlkGmZOHF3jkTYLyKkWKSrj9RjdYzJF4n+i5xphRVYdeIknCNITSKceOlbGXC43/HjYyl5EOc0VJixNZKz4WVwjJ3Y4SQbOPaB/yhz91BtvuQIHsaZGJkZoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177585; 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=DZyOZ5ibz8YB1lWsiaU/JxXFHwk/vo9PWaKWI3jDReA=; b=ULjT1pFvbxybhosFIUClK7NanilzGXLmYlfV1P9FsWIe4Dr5/itB7He2T1XffQu5Sa3DT9Map+H7DEg/cupnHMM4Y53FzzxkyDVW7zRsdzno9J51bLm/daa+wx0B0bkvgFUC/py/ly1voZFCvCzG2IpHGTB67bMX/oTu/ffvbxU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177585756896.5584050041352; Sat, 2 Aug 2025 16:33:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLhP-0007hx-50; Sat, 02 Aug 2025 19:31:35 -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 1uiLgb-0006mK-Cg for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:46 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgZ-0004uG-MW for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:45 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-2ffa1b10918so1987953fac.2 for ; Sat, 02 Aug 2025 16:30:43 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177442; x=1754782242; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DZyOZ5ibz8YB1lWsiaU/JxXFHwk/vo9PWaKWI3jDReA=; b=ljhohh4J2Lqd0KBNZeqNClgRpYb/6IAsExY0XRr+s7qLlNzlTWGTY+VAIkFznOKB8F 0NXq8m5s1zIdZcgqwNF8SszVASrwiohzVtN7qlIN5U1ybiUt/uN4S8U2BRmoh6h9mQdO JJXL5zB5rGH7vaPsVBVKfqMtBSWa6RVf1CTNkrIsBHoJ0+rcMgzvL5mbe5zv1YWTqMtx X6oM4lAL5tPgoJH5NgPnaq+ttMSnX5aFdSwPWCmQeezJ/HdOeaoIZXWR0cLF7l2MY2N9 Tt3gVN/iolRud+WqbAdOGlsqLVCDsSaZ/N1HhZHiHrJmKNcWN+2inZ0+AG1WHyfoK1Xj 53YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177442; x=1754782242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DZyOZ5ibz8YB1lWsiaU/JxXFHwk/vo9PWaKWI3jDReA=; b=N3eT/UYkAfnFyRXbemZrRc7KC0y6G/HvRsu8QV0v3Kn1sMDqzmwmTD47FYvPyzpZof Lj6pW405kFKKssNM3cNMGdXw6VGVIccmYiWDvWj1u5Z3w2KbZvsGTx4SInGfjXqvzXQY 3QjcNIZVqG4NFogIrpe/zwsr4KkxsOPlkOELNgqAt0eymeh9JoLcN/6Lt6HSOPq1w9ZF c0cZtcNKt5GowRNLEuLF9FOXGS4k+7K1TBkbRxiTHMSFLgwoNYzj9ABuiyG+Q8DRUKyh 4+yh4tsIihVL7m5x4bXbcZPywLXoWzKTTEUzVhrhXJ64Y0z/aNivgpif0BKLPz+klGDi kO+Q== X-Gm-Message-State: AOJu0Yxpgy/jvqOfL0cX/hklOyoHIJ3sx4yIawbs3UKzwmK8WW1a6IEC jIGJB2g9OPv3mzyjm8UOSzlU5kJoifN2gQKetWeLeqnTKzWuVLsElMH3IBtdpAPWrVfIwe3o61G CKJf/SOU= X-Gm-Gg: ASbGncvyOWlIrkJdKwfiP9go0V6uYUEm3t+PsEzc7uDTQU2W9maEdyeW5tyYH4qPXTy vmyB5qLHUPqRpFEtQ6O7edQNUfR/t7XvQCY3bh8/NiVo/El6ZZ/Bp5isat8Isndcf0/o44+evYn laHLEEcAdeFSJz42BmMwGzhVRFLgZ5X//t74bdQwbgSwZY0/s+11V65NSCgfdd+ixllRTpRUXAf dIiJ9lXYsk9+6CXFuJwO13G6ks6Gw/rFp8kwz/GhnuquvnPPfhEUsD1fJr6Xysa307blleImZ2x y9xP1zQqQUSKi6JkYmv0+zF/QwsDDaROAfEWI8Q30DpsPthdDUtmKXR673VsgvghMCfQpQ65DxL IUfMx/Cg44zuQT+DTKGjXc/1pSV/BYaCpoxHMPrH+26Ivp010HZ+HeWpCNY/Egns= X-Google-Smtp-Source: AGHT+IGukVB1JlVARvWQrAXUEnSCP+hxMp5H/nbHFMvlGxrtokoaFRwEciLa155NexkoY30F3VWxNg== X-Received: by 2002:a05:6870:b60b:b0:2df:a9d0:1dc9 with SMTP id 586e51a60fabf-30b67be9669mr2676103fac.37.1754177442506; Sat, 02 Aug 2025 16:30:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 09/85] target/arm: Add prot_check parameter to do_ats_write Date: Sun, 3 Aug 2025 09:28:37 +1000 Message-ID: <20250802232953.413294-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::30; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x30.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177586224116600 Content-Type: text/plain; charset="utf-8" Separate protection check from access type, in preparation for skipping the protection check altogether. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/cpregs-at.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/arm/tcg/cpregs-at.c b/target/arm/tcg/cpregs-at.c index 2ff0b3e76f..bebf168997 100644 --- a/target/arm/tcg/cpregs-at.c +++ b/target/arm/tcg/cpregs-at.c @@ -24,14 +24,14 @@ static int par_el1_shareability(GetPhysAddrResult *res) } =20 static uint64_t do_ats_write(CPUARMState *env, uint64_t value, - MMUAccessType access_type, ARMMMUIdx mmu_idx, + unsigned prot_check, ARMMMUIdx mmu_idx, ARMSecuritySpace ss) { uint64_t par64; bool format64 =3D false; ARMMMUFaultInfo fi =3D {}; GetPhysAddrResult res =3D {}; - bool ret =3D get_phys_addr_for_at(env, value, 1 << access_type, + bool ret =3D get_phys_addr_for_at(env, value, prot_check, mmu_idx, ss, &res, &fi); =20 /* @@ -191,7 +191,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t= value, =20 static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t v= alue) { - MMUAccessType access_type =3D ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA= _LOAD; + unsigned access_perm =3D ri->opc2 & 1 ? PAGE_WRITE : PAGE_READ; uint64_t par64; ARMMMUIdx mmu_idx; int el =3D arm_current_el(env); @@ -253,7 +253,7 @@ static void ats_write(CPUARMState *env, const ARMCPRegI= nfo *ri, uint64_t value) g_assert_not_reached(); } =20 - par64 =3D do_ats_write(env, value, access_type, mmu_idx, ss); + par64 =3D do_ats_write(env, value, access_perm, mmu_idx, ss); =20 A32_BANKED_CURRENT_REG_SET(env, par, par64); } @@ -261,11 +261,11 @@ static void ats_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - MMUAccessType access_type =3D ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA= _LOAD; + unsigned access_perm =3D ri->opc2 & 1 ? PAGE_WRITE : PAGE_READ; uint64_t par64; =20 /* There is no SecureEL2 for AArch32. */ - par64 =3D do_ats_write(env, value, access_type, ARMMMUIdx_E2, + par64 =3D do_ats_write(env, value, access_perm, ARMMMUIdx_E2, ARMSS_NonSecure); =20 A32_BANKED_CURRENT_REG_SET(env, par, par64); @@ -309,7 +309,7 @@ static CPAccessResult at_s1e01_access(CPUARMState *env,= const ARMCPRegInfo *ri, static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - MMUAccessType access_type =3D ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA= _LOAD; + unsigned access_perm =3D ri->opc2 & 1 ? PAGE_WRITE : PAGE_READ; ARMMMUIdx mmu_idx; uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); bool regime_e20 =3D (hcr_el2 & (HCR_E2H | HCR_TGE)) =3D=3D (HCR_E2H | = HCR_TGE); @@ -352,7 +352,7 @@ static void ats_write64(CPUARMState *env, const ARMCPRe= gInfo *ri, } =20 ss =3D for_el3 ? arm_security_space(env) : arm_security_space_below_el= 3(env); - env->cp15.par_el[1] =3D do_ats_write(env, value, access_type, mmu_idx,= ss); + env->cp15.par_el[1] =3D do_ats_write(env, value, access_perm, mmu_idx,= ss); } =20 static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179245; cv=none; d=zohomail.com; s=zohoarc; b=P0V/6Cqj4vptczZzYCiE5LbKsC8lAKTAWp8Jf6650JmU7h0ptRMQrZ7M2RIPKldLFvkI5UwBYxRwx00UyWJJcOeUYyl25XfpRVwPx9PEgyB3Ce9TuUjGXgeIgdIfHMhmGteqE4VYorUUEWV8hGtUEefqsO/ae1oIlZAu3lWugWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179245; 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=kEj8duxAu1Pam82WhtcHKlYlFMg89KDGm3ClOoILo48=; b=WwJp8uOa3RYvYcFhtOSVEAkcier/tyAtlno+FvzOKzzdV61U1lkbgdFM8GRNI8CS/X/usKISxNGrkRSli0rp2FInDrBUB8iPWRYB0ktqE0b2MF9Xx7jBGS0qBIIYAVmaul3/sVhsGY/ww8WJF3j+psDkV2V/Ol78Jut91khgoII= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179245146436.06888745121967; Sat, 2 Aug 2025 17:00:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLin-0002Ag-Mj; Sat, 02 Aug 2025 19:33:02 -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 1uiLgf-0006se-UY for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:50 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLge-0004uy-2S for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:49 -0400 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-741a254d4a0so892941a34.1 for ; Sat, 02 Aug 2025 16:30:47 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177447; x=1754782247; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kEj8duxAu1Pam82WhtcHKlYlFMg89KDGm3ClOoILo48=; b=u7PBaoiLD00XkhOppNWpjHjYFoa2x8Q3sjGjVTN+W3tPfwIB6Dzpaqpu0CnDuK57QK a1j6IfTkwBu4HYBTVzz7Pym0ZNeBbN7pLx1EbA7S6uyBDoidgXdm+NFrqp667jo+PQub 8CYUKPP6vvz2GbHusZrk994/MFoQGlSeE259+GTTQHELBFiNBQXIAsDQdByA/QNcTKLA EJgNw/RTEgT30+Rf+QGHwqnkMrR1cFSA2m8Erv67yauxqfiRB3wGm8Fx5A7F6KvA03QH NFxraefxvutlar6pVzISmiEwog6vOQ8qyJIxiG42FZHVgDlehGrfyRf6p6kOjWxkWpIM QA5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177447; x=1754782247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kEj8duxAu1Pam82WhtcHKlYlFMg89KDGm3ClOoILo48=; b=qTMvzsvQLYYRGwBXKYXTu7cqTScq7XK2oZF+Bs78eSyteGtTYIgbxmZ8qH/F5ZzgtH hmeiFo8DB/+s2Amd27VdrgJ90UzPXx0ak7fUsKFRoCzlVAHk78bb1b1VUyhoC0CbikOI HSZLHxmF/7riS4vz1ODmR73rCoI6mPGXHWMsVh8TkipXQt9wFlBZ0plk1AekfaEJtLdU Sk+UCS4383un/J6MBAnMXvXH4WUHgTt6ebU6NHXHIMM7ePJK8jhuqOjSGAp40R5i+mjB uhRxISmKq4mL7hkVVKxN4sLvFcs3NzCrkMk+ddjp66WNujR/v/5guHB/+7GPhNASp5ok DtJA== X-Gm-Message-State: AOJu0YySYq3cDebHG8GiURKjG5YGKcZARMLSLYeL5VwiUhOhvrYz3N7u YRoj+p+E+vIo0reGzS8giQzQsVj6PXDZyK63/qz8zA8VV0AGJ/r7kkbEdWlSPSTjLq9sfGGoP86 /MaFiQPw= X-Gm-Gg: ASbGncuWIyx5KOjyT44YFGPrZ7cm5ke86ZQm77KursOdrVo+HnlUrs3aJgziWZNRpZi xoiAH1NjN1ZPGLP4CNDfsn10s4fdzghfu3Q6CUkf3mLg3W0+MvorslUQg10Zo2nY4gDJEJT1oKm d2iMczNbpwpESWp49aJGw/tJtqagIQM9CazwMJIJJSiIG9CReFNMN5P8w9W0km+emcl6lOxorw9 tlHgDZeDS/ReIf+G1+eZrjuoohWgjCC5ml2YhGyozzewG728AUHV2o5hCGS/lqWPyLJ3mPYcTUI opCPOiNx7yiuO9fVV4gu2mDDnLc9hy1OJ+tg+EgXXfy7UFyB507mh772Us4hXhmAFY/6TL9Gyot fDwzVuGmcK7nCWInQxJ3jZWOFfKK+Ms2BXalFjf/ckug/k44OCeyN X-Google-Smtp-Source: AGHT+IHiqSeqoSJmoQQLzg0b/R7VSK1wiFSdieYogDifbx+Txeh56HuZ5yxKRJR46OjPVimEzix7SQ== X-Received: by 2002:a05:6830:600f:b0:73e:5540:730e with SMTP id 46e09a7af769-741879d7295mr7675745a34.4.1754177446714; Sat, 02 Aug 2025 16:30:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 10/85] target/arm: Fill in HFG[RWI]TR_EL2 bits for Arm v9.5 Date: Sun, 3 Aug 2025 09:28:38 +1000 Message-ID: <20250802232953.413294-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32e.google.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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UPPERCASE_50_75=0.008 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179246099116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index c9506aa6d5..1d103b577f 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -408,10 +408,19 @@ FIELD(HFGRTR_EL2, ERXPFGCTL_EL1, 47, 1) FIELD(HFGRTR_EL2, ERXPFGCDN_EL1, 48, 1) FIELD(HFGRTR_EL2, ERXADDR_EL1, 49, 1) FIELD(HFGRTR_EL2, NACCDATA_EL1, 50, 1) -/* 51-53: RES0 */ +/* 51: RES0 */ +FIELD(HFGRTR_EL2, NGCS_EL0, 52, 1) +FIELD(HFGRTR_EL2, NGCS_EL1, 53, 1) FIELD(HFGRTR_EL2, NSMPRI_EL1, 54, 1) FIELD(HFGRTR_EL2, NTPIDR2_EL0, 55, 1) -/* 56-63: RES0 */ +FIELD(HFGRTR_EL2, NRCWMASK_EL1, 56, 1) +FIELD(HFGRTR_EL2, NPIRE0_EL1, 57, 1) +FIELD(HFGRTR_EL2, NPIR_EL1, 58, 1) +FIELD(HFGRTR_EL2, NPOR_EL0, 59, 1) +FIELD(HFGRTR_EL2, NPOR_EL1, 60, 1) +FIELD(HFGRTR_EL2, NS2POR_EL1, 61, 1) +FIELD(HFGRTR_EL2, NMAIR2_EL1, 62, 1) +FIELD(HFGRTR_EL2, NAMAIR2_EL1, 63, 1) =20 /* These match HFGRTR but bits for RO registers are RES0 */ FIELD(HFGWTR_EL2, AFSR0_EL1, 0, 1) @@ -452,8 +461,18 @@ FIELD(HFGWTR_EL2, ERXPFGCTL_EL1, 47, 1) FIELD(HFGWTR_EL2, ERXPFGCDN_EL1, 48, 1) FIELD(HFGWTR_EL2, ERXADDR_EL1, 49, 1) FIELD(HFGWTR_EL2, NACCDATA_EL1, 50, 1) +FIELD(HFGWTR_EL2, NGCS_EL0, 52, 1) +FIELD(HFGWTR_EL2, NGCS_EL1, 53, 1) FIELD(HFGWTR_EL2, NSMPRI_EL1, 54, 1) FIELD(HFGWTR_EL2, NTPIDR2_EL0, 55, 1) +FIELD(HFGWTR_EL2, NRCWMASK_EL1, 56, 1) +FIELD(HFGWTR_EL2, NPIRE0_EL1, 57, 1) +FIELD(HFGWTR_EL2, NPIR_EL1, 58, 1) +FIELD(HFGWTR_EL2, NPOR_EL0, 59, 1) +FIELD(HFGWTR_EL2, NPOR_EL1, 60, 1) +FIELD(HFGWTR_EL2, NS2POR_EL1, 61, 1) +FIELD(HFGWTR_EL2, NMAIR2_EL1, 62, 1) +FIELD(HFGWTR_EL2, NAMAIR2_EL1, 63, 1) =20 FIELD(HFGITR_EL2, ICIALLUIS, 0, 1) FIELD(HFGITR_EL2, ICIALLU, 1, 1) @@ -512,6 +531,11 @@ FIELD(HFGITR_EL2, SVC_EL1, 53, 1) FIELD(HFGITR_EL2, DCCVAC, 54, 1) FIELD(HFGITR_EL2, NBRBINJ, 55, 1) FIELD(HFGITR_EL2, NBRBIALL, 56, 1) +FIELD(HFGITR_EL2, NGCSPUSHM_EL1, 57, 1) +FIELD(HFGITR_EL2, NGCSSTR_EL1, 58, 1) +FIELD(HFGITR_EL2, NGCSEPP, 59, 1) +FIELD(HFGITR_EL2, COSPRCTX, 60, 1) +FIELD(HFGITR_EL2, ATS1E1A, 62, 1) =20 FIELD(HDFGRTR_EL2, DBGBCRN_EL1, 0, 1) FIELD(HDFGRTR_EL2, DBGBVRN_EL1, 1, 1) --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178122; cv=none; d=zohomail.com; s=zohoarc; b=KCTobRmCObDPDVJ99W76Z6QDax9waTnShZYRHyQz4lGUzxHrlzoMNfInrdzEFheeSXHDJLBuUpskGS4iMI5ywbX8YkMzKLe2G3SO1wVZy2lOuGtVB7RgKJrj2osRrZkevQjD3Psu3mxkjpTdfEQ6wMqiFYAiYSfC5qmo4sQRkrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178122; 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=5pyV9I1ab5c29rW3qcGtq+wHa18CtHBS8e6ckAGh5og=; b=kEOxvUxvtFIWv8d2MFNh1F2CEtWseSXOU9jELLleVfMQ6wZQ6BxBWpGs+nJgjB90gKtJN8ToarQH6hcvX5AqRpZlmKtQPo7d26OqWo+faMQ7cN8pbrY/yGGXbH1NHdulQqE+ZSj6bjo8dixDeNkSGXFL/ZOU9Z8SAohU+9jI5VI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178122191698.7277137844831; Sat, 2 Aug 2025 16:42:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjO-00041l-JF; Sat, 02 Aug 2025 19:33:38 -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 1uiLgk-00072M-Rt for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:59 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgi-0004vx-7X for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:54 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-2ff9b45aec2so1829039fac.2 for ; Sat, 02 Aug 2025 16:30:51 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177451; x=1754782251; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5pyV9I1ab5c29rW3qcGtq+wHa18CtHBS8e6ckAGh5og=; b=ltYlW/hfaE1XZA4PUlT3M3SVDenRhUlW4X/xnNJ69yxi1C1mdG4FQPBqbhjnOEV+PP xCSVed0UKRCg6btAPzMFjrGsOyLdAp97DsGSch1Cv3RK+kEy6+DUBdPmiYWM5nuqIsB3 EwFu1I0dbZ2+vPV0O2AkuBIeBmMkecWl/cl+x3NQwSnFgqF36vtMX54a+cLpt3foz/X2 GSfuECkk0v54mpjJTYW1hzGiHw9CuAFjNspXfXS1OCgL+1ogSgki9rUvUSwm8UaBhZfT uis8xFovE0V3WTA1wWe3ZrgK477CWRmdk8emiTg9THkbHaGoKmW0doxz/XV2kRp7GnFO 658w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177451; x=1754782251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5pyV9I1ab5c29rW3qcGtq+wHa18CtHBS8e6ckAGh5og=; b=qPlXxa8/Px+4j7Rm4FMNtzgKvVCUEfBMaVzQ0ooCxkx+OEzmrtXDTwBMSPvJ5shTRq JWWwACMRKQQn0VX8FhU73znQPEzME5rVh3VjfxTZd/qhD0IVzKSdIRCMhrAE5eVROJGx NxblmvI6Hf2JRNWQdvhHoj6BSKGiEX8WnXOf5OwA0iiRMV4dCGykFXTV8vscERYevqIE mPfsCFuCn0NOKFwwCMpFRDVDMLFQvM2Kb8eyiU7wkUUPA+sWwmyucJCQ+rMHOirW0Ogr ddKnVkf7CDDHiXspGwOaWcId3lxVbf9rd6CRZ3biDgLSLRi1GNVms8QYDx31FNF552ZL LLcg== X-Gm-Message-State: AOJu0YwEJnSxrrDSHBF4w8GBrtfV/SoHUr8dA0+TsYB+qBDf7qxYCQxa rmrUYLt3hfsAWjlgE+V+FhnoOHsYytLczk1/8hHXt40aNtLpxxxp9HTvph3HeRgthvdHHv6HH1Z UQ+E1uKI= X-Gm-Gg: ASbGncuTFTNjR8WtbNffFNVDyyKi0rFlweB8jX9uMtsNPDkF98t/5xN84euePbNk9VX dHOJfYFQ4w6pJfKywoR1QfjCXZd+F5pHcQTPdzrsZBwcVKHX+FXyI6WaiHNZX70s6cyAIWIQTDq fudUXLICtVlCFj04rsuzl9oLH46+xhQjaKT04gzsI03TMBzTJEdPfpT6iyAYII9knfVWXFbl9l5 gaVfyhZSla47afdyQo2aRalpgOF3ZPES4ujrPuIQMmkrnqUOxEqJOSNdfcAAWdTzuuT/iiZxtan qlXw6l9X8BsqM3agysyMSakbkqy/Ohko3cWYdOvEEV8HqJgWmECIhgFJqurlSAGWtdmiECqYRVF 1xFofcRjgYVwMqbaGrvLri0mSbtfNM3+ClmKO8KR2+zNj58HqjB93 X-Google-Smtp-Source: AGHT+IH56x1gpC6ohR//suvmXWYZsOVjvQwT9pWymmz/BRTYFIzVmhJ6B1AIeKTVTdh56cqXNSGPIA== X-Received: by 2002:a05:6870:3516:b0:2e9:9e9:d94b with SMTP id 586e51a60fabf-30b67cbad99mr2688884fac.39.1754177451134; Sat, 02 Aug 2025 16:30:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 11/85] target/arm: Remove outdated comment for ZCR_EL12 Date: Sun, 3 Aug 2025 09:28:39 +1000 Message-ID: <20250802232953.413294-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178124138116600 Content-Type: text/plain; charset="utf-8" The comment about not being included in the summary table has been out of date for quite a while. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/helper.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 20b69a12df..dc6c82b7e2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4566,11 +4566,6 @@ static void define_arm_vh_e2h_redirects_aliases(ARMC= PU *cpu) { K(3, 0, 14, 1, 0), K(3, 4, 14, 1, 0), K(3, 5, 14, 1, 0), "CNTKCTL", "CNTHCTL_EL2", "CNTKCTL_EL12" }, =20 - /* - * Note that redirection of ZCR is mentioned in the description - * of ZCR_EL2, and aliasing in the description of ZCR_EL1, but - * not in the summary table. - */ { K(3, 0, 1, 2, 0), K(3, 4, 1, 2, 0), K(3, 5, 1, 2, 0), "ZCR_EL1", "ZCR_EL2", "ZCR_EL12", isar_feature_aa64_sve }, { K(3, 0, 1, 2, 6), K(3, 4, 1, 2, 6), K(3, 5, 1, 2, 6), --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177727; cv=none; d=zohomail.com; s=zohoarc; b=TQ3VJjrc+ld0LlGum8TUVt1wBCcbRdftGw/SKdrgi6MMjcs454XbDMxJ25xj2jb6EwVx19tzBZBeXx9Cb0/lKDMc90pPP9xF5T3aYpHWPtE8wuTUTRuG32yWUlqpfftJoRhM8PW/xYT7KUyK3O0eXC5rbHfUHdAjM6WJ0ilqeKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177727; 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=sHSDdWTCh8t1tRyRbP9Lg4R3+bQUPTmxLzxlpsJeaKQ=; b=icz1arADHb+5IaUwIxXb5LE4puePhmnJ9vN5NIkhF8RNrtn7OBhqjtcat7RhKuZrdKZk0iW8FbvM9kF6YgnsNy0S7M1Ng/jEpHc9L9ZjHHdbBfj3YQPqr8WDGtMNi0KDFEgKzZTB9TtD604xSsMYD2HVjw9fo7G3h9363En9mX0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177727872501.63634972263765; Sat, 2 Aug 2025 16:35:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjG-0003Rg-J6; Sat, 02 Aug 2025 19:33:30 -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 1uiLgo-00075R-Go for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:59 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgm-0004wu-O3 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:30:58 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-741a0ec1a05so314692a34.2 for ; Sat, 02 Aug 2025 16:30:56 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177455; x=1754782255; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sHSDdWTCh8t1tRyRbP9Lg4R3+bQUPTmxLzxlpsJeaKQ=; b=NHITojqfyD/7JuKhBWMqS4uh+l54mM4s7KCmnVGGXaP84NKXNO7+V4DpX6A6KFci+T gVasqipFyZ+pahRAuyC9UuxorNTYIxhf8IpgFUWlyLN1cltgdAJYqDVwUA4cvibwZcDS apN/2wQW/GFTSfkTvJCqMw9lvXWwDUJDOcCYMYgoOZL2AQia7zl3+oa/UMLGUGWY209z RtRttZ26MLi/L9+l7ya1zax7wuLu7fQIQ2WZieRY+GQw0axH3Nt5QYEmv39tgwGp4uea puBNcWGyXUUVBjWeMICAnxxQpZd5Wih4q6FrfWloyyg7LNV3OyCgsDZE08H+kSytWvbQ eiyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177455; x=1754782255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sHSDdWTCh8t1tRyRbP9Lg4R3+bQUPTmxLzxlpsJeaKQ=; b=aPbpC3ylc8UKWUi/suDNV6/GnH0uNFj8obbWSg7DWOLy+nPdUXDTEiN14tR0yiqXL7 eT2GrSHPBB8CLVsih7zl5FTgO3Q13Q1TaZYdKRZLCGfZ526bAGGspIslcFVtVsZvcaBJ IUn5FE7EhjUSQRqAky13TYavOkZLjIzR423mSDky12IpocTy8dWA+ZsDe9hTBqu4R8VK kecwxdnjTtvMusGrDzRozSKVnmgXW6GixvbQftF+jOKx4afc19qpIrLIJcaYhl3qlzU2 HZzmDzBghS9v8+yWBRIzMEkMIY+xRdLZmyJIPqHAbF4uXK3xCJpUVwdYZgO9Ek1MuCG/ hF2A== X-Gm-Message-State: AOJu0YxSrSZ27bvlz1w7tYWU4G5LK2RsFY0G+NLH2I9Ulzzu3QMFWzkI t/lFnV0MCpFhEw2D4pmFJoweszSrgAv3zLnbl0gxWpPyajyIDXAmV4Vr5ULy0W+t76WWaeCU1zO CklK/Ilk= X-Gm-Gg: ASbGncvzynkd/3DYtT3cmwbTCfZVN7Xxvh3F0cqL80OtrCNE8cvYtXh/5/JZIL5sClB cBiF2h6O7Ez7mxbxvFdG5ktyLh5TkldHkk3qri3C0L4nOdUpgPUtWSWREkQJ1/R7AbFvUPFZD3C /dsKi+ISwp0OzTI/0xnQlPC8xlqj1aDkM3a/RRYrYUY5Fd3F0U+7NefxS2siF0jt/A+OEzZ1zJP /pUVheIXTH0sar5NRfhXpzn3/RVPI9w/Xb5zqSd4jdps4nuS1ffCUkgcPg1Mu6SJQmbNChlZRAW /F/eBe0s5TTHPHm3ianbqZqQn8dYkTltVJO/KuvOHq7AN4XBh2kH9/SGEQ5Komhmk2BKYc2uBy5 mnnO+3h8TIN5GWlpvPoDRvURWqPr/j5X/qqyZjmxHDeljA5BtRmQRn9v0gpliqOw= X-Google-Smtp-Source: AGHT+IELt0Oz9KTDk+skBjyGwaYpTxm/F5fV5PMbq2QMVVKUg9W/yGstx+UoIJfXjW+xJyw2crovjQ== X-Received: by 2002:a05:6871:522a:b0:306:a149:f4c0 with SMTP id 586e51a60fabf-30b6780dc5amr2706607fac.23.1754177455512; Sat, 02 Aug 2025 16:30:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 12/85] target/arm: Implement FEAT_ATS1A Date: Sun, 3 Aug 2025 09:28:40 +1000 Message-ID: <20250802232953.413294-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177729930124100 Content-Type: text/plain; charset="utf-8" Implement FEAT_ATS1A and enable for -cpu max. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpu-features.h | 5 ++++ target/arm/tcg/cpregs-at.c | 44 +++++++++++++++++++++++++++++++++++ target/arm/tcg/cpu64.c | 1 + docs/system/arm/emulation.rst | 1 + 5 files changed, 52 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 1d103b577f..2a4826f5c4 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -854,6 +854,7 @@ typedef enum FGTBit { DO_BIT(HFGITR, DVPRCTX), DO_BIT(HFGITR, CPPRCTX), DO_BIT(HFGITR, DCCVAC), + DO_BIT(HFGITR, ATS1E1A), } FGTBit; =20 #undef DO_BIT diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 9579d93cec..7f2ca51b4c 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -609,6 +609,11 @@ static inline bool isar_feature_aa64_lut(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR2, LUT); } =20 +static inline bool isar_feature_aa64_ats1a(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64ISAR2, ATS1A); +} + static inline bool isar_feature_aa64_fp_simd(const ARMISARegisters *id) { /* We always set the AdvSIMD and FP fields identically. */ diff --git a/target/arm/tcg/cpregs-at.c b/target/arm/tcg/cpregs-at.c index bebf168997..0e8f229aa7 100644 --- a/target/arm/tcg/cpregs-at.c +++ b/target/arm/tcg/cpregs-at.c @@ -488,6 +488,47 @@ static const ARMCPRegInfo ats1cp_reginfo[] =3D { .writefn =3D ats_write }, }; =20 +static void ats_s1e1a(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t v= alue) +{ + uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); + bool regime_e20 =3D (hcr_el2 & (HCR_E2H | HCR_TGE)) =3D=3D (HCR_E2H | = HCR_TGE); + ARMMMUIdx mmu_idx =3D regime_e20 ? ARMMMUIdx_E20_2 : ARMMMUIdx_Stage1_= E1; + ARMSecuritySpace ss =3D arm_security_space_below_el3(env); + + env->cp15.par_el[1] =3D do_ats_write(env, value, 0, mmu_idx, ss); +} + +static void ats_s1e2a(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t v= alue) +{ + uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); + ARMMMUIdx mmu_idx =3D hcr_el2 & HCR_E2H ? ARMMMUIdx_E20_2 : ARMMMUIdx_= E2; + ARMSecuritySpace ss =3D arm_security_space_below_el3(env); + + env->cp15.par_el[1] =3D do_ats_write(env, value, 0, mmu_idx, ss); +} + +static void ats_s1e3a(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t v= alue) +{ + env->cp15.par_el[1] =3D do_ats_write(env, value, 0, ARMMMUIdx_E3, + arm_security_space(env)); +} + +static const ARMCPRegInfo ats1a_reginfo[] =3D { + { .name =3D "AT_S1E1A", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 9, .opc2 =3D 2, + .access =3D PL1_W, .type =3D ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .fgt =3D FGT_ATS1E1A, + .accessfn =3D at_s1e01_access, .writefn =3D ats_s1e1a }, + { .name =3D "AT_S1E2A", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 7, .crm =3D 9, .opc2 =3D 2, + .access =3D PL2_W, .type =3D ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .accessfn =3D at_s1e2_access, .writefn =3D ats_s1e2a }, + { .name =3D "AT_S1E3A", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 7, .crm =3D 9, .opc2 =3D 2, + .access =3D PL3_W, .type =3D ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .writefn =3D ats_s1e3a }, +}; + void define_at_insn_regs(ARMCPU *cpu) { CPUARMState *env =3D &cpu->env; @@ -509,4 +550,7 @@ void define_at_insn_regs(ARMCPU *cpu) if (cpu_isar_feature(aa32_ats1e1, cpu)) { define_arm_cp_regs(cpu, ats1cp_reginfo); } + if (cpu_isar_feature(aa64_ats1a, cpu)) { + define_arm_cp_regs(cpu, ats1a_reginfo); + } } diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index c54aa528c6..22ccc4f697 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1178,6 +1178,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64ISAR2, MOPS, 1); /* FEAT_MOPS */ t =3D FIELD_DP64(t, ID_AA64ISAR2, BC, 1); /* FEAT_HBC */ t =3D FIELD_DP64(t, ID_AA64ISAR2, WFXT, 2); /* FEAT_WFxT */ + t =3D FIELD_DP64(t, ID_AA64ISAR2, ATS1A, 1); /* FEAT_ATS1A */ SET_IDREG(isar, ID_AA64ISAR2, t); =20 t =3D GET_IDREG(isar, ID_AA64PFR0); diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index d207a9f266..1489c262b8 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -23,6 +23,7 @@ the following architecture extensions: - FEAT_AFP (Alternate floating-point behavior) - FEAT_Armv9_Crypto (Armv9 Cryptographic Extension) - FEAT_ASID16 (16 bit ASID) +- FEAT_ATS1A (Address Translation operations that ignore stage 1 permissio= ns) - FEAT_BBM at level 2 (Translation table break-before-make levels) - FEAT_BF16 (AArch64 BFloat16 instructions) - FEAT_BTI (Branch Target Identification) --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179169; cv=none; d=zohomail.com; s=zohoarc; b=JdJeLF52ZxWbe5+0LQyB3dWvSzwelIeFEn9XFesrtSQJv1hceN8nwq5Ybz8brQLu/y8sVOD9RIN3VkGNtrdXYgZVK5kWZ7G6GZurqWyeBBRsQt8+yRG5XBIt81XAbPqkiILR2r40blTUO34RbqsZnIFe2pJxzhzus/vXvRmW60c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179169; 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=Aml6O/ihqRQ5/Olxx3E4fWtWtO1GlytBAF8K5CE0V54=; b=AA4aXrYYIahGtu7G3gcEnwrio8k2gCfZAFLHAPiYchwIOvKTbhssO67dhXUsrm/QrRq+24ojr5EU1nz4SzWJ3JxB3jjupD5mrEDXUAO5o5yA5lyAHZR0e9DVdlHr+l/fzbfC17yCskqOHRkY+bGYIK2KytfO9lBp1k4ylT50Jlk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417916984020.447758369757935; Sat, 2 Aug 2025 16:59:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLhn-00006H-CL; Sat, 02 Aug 2025 19:31:59 -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 1uiLgv-0007Dc-LD for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:05 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgt-0004xq-DM for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:04 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-30b776f0805so545260fac.3 for ; Sat, 02 Aug 2025 16:31:03 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177462; x=1754782262; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Aml6O/ihqRQ5/Olxx3E4fWtWtO1GlytBAF8K5CE0V54=; b=hHAgiJup/4T9U4W5zZuJ1Zl6QBV7g9dBS4VHYvc8TE7Ecl9yNLCXBZeIOCQ+Dn8LML 6A8PvPiywCB9eB5EAnGgWaAHzk1yF1/nc/506Qan4X+p/Aqogo5Hx8QKX+Ixeq6wW4mV VEms/ri2KKSuejiGYPjzIsVQj+TteTusVvUlcaK221jP/4OZD7WvWUx6ko4VFClvCskt /RWUppRWnvWpIUjix90NnbP7agpz/6ou2O/1DNd5Kcc3WYEq1kB0LgZeOu9nzprCfaVS oLvUS+RMReJ9CzFuyXxdPWkTuZ4Y7NOI6S0Sqdkj5xMqRV6JYGkaPTAiothYJdyBOLyf DDyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177462; x=1754782262; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Aml6O/ihqRQ5/Olxx3E4fWtWtO1GlytBAF8K5CE0V54=; b=htLlOQTdstFJ2j7wtdLzdULkFO06jWVzDVi5cAA4B5/DGxuteoskGPmGU0MEXAfj+P /pHycy4vZfT56H1XbvW0mucG9oJ3oqW2b09JBx165naYYTrvhAAaEdUtB78BN93/Xmiw fXAx/UCbH9CfDSexVYrB+n9ifyMryMCXAgl9NvhPd7CZfjEzryrIs8Mk5YOxtsiNly3m LBiCQHyHHQKBMrHIS9xbzIo24OuWq5L0ApIsJgWvK9BU8yQ45leovp5gQ44IPdaCTIIV KGFKPDTw14CAHP9bqdLtRbhNChPY+MfVjKKm/WlrxIJZktV9EWVm0ITB4aSglCPOXpMm 2vQA== X-Gm-Message-State: AOJu0YyyOwMDHlUZYMuO1ZmymgpMQNViS6vQvbFDWu17K9BzguO2t8av e/JL12saDJy4G3T1JGqh+RulKvi3ORoPFgkb+OwUoARIoDSCPrErRJ+6u66wFlNhpnwpNJagBIX lTUX912M= X-Gm-Gg: ASbGncs7hSCfrpEbutXNcrpa4RRRk43/o+18NXiDHp5BaeP8ZB7anFpXDJrntccU84C mHHl6MzvPLf4C7rOe5xW5ZhvVfRI1HsqgqmqOYIfarzGB3X/BlgSY+rlHnx/wcptZ8Rphd0uxSX /8dZCC0ZIvCAloEGK2eOFfqUs1QtZY4SFqiY0QJbRYPUEx31MKoVhS9hEA1qL0DvoTAQUUG7qfk NxXsdepNX9VsNh5T4vIyhRXjat1DStIV2Yr40zA9uHE45s+iQ52X9VgKbvH+L2AKaaaLUPzxzV+ qj6aYgCRF+EMuyA1iHMmwo/yXryxBMj1CyYy+aM9aLRAyw1pChX5ncpKRO42zYsWGEpGnukFJuK ptkHJ2FO6q9A8jDpRj1A6LI7Zpak+qRnrE1vCZ0YOqzuJgmBCwvU2 X-Google-Smtp-Source: AGHT+IHEjCMcvfy7+bS+jsFRopBQ+lrDRgn1osJStQjwas1hmXKdNq7MJ+xSJ0LZP44zwGZi/9PNww== X-Received: by 2002:a05:6871:490:b0:2f6:c9a6:4f7f with SMTP id 586e51a60fabf-30b679eeea9mr2326164fac.39.1754177462252; Sat, 02 Aug 2025 16:31:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 13/85] target/arm: Add isar feature test for FEAT_S1PIE, FEAT_S2PIE Date: Sun, 3 Aug 2025 09:28:41 +1000 Message-ID: <20250802232953.413294-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2c; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2c.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179171379116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpu-features.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 7f2ca51b4c..83875c06bb 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -919,6 +919,16 @@ static inline bool isar_feature_aa64_sctlr2(const ARMI= SARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64MMFR3, SCTLRX) !=3D 0; } =20 +static inline bool isar_feature_aa64_s1pie(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, S1PIE) !=3D 0; +} + +static inline bool isar_feature_aa64_s2pie(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, S2PIE) !=3D 0; +} + static inline bool isar_feature_aa64_mec(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64MMFR3, MEC) !=3D 0; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177643; cv=none; d=zohomail.com; s=zohoarc; b=fnS0rkDVI+JGnGBrys/fCAmcjdWeDTMqNuYtQnDYBhzCjEogYewQWCK6Umawv5nMtea1ZlULY/LqM+a1V3uCKer0koqzHAbR6LJLYgaQ7mG5+C6qdvtNBcRsbwuW2DqTGkUDtKM97NIDemImBGBtGtkovDFmVz37HQc7L6/g6CI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177643; 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=Utmv5egIEVGewAwFQzpT1Xl8BddTKGqUYuRm1k9B5kE=; b=jUMrXjjCEjeX7Ur+EINJ3L/ud1htVg5BTYlKR5rL72bxXjyLTUjxnipoDdxRrYWpvRfFnSJraFxIinpPaDt8i2hKO2/mAD62aeQBZWHkb4+V15x3G/IbuTFOFvgBgFyJEc3vBxoHJ+q4khFf4+x7p9hBJqTZGhpSubfbtf/2Z0U= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177643969173.15873979036223; Sat, 2 Aug 2025 16:34:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLj8-0002y6-Rw; Sat, 02 Aug 2025 19:33:23 -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 1uiLh0-0007J8-1M for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:12 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLgx-0004yc-Ei for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:09 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-74190ce061fso1107863a34.3 for ; Sat, 02 Aug 2025 16:31:07 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177466; x=1754782266; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Utmv5egIEVGewAwFQzpT1Xl8BddTKGqUYuRm1k9B5kE=; b=jh8xzOL+AGN3hKXnI89YJgsGQmjm4Bge3ao/XU8W6CIpCj2LVqd3UZPwMWMqEgi9vA oMNODRcU18bz0xXaIv3RFbOrcNZQEYRd99bqweNCC0GKqPd08nBlIFz36MtQOTce7a9u hW/nAZYw3iIhbztF3Fk41GUuv7Jb3S0xtI6WzhD35f2iQc9SAlu/M2qf2hi/krh48bUu 1mbEAfHNBG6a0Sa+8awKmawLORVZHAykrdxI7syvaKS1eeeh/cndo+xck+uY1uNOTSUD N0JebC/vRwPulbhayeGEGr7EcfRRerSW/V04r9MvbqIHsnyPpS+Z8HSrsswMQermXrPx kwfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177466; x=1754782266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Utmv5egIEVGewAwFQzpT1Xl8BddTKGqUYuRm1k9B5kE=; b=IBdP6Ijv2+qbLGmqWFhAVDbggtp1GBWBge6xxVJ2Aw42p6F6XQncwg+BDstuQNF8Yp UuwlCbrtpFIrIQdi7ylHqXLIZzOEuwqFZeThI9T2RZOmpt2qVUVpu+ho2NEO+StnFwla S+SsFE6tybO1oVWGdgktqOuF5PYsTfVbBUlbKqBuQDGpkM1XwZ7I4/3OxMjyWp/a0BwY zZoXolkweYGVfkyVSCG7vajGh5XBlFcI+6PO37OyJpKY8/MIFjOjCri3mJ4knNEoVTZT JdT/fAWlg/n8IxnBFVPpZPMce5yE8tN0Vj5ddZbpudBccSIpQsYOcogkhzWw+AChkxQs UDUw== X-Gm-Message-State: AOJu0Yw8qiTagZz0egC2D6NBPofVbiUPiZL/KkYDSutW7J7dTdBZc42L /qQM+ygkoM9nKtsGDg6cNi9szYWExEzXB3DH/CACRY4ovk9OfvudmKG9ykCweQvyJ3hXLamu4O1 70LQcNV8= X-Gm-Gg: ASbGncv0uTBoW78UCOIoduIyHXJFtyIRtzGNwmKEZOCHp5P2ZmHAa4JKjl+7BzdjfTe 1S82v98MI5PDcFJRafUX4ttAZ9GhgN56MTZL2y6y9v8LpMjWTavvLvV9IkUVdqhMR2i531WwPqs 5lorD8XYt60ylCXilZ6obH0o96jelBe8iEuyUhXKknjipqpsp+mEEpfBz8QjWYPuUbPdvgK4f2P H/5EJtVg6B0UwXD4Emab3R909GlhnMgvxXRqzcARb1tEDGU/SKzya9ZETRQzThg+CLL9/+i1RwC 3NkF8rIoKWJhEteyyfBHzxRQosvK0MeFiB9+ZniiWAM1WpToCdYix8AcrUrf7mlUyhIyTLfZ9G2 YRtdMPscen7MbaSe59p7oeptKmkcBJvLdlnfZSg+R6lIyV+82Fw1Qva+9A/AffO0= X-Google-Smtp-Source: AGHT+IHyCyAtiHzcpgMb6WUmfZ7Gv99xpJPloxAC24N+9KY91NH+LNFauyv/7y2VWOzfQIqNMTzr/Q== X-Received: by 2002:a05:6808:2182:b0:40a:fb27:9e8d with SMTP id 5614622812f47-433f022ca16mr2830647b6e.15.1754177466343; Sat, 02 Aug 2025 16:31:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 14/85] target/arm: Enable TCR2_ELx.PIE Date: Sun, 3 Aug 2025 09:28:42 +1000 Message-ID: <20250802232953.413294-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177645163124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index dc6c82b7e2..61ba9ba5b2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6202,8 +6202,12 @@ static CPAccessResult tcr2_el1_access(CPUARMState *e= nv, const ARMCPRegInfo *ri, static void tcr2_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { + ARMCPU *cpu =3D env_archcpu(env); uint64_t valid_mask =3D 0; =20 + if (cpu_isar_feature(aa64_s1pie, cpu)) { + valid_mask |=3D TCR2_PIE; + } value &=3D valid_mask; raw_write(env, ri, value); } @@ -6211,11 +6215,15 @@ static void tcr2_el1_write(CPUARMState *env, const = ARMCPRegInfo *ri, static void tcr2_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { + ARMCPU *cpu =3D env_archcpu(env); uint64_t valid_mask =3D 0; =20 - if (cpu_isar_feature(aa64_mec, env_archcpu(env))) { + if (cpu_isar_feature(aa64_mec, cpu)) { valid_mask |=3D TCR2_AMEC0 | TCR2_AMEC1; } + if (cpu_isar_feature(aa64_s1pie, cpu)) { + valid_mask |=3D TCR2_PIE; + } value &=3D valid_mask; raw_write(env, ri, value); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177986; cv=none; d=zohomail.com; s=zohoarc; b=LWo03TYbC3kQ9xDw53bNCVNjtG0Ir4HZkeYmjdcfWum3kIyjEerKQdeQbwNKduDTg33X+wYMlNefb5v09hFaBE5zcGKfODv0B/QIT3EJHF4CtdhTtpi42fuAtyR+bmEDltCQZUpihUcXPesqg0NCQFA4H+zySAtlm+WOhtGEpBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177986; 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=L0ihX/6NjLJeiAV+rHpWXFChl+HIpT5VNQEwKbT4BfA=; b=MfP/HDAsiZn5KfpQv6jFiHllJ0IkG3Zntsn6nGxCwV/9bWBrWdOWaO/jqUQui2iJMVSP3G5PVvB7Hetq/yrqLERTw2VUdOeOxak3jOMp0Go7rQFvhdVV+1273Tm45eYHbiccz0YSHEqcR2QGEuA12KZCL2RRQ0NES9S2yr7fdLo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177986851430.11079223011166; Sat, 2 Aug 2025 16:39:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjY-0004n5-01; Sat, 02 Aug 2025 19:33:48 -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 1uiLh3-0007MD-4Y for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:13 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLh1-0004zV-1g for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:12 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-306b7eb492aso2041038fac.0 for ; Sat, 02 Aug 2025 16:31:10 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177470; x=1754782270; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L0ihX/6NjLJeiAV+rHpWXFChl+HIpT5VNQEwKbT4BfA=; b=GeITLfHgNtSvtnjhGrxgntU2YsGBWEoW/ivuZ0qPAMAplvw3Q6iryCbirqyQg1Y4Rl VJoFIu/MHXOLLNe1xRkifg0+zRy2/3DuFPRhK1nJBPc8QlC9E59LAP7jcpDmLEbE/gm0 W02bColussaIJQd9DFL/uCu6KoyPpefmGuisdqyWsU0JA0tCcY80uLlHIaysc2mI4dSo iIg0JkhwomxNcCCRdSWIVEF8n3Gs6YDvc1Ee5ivZzYBFURCq5XB3/2b95V5VoZWIBkFl b8Up4+7ApVvhhQJ80SYOgr/zy7diTq5tWgcFZKZTJA7rpeyF4mc6o1+f+ylm8/ufjt1o mRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177470; x=1754782270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L0ihX/6NjLJeiAV+rHpWXFChl+HIpT5VNQEwKbT4BfA=; b=LE7EHCXWvV4gXTKknniSdOO70SwS7WxOFfITSsf3hYJDYpfLnkI8qjZNoJqai0haxB j7nOEJvQ30uWUVA91qnUAaI4JIhVTku/nw3zBIgOiNFZ4QFGeyRl9TjI9wuMitkoXway NI4fzqQTC/LoIaYMXB3bc5ca9Mnz9bbC/EuH8VK4Lx2RaLNcnXup9nAKPowp/sfi7iIo StW5sI0pQ3aV5dmzG1UsMYkUq0+juzQNpgwP+EdAB1fXC0Mho4+/zUFpfNUVTi3K3o9O RwR2wwfA2Rc93MlDOElnSJgrOw9BdzhojhkhT1Poni6RmduF1ZfC3IbPNQ2Kj3Jn4F6n LAng== X-Gm-Message-State: AOJu0Yx1Vq1A45Cgov8G+94J2a2WaLoR6BZbcKo7ONbZysyltFFnURu/ jXcPNoTN64PVoJoHSyu9XEXe839I+L6BrR7OiG7j4Nul0ycnH17JCLiOlCo1NGHSknPjwZ0GPdU h6iNHYxU= X-Gm-Gg: ASbGncvhhgYfS36f0gLKAJZJEaAKl1CTr9ZlW705Tc4v7dLxWOrMes2QccWRY8L7ZvE p2hBy8D9GS6b+GjMr0IDykbBAcYtgbof0J+VBI2cphocWjKfDSh27KbHzlS2t2BG1/01O9Bqfuq fIHqsUZUELSibhu5px9LDrPlwnAcjDgNK3qjlroi9GzVuRLsSDke8QGRzEaNZPXjiNrRnQ9b922 gK6RjzR33XzeFc2SeSuaFFUDBdoENlAABaSScoTB/OinCZa9vkDYH1rCDHZ0xRfy89ya9yjscrl FicNae7GA5aVUHTRpwfIb+XVc2hkxwMyyL7M5RnRQggFsT1p6GujDITIxOwJcBWGuvmZCClnZiV 1UNsWgw90Oq/0R7nrLZNBoIxhKWETSeNO+kMBhLf2mzOURfcODHhl X-Google-Smtp-Source: AGHT+IGr162rRzZrx4qHcdlEVYIJ2UOpilOLsjoYgRy8s/XY3ZfHlQJWAl6RdiRg1CASgGUxKm4RNw== X-Received: by 2002:a05:6870:b40d:b0:2d5:2dfd:e11c with SMTP id 586e51a60fabf-30b668dc0fdmr2764954fac.7.1754177469916; Sat, 02 Aug 2025 16:31:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 15/85] target/arm: Implement PIR_ELx, PIRE0_ELx, S2PIR_EL2 registers Date: Sun, 3 Aug 2025 09:28:43 +1000 Message-ID: <20250802232953.413294-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2c; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2c.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754177988757124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 2 ++ target/arm/cpu.h | 4 +++ target/arm/cpu.c | 4 +++ target/arm/helper.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 2a4826f5c4..9efe9238c1 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -776,6 +776,8 @@ typedef enum FGTBit { DO_BIT(HFGRTR, ERRIDR_EL1), DO_REV_BIT(HFGRTR, NSMPRI_EL1), DO_REV_BIT(HFGRTR, NTPIDR2_EL0), + DO_REV_BIT(HFGRTR, NPIRE0_EL1), + DO_REV_BIT(HFGRTR, NPIR_EL1), =20 /* Trap bits in HDFGRTR_EL2 / HDFGWTR_EL2, starting from bit 0. */ DO_BIT(HDFGRTR, DBGBCRN_EL1), diff --git a/target/arm/cpu.h b/target/arm/cpu.h index defe2852f2..fb87fcc3e6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -369,6 +369,9 @@ typedef struct CPUArchState { uint64_t tcr2_el[3]; uint64_t vtcr_el2; /* Virtualization Translation Control. */ uint64_t vstcr_el2; /* Secure Virtualization Translation Control. = */ + uint64_t pir_el[4]; /* PIRE0_EL1, PIR_EL1, PIR_EL2, PIR_EL3 */ + uint64_t pire0_el2; + uint64_t s2pir_el2; uint32_t c2_data; /* MPU data cacheable bits. */ uint32_t c2_insn; /* MPU instruction cacheable bits. */ union { /* MMU domain access control register @@ -1738,6 +1741,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_ENTP2 (1ULL << 41) #define SCR_TCR2EN (1ULL << 43) #define SCR_SCTLR2EN (1ULL << 44) +#define SCR_PIEN (1ULL << 45) #define SCR_GPF (1ULL << 48) #define SCR_MECEN (1ULL << 49) #define SCR_NSE (1ULL << 62) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index f0545a276e..b472992b4a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -650,6 +650,10 @@ void arm_emulate_firmware_reset(CPUState *cpustate, in= t target_el) if (cpu_isar_feature(aa64_sctlr2, cpu)) { env->cp15.scr_el3 |=3D SCR_SCTLR2EN; } + if (cpu_isar_feature(aa64_s1pie, cpu) || + cpu_isar_feature(aa64_s2pie, cpu)) { + env->cp15.scr_el3 |=3D SCR_PIEN; + } if (cpu_isar_feature(aa64_mec, cpu)) { env->cp15.scr_el3 |=3D SCR_MECEN; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 61ba9ba5b2..6353b2dea1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -747,6 +747,10 @@ static void scr_write(CPUARMState *env, const ARMCPReg= Info *ri, uint64_t value) if (cpu_isar_feature(aa64_sctlr2, cpu)) { valid_mask |=3D SCR_SCTLR2EN; } + if (cpu_isar_feature(aa64_s1pie, cpu) || + cpu_isar_feature(aa64_s2pie, cpu)) { + valid_mask |=3D SCR_PIEN; + } if (cpu_isar_feature(aa64_mec, cpu)) { valid_mask |=3D SCR_MECEN; } @@ -4578,6 +4582,11 @@ static void define_arm_vh_e2h_redirects_aliases(ARMC= PU *cpu) "SCXTNUM_EL1", "SCXTNUM_EL2", "SCXTNUM_EL12", isar_feature_aa64_scxtnum }, =20 + { K(3, 0, 10, 2, 3), K(3, 4, 10, 2, 3), K(3, 5, 10, 2, 3), + "PIR_EL1", "PIR_EL2", "PIR_EL12", isar_feature_aa64_s1pie }, + { K(3, 0, 10, 2, 2), K(3, 4, 10, 2, 2), K(3, 5, 10, 2, 2), + "PIRE0_EL1", "PIRE0_EL2", "PIRE0_EL12", isar_feature_aa64_s1pie = }, + /* TODO: ARMv8.2-SPE -- PMSCR_EL2 */ /* TODO: ARMv8.4-Trace -- TRFCR_EL2 */ }; @@ -6242,6 +6251,60 @@ static const ARMCPRegInfo tcr2_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, cp15.tcr2_el[2]) }, }; =20 +static CPAccessResult pien_access(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_PIEN) + && arm_current_el(env) < 3) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static CPAccessResult pien_el1_access(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + CPAccessResult ret =3D access_tvm_trvm(env, ri, isread); + if (ret =3D=3D CP_ACCESS_OK) { + ret =3D pien_access(env, ri, isread); + } + return ret; +} + +static const ARMCPRegInfo s1pie_reginfo[] =3D { + { .name =3D "PIR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 3, .crn =3D 10, .crm =3D 2, + .access =3D PL1_RW, .accessfn =3D pien_el1_access, + .fgt =3D FGT_NPIR_EL1, .nv2_redirect_offset =3D 0x2a0 | NV2_REDIR_NV= 1, + .fieldoffset =3D offsetof(CPUARMState, cp15.pir_el[1]) }, + { .name =3D "PIR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 3, .crn =3D 10, .crm =3D 2, + .access =3D PL2_RW, .accessfn =3D pien_access, + .fieldoffset =3D offsetof(CPUARMState, cp15.pir_el[2]) }, + { .name =3D "PIR_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .opc2 =3D 3, .crn =3D 10, .crm =3D 2, + .access =3D PL3_RW, + .fieldoffset =3D offsetof(CPUARMState, cp15.pir_el[3]) }, + { .name =3D "PIRE0_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 2, .crn =3D 10, .crm =3D 2, + .access =3D PL1_RW, .accessfn =3D pien_el1_access, + .fgt =3D FGT_NPIRE0_EL1, .nv2_redirect_offset =3D 0x290 | NV2_REDIR_= NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.pir_el[0]) }, + { .name =3D "PIRE0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 2, .crn =3D 10, .crm =3D 2, + .access =3D PL2_RW, .accessfn =3D pien_access, + .fieldoffset =3D offsetof(CPUARMState, cp15.pire0_el2) }, +}; + +static const ARMCPRegInfo s2pie_reginfo[] =3D { + { .name =3D "S2PIR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 5, .crn =3D 10, .crm =3D 2, + .access =3D PL2_RW, .accessfn =3D pien_access, + .nv2_redirect_offset =3D 0x2b0, + .fieldoffset =3D offsetof(CPUARMState, cp15.s2pir_el2) }, +}; + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -7479,6 +7542,13 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, tcr2_reginfo); } =20 + if (cpu_isar_feature(aa64_s1pie, cpu)) { + define_arm_cp_regs(cpu, s1pie_reginfo); + } + if (cpu_isar_feature(aa64_s2pie, cpu)) { + define_arm_cp_regs(cpu, s2pie_reginfo); + } + if (cpu_isar_feature(aa64_mec, cpu)) { define_arm_cp_regs(cpu, mec_reginfo); if (cpu_isar_feature(aa64_mte, cpu)) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179042; cv=none; d=zohomail.com; s=zohoarc; b=cwGUWMs6qu34s2twZzQAKIfolo1mWjPPFg988byL8fuZazXuPPTmpZQOEa+QqnigLzvK7JuALdXAbnfA2PRWvwopGgnbm4IefF+ha14I8GTGgKC/00tJkOnw0NXYlfBuV4FN2bGb1in3XOEKLm0TcrETq+qevDjKc0RcincsSM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179042; 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=P80G+Mqq/PBj5fm0u9e6xc+6PUuM6bwSvtsR/7Pt9Yc=; b=SYZHWdDbOgpcCbk+JkFy0oTVpI11QsCdE5LVy9cmyS26rhE2htktqqAHHlyFqPsJd8zt2g0hJ+STxKrjvy9whkldqOpI98Rro5706rr6e/DNM8wqw0q8ajjbP9o2Lzkem3hh0ORtaBSApWJ/6o8/eQL57Q29qB+c8QQy35IImkY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179042365191.95533621862717; Sat, 2 Aug 2025 16:57:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjl-0005J4-S2; Sat, 02 Aug 2025 19:34:02 -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 1uiLh7-0007Vl-Lq for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:22 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLh5-00050e-W2 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:17 -0400 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-741a8bb8aa4so160515a34.1 for ; Sat, 02 Aug 2025 16:31:15 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177474; x=1754782274; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P80G+Mqq/PBj5fm0u9e6xc+6PUuM6bwSvtsR/7Pt9Yc=; b=TfmsKU8o4q/LgSrOIcAl2mwjkja73vmQKQOaMyxlpwE8r40q70xdkkwdxEXKQUEKR8 b5wNnGv4E0fzhARVHxzJxLBLQpuOZufe+Ipq3lHvcl+oFu2GVj5VwWuRX65a5bevkVl+ 1rOWE1lO9dNnKy/a45KjVFhK+RF7pBo94VPn64kpX+ZoofLsQQ+G9DXMRt0okevhXOJj 62WKWQCw2BMJbZe/wfni8bjtelvK4cLsrja/z8pVSkG0/s2SBMV8WVU2qfqmH08WJbTo Nt1DNezxXmlvtKeMl743yAMOOkg1sUVGNLcgPO3nLBIOc7MbJHeiilDQTjxoATW7CpjY M9NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177474; x=1754782274; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P80G+Mqq/PBj5fm0u9e6xc+6PUuM6bwSvtsR/7Pt9Yc=; b=ZNcjTFWUN6rY5zqpZRYrCpf/wHXKzkm72ig//ecUsffDdkPJqp4K7fVYOgwSLcBD+i 5hGNfkahUI27MznSg7sOQAGqyqU+Y5d3lWTs0k8XQrXQqLxk28/v6IXylgvrKI8qqmcx tYSRjRe6g0+oJuEUW4kvqYAnbW04RNP+U0953Els8HFxni7layD2GXOoYDuin94CyA+j Kectzi1xkL97IgTzLmRXc8eEjAYqy/HWuf/1o2/z7UVgxqzJhN5pxbrZAT0n8WTWL/cF P0fPpzfJRIOpx1LT3Ihemrb+BxPoKWJskcE6jfx6VREurOIscWsay1STyVJuUMKoyfhQ LC3g== X-Gm-Message-State: AOJu0Yzhx73SyQip+L3lI3BWbu3Onjv+JPLEivjEgaK1LMwNPxKI3RVh J+SUfPU8yR5NchD5mp0EyNVRepHmyjol+Qr8mkR0Gn04Bawv8zpAxPDMS1F6EqgxcOzVkZfmxje BgCooZKs= X-Gm-Gg: ASbGncuINYGhOqmQnku1a0UmGUAjiD/oohK02gQCNNCZ2hwVhX6QYvVRZWPhb5EtG7N Ohd6Lkp4/vhG0XYOXfmcCyXvZROvFmpGUJzmNctsKFWgE5WNJx9PYX7ArMrgeaHYsf7+VzdoR2L Scm1daXerLmeq9tOnuSvhnm7qV+qp1vVBLzjxoH0cn6vGvl/JKFOt4/LuHqGIIXMLZoBvz/wMO6 n22yhZ29S9M7GAht1zc9F+Olvx6yZvaM7qotU4ZAWvnPKwAfw0qa+OMIfS4EhORpmP9Bc2qdutD fXbZSAZpecM5oTV9pPL1iJ2hn7qE5UJCzg80VbnUq0+ufw5T7NUj0/mqBqBBDCLO3yCj/V4a4fJ xZ3ItQ46pXhTwsY3iREnxVsazAGjHPyqjK0XLTt1z7I1xTv2ze8aKbgs9Di9Td4g= X-Google-Smtp-Source: AGHT+IHAge1UajJHYqO+OIVab+CpN2HvImOtBO/RfqnCiNnB3htLrlzQlMc0rD/udKK8v2aPQNWB6g== X-Received: by 2002:a05:6830:7187:b0:73e:a0fd:ac84 with SMTP id 46e09a7af769-7419d165690mr2980159a34.8.1754177474493; Sat, 02 Aug 2025 16:31:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 16/85] target/arm: Force HPD for stage2 translations Date: Sun, 3 Aug 2025 09:28:44 +1000 Message-ID: <20250802232953.413294-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179044376116600 Content-Type: text/plain; charset="utf-8" Stage2 translations do not have hierarchial permissions. Setting HPD means we can eliminate an extra check against regime_is_stage2. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/helper.c | 7 +++++-- target/arm/ptw.c | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 6353b2dea1..a6130f7dcd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9639,8 +9639,11 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env,= uint64_t va, tsz =3D extract32(tcr, 0, 6); gran =3D tg0_to_gran_size(extract32(tcr, 14, 2)); if (stage2) { - /* VTCR_EL2 */ - hpd =3D false; + /* + * Stage2 does not have hierarchical permissions. + * Thus disabling them makes things easier during ptw. + */ + hpd =3D true; } else { hpd =3D extract32(tcr, 24, 1); } diff --git a/target/arm/ptw.c b/target/arm/ptw.c index efbad7af1f..2eb2041edb 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1472,8 +1472,12 @@ static ARMVAParameters aa32_va_parameters(CPUARMStat= e *env, uint32_t va, } tsz =3D sextract32(tcr, 0, 4) + 8; select =3D 0; - hpd =3D false; epd =3D false; + /* + * Stage2 does not have hierarchical permissions. + * Thus disabling them makes things easier during ptw. + */ + hpd =3D true; } else if (el =3D=3D 2) { /* HTCR */ tsz =3D extract32(tcr, 0, 3); @@ -1979,16 +1983,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, * except NSTable (which we have already handled). */ attrs =3D new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(5= 0, 14)); - if (!regime_is_stage2(mmu_idx)) { - if (!param.hpd) { - attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ - /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0]= =3D=3D 1 - * means "force PL1 access only", which means forcing AP[1] to= 0. - */ - attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D= > AP[1] */ - attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D>= AP[2] */ - } + if (!param.hpd) { + attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D= =3D 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D> AP= [1] */ + attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D> AP[= 2] */ } =20 ap =3D extract32(attrs, 6, 2); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177612; cv=none; d=zohomail.com; s=zohoarc; b=WtICKOMu+7g3KXKz2f81Opja+rL50ZjjxLoxOnCfDsirvQ/YlPncbv6CvjNcvhIw4tgGDprYYb+FJifEgl1xWk+c7fsyxqFIVy9wsXo3uvVh+lUGf0Q0ZRRZtLi3lkQ17sN5KFWVeKHrLeMAAiTdw3YzJ6YKmyQHtADeeK8iN6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177612; 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=E7hKQRMRTXCmigZqJckaUTqAy652f0/yVmAQHFcYbaY=; b=jxbA6eLtgu4d2AAwniTQNvUx4vr8P7nO4w7cWncm7h+XSs8wnN5FMXbqS+HO7PputFwSLZnhvIBNH/HqUzeVybvrfGn6/Rn/pbiO0odNB5yaYRetfTCYAxA2YXhTOKwZBEJNevfdxvRmH0Ek63VB6+bU5DmlUiCKooQtSEtCJMA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177612668974.0190858386809; Sat, 2 Aug 2025 16:33:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLi5-0000gm-IZ; Sat, 02 Aug 2025 19:32:18 -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 1uiLhC-0007Xz-Up for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:28 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhA-00051H-C9 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:21 -0400 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-741a0ec1a05so314769a34.2 for ; Sat, 02 Aug 2025 16:31:19 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177479; x=1754782279; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E7hKQRMRTXCmigZqJckaUTqAy652f0/yVmAQHFcYbaY=; b=bbXrrwoRMVsWjYSY483eSrER4dCtMKctGrkUqIhUICqRZ8X4u0HjSKD1kfM1ljiFCe GM/zph8HsUNZibXLKQSi3N3VSilERhxhSXazCdASUt6amrhEMh8eQSk6OJmZb10SLHyZ mKmerrTfeeH4nSRRkMM/NjCUHKY9l3PH6JcNp6g56VMa/Qv52D633oVHbaaqoj/r1BM/ 2WiX9FCi1sRnetfiUXsN5vL0RNtlapgS7NIIICseooxxSp8pICn9/XQdEtyp8jrk68JY 8Vl77JaPUmpFIdTIvwPdS6lm+w7vENAsG9+2LenYNpwZDXxDN5+qY/qKMOdMCVZtfW5/ Z1sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177479; x=1754782279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E7hKQRMRTXCmigZqJckaUTqAy652f0/yVmAQHFcYbaY=; b=HzFlbu+g510x3+iEnq3JygLHxw7LxDaT5NaYJ+E7DCzHwtxHhkAmhL/i7uJecZuyP6 nQd4kLe9qvcPokO2kChH+in6OtGagzU70KnfWRWQ8Gq1norvKzpVIlNnySRnNQgtaGGb JIjbkcacTYjkHefF8cnEomNrcXZAtOqUsmEEZ9BoS1Spf8LA4O/MpK/JUIJhV3Nfubhk EfIcjfirAdxxYZK+SWoeF3Vp/JAgH5Or+batO0cFlDSPCkI2rmrgrsB4vME3hwiZAQqq AdNnbr/Q+pJmTZfxs8SrzlV24jST3/nj0NYhIelLbUhPRFsrCa38yXCkYU0q6UUc3ExD wxOg== X-Gm-Message-State: AOJu0YzOyLigexHTqwQJXWc1mJaP0j8cK0GMHbsGlF2sVIUt3FgId/xY BhE3cq2OefzMNPeWlsAqAuurJLEGXpDlyCBc5/E9cxoijqdiX56r6MBNA+kEl6FkXIueaBhta+7 l0R+XIDI= X-Gm-Gg: ASbGncszAcOJCpSqZ1+BoVZtu/GZlxco8qnd1Gq0rR76ZyKwYMkiDp4OvBwbKKBB/8J K4fKVMxhrHo58NIEw75r9FJ76m2OKrtD2/R9KD940vPhH55wAG5HP4thquvAKHffTnk0n7bOAR2 +oNNpQ8zaYKWu4B7PxmU+h5uwaQ+seoL+JssyAcqFp0+73t6q9+NXL8A4HsZM97JQ58JaTkGodW VU43u3ZvPqvEALV2WeT78rwIIzBVmQBA6aHCi0b9l4n+objBS5V+tEsbsBmt8q9WDj8m2ZHCR+j aS2OErKrj6AZI34TSVO8YIDyeTAVNoPDT/Jn4QR/7na+guSETGSJDbh7DoFsaS4yvmut3DEXYUM IT2C9QK4uPofiKqkbu4cj6ryvQDkwcwZMVVDU2q8hLzZm3eex9HqThh6/erLQCWE= X-Google-Smtp-Source: AGHT+IGzoPOgD0uSrt+THKXIeR3GKFbFA7ExjR4dUGzLOmW6YosuZIa+AxpXHODvRYP5LMjLsrkzLg== X-Received: by 2002:a05:6870:80c6:b0:2e8:eccb:fe1c with SMTP id 586e51a60fabf-30b678c0905mr2797589fac.31.1754177479011; Sat, 02 Aug 2025 16:31:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 17/85] target/arm: Cache NV1 early in get_phys_addr_lpae Date: Sun, 3 Aug 2025 09:28:45 +1000 Message-ID: <20250802232953.413294-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x330.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177614469116600 Content-Type: text/plain; charset="utf-8" We were not using the correct security space in the existing call to nv_nv1_enabled, because it may have been modified for NSTable. Cache it early, as we will shortly need it elsewhere as well. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/ptw.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 2eb2041edb..a5a3c03a4c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -76,6 +76,8 @@ typedef struct S1Translate { * may be suppressed for debug or AT insns. */ uint8_t in_prot_check; + /* Cached EffectiveHCR_EL2_NVx() bit */ + bool in_nv1; bool out_rw; bool out_be; ARMSecuritySpace out_space; @@ -1642,12 +1644,6 @@ static bool lpae_block_desc_valid(ARMCPU *cpu, bool = ds, } } =20 -static bool nv_nv1_enabled(CPUARMState *env, S1Translate *ptw) -{ - uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, ptw->in_space); - return (hcr & (HCR_NV | HCR_NV1)) =3D=3D (HCR_NV | HCR_NV1); -} - /** * get_phys_addr_lpae: perform one stage of page table walk, LPAE format * @@ -1699,6 +1695,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, !arm_el_is_aa64(env, 1)); level =3D 0; =20 + /* Cache NV1 before we adjust ptw->in_space for NSTable. */ + ptw->in_nv1 =3D (arm_hcr_el2_eff_secstate(env, ptw->in_space) + & (HCR_NV | HCR_NV1)) =3D=3D (HCR_NV | HCR_NV1); + /* * If TxSZ is programmed to a value larger than the maximum, * or smaller than the effective minimum, it is IMPLEMENTATION @@ -2074,7 +2074,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, xn =3D extract64(attrs, 54, 1); pxn =3D extract64(attrs, 53, 1); =20 - if (el =3D=3D 1 && nv_nv1_enabled(env, ptw)) { + if (el =3D=3D 1 && ptw->in_nv1) { /* * With FEAT_NV, when HCR_EL2.{NV,NV1} =3D=3D {1,1}, the block= /page * descriptor bit 54 holds PXN, 53 is RES0, and the effective = value --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178459; cv=none; d=zohomail.com; s=zohoarc; b=MSyO5WsEzLVmd6AcY6/eNCMO9TNhN7vVuBcmL01dkfjuPiZxwwxqNLK0dZlrr2P0JTaZoOhHKAk0LwGeUN2R14KgHto46xqopCG2xk/qxDziOt9FEBm/Z/7HLu9AHC1fdoCXlf9excpgcndxYkjlHRzJsfGfRfUPJ8cCZHvH4WY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178459; 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=qRRS/gV/szOXu7puF9a2nCAqRylQ06iARqw+VOh+yuA=; b=lASJdRlyj9iQUNjrByqUd1EglTABoH3rhFi6Mz/j6Xh08a6/a+RXAEwsGi86Mi9gRn4fWk7uAuMGAIINAxMMItiKVXNTYYAe3BhZQfjsEja3P7trr9oXY04FgjfYyJ2wYNchB9PLVT/jSiMPaENj0l0SjEVZcBK4V5whUfkV28M= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178459880925.6937901746556; Sat, 2 Aug 2025 16:47:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjK-0003gm-1K; Sat, 02 Aug 2025 19:33:34 -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 1uiLhN-0007ho-S9 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:34 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhM-000532-5N for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:33 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-3005517e7d0so698313fac.0 for ; Sat, 02 Aug 2025 16:31:31 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177491; x=1754782291; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qRRS/gV/szOXu7puF9a2nCAqRylQ06iARqw+VOh+yuA=; b=GuzuMgI039RxsACXw53lyR/rB8MHOeHoQd5wEeH+poyy6BJHaawr8t5mLaCFNdg972 M7JEawbUFFdGYXfuJvzfaxVQHUUhhrxXp290wUduc2aS0VjmNVGuY+VVaJJag4O8pAvQ UAGqGf/oBhHXRr5Yz4d5uAe0SF1yr5ZBCK+8AFUyEHD7E0QRRs/+NkRYi2O1Zblhv3n/ /EPT2+WfL2IZ4SijuSfC7svTIx/dOIdjgw0mUmJguJqXg6lUUcDumD48kG7fVDEwVykP 2w7+E/Df7YcH47xDqlrbhd2+FQK/9/sFROhx7JVv9swnYHOdCFk1EmYsftWenwsoIjng 8Jcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177491; x=1754782291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qRRS/gV/szOXu7puF9a2nCAqRylQ06iARqw+VOh+yuA=; b=VqDWlC8b7j5gD6LdGntVadM+A6t4wYa027Em9Jv4RdiLin/8tZPnXqjlNrTXpgLLBF mW0PrFtfthhbRXspG4cm/0pYgn8WHomoFa2rCzrmtZkl55ju2C4/K78NKvYKplJGkTMN 3dgrRy6HP4Ms9Sq2w/lzuVOye+bhKnPLJvXtb85OCwwiemmhuQ1XGmL+ah6g5+xYZypM 5367IbyzFq6AwyeDv6bJxeY6+eQpioyhuqQbYOeq3aYqv7lyMVPWlzs9mnl1JNGNytAF pDAtXztA+YGw9zkETMIFS5aEcNZhbdLGN1eeO9nXFe4hu9oBqqpMrHm9ARdPozONbLkY LOsA== X-Gm-Message-State: AOJu0YxXitXU9n3rgnOxpI3uD6U/Y288Wr5sgdbrCGGs5YYV0tGftkuN +ONjQhBVFglyeZM2NjzrrPqZRx0Yq6GGe3i+iW6eenVKFVwBhTO9ZyqfsOmJVlhinC4ToBMr0KO fY3FaFLk= X-Gm-Gg: ASbGncu8AxskBQ2NdyCeR1mki4iG6ePucds+Isl1a4pbNanNxV0fAqqmMmvTxtoz09E egIsBNVWxFC3P+Bdd5hdbPSQZF7y0soavdNjrvOwv8Lp8haknyrFqhk0zWPNDmwqzKyc1pFJNY7 b6rixE+gnfyotzVubYlXZWVE9CgMp53O264wip5mcy+FCzloHCp2FqP+tgujC5yTMLBM0sLjYxq UiCklFiGquSQQWpkFyHb3DakHeV9F3nSz/UkUNjrm5bqBl7azcCXKpsj9DK/iDXsa4Ep5APd+6q UBPLBa9lskXvTZQdO3xfOOX61+mrcDJyac/1yplIJoHCPOfx8B8/1CCG6YFlZM3qbfSwkIu5CsR COGAvlIUw2ev6rqm3v7heKB3FKBI3mNMI9iItBt9ZrSfsZPTvZ+w7soI9GwkfvjV1nJD+fE70Ew == X-Google-Smtp-Source: AGHT+IEpXOP5BjOmV5bdg8GlCsVa+fOV0Pxmhg5mWnbHYQpS9HHF5yv7yrX9XFWE4eIuY1w1vfwtWw== X-Received: by 2002:a05:6870:8613:b0:2d4:e101:13eb with SMTP id 586e51a60fabf-30b679db3aamr2682990fac.28.1754177490916; Sat, 02 Aug 2025 16:31:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 18/85] target/arm: Populate PIE in aa64_va_parameters Date: Sun, 3 Aug 2025 09:28:46 +1000 Message-ID: <20250802232953.413294-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178461797124100 Content-Type: text/plain; charset="utf-8" Select the PIE bit for the translation regime. With PIE, the PTE layout changes, forcing HPD. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 3 ++- target/arm/helper.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 0dd1b214c8..d5f501bb30 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1488,7 +1488,7 @@ static inline int arm_granule_bits(ARMGranuleSize gra= n) =20 /* * Parameters of a given virtual address, as extracted from the - * translation control register (TCR) for a given regime. + * translation controls for a given regime. */ typedef struct ARMVAParameters { unsigned tsz : 8; @@ -1503,6 +1503,7 @@ typedef struct ARMVAParameters { bool ha : 1; bool hd : 1; ARMGranuleSize gran : 2; + bool pie : 1; } ARMVAParameters; =20 /** diff --git a/target/arm/helper.c b/target/arm/helper.c index a6130f7dcd..168557b08f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9628,11 +9628,12 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, bool el1_is_aa32) { uint64_t tcr =3D regime_tcr(env, mmu_idx); - bool epd, hpd, tsz_oob, ds, ha, hd; + bool epd, hpd, tsz_oob, ds, ha, hd, pie =3D false; int select, tsz, tbi, max_tsz, min_tsz, ps, sh; ARMGranuleSize gran; ARMCPU *cpu =3D env_archcpu(env); bool stage2 =3D regime_is_stage2(mmu_idx); + int r_el =3D regime_el(env, mmu_idx); =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -9644,8 +9645,17 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env,= uint64_t va, * Thus disabling them makes things easier during ptw. */ hpd =3D true; + pie =3D extract64(tcr, 36, 1) && cpu_isar_feature(aa64_s2pie, = cpu); } else { hpd =3D extract32(tcr, 24, 1); + if (r_el =3D=3D 3) { + pie =3D (extract64(tcr, 35, 1) + && cpu_isar_feature(aa64_s1pie, cpu)); + } else { + pie =3D ((env->cp15.tcr2_el[2] & TCR2_PIE) + && (!arm_feature(env, ARM_FEATURE_EL3) + || (env->cp15.scr_el3 & SCR_TCR2EN))); + } } epd =3D false; sh =3D extract32(tcr, 12, 2); @@ -9685,7 +9695,13 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env,= uint64_t va, regime_is_user(env, mmu_idx)) { epd =3D true; } + + pie =3D ((env->cp15.tcr2_el[r_el] & TCR2_PIE) + && (!arm_feature(env, ARM_FEATURE_EL3) + || (env->cp15.scr_el3 & SCR_TCR2EN)) + && (r_el =3D=3D 2 || (arm_hcrx_el2_eff(env) & HCRX_TCR2EN))= ); } + hpd |=3D pie; =20 gran =3D sanitize_gran_size(cpu, gran, stage2); =20 @@ -9764,6 +9780,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, = uint64_t va, .ha =3D ha, .hd =3D ha && hd, .gran =3D gran, + .pie =3D pie, }; } =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178190; cv=none; d=zohomail.com; s=zohoarc; b=BgncpzXEtKI7t9dFrWS8EMXI6agL6bzWtnHhwhlSH2f2lM9UP6kYOnCKQ6A6FKJ18URz47e79nMTuMsJUpi1r1RBrFljc5HdTS22vFamix8+k22CoMUY4zZkibL5v+TIzD1nfgZCvMDpCZFEqbqK2pDODzqRpcPd2GIncoKQlhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178190; 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=Y1C+mCkPpaYdwsiDevSN1ysjcA0iJlDfVBhccuXEqSc=; b=Q+GIgHJDw4RBfuOedrSfxa7ya2/9yD0dG/Z1LzR8x2xcLRKJ3/T/h6fdbT1W6yqMre8m//13y7pJYj+U7hgaje2mIq5GNvvAXXd8sI3HjXpjEV89GpU6lNSAJMuBlXT7aMd6Ie4Kc8GA2ILDK8k09qBG15Aw1U4MmejRxNhSy9o= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178190720901.1041260115919; Sat, 2 Aug 2025 16:43:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjc-0004tr-6P; Sat, 02 Aug 2025 19:33:52 -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 1uiLhR-0007qB-Uz for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:38 -0400 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhQ-00054A-09 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:37 -0400 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-741a6272c8fso140795a34.3 for ; Sat, 02 Aug 2025 16:31:35 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177495; x=1754782295; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y1C+mCkPpaYdwsiDevSN1ysjcA0iJlDfVBhccuXEqSc=; b=i/9/rsmvQ7t91TIBaU+GWB4wmdpnO+iD7cypIEbAYPIWg0oh20cOO1P8kblP8/+48v CwD2VvQzkOJMljOv4Stw/pEOjvxFVonl/Sr6jccHGoz5iGsL8iNVfIiPE3ii3eiRbuYo xGLPePdXOjFOyxAOEtjFGeF6189KyB0qFrajZ/ui35uIYq1kHAekGbGyAOwmIVgIIFkV JiPXJPojF2u1RIqr/x16f1DW3nNEN4lN3NEsO+rChUiEe9tBOnUFW0iFRfNS2UOIfXvK mF4ZrJuxqXObSqRmKZZ/3eJthTG7Wq3deZaZPfxtVB5F0z45qbn8YjqLvs3f2t9sPgyo qlgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177495; x=1754782295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y1C+mCkPpaYdwsiDevSN1ysjcA0iJlDfVBhccuXEqSc=; b=HV95uzslNlQlW71JDavkL3rpiLhPgzQHP8lLPTD1+bS//0rGA9Lb5SXor/vd9ZBySb 6Kivr9GI/yQkQ1R0o2YOHZsVbS+H8TBVzQvPxCLQI/42Wnno8VbS4jvWZe+jgoOgUPyU uAD/hjYlyBgFI7pgC2WomyrwgEwpdVqa5NaIEDQ7R9Rr0OKQeumRMyJShoWcJBbPD2eU dzpzch43YqXndpkFErEpdlZakaPSlKzFQroN5xMHCsD22lEANgbvDOULCFtGBzPlHEMP iUL/qdyB6SScWFJSQn3p+zyrno6u5a3Wc0xmbMMZGJxAlcDkHb5JcpNqLXPNd9KiZFmi McMA== X-Gm-Message-State: AOJu0YwnpCMRyfzJSsIMwIPudOw/XBX/pvw773i7Q7ZMXSMSuZ2q1x7x V/Mr0thir4P/JTXcomWWaCQ/xMWTCnRSnO8nT4Pm1xQBN0wPlFcd4oGl+u0GUmevTxLDLnf/SPo ya0tjlsI= X-Gm-Gg: ASbGncsYb4a23LLO38vKJqNoP5vsibsVjMUzFOJYfY2p9iN3ZqhkHpze/fO6MyISAzJ DY8xWa13eBVbAxwKjrKbuW/p/Dg0jtCmhM9jXbkkAKr1c3jemfMVYbzjloBiDuSl6vmx57txP39 o7hQq9Wyaxsj4qYaU2Ntvi9sGouiJcnjl14xYpWmeAUiw8L420vKD7USpooyBQwMM9MW3FT1Z9g 6U6eN5gMy1rCg+02DSqecz2cL+/+sWUUGli5vxK+71r88vIAKkq9hqsExcwxRfAeEPPKKa2m8AB lIw6wTiTESOjwSq3RMtJoj2KaCnorWVEo/C7h4OS2jkZqvZoFvKKBQ4u0ZuoTbNCEhaSBleq0tR p669V3jF/a7n+RtS/1B8dOfoKt3Njs0vYyUN1SrPpcwkon7tyIhR38r7covhT5xg= X-Google-Smtp-Source: AGHT+IFOexHCVNovhRM3PazxdiDSodfErg16PWP3QAwfEy+p2sRWGSmDuSDEja6a+7vTUzd4Ynwp3g== X-Received: by 2002:a05:6870:80c6:b0:2e8:eccb:fe1c with SMTP id 586e51a60fabf-30b678c0905mr2797919fac.31.1754177494767; Sat, 02 Aug 2025 16:31:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 19/85] target/arm: Implement get_S1prot_indirect Date: Sun, 3 Aug 2025 09:28:47 +1000 Message-ID: <20250802232953.413294-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32b; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32b.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178193100124100 Content-Type: text/plain; charset="utf-8" This approximately corresponds to AArch64.S1IndirectBasePermissions and the tail of AArch64.S1ComputePermissions which applies WXN. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/ptw.c | 169 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 143 insertions(+), 26 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index a5a3c03a4c..7fd1cee98a 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1449,6 +1449,106 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx m= mu_idx, bool is_aa64, return prot_rw | PAGE_EXEC; } =20 +/* Extra page permission bits, during get_S1prot_indirect only. */ +#define PAGE_GCS (1 << 3) +#define PAGE_WXN (1 << 4) +#define PAGE_OVERLAY (1 << 5) +QEMU_BUILD_BUG_ON(PAGE_RWX & (PAGE_GCS | PAGE_WXN | PAGE_OVERLAY)); + +static int get_S1prot_indirect(CPUARMState *env, S1Translate *ptw, + ARMMMUIdx mmu_idx, int pi_index, int po_ind= ex, + ARMSecuritySpace in_pa, ARMSecuritySpace ou= t_pa) +{ + static const uint8_t perm_table[16] =3D { + /* 0 */ PAGE_OVERLAY, /* no access */ + /* 1 */ PAGE_OVERLAY | PAGE_READ, + /* 2 */ PAGE_OVERLAY | PAGE_EXEC, + /* 3 */ PAGE_OVERLAY | PAGE_READ | PAGE_EXEC, + /* 4 */ PAGE_OVERLAY, /* reserved */ + /* 5 */ PAGE_OVERLAY | PAGE_READ | PAGE_WRITE, + /* 6 */ PAGE_OVERLAY | PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_W= XN, + /* 7 */ PAGE_OVERLAY | PAGE_READ | PAGE_WRITE | PAGE_EXEC, + /* 8 */ PAGE_READ, + /* 9 */ PAGE_READ | PAGE_GCS, + /* A */ PAGE_READ | PAGE_EXEC, + /* B */ 0, /* reserved */ + /* C */ PAGE_READ | PAGE_WRITE, + /* D */ 0, /* reserved */ + /* E */ PAGE_READ | PAGE_WRITE | PAGE_EXEC, + /* F */ 0, /* reserved */ + }; + + uint32_t el =3D regime_el(env, mmu_idx); + uint64_t pir =3D env->cp15.pir_el[el]; + uint64_t pire0 =3D 0; + int perm; + + if (el < 3) { + if (arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_PIEN)) { + pir =3D 0; + } else if (el =3D=3D 2) { + pire0 =3D env->cp15.pire0_el2; + } else if (!ptw->in_nv1) { + pire0 =3D env->cp15.pir_el[0]; + } + } + perm =3D perm_table[extract64(pir, pi_index * 4, 4)]; + + if (regime_has_2_ranges(mmu_idx)) { + int p_perm =3D perm; + int u_perm =3D perm_table[extract64(pire0, pi_index * 4, 4)]; + + if ((p_perm & (PAGE_EXEC | PAGE_GCS)) && + (u_perm & (PAGE_WRITE | PAGE_GCS))) { + p_perm &=3D ~(PAGE_RWX | PAGE_GCS); + u_perm &=3D ~(PAGE_RWX | PAGE_GCS); + } + if ((u_perm & (PAGE_RWX | PAGE_GCS)) && regime_is_pan(env, mmu_idx= )) { + p_perm &=3D ~(PAGE_READ | PAGE_WRITE); + } + perm =3D regime_is_user(env, mmu_idx) ? u_perm : p_perm; + } + + if (in_pa !=3D out_pa) { + switch (in_pa) { + case ARMSS_Root: + /* + * R_ZWRVD: permission fault for insn fetched from non-Root, + * I_WWBFB: SIF has no effect in EL3. + */ + perm &=3D ~(PAGE_EXEC | PAGE_GCS); + break; + case ARMSS_Realm: + /* + * R_PKTDS: permission fault for insn fetched from non-Realm, + * for Realm EL2 or EL2&0. The corresponding fault for EL1&0 + * happens during any stage2 translation. + */ + if (el =3D=3D 2) { + perm &=3D ~(PAGE_EXEC | PAGE_GCS); + } + break; + case ARMSS_Secure: + if (env->cp15.scr_el3 & SCR_SIF) { + perm &=3D ~(PAGE_EXEC | PAGE_GCS); + } + break; + default: + /* Input NonSecure must have output NonSecure. */ + g_assert_not_reached(); + } + } + + if (perm & PAGE_WXN) { + perm &=3D ~PAGE_EXEC; + } + + /* TODO: FEAT_GCS */ + + return perm & PAGE_RWX; +} + static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, ARMMMUIdx mmu_idx) { @@ -1678,7 +1778,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, int32_t stride; int addrsize, inputsize, outputsize; uint64_t tcr =3D regime_tcr(env, mmu_idx); - int ap, xn, pxn; + int ap; uint32_t el =3D regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); @@ -2006,7 +2106,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, out_space =3D ARMSS_NonSecure; result->f.prot =3D get_S2prot_noexecute(ap); } else { - xn =3D extract64(attrs, 53, 2); + int xn =3D extract64(attrs, 53, 2); result->f.prot =3D get_S2prot(env, ap, xn, ptw->in_s1_is_el0); } =20 @@ -2022,7 +2122,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, int nse, ns =3D extract32(attrs, 5, 1); uint8_t attrindx; uint64_t mair; - int user_rw, prot_rw; =20 switch (out_space) { case ARMSS_Root: @@ -2071,33 +2170,51 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, default: g_assert_not_reached(); } - xn =3D extract64(attrs, 54, 1); - pxn =3D extract64(attrs, 53, 1); =20 - if (el =3D=3D 1 && ptw->in_nv1) { + if (param.pie) { + int pi =3D extract64(attrs, 6, 1) + | (extract64(attrs, 51, 1) << 1) + | (extract64(attrs, 53, 2) << 2); + int po =3D extract64(attrs, 60, 3); /* - * With FEAT_NV, when HCR_EL2.{NV,NV1} =3D=3D {1,1}, the block= /page - * descriptor bit 54 holds PXN, 53 is RES0, and the effective = value - * of UXN is 0. Similarly for bits 59 and 60 in table descript= ors - * (which we have already folded into bits 53 and 54 of attrs). - * AP[1] (descriptor bit 6, our ap bit 0) is treated as 0. - * Similarly, APTable[0] from the table descriptor is treated = as 0; - * we already folded this into AP[1] and squashing that to 0 d= oes - * the right thing. + * Note that we modified ptw->in_space earlier for NSTable, but + * result->f.attrs retains a copy of the original security spa= ce. */ - pxn =3D xn; - xn =3D 0; - ap &=3D ~1; - } + result->f.prot =3D get_S1prot_indirect(env, ptw, mmu_idx, pi, = po, + result->f.attrs.space, + out_space); + } else { + int xn =3D extract64(attrs, 54, 1); + int pxn =3D extract64(attrs, 53, 1); + int user_rw, prot_rw; =20 - user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); - prot_rw =3D simple_ap_to_rw_prot_is_user(ap, false); - /* - * Note that we modified ptw->in_space earlier for NSTable, but - * result->f.attrs retains a copy of the original security space. - */ - result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, user_rw, prot= _rw, - xn, pxn, result->f.attrs.space, out_sp= ace); + if (el =3D=3D 1 && ptw->in_nv1) { + /* + * With FEAT_NV, when HCR_EL2.{NV,NV1} =3D=3D {1,1}, + * the block/page descriptor bit 54 holds PXN, + * 53 is RES0, and the effective value of UXN is 0. + * Similarly for bits 59 and 60 in table descriptors + * (which we have already folded into bits 53 and 54 of at= trs). + * AP[1] (descriptor bit 6, our ap bit 0) is treated as 0. + * Similarly, APTable[0] from the table descriptor is trea= ted + * as 0; we already folded this into AP[1] and squashing + * that to 0 does the right thing. + */ + pxn =3D xn; + xn =3D 0; + ap &=3D ~1; + } + + user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); + prot_rw =3D simple_ap_to_rw_prot_is_user(ap, false); + /* + * Note that we modified ptw->in_space earlier for NSTable, but + * result->f.attrs retains a copy of the original security spa= ce. + */ + result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, + user_rw, prot_rw, xn, pxn, + result->f.attrs.space, out_space); + } =20 /* Index into MAIR registers for cache attributes */ attrindx =3D extract32(attrs, 2, 3); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177652; cv=none; d=zohomail.com; s=zohoarc; b=nxO/CtWFzvDxYmECVQazpFRSEu0Uwb6jRxVTgfNkK9u16c2f0yOf/Dhunasdr8yDt8nk9uL7xaBowCChARg5Zb4JqCzy+US9iF5l1OQYxiM9aj8vNVu6qyviwzIB7S3ijWHbNdFRXrqDCM2opaHiCe41+bSP11PIYPlnrb8W1Rw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177652; 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=cQJhsDPGVOwUxFmYhXztN3F3u/xGoBHah5fHPe9a1SU=; b=Kt8WQMLWEirey9wENhfzH8nOCJbOVe7b3iP8feJI3xJppYkaNxljgas7aR/nLT2Hk0zyR7adi+EdcV1r2XdWvrQL9XaR0cdZPFQXn5Nx8VscAIGMmMndpX54gWBVgrQ1n3MPpEGc4eWR+N5Wyk8ARPznaYH3EK8b/Pf+4T+sIPo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177652279894.5802868174213; Sat, 2 Aug 2025 16:34:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjU-0004W8-Ax; Sat, 02 Aug 2025 19:33:44 -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 1uiLhX-00085w-2Z for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:43 -0400 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhV-00054y-3b for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:42 -0400 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-6199bd724e1so54940eaf.2 for ; Sat, 02 Aug 2025 16:31:40 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177499; x=1754782299; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cQJhsDPGVOwUxFmYhXztN3F3u/xGoBHah5fHPe9a1SU=; b=MWcj/yjv4I7Lbq1pAP6EG5ImOmSnAJcwmAEwNmWkvkHBEEbEHJeT78sCorFutZgXCh Hgaine5PcrHPey1eS0ZymFk77T3KUT+LN5NeChvwdBaCXul71K0DKxPdL0WpYyPG6Iin ZIvxnZyDmwEKoSi+l3VbF+mqNahdE5xsy9aBJNLTnF6KwZ8s24unVeiauHFgs0S5Ysco DH1BXOqX9SS8yso6nPLZyC01PVZ/1CyIB7OrijceioJmEfTdOuWDl08jevkH7KG8d0lU P3cC49+HK2QsQQV9CBAJFP8sWGkzK3osRyr/iugE065fbX392aOonruPBgjkAKw6NUM3 pE/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177499; x=1754782299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cQJhsDPGVOwUxFmYhXztN3F3u/xGoBHah5fHPe9a1SU=; b=jGK2XhAPoqBGz5v8jxoaIrjLaqMQXmZ9Jh6u+IuTVBbTJhaJuvtlBqy40/H/iVPxDQ 87NDNi6KH4vIK4lw93UAMkOfzzcrnW+Y908RkWp3Flpzsgiza21ubGrmSwwtRYnfNnPf hgl/O2d6ouY/DHg/NS1usDFwBPf/0Jk2qXzNoc51XUZEmixIsBOpji4wbFNjxUjjHk0u hHY6Ou426Q2AuDplvKKsdUbbJKAtP/WbV+l7QqceqHnlZSLM+dOn8GN8U1jtoIKadLcA oEzsLlLa+A0aCJAYnn7/XGCKU0opWBbxITTpN41nvinQWmMDLvfA3aiogIu75S8GgOIE U44Q== X-Gm-Message-State: AOJu0YxCr0J2Ww1xpvB60yer29aV3BvrEmJvSVVQqt7Vx+3PaAjq3OFv DihfXYX4vAVwgvLZmuQTvipTQ3jH/U7j4+l5Vp4/zYA3xMBzrqSIzuN7UtuyIi+ZBElt50GFX/R wA1zRPOQ= X-Gm-Gg: ASbGnctn+cJ1gXzK9OPRGuTFAMrnbJZkVaBDnrmIGL6wky8tHWv0pUSWrI1O5CkGcIc 6cGCWqNayFxrnF6F+9bRt2Vz2ziC9GTtOvGrkg6liFUW4nz1fbDovxVqyfbTDAiHnvawb+9MOra 4Ob7VUaGK6Po+IClGgAyI9R3PfaFuqjLIjP2Vmar8qa02KX8d5l6xn6n6HzzLon5O339SOy6Qpa otF+zNBDKVyx73bHXAxHazH7CYUO0vSvs3Di7mSg/rrgvEaC1rTRdDh1vRYcynG9toXD12RWjs0 gPs//BpEBYeGRalVf/YrNrxxpGIumbv6UV2yMImeGJC9CIHSRrT20a9vdf6MXFWGO22giYb30rz TkUwzODJihqi3F4S4n0Dlepftu5vJtlf6GIaYMExce6m0JcQV77m3 X-Google-Smtp-Source: AGHT+IHfHVy73Z76KRHplpYZwVFulCEvcsMsyAe8u9oYyA2zmRKftqLafLd5PsFtSI/cW1K1ltrJ9Q== X-Received: by 2002:a05:6871:7c0b:b0:2ea:1e5d:8ad3 with SMTP id 586e51a60fabf-30b6786df66mr2693644fac.22.1754177499471; Sat, 02 Aug 2025 16:31:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 20/85] target/arm: Implement get_S2prot_indirect Date: Sun, 3 Aug 2025 09:28:48 +1000 Message-ID: <20250802232953.413294-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c30; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc30.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177656222124100 Content-Type: text/plain; charset="utf-8" Move the stage2 permissions for normal accesses to GetPhysAddrResult.s2prot. Put the stage2 permissions for page table walking in CPUTLBEntryFull.prot. This allows the permission checks in S1_ptw_translate and arm_casq_ptw to see the right permission. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 7 ++++ target/arm/ptw.c | 81 +++++++++++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 20 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index d5f501bb30..f0e888ff93 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1574,6 +1574,13 @@ typedef struct ARMCacheAttrs { typedef struct GetPhysAddrResult { CPUTLBEntryFull f; ARMCacheAttrs cacheattrs; + /* + * For ARMMMUIdx_Stage2*, the protection installed into f.prot + * is the result for AccessType_TTW, i.e. the page table walk itself. + * The protection installed info s2prot is the one to be merged + * with the stage1 protection. + */ + int s2prot; } GetPhysAddrResult; =20 /** diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 7fd1cee98a..323fc8052d 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1281,7 +1281,7 @@ do_fault: * @xn: XN (execute-never) bits * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 */ -static int get_S2prot_noexecute(int s2ap) +static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) { int prot =3D 0; =20 @@ -1291,12 +1291,6 @@ static int get_S2prot_noexecute(int s2ap) if (s2ap & 2) { prot |=3D PAGE_WRITE; } - return prot; -} - -static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) -{ - int prot =3D get_S2prot_noexecute(s2ap); =20 if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { switch (xn) { @@ -1328,6 +1322,44 @@ static int get_S2prot(CPUARMState *env, int s2ap, in= t xn, bool s1_is_el0) return prot; } =20 +static int get_S2prot_indirect(CPUARMState *env, GetPhysAddrResult *result, + int pi_index, int po_index, bool s1_is_el0) +{ + /* Last index is (priv, unpriv, ttw) */ + static const uint8_t perm_table[16][3] =3D { + /* 0 */ { 0, 0, 0 }, /* no access */ + /* 1 */ { 0, 0, 0 }, /* reserved */ + /* 2 */ { PAGE_READ, PAGE_READ, PAGE_READ | PAGE_WRITE }, + /* 3 */ { PAGE_READ, PAGE_READ, PAGE_READ | PAGE_WRITE }, + /* 4 */ { PAGE_WRITE, PAGE_WRITE, 0 }, + /* 5 */ { 0, 0, 0 }, /* reserved */ + /* 6 */ { PAGE_READ, PAGE_READ, PAGE_READ | PAGE_WRITE }, + /* 7 */ { PAGE_READ, PAGE_READ, PAGE_READ | PAGE_WRITE }, + /* 8 */ { PAGE_READ, PAGE_READ, PAGE_READ }, + /* 9 */ { PAGE_READ, PAGE_READ | PAGE_EXEC, PAGE_READ }, + /* A */ { PAGE_READ | PAGE_EXEC, PAGE_READ, PAGE_READ }, + /* B */ { PAGE_READ | PAGE_EXEC, PAGE_READ | PAGE_EXEC, PAGE_READ = }, + /* C */ { PAGE_READ | PAGE_WRITE, + PAGE_READ | PAGE_WRITE, + PAGE_READ | PAGE_WRITE }, + /* D */ { PAGE_READ | PAGE_WRITE, + PAGE_READ | PAGE_WRITE | PAGE_EXEC, + PAGE_READ | PAGE_WRITE }, + /* E */ { PAGE_READ | PAGE_WRITE | PAGE_EXEC, + PAGE_READ | PAGE_WRITE, + PAGE_READ | PAGE_WRITE }, + /* F */ { PAGE_READ | PAGE_WRITE | PAGE_EXEC, + PAGE_READ | PAGE_WRITE | PAGE_EXEC, + PAGE_READ | PAGE_WRITE }, + }; + + uint64_t pir =3D (env->cp15.scr_el3 & SCR_PIEN ? env->cp15.s2pir_el2 := 0); + int s2pi =3D extract64(pir, pi_index * 4, 4); + + result->f.prot =3D perm_table[s2pi][2]; + return perm_table[s2pi][s1_is_el0]; +} + /* * Translate section/page access permissions to protection flags * @env: CPUARMState @@ -1778,7 +1810,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, int32_t stride; int addrsize, inputsize, outputsize; uint64_t tcr =3D regime_tcr(env, mmu_idx); - int ap; + int ap, prot; uint32_t el =3D regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); @@ -2096,6 +2128,18 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, ap =3D extract32(attrs, 6, 2); out_space =3D ptw->in_space; if (regime_is_stage2(mmu_idx)) { + if (param.pie) { + int pi =3D extract64(attrs, 6, 1) + | (extract64(attrs, 51, 1) << 1) + | (extract64(attrs, 53, 2) << 2); + int po =3D extract64(attrs, 60, 3); + prot =3D get_S2prot_indirect(env, result, pi, po, ptw->in_s1_i= s_el0); + } else { + int xn =3D extract64(attrs, 53, 2); + prot =3D get_S2prot(env, ap, xn, ptw->in_s1_is_el0); + /* Install TTW permissions in f.prot. */ + result->f.prot =3D prot & (PAGE_READ | PAGE_WRITE); + } /* * R_GYNXY: For stage2 in Realm security state, bit 55 is NS. * The bit remains ignored for other security states. @@ -2104,11 +2148,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, */ if (out_space =3D=3D ARMSS_Realm && extract64(attrs, 55, 1)) { out_space =3D ARMSS_NonSecure; - result->f.prot =3D get_S2prot_noexecute(ap); - } else { - int xn =3D extract64(attrs, 53, 2); - result->f.prot =3D get_S2prot(env, ap, xn, ptw->in_s1_is_el0); + prot &=3D ~PAGE_EXEC; } + result->s2prot =3D prot; =20 result->cacheattrs.is_s2_format =3D true; result->cacheattrs.attrs =3D extract32(attrs, 2, 4); @@ -2180,9 +2222,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * Note that we modified ptw->in_space earlier for NSTable, but * result->f.attrs retains a copy of the original security spa= ce. */ - result->f.prot =3D get_S1prot_indirect(env, ptw, mmu_idx, pi, = po, - result->f.attrs.space, - out_space); + prot =3D get_S1prot_indirect(env, ptw, mmu_idx, pi, po, + result->f.attrs.space, out_space); } else { int xn =3D extract64(attrs, 54, 1); int pxn =3D extract64(attrs, 53, 1); @@ -2211,10 +2252,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, * Note that we modified ptw->in_space earlier for NSTable, but * result->f.attrs retains a copy of the original security spa= ce. */ - result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, - user_rw, prot_rw, xn, pxn, - result->f.attrs.space, out_space); + prot =3D get_S1prot(env, mmu_idx, aarch64, user_rw, prot_rw, x= n, pxn, + result->f.attrs.space, out_space); } + result->f.prot =3D prot; =20 /* Index into MAIR registers for cache attributes */ attrindx =3D extract32(attrs, 2, 3); @@ -2260,7 +2301,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.tlb_fill_flags =3D 0; } =20 - if (ptw->in_prot_check & ~result->f.prot) { + if (ptw->in_prot_check & ~prot) { fi->type =3D ARMFault_Permission; goto do_fault; } @@ -3458,7 +3499,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, fi->s2addr =3D ipa; =20 /* Combine the S1 and S2 perms. */ - result->f.prot &=3D s1_prot; + result->f.prot =3D s1_prot & result->s2prot; =20 /* If S2 fails, return early. */ if (ret) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177953; cv=none; d=zohomail.com; s=zohoarc; b=DVe1LK49nhqjrBfC3JwNJT7N+Xw5g8dNAomYE4RGEeEyLaxrG2/WHFENTUKKomoS2GFtq0fJXhiAircL8qQ49+CJWl677I0bpNCV8oC/sAItQi+srYKWwNKbunEYxF4S4LDjXyMwlvG1qycJW+mCOrKcoIXE8pkyqbMDDamwD08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177953; 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=BgqEOYuQ75vNcJCSdrIzICkpbTEEoH2jCjP3tSq0CeU=; b=ijrF/FVAOToUGsozpJX0Hu6vFnsTsoDhSfO1UEqHfZDTZn1riEKN173+9Syp6vtzeTkOHxLVdAMdIUKIEV18attDHys/3zdc11Xnyp+n83gAXVqJCE0mYjHxoAP9JkHNoAN9IH638uVK1HwD0K6JSyuxFY5ZeYPJCUWyQ5IKLn4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177953002269.55141618829043; Sat, 2 Aug 2025 16:39:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLk5-0006Q7-Vp; Sat, 02 Aug 2025 19:34:22 -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 1uiLhb-0008L1-29 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:48 -0400 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhZ-00055h-Ai for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:46 -0400 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-61585dfc8f8so1030171eaf.0 for ; Sat, 02 Aug 2025 16:31:44 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177504; x=1754782304; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BgqEOYuQ75vNcJCSdrIzICkpbTEEoH2jCjP3tSq0CeU=; b=vYEPDy8ymaISDKW/roe8jb9kHAWtBxutjcnXWm9DklnZmPc52jEhhYxJT64nCvhV1e MWjzmAzRbb+IgiQR2OlKOXBdGC7PlofElNIRkO1IGUgOpfYwLQwTeal4remoDEh03b29 dHuBEF6JGphffKfLr4ck0BflZQ8Jhl8RYrywx3Lja1oDd9ida4BJNXlFkPUdtBu3YWdc 3ERrEPVCPjUOcmTSPhEQTfytOG/hBfIHTaBGp9RJTf/zY+YRd8edABml2pBGovilu59S HBvfA7jhgh6o11uXOceY6eQvXcFgDofztVCbgGC1xzMYglf1ojs83CTbls6NheDXaV+U RTbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177504; x=1754782304; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BgqEOYuQ75vNcJCSdrIzICkpbTEEoH2jCjP3tSq0CeU=; b=ab1O6EkyhTEu7mpn50ZqXgZNislUILVBnvwPcOxZJa0TSiSIc05Y2Zg63GNR1/WzUP QRjf79G2HzYNO6OPWe6jB62n7tqEJF1N4qh/3csmmPBK24fPJ4kFz0Yh0JDegZ4Qy0vR lipDzAZwpuYTFncP+vKL84S7fyJ4xAX80e5EsZrmLo0YFfu/uUEueCI48IzWVY8jWlrU vMSGgGEktbrVM9G/zuQisO3Y2NN8WtZEjNh5DPQRh+QhgZdVP5qTtaDb065+f0K/N4lf n7jw/3gYDFKAPsKWojblf+7M2BwjnRIX7GQCTlMR8yQDFxGor0XJEoLsg9P/7ixSwJj/ evPA== X-Gm-Message-State: AOJu0YwugcmB23KAvvz5Z3oWxOycAYObnSXz1Fgc5leTAW+GDAiGZN+7 eP5SrGBR5yePGpm/tiom40NOAN2FwxdFjPEsuPnLFADor+QY4IQ6BLpEsgYW10An9C8il/fm3S8 RiiJXI4U= X-Gm-Gg: ASbGnctBGqSKni4e8rPHPwuxN+/DHfY9mgpdXTk9Gn5p8eNSwPQdBRbjTp2B0aexKSS sv0BNCX35o9fjd5BBzba5na/YcGK7pobS/NTPuZIOoQ60mHWd4z2g+JHgwKJpR6ZpZ4q5TQNBgZ u+0kQ9jfmIJg94ryxkqm+rSGKklWjpJtlDS4lJnXGoicchGhhjfUcLvOc2b3PdLTasiUcoeVpEP EKBXAXRE8tuEkfWEsSEtAbM+/8wH0JCIbcINgVWe5a93FapWmz3OetaXUXmucaVcdz2rV98roMZ eV9sSILouLTrVAa3kja5VhZgkZ39jgNWr3LlX0WtvF33SMZxxjzGQt/gfUY0gXGHubmlqXL+5I5 5jHcPiIkou5gV54FWGMf76lP2yq+h1t+9EMd9RxqltlStEGHGLq/o X-Google-Smtp-Source: AGHT+IHtEOUAuUbj++75YcgF7NQQy2YnkbT0alq4xC5LV8Vs6/iw7qXg1Z2gSOyFd7RPZl8FM8oeAQ== X-Received: by 2002:a05:6870:b027:b0:307:b2c9:9f99 with SMTP id 586e51a60fabf-30b679b882fmr2242587fac.39.1754177503826; Sat, 02 Aug 2025 16:31:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 21/85] target/arm: Do not migrate env->exception Date: Sun, 3 Aug 2025 09:28:49 +1000 Message-ID: <20250802232953.413294-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c33; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc33.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754177954392124100 Content-Type: text/plain; charset="utf-8" These are not architectural state, only placeholders between identifying the exception and delivering it. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/machine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/arm/machine.c b/target/arm/machine.c index 6986915bee..8dbeca2867 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1085,9 +1085,9 @@ const VMStateDescription vmstate_arm_cpu =3D { VMSTATE_UINT64(env.exclusive_val, ARMCPU), VMSTATE_UINT64(env.exclusive_high, ARMCPU), VMSTATE_UNUSED(sizeof(uint64_t)), - VMSTATE_UINT32(env.exception.syndrome, ARMCPU), - VMSTATE_UINT32(env.exception.fsr, ARMCPU), - VMSTATE_UINT64(env.exception.vaddress, ARMCPU), + VMSTATE_UNUSED(sizeof(uint32_t)), + VMSTATE_UNUSED(sizeof(uint32_t)), + VMSTATE_UNUSED(sizeof(uint64_t)), VMSTATE_TIMER_PTR(gt_timer[GTIMER_PHYS], ARMCPU), VMSTATE_TIMER_PTR(gt_timer[GTIMER_VIRT], ARMCPU), { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178999; cv=none; d=zohomail.com; s=zohoarc; b=PbIfJrlLSarC6ASwgOV+O/1g207y9h6TlUWBxzXr4lVB04ZJIa/hJh35YO1ow7cQoupW6kboiu/5VL4X6LJMKzGxJK0I/lu11w7TFeF0WR5+tLi3gvE/+xqIfUsBTbsUon8QlwTwWF6+LY2FqSu2mXx3JRQLDJxTE7jE5MSvuXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178999; 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=NR3W5du9ZFi4qPy6YJwkknWURFd+s6CJ6eRMr5OXqWE=; b=b9Y2AqqS0R5uSKCj1QRClTUQ4/v+JbcW8izgWj2TaOwc5BXpbw0wCZQBsXFWm2w6u7Ti9rkaotUok+1Ampj0MhraJ3ka7CDWdTGXxhmexdobnc8tYLStiYP3dmXfU5WUYo/yYQbqbjRJPcpdHRhy7AwOVDouv0onr5RtYarxe0g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417899933362.32290165738959; Sat, 2 Aug 2025 16:56:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjl-0005HD-2w; Sat, 02 Aug 2025 19:34:01 -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 1uiLhe-0008OW-8a for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:54 -0400 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhc-000569-TJ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:50 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-30174a93186so2672590fac.3 for ; Sat, 02 Aug 2025 16:31:48 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177507; x=1754782307; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NR3W5du9ZFi4qPy6YJwkknWURFd+s6CJ6eRMr5OXqWE=; b=NT9xT0zncpoYCgpt+cP0ZCPct1QsOXG0V3zbxmzV5L0zbmiooomVF3SaFrnawA7KDg 8pIGxWqNFuynYffQWogifF3QanXKmfVCwZ1DY55bDEZpHmoblIFK41+/p76N8S2+elen uvKJopGRnTxpqzuOaAfEVuC0CedJFgQZuRAJHIhPERZDhPy8bB6qaUkVHB8zQJD9s5Xj DPCGl2BB0R8ARd+g+lzWdY3YyLPW6nMyJJ+jy9PscnGjRXZWDu3URVYlTzfNZGaYTdeM DnkAkFfT4MLlQjDA40be4vZ4o51K2gVXcNbU2npmOljhR384GDdaiWc2ZwklsGb7uX80 x6mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177507; x=1754782307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NR3W5du9ZFi4qPy6YJwkknWURFd+s6CJ6eRMr5OXqWE=; b=mbWqD8J4LBYOV3NstoLC/Bmu3T0xhArIML8blv95dmgK+YGohViiVORf4h8Xcx/1MZ p8hwWJcd+V2i5fmnQdtFTGgc+rCHZ/Q02ikwb9E+gQ6+FlLGqGCl9Flp9I3iXFS7BGg3 qJpBjuxAuq7jb+6sx3Xu2ey365MZfi8Yde8y46uBwrSasCDjznnwIYKUNLeIARPA4hIi h49mXVg+PD7mgtV18juTMKriqtqFTZ//dRFwhzRAXf4tbkp3eJUU9uv1oGvywBQaXSKn 4fW/U/DlXl7CE+wIBDXmw8QMI3jByGnTCqafgLPR59CeL/V9iKCXEONqlPuUPOCyMamM 6Epw== X-Gm-Message-State: AOJu0YzMLwjfoDOUBuY+REaCTcyqa5l/h7mG/eQBPD4IGkqeNLKRhOhl JEQNcUm/uPoAMQCvNdF7TusYir4EoFZ9uP5QAO2sDPwa7rdBHaqI0oNSxjKja+SyX3jOqS6eIzI fglLRkVc= X-Gm-Gg: ASbGnctdTg7Thhs9TnB8MeLMNZKEuBoRLJtHklYqZXwblPsGn9DhYxtVOKFAsq3/lU/ 0yjPSKqYcwGUQn/+73oQHKkrO/fq2U092KsiwlDxBBbKPyO7irRCPJT2z+E5H8qkgd2W4iSlopX /U9CI8FsypjtHIL6cf/Pfr7kLfrX5vpxtjLGrdAk/5e9St8WAr51fodYQ6P2BCA35cct4LGKVYU g/Dzta2sZsA8rJcQUh5MJ3OJmHIQbunFarZJwhLpWRZmeWxz5l8CztwQNnto9ZA58+a7LX3Di3J vDSWUOJwkski3QskTTHS7OvYHlZVQdNKQRdhUCoGpF6UY2CYdJiNvZi3oFYPZtnji4GBgzUQGHg NuiQhMNDIADicE5RYeQ2tuGj1A+feZhBzntDtimxrO01EFJh4NZDK X-Google-Smtp-Source: AGHT+IGJMnEvtsvIBqloejw81L8/1dMitVLEcq4M/I1eq0MXKlQ4VMhdYJBeYpOUnEQZvfKa8Of4dA== X-Received: by 2002:a05:6870:d32f:b0:307:bba1:d09f with SMTP id 586e51a60fabf-30b6768a30dmr2446653fac.15.1754177507685; Sat, 02 Aug 2025 16:31:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 22/85] target/arm: Expand CPUARMState.exception.syndrome to 64 bits Date: Sun, 3 Aug 2025 09:28:50 +1000 Message-ID: <20250802232953.413294-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179000012116600 Content-Type: text/plain; charset="utf-8" This will be used for storing the ISS2 portion of the ESR_ELx registers in aarch64 state. Re-order the fsr member to eliminate two structure holes. Drop the comment about "if we implement EL2" since we have already done so. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpu.h | 7 ++----- target/arm/helper.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index fb87fcc3e6..4940bd6a45 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -644,13 +644,10 @@ typedef struct CPUArchState { * entry process. */ struct { - uint32_t syndrome; /* AArch64 format syndrome register */ - uint32_t fsr; /* AArch32 format fault status register info */ + uint64_t syndrome; /* AArch64 format syndrome register */ uint64_t vaddress; /* virtual addr associated with exception, if a= ny */ + uint32_t fsr; /* AArch32 format fault status register info */ uint32_t target_el; /* EL the exception should be targeted for */ - /* If we implement EL2 we will also need to store information - * about the intermediate physical address for stage 2 faults. - */ } exception; =20 /* Information associated with an SError */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 168557b08f..9447d7ba59 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9438,7 +9438,7 @@ void arm_cpu_do_interrupt(CPUState *cs) new_el); if (qemu_loglevel_mask(CPU_LOG_INT) && !excp_is_internal(cs->exception_index)) { - qemu_log_mask(CPU_LOG_INT, "...with ESR 0x%x/0x%" PRIx32 "\n", + qemu_log_mask(CPU_LOG_INT, "...with ESR 0x%x/0x%" PRIx64 "\n", syn_get_ec(env->exception.syndrome), env->exception.syndrome); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177723; cv=none; d=zohomail.com; s=zohoarc; b=kb5cGWsULt23nHObhzdoX+hn3PXbmNkTrYLdQ3PLQpL+L/2UBQerf+ON4j/fFKSkgSP1BukXQmZRBDx+cZeHeUUkeQlem/dN+2GdJxKXbwcbQv36d01q+CwTjpYb4258RNQJvHmjOyt15UTgnPaYCk7bUKnXGJeb0g60yNWhVjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177723; 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=zGaWh6qB/XNYeP5vG0YKYiWrjkJVNrqnpJ3x4KugETg=; b=maWCn4021qYYn4IDxJDlPm9EPB7wvnNTuM5NsweipQLvK6c6ljT8W6UowIi5HyjxUZCCFU7QDb/FBGudxaxAI5P/P2zizl1f1f3WWvYEvePL2T2NpVpoDzpckh0jm+Rcwja1WeHTiLCey8kiBOTN3RTsm+At7OsXVkL3ipKl0Fk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177723751446.4348481297054; Sat, 2 Aug 2025 16:35:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLkK-0006pp-Mc; Sat, 02 Aug 2025 19:34:36 -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 1uiLhi-0008R2-QN for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:55 -0400 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhh-00056f-20 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:54 -0400 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-61585dfc8f8so1030194eaf.0 for ; Sat, 02 Aug 2025 16:31:52 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177512; x=1754782312; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zGaWh6qB/XNYeP5vG0YKYiWrjkJVNrqnpJ3x4KugETg=; b=JL23AYsHSmpbzDwC6HBVTjOfyy6MP6m3D9GVtsBTYUUBPZrfGU/8VD7yD4MtXc14zB emVQysWGrVQ87DQ2uaZS54YZ0gSQY96lBgeJ/WoKwMM3aPU7xVvDZl9uancIHIYKyq8Z RZKS6vVAVs02QCX/2Po8dNVjbNuHOPv3e/OduU2jH99IBZHNk/XO+OpUbN+R/jrylj0c cGqoL4XWui0+tGMuVv2vVZQZ/h0QQ8pZnK2UL2P7BuN5HWPTSlZNR8mV6Vlv7P7r4D3H jaPvpO0Hk/vGeYG0LoDXS9OkDixrlKiNAOebaarAczg+pBlaExfc2ilaYtxzUA6th8cQ xMnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177512; x=1754782312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zGaWh6qB/XNYeP5vG0YKYiWrjkJVNrqnpJ3x4KugETg=; b=otJxYmKlNWqGIzqSraCy9KmUHQBiname2TFSx0kdOC2yv+7vY+GyDpJ2VRhEJMozWQ zi/LtYsX78dX9BxwV/VkVf62HK83aj09S4E1qK1BjxPTf5Nz/3VX238xH0ue3nBPf6du 0O5lslnStxqEbjH+UQnHPsiPVAgMrmkSB5Q9hs2xqnAxiyZg3CmrvpFkKVFHBQs03V/6 XsfJg9LqXU0+bOm4r4F3rEv+3IKbAAae2zAjbs4BJioa66Bp9ug//xlBSf01tQmg8Viy +9+mQBez1NtP3ENyPVtvzJKSIOJ58SXzeJ8+B2Wt5q+EoMDbb0kGvjkJXMOqSxxtlzeI tMDQ== X-Gm-Message-State: AOJu0YwIeHnuCNGBtMMAKuNG3K1Qu/6IczzgzJfHZEW+CPQy9D0OkMX5 QOiEFpmaKBWy05F93DE4RKob7xFauUm+Tk6O5w0b/3TIcw3aCsB8gAoIWPFbFMXhZ9vpdNIfX2a sZNVWnFA= X-Gm-Gg: ASbGncuT+XQ5Fo0jcl5DjD+PpPIgU5Go3LAiw+eh25huj4SY0qTs47wqNquCFyoz3iz lmU4QXyfAsqi9pnR0YE85G/WhGjagzH4hhGs+01u/1fr1KXsEQuscgfmTu1kOcd+VkV4Bik+L2E Bv5jNr/ROCNfJQVdTOiw8X7/uaoaP6OCjPErsq7tc/FVBvTGepKGCf4sr6uB9fwtmaQDQPLtkej EaLoAQOAyYHFcJr4QuqOsTTFNItLFmocAkxhtotArY4ScLegBZU/+RWXHba2w/sTPmDvImVftek T/xHPA92OYedzSad1ZeI9Wm42TbySedSNh6mcZ0fiWROKtgQcGCU6GEMFocQM3d5gNVPoAAh7BD CBCnTHgU/yKGcj/zye3/g3DJXdDQcDdMkiNfJMsfegQtMgOaRBtW1 X-Google-Smtp-Source: AGHT+IEYragkG9sFyeueBHpelys0pg8+Y6YrfUjagcM1Me2m42UOdmWOFIzaoKnmJ7tpZtd4lURflw== X-Received: by 2002:a05:6871:2881:b0:301:1218:60a0 with SMTP id 586e51a60fabf-30b679a5575mr2751857fac.34.1754177511972; Sat, 02 Aug 2025 16:31:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 23/85] target/arm: Expand syndrome parameter to raise_exception* Date: Sun, 3 Aug 2025 09:28:51 +1000 Message-ID: <20250802232953.413294-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c36; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc36.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177725803124100 Content-Type: text/plain; charset="utf-8" Prepare for raising exceptions with 64-bit syndromes. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/internals.h | 6 +++--- target/arm/tcg-stubs.c | 2 +- target/arm/tcg/op_helper.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index f0e888ff93..fc82dd65e8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -306,14 +306,14 @@ FIELD(CNTHCTL, CNTPMASK, 19, 1) * and never returns because we will longjump back up to the CPU main loop. */ G_NORETURN void raise_exception(CPUARMState *env, uint32_t excp, - uint32_t syndrome, uint32_t target_el); + uint64_t syndrome, uint32_t target_el); =20 /* * Similarly, but also use unwinding to restore cpu state. */ G_NORETURN void raise_exception_ra(CPUARMState *env, uint32_t excp, - uint32_t syndrome, uint32_t target_e= l, - uintptr_t ra); + uint64_t syndrome, uint32_t target_el, + uintptr_t ra); =20 /* * For AArch64, map a given EL to an index in the banked_spsr array. diff --git a/target/arm/tcg-stubs.c b/target/arm/tcg-stubs.c index aac99b2672..aeeede8066 100644 --- a/target/arm/tcg-stubs.c +++ b/target/arm/tcg-stubs.c @@ -16,7 +16,7 @@ void write_v7m_exception(CPUARMState *env, uint32_t new_e= xc) g_assert_not_reached(); } =20 -void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, +void raise_exception_ra(CPUARMState *env, uint32_t excp, uint64_t syndrome, uint32_t target_el, uintptr_t ra) { g_assert_not_reached(); diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index 575e566280..46a3b911ec 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -46,7 +46,7 @@ int exception_target_el(CPUARMState *env) } =20 void raise_exception(CPUARMState *env, uint32_t excp, - uint32_t syndrome, uint32_t target_el) + uint64_t syndrome, uint32_t target_el) { CPUState *cs =3D env_cpu(env); =20 @@ -70,7 +70,7 @@ void raise_exception(CPUARMState *env, uint32_t excp, cpu_loop_exit(cs); } =20 -void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, +void raise_exception_ra(CPUARMState *env, uint32_t excp, uint64_t syndrome, uint32_t target_el, uintptr_t ra) { CPUState *cs =3D env_cpu(env); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178678; cv=none; d=zohomail.com; s=zohoarc; b=SL4QQQkd2+CapNiqubSyr8K9ouAPWHUxvglvD36d1hVMugoF5VNooXx0xR6rZ0gWoiZI/FFDE8+L/g98Ovx7tswHHPkXCkG16eoOQiZBQxHVEmV1wUKxMt9pd2BkiVk/3IAk28tEergXwyGnJ6vi5qx/6Q8R+3KYK+JIHxB70N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178678; 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=TtfdJAKHkhBXVVur9KnTeJdEj0NKkUPLOFyccsCQyeU=; b=NHY+99CKYFpv/17fDDxW5IlosJJNpoFE7fYPUVpXd/ewsvZA5XNpSUer2zFhsdO4Cf47+QGLEtBNBQtF14kzg9ZJabDlCWIyqpLEAdphRpKRTzE4DjW9nzN3/HrXouTeilrj/WL60TdxMDQqkRhQlZ2lVIlhRNwpSGbMN9szdPU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178678866287.8983306677544; Sat, 2 Aug 2025 16:51:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjn-0005Oi-Uj; Sat, 02 Aug 2025 19:34:03 -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 1uiLho-0000AJ-54 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:01 -0400 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhm-00057c-EZ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:31:59 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-2ffaa884a44so2080930fac.1 for ; Sat, 02 Aug 2025 16:31:57 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177517; x=1754782317; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TtfdJAKHkhBXVVur9KnTeJdEj0NKkUPLOFyccsCQyeU=; b=ja5tKzs6yXhp3ae36h5mQaZxwfZZJEfoxY1ZsAiosr0FKRKaFf6ZulY97coYxv6nN+ jYmaeoVulsbej6EqlD/o2by0sE7oeUKXAWOmPaWsWo3SCWl0/47svLjTtab6xdEHZo+l 8I08MGjnQUuXldGFQ7YH01UuL10tVWZQC8d/JKGqaJZMGNnnpwP4KYUj/aZQf9NlE1xf Otuit4h316JqEmGxIJ7bb/OeAOrOIJj2eB5ZPKQdpJDyYGX6bz2RTriJ/FtMc56yWN60 wZmM2DcxoKV2I7cIwwFV+bmkHYOkJ+fplAXGwAbem0jOHwy62sYQjwjuUruga0VK/JeH DYmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177517; x=1754782317; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TtfdJAKHkhBXVVur9KnTeJdEj0NKkUPLOFyccsCQyeU=; b=w0A74bNyjnUJczKj+Hjb4J50TaJnDt+iQUg9aM70HK1CXTBI55x/hvzN2kx9XO0BcI AvrYhRprcCWUl2mywSlrZFV6jwsVQusrBEnPR+f8IdFB5+8Wz/9l9Uj0goKdowQc9sQ3 KXauaRfO3bsnMivOe/WVUXN9PHnp1kc1n8Esfo/4LX/w/tUpyHV6BJ9P7opWF6vP0n1j iCH8dLPC1YI3RDFAcjbX71Zrny6YX4ODUWykw4xEQ7ebTHmlQtFRb+f1F8kU3xhbzVY4 aSIfGvAyskuwr6k9AjRNEBmu5p5jBdQ8Tsjq+YTWhIeT/rOn4lD7C7+Qu78iKr6mM2qT IklQ== X-Gm-Message-State: AOJu0Yyh06ablgIInl4Zv1CSCaE+uvQ05Hkgz6vNAcmhX84PnKchRUcx 4cpLVbVWVsqQvl3PXmfZM7rJ3JSZIlKWnXqHnHlsWMoH0TZ0uQpHpF2+1kpwOaz42zywlXcc2M8 GpMxzH6w= X-Gm-Gg: ASbGncsCAcuXTO4UNybrrFQHkluwWiQWrr3M9DZyUnVf4hXOtIAh+Np46xYJKDiT9/e vtS3UL0Ze/GxRBKmg6/KN2JVCVwSyWHd5NfVaWFhvJIeTzOYiocr9vmZyf3m8RyCWXTFINrIzrt 4Eex2VrkUtqIPx089qlA8UXx80ERurbSZ6H6QJ7PzNcfKjf/hbpXWbTydGLf3WN6UARALc+GUOH u2nJjRwwQqgly/NipCh3LuAEUgPtpYSXk7jluwc3MWJZjk/kgKwuzOmoHm+hs7/PjLF3T5ZumW/ bvbWb2DcoJN67XG6COtnls7JdutrJ9JuZrbE78j0znH34ttnu+02LZlEnWP7rFlL0nryYowcFfA oJKyxwYZngpZGDJ0kaElISx/aIGwYQYyTw8g+c+mOjZn1R1Hpm5Ka X-Google-Smtp-Source: AGHT+IGazccfX3NI/VYEnzo4AbEkGmch1ZTBvtJ6fLmfxKA3gMvnFQLPP+p/a9QEWaUbsXUWnGziEg== X-Received: by 2002:a05:6870:a44a:b0:2eb:9fe5:d06c with SMTP id 586e51a60fabf-30b6685b897mr2728877fac.3.1754177516873; Sat, 02 Aug 2025 16:31:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 24/85] target/arm: Implement dirtybit check for PIE Date: Sun, 3 Aug 2025 09:28:52 +1000 Message-ID: <20250802232953.413294-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2b; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2b.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178680139124100 Content-Type: text/plain; charset="utf-8" Both S1PIE and S2PIE have a bit to make software tracking of dirty pages easier. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 1 + target/arm/ptw.c | 16 ++++++++++++++++ target/arm/tcg/tlb_helper.c | 12 +++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index fc82dd65e8..b6499683cc 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -754,6 +754,7 @@ struct ARMMMUFaultInfo { bool s1ptw; bool s1ns; bool ea; + bool dirtybit; /* FEAT_S1PIE, FEAT_S2PIE */ }; =20 /** diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 323fc8052d..820d5e65a0 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2306,6 +2306,22 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, goto do_fault; } =20 + /* S1PIE and S2PIE both have a bit for software dirty page tracking. */ + if (access_type =3D=3D MMU_DATA_STORE && param.pie) { + /* + * For S1PIE, bit 7 is nDirty and both HA and HD are checked. + * For S2PIE, bit 7 is Dirty and only HD is checked. + */ + bool bit7 =3D extract64(attrs, 7, 1); + if (regime_is_stage2(mmu_idx) + ? !bit7 && !param.hd + : bit7 && !(param.ha && param.hd)) { + fi->type =3D ARMFault_Permission; + fi->dirtybit =3D true; + goto do_fault; + } + } + /* If FEAT_HAFDBS has made changes, update the PTE. */ if (new_descriptor !=3D descriptor) { new_descriptor =3D arm_casq_ptw(env, descriptor, new_descriptor, p= tw, fi); diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index 23c72a99f5..ae2acd6727 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -24,13 +24,13 @@ bool arm_s1_regime_using_lpae_format(CPUARMState *env, = ARMMMUIdx mmu_idx) return regime_using_lpae_format(env, mmu_idx); } =20 -static inline uint32_t merge_syn_data_abort(uint32_t template_syn, +static inline uint64_t merge_syn_data_abort(uint32_t template_syn, ARMMMUFaultInfo *fi, unsigned int target_el, bool same_el, bool is_write, int fsc) { - uint32_t syn; + uint64_t syn; =20 /* * ISV is only set for stage-2 data aborts routed to EL2 and @@ -75,6 +75,10 @@ static inline uint32_t merge_syn_data_abort(uint32_t tem= plate_syn, /* Merge the runtime syndrome with the template syndrome. */ syn |=3D template_syn; } + + /* Form ISS2 at the top of the syndrome. */ + syn |=3D (uint64_t)fi->dirtybit << 37; + return syn; } =20 @@ -176,7 +180,9 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, int target_el =3D exception_target_el(env); int current_el =3D arm_current_el(env); bool same_el; - uint32_t syn, exc, fsr, fsc; + uint32_t exc, fsr, fsc; + uint64_t syn; + /* * We know this must be a data or insn abort, and that * env->exception.syndrome contains the template syndrome set --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177718; cv=none; d=zohomail.com; s=zohoarc; b=gOw5Uk3KalIHdnCOupbbLcXNHy/43SsDH30u8v7G9TWYekDMoYGVCjPztn2SC8Ci+L5TY5myxjvtbTfNIl1i1OcIgRl+MF9IHt+ZE12lEL2MS3MCekiEQedc0zYNgNh2Sg2PwEL1lbNfqdCRCAfY2ZzMSvElsnS4GmHHheojtms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177718; 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=80S2/0N0JL09bgOILR4cEYvK2n2zuzmPlht61UmRSoo=; b=BOU68iQmsHymxAk8q3tCThlVRE25zp3ll/RfG6dboffGk6/quppUn/2LCmlmfCoqSisByblcUQBk2vY8EuX/IPpoLhSHaXx9dsmuh91wPoXSqWQfDRM1y117WGYG87czmQGdZY2Y2n2HigL8K7WIZQurnzXfn+nn1hqodlLl7ME= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177718001974.4434165123757; Sat, 2 Aug 2025 16:35:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLju-0005gl-8n; Sat, 02 Aug 2025 19:34:10 -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 1uiLhr-0000Dw-Kr for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:04 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhq-000580-0X for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:03 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-2ea58f008e9so1258477fac.0 for ; Sat, 02 Aug 2025 16:32:01 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177521; x=1754782321; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=80S2/0N0JL09bgOILR4cEYvK2n2zuzmPlht61UmRSoo=; b=LScW97aWc0IwGO6fhEQ+m+0cV8bwSBrDcoDwlMfY2jRAnMQ20EWNS5ZwjMoix3CW2P aeR/xo6Uv92STGvz5BmfK1pCeB87C03t1ehulRqZCLFlicTQbjk1CvEzwEe2q1qldlAF QUcsbjyb2krZa/iR4DEjvx1wXqw0aDDElAD7qlJFj7kzkemUwrD8Za/BEAYYFSL2umLB 94MYuqrh/CSVYhbkM0f/4l9s66RWXMLQ+iU1MGxczipD84qfm3VUkiSEGkhYDeOTShRJ 5CHSHEg1gOMTXeSNOjvh7EOChTTIjWh21hO8ziSCF+zBTWkA0TMUDqc/rUN7oqmXBc0p mDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177521; x=1754782321; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=80S2/0N0JL09bgOILR4cEYvK2n2zuzmPlht61UmRSoo=; b=qNOaUyVFItEqj4BFiX6kIyWGyn8SXImksRxSaB48by/ylpWPROAd03LFknHzww3zYu DIUli/YwwTr0SgGBuSFmDlydV3au9ETe8H3EHepp1NueZ7Nbo12otjrH09hSUOhl2LJS 7H9r3ZCPFA1mUv1klsPAr6ODfTT1CXJlKZtntcxjDpAou4bHomTfouTnzEmcbaRpbcYp fZsabK35pEQuXI6DScvE6t55wZ/1UPkDbjhiwdznHz3LO0dP0yylEjpr4vw7xx85WsAp KfzyGRp1yFHm9qMp03+RUo1lPENVvW7uhvQzx56Fh6D3ohwB86UeLZhkAqW8idNO8V2M w4pw== X-Gm-Message-State: AOJu0YxBdnybYXjbp/82lbLkTRwTRY3Cbk2x8eer0/4TjfuPdZ9vtaD1 LfnjfdnVlqHpSbIHlEFsDnrm1K5v0+damDPaWDl5kV7ebkRKaA6HVhdMaprlRpLwWgkNV0VYD3D hOLf0uXg= X-Gm-Gg: ASbGnctGog6cht1QVQ4fxy5lYjUwY1r4yKn0tB55gXIP5qJNQ7/EcwvaFHMScEcR8J/ uUrFpAbNEAkf5PjWXbLuJzmm0ZzGxFiKaoY0tHUMIQWTjpyV+aCnIRWsAggJyUFwa4N6kjIOqqD sjL+pY2Pmj2EEUkjjszgH3eALXIYFOOHSxZwNI4MHs33CtZ4S1QgSDYU0yShVc5J/AvwPGIzrOn AmlauYxub+pNZ8NZA780LVB11NlJ58GRZlE/fHIQZb0/+gJVfrNAJxZl973wrZ1py23i2tMzT7i xCvlaQA5kqMZL0JSDKqSbvHaz8xlist5CuGb4jYJozZiMDNFmsCLwFE7Rs/Jn4i+dm186xk1Spo ovfK0qBWOVA7viKbaAbdr9aBJ22f/5gC7aIzbBvjTr+T04d/t4ZjE X-Google-Smtp-Source: AGHT+IFSiTLcFvVavDCnFphBzVtRMt+JjFpj/cVl2bCVv8zeGfITTueW6pivqmjt8DD2xzwLTi9pgg== X-Received: by 2002:a05:6870:e30a:b0:2d4:ce45:6990 with SMTP id 586e51a60fabf-30b675d5eb9mr2582942fac.7.1754177520740; Sat, 02 Aug 2025 16:32:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 25/85] target/arm: Enable FEAT_S1PIE and FEAT_S2PIE on -cpu max Date: Sun, 3 Aug 2025 09:28:53 +1000 Message-ID: <20250802232953.413294-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177719715124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/cpu64.c | 2 ++ docs/system/arm/emulation.rst | 2 ++ 2 files changed, 4 insertions(+) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 22ccc4f697..f4a41c854f 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1253,6 +1253,8 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64MMFR3, SCTLRX, 1); /* FEAT_SCTLR2 */ t =3D FIELD_DP64(t, ID_AA64MMFR3, MEC, 1); /* FEAT_MEC */ t =3D FIELD_DP64(t, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPEC */ + t =3D FIELD_DP64(t, ID_AA64MMFR3, S1PIE, 1); /* FEAT_S1PIE */ + t =3D FIELD_DP64(t, ID_AA64MMFR3, S2PIE, 1); /* FEAT_S2PIE */ SET_IDREG(isar, ID_AA64MMFR3, t); =20 t =3D GET_IDREG(isar, ID_AA64ZFR0); diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 1489c262b8..6ebf9c9ce9 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -123,6 +123,8 @@ the following architecture extensions: - FEAT_RME (Realm Management Extension) (NB: support status in QEMU is exp= erimental) - FEAT_RNG (Random number generator) - FEAT_RPRES (Increased precision of FRECPE and FRSQRTE) +- FEAT_S1PIE (Stage 1 permission indirections) +- FEAT_S2PIE (Stage 2 permission indirections) - FEAT_S2FWB (Stage 2 forced Write-Back) - FEAT_SB (Speculation Barrier) - FEAT_SCTLR2 (Extension to SCTLR_ELx) --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177991; cv=none; d=zohomail.com; s=zohoarc; b=fHmdYj3sGjR72/cQA3+bP2FS+SfAn/FSBvsvQkFcp5Rfltp3JzbOvB6opu+DlpMJN7tvN5eqs51G6BlSDWT5DWQBrCKMKrrfBXTMZYRjFexPcwUUZNNJfgSaW5nyaNoaxxLVMq7z94Ij1njfTy9zMVQBqtlYA1P52iVH7gxq5/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177991; 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=yzErdxa6ZkVBa6lEBDxGiyKzAGuLJ7HYtDGlIeknl/c=; b=gYj0UM1KZ2XDEW7rMLqe3OLZiZn9Bqd7CMCy4JonNmxp3+Hzro2t4eMlD6tzd9ljMbvhaEEeEySDNVydfOiYQ4/LmAmFa8lLAH1WjKdzmwZdFvwoxr+9xt2MY3Y/fmS3mbrPQkeMHRpInVIMSY2bNYoCK89MVBbOXK1xSig1ppA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177991013252.84521913630533; Sat, 2 Aug 2025 16:39:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjj-0005Cg-34; Sat, 02 Aug 2025 19:33:59 -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 1uiLhx-0000MB-Uo for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:10 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhv-00058n-1T for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:09 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-306ab3a49d6so1700801fac.0 for ; Sat, 02 Aug 2025 16:32:06 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177526; x=1754782326; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yzErdxa6ZkVBa6lEBDxGiyKzAGuLJ7HYtDGlIeknl/c=; b=JO2ugnLM/HnSN4qFIufPutaGyuha/OtYDjhhxg/pJRGSbMz4HjkoC6/WYhr9h9TaTj Kt51NgUXgO2k6A5m+rv5uiRb0zcO8SB9bUac/ibbdJwBWzQHHx8aA1gX1pPoNhg6eLzH noSqkLmFqMRxb6isQOn1BepOjbDP1xCTp0unVaOrPneuOpPqcGMhIIxnhIvO7G3GqFTZ ENaSPf4BYZdrm8dIiDBIUhJMMWohfsiIAdCOwPq2F8fcwJWjZnjn4vhyMehNj2WA0rGF 2d0UhUH+Fn+hR3BhncE2ckLUZPGCLFTEtstEtD9gncxut4NCafLOuwzFRXLBOXupb3dj Tikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177526; x=1754782326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yzErdxa6ZkVBa6lEBDxGiyKzAGuLJ7HYtDGlIeknl/c=; b=ijHaRLv2SIDnaWiueZ/7keDvW3T73jIQrY8F5MvfDp+PCIfPlmBR16h9tT/E+EkNuG 5RJLSY1WaQjOYYWp8aFo+qsY+G+LVvHrRrKag+WLLiaKj3XAIFpJ1kH7sduYwOw5L8OE S6k9VNu5YLPkxYbC0C0pHWXH+jk79nf7uLeUmwtSl+lgRMpItJVBs0B8aD6ASHkkO+y5 MSKKld5rSP2sSYHM62gDvar8qeftJ5vEUxtmfcL6TvgXkwCer7xS1quygwPjxrURpolf 7ebsHfnBn16XTqIp1DUJojYSINrsUdWcd8PFG4r9IkktZlkY5u87eupOlWAX0wfUEbKX nJfg== X-Gm-Message-State: AOJu0Yz46xLlZzY8BG+O7VBELiX6CwrArW6oFfL6lfAGql6P5Q6vrenE oB72dohFx0PhZDVwH8tLa1Cu6OMAN0k40QUj7fjxFjfsRAcIAL6mq5fmyiwTt4Haok0i4ji5xeV tAbX66M8= X-Gm-Gg: ASbGnct8p/NAuhHZVrdbcFWHNAULJ33lbm6nR2aZ5eF6+lGS6BTKBcZcaK9t+AvEIz0 Uv4lMEm1804KU1UbOdT7AZIsyAYJjXI2Q9vErSSiBmEhwqCf0yFlNacmAeT3lxaet70CNI4bW1D 9mlu0T+08ZhuPUAVEzDdSoQDNpzEc19jsyHN3cZmLpIopYaNn99C/z97rHfeDs0bizrv+XawdFz HGCzhpGTl4zN0ai+sWSyttTkhEYc6Y1o43hURbNXd1QCKjeyVjzpVsdO+TvdeXjxQlXiwVC45ov ibSAPoWRRoffgBWzVT6tYVCJf0ZjrDdhOPbT5vRr5fa4rLR3e6rkeTY4JCtU8z/wJV2DNCAp4ML 9lfScFO/lXQlDhYxpNxuSQudtjbxBxpOsW/iQ0vbHO/L/Q/mVBVUc X-Google-Smtp-Source: AGHT+IFabHbZna1wCkhqDYho3vGAjEVs5ROn8GoK32k8ZlhkFez80kjZ4QttaZQQx0DVWc62KnXdcg== X-Received: by 2002:a05:6870:79e:b0:308:fc2b:b77 with SMTP id 586e51a60fabf-30b679e60f9mr2253678fac.40.1754177525588; Sat, 02 Aug 2025 16:32:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 26/85] include/hw/core/cpu: Introduce MMUIdxMap Date: Sun, 3 Aug 2025 09:28:54 +1000 Message-ID: <20250802232953.413294-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::30; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x30.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177992983124100 Content-Type: text/plain; charset="utf-8" Use a typedef instead of uint16_t directly when describing sets of mmu indexes. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/cputlb.h | 32 ++++++++++++++++---------------- include/hw/core/cpu.h | 6 +++--- accel/tcg/cputlb.c | 30 +++++++++++++++--------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h index 03ed7e2165..9bec0e7890 100644 --- a/include/exec/cputlb.h +++ b/include/exec/cputlb.h @@ -150,7 +150,7 @@ void tlb_flush_all_cpus_synced(CPUState *src_cpu); * MMU indexes. */ void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap); + MMUIdxMap idxmap); =20 /** * tlb_flush_page_by_mmuidx_all_cpus_synced: @@ -165,7 +165,7 @@ void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, * translations using the flushed TLBs. */ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, - uint16_t idxmap); + MMUIdxMap idxmap); =20 /** * tlb_flush_by_mmuidx: @@ -176,7 +176,7 @@ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState = *cpu, vaddr addr, * Flush all entries from the TLB of the specified CPU, for the specified * MMU indexes. */ -void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap); +void tlb_flush_by_mmuidx(CPUState *cpu, MMUIdxMap idxmap); =20 /** * tlb_flush_by_mmuidx_all_cpus_synced: @@ -189,7 +189,7 @@ void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap= ); * When this function returns, no CPUs will subsequently perform * translations using the flushed TLBs. */ -void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); +void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, MMUIdxMap idxmap); =20 /** * tlb_flush_page_bits_by_mmuidx @@ -201,11 +201,11 @@ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cp= u, uint16_t idxmap); * Similar to tlb_flush_page_mask, but with a bitmap of indexes. */ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap, unsigned bits); + MMUIdxMap idxmap, unsigned bits); =20 /* Similarly, with broadcast and syncing. */ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr ad= dr, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits); =20 /** @@ -220,14 +220,14 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CP= UState *cpu, vaddr addr, * comparing only the low @bits worth of each virtual page. */ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, - vaddr len, uint16_t idxmap, + vaddr len, MMUIdxMap idxmap, unsigned bits); =20 /* Similarly, with broadcast and syncing. */ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, vaddr len, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits); #else static inline void tlb_flush_page(CPUState *cpu, vaddr addr) @@ -243,42 +243,42 @@ static inline void tlb_flush_all_cpus_synced(CPUState= *src_cpu) { } static inline void tlb_flush_page_by_mmuidx(CPUState *cpu, - vaddr addr, uint16_t idxmap) + vaddr addr, MMUIdxMap idxmap) { } =20 -static inline void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) +static inline void tlb_flush_by_mmuidx(CPUState *cpu, MMUIdxMap idxmap) { } static inline void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, - uint16_t idxma= p) + MMUIdxMap idxm= ap) { } static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, - uint16_t idxmap) + MMUIdxMap idxmap) { } static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits) { } static inline void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, - uint16_t idxmap, unsigned bi= ts) + MMUIdxMap idxmap, unsigned b= its) { } static inline void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, - vaddr len, uint16_t idxmap, + vaddr len, MMUIdxMap idxmap, unsigned bits) { } static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, vaddr len, - uint16_t idxm= ap, + MMUIdxMap idx= map, unsigned bits) { } diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5eaf41a566..1153cadb70 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -198,10 +198,10 @@ struct CPUClass { }; =20 /* - * Fix the number of mmu modes to 16, which is also the maximum - * supported by the softmmu tlb api. + * Fix the number of mmu modes to 16. */ #define NB_MMU_MODES 16 +typedef uint16_t MMUIdxMap; =20 /* Use a fully associative victim tlb of 8 entries. */ #define CPU_VTLB_SIZE 8 @@ -306,7 +306,7 @@ typedef struct CPUTLBCommon { * mmu_idx N since the last time that mmu_idx was flushed. * Protected by tlb_c.lock. */ - uint16_t dirty; + MMUIdxMap dirty; /* * Statistics. These are not lock protected, but are read and * written atomically. This allows the monitor to print a snapshot diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 87e14bde4f..d324f33339 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -370,8 +370,8 @@ static void flush_all_helper(CPUState *src, run_on_cpu_= func fn, =20 static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data = data) { - uint16_t asked =3D data.host_int; - uint16_t all_dirty, work, to_clean; + MMUIdxMap asked =3D data.host_int; + MMUIdxMap all_dirty, work, to_clean; int64_t now =3D get_clock_realtime(); =20 assert_cpu_is_self(cpu); @@ -408,7 +408,7 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cp= u, run_on_cpu_data data) } } =20 -void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) +void tlb_flush_by_mmuidx(CPUState *cpu, MMUIdxMap idxmap) { tlb_debug("mmu_idx: 0x%" PRIx16 "\n", idxmap); =20 @@ -422,7 +422,7 @@ void tlb_flush(CPUState *cpu) tlb_flush_by_mmuidx(cpu, ALL_MMUIDX_BITS); } =20 -void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *src_cpu, uint16_t idxma= p) +void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *src_cpu, MMUIdxMap idxm= ap) { const run_on_cpu_func fn =3D tlb_flush_by_mmuidx_async_work; =20 @@ -531,7 +531,7 @@ static void tlb_flush_page_locked(CPUState *cpu, int mi= dx, vaddr page) */ static void tlb_flush_page_by_mmuidx_async_0(CPUState *cpu, vaddr addr, - uint16_t idxmap) + MMUIdxMap idxmap) { int mmu_idx; =20 @@ -570,14 +570,14 @@ static void tlb_flush_page_by_mmuidx_async_1(CPUState= *cpu, { vaddr addr_and_idxmap =3D data.target_ptr; vaddr addr =3D addr_and_idxmap & TARGET_PAGE_MASK; - uint16_t idxmap =3D addr_and_idxmap & ~TARGET_PAGE_MASK; + MMUIdxMap idxmap =3D addr_and_idxmap & ~TARGET_PAGE_MASK; =20 tlb_flush_page_by_mmuidx_async_0(cpu, addr, idxmap); } =20 typedef struct { vaddr addr; - uint16_t idxmap; + MMUIdxMap idxmap; } TLBFlushPageByMMUIdxData; =20 /** @@ -599,7 +599,7 @@ static void tlb_flush_page_by_mmuidx_async_2(CPUState *= cpu, g_free(d); } =20 -void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, uint16_t idxmap) +void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, MMUIdxMap idxmap) { tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%" PRIx16 "\n", addr, idxm= ap); =20 @@ -618,7 +618,7 @@ void tlb_flush_page(CPUState *cpu, vaddr addr) =20 void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, - uint16_t idxmap) + MMUIdxMap idxmap) { tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%"PRIx16"\n", addr, idxmap= ); =20 @@ -715,8 +715,8 @@ static void tlb_flush_range_locked(CPUState *cpu, int m= idx, typedef struct { vaddr addr; vaddr len; - uint16_t idxmap; - uint16_t bits; + MMUIdxMap idxmap; + unsigned bits; } TLBFlushRangeData; =20 static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, @@ -766,7 +766,7 @@ static void tlb_flush_range_by_mmuidx_async_1(CPUState = *cpu, } =20 void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, - vaddr len, uint16_t idxmap, + vaddr len, MMUIdxMap idxmap, unsigned bits) { TLBFlushRangeData d; @@ -797,7 +797,7 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr add= r, } =20 void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap, unsigned bits) + MMUIdxMap idxmap, unsigned bits) { tlb_flush_range_by_mmuidx(cpu, addr, TARGET_PAGE_SIZE, idxmap, bits); } @@ -805,7 +805,7 @@ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr= addr, void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, vaddr len, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits) { TLBFlushRangeData d, *p; @@ -847,7 +847,7 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState= *src_cpu, =20 void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits) { tlb_flush_range_by_mmuidx_all_cpus_synced(src_cpu, addr, TARGET_PAGE_S= IZE, --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178309; cv=none; d=zohomail.com; s=zohoarc; b=Cl1RkwD0l+4jb/stZZhmK+LmzGZ9TFeVoKwCi8wTwBnIYa518VIT8s/iGbKJzEePVwkgDw/uB85/RvhQyNovir4wfa+wenSHCoHEm9G3T+ZLtnR54m/XoCAW7omD55tU0A6uV+epkmcJ1iqHR0ir6hwfnVJxR+9BaIRMtVYB2GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178309; 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=1d9dQVqrNWqrEXWej/JwzyJrCDkscWOsMBodTniFYpE=; b=VKgc3OKtBpktxprddb/dt8tBlBmF1zQQIq0X/CAkLhVHvQhOyAVv3N13t5tQsTkQ1CSKbAMwktApfO/huo7noQ0SVLNpanm1KcoZ7A8Ja0Y4UgMhI0fZNARnVYxQxHk2P/VLiLYKlzs3sYy9YvscgJJNuzaqdAWvmB9py+pijzU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178309305963.6230025964162; Sat, 2 Aug 2025 16:45:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjm-0005L6-F1; Sat, 02 Aug 2025 19:34:02 -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 1uiLi1-0000XE-JR for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:13 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhz-00059I-KF for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:13 -0400 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-741a0ec1a05so314974a34.2 for ; Sat, 02 Aug 2025 16:32:11 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177530; x=1754782330; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1d9dQVqrNWqrEXWej/JwzyJrCDkscWOsMBodTniFYpE=; b=oIyUWgZzkuy2d9Vt4lH7cY47dld5bwbnWIzvC1V4GFFFy9si6dXqSXmop8j/Anzp9T 25akouLFLthqxIKUUb8GjM1EsnT+c+FcEr9bNML4MQcvdWq64lQwwV3593H/+B2oIRU2 7f84bjUU/1QAkZ7pv1wLA/sxv/F2zsXHsuMwnLwNZJVRzPc57oJgyQwDSt63LpGK5oWD MPiborCptozRYMwVm/xCG0iapHHOlVgkabAX+BO7Xmx20MhtpWh25FWnvzpu9YqB518q AckrN/YDntEs1so9WkGVhVTt+OYhzgv38NnbfiPU9fAitY0fAdsyYkOH6wcFuIcxntvI T9pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177530; x=1754782330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1d9dQVqrNWqrEXWej/JwzyJrCDkscWOsMBodTniFYpE=; b=WbaAhrMa8Rmyo/eO3/h+AFtaTx4zLhr8ch8BtIX6qSXBeMuWwTrqHNpBGv4iA7/cyE aen8UFBn4j9rvXshSt2hugtPZCz7qqzK4yJX/4Y6LRVleA47RvGuLNYM7yQ77hWg4mZt SFYlpTgI1hV881ehCUVzOIeNYOQsLE5EU+Ksup8IcZgcjUZ0vnMDvKiiJnzMWyrsWtrD GurJ1jCifWeIkRQXK0SoyIyt2zNWwI976TeXC40Z8uc/zbN04kn90YYBNOLSukyzgZ4o TETe5nSwPP6J9LD51jsMka5QKzzSk8IX6CdODVoWBWg0cuTUzzLCeJ9OsZLwsLgrrule qgyA== X-Gm-Message-State: AOJu0YzMSN3bsWUAnRi5sE5YUz9MO2My0lXdDP//sLiI5kCBrS8o+V2G TknJTzTNROdMAaVkTpkShVrhLRhyWyRPOckVBE1sknQWhFk2ShpvVpNTbzxrTBWh+jF9tw1vors 5u/ZiZNc= X-Gm-Gg: ASbGncu/A56jcmYNb5Fig+UpnAP66phW4tMEVqE6v9VAU+/sEM7BXqyb2Bso3jiIq2s g5uOY6Dxt2mJu6OB7WnJhCxGc/TyY/Akg+hmBurPG+tAZbhEMdtffIPmzeeiuoIBxanLQ0a8q5O J5ddq4QqHSvu4o7Qc9zRtgC+72yBuSH2FRRR0aJREtb1rCsXEqq3P7gRYcNPCORPGPOb9vO3GPF FgRmCVaBymnhgDtScxRl5MNsG889tAalKyjZFmlxHztWnS22vAb2fuS2Kj05ge5jrmoMdjpmlr3 fOTf+w4VBBe8EnKhYpe27Gk+v4SG81+ICeNxC7HXh8iqWRZppBi+W3c+FPclFg+b8cvmv8hrRlp 9j/0qD5ln/Rv3PWyYKLFXIEVAiTNI5WSo03mrA0Bwy0TTeN11q86Z X-Google-Smtp-Source: AGHT+IHgcPZ5Lzyeh1ys/R0BlrxMmuQonLdotkK3Mu5rKHzjSEd9UKKV2Vae2U+3ukwyRWoOd1spHA== X-Received: by 2002:a05:6871:4519:b0:308:51fe:ea07 with SMTP id 586e51a60fabf-30b67558bf1mr2385170fac.1.1754177530420; Sat, 02 Aug 2025 16:32:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 27/85] include/hw/core/cpu: Introduce cpu_tlb_fast Date: Sun, 3 Aug 2025 09:28:55 +1000 Message-ID: <20250802232953.413294-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178310137116600 Content-Type: text/plain; charset="utf-8" Encapsulate access to cpu->neg.tlb.f[] in a function. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 7 +++++++ accel/tcg/cputlb.c | 16 ++++++++-------- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 1153cadb70..bd835b07d5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -593,6 +593,13 @@ static inline CPUArchState *cpu_env(CPUState *cpu) return (CPUArchState *)(cpu + 1); } =20 +#ifdef CONFIG_TCG +static inline CPUTLBDescFast *cpu_tlb_fast(CPUState *cpu, int mmu_idx) +{ + return &cpu->neg.tlb.f[mmu_idx]; +} +#endif + typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ; extern CPUTailQ cpus_queue; =20 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index d324f33339..2a6aa01c57 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -129,7 +129,7 @@ static inline uint64_t tlb_addr_write(const CPUTLBEntry= *entry) static inline uintptr_t tlb_index(CPUState *cpu, uintptr_t mmu_idx, vaddr addr) { - uintptr_t size_mask =3D cpu->neg.tlb.f[mmu_idx].mask >> CPU_TLB_ENTRY_= BITS; + uintptr_t size_mask =3D cpu_tlb_fast(cpu, mmu_idx)->mask >> CPU_TLB_EN= TRY_BITS; =20 return (addr >> TARGET_PAGE_BITS) & size_mask; } @@ -138,7 +138,7 @@ static inline uintptr_t tlb_index(CPUState *cpu, uintpt= r_t mmu_idx, static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx, vaddr addr) { - return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)]; + return &cpu_tlb_fast(cpu, mmu_idx)->table[tlb_index(cpu, mmu_idx, addr= )]; } =20 static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns, @@ -292,7 +292,7 @@ static void tlb_flush_one_mmuidx_locked(CPUState *cpu, = int mmu_idx, int64_t now) { CPUTLBDesc *desc =3D &cpu->neg.tlb.d[mmu_idx]; - CPUTLBDescFast *fast =3D &cpu->neg.tlb.f[mmu_idx]; + CPUTLBDescFast *fast =3D cpu_tlb_fast(cpu, mmu_idx); =20 tlb_mmu_resize_locked(desc, fast, now); tlb_mmu_flush_locked(desc, fast); @@ -331,7 +331,7 @@ void tlb_init(CPUState *cpu) cpu->neg.tlb.c.dirty =3D 0; =20 for (i =3D 0; i < NB_MMU_MODES; i++) { - tlb_mmu_init(&cpu->neg.tlb.d[i], &cpu->neg.tlb.f[i], now); + tlb_mmu_init(&cpu->neg.tlb.d[i], cpu_tlb_fast(cpu, i), now); } } =20 @@ -342,7 +342,7 @@ void tlb_destroy(CPUState *cpu) qemu_spin_destroy(&cpu->neg.tlb.c.lock); for (i =3D 0; i < NB_MMU_MODES; i++) { CPUTLBDesc *desc =3D &cpu->neg.tlb.d[i]; - CPUTLBDescFast *fast =3D &cpu->neg.tlb.f[i]; + CPUTLBDescFast *fast =3D cpu_tlb_fast(cpu, i); =20 g_free(fast->table); g_free(desc->fulltlb); @@ -667,7 +667,7 @@ static void tlb_flush_range_locked(CPUState *cpu, int m= idx, unsigned bits) { CPUTLBDesc *d =3D &cpu->neg.tlb.d[midx]; - CPUTLBDescFast *f =3D &cpu->neg.tlb.f[midx]; + CPUTLBDescFast *f =3D cpu_tlb_fast(cpu, midx); vaddr mask =3D MAKE_64BIT_MASK(0, bits); =20 /* @@ -923,7 +923,7 @@ void tlb_reset_dirty(CPUState *cpu, uintptr_t start, ui= ntptr_t length) qemu_spin_lock(&cpu->neg.tlb.c.lock); for (mmu_idx =3D 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { CPUTLBDesc *desc =3D &cpu->neg.tlb.d[mmu_idx]; - CPUTLBDescFast *fast =3D &cpu->neg.tlb.f[mmu_idx]; + CPUTLBDescFast *fast =3D cpu_tlb_fast(cpu, mmu_idx); unsigned int n =3D tlb_n_entries(fast); unsigned int i; =20 @@ -1316,7 +1316,7 @@ static bool victim_tlb_hit(CPUState *cpu, size_t mmu_= idx, size_t index, =20 if (cmp =3D=3D page) { /* Found entry in victim tlb, swap tlb and iotlb. */ - CPUTLBEntry tmptlb, *tlb =3D &cpu->neg.tlb.f[mmu_idx].table[in= dex]; + CPUTLBEntry tmptlb, *tlb =3D &cpu_tlb_fast(cpu, mmu_idx)->tabl= e[index]; =20 qemu_spin_lock(&cpu->neg.tlb.c.lock); copy_tlb_helper_locked(&tmptlb, tlb); diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 3b088b7bd9..caf79c742d 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1668,7 +1668,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, ldst->oi =3D oi; ldst->addr_reg =3D addr_reg; =20 - /* Load cpu->neg.tlb.f[mmu_idx].{mask,table} into {tmp0,tmp1}. */ + /* Load CPUTLBDescFast.{mask,table} into {tmp0,tmp1}. */ QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, mask) !=3D 0); QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, table) !=3D 8); tcg_out_insn(s, 3314, LDP, TCG_REG_TMP0, TCG_REG_TMP1, TCG_AREG0, diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 836894b16a..4069508272 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1420,7 +1420,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, ldst->oi =3D oi; ldst->addr_reg =3D addr; =20 - /* Load cpu->neg.tlb.f[mmu_idx].{mask,table} into {r0,r1}. */ + /* Load CPUTLBDescFast.{mask,table} into {r0,r1}. */ QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, mask) !=3D 0); QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, table) !=3D 4); tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177849; cv=none; d=zohomail.com; s=zohoarc; b=LOMl1sL5cH8ms3gzlmzzVeq5v7FJr09Pf2A3CsD69ZaoH67IiVpNEzr7x+Fl9YoRhQB239GLZUhMp6mM1nAzveJTigjzqD24ANZJQreEcLh0FmRGt1C3Ca1faMpoWJoOcvUb4n1GOFXMvWabaDwXpH+Y7nVzonkHZIh1sVHCVDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177849; 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=959M7Q6IuKP+g65z4hBcFTVaco9+JWPJ3YTIq2edbMc=; b=YlEfpEIHKnXfk+YguIPK7FP0jlYLFXySP3Sgt/E54Goe9SevzerCOByNQHOuKLY2fKn9osKV2aSZexlnvmX0XkpTTjwYYeU+byusaQMa01CxzdzyUVkBOZtJl9mf5ZTAxHnE0g8OfFPPKQeqV5ox1mJYdKFKIgqUKc4O9EBpKHA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177849839648.7236261248574; Sat, 2 Aug 2025 16:37:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjq-0005VD-71; Sat, 02 Aug 2025 19:34:06 -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 1uiLi6-0000sj-7t for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:20 -0400 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLi4-0005A5-Am for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:17 -0400 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-30799a41109so1059331fac.2 for ; Sat, 02 Aug 2025 16:32:15 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177535; x=1754782335; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=959M7Q6IuKP+g65z4hBcFTVaco9+JWPJ3YTIq2edbMc=; b=MlsJZATYMYbHLGfHRWpOhbYToxoktG5Disa6nEDJgMTSvw2+VGa6cAvYBJ3zCFgx2x 8hxqjpPRpG+RHW5jQSXWaMfzYimpoy7Ghx+fU8dIdsz8BXzg6ipcYWrvAvxV4JP8RQM1 bcDjjshtWjhRLYjxlgRjIawZtYalmTYuNjVOGfWfq3c1i0FR3ka8W3AvLHVZi7QzcTB6 DgXLtvVIrAHwHD8JZKesQbI9BfW5N/BmKORTPtDNNTommtdBBiVL5aUxvyclJfMQdFLP hqHaMoOCzqAKGKJJFwS89STSazxG0h0qMEngsEs+vadB+AtyzE65mieOlNzFnS1fiLTI DPNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177535; x=1754782335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=959M7Q6IuKP+g65z4hBcFTVaco9+JWPJ3YTIq2edbMc=; b=TDFCwN6ySOm9jeaHlOMcD4xyBma6QCFyxR80LdZHhY2oIuOyhAU5R2StwYhuTSkTyH kCBrM0WGZFYjVXx3BvXvov/0MfxPgvbjIxWcR6UaRg3S0ZkvXsjU89dIKu8PJijAkexY BRKxXDGoesBZ0H5IetydD9Fpl5RR5kya+QYa/rCaVDKDTsCTo0aaGEXvwpNDgbnf2ZJz T9cimOQYSZIUp9ZIJ025jAWbdWsZz7mkzRAJk2pF77QGzF9/EZWOWwsjdAhX2YtRKzIa UtuHF0Papc0/J/ZmI+UqW0W8SnbINXN7RkMDPTqK/YqkxW0Mc1UY6AdA6wpHnulPWfEl EtmQ== X-Gm-Message-State: AOJu0Yy88vfBs/6uzrNbYJbkqKczjRx+vTBwtfltVMvUnpNPhgQFhcnp yM8mO6UdDdqLUCKGrJiW35wwF2BQUl07mr6TFjs1mzbqpqPh1nvUpub3H//HVHGtCLMObX7lCuK 5Lx7CJlw= X-Gm-Gg: ASbGncsKv1OzU/TaxeDfEGsN0eIaHAqPhLvLuNMijJ9u+pDsibcLbtXGA+Q748K3Q1t /9477FMYo/GYzN7kXmrwaLKaretgsXmmmrZeWVa1CQWskcINQ5GveQxd4dD1i7zFncq4mvJvcZT Oy26dpOEdkmE0RKypZCboDQDf/x+FFJ51wJrBCdB+kjLGQoondDyCs6mWObILuUYNCSoznVb12w 9j8Fm/POjPD6ui2H10Y67bHIBfu+Pq1mab9X+eVGvMABOH2807WI3ut4e+SrLW1LSEnQB4B8BcJ TfwPiTT9Qw7CJlyMR7oB70/zT69BWoM9vyR5IpnIAGo5GFAsrFO5MA35CSLDqYEGi8adQgDbywg jFINwvf9pUjaKCZSqGryCB09szsN82mDLPJUzfa3Gsxk1NANLHB+B X-Google-Smtp-Source: AGHT+IGY+fVi2+ldJDyqTOHUDe5qcjUcbmXULIvVhC72cV+g1+sVHiEmKjnPOz6iBG9VY32gn7HydQ== X-Received: by 2002:a05:6870:b289:b0:301:a823:9cd1 with SMTP id 586e51a60fabf-30b6793c06emr2353982fac.22.1754177534856; Sat, 02 Aug 2025 16:32:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 28/85] include/hw/core/cpu: Invert the indexing into CPUTLBDescFast Date: Sun, 3 Aug 2025 09:28:56 +1000 Message-ID: <20250802232953.413294-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::35; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x35.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177850324116600 Content-Type: text/plain; charset="utf-8" This array is within CPUNegativeOffsetState, which means the last element of the array has an offset from env with the smallest magnitude. This can be encoded into fewer bits when generating TCG fast path memory references. When we changed the NB_MMU_MODES to be a global constant, rather than a per-target value, we pessimized the code generated for targets which use only a few mmu indexes. By inverting the array index, we counteract that. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 11 ++++++++++- tcg/tcg.c | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index bd835b07d5..23eb849a9b 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -594,9 +594,18 @@ static inline CPUArchState *cpu_env(CPUState *cpu) } =20 #ifdef CONFIG_TCG +/* + * Invert the index order of the CPUTLBDescFast array so that lower + * mmu_idx have offsets from env with smaller magnitude. + */ +static inline int mmuidx_to_fast_index(int mmu_idx) +{ + return NB_MMU_MODES - 1 - mmu_idx; +} + static inline CPUTLBDescFast *cpu_tlb_fast(CPUState *cpu, int mmu_idx) { - return &cpu->neg.tlb.f[mmu_idx]; + return &cpu->neg.tlb.f[mmuidx_to_fast_index(mmu_idx)]; } #endif =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index afac55a203..294762c283 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -425,7 +425,8 @@ static uintptr_t G_GNUC_UNUSED get_jmp_target_addr(TCGC= ontext *s, int which) static int __attribute__((unused)) tlb_mask_table_ofs(TCGContext *s, int which) { - return (offsetof(CPUNegativeOffsetState, tlb.f[which]) - + int fi =3D mmuidx_to_fast_index(which); + return (offsetof(CPUNegativeOffsetState, tlb.f[fi]) - sizeof(CPUNegativeOffsetState)); } =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177850; cv=none; d=zohomail.com; s=zohoarc; b=anRUdGqt2Z7M4hzwTMjD/oOu5CvgPbgoCfSr3MRsHHJBcz87r8dsUG3x7tDyn+h1wOQ3V0VZP9rkUbL1EeDViS2S7GKQTCwdmr2/C2iQExtwBr6DjkaQ0Vr1CDkUnapbO2s1b+GLuWw6OZzFtdanP32lZi2UKBbtrfElvb4F4f0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177850; 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=UkNyZZYFhHeil9ygYrAE1UXkAwT1+GtqIOD2Xj8zAVs=; b=YoQHgX81YWCSAU/PiERPvpFY3zNJHPwgovCMrXYZPhHl1FkyRKtIICet+7fhnkj29iLmyNa7x6oxFPaQnwNKJ+nRCpw8m63HKvBO9Gy+fPo2ClWZnNCFGilWjtex0QsDkQ136PQ/uCGIZap5XyXYMonmGLHRk2v0HsGLG7H9tOM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177850599471.6642758338388; Sat, 2 Aug 2025 16:37:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjv-0005lp-3a; Sat, 02 Aug 2025 19:34:11 -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 1uiLiA-000121-K9 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:23 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLi8-0005An-UT for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:22 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2eb5cbe41e1so2561997fac.0 for ; Sat, 02 Aug 2025 16:32:20 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177540; x=1754782340; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UkNyZZYFhHeil9ygYrAE1UXkAwT1+GtqIOD2Xj8zAVs=; b=x0p+trCfWcYmIO4CP4dG9LkdZbI9U7lpxJBe905Xywe9k7ztAVQBNrutuSme5CQ2tj miYMa8N/7PD3S8Ll0Piu0fwQLUxGy1QMF6D/E98MSPQR9mgCiBeFk/i6oeZSJUONQI+5 1gU/6NxGxVb0kI1krl5P0wimyoONZvMDilR6PGi5rX+PUhr4DkGAzs/rjokv8msBA9vI YHMLVRV5rmMQhHAP0XyCzBPP1dH9qR91SEToh0y+nhzP2gTaXrDZummytNmBColzfNBZ qCYMw2DykH+hZVWoKW2WLcr8bbuxF7rMpJO4umjJHvtbw4HjpFIEYzxezqhP0UG7TEsA ljwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177540; x=1754782340; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UkNyZZYFhHeil9ygYrAE1UXkAwT1+GtqIOD2Xj8zAVs=; b=gY/uRWrfFlhXrb5LtOMm2HAW7MCKCYgt/oZ6v2ebJpJwzeK3k1oVIK6sisoycfGfLz hqPJ2C1t3USGxzec+AbDb8Ig+/cbDIJ/kZpSldfN+nYFEXO8dQsul/VhP7/lGFSheiII ggiljgI3ypuQSdfXvd2P2B558G1H4V1Wx2vX1WONcj6WZIu4Ds5a6+8z9/4I7cTYEuu+ Mbb2EPKiA4RLnGTTNM2G5jRwGrVXyOE7bZZU9epY8OU5/IDFqgMAZHNcoKjoqH2bgsKp vKzI0RzsHft+zyGbXI2+mG5InXjdaRZdUkJ9dIpmkC5g9eqMBjKBQLdE9HDMxD7zlnje pc1g== X-Gm-Message-State: AOJu0YwH8v1rJYjk2LhaanzAJvGQVVs7/0NtLQ2KH3wxSJ9tRNQmyJq+ uoEStgmLuRXFYLG3AtH/eGB7S9s2VDSPMnABeZc3u8JGoMJA2LUQOBNbi8UNAToZv3zWzjCynC5 b5NAzYRg= X-Gm-Gg: ASbGncubb5Tfq16+Aog90TwoxxRIiVht7wSTwYZZhqX1nYomnrn0c6xAe9KHGSy+/5i UVyyqqEp5VGG7ts+GJ1OQgK0RA7xM+04OOaeRCqX596AKDNUwbPzUO6cwi16bhJol8fsepSf8YY dDBXO7nWZC8SdyD29OaubBmyVeFlItDvQjxGtn5LXcHUI43oD253ZjBn0mS/UkoBuqom3Go/6MT HUGlVMXAo+RXI0R15rhmYOWUw4AzkM8YdPuQg3OQsxTVr6lghnWSuNJd6UvYGcCprfPDq9r1oGR SUHgiOPzuUsWP1slrVAnw5WGeRFQllI/vTo++4Sda5lmCGD6fxzN/z9/ko9uOLsXZtuDsJquR/S Z3Qpojr1KThk+QXd0iAtahM+eYWqCAqtds/BFrN4onvRkn/Vv34OH4QjNYrIKVMw= X-Google-Smtp-Source: AGHT+IFaZzmK5IYUTuJNQzaACtC5hO+K31zKKWlBkqoFSys/khbeKudzmVw91FuYj9atNyCYvwbvbw== X-Received: by 2002:a05:6871:5889:b0:306:c0b8:49f1 with SMTP id 586e51a60fabf-30b6796f2b8mr2705043fac.19.1754177539760; Sat, 02 Aug 2025 16:32:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 29/85] target/hppa: Adjust mmu indexes to begin with 0 Date: Sun, 3 Aug 2025 09:28:57 +1000 Message-ID: <20250802232953.413294-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177853290124100 Content-Type: text/plain; charset="utf-8" This is a logical reversion of 2ad04500543, though there have been additions to the set of mmu indexes since then. The impetus to that original patch, "9-15 will use shorter assembler instructions when run on a x86-64 host" is now handled generically. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 11d59d11ca..672ab3750c 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -29,21 +29,21 @@ #include "qemu/interval-tree.h" #include "hw/registerfields.h" =20 -#define MMU_ABS_W_IDX 6 -#define MMU_ABS_IDX 7 -#define MMU_KERNEL_IDX 8 -#define MMU_KERNEL_P_IDX 9 -#define MMU_PL1_IDX 10 -#define MMU_PL1_P_IDX 11 -#define MMU_PL2_IDX 12 -#define MMU_PL2_P_IDX 13 -#define MMU_USER_IDX 14 -#define MMU_USER_P_IDX 15 +#define MMU_KERNEL_IDX 0 +#define MMU_KERNEL_P_IDX 1 +#define MMU_PL1_IDX 2 +#define MMU_PL1_P_IDX 3 +#define MMU_PL2_IDX 4 +#define MMU_PL2_P_IDX 5 +#define MMU_USER_IDX 6 +#define MMU_USER_P_IDX 7 +#define MMU_ABS_IDX 8 +#define MMU_ABS_W_IDX 9 =20 -#define MMU_IDX_MMU_DISABLED(MIDX) ((MIDX) < MMU_KERNEL_IDX) -#define MMU_IDX_TO_PRIV(MIDX) (((MIDX) - MMU_KERNEL_IDX) / 2) -#define MMU_IDX_TO_P(MIDX) (((MIDX) - MMU_KERNEL_IDX) & 1) -#define PRIV_P_TO_MMU_IDX(PRIV, P) ((PRIV) * 2 + !!(P) + MMU_KERNEL_IDX) +#define MMU_IDX_MMU_DISABLED(MIDX) ((MIDX) >=3D MMU_ABS_IDX) +#define MMU_IDX_TO_PRIV(MIDX) ((MIDX) / 2) +#define MMU_IDX_TO_P(MIDX) ((MIDX) & 1) +#define PRIV_P_TO_MMU_IDX(PRIV, P) ((PRIV) * 2 + !!(P)) =20 #define PRIV_KERNEL 0 #define PRIV_USER 3 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178080; cv=none; d=zohomail.com; s=zohoarc; b=O8TsTLUk71qPZBxZop0NMv/NpMHyY6JQNnLKO9/OFpWzH18HlMwTSoppj2OVuLfEbllVrOe/9Lufa6YmWEETOdYQr0Gf8FwM45HsuJqQb4hTrtI++VPPHAQQtqfijZUW9XLJMYbRgtVc7koael+aDTO6FEVBgGbJx1WfthtdYqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178080; 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=jHDom8RqSvFBhHj/9Q/rXAoVV+sGpC/X8GRYrjCGKNI=; b=giJsEPbwu2K2VjCUMi5ZA8WJ28P97aZupiWEnTU4uU/VCBTz9/lksUyDRlOp3lzcxQ0XwI9MxfeT2vi6uKy6nbD5yrYW+7IbxhOi9c2kAKwoZ2t50lT7KE8ytWOB4SkPZzfvs/uAhpEp+kt8iIWt9oYB7jLwfHEok/C2scjN7Xc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178080768430.55213850679854; Sat, 2 Aug 2025 16:41:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLl8-00081N-MT; Sat, 02 Aug 2025 19:35:27 -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 1uiLiE-00018Y-JP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:27 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiD-0005Bu-25 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:26 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-306ab1b63fdso1327284fac.1 for ; Sat, 02 Aug 2025 16:32:24 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177544; x=1754782344; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jHDom8RqSvFBhHj/9Q/rXAoVV+sGpC/X8GRYrjCGKNI=; b=T79WVbvjSXh/SjbwdAiVUeSldUv9m4NG40O3SOuzsaD1Gu34MpMR8dQRALBt7R0r5e mpPFOQm4eG0cmNFXaBel8NWytpIYBUMEHkKhg6q3NN62te+Zydg4DEkno3aXSjQyABf+ NGIzTFNOBLeZ7P9ci0hW6tzll8n+mnd0uEzr9++YrSePkkvt1/1k+Q9IitURrSUNQYDM 9K2R7/G6r1hPIelw7qNwvxITIY6WFSU+4awe78ftGSZAsKFOS4obCC3Aly2j7KqhFGa7 gM1ULP8ctm8xrgf0CZZC4gKv6Z9u2HwbF0pxEXJwoLdrGT370tmIn9mncsIVxDSuzqzw 8CEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177544; x=1754782344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jHDom8RqSvFBhHj/9Q/rXAoVV+sGpC/X8GRYrjCGKNI=; b=iEGt8LERLGkFqqe1aHBu2a/qHfjl3qNNP0+K6DHRD7um8S8SNkRs9UcXNsLiyOUs6k NG6X4dVE7nVUfVb4BTAKLOJplB8Rl5XiBnr2nCBxky0a8vBa4AYz7rMAkI//QsSidxoL hJY8YO2RNAcIPx4Y5xJzxN0x6SshF7qjwwQBH5Hurtb1+7V5dAbVLIKhxBvenflssyQ4 3SC2AYDgAuNnhs8LXF7SayCEq0MDeKPpMkqDqIys0AvddLKXWGnPvRvrPe06edR27vvD 7qB5fGKCRpUuJ2vtf+XgRJYX5hWIdTsbMR3o+cm+tD2I5djpNXk5COKDof6On5N4LftK Up4w== X-Gm-Message-State: AOJu0YxbVjvpvrZP3eaWNkbvlm3pBjWTT86XEVQ/hqzXaU2ZOIFWBR2K ygRYovENDAWZljazUyxW+GMPwExXN+4JejtGFclFgqe+S/ZTLq5/qei7Cdq5YE3IpZ3RMeDOs+V Z108gleA= X-Gm-Gg: ASbGncupEGUyAcYkqjenbIoREP5YCYhO8xsPMqYHMTjq6gb+g85QcV4v5hJRf49QOCE bpSofzTqGWo3BoK1nzariRATx6Zvoa+1NxwW3LU1AdNV8GFgSDLj9NiCh7VMUf7OpJyDHLgd/Tj f3Vwm9fByfm79Yub0rd46GL1eQWCQPrTlq8bbNf89C6x+rE8AcxKkiPe+oIIc/K9FRqW3JdCStH q6KV2dsYdVoaLGtWjvJ41mIt9gpvviSlPoyIFT+kTTMA4MldlDYaSKeAlj3ENFFCmnHlYzdBQSk gjhlv5RNVOhEFxObNFa4juiW5Mak0Qln1uMfpNAvharSVm45Js1TYRi30tGm8QVQlR8IqQovULu pi7JxO9VXeckYCjzK1Bgis3LwPWQ1onmL2RytfSFFg7xafgsVuZJy X-Google-Smtp-Source: AGHT+IG6NWPotY80eQ3XZ5CSOfebqtBbgd0mWrQ1Oh+Mcabdpqtc8IW9VQ9VTzpJULz3LNRCVcIYQA== X-Received: by 2002:a05:6871:2318:b0:2ef:98fc:6f59 with SMTP id 586e51a60fabf-30b67bc7100mr3265862fac.35.1754177543907; Sat, 02 Aug 2025 16:32:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 30/85] include/exec/memopidx: Adjust for 32 mmu indexes Date: Sun, 3 Aug 2025 09:28:58 +1000 Message-ID: <20250802232953.413294-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2c; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2c.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178081849124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/exec/memopidx.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/exec/memopidx.h b/include/exec/memopidx.h index eb7f1591a3..66d9c58b3a 100644 --- a/include/exec/memopidx.h +++ b/include/exec/memopidx.h @@ -25,9 +25,10 @@ typedef uint32_t MemOpIdx; static inline MemOpIdx make_memop_idx(MemOp op, unsigned idx) { #ifdef CONFIG_DEBUG_TCG - assert(idx <=3D 15); + assert(idx <=3D 31); + assert(clz32(op) >=3D 5); #endif - return (op << 4) | idx; + return (op << 5) | idx; } =20 /** @@ -38,7 +39,7 @@ static inline MemOpIdx make_memop_idx(MemOp op, unsigned = idx) */ static inline MemOp get_memop(MemOpIdx oi) { - return oi >> 4; + return oi >> 5; } =20 /** @@ -49,7 +50,7 @@ static inline MemOp get_memop(MemOpIdx oi) */ static inline unsigned get_mmuidx(MemOpIdx oi) { - return oi & 15; + return oi & 31; } =20 #endif --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179636; cv=none; d=zohomail.com; s=zohoarc; b=MsymPmKdkQloNDAUDi8LUrdSd760O0Z7z0Oe29SIRHdkDGPxW6f8hzP8ptnMMBGITQv0Fmuis1cGaVDFoQE3FsYgSrKpglhfHkkGjkU07HTXRZMJINXTiuHb89hNVJM12hkxlZTH8l9tbbQTRbQNcY5EvjlvSO4w8i4OAk8B2gk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179636; 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=7+ER0bRwaWJSVZXuKMTaNBSXf4hbZ3aeU4lFfN33xP8=; b=Vc6qsy1RuNxL5I38jSq69ToqeZgPGKEv9PpxuUn4tWBUPQr7Fq4b87bGExm1ZO7RZR9QOZs6VMsH29aIgIVPLjPyj1pW5of2XKxgqQ69hKtriWLxcls0wGQHQa6HLx0GTzI8wKdAaDEZh1eQQ5kRk6ZBcqQ8rDv5I5VmzrIoG4A= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179636443140.30663241734987; Sat, 2 Aug 2025 17:07:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjx-0005x3-KB; Sat, 02 Aug 2025 19:34:13 -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 1uiLiJ-0001Mh-Hi for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:33 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiH-0005Cj-SP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:31 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-2ea34731c5dso2673779fac.0 for ; Sat, 02 Aug 2025 16:32:29 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177549; x=1754782349; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7+ER0bRwaWJSVZXuKMTaNBSXf4hbZ3aeU4lFfN33xP8=; b=rGt8mPSzDtoe4puD1gMxHJD6hoSkYNEFLkJPmJN3T8INXF8dQMzFSRnfBRmTIKZSp0 JHWhzIScRi0adwVin72uTRrYAEEaKJan+6+VDmE2Cv6VqkCcmtwZJVbuQIvALM+KdOYh 1cRQB7SWPRuO38I7AomaJlDWZyFZ4ErvUcWC5xk8HZVqmrg7FQ6CbreHhpnjtMTUum4Y 3Jvn3TYKXhzfaBoxxycrNnhjEHo2xMoZ2qN+thOHBBz9xWR/TQRkIVhhb0DXkl2V4q8g MYRK0MK4ji/5WnZOADoq25Zcjjvj6KueVZtlr7+33uGf9UmZRmOw93HbIJbawhRTGaZm BaHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177549; x=1754782349; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7+ER0bRwaWJSVZXuKMTaNBSXf4hbZ3aeU4lFfN33xP8=; b=T3IwMNyVWGy5dpd9PuK0FRtsw6N/HeFYUE0Sd87RWvJ9pg7zavtKYGdbnlqwBZbqUy JRfmBejF59tl5PXlVle0DuMWLvc6rqsiYQCgH1vBoRkY+dPSc+SMh96+OJ8WBF/lFItL etLzU/m72/Ple0zl+areSmHgzUfQagQ3b+Gg41Dn+SqJDfbeCVV55vb8qsdOew0P+DHT O82AhNP0iReTwZsxjYSS2cZCMAY7zUc9DRihAbgicnsLs49ekUDce3cSby/lJwYfXiad Vldj1P8grUjS1FNazPdotU/wHZirPPQ4DC4a9g2P6DCHvMO/MEd5isSRzBFTtW7dtQYN mvGw== X-Gm-Message-State: AOJu0YzpJKPph7B8hHYMTDPPMxnwyhUFvMkPVFaW+mQH36C2SE5aqsLI UK7q3JZA0u8svVChRR3LajW1b7SsN9rOJHWTa79No0tdvvbHbJUBE07pxTNwyO+yBtrH/AcAA5/ arAaHlPo= X-Gm-Gg: ASbGncsoGrgP3RzGaVP7ED2Q0d7+8E97MRYCYOiiMleAJdBoms0cfU+2WOrvJoeA44s wfxUO6Os/GoJFe4n0syCCBDQMAoBEVuLkmaPSoPap7MYDKXB2NVaVXr2uir2242YC0vfvgKi8cd 7ugpJWXVsHzbQ7QirmfyaMSdktoWmeET+t7TyxwYiHEO3ud1gOogpZatw69CJDCNQSNcsQuI+yt kmrr9dpTn+qJTwuoNmm46pMvnL6IKdWcG3P24xnJrtmypF51DEfn2oX8nW7fYM4HLvGkcdE8Fy+ U+4GGcIBuNIQxv6kFggTZIxGIkmUEeztz/SMYcNR0EFMXPm4IuSciBD4/4pUY2T+/m1TKT6o24/ F0yNrc8W4A5mYSRqexi/t218qIqSKgGCLl3SkIyW461XE27EWBKoA X-Google-Smtp-Source: AGHT+IFJhpavev8tmCsno0hhsspVnsNFKxZqLAejzQxySeJtzBiiomFYZ2XygFfoD4LgIJjxIqNOGQ== X-Received: by 2002:a05:6870:7041:10b0:30b:6a26:5193 with SMTP id 586e51a60fabf-30b6a2652bfmr1588619fac.37.1754177548694; Sat, 02 Aug 2025 16:32:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 31/85] include/hw/core/cpu: Widen MMUIdxMap Date: Sun, 3 Aug 2025 09:28:59 +1000 Message-ID: <20250802232953.413294-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179638559124100 Content-Type: text/plain; charset="utf-8" Widen MMUIdxMap to 32 bits. Do not yet expand NB_MMU_MODES, but widen the map type in preparation. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 2 +- accel/tcg/cputlb.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 23eb849a9b..fc9a2291d5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -201,7 +201,7 @@ struct CPUClass { * Fix the number of mmu modes to 16. */ #define NB_MMU_MODES 16 -typedef uint16_t MMUIdxMap; +typedef uint32_t MMUIdxMap; =20 /* Use a fully associative victim tlb of 8 entries. */ #define CPU_VTLB_SIZE 8 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 2a6aa01c57..416aaa1040 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -89,9 +89,6 @@ */ QEMU_BUILD_BUG_ON(sizeof(vaddr) > sizeof(run_on_cpu_data)); =20 -/* We currently can't handle more than 16 bits in the MMUIDX bitmask. - */ -QEMU_BUILD_BUG_ON(NB_MMU_MODES > 16); #define ALL_MMUIDX_BITS ((1 << NB_MMU_MODES) - 1) =20 static inline size_t tlb_n_entries(CPUTLBDescFast *fast) --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177717; cv=none; d=zohomail.com; s=zohoarc; b=N3V6w97Wa2etPaM7qzGvss6nykwd+c+Yuk3n5+lORalD/y5PTeSraA2gjc/boYVGxdlGbkJdO2aESaIaLqK9qVxfKlnjh/jlTBx/AsNTP4pD/G1u7R12SjW0LMO9iBXYMjjOlOxteJqTbH+o9YIhqmZM8YHzvG9vfMhKfBvJkyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177717; 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=FcrbnGvC8wHaos0qfTFoQYCNdptAHdrbtB+53LS2oec=; b=h5NKw+vRmvjjv+lm6Q+hPJCmcgpj/FFYiwSH8NOMH97sjqNLRZzandNYriDL3nXcHJ7NOE+sBqr77eR+hktpddCJphYYQcfQ2lG9l7RNymjezGJnxFRSpYE/gm9SyuP0pehcnlu2YSyGqfu6ULk72sOlxr+uFfc1VXS2j4t4M04= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177717260359.0934780232121; Sat, 2 Aug 2025 16:35:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLk2-0006JG-Ij; Sat, 02 Aug 2025 19:34:19 -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 1uiLiQ-0001UQ-E3 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:38 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiN-0005Dj-BB for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:37 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2ea6dd628a7so2030951fac.1 for ; Sat, 02 Aug 2025 16:32:34 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177554; x=1754782354; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FcrbnGvC8wHaos0qfTFoQYCNdptAHdrbtB+53LS2oec=; b=PAV2cBeRzYHwZIpes4tzesimPG6rjelknZwp4Oe84Dq9BYOIzYi8TG03/rywjuIzey mrVp6xHzzafln66pbd++Mq1U3SkNePDim5mk4Qg7FVxgFf2Fxx8vUMywQTTq5jfq/F6U p+JkHGUH3zZ53S0B7zJ1CTZJNQLRnN7XFQHrzhC46fq3rTrU0vuTIwsMvizKm7UTP4ME +TK/vmffOcKI+f5KSAadZDAD3KCUflRNwBuMqL65KifuiTfv5QcnacC0ujtkvjbQvFOb 1B8apWH7cjEVwEEk5ul3iXqk3wwIk0PG9fUMk+sGvOuZ7pUjyOOggHfF5+0on8jBX6ap 7blQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177554; x=1754782354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FcrbnGvC8wHaos0qfTFoQYCNdptAHdrbtB+53LS2oec=; b=dJpvz8tUMPYtZHf0wqL1l+s1MK8p5aqXA6/7b+BejqPOareLc6O2yeXe0MMFPpqHUO Qm1EJLNQHts2orMsVZeERNkjiscrMrHJSoBOX2NmRJsn2c4Qm8VixMlaRqAqJ5HxuPAv MXW+mj7gF5Jtq2bkXg3HJpn03o2Vse69I4BD11AeS/wXPPXCyr84MVOkcZ8P/vGUSs9F cpXDqN8i91hFq+xB247bsM84x1BU5iDX/LvSJqynJSmTfHJB7ZqppbPg/VLVGuJEdW5w F5Kf2NITBBg8RRWqL72lyolccJYEMes12UJuVBCRhVNqpGB8qEpxCcSSaMHHVHTeNTlH AXyg== X-Gm-Message-State: AOJu0YybiwB16yChdcxZMINVih6jvG5ZzwT+Mpyj2giqsOyZ+cXgls18 FTmEjAeSwji2MqBxv5DQLfHtcOMm5Fvp/dahdhXJ4q5nI7RKzim/MWhS3UpcpyFuYCTBnaUqBQG i+NWbOPg= X-Gm-Gg: ASbGnctQwTH3mePpH3bhqiI6h+oe41qRkcC938zu+xxTFIN1V+BMXldNIwdD3OjYvBv IqGGbW+3u/HTya1376mo3JRZgSnhrK3AZl8kMk+8rLYDYuPtyuCSHLQMgaie+Sj2UXOLaUwgjzM DZ7DxfXEn9ExooGJORbxdgBGKUxwrlc9KOwsBgwCuilaiXMw8UhL0I1DUL6iVTgyaNtksQHTdhU 41FTvHNoc8lVaR5qJ6dBqNAA0W6+OmUmlyrVo3VhzzP9ZXzzds4yt2B1nTiZDUZasnwi9jJ8SWP yJS2Ii7jmi+ejW/toHgOTOzf73t5XMltSyEBx9Kb2BcK0O5kklBeyYG82ylKSELl10CILVrsYx2 aNCe0mXHRFUTW1L68vhQn01bMlme5vsZRX3yZWMMR96ZcCwh1IeGT X-Google-Smtp-Source: AGHT+IFqkI9EXZ9me7n2GY/L3SNfj2HkdoxCfhzzDiuNBr0O6PGik0mBf8CbEAWibCkxJAjdt9k5wA== X-Received: by 2002:a05:6870:3328:b0:2d5:296d:4ed4 with SMTP id 586e51a60fabf-30b67a106admr2715530fac.28.1754177554034; Sat, 02 Aug 2025 16:32:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 32/85] target/arm: Split out mmuidx.h from cpu.h Date: Sun, 3 Aug 2025 09:29:00 +1000 Message-ID: <20250802232953.413294-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177733252124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 207 +----------------------------------------- target/arm/mmuidx.h | 216 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+), 206 deletions(-) create mode 100644 target/arm/mmuidx.h diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4940bd6a45..da42bd4466 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -33,6 +33,7 @@ #include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" #include "target/arm/cpu-sysregs.h" +#include "target/arm/mmuidx.h" =20 #define EXCP_UDEF 1 /* undefined instruction */ #define EXCP_SWI 2 /* software interrupt */ @@ -2736,212 +2737,6 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_s= ync); =20 #define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU =20 -/* ARM has the following "translation regimes" (as the ARM ARM calls them): - * - * If EL3 is 64-bit: - * + NonSecure EL1 & 0 stage 1 - * + NonSecure EL1 & 0 stage 2 - * + NonSecure EL2 - * + NonSecure EL2 & 0 (ARMv8.1-VHE) - * + Secure EL1 & 0 stage 1 - * + Secure EL1 & 0 stage 2 (FEAT_SEL2) - * + Secure EL2 (FEAT_SEL2) - * + Secure EL2 & 0 (FEAT_SEL2) - * + Realm EL1 & 0 stage 1 (FEAT_RME) - * + Realm EL1 & 0 stage 2 (FEAT_RME) - * + Realm EL2 (FEAT_RME) - * + EL3 - * If EL3 is 32-bit: - * + NonSecure PL1 & 0 stage 1 - * + NonSecure PL1 & 0 stage 2 - * + NonSecure PL2 - * + Secure PL1 & 0 - * (reminder: for 32 bit EL3, Secure PL1 is *EL3*, not EL1.) - * - * For QEMU, an mmu_idx is not quite the same as a translation regime beca= use: - * 1. we need to split the "EL1 & 0" and "EL2 & 0" regimes into two mmu_i= dxes, - * because they may differ in access permissions even if the VA->PA ma= p is - * the same - * 2. we want to cache in our TLB the full VA->IPA->PA lookup for a stage= 1+2 - * translation, which means that we have one mmu_idx that deals with t= wo - * concatenated translation regimes [this sort of combined s1+2 TLB is - * architecturally permitted] - * 3. we don't need to allocate an mmu_idx to translations that we won't = be - * handling via the TLB. The only way to do a stage 1 translation with= out - * the immediate stage 2 translation is via the ATS or AT system insns, - * which can be slow-pathed and always do a page table walk. - * The only use of stage 2 translations is either as part of an s1+2 - * lookup or when loading the descriptors during a stage 1 page table = walk, - * and in both those cases we don't use the TLB. - * 4. we can also safely fold together the "32 bit EL3" and "64 bit EL3" - * translation regimes, because they map reasonably well to each other - * and they can't both be active at the same time. - * 5. we want to be able to use the TLB for accesses done as part of a - * stage1 page table walk, rather than having to walk the stage2 page - * table over and over. - * 6. we need separate EL1/EL2 mmu_idx for handling the Privileged Access - * Never (PAN) bit within PSTATE. - * 7. we fold together most secure and non-secure regimes for A-profile, - * because there are no banked system registers for aarch64, so the - * process of switching between secure and non-secure is - * already heavyweight. - * 8. we cannot fold together Stage 2 Secure and Stage 2 NonSecure, - * because both are in use simultaneously for Secure EL2. - * - * This gives us the following list of cases: - * - * EL0 EL1&0 stage 1+2 (aka NS PL0 PL1&0 stage 1+2) - * EL1 EL1&0 stage 1+2 (aka NS PL1 PL1&0 stage 1+2) - * EL1 EL1&0 stage 1+2 +PAN (aka NS PL1 P1&0 stage 1+2 +PAN) - * EL0 EL2&0 - * EL2 EL2&0 - * EL2 EL2&0 +PAN - * EL2 (aka NS PL2) - * EL3 (aka AArch32 S PL1 PL1&0) - * AArch32 S PL0 PL1&0 (we call this EL30_0) - * AArch32 S PL1 PL1&0 +PAN (we call this EL30_3_PAN) - * Stage2 Secure - * Stage2 NonSecure - * plus one TLB per Physical address space: S, NS, Realm, Root - * - * for a total of 16 different mmu_idx. - * - * R profile CPUs have an MPU, but can use the same set of MMU indexes - * as A profile. They only need to distinguish EL0 and EL1 (and - * EL2 for cores like the Cortex-R52). - * - * M profile CPUs are rather different as they do not have a true MMU. - * They have the following different MMU indexes: - * User - * Privileged - * User, execution priority negative (ie the MPU HFNMIENA bit may apply) - * Privileged, execution priority negative (ditto) - * If the CPU supports the v8M Security Extension then there are also: - * Secure User - * Secure Privileged - * Secure User, execution priority negative - * Secure Privileged, execution priority negative - * - * The ARMMMUIdx and the mmu index value used by the core QEMU TLB code - * are not quite the same -- different CPU types (most notably M profile - * vs A/R profile) would like to use MMU indexes with different semantics, - * but since we don't ever need to use all of those in a single CPU we - * can avoid having to set NB_MMU_MODES to "total number of A profile MMU - * modes + total number of M profile MMU modes". The lower bits of - * ARMMMUIdx are the core TLB mmu index, and the higher bits are always - * the same for any particular CPU. - * Variables of type ARMMUIdx are always full values, and the core - * index values are in variables of type 'int'. - * - * Our enumeration includes at the end some entries which are not "true" - * mmu_idx values in that they don't have corresponding TLBs and are only - * valid for doing slow path page table walks. - * - * The constant names here are patterned after the general style of the na= mes - * of the AT/ATS operations. - * The values used are carefully arranged to make mmu_idx =3D> EL lookup e= asy. - * For M profile we arrange them to have a bit for priv, a bit for negpri - * and a bit for secure. - */ -#define ARM_MMU_IDX_A 0x10 /* A profile */ -#define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */ -#define ARM_MMU_IDX_M 0x40 /* M profile */ - -/* Meanings of the bits for M profile mmu idx values */ -#define ARM_MMU_IDX_M_PRIV 0x1 -#define ARM_MMU_IDX_M_NEGPRI 0x2 -#define ARM_MMU_IDX_M_S 0x4 /* Secure */ - -#define ARM_MMU_IDX_TYPE_MASK \ - (ARM_MMU_IDX_A | ARM_MMU_IDX_M | ARM_MMU_IDX_NOTLB) -#define ARM_MMU_IDX_COREIDX_MASK 0xf - -typedef enum ARMMMUIdx { - /* - * A-profile. - */ - ARMMMUIdx_E10_0 =3D 0 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_0 =3D 1 | ARM_MMU_IDX_A, - ARMMMUIdx_E10_1 =3D 2 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_2 =3D 3 | ARM_MMU_IDX_A, - ARMMMUIdx_E10_1_PAN =3D 4 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_2_PAN =3D 5 | ARM_MMU_IDX_A, - ARMMMUIdx_E2 =3D 6 | ARM_MMU_IDX_A, - ARMMMUIdx_E3 =3D 7 | ARM_MMU_IDX_A, - ARMMMUIdx_E30_0 =3D 8 | ARM_MMU_IDX_A, - ARMMMUIdx_E30_3_PAN =3D 9 | ARM_MMU_IDX_A, - - /* - * Used for second stage of an S12 page table walk, or for descriptor - * loads during first stage of an S1 page table walk. Note that both - * are in use simultaneously for SecureEL2: the security state for - * the S2 ptw is selected by the NS bit from the S1 ptw. - */ - ARMMMUIdx_Stage2_S =3D 10 | ARM_MMU_IDX_A, - ARMMMUIdx_Stage2 =3D 11 | ARM_MMU_IDX_A, - - /* TLBs with 1-1 mapping to the physical address spaces. */ - ARMMMUIdx_Phys_S =3D 12 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_NS =3D 13 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_Root =3D 14 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_Realm =3D 15 | ARM_MMU_IDX_A, - - /* - * These are not allocated TLBs and are used only for AT system - * instructions or for the first stage of an S12 page table walk. - */ - ARMMMUIdx_Stage1_E0 =3D 0 | ARM_MMU_IDX_NOTLB, - ARMMMUIdx_Stage1_E1 =3D 1 | ARM_MMU_IDX_NOTLB, - ARMMMUIdx_Stage1_E1_PAN =3D 2 | ARM_MMU_IDX_NOTLB, - - /* - * M-profile. - */ - ARMMMUIdx_MUser =3D ARM_MMU_IDX_M, - ARMMMUIdx_MPriv =3D ARM_MMU_IDX_M | ARM_MMU_IDX_M_PRIV, - ARMMMUIdx_MUserNegPri =3D ARMMMUIdx_MUser | ARM_MMU_IDX_M_NEGPRI, - ARMMMUIdx_MPrivNegPri =3D ARMMMUIdx_MPriv | ARM_MMU_IDX_M_NEGPRI, - ARMMMUIdx_MSUser =3D ARMMMUIdx_MUser | ARM_MMU_IDX_M_S, - ARMMMUIdx_MSPriv =3D ARMMMUIdx_MPriv | ARM_MMU_IDX_M_S, - ARMMMUIdx_MSUserNegPri =3D ARMMMUIdx_MUserNegPri | ARM_MMU_IDX_M_S, - ARMMMUIdx_MSPrivNegPri =3D ARMMMUIdx_MPrivNegPri | ARM_MMU_IDX_M_S, -} ARMMMUIdx; - -/* - * Bit macros for the core-mmu-index values for each index, - * for use when calling tlb_flush_by_mmuidx() and friends. - */ -#define TO_CORE_BIT(NAME) \ - ARMMMUIdxBit_##NAME =3D 1 << (ARMMMUIdx_##NAME & ARM_MMU_IDX_COREIDX_M= ASK) - -typedef enum ARMMMUIdxBit { - TO_CORE_BIT(E10_0), - TO_CORE_BIT(E20_0), - TO_CORE_BIT(E10_1), - TO_CORE_BIT(E10_1_PAN), - TO_CORE_BIT(E2), - TO_CORE_BIT(E20_2), - TO_CORE_BIT(E20_2_PAN), - TO_CORE_BIT(E3), - TO_CORE_BIT(E30_0), - TO_CORE_BIT(E30_3_PAN), - TO_CORE_BIT(Stage2), - TO_CORE_BIT(Stage2_S), - - TO_CORE_BIT(MUser), - TO_CORE_BIT(MPriv), - TO_CORE_BIT(MUserNegPri), - TO_CORE_BIT(MPrivNegPri), - TO_CORE_BIT(MSUser), - TO_CORE_BIT(MSPriv), - TO_CORE_BIT(MSUserNegPri), - TO_CORE_BIT(MSPrivNegPri), -} ARMMMUIdxBit; - -#undef TO_CORE_BIT - -#define MMU_USER_IDX 0 - /* Indexes used when registering address spaces with cpu_address_space_ini= t */ typedef enum ARMASIdx { ARMASIdx_NS =3D 0, diff --git a/target/arm/mmuidx.h b/target/arm/mmuidx.h new file mode 100644 index 0000000000..5b9b4bc84f --- /dev/null +++ b/target/arm/mmuidx.h @@ -0,0 +1,216 @@ +/* + * QEMU Arm software mmu index definitions + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_ARM_MMUIDX_H +#define TARGET_ARM_MMUIDX_H + +/* + * Arm has the following "translation regimes" (as the Arm ARM calls them): + * + * If EL3 is 64-bit: + * + NonSecure EL1 & 0 stage 1 + * + NonSecure EL1 & 0 stage 2 + * + NonSecure EL2 + * + NonSecure EL2 & 0 (ARMv8.1-VHE) + * + Secure EL1 & 0 stage 1 + * + Secure EL1 & 0 stage 2 (FEAT_SEL2) + * + Secure EL2 (FEAT_SEL2) + * + Secure EL2 & 0 (FEAT_SEL2) + * + Realm EL1 & 0 stage 1 (FEAT_RME) + * + Realm EL1 & 0 stage 2 (FEAT_RME) + * + Realm EL2 (FEAT_RME) + * + EL3 + * If EL3 is 32-bit: + * + NonSecure PL1 & 0 stage 1 + * + NonSecure PL1 & 0 stage 2 + * + NonSecure PL2 + * + Secure PL1 & 0 + * (reminder: for 32 bit EL3, Secure PL1 is *EL3*, not EL1.) + * + * For QEMU, an mmu_idx is not quite the same as a translation regime beca= use: + * 1. we need to split the "EL1 & 0" and "EL2 & 0" regimes into two mmu_i= dxes, + * because they may differ in access permissions even if the VA->PA ma= p is + * the same + * 2. we want to cache in our TLB the full VA->IPA->PA lookup for a stage= 1+2 + * translation, which means that we have one mmu_idx that deals with t= wo + * concatenated translation regimes [this sort of combined s1+2 TLB is + * architecturally permitted] + * 3. we don't need to allocate an mmu_idx to translations that we won't = be + * handling via the TLB. The only way to do a stage 1 translation with= out + * the immediate stage 2 translation is via the ATS or AT system insns, + * which can be slow-pathed and always do a page table walk. + * The only use of stage 2 translations is either as part of an s1+2 + * lookup or when loading the descriptors during a stage 1 page table = walk, + * and in both those cases we don't use the TLB. + * 4. we can also safely fold together the "32 bit EL3" and "64 bit EL3" + * translation regimes, because they map reasonably well to each other + * and they can't both be active at the same time. + * 5. we want to be able to use the TLB for accesses done as part of a + * stage1 page table walk, rather than having to walk the stage2 page + * table over and over. + * 6. we need separate EL1/EL2 mmu_idx for handling the Privileged Access + * Never (PAN) bit within PSTATE. + * 7. we fold together most secure and non-secure regimes for A-profile, + * because there are no banked system registers for aarch64, so the + * process of switching between secure and non-secure is + * already heavyweight. + * 8. we cannot fold together Stage 2 Secure and Stage 2 NonSecure, + * because both are in use simultaneously for Secure EL2. + * + * This gives us the following list of cases: + * + * EL0 EL1&0 stage 1+2 (aka NS PL0 PL1&0 stage 1+2) + * EL1 EL1&0 stage 1+2 (aka NS PL1 PL1&0 stage 1+2) + * EL1 EL1&0 stage 1+2 +PAN (aka NS PL1 P1&0 stage 1+2 +PAN) + * EL0 EL2&0 + * EL2 EL2&0 + * EL2 EL2&0 +PAN + * EL2 (aka NS PL2) + * EL3 (aka AArch32 S PL1 PL1&0) + * AArch32 S PL0 PL1&0 (we call this EL30_0) + * AArch32 S PL1 PL1&0 +PAN (we call this EL30_3_PAN) + * Stage2 Secure + * Stage2 NonSecure + * plus one TLB per Physical address space: S, NS, Realm, Root + * + * for a total of 16 different mmu_idx. + * + * R profile CPUs have an MPU, but can use the same set of MMU indexes + * as A profile. They only need to distinguish EL0 and EL1 (and + * EL2 for cores like the Cortex-R52). + * + * M profile CPUs are rather different as they do not have a true MMU. + * They have the following different MMU indexes: + * User + * Privileged + * User, execution priority negative (ie the MPU HFNMIENA bit may apply) + * Privileged, execution priority negative (ditto) + * If the CPU supports the v8M Security Extension then there are also: + * Secure User + * Secure Privileged + * Secure User, execution priority negative + * Secure Privileged, execution priority negative + * + * The ARMMMUIdx and the mmu index value used by the core QEMU TLB code + * are not quite the same -- different CPU types (most notably M profile + * vs A/R profile) would like to use MMU indexes with different semantics, + * but since we don't ever need to use all of those in a single CPU we + * can avoid having to set NB_MMU_MODES to "total number of A profile MMU + * modes + total number of M profile MMU modes". The lower bits of + * ARMMMUIdx are the core TLB mmu index, and the higher bits are always + * the same for any particular CPU. + * Variables of type ARMMUIdx are always full values, and the core + * index values are in variables of type 'int'. + * + * Our enumeration includes at the end some entries which are not "true" + * mmu_idx values in that they don't have corresponding TLBs and are only + * valid for doing slow path page table walks. + * + * The constant names here are patterned after the general style of the na= mes + * of the AT/ATS operations. + * The values used are carefully arranged to make mmu_idx =3D> EL lookup e= asy. + * For M profile we arrange them to have a bit for priv, a bit for negpri + * and a bit for secure. + */ +#define ARM_MMU_IDX_A 0x10 /* A profile */ +#define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */ +#define ARM_MMU_IDX_M 0x40 /* M profile */ + +/* Meanings of the bits for M profile mmu idx values */ +#define ARM_MMU_IDX_M_PRIV 0x1 +#define ARM_MMU_IDX_M_NEGPRI 0x2 +#define ARM_MMU_IDX_M_S 0x4 /* Secure */ + +#define ARM_MMU_IDX_TYPE_MASK \ + (ARM_MMU_IDX_A | ARM_MMU_IDX_M | ARM_MMU_IDX_NOTLB) +#define ARM_MMU_IDX_COREIDX_MASK 0xf + +typedef enum ARMMMUIdx { + /* + * A-profile. + */ + ARMMMUIdx_E10_0 =3D 0 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_0 =3D 1 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1 =3D 2 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2 =3D 3 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1_PAN =3D 4 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2_PAN =3D 5 | ARM_MMU_IDX_A, + ARMMMUIdx_E2 =3D 6 | ARM_MMU_IDX_A, + ARMMMUIdx_E3 =3D 7 | ARM_MMU_IDX_A, + ARMMMUIdx_E30_0 =3D 8 | ARM_MMU_IDX_A, + ARMMMUIdx_E30_3_PAN =3D 9 | ARM_MMU_IDX_A, + + /* + * Used for second stage of an S12 page table walk, or for descriptor + * loads during first stage of an S1 page table walk. Note that both + * are in use simultaneously for SecureEL2: the security state for + * the S2 ptw is selected by the NS bit from the S1 ptw. + */ + ARMMMUIdx_Stage2_S =3D 10 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2 =3D 11 | ARM_MMU_IDX_A, + + /* TLBs with 1-1 mapping to the physical address spaces. */ + ARMMMUIdx_Phys_S =3D 12 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_NS =3D 13 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Root =3D 14 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Realm =3D 15 | ARM_MMU_IDX_A, + + /* + * These are not allocated TLBs and are used only for AT system + * instructions or for the first stage of an S12 page table walk. + */ + ARMMMUIdx_Stage1_E0 =3D 0 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1 =3D 1 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1_PAN =3D 2 | ARM_MMU_IDX_NOTLB, + + /* + * M-profile. + */ + ARMMMUIdx_MUser =3D ARM_MMU_IDX_M, + ARMMMUIdx_MPriv =3D ARM_MMU_IDX_M | ARM_MMU_IDX_M_PRIV, + ARMMMUIdx_MUserNegPri =3D ARMMMUIdx_MUser | ARM_MMU_IDX_M_NEGPRI, + ARMMMUIdx_MPrivNegPri =3D ARMMMUIdx_MPriv | ARM_MMU_IDX_M_NEGPRI, + ARMMMUIdx_MSUser =3D ARMMMUIdx_MUser | ARM_MMU_IDX_M_S, + ARMMMUIdx_MSPriv =3D ARMMMUIdx_MPriv | ARM_MMU_IDX_M_S, + ARMMMUIdx_MSUserNegPri =3D ARMMMUIdx_MUserNegPri | ARM_MMU_IDX_M_S, + ARMMMUIdx_MSPrivNegPri =3D ARMMMUIdx_MPrivNegPri | ARM_MMU_IDX_M_S, +} ARMMMUIdx; + +/* + * Bit macros for the core-mmu-index values for each index, + * for use when calling tlb_flush_by_mmuidx() and friends. + */ +#define TO_CORE_BIT(NAME) \ + ARMMMUIdxBit_##NAME =3D 1 << (ARMMMUIdx_##NAME & ARM_MMU_IDX_COREIDX_M= ASK) + +typedef enum ARMMMUIdxBit { + TO_CORE_BIT(E10_0), + TO_CORE_BIT(E20_0), + TO_CORE_BIT(E10_1), + TO_CORE_BIT(E10_1_PAN), + TO_CORE_BIT(E2), + TO_CORE_BIT(E20_2), + TO_CORE_BIT(E20_2_PAN), + TO_CORE_BIT(E3), + TO_CORE_BIT(E30_0), + TO_CORE_BIT(E30_3_PAN), + TO_CORE_BIT(Stage2), + TO_CORE_BIT(Stage2_S), + + TO_CORE_BIT(MUser), + TO_CORE_BIT(MPriv), + TO_CORE_BIT(MUserNegPri), + TO_CORE_BIT(MPrivNegPri), + TO_CORE_BIT(MSUser), + TO_CORE_BIT(MSPriv), + TO_CORE_BIT(MSUserNegPri), + TO_CORE_BIT(MSPrivNegPri), +} ARMMMUIdxBit; + +#undef TO_CORE_BIT + +#define MMU_USER_IDX 0 + +#endif /* TARGET_ARM_MMUIDX_H */ --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179002; cv=none; d=zohomail.com; s=zohoarc; b=DCVtfoNqS0k+96Voe18m+cAe9zG8lIJR2MtgP3HTTXx/pVZ2mC3t5ocX/KATWlh6PBCzdCJgpVeYrNXybdAbcUvfF4Fi5X+8y7UdT67XTcPb33W0xiy65eohbcBO30/bYwrEoEIulou5Mo+2roj4qyed/lXK6ecqjHF9j5XTPCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179002; 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=RAF23I8Ky/4FVd+dyZVZ6YbCp7h0YfAKI01Ox5TbjXk=; b=kAE6x3knt0lD603Kbpui5hTWdcx40SwsyXyFzR8xXdak56hrjV56G7rgDbZoRZrHhfOpSRVpbdyok6nus542W7xNRnxzEDOe9alfSIylj0U5NNsidkrF76EKcM/llG74yKEpkDSWObBWG8P7XCVSriUbkGo7CUTLIKqsHzwSU5o= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179002011395.12869153235397; Sat, 2 Aug 2025 16:56:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLlI-00009a-23; Sat, 02 Aug 2025 19:35:36 -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 1uiLiT-0001ZC-Ui for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:43 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiR-0005ER-65 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:41 -0400 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-741a8bb8aa4so160789a34.1 for ; Sat, 02 Aug 2025 16:32:38 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177558; x=1754782358; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RAF23I8Ky/4FVd+dyZVZ6YbCp7h0YfAKI01Ox5TbjXk=; b=KnqH2F/2EZcVh48eSzBDgJhjwvU8BPvy4Zi83tvg6wvFKPHkeog3nxnxHwQqQBOw+K iiFkKAaIhIClWLLeF/L5GN7kj2kzTj/DxJO3HRFJkH0GQgVw7rJLm0o6rsD5/vxm+LWd Z65k8PPRkjDSzcAsT6pxx2FcVWPMl0R/42d9quzlYdhVJLmYBE8FPFhlhpx01AUjmfV+ h54JtIIRn0qDmuYXUpEyp/i0RF1dZVMRMAu0ozGbi517taxwS5pSHLjJDMscv4+WfWDr ymOT6dH8yOCCweXrECgenypVkidqKegq/rFUZ2VHWRU9TOoA6FpeLAS8ZfmaEg8Zq5Jh IbEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177558; x=1754782358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RAF23I8Ky/4FVd+dyZVZ6YbCp7h0YfAKI01Ox5TbjXk=; b=gjmddbRgV07/VVvkB7zmAPh+1nIsc5YucsvH9hC0r197Rn3glIs+H6/i/JltvT2lsH KSM5cJD322ZAq0YmIaU6hSufsFKj8Yq/MeuuPGm55kiVM4QsYnOHBb/Q+lklGS1qI6cX ZZtqmHLMtvCVauDpqrmR+9thAjr5e5pLb7smKDwM7JQJHzAEO6fkUcW2L+eltkNfYJQY m/8zAAUJKXMhZrAAEIVlUpD+HPN/Ts1Bu58S2M9c5eY+fykjuIdme7++QFHC+DGwCayP mg+oTByO3b4qISvswJZF8rNtWgNSjTe7iHcIHjhaJp92dnTm+ILQkz7P+LvQF2cu/6t8 bsrw== X-Gm-Message-State: AOJu0Yxeuc5O/wS5+DhR46Wo9MCzAGg/GKQpDDIBvMN50ORNV++fU0aX gqGYvpWZ4/EDcO5GZlpkeZbenhcifcyugfZenL7wPWRsZa6/hdkEx43aTyXyRXKHPMz68eO0N/B +wMq+fbA= X-Gm-Gg: ASbGnct1eXQ7t69feaV+cnyZjH5wlfz9NxqzNrsDJ2s0Um1lSibwePWuic6Y/SjTNwP 6+Cn8UpqBBGmfjyYBJBXmCtw8LATodK0B+NM/4LMTh1vSlJR88T7smcs77LsWKEQ6s7010LUvfM kWeW9jmOY7HezpwcKFVk0BJ7tjo3/wr5ID4EXzDcxgpEJ360ZRU1coLRBDAA4d0qnzB5HgoICSN pv+JkaqSw6Phb7rp5dgP/MxnYzaQ0MMGxm1AYg2DXTuDtaWy2hLRFjQbgmIhQzntsgHq/gZloA/ YjTv/UNV6cwgBVH4Pv8/v7SbX6IZ3JoqG7QPz5A6KlBGLttKhboN9xefybgiCJ+MLAwZDjaFflS VoLwsZnn2m6PcAuSPSKJ4QgL1NVLAqy4oauRPejQUfsgC0vOzLd4Z X-Google-Smtp-Source: AGHT+IGQwz2fA5L1AljGXK1xEAwQcEG0elim4DRUdy9xsU0ebbukkeaQBiBxRpmKjuNt+E26yA0jpg== X-Received: by 2002:a05:6871:400c:b0:307:15a8:2dc8 with SMTP id 586e51a60fabf-30b675d13ecmr2554555fac.12.1754177557885; Sat, 02 Aug 2025 16:32:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 33/85] target/arm: Convert arm_mmu_idx_to_el from switch to table Date: Sun, 3 Aug 2025 09:29:01 +1000 Message-ID: <20250802232953.413294-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179004115116600 Content-Type: text/plain; charset="utf-8" In an effort to keep all ARMMMUIdx data in one place, begin construction of an info table describing all of the properties of the mmu_idx. Begin with the access EL. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/internals.h | 3 +-- target/arm/mmuidx-internal.h | 29 +++++++++++++++++++++++++ target/arm/helper.c | 27 ------------------------ target/arm/mmuidx.c | 41 ++++++++++++++++++++++++++++++++++++ target/arm/meson.build | 7 +++++- 5 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 target/arm/mmuidx-internal.h create mode 100644 target/arm/mmuidx.c diff --git a/target/arm/internals.h b/target/arm/internals.h index b6499683cc..2dc82330ec 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -34,6 +34,7 @@ #include "system/memory.h" #include "syndrome.h" #include "cpu-features.h" +#include "mmuidx-internal.h" =20 /* register banks for CPU modes */ #define BANK_USRSYS 0 @@ -986,8 +987,6 @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_id= x) return mmu_idx | ARM_MMU_IDX_A; } =20 -int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); - /* Return the MMU index for a v7M CPU in the specified security state */ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); =20 diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h new file mode 100644 index 0000000000..29bba4ecb5 --- /dev/null +++ b/target/arm/mmuidx-internal.h @@ -0,0 +1,29 @@ +/* + * QEMU Arm software mmu index internal definitions + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_ARM_MMUIDX_INTERNAL_H +#define TARGET_ARM_MMUIDX_INTERNAL_H + +#include "mmuidx.h" +#include "tcg/debug-assert.h" +#include "hw/registerfields.h" + + +FIELD(MMUIDXINFO, EL, 0, 2) +FIELD(MMUIDXINFO, ELVALID, 2, 1) + +extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; + +#define arm_mmuidx_is_valid(x) ((unsigned)(x) < ARRAY_SIZE(arm_mmuidx_tab= le)) + +/* Return the exception level associated with this mmu index. */ +static inline int arm_mmu_idx_to_el(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + tcg_debug_assert(FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, ELVALID= )); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, EL); +} + +#endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 9447d7ba59..8985ad8c8a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9895,33 +9895,6 @@ int fp_exception_el(CPUARMState *env, int cur_el) return 0; } =20 -/* Return the exception level we're running at if this is our mmu_idx */ -int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) -{ - if (mmu_idx & ARM_MMU_IDX_M) { - return mmu_idx & ARM_MMU_IDX_M_PRIV; - } - - switch (mmu_idx) { - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E20_0: - case ARMMMUIdx_E30_0: - return 0; - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - return 1; - case ARMMMUIdx_E2: - case ARMMMUIdx_E20_2: - case ARMMMUIdx_E20_2_PAN: - return 2; - case ARMMMUIdx_E3: - case ARMMMUIdx_E30_3_PAN: - return 3; - default: - g_assert_not_reached(); - } -} - #ifndef CONFIG_TCG ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) { diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c new file mode 100644 index 0000000000..309b1d68df --- /dev/null +++ b/target/arm/mmuidx.c @@ -0,0 +1,41 @@ +/* + * QEMU Arm software mmu index definitions + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "mmuidx-internal.h" + + +#define EL(X) ((X << R_MMUIDXINFO_EL_SHIFT) | R_MMUIDXINFO_ELVALID_MASK) + +const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { + /* + * A-profile. + */ + [ARMMMUIdx_E10_0] =3D EL(0), + [ARMMMUIdx_E10_1] =3D EL(1), + [ARMMMUIdx_E10_1_PAN] =3D EL(1), + + [ARMMMUIdx_E20_0] =3D EL(0), + [ARMMMUIdx_E20_2] =3D EL(2), + [ARMMMUIdx_E20_2_PAN] =3D EL(2), + + [ARMMMUIdx_E2] =3D EL(2), + + [ARMMMUIdx_E3] =3D EL(3), + [ARMMMUIdx_E30_0] =3D EL(0), + [ARMMMUIdx_E30_3_PAN] =3D EL(3), + + /* + * M-profile. + */ + [ARMMMUIdx_MUser] =3D EL(0), + [ARMMMUIdx_MPriv] =3D EL(1), + [ARMMMUIdx_MUserNegPri] =3D EL(0), + [ARMMMUIdx_MPrivNegPri] =3D EL(1), + [ARMMMUIdx_MSUser] =3D EL(0), + [ARMMMUIdx_MSPriv] =3D EL(1), + [ARMMMUIdx_MSUserNegPri] =3D EL(0), + [ARMMMUIdx_MSPrivNegPri] =3D EL(1), +}; diff --git a/target/arm/meson.build b/target/arm/meson.build index 07d9271aa4..91630a1f72 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -6,7 +6,12 @@ arm_ss.add(files( =20 arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', - 'gdbstub64.c')) + 'gdbstub64.c' +)) + +arm_common_ss.add(files( + 'mmuidx.c', +)) =20 arm_system_ss =3D ss.source_set() arm_common_system_ss =3D ss.source_set() --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178232; cv=none; d=zohomail.com; s=zohoarc; b=PKbK+L4OShmRztGVr7AkBSGPQT+FzjmX3HG4SVQxVQKsbeN1H1uAysEWEpoSrQiYD9j3eieDz0OMmegJ5MA2xQo/dRC228PSQv8yBS8TsghFQsyrO1Tib1jRKDkKhRWoC63xTqmX3ovIdibSJBgsEqOhHXHcUSckirSGQ+1AzEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178232; 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=tSLil6w6r7oo+sEGt7sKp3avkXfxAqFCrAq/SF3v9/Q=; b=nRwAy/JAzosj2H6TpVf93PNwPuJdKXP9oFGqr7kk9H1EsweSqzAPbFNUNUaqRfT6RPXmyZNxeZlr+jJtjyFisv1OUe0QufbnI6YegFqZyUepuWJBkDTz0pCNXF1OYktx0Z43r4x9gioh4RjhTg1L/GYSxYzK9Kg8wBTdxlx0I9s= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178232513684.4770133864199; Sat, 2 Aug 2025 16:43:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLlK-0000Kt-WD; Sat, 02 Aug 2025 19:35:39 -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 1uiLiY-0001oJ-G4 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:49 -0400 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiV-0005Er-R9 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:46 -0400 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-6196ca9a2edso836599eaf.2 for ; Sat, 02 Aug 2025 16:32:43 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177562; x=1754782362; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tSLil6w6r7oo+sEGt7sKp3avkXfxAqFCrAq/SF3v9/Q=; b=vNMBeEPKYbLZ0Sp9YGcQrrv/yoELz5Cvim1Iu6zXyeqdWzF8UG/VGE+Q+zmvg8NX/G Yrhy9vnCzOlIDvsQvgWkDfo/eroXe++C0hX54tPbqdsHw6cFTonRDtyWmyZDkl1MtYlt Y1YEiTi8iIMwRStxl4nGt2k1U89lSCrnXhxEBKyCYB3/ajY1ib9TzlQqbLIsJEwDPF32 qLiRtrdMlOKr0rTFiO0tllDsP+r5uQA7F/Vxbd1/qtKlmkWE7rQYs2twoIUj9+V4uvwc lsUOgUqybh6wjM4QnWUzKEjQCCWzclF6LkOeSlEkBioasuIT8kEVERhdHOgN8oRb8k25 4vqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177562; x=1754782362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tSLil6w6r7oo+sEGt7sKp3avkXfxAqFCrAq/SF3v9/Q=; b=sa3GFJz5Dqz+mkCSXr+8HHECuofYqosHuEU+/ZqKGPxam5hF6sATdqoiF0zUqoLulP lPqJrOE2I5UanjtTsRmvqcYfizFPmtWHMVLY16aQhDb6a+5Z4mXLq0nbsV+xehyMzW9B Nts405ClEwNP4dszy3Y2U8MlC+JZUsOQwPkZc+1qVGb7gvLfDHIRKb4N6xmQz4cV+jh7 cZ/uyJoV+gFZc2Je418kmpeEPCDQ5qLp5F1onzQeN57cYFUaD6rL70kRG3MVMAx2TW5g QhOeRodv5ANgbZUHAg9UesGRY4zUXMJH4SZfSl+fNv7I4nUVw/JW/8L0U812djglZik0 9Pfw== X-Gm-Message-State: AOJu0YzzHkF6fXkAltYwCORYTxqw/wORFdfM2vVIMIvh3bATIej+WpP4 TTnFsjsTZ4k55TJ9YjeIPOM4bpIPwTO7OrLt7lz0aVYrJymaNmXBOx5pqmiNNSDCzhB89xPuzTs I4LAI07E= X-Gm-Gg: ASbGncshv2KC+1eUzt/nEW56SiOs+VeAWrZmBf3/euFNNNCZ0DqCb1c1+ZsB8ZZHRim kaIPUtX6xqAmsEkwZGlLgLQdSlz7Cg9jPqqGqMD3iTaL9XPfM1kUHyEhgYS34tImFw2jyCwKcO2 +yRihFIUNpg8vfJTQpfJbuyTyAGn2xMzo0TiWfQnY/XrRAQlawDbNP003D4h2OZ+Ui56+mscoQv 8Oba1YZGdhwdji0ojgtOjrBAy2sw+yXPwRBweCtKEtnr7M8zyRu7BQ61ly/JdfhmykBtPKl8o11 SdHqzwlOpP/xRfw/o3hREo7iYV1QqpuW7cRcSpCz79LAqmuCcR4NV9Q2KptuA85IgWZwnm65Xy0 bRbh4lx0+Dtovh1LvQ+k55ZwaB18dvaSWcYGwbexFxOp+Wc4WeXwc X-Google-Smtp-Source: AGHT+IHsYsB1hkT09yH0i+J8HA7e4OkVLcs/jHst/ws14jBbKeRLBAt1t8AJ6wYC2DPe6keDUIEEIA== X-Received: by 2002:a05:6871:2b1d:b0:2ff:9ecb:9bad with SMTP id 586e51a60fabf-30b67973ff4mr2856215fac.30.1754177562409; Sat, 02 Aug 2025 16:32:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 34/85] target/arm: Remove unused env argument from regime_el Date: Sun, 3 Aug 2025 09:29:02 +1000 Message-ID: <20250802232953.413294-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c35; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc35.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178233081116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/internals.h | 8 ++++---- target/arm/helper.c | 2 +- target/arm/ptw.c | 34 +++++++++++++++++----------------- target/arm/tcg/mte_helper.c | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 2dc82330ec..4991d6ab7f 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1076,7 +1076,7 @@ static inline bool regime_is_stage2(ARMMMUIdx mmu_idx) } =20 /* Return the exception level which controls this address translation regi= me */ -static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) +static inline uint32_t regime_el(ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_E20_0: @@ -1130,7 +1130,7 @@ static inline bool regime_is_user(CPUARMState *env, A= RMMMUIdx mmu_idx) /* Return the SCTLR value which controls this address translation regime */ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) { - return env->cp15.sctlr_el[regime_el(env, mmu_idx)]; + return env->cp15.sctlr_el[regime_el(mmu_idx)]; } =20 /* @@ -1162,13 +1162,13 @@ static inline uint64_t regime_tcr(CPUARMState *env,= ARMMMUIdx mmu_idx) v |=3D env->cp15.vtcr_el2 & VTCR_SHARED_FIELD_MASK; return v; } - return env->cp15.tcr_el[regime_el(env, mmu_idx)]; + return env->cp15.tcr_el[regime_el(mmu_idx)]; } =20 /* Return true if the translation regime is using LPAE format page tables = */ static inline bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mm= u_idx) { - int el =3D regime_el(env, mmu_idx); + int el =3D regime_el(mmu_idx); if (el =3D=3D 2 || arm_el_is_aa64(env, el)) { return true; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 8985ad8c8a..78f670314d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9633,7 +9633,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, = uint64_t va, ARMGranuleSize gran; ARMCPU *cpu =3D env_archcpu(env); bool stage2 =3D regime_is_stage2(mmu_idx); - int r_el =3D regime_el(env, mmu_idx); + int r_el =3D regime_el(mmu_idx); =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 820d5e65a0..30c83334b6 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -232,9 +232,9 @@ static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx= mmu_idx, int ttbrn) return env->cp15.vsttbr_el2; } if (ttbrn =3D=3D 0) { - return env->cp15.ttbr0_el[regime_el(env, mmu_idx)]; + return env->cp15.ttbr0_el[regime_el(mmu_idx)]; } else { - return env->cp15.ttbr1_el[regime_el(env, mmu_idx)]; + return env->cp15.ttbr1_el[regime_el(mmu_idx)]; } } =20 @@ -1023,7 +1023,7 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Tran= slate *ptw, } type =3D (desc & 3); domain =3D (desc >> 5) & 0x0f; - if (regime_el(env, ptw->in_mmu_idx) =3D=3D 1) { + if (regime_el(ptw->in_mmu_idx) =3D=3D 1) { dacr =3D env->cp15.dacr_ns; } else { dacr =3D env->cp15.dacr_s; @@ -1163,7 +1163,7 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Tran= slate *ptw, /* Page or Section. */ domain =3D (desc >> 5) & 0x0f; } - if (regime_el(env, mmu_idx) =3D=3D 1) { + if (regime_el(mmu_idx) =3D=3D 1) { dacr =3D env->cp15.dacr_ns; } else { dacr =3D env->cp15.dacr_s; @@ -1454,7 +1454,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu= _idx, bool is_aa64, xn =3D pxn || (user_rw & PAGE_WRITE); } } else if (arm_feature(env, ARM_FEATURE_V7)) { - switch (regime_el(env, mmu_idx)) { + switch (regime_el(mmu_idx)) { case 1: case 3: if (is_user) { @@ -1510,7 +1510,7 @@ static int get_S1prot_indirect(CPUARMState *env, S1Tr= anslate *ptw, /* F */ 0, /* reserved */ }; =20 - uint32_t el =3D regime_el(env, mmu_idx); + uint32_t el =3D regime_el(mmu_idx); uint64_t pir =3D env->cp15.pir_el[el]; uint64_t pire0 =3D 0; int perm; @@ -1585,7 +1585,7 @@ static ARMVAParameters aa32_va_parameters(CPUARMState= *env, uint32_t va, ARMMMUIdx mmu_idx) { uint64_t tcr =3D regime_tcr(env, mmu_idx); - uint32_t el =3D regime_el(env, mmu_idx); + uint32_t el =3D regime_el(mmu_idx); int select, tsz; bool epd, hpd; =20 @@ -1811,7 +1811,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, int addrsize, inputsize, outputsize; uint64_t tcr =3D regime_tcr(env, mmu_idx); int ap, prot; - uint32_t el =3D regime_el(env, mmu_idx); + uint32_t el =3D regime_el(mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); uint64_t descriptor, new_descriptor; @@ -2259,7 +2259,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 /* Index into MAIR registers for cache attributes */ attrindx =3D extract32(attrs, 2, 3); - mair =3D env->cp15.mair_el[regime_el(env, mmu_idx)]; + mair =3D env->cp15.mair_el[regime_el(mmu_idx)]; assert(attrindx <=3D 7); result->cacheattrs.is_s2_format =3D false; result->cacheattrs.attrs =3D extract64(mair, attrindx * 8, 8); @@ -2737,7 +2737,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, static uint32_t *regime_rbar(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t secure) { - if (regime_el(env, mmu_idx) =3D=3D 2) { + if (regime_el(mmu_idx) =3D=3D 2) { return env->pmsav8.hprbar; } else { return env->pmsav8.rbar[secure]; @@ -2747,7 +2747,7 @@ static uint32_t *regime_rbar(CPUARMState *env, ARMMMU= Idx mmu_idx, static uint32_t *regime_rlar(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t secure) { - if (regime_el(env, mmu_idx) =3D=3D 2) { + if (regime_el(mmu_idx) =3D=3D 2) { return env->pmsav8.hprlar; } else { return env->pmsav8.rlar[secure]; @@ -2779,7 +2779,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, uint32_t addr_page_limit =3D addr_page_base + (TARGET_PAGE_SIZE - 1); int region_counter; =20 - if (regime_el(env, mmu_idx) =3D=3D 2) { + if (regime_el(mmu_idx) =3D=3D 2) { region_counter =3D cpu->pmsav8r_hdregion; } else { region_counter =3D cpu->pmsav7_dregion; @@ -2905,7 +2905,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, xn =3D 1; } =20 - if (regime_el(env, mmu_idx) =3D=3D 2) { + if (regime_el(mmu_idx) =3D=3D 2) { result->f.prot =3D simple_ap_to_rw_prot_is_user(ap, mmu_idx !=3D ARMMMUIdx_E2); } else { @@ -2914,7 +2914,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, =20 if (!arm_feature(env, ARM_FEATURE_M)) { uint8_t attrindx =3D extract32(matched_rlar, 1, 3); - uint64_t mair =3D env->cp15.mair_el[regime_el(env, mmu_idx)]; + uint64_t mair =3D env->cp15.mair_el[regime_el(mmu_idx)]; uint8_t sh =3D extract32(matched_rlar, 3, 2); =20 if (regime_sctlr(env, mmu_idx) & SCTLR_WXN && @@ -2922,7 +2922,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, xn =3D 0x1; } =20 - if ((regime_el(env, mmu_idx) =3D=3D 1) && + if ((regime_el(mmu_idx) =3D=3D 1) && regime_sctlr(env, mmu_idx) & SCTLR_UWXN && ap =3D=3D 0x1) { pxn =3D 0x1; } @@ -3407,7 +3407,7 @@ static bool get_phys_addr_disabled(CPUARMState *env, break; =20 default: - r_el =3D regime_el(env, mmu_idx); + r_el =3D regime_el(mmu_idx); if (arm_el_is_aa64(env, r_el)) { int pamax =3D arm_pamax(env_archcpu(env)); uint64_t tcr =3D env->cp15.tcr_el[r_el]; @@ -3659,7 +3659,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, */ if (address < 0x02000000 && mmu_idx !=3D ARMMMUIdx_Stage2 && !arm_feature(env, ARM_FEATURE_V8)) { - if (regime_el(env, mmu_idx) =3D=3D 3) { + if (regime_el(mmu_idx) =3D=3D 3) { address +=3D env->cp15.fcseidr_s; } else { address +=3D env->cp15.fcseidr_ns; diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c index 0efc18a181..ed30026b7d 100644 --- a/target/arm/tcg/mte_helper.c +++ b/target/arm/tcg/mte_helper.c @@ -604,7 +604,7 @@ void mte_check_fail(CPUARMState *env, uint32_t desc, int el, reg_el, tcf; uint64_t sctlr; =20 - reg_el =3D regime_el(env, arm_mmu_idx); + reg_el =3D regime_el(arm_mmu_idx); sctlr =3D env->cp15.sctlr_el[reg_el]; =20 switch (arm_mmu_idx) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178152; cv=none; d=zohomail.com; s=zohoarc; b=bHVC472KwM79frjuIZjpXJ1P+1nIVg+JkEOLjdB++u+abfFvrrbJ7CDks63RpH27jOpH0c967Pq48MH3R1GQsI/P/x1mY1I5RXHd4AXnd24CACDmsAeM11XCiAn+I3c7AYYKeHy6Yp96oBvJsEaUPtPHAkjxDojVPrK8VEC3uBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178152; 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=nK/orVpSsRC7EeosV5+++ApHwhVQ4D3Ng52cDHWLf6A=; b=iLQsghUzlyxka6lOIqGautnrC+TL2H9EbaDE+HJht/zXnroM0vzd7cI2K/5SEdxqHkJnEOLSQLVqfpN12aq5KmBS3cYy7q7wsXWxHBtYAjOXd7ML5VEOSRT3P0SSxr/yAAt0iIuifTve8crRcW8PbInLQVh5apHgCmrwvPQ8CkM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178152843746.947329181079; Sat, 2 Aug 2025 16:42:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLlR-0000qv-DR; Sat, 02 Aug 2025 19:35:45 -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 1uiLid-0001vS-Ns for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:52 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLib-0005G9-SJ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:51 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-741a6272c8fso140929a34.3 for ; Sat, 02 Aug 2025 16:32:49 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177569; x=1754782369; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nK/orVpSsRC7EeosV5+++ApHwhVQ4D3Ng52cDHWLf6A=; b=oWwU4vX5SzeQwuyv8wi8rfzh/UDilIWoQtDGLgW9EgRgP/Q9wlrRswu6YATXBs1tsb CLs7guQUG7t3KSoeWog6yz9K5yu12I6ALqzRYaxYkgnvRrXpcepi+Go5AAaLAMTFk40q aB3a7ACw1rAwC3kbarNTNKB4U5INCa7ruNRwMBJWVaxeBkSGx3bBd2H+Edy+Od5VfSt0 JDkMYVAySiWv9ZqWFkbcGZz63TfSJRRLfqGMjWlwmIEk2IMfgjj+BkxV7PnMxhonJ9Fy hSL1lQJSj4VQBEx6iDhn1dm70uQt89SZyLB86UVCq0EE0W2ZNkeCFGHx+LGmEEsKmyvX GsXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177569; x=1754782369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nK/orVpSsRC7EeosV5+++ApHwhVQ4D3Ng52cDHWLf6A=; b=DWb0+C/b/rOy0WjnHW/4zsbE6vfFPt4swbUUzmz+K8rII2657OPqEg8jAqY5X1H1aw LqFbS569EYNSVTqEQkbVbJmlBKA1/XSVBmfmLolYzq8kF0grm1mzSw2cdHpwu6ud2Bj5 ykTBZvZ4qEo0zBjI8wp9rIJjh7uNNRTTFxGfttjRuvtNMX6qJSi8cd8cYKA66AW/5K/E TQwbQFO3CLbgF5pNzXsCEx5u2ocoeOLQxqmrxXTLkHAZ6BLe82gu0uanqeFt/EBiWgG5 e7ASkRaiPRFW1HEc2skWgpR9Pjdzpua0x/FGEBUDYAlTBvEzcWfV9PLKLbT69G/Ayek/ O5Gw== X-Gm-Message-State: AOJu0YyGNLNyHc1WLDe0ZEAgavP3Kz8sbNiqgIYu6XWd/tvBSk3+rXO7 D2OwOkPFm+pdK3azmRs5D2e2k/CEkT/VLCiFLx9/QWNctMtUdSBq5FbPG7eM6f8EV3PFzkve3ip 0Y33KipI= X-Gm-Gg: ASbGnctLmBM/3Yxm/MqCbNPOFA3PDP4hhx561CzvkKUHNw3qw6khiJp7ylV1xGvKG2r Buu8zSf7FtIm5F+1qIUukqhk4ZY21Vp8mQdOMxjJe3syQmvzTuW4nNjrbk/feGzlkTHaqnCJ0Un bPVs+BVi1GEPLXD2+oeGbaPe3UpM8KQfjC8hGTw5u7xybZj5CKm5nRm7CDzEytXEQsGe6IMLyKi 7gwKatcQnTWB47NONG5Nzo85x6ykm8giiKWETlDIJJYI9mRWQbLYdQIkLU3uyQKohPRp8/HRknF BTgdY0f0gyk8vcl3kb9NpPywjjL8JrPcJx6yqoQQvjkfVYgJyeBdIYPan4lwG96Gg2nS7dotgq8 nWFiDk/0uhxNl5fo1pcrnDbc6WIoikGifRDHUWyUL21A3+ffpgDKm X-Google-Smtp-Source: AGHT+IFX76f0aSyMvDRAlSIoQP8JPAR9tzVIC1cs8Whme00eEYgKP5mNKaOExbq+2Et+/DuOnkkC3A== X-Received: by 2002:a05:6871:708:b0:2f7:840d:fe9 with SMTP id 586e51a60fabf-30b6780dbf1mr2619969fac.22.1754177568612; Sat, 02 Aug 2025 16:32:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 35/85] target/arm: Convert regime_el from switch to table Date: Sun, 3 Aug 2025 09:29:03 +1000 Message-ID: <20250802232953.413294-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178154394116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 35 ---------------------------- target/arm/mmuidx-internal.h | 13 +++++++++++ target/arm/mmuidx.c | 44 +++++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 53 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 4991d6ab7f..3b730a5d81 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1075,41 +1075,6 @@ static inline bool regime_is_stage2(ARMMMUIdx mmu_id= x) return mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Sta= ge2_S; } =20 -/* Return the exception level which controls this address translation regi= me */ -static inline uint32_t regime_el(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_E20_0: - case ARMMMUIdx_E20_2: - case ARMMMUIdx_E20_2_PAN: - case ARMMMUIdx_Stage2: - case ARMMMUIdx_Stage2_S: - case ARMMMUIdx_E2: - return 2; - case ARMMMUIdx_E3: - case ARMMMUIdx_E30_0: - case ARMMMUIdx_E30_3_PAN: - return 3; - case ARMMMUIdx_E10_0: - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_Stage1_E1: - case ARMMMUIdx_Stage1_E1_PAN: - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - case ARMMMUIdx_MPrivNegPri: - case ARMMMUIdx_MUserNegPri: - case ARMMMUIdx_MPriv: - case ARMMMUIdx_MUser: - case ARMMMUIdx_MSPrivNegPri: - case ARMMMUIdx_MSUserNegPri: - case ARMMMUIdx_MSPriv: - case ARMMMUIdx_MSUser: - return 1; - default: - g_assert_not_reached(); - } -} - static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index 29bba4ecb5..d8d64a14d6 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -13,6 +13,8 @@ =20 FIELD(MMUIDXINFO, EL, 0, 2) FIELD(MMUIDXINFO, ELVALID, 2, 1) +FIELD(MMUIDXINFO, REL, 3, 2) +FIELD(MMUIDXINFO, RELVALID, 5, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -26,4 +28,15 @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, EL); } =20 +/* + * Return the exception level for the address translation regime + * associated with this mmu index. + */ +static inline uint32_t regime_el(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + tcg_debug_assert(FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, RELVALI= D)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, REL); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index 309b1d68df..6dfefa56c2 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -8,34 +8,42 @@ =20 =20 #define EL(X) ((X << R_MMUIDXINFO_EL_SHIFT) | R_MMUIDXINFO_ELVALID_MASK) +#define REL(X) ((X << R_MMUIDXINFO_REL_SHIFT) | R_MMUIDXINFO_RELVALID_MASK) =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* * A-profile. */ - [ARMMMUIdx_E10_0] =3D EL(0), - [ARMMMUIdx_E10_1] =3D EL(1), - [ARMMMUIdx_E10_1_PAN] =3D EL(1), + [ARMMMUIdx_E10_0] =3D EL(0) | REL(1), + [ARMMMUIdx_E10_1] =3D EL(1) | REL(1), + [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1), =20 - [ARMMMUIdx_E20_0] =3D EL(0), - [ARMMMUIdx_E20_2] =3D EL(2), - [ARMMMUIdx_E20_2_PAN] =3D EL(2), + [ARMMMUIdx_E20_0] =3D EL(0) | REL(2), + [ARMMMUIdx_E20_2] =3D EL(2) | REL(2), + [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2), =20 - [ARMMMUIdx_E2] =3D EL(2), + [ARMMMUIdx_E2] =3D EL(2) | REL(2), =20 - [ARMMMUIdx_E3] =3D EL(3), - [ARMMMUIdx_E30_0] =3D EL(0), - [ARMMMUIdx_E30_3_PAN] =3D EL(3), + [ARMMMUIdx_E3] =3D EL(3) | REL(3), + [ARMMMUIdx_E30_0] =3D EL(0) | REL(3), + [ARMMMUIdx_E30_3_PAN] =3D EL(3) | REL(3), + + [ARMMMUIdx_Stage2_S] =3D REL(2), + [ARMMMUIdx_Stage2] =3D REL(2), + + [ARMMMUIdx_Stage1_E0] =3D REL(1), + [ARMMMUIdx_Stage1_E1] =3D REL(1), + [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1), =20 /* * M-profile. */ - [ARMMMUIdx_MUser] =3D EL(0), - [ARMMMUIdx_MPriv] =3D EL(1), - [ARMMMUIdx_MUserNegPri] =3D EL(0), - [ARMMMUIdx_MPrivNegPri] =3D EL(1), - [ARMMMUIdx_MSUser] =3D EL(0), - [ARMMMUIdx_MSPriv] =3D EL(1), - [ARMMMUIdx_MSUserNegPri] =3D EL(0), - [ARMMMUIdx_MSPrivNegPri] =3D EL(1), + [ARMMMUIdx_MUser] =3D EL(0) | REL(1), + [ARMMMUIdx_MPriv] =3D EL(1) | REL(1), + [ARMMMUIdx_MUserNegPri] =3D EL(0) | REL(1), + [ARMMMUIdx_MPrivNegPri] =3D EL(1) | REL(1), + [ARMMMUIdx_MSUser] =3D EL(0) | REL(1), + [ARMMMUIdx_MSPriv] =3D EL(1) | REL(1), + [ARMMMUIdx_MSUserNegPri] =3D EL(0) | REL(1), + [ARMMMUIdx_MSPrivNegPri] =3D EL(1) | REL(1), }; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179281; cv=none; d=zohomail.com; s=zohoarc; b=ay/LHU0KzoUZ7PR0i0xFcm3mJtO9yu9txHTKepF/WiDyfp4TeTXpDY/8oYarj1DCcimxZ4AC64P/pR0PFVMB6djXCPAGCwqR89uLZXVb/Lx9X08IZoH0mJYSZ+SFu9lIE6BoSnjpkyJrSJ3kktFMGtJVANxUKtMh0uKcLqHYPT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179281; 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=yW/5iqr1LXzaRcUIZ6o2S3mScJrT5xleYfUADzIzlrM=; b=EKfd1lnJl7Xkc/lhzuAj1aziA/5MKQo7U0emGiudjhqorH0QmNm43bJ1dMSqoDhMZQymxghEXnycbScmhtEAGxD8h1rU1bqhxvDNVAmwne7aQb8Bbpw4+c1zgCTvlPbdHDCCYb+RUs03yizJLRRAKo/t15kygaUSKNFL2Vdoojg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179281529918.5160614896141; Sat, 2 Aug 2025 17:01:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLk0-000678-6t; Sat, 02 Aug 2025 19:34:16 -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 1uiLii-00022y-AQ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:57 -0400 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLig-0005HC-HG for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:56 -0400 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-619a603b7cdso73400eaf.2 for ; Sat, 02 Aug 2025 16:32:54 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177573; x=1754782373; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yW/5iqr1LXzaRcUIZ6o2S3mScJrT5xleYfUADzIzlrM=; b=xQp4M+6t4Ikh+UlnbjUy6+mI2shlKfelr7M2zUWBoQO9HAIStWOEZjJ0w9aixF/hQT 11sH2E2FksxF+gtLDSh4oZ/XkTCFRMfZjJhhwPU1mRO0zjGWmvmZji7b8bmr0iuPX4bF XstVkJIKj8XC50QTamxBpAIk4rBjFPQKePO7WESP9NnHOsPCPUzlqtaAmNZ/3b6OY7BL NzMV4IaabC1ctq1vy+H02ZY8FQsdVNC4onYeUwu9sjPoaavZdkBDgn5bwiKmD4isCQjd eoFp/HTr7+M3hsuVhqxFpicOkmWI5vgolOCA33MqLfsc4wWBhDVZqHqSDETR4PNYASxP aHlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177573; x=1754782373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yW/5iqr1LXzaRcUIZ6o2S3mScJrT5xleYfUADzIzlrM=; b=GIm6AXnipKsxJaAI4iI2glPoEM89x8y61lC4t0oXsOeMd4+iuKYHAZrUC9NTVGh4Y6 08cjiQJ/vcj9VsgOAMtDjmDq54MC3QEVJJiIfReMceeu0J8xZW2y8cmVnm81fJw9vYvF jufiXH3RvYOyxpRGfCZ4ZbbzBdjRWfhgql8ozjKpuaUoAYMNhHMG4u4xYyO5QNINk7VB rFinUuji1XgNC7Nfn02I7f2SmspspH03oxoykuNbqlNVob8Z1bvQB48CO38YZbB0e1RN 4YYKJhdwGgcQIUYz3jHzjUerfZT4G6IaZ2mSLLYjO+DSeZgLGTdcYJAWf3xr0cqkFfot tLSg== X-Gm-Message-State: AOJu0Yw+Ls4/U0AGmAOw3QTkkZr7ocO09v5IbTwDf52oqNxsDmcsiLpK RZWAgEVpbLAziipxO6+hXdYuATmrByYZlpJtHq3DDXtCJJLByIMotxnC5QUbFUEg2Yd4a4lIfQy pnhjiYKQ= X-Gm-Gg: ASbGncvzP25PjoOhBOw5awmnRHtQIf1E7+DMn20/lDzaSQ6y34G00BRnauWXPvd1qyL z//RxHuEQwzYK/R0rX5N01QE58CiD+XKPyZXobbIkjzZjLtqTsclRsDDw0q6WahVBuatYxsOp2O AjkiVMyvuFoUMH1kaT9dFxoc1gem3FyLz6zpIUn6nUIRM4O7qOaLlZXj/M5ubgFr611x+GA6SVH tUGyrDH4DHUFCGZ0S+3fb8aa4gkNOFoi8SkQthyiXN5CJ0mSP5LKbGEQGSeG6DXI7IbZqoTSRGs XzbuFuhjFjFMh0RYlhlxHagp7fbjaxBhgNX3AtXdW1awubZzuxqMqwxDJsx9TmacH8arXDIiRXa 7p4twxhcvo7UJsQFo2GC5wizUaxlyMJa374gogKYDB24Zxfg/VbmE X-Google-Smtp-Source: AGHT+IFcSzEPGCpbEr5Y0iXv5s+txrjkDZRxJr3YEFGwVN4/ceycjho10gys7jgnQEOFxvE3L7TTYQ== X-Received: by 2002:a05:6870:df4b:b0:30b:90f4:ca08 with SMTP id 586e51a60fabf-30b90f50bb2mr35511fac.22.1754177573306; Sat, 02 Aug 2025 16:32:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 36/85] target/arm: Convert regime_has_2_ranges from switch to table Date: Sun, 3 Aug 2025 09:29:04 +1000 Message-ID: <20250802232953.413294-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c2e; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2e.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179282579124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 28 ---------------------------- target/arm/mmuidx-internal.h | 17 +++++++++++++++++ target/arm/mmuidx.c | 19 ++++++++++--------- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 3b730a5d81..0322646753 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1029,34 +1029,6 @@ static inline void arm_call_el_change_hook(ARMCPU *c= pu) } } =20 -/* - * Return true if this address translation regime has two ranges. - * Note that this will not return the correct answer for AArch32 - * Secure PL1&0 (i.e. mmu indexes E3, E30_0, E30_3_PAN), but it is - * never called from a context where EL3 can be AArch32. (The - * correct return value for ARMMMUIdx_E3 would be different for - * that case, so we can't just make the function return the - * correct value anyway; we would need an extra "bool e3_is_aarch32" - * argument which all the current callsites would pass as 'false'.) - */ -static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_Stage1_E1: - case ARMMMUIdx_Stage1_E1_PAN: - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - case ARMMMUIdx_E20_0: - case ARMMMUIdx_E20_2: - case ARMMMUIdx_E20_2_PAN: - return true; - default: - return false; - } -} - static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index d8d64a14d6..f03a2ab94c 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -15,6 +15,7 @@ FIELD(MMUIDXINFO, EL, 0, 2) FIELD(MMUIDXINFO, ELVALID, 2, 1) FIELD(MMUIDXINFO, REL, 3, 2) FIELD(MMUIDXINFO, RELVALID, 5, 1) +FIELD(MMUIDXINFO, 2RANGES, 6, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -39,4 +40,20 @@ static inline uint32_t regime_el(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, REL); } =20 +/* + * Return true if this address translation regime has two ranges. + * Note that this will not return the correct answer for AArch32 + * Secure PL1&0 (i.e. mmu indexes E3, E30_0, E30_3_PAN), but it is + * never called from a context where EL3 can be AArch32. (The + * correct return value for ARMMMUIdx_E3 would be different for + * that case, so we can't just make the function return the + * correct value anyway; we would need an extra "bool e3_is_aarch32" + * argument which all the current callsites would pass as 'false'.) + */ +static inline bool regime_has_2_ranges(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, 2RANGES); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index 6dfefa56c2..f880d21606 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -9,18 +9,19 @@ =20 #define EL(X) ((X << R_MMUIDXINFO_EL_SHIFT) | R_MMUIDXINFO_ELVALID_MASK) #define REL(X) ((X << R_MMUIDXINFO_REL_SHIFT) | R_MMUIDXINFO_RELVALID_MASK) +#define R2 R_MMUIDXINFO_2RANGES_MASK =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* * A-profile. */ - [ARMMMUIdx_E10_0] =3D EL(0) | REL(1), - [ARMMMUIdx_E10_1] =3D EL(1) | REL(1), - [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1), + [ARMMMUIdx_E10_0] =3D EL(0) | REL(1) | R2, + [ARMMMUIdx_E10_1] =3D EL(1) | REL(1) | R2, + [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1) | R2, =20 - [ARMMMUIdx_E20_0] =3D EL(0) | REL(2), - [ARMMMUIdx_E20_2] =3D EL(2) | REL(2), - [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2), + [ARMMMUIdx_E20_0] =3D EL(0) | REL(2) | R2, + [ARMMMUIdx_E20_2] =3D EL(2) | REL(2) | R2, + [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2) | R2, =20 [ARMMMUIdx_E2] =3D EL(2) | REL(2), =20 @@ -31,9 +32,9 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { [ARMMMUIdx_Stage2_S] =3D REL(2), [ARMMMUIdx_Stage2] =3D REL(2), =20 - [ARMMMUIdx_Stage1_E0] =3D REL(1), - [ARMMMUIdx_Stage1_E1] =3D REL(1), - [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1), + [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2, + [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2, + [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2, =20 /* * M-profile. --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177739; cv=none; d=zohomail.com; s=zohoarc; b=Sqm+JHUH5FYgQQw2hLHN4LnGfCUhOonoGAIc83ZxLCIE5w5+3Ui5XlaHZ/YZwj1h/xiFjThmQE34nc0JzcumvOnFq1mxQXS8O/H9jM915KpbSNhNlMlBbGtCSxfogRfSX0A/qJIwEErSqeVLPrLJ+0cKXgIyO1dPe86wH1G7OhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177739; 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=qbGwNjCy+e+Sbpz2PXB4lvl0QoItA91bfxAh1LBwoOc=; b=Mk7CuIdbdCVJrhjJ49b6ebrbsU1EPTqwyqxSJpHYg/ZbppXQETyE90gvoqTaqxHen7v01U+LSyL8oB1mD9p5+3GsuM8EoqDsTtnzhNOSnVh92f/XlTMgbgDUC8PHJGciaT3cED0yJnfcf+XtJCeHCTNqg5OVrJAtqRyLRK/nyik= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754177739743117.5973937690394; Sat, 2 Aug 2025 16:35:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLk2-0006JZ-Hx; Sat, 02 Aug 2025 19:34:19 -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 1uiLim-0002B3-PM for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:33:01 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLil-0005I4-6r for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:33:00 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-741a8bb8aa4so160849a34.1 for ; Sat, 02 Aug 2025 16:32:58 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177578; x=1754782378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qbGwNjCy+e+Sbpz2PXB4lvl0QoItA91bfxAh1LBwoOc=; b=u6YQe8FERMXctgiKxbgOM/4r9cAOVwbCqrlkPNRIRJGMHBHm7Bl0m3MIorB5CM+QIR lXN6HH2kumJgC+jvLlGGmgP/GUt1G0Phyx9h4xu9m/H+jldJLYQEm01N0QU93LCvNB5y BWc1Z20AM1vEdTP4Jogkr8OkE1Li9/1/KF94XRnkTbLiHFxQNGgKOlQQEa1264pz32Ng 0YlJj49g/lSlLAAtJobjcsZy/dr3aFervKsaqWSutZzkX4orLe4/3vDYcbg8v5fEajvb DnQSE10KJAc99J8wqKVe2Xb2RlBTr3kPD17rkFod1b4k/yB2ZUYjcOUmJtFPMjhgsPme WTuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177578; x=1754782378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qbGwNjCy+e+Sbpz2PXB4lvl0QoItA91bfxAh1LBwoOc=; b=bpMRWjo0vLOvmDCza+PRpAb8z3vIfOkIBIEe8sgFXnZY6ph/SXqhe9OtaaaImbxtD5 z6GQZ75Y8P0JK7l5tnxRBwAg7KfMrwjBySIrfvVrAwFASZtIWxJvtL0bbnVCt7g4Syfc d7l4RSAEJIwS3ghm/S16eLXzIrPEj2LDsEXiweF9Zrm5vMRJYzDrAapPV24GAV+N/cbC IpjWzvzKsvuRiGDyS1ixjlqs64czGQAGYFbmpAeAetTSEEXjmjN6yfeyNq8S3FJbfQlq NxUsIG+DDD+vAD0VLacT+w0AAK0i98iRjljg3HVtRiat799SKN9T0gdC7XZDsMaIUgMR X2yg== X-Gm-Message-State: AOJu0YyA2HkgbaKlqlJr8IHWMNT90doDYEnWQjYX++VxJgYNsHR7fPil fnGBFfBIAEytnRit0wnL7MOObjyZA1ejmYaA7yJyjiUlm2CrOOb2Y95baPpzM2rg2JeHkNMLFjV 8gIh9F4Y= X-Gm-Gg: ASbGnct13Smoz20vgt31GLyxU8vzm5wFHBQioQHqG2YMGwkxo+bJ2cYEuKiKRIUAOYX i4Xc9XeXhao4d89o5lZLfj6grv3kJxam4bDRepJkrPD+ANwvvyw4A/fDmK6CKWUu6JyA8qY50ZO uzlyAUUS5BIsNf3fR6oNDAd+UdXGtwk21w9SKTC8hhgsqLZvV46EZM8xJFnCog0kAQU6+ObRg31 1UhAAptbWqsQbcgWlln6GeEjxg1FZwInJ5cmiG8ZGVlQdoF1R/eltHskM/qtWe97y6hSrSvNcJe XmZ8sAzQQxHfAYWEklx294UboFPubMBKSJKNUXxdVpt/lNmS5OP3Ea7DUt+svSUYe+JNqbZ3eg+ I8/aGbfO+hbx0/zI27BxzmijfzqCxYwr/r2H1erWPse1/7+F2vqcA X-Google-Smtp-Source: AGHT+IEIJnseBBBP2T/DvC6rREZP+EzcZqrLGtMbeoHwj5vBnVvN1cMSC0IGd3orqE3f1d1I4ht2eA== X-Received: by 2002:a05:6871:610a:b0:2ff:8978:6be9 with SMTP id 586e51a60fabf-30b675e77d9mr2548657fac.16.1754177577997; Sat, 02 Aug 2025 16:32:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 37/85] target/arm: Remove unused env argument from regime_is_pan Date: Sun, 3 Aug 2025 09:29:05 +1000 Message-ID: <20250802232953.413294-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177741434116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 2 +- target/arm/ptw.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 0322646753..962fc423a6 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1029,7 +1029,7 @@ static inline void arm_call_el_change_hook(ARMCPU *cp= u) } } =20 -static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx) +static inline bool regime_is_pan(ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_Stage1_E1_PAN: diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 30c83334b6..c75b15b263 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1394,10 +1394,10 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx m= mu_idx, bool is_aa64, * We make the IMPDEF choices that SCR_EL3.SIF and Realm EL2&0 * do not affect EPAN. */ - if (user_rw && regime_is_pan(env, mmu_idx)) { + if (user_rw && regime_is_pan(mmu_idx)) { prot_rw =3D 0; } else if (cpu_isar_feature(aa64_pan3, cpu) && is_aa64 && - regime_is_pan(env, mmu_idx) && + regime_is_pan(mmu_idx) && (regime_sctlr(env, mmu_idx) & SCTLR_EPAN) && !xn) { prot_rw =3D 0; } @@ -1536,7 +1536,7 @@ static int get_S1prot_indirect(CPUARMState *env, S1Tr= anslate *ptw, p_perm &=3D ~(PAGE_RWX | PAGE_GCS); u_perm &=3D ~(PAGE_RWX | PAGE_GCS); } - if ((u_perm & (PAGE_RWX | PAGE_GCS)) && regime_is_pan(env, mmu_idx= )) { + if ((u_perm & (PAGE_RWX | PAGE_GCS)) && regime_is_pan(mmu_idx)) { p_perm &=3D ~(PAGE_READ | PAGE_WRITE); } perm =3D regime_is_user(env, mmu_idx) ? u_perm : p_perm; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178437; cv=none; d=zohomail.com; s=zohoarc; b=BLsAaEoMwWbHZ9PElnsDLJUChBRb0rv1IiSdhI1S1H0c7iS1Tz8dvveryCgH9LnrjdODqu5OTbF3RTTwiocVbmkiVV0qaoC59y+5LH/+vMJFNao4YnLdESU9x+j1DSV/pBbO0exUkqVUCoOEdVYO5cZGsRsi9ZtWwVRo6y4cwGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178437; 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=1FtjhMLhMPqBf/akhP4/Q7b8Tx2CMEduly/logXB3Ks=; b=WX1N8Gs0OEhlz1YcHuANipkCf8Ui6F1eU7nAHRSV5j9z1SFRoCg5u+ZLCaOd4QhhMvSSbk/jHKSRAdTH+saXPDe/qYtbWBYYXIgxcmiiV7QrRzCjsShM79Jzqs2Ji/b+V1IaRXguKIwTkFl0FZXb+rWgHHfaVPEAH5VhUEzDGts= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178437141489.44585876616316; Sat, 2 Aug 2025 16:47:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLlX-0001Oc-Ml; Sat, 02 Aug 2025 19:35:52 -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 1uiLit-0002NY-5b for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:33:07 -0400 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiq-0005Il-7m for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:33:06 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-2ffaa884a44so2081180fac.1 for ; Sat, 02 Aug 2025 16:33:03 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177582; x=1754782382; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1FtjhMLhMPqBf/akhP4/Q7b8Tx2CMEduly/logXB3Ks=; b=MA7Tg9bbF2uiyofQ7352+TFWnYkyRsPCVm8xbF6e0ptnDeyPr+Gy1kzboJTYOHIKQk halax0aIdf5PNLCvXbo/b/viHGrsXWOeJDTgm4dKM3fH0DEQ0JVR7s0/mZn+avYPfTJm CkkpuN4H1pb2tlLglwk4DtPplNzLu0s2iX6ruvmY2gMeldEs/rMg+EZT1vd5Qohb31f6 nTCumVTrpVwtb/PBUpb4oVhYVqcfmDgxPu9Kt6yrLcdMRYnVBCaajcXQ+3JVHjCsD7Yf Nn/96wOtGrwUV+FT518NQgZYhcxFHpTS1JCprtOYG+uSJUqCZ/j+9kKM8xy5icAXjx4D 1BLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177582; x=1754782382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1FtjhMLhMPqBf/akhP4/Q7b8Tx2CMEduly/logXB3Ks=; b=LoOGjBUuumoh6tXZPzms4FoVrJmiyssJdzQiiCIQ+pDi7weGneIMstZ3j3mkzCukAy uxRfIUH+8sfjKUfFUBqv0BzwBmH1lB6xK9Y+OeJ1NXu8GezNGoy/xTgIuleVcdvIxfOE V9zIznMwqmNeoF8lFvyzRGingQB6R1RlZP7jxEDv+otIyyF3rWwN22iCxeno3JzUINeB 7xtusxxUd/F2J68/QAhdZEJ9C1NB/WcMtqM6lSf2HjKlOtwYBlzikKL//aAem8yz1hfH Skmz0p50sONrN94BvyLsRgtgJ0xjEEwh7D693na7pk/adbfsfickphIc/PlW0YsLQqDL Phgg== X-Gm-Message-State: AOJu0YxB6LA7fSnuzdR0gE1Ly0pLwSRHSfI5ymZDAckjzDA8rjTT1Py8 7NLKZHaes/7JUDtyTnoM8/KzJoIFYyDCy+Ib71PpX/sf5F3oAVz2O6qmW78hzTUjhRcC1SFxD+m U+8+AoNQ= X-Gm-Gg: ASbGnct5S219jzylOrrPbIxsNX5rhQ9QahxC0n255bv0NWdat1ZUVzS9D2gySlF3p48 yPBTAMdsuykDaewoKIrCGJ1dbxBNA0daNle0FP0UWjpbXOlpGFHZQjowu+mGeg9i/v6oVdC1SYe j0LM1uVJIAfmGgSru3jhhK9oFqFSaEOxP2n+iPv5RE7hW+ujMCyqcTLEz6rdhppVbz2Z25LHkZr C/gor8k2Hpc4viTxM6KSWTrNsxSmG9FSooFbaqO01Ma8qJs3TqaQZcQPC+Z4F7kh7TKFf6LfMOI U0GeGrmOJH/wvKrruYkfG7+x3S3Dorut/5f39bPAEsjW50ppotkEWIgsnEdmJf6LGYoDTAVlBHq k4u4l96P6FELEizoUI3SIo+rU7qq3XWtrkGIlHdmqlU8GrV8KA2IT X-Google-Smtp-Source: AGHT+IFHWK1G/DsWOIrrEvnMh4//0acEeGJFeyNLA7J8ewcVJqBhyyExlozGJzjucIUydrU1ZK7sag== X-Received: by 2002:a05:6870:d8f:b0:306:e708:c958 with SMTP id 586e51a60fabf-30b6685aa08mr2847951fac.4.1754177582557; Sat, 02 Aug 2025 16:33:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 38/85] target/arm: Convert regime_is_pan from switch to table Date: Sun, 3 Aug 2025 09:29:06 +1000 Message-ID: <20250802232953.413294-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178437828124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 13 ------------- target/arm/mmuidx-internal.h | 8 ++++++++ target/arm/mmuidx.c | 9 +++++---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 962fc423a6..f665971b97 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1029,19 +1029,6 @@ static inline void arm_call_el_change_hook(ARMCPU *c= pu) } } =20 -static inline bool regime_is_pan(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_Stage1_E1_PAN: - case ARMMMUIdx_E10_1_PAN: - case ARMMMUIdx_E20_2_PAN: - case ARMMMUIdx_E30_3_PAN: - return true; - default: - return false; - } -} - static inline bool regime_is_stage2(ARMMMUIdx mmu_idx) { return mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Sta= ge2_S; diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index f03a2ab94c..41baf1a003 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -16,6 +16,7 @@ FIELD(MMUIDXINFO, ELVALID, 2, 1) FIELD(MMUIDXINFO, REL, 3, 2) FIELD(MMUIDXINFO, RELVALID, 5, 1) FIELD(MMUIDXINFO, 2RANGES, 6, 1) +FIELD(MMUIDXINFO, PAN, 7, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -56,4 +57,11 @@ static inline bool regime_has_2_ranges(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, 2RANGES); } =20 +/* Return true if Privileged Access Never is enabled for this mmu index. */ +static inline bool regime_is_pan(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, PAN); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index f880d21606..98db02b8e5 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -10,6 +10,7 @@ #define EL(X) ((X << R_MMUIDXINFO_EL_SHIFT) | R_MMUIDXINFO_ELVALID_MASK) #define REL(X) ((X << R_MMUIDXINFO_REL_SHIFT) | R_MMUIDXINFO_RELVALID_MASK) #define R2 R_MMUIDXINFO_2RANGES_MASK +#define PAN R_MMUIDXINFO_PAN_MASK =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* @@ -17,24 +18,24 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { */ [ARMMMUIdx_E10_0] =3D EL(0) | REL(1) | R2, [ARMMMUIdx_E10_1] =3D EL(1) | REL(1) | R2, - [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1) | R2, + [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1) | R2 | PAN, =20 [ARMMMUIdx_E20_0] =3D EL(0) | REL(2) | R2, [ARMMMUIdx_E20_2] =3D EL(2) | REL(2) | R2, - [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2) | R2, + [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2) | R2 | PAN, =20 [ARMMMUIdx_E2] =3D EL(2) | REL(2), =20 [ARMMMUIdx_E3] =3D EL(3) | REL(3), [ARMMMUIdx_E30_0] =3D EL(0) | REL(3), - [ARMMMUIdx_E30_3_PAN] =3D EL(3) | REL(3), + [ARMMMUIdx_E30_3_PAN] =3D EL(3) | REL(3) | PAN, =20 [ARMMMUIdx_Stage2_S] =3D REL(2), [ARMMMUIdx_Stage2] =3D REL(2), =20 [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2, [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2, - [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2, + [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | PAN, =20 /* * M-profile. --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754177789; cv=none; d=zohomail.com; s=zohoarc; b=ddwoJHIvjoRL9XerZa+RYMNS5gTN1A5HyO2loC9KQGygJbnSpnG1on/7FjD2MvXFdX2Ou1MVsO9JKOZ+NQ8kLi9XUMmfY2KK1aY9kpbPnHxhfK43zuIqDW6jcWS2DFhbAfNxmarBq9LyTzkM//G5uVQPUjszAE0eJUoGWziZVa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754177789; 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=ZZOw9ryR7txUPbUNE8ys+z7FS49ZXU14iEzf3W4F/4k=; b=ZHeNbuQ1yh0oeW/nAId/rGVVWmEmeSxTyirt/SO+t5By+7NdMGeUCVTrcy6nYUOwKPsannWB+KVl5lV8sqBw3iQjzL/NI8JIVnaw8zkCEo67r4iW8ze3/mGTYS7RC7UNiUAupQFTgJ9sjsof2VNfW/ZuJ/iGs2YJloQvgRQi+mg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417778911659.81124310966891; Sat, 2 Aug 2025 16:36:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLkG-0006dr-1m; Sat, 02 Aug 2025 19:34:32 -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 1uiLiv-0002SA-MD for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:33:10 -0400 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLiu-0005JP-1X for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:33:09 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-2ea6dd628a7so2031138fac.1 for ; Sat, 02 Aug 2025 16:33:07 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177587; x=1754782387; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZZOw9ryR7txUPbUNE8ys+z7FS49ZXU14iEzf3W4F/4k=; b=EIcdRDc7SAW2FC5lZZc9JRtiEBUIvF3o7j4+6NoSdPzEiXyBMr+IOsFubTjY2L8JLl 3kcoHp20ehfrsM5wBHdEA1v+CvHD7zyEqcYVvdH7ltKOA8u1oVnkqAWEnmOlvtRSl2pc hJ/Ul43+ezrF/+o60ya7T43H0sDHu9V2WtFscWFe0qIHTT9Y0OLIsi0JNndBgybkAasX rdZXOlVJ48bAKH1UrBfMB4ORoB8Lpx3sOOcRbJWjlJkH3V6Cdv011JP/wBT5RqIAuno0 MNgFX1sTKU4o6eTq3cE0HvSU86lczXDK+0+yTyT4hB0NMXugUYb6/fRe8aEJpkVWm4hl 7zhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177587; x=1754782387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZZOw9ryR7txUPbUNE8ys+z7FS49ZXU14iEzf3W4F/4k=; b=pHo7vPKG+yqWVwUYgzhrXMW+j+sBWz3MUPznl4nr86wYOLzXzvIavyQ1MCb1uPfW56 fIyN+0WZNAozuzIDN8tvwbecryJTMUbuG5yOMhB+zvOLaFZSICMoOB5D60GAOVJ7blkn nR3hpT45IaEdLhOz/HBETZM1wlwGMv2QksDYrms6TQpsrs8ltpU3fGIVwAOYAZlHkE0B IIAlzEgMFNW+fG5Gz7wMUr1HotGjGMPLycR7nitZBZ3ukd6adyTxZBIL6jLJwuDV2eCI P6YSLtQivnPmFEDqBoBInHOpqUQGRW4j6hT6hd/rgahw8dEZXZZBVtNULuvFFxhg/j+O YZrQ== X-Gm-Message-State: AOJu0YxIz8WRH/CvAdRpD12PTePM48m3j2jYpiH/jQggkTyjrzqFgQtA R7Rbi0mXuFFJYOrIMqp9xUfIWDd6ytV4aRgsmdJNwgUobHceNv8NxDoffC3auLqWuyRPIOFljcZ kAqmQbZ8= X-Gm-Gg: ASbGncscWEuI/0Pzxinodsc1DBCpM2wN0BXFosGAVlraFf5P5pZStp5qYWC9QjrFDMn P3p8uhYUCPjxl9eWTNClR6IS46smEaGYfC+1ndSlualGRPLOM6SeeOrG3ewR0baQglWkCQTYIE0 Xg/BcAAd/KZLE4BIrYbVON70pUkPLVIUf+P8Fkmtn2+4/WRVuF+oGV+I2panxUQRvZmbfVAbGyi rbL8nvy28OhTaj4ul2HTAjPUElW5B3NPmg1FNIcWQG0pAhdCuegr6a34CGxl2cBbtGKpu+cWSMG q+OlLNCTl/TxcU6vJzvNh0u3TTxs5MnWc7IscQxYOgXI6D/TTxjHHxjocWg7rRB1ntcqSUWLo+d n8jxk3BvCR5Z9kQoB82/yep454SBST4BwBYkvaHInudleBSP03l8nO3dG5G7ncKM= X-Google-Smtp-Source: AGHT+IH0EzsRlOzQYJxanoiCj/EWxT2adLgfV4RiogBEjgQRPRARAdLAq1jGkbGtwLdAt9tFZFWJig== X-Received: by 2002:a05:6870:ad08:b0:2ea:83e7:d525 with SMTP id 586e51a60fabf-30b676c5e7dmr2352236fac.16.1754177586827; Sat, 02 Aug 2025 16:33:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 39/85] target/arm: Remove unused env argument from regime_is_user Date: Sun, 3 Aug 2025 09:29:07 +1000 Message-ID: <20250802232953.413294-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754177789965116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 2 +- target/arm/helper.c | 2 +- target/arm/ptw.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index f665971b97..ea210c7179 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1034,7 +1034,7 @@ static inline bool regime_is_stage2(ARMMMUIdx mmu_idx) return mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Sta= ge2_S; } =20 -static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) +static inline bool regime_is_user(ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_E10_0: diff --git a/target/arm/helper.c b/target/arm/helper.c index 78f670314d..090076af24 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9692,7 +9692,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, = uint64_t va, ds =3D extract64(tcr, 59, 1); =20 if (e0pd && cpu_isar_feature(aa64_e0pd, cpu) && - regime_is_user(env, mmu_idx)) { + regime_is_user(mmu_idx)) { epd =3D true; } =20 diff --git a/target/arm/ptw.c b/target/arm/ptw.c index c75b15b263..493ec78c1a 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -964,7 +964,7 @@ static int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mm= u_idx, int ap, int domain_prot) { return ap_to_rw_prot_is_user(env, mmu_idx, ap, domain_prot, - regime_is_user(env, mmu_idx)); + regime_is_user(mmu_idx)); } =20 /* @@ -990,7 +990,7 @@ static int simple_ap_to_rw_prot_is_user(int ap, bool is= _user) =20 static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int a= p) { - return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); + return simple_ap_to_rw_prot_is_user(ap, regime_is_user(mmu_idx)); } =20 static bool get_phys_addr_v5(CPUARMState *env, S1Translate *ptw, @@ -1377,7 +1377,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu= _idx, bool is_aa64, ARMSecuritySpace in_pa, ARMSecuritySpace out_pa) { ARMCPU *cpu =3D env_archcpu(env); - bool is_user =3D regime_is_user(env, mmu_idx); + bool is_user =3D regime_is_user(mmu_idx); bool have_wxn; int wxn =3D 0; =20 @@ -1539,7 +1539,7 @@ static int get_S1prot_indirect(CPUARMState *env, S1Tr= anslate *ptw, if ((u_perm & (PAGE_RWX | PAGE_GCS)) && regime_is_pan(mmu_idx)) { p_perm &=3D ~(PAGE_READ | PAGE_WRITE); } - perm =3D regime_is_user(env, mmu_idx) ? u_perm : p_perm; + perm =3D regime_is_user(mmu_idx) ? u_perm : p_perm; } =20 if (in_pa !=3D out_pa) { @@ -2384,7 +2384,7 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t mask; uint32_t base; ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - bool is_user =3D regime_is_user(env, mmu_idx); + bool is_user =3D regime_is_user(mmu_idx); =20 if (regime_translation_disabled(env, mmu_idx, ptw->in_space)) { /* MPU disabled. */ @@ -2551,7 +2551,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, ARMCPU *cpu =3D env_archcpu(env); int n; ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - bool is_user =3D regime_is_user(env, mmu_idx); + bool is_user =3D regime_is_user(mmu_idx); bool secure =3D arm_space_is_secure(ptw->in_space); =20 result->f.phys_addr =3D address; @@ -2771,7 +2771,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t add= ress, * memory system to use a subpage. */ ARMCPU *cpu =3D env_archcpu(env); - bool is_user =3D regime_is_user(env, mmu_idx); + bool is_user =3D regime_is_user(mmu_idx); int n; int matchregion =3D -1; bool hit =3D false; @@ -3651,7 +3651,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1T= ranslate *ptw, break; } =20 - result->f.attrs.user =3D regime_is_user(env, mmu_idx); + result->f.attrs.user =3D regime_is_user(mmu_idx); =20 /* * Fast Context Switch Extension. This doesn't exist at all in v8. --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180102; cv=none; d=zohomail.com; s=zohoarc; b=JWXeQSsajrq0Blw9UkUC07gptczo0XG0khryiZ3RgXZnoMyKrviJJjRtT/Z9BEi50KDr6rYaPC5lgkyz3KLmRBWGuVsBZ6dZSVqLGDq1RCXZJI5SAaBcybbFLenb+WkNd7lx62ChntKL7DnJGlJ3ByFu9ymPz4kROsxnTiAEnuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180102; 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=J+LLQ9+ADAzbo3f8WTKEz7f5+T9KiIhpbqjO0j0F7Jw=; b=IaUlo+4LaI8pEfDbDPRPEikfDGl9Ixo9RxZGh+Sk4I/xIWyKUBwYYgTDyd6WJvxOqxgWdpRT0MgKIB/p+Zfc/pt8r1KZj44L0Fj/TRV0HXOWRZDMxm1KA2wIF3kk315GzhN0QT5zq8b8KrbePWSsqQHpG3VSu9upkTKz6HWOmn0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180102105106.62040329422211; Sat, 2 Aug 2025 17:15:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLnW-0004ez-3E; Sat, 02 Aug 2025 19:37:54 -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 1uiLm1-0002Hc-Az for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:21 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLlz-0005gz-Ao for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:21 -0400 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-42ce1441042so1174258b6e.3 for ; Sat, 02 Aug 2025 16:36:18 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177778; x=1754782578; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J+LLQ9+ADAzbo3f8WTKEz7f5+T9KiIhpbqjO0j0F7Jw=; b=cT3J2Lj1X60isvj6MgHWleJpoAOPm8spISB3Lf/LCIWI4dahfzq6oraa/XckWbTZDB MIySAor6JdnrGrlhhgzcMZEMpbPLCH6hUlOiM0eUKIhajj52qP2J2NVw4RoefF/3OVgm fZExUy09b6hjtMgTW5MLDYbq9sQ3zBZnTGokZc6Mh9h1EJ6e5fg6Vcq3Aa9pEE+kiM2f Mqgd9ND/1P9/0z0F6kwCJprcl+/iGxyU2zvlPMkJNjyVjNqQy4MRaCjomKb5mtK5W44i pZpTycsGto1Q5vvZe3aet3zjNDNYexIZqT6hVkQwegFsltbO4HFt11R0JzkydBGmPnm4 LEkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177778; x=1754782578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J+LLQ9+ADAzbo3f8WTKEz7f5+T9KiIhpbqjO0j0F7Jw=; b=AoeJzJr3Nzrz+FYWleWkcMDVHgSJJcCN2Ife0NogxU3wAY5lVzfhTYpyT1x4g8YvLV kJ8K5WRXs72t5FaXxNlWhi0JfWvPsjnEybdv4ZQtWbUM2kNfgl4nj2YVM0Pw22aE98aD CPhHBf+52etbjxCpFMi47v10Ae5ZET6F6jXRL7huVJ5OhlEr9+gXZ/q8sFCopuTMw2jV tUXTa5o0yO9DNWuu7YX3u6ciXtDdLbZwPlas9/cWocRU+G+6Vd8k4kO3b//2x3f4hgOh dOLOkKEyxogu/VsHDcjgRQ6scUhgr2WFOHWRA1S67rZpvnD51fcnWs44HLQt949XSstW 9knA== X-Gm-Message-State: AOJu0YywTB0+gUIC/6df1tqCRTFXZG+WPeTLa+LaUyc6ZXCdyeLWhQLX zhGXFNlY6fOTWzeQebItt9oMFI8B7DczOfUle5mchfVEtgt9jguF4trm5DJ25+mvDHkVZGVIUPb E2puUK4w= X-Gm-Gg: ASbGncvWF/WNYOZ6TvCPvoNlwOfTlrvqVkr0JnYQ8PDfJ903kiDOv3SlMgZ5epvI+SN WMp7l97rUAbueN3o6bcLrnO+VvQNcsSH50dMx7nw90jPLGPPB1x+ocJmWLbciPv2BGZgkFFI1zP mkp1mohA4DnZuqeUfoiCpm/hbpw9g+PzuyTAJvtLkIxhgaTz1A6X+lKU79rdrBoCnVItHDPp9eN wSeTVxZLrQyvs1ZvTgSV/kFJ+uIAUonOiwrhFC/noxFesuOaVPGQwzwgwScWZymSNLWYeek/9kw FrcBdyqIAWQ5Q5vry0drPhOEZxAkn9nD4Fc6ft5wlrB5hHOZDMEwBxkQznJOEQ4oiDbeePoIOy8 retqcBM/rsjmpeD6ez8vyWndPgNOYpiuYSMGIa9hi8/f3YeygWhYD X-Google-Smtp-Source: AGHT+IHrRtJh2WhqExf7yX7dbYNLBgZ2tV2GskHgbfD3QmO2X8Q31C42fHtTq5Ycdkoj/c8WyaKXcQ== X-Received: by 2002:a05:6808:8193:10b0:433:fdfa:913c with SMTP id 5614622812f47-433fdfa9843mr694021b6e.30.1754177777987; Sat, 02 Aug 2025 16:36:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 40/85] target/arm: Convert regime_is_user from switch to table Date: Sun, 3 Aug 2025 09:29:08 +1000 Message-ID: <20250802232953.413294-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754180104068116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 17 ----------------- target/arm/mmuidx-internal.h | 12 ++++++++++++ target/arm/mmuidx.c | 6 ++++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index ea210c7179..c6f3ae470b 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1034,23 +1034,6 @@ static inline bool regime_is_stage2(ARMMMUIdx mmu_id= x) return mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Sta= ge2_S; } =20 -static inline bool regime_is_user(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E20_0: - case ARMMMUIdx_E30_0: - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_MUser: - case ARMMMUIdx_MSUser: - case ARMMMUIdx_MUserNegPri: - case ARMMMUIdx_MSUserNegPri: - return true; - default: - return false; - } -} - /* Return the SCTLR value which controls this address translation regime */ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index 41baf1a003..3e51c0f579 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -17,6 +17,7 @@ FIELD(MMUIDXINFO, REL, 3, 2) FIELD(MMUIDXINFO, RELVALID, 5, 1) FIELD(MMUIDXINFO, 2RANGES, 6, 1) FIELD(MMUIDXINFO, PAN, 7, 1) +FIELD(MMUIDXINFO, USER, 8, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -64,4 +65,15 @@ static inline bool regime_is_pan(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, PAN); } =20 +/* + * Return true if the exception level associated with this mmu index is 0. + * Differs from arm_mmu_idx_to_el(idx) =3D=3D 0 in that this allows queryi= ng + * Stage1 and Stage2 mmu indexes. + */ +static inline bool regime_is_user(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, USER); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index 98db02b8e5..1c1e062bfe 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -7,10 +7,12 @@ #include "mmuidx-internal.h" =20 =20 -#define EL(X) ((X << R_MMUIDXINFO_EL_SHIFT) | R_MMUIDXINFO_ELVALID_MASK) +#define EL(X) ((X << R_MMUIDXINFO_EL_SHIFT) | R_MMUIDXINFO_ELVALID_MASK |= \ + ((X =3D=3D 0) << R_MMUIDXINFO_USER_SHIFT)) #define REL(X) ((X << R_MMUIDXINFO_REL_SHIFT) | R_MMUIDXINFO_RELVALID_MASK) #define R2 R_MMUIDXINFO_2RANGES_MASK #define PAN R_MMUIDXINFO_PAN_MASK +#define USER R_MMUIDXINFO_USER_MASK =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* @@ -33,7 +35,7 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { [ARMMMUIdx_Stage2_S] =3D REL(2), [ARMMMUIdx_Stage2] =3D REL(2), =20 - [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2, + [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | USER, [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2, [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | PAN, =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178473; cv=none; d=zohomail.com; s=zohoarc; b=LnkjHH2XtfsunXCZGAtXdmtenBN6d1Koa+EEepdMqKCOIKgEGT8TgZJ4KpLBm0WpV0KeXroHD4BH5vGf9MympSSJSurXe6qeNpjlGbsnjqBz7HV385k0zKFk4njf1CE3H1/Gb5VqcOwAcgaMspnko3jaAMUJG/S8NiAOq1cX9+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178473; 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=8YP9JcYf4nGEn4oQobQeHHEIsb6i/+ENAm1xO75l8c8=; b=k8aEEtmIjgFOwhr7HntnlB9cN8IQ9hNH8JX52WQN+63gbd6h+F6I0aOuBnAzmxwEYHj25UItP9nSKgoQn35K1yHgNubAMo7iJuXzXtG8eH6xbtSBL9WKqzdZ5blzipP39LEjYt3TL5D/sbog9JkpAXELi6ML3NE45sQCwS/yIcw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178473396227.94849588381567; Sat, 2 Aug 2025 16:47:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLnY-0004gs-3d; Sat, 02 Aug 2025 19:37:59 -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 1uiLm5-0002YY-4k for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:25 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLm3-0005hq-FP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:24 -0400 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-741b1fe0d43so15243a34.1 for ; Sat, 02 Aug 2025 16:36:23 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177782; x=1754782582; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8YP9JcYf4nGEn4oQobQeHHEIsb6i/+ENAm1xO75l8c8=; b=hhk0urn+lP0ynU2cFxgA17aRCgAP/TtpUYWaeneu9HL4bz7AgTiVWZ2Pbs0ZaZznL/ l6xRKr7xK/rSWRNTrNvcxVYKlOTJf4cUq363WQeLXza4x/ZlMpx1lOyfpHfW1G/0YKZD 4XZVKAQrK1/q2pgupyGIzXQRQ3i8UeidMi6w7IaiaIj1VYXlDfZdyd9Cg6Pevnj1SyQM bflpx6B5OapqRrkqlKEA1kCxDIKDkkPgaaAvq/8m87fzgwdjnRZ/em53idmz0RBCWjCQ h2zNSguTTIshBZHuOr9u/bUJ3ZYJZzOibv1/DNAIY7l1DbhcODny4eg4RooDetTuS6cX iTUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177782; x=1754782582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8YP9JcYf4nGEn4oQobQeHHEIsb6i/+ENAm1xO75l8c8=; b=c6XNuollH/wGign0uuxPZjk3XwU8ikDIvdkRfYMGQ8GwyHd1fVaINmV1uMLsb+B5oj eqD735pGDPUJ5y/wIwB2SvPeHimhWpxXSOAKSOGTdRdFrDSPvwM7OBydjsITQej43hah myMN7A1asm3zwaCitT9tpk349x7Rbe2ztcWWNVD0op5XMEoNjzt6b/FetR+iikT5iFx4 UBAQxovDyRSAbqbgK1OHLKvHGaV3+b2EOnwPc1zLFjxXSt7ZY4hd9XyfQmCami3B5oI3 9KcMqeCgQ5iSp770XGe7XWSLnd8mPps2dI0V49Zd9qnjnw2+Ou0wq8MtBpMKhfVaRaFD Ey9A== X-Gm-Message-State: AOJu0YyQjtYnD1pnO52dxbVc67jvMutgcX624sKUmq1/OewvCeX3AfvH z8C8Jc+lcky1oKzAbBuih2QOHG0gLl3SIeHop86Qy4FXOx9+6RR5yVr+uuKjxx6dervHPlWZ4bO dAPwcdlA= X-Gm-Gg: ASbGncvuoeRiC5ABEtYwW0JATorGDMcTZz0mTVdnlx1rVYTB4ObaNyUaUmOPlGw6njh v1fissrRXtJ5bvehpCo0CfmGXbcvS+pg8FtmQNK2uRb3PcBmeKXq6JU8yuxjWKOmc9sMZJiypFs XYbg8R8NqbZa1LqYUWosjutrt07GcBnBjJA/OhpEa8FLxrVyyC6Txd9tdsg2WEbymYv/drl2/v7 W/1X7eSHPqAdutKTvENxPsF54mcpN9moOzdNBa5Md/XSQdWB2+d0qqAcO5fwfAHGNmZtnggeSuq 4WkikGh6XnOLOQkFclXVucMtIGclpRFn8M9cyvS+KZTXOXDwE8AGi+HEjUadqkvIAlWA5U6+3CF 3xfdDjcIk8MdxuzzkwYEPQJqCmaDMUmMNv+qkjGuwFe0zMJ07GS/a X-Google-Smtp-Source: AGHT+IEOx2n/IRBEkjcjuum2Xwgas/fTk5h345aZBSxQxrYHWzY3VSZ2PKgawbSawrCbV39En+T9pA== X-Received: by 2002:a05:6808:5092:b0:40b:3390:397a with SMTP id 5614622812f47-433f0216500mr2999396b6e.7.1754177782224; Sat, 02 Aug 2025 16:36:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 41/85] target/arm: Convert arm_mmu_idx_is_stage1_of_2 from switch to table Date: Sun, 3 Aug 2025 09:29:09 +1000 Message-ID: <20250802232953.413294-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178475031116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 19 ------------------- target/arm/mmuidx-internal.h | 8 ++++++++ target/arm/mmuidx.c | 7 ++++--- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index c6f3ae470b..4f99ec69f8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1282,25 +1282,6 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx); ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); #endif =20 -/** - * arm_mmu_idx_is_stage1_of_2: - * @mmu_idx: The ARMMMUIdx to test - * - * Return true if @mmu_idx is a NOTLB mmu_idx that is the - * first stage of a two stage regime. - */ -static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_Stage1_E1: - case ARMMMUIdx_Stage1_E1_PAN: - return true; - default: - return false; - } -} - static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, const ARMISARegisters *id) { diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index 3e51c0f579..55fba4aae2 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -18,6 +18,7 @@ FIELD(MMUIDXINFO, RELVALID, 5, 1) FIELD(MMUIDXINFO, 2RANGES, 6, 1) FIELD(MMUIDXINFO, PAN, 7, 1) FIELD(MMUIDXINFO, USER, 8, 1) +FIELD(MMUIDXINFO, STAGE1, 9, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -76,4 +77,11 @@ static inline bool regime_is_user(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, USER); } =20 +/* Return true if this mmu index is stage 1 of a 2-stage translation. */ +static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, STAGE1); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index 1c1e062bfe..c5b43a5932 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -13,6 +13,7 @@ #define R2 R_MMUIDXINFO_2RANGES_MASK #define PAN R_MMUIDXINFO_PAN_MASK #define USER R_MMUIDXINFO_USER_MASK +#define S1 R_MMUIDXINFO_STAGE1_MASK =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* @@ -35,9 +36,9 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { [ARMMMUIdx_Stage2_S] =3D REL(2), [ARMMMUIdx_Stage2] =3D REL(2), =20 - [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | USER, - [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2, - [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | PAN, + [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | S1 | USER, + [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2 | S1, + [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | S1 | PAN, =20 /* * M-profile. --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179599; cv=none; d=zohomail.com; s=zohoarc; b=eh5hA7B7STE5Udel2PXjW66cLsp67iMysG+kV+fw4Y502ODOSTTby7N8JtvNLm3YpS4jPCsNAdXI4d3W5rFJqb9+JPg9miG5KQuJLjK3WAqzofBnIZSp7I/aX1yBQuRyQkYrHnPFWJc6QKyPLkzRhI11uDv6wP1JeoDE2FfdmCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179599; 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=YxHv4sVJA2ofapZZSOKB+oPZfBz6mz5HrOhjLCHq2Dk=; b=nQDM5/0tReEiuMx5Q24QkaierTt+ERn+Ey6MYP2Yn6ydkwkcVp95ASosZW1m20u+omilgYcNAQhR6C5mjVDzQcZKPh43Gv90kk999jVKrmqhIeyiamOwTpXNaIkuD/GoRFFhouQnIap1hBZEUBAa5GQYZefjeJ5TpihkTLY07H8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179598994305.1257294281311; Sat, 2 Aug 2025 17:06:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLor-0006qV-8q; Sat, 02 Aug 2025 19:39:19 -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 1uiLmA-0002ri-M7 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:34 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLm7-0005iZ-Vm for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:30 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-741ae696663so92897a34.0 for ; Sat, 02 Aug 2025 16:36:27 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177787; x=1754782587; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YxHv4sVJA2ofapZZSOKB+oPZfBz6mz5HrOhjLCHq2Dk=; b=OU+X0TPRaRF4IzRhy4JGwpYtZf9TH3ll1da/JT8q1WFqmZfFcTTdyFpDYVCq2ur6NS a7GIQU9dtFdWqb3V9Jg/FjgYrpBZsEYbuvaAX3CNBwdhiIaLhcHZ5hD4RsvujGutBgGN oLYnuOkskN2mHlzuJ4WEun1NOUGuqkfU+lXux9lXt8bxUlmNDe6rrr8cP0vKyiH+JWoD aVt9QY4Cy3OMQ6WSaDLqsDZOBPgkNtl3367t5oNGorsOUsgDxvHNxbKJsGO0WutjhsBR TusZ9GtKTZ8oKdaJGWLV/GFK/iofzx4fQUmmaQw8uQIqglsRFnKSSlsztN/gKrQFp5uB 8CEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177787; x=1754782587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YxHv4sVJA2ofapZZSOKB+oPZfBz6mz5HrOhjLCHq2Dk=; b=diBSoN3+nm5GyrA0nH/LpxsGcdwLGRxIUj2neyy5ZdMpO44vWJZ+mFdgT2vko6KM0/ cLJR9nbKKMLWmfURIGYUdPlEw99Dx3yAZX+z++L8as5aggOURDx7fIB4NS4eLiW4DNKy 5TothzKkuZ87AqEHq6l7aSUgcq3aBV+r/pczXoSbTYWbehgFL+C+H83MJFip2tm7D90v isEGV4U/h7G8Old5yLUdukqHWHgDYycJMC0mFTjD/e/MykSLhUbiMc59bw5dmK8pPVUX VhbNihT6mmsTGlGNdtX4T12Ic5qknTeQC5MKqMAXtCCcX6OFw0gzVkhQAoOZNPNuy8+k tFtQ== X-Gm-Message-State: AOJu0YyUADEWe77FELkYJhKDjBw/DOzDZPpQAMBkhT0NQXfEewq/IjWv HZ2g4KJAM7Q6HqggzpJh/LLTg2hsPVeWTo/hHi7+G/wL/y2gs4uHuELArf7xxLFCglahhgi/0YB LBoo2QwI= X-Gm-Gg: ASbGncvCyVSijU/21a9F2H//KJSapdjtTPv9+N1rGDTKGRxpzNfHtiP44Pp3YEeYGiw JnAqMgSGwnhkS5r7jCbo9ixCfjAhE+vB8PdD7P9L3nj2Fjm5uGy9acYuwqAxd9mdRun3w2Ys1g/ hfC//3dpe+QO4qws2TrTEn/wd01AnFQWXFxxnTVHQamUAA5qjO1zUhL2D33e8opR1lSIfV4QLjU rKoHb8uhpdZ0sSyC7TBHGCJEDN/ZdG/z9/D4U9Mc76783vXMmJZRNYYay8lXnN9i7/GX3MLh82r 5V4flBW3NO5LMxfeJPf7iCPAsp2cYyjhikSAlVjnONDmHIeLjHJRhyf8YMewR+VxYpj76yv/t7F B1IM9NcydVdZd9mfsHnoz4ViVjmcNglG5x6cOMKXvro6WIvZQmAJ1 X-Google-Smtp-Source: AGHT+IEowArKYJkLYQrzgta2QLOSAHklVrAs5fz7ZJnOhjNNduf4UbSlSUqz1OEP6Or29GwGcopEFA== X-Received: by 2002:a05:6830:440c:b0:741:b12d:9837 with SMTP id 46e09a7af769-741b12db2aamr258588a34.22.1754177786832; Sat, 02 Aug 2025 16:36:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 42/85] target/arm: Convert regime_is_stage2 to table Date: Sun, 3 Aug 2025 09:29:10 +1000 Message-ID: <20250802232953.413294-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179600612124100 Content-Type: text/plain; charset="utf-8" This wasn't using a switch, but two comparisons. Convert it to arm_mmuidx_table for consistency. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 5 ----- target/arm/mmuidx-internal.h | 8 ++++++++ target/arm/mmuidx.c | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 4f99ec69f8..805f4a1876 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1029,11 +1029,6 @@ static inline void arm_call_el_change_hook(ARMCPU *c= pu) } } =20 -static inline bool regime_is_stage2(ARMMMUIdx mmu_idx) -{ - return mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Sta= ge2_S; -} - /* Return the SCTLR value which controls this address translation regime */ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index 55fba4aae2..1d948aa6f4 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -19,6 +19,7 @@ FIELD(MMUIDXINFO, 2RANGES, 6, 1) FIELD(MMUIDXINFO, PAN, 7, 1) FIELD(MMUIDXINFO, USER, 8, 1) FIELD(MMUIDXINFO, STAGE1, 9, 1) +FIELD(MMUIDXINFO, STAGE2, 10, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -84,4 +85,11 @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx = idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, STAGE1); } =20 +/* Return true if this mmu index is stage 2 of a 2-stage translation. */ +static inline bool regime_is_stage2(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, STAGE2); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index c5b43a5932..61a682e655 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -14,6 +14,7 @@ #define PAN R_MMUIDXINFO_PAN_MASK #define USER R_MMUIDXINFO_USER_MASK #define S1 R_MMUIDXINFO_STAGE1_MASK +#define S2 R_MMUIDXINFO_STAGE2_MASK =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* @@ -33,8 +34,8 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { [ARMMMUIdx_E30_0] =3D EL(0) | REL(3), [ARMMMUIdx_E30_3_PAN] =3D EL(3) | REL(3) | PAN, =20 - [ARMMMUIdx_Stage2_S] =3D REL(2), - [ARMMMUIdx_Stage2] =3D REL(2), + [ARMMMUIdx_Stage2_S] =3D REL(2) | S2, + [ARMMMUIdx_Stage2] =3D REL(2) | S2, =20 [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | S1 | USER, [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2 | S1, --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179142; cv=none; d=zohomail.com; s=zohoarc; b=J07BSO8eOwfuzLcMZTfQStw8Jrbqln0upvYFuEVbhJ2Gym07j0EWszW/S6bJrnuqYXp+YKbG06i4kvf+8AhFGJLmPJ6G+khhhJf/cHeAc940UGIgkMzPuJCn26bFUuKjqmcxSQwbsG4T+dMNdCfnyl7vY++PaJGviIwd+TsqM80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179142; 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=Dr8oS8tkl1LvOnsjGxd0cm7bLVu4DfNtjNz/a086H1k=; b=jfntC42OXVwUGrHwjkUrv0jl98kAZLykHfLtHyZHQzVZybZUeLUl63O3CNGLOl+0xZZHni9F/OlpUU7ueaRlLyYXbrWKLpoBGSAP7sJfhuL4Awmnqqbe6sg5Rb83GxcfgpH/aeg5SrmXCt5OL/sKa+J1RgX2yk4/0ci4MGmEqKo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179142385384.2383555508454; Sat, 2 Aug 2025 16:59:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLoj-0006GR-DF; Sat, 02 Aug 2025 19:39:09 -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 1uiLmG-0002uq-Dy for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:38 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmD-0005jB-1a for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:35 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-741a254d4a0so894985a34.1 for ; Sat, 02 Aug 2025 16:36:32 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177792; x=1754782592; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dr8oS8tkl1LvOnsjGxd0cm7bLVu4DfNtjNz/a086H1k=; b=RIMy/id+VQVodSFgsqc5l+8IDjT8Xhhggg5IwH8dAqxQZOl4UnZEMpTp9NztYTyXZ8 omc+1VD+AF9aH1k1vP6AVzXlXLRB0M2sS0co0xOk1W5zWk//74WEbe137Oge98U8ObKB 2q7srl6kkyzNVExX1UdF/ApfhrpXiX1NpKlf0MOOCvzgPuubB1bM67bp8VZ5OKWU/S6L jY4iPlOHq2E2AYApPbm/7zLAGv9UZAOU3sClWGEpdzpokx9E+XSeX1L1/ZpkhdghDhBP pUTctoQepBMHXBqaOezWq00YxHqaShsWYtEHwifx5b7yGODuYtSgz4/Ndc7iikmD3Dnb Kx0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177792; x=1754782592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dr8oS8tkl1LvOnsjGxd0cm7bLVu4DfNtjNz/a086H1k=; b=YazlNfa2nCuSBz0OQdQCOYzM+Q0iGpk52ECeTOLvBxbjd/bSsoCK6kyOIkeWq43ins X16iaoy9wgWfgOzlQOII0GWtron0/hBETAMH4KshCaAVPN3ksMOCARVtNavfozspxM98 EcciJMA8B+b72GiaWujsREf5iN2qb7wEXAvf9s2UMFf46ZLMYP0gb/SlPGB3S4eJqzFF nSsQPi8k0rMelPN3qII/tmHPYMEipnw3Yvbfo9MWwRr1F/hEk3jaZc9TdWYC6MBwNzCE WFd0w9iw4h3oCbfl+gpMQ1lcainsos4B/VN/Am5vGUMYyLjlDD2lTRoEirE53+PYOrKW qEPA== X-Gm-Message-State: AOJu0YzzyfGTocp6Ho5rHpqtSguMTcqAzjRp7X6WxeAr1yd4RB7c3UAy itJH0fieBwAwhnEPIO7mOAHYMU9MNVNBENUj/G992Fn2/5EfmOZcedeZKDF7YGFk2bX/tNTdEWm qKU9hCaw= X-Gm-Gg: ASbGnctvD6dUl7RBcv12+d293wxLGcJNqSaKpk8WzjIAkgzRLiWjJjV756+gxK8fTgf iiOKg6PkeBZhXan/fast+eLP8MZWeGfdF9D9CxxJmAuts4K3nKLc+Zg7X6G19aLj2yKlVne6KRq 6741ZIJc7p4Xn1F470AUSzA3D9/ciS3lTfBgBa73NQkkTcq5ZmiH929ibr3pWmyn7E51Yg6V/41 Me1LEeaxDrc1AEf6kkOa4lsXgvQKo1mEIs6foYendHh7FFAHTpILyMd/skOIvtYh/GZS8OmqxMX 4d4gzY2oyQ5oOR8VndVRGUyX2uUtFUD+hHYCnslYoArYQvU8qocM2WL0e5PdC60q+izmyhrSWKE RZEq2hdurtteGFRBcnxE5p+Rwib8fMVRy8aPh6HlhhkGqzEKulJPo X-Google-Smtp-Source: AGHT+IHHWKq+Xy/mLASoiLng6kSghl5Ot8X5vo+6Lewk/zJBM2NUZfQ8VDDsCUoIor2Sl9hjMSgZTw== X-Received: by 2002:a05:6830:d1a:b0:73c:e9dd:cc1e with SMTP id 46e09a7af769-7419c5cb98fmr3039084a34.1.1754177791708; Sat, 02 Aug 2025 16:36:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 43/85] target/arm: Introduce mmu indexes for GCS Date: Sun, 3 Aug 2025 09:29:11 +1000 Message-ID: <20250802232953.413294-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179143149116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 5 ++- target/arm/mmuidx-internal.h | 8 ++++ target/arm/mmuidx.h | 71 ++++++++++++++++++++++++------------ target/arm/helper.c | 15 ++++++-- target/arm/mmuidx.c | 9 +++++ target/arm/ptw.c | 20 ++++++++++ target/arm/tcg/tlb-insns.c | 47 ++++++++++++++++-------- 7 files changed, 132 insertions(+), 43 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fc9a2291d5..671c4bc6bb 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -198,9 +198,10 @@ struct CPUClass { }; =20 /* - * Fix the number of mmu modes to 16. + * Fix the number of mmu modes across all targets. + * Current maximum is target/arm/. */ -#define NB_MMU_MODES 16 +#define NB_MMU_MODES 22 typedef uint32_t MMUIdxMap; =20 /* Use a fully associative victim tlb of 8 entries. */ diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index 1d948aa6f4..f494ec348d 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -20,6 +20,7 @@ FIELD(MMUIDXINFO, PAN, 7, 1) FIELD(MMUIDXINFO, USER, 8, 1) FIELD(MMUIDXINFO, STAGE1, 9, 1) FIELD(MMUIDXINFO, STAGE2, 10, 1) +FIELD(MMUIDXINFO, GCS, 11, 1) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -92,4 +93,11 @@ static inline bool regime_is_stage2(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, STAGE2); } =20 +/* Return true if this mmu index implies AccessType_GCS. */ +static inline bool regime_is_gcs(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, GCS); +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.h b/target/arm/mmuidx.h index 5b9b4bc84f..8d8d27337e 100644 --- a/target/arm/mmuidx.h +++ b/target/arm/mmuidx.h @@ -58,24 +58,31 @@ * already heavyweight. * 8. we cannot fold together Stage 2 Secure and Stage 2 NonSecure, * because both are in use simultaneously for Secure EL2. + * 9. we need separate indexes for handling AccessType_GCS. * * This gives us the following list of cases: * * EL0 EL1&0 stage 1+2 (aka NS PL0 PL1&0 stage 1+2) + * EL0 EL1&0 stage 1+2 +GCS * EL1 EL1&0 stage 1+2 (aka NS PL1 PL1&0 stage 1+2) * EL1 EL1&0 stage 1+2 +PAN (aka NS PL1 P1&0 stage 1+2 +PAN) + * EL1 EL1&0 stage 1+2 +GCS * EL0 EL2&0 + * EL0 EL2&0 +GCS * EL2 EL2&0 * EL2 EL2&0 +PAN + * EL2 EL2&0 +GCS * EL2 (aka NS PL2) + * EL2 +GCS * EL3 (aka AArch32 S PL1 PL1&0) + * EL3 +GCS * AArch32 S PL0 PL1&0 (we call this EL30_0) * AArch32 S PL1 PL1&0 +PAN (we call this EL30_3_PAN) * Stage2 Secure * Stage2 NonSecure * plus one TLB per Physical address space: S, NS, Realm, Root * - * for a total of 16 different mmu_idx. + * for a total of 22 different mmu_idx. * * R profile CPUs have an MPU, but can use the same set of MMU indexes * as A profile. They only need to distinguish EL0 and EL1 (and @@ -114,9 +121,9 @@ * For M profile we arrange them to have a bit for priv, a bit for negpri * and a bit for secure. */ -#define ARM_MMU_IDX_A 0x10 /* A profile */ -#define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */ -#define ARM_MMU_IDX_M 0x40 /* M profile */ +#define ARM_MMU_IDX_A 0x20 /* A profile */ +#define ARM_MMU_IDX_NOTLB 0x40 /* does not have a TLB */ +#define ARM_MMU_IDX_M 0x80 /* M profile */ =20 /* Meanings of the bits for M profile mmu idx values */ #define ARM_MMU_IDX_M_PRIV 0x1 @@ -125,22 +132,32 @@ =20 #define ARM_MMU_IDX_TYPE_MASK \ (ARM_MMU_IDX_A | ARM_MMU_IDX_M | ARM_MMU_IDX_NOTLB) -#define ARM_MMU_IDX_COREIDX_MASK 0xf +#define ARM_MMU_IDX_COREIDX_MASK 0x1f =20 typedef enum ARMMMUIdx { /* * A-profile. */ - ARMMMUIdx_E10_0 =3D 0 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_0 =3D 1 | ARM_MMU_IDX_A, - ARMMMUIdx_E10_1 =3D 2 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_2 =3D 3 | ARM_MMU_IDX_A, - ARMMMUIdx_E10_1_PAN =3D 4 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_2_PAN =3D 5 | ARM_MMU_IDX_A, - ARMMMUIdx_E2 =3D 6 | ARM_MMU_IDX_A, - ARMMMUIdx_E3 =3D 7 | ARM_MMU_IDX_A, - ARMMMUIdx_E30_0 =3D 8 | ARM_MMU_IDX_A, - ARMMMUIdx_E30_3_PAN =3D 9 | ARM_MMU_IDX_A, + + ARMMMUIdx_E10_0 =3D 0 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_0_GCS =3D 1 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1 =3D 2 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1_PAN =3D 3 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1_GCS =3D 4 | ARM_MMU_IDX_A, + + ARMMMUIdx_E20_0 =3D 5 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_0_GCS =3D 6 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2 =3D 7 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2_PAN =3D 8 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2_GCS =3D 9 | ARM_MMU_IDX_A, + + ARMMMUIdx_E2 =3D 10 | ARM_MMU_IDX_A, + ARMMMUIdx_E2_GCS =3D 11 | ARM_MMU_IDX_A, + + ARMMMUIdx_E3 =3D 12 | ARM_MMU_IDX_A, + ARMMMUIdx_E3_GCS =3D 13 | ARM_MMU_IDX_A, + ARMMMUIdx_E30_0 =3D 14 | ARM_MMU_IDX_A, + ARMMMUIdx_E30_3_PAN =3D 15 | ARM_MMU_IDX_A, =20 /* * Used for second stage of an S12 page table walk, or for descriptor @@ -148,14 +165,14 @@ typedef enum ARMMMUIdx { * are in use simultaneously for SecureEL2: the security state for * the S2 ptw is selected by the NS bit from the S1 ptw. */ - ARMMMUIdx_Stage2_S =3D 10 | ARM_MMU_IDX_A, - ARMMMUIdx_Stage2 =3D 11 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2_S =3D 16 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2 =3D 17 | ARM_MMU_IDX_A, =20 /* TLBs with 1-1 mapping to the physical address spaces. */ - ARMMMUIdx_Phys_S =3D 12 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_NS =3D 13 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_Root =3D 14 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_Realm =3D 15 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_S =3D 18 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_NS =3D 19 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Root =3D 20 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Realm =3D 21 | ARM_MMU_IDX_A, =20 /* * These are not allocated TLBs and are used only for AT system @@ -164,6 +181,8 @@ typedef enum ARMMMUIdx { ARMMMUIdx_Stage1_E0 =3D 0 | ARM_MMU_IDX_NOTLB, ARMMMUIdx_Stage1_E1 =3D 1 | ARM_MMU_IDX_NOTLB, ARMMMUIdx_Stage1_E1_PAN =3D 2 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E0_GCS =3D 3 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1_GCS =3D 4 | ARM_MMU_IDX_NOTLB, =20 /* * M-profile. @@ -187,13 +206,19 @@ typedef enum ARMMMUIdx { =20 typedef enum ARMMMUIdxBit { TO_CORE_BIT(E10_0), - TO_CORE_BIT(E20_0), + TO_CORE_BIT(E10_0_GCS), TO_CORE_BIT(E10_1), TO_CORE_BIT(E10_1_PAN), - TO_CORE_BIT(E2), + TO_CORE_BIT(E10_1_GCS), + TO_CORE_BIT(E20_0), + TO_CORE_BIT(E20_0_GCS), TO_CORE_BIT(E20_2), TO_CORE_BIT(E20_2_PAN), + TO_CORE_BIT(E20_2_GCS), + TO_CORE_BIT(E2), + TO_CORE_BIT(E2_GCS), TO_CORE_BIT(E3), + TO_CORE_BIT(E3_GCS), TO_CORE_BIT(E30_0), TO_CORE_BIT(E30_3_PAN), TO_CORE_BIT(Stage2), diff --git a/target/arm/helper.c b/target/arm/helper.c index 090076af24..1b21ae5d8e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -401,7 +401,9 @@ int alle1_tlbmask(CPUARMState *env) */ return (ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_1_PAN | + ARMMMUIdxBit_E10_1_GCS | ARMMMUIdxBit_E10_0 | + ARMMMUIdxBit_E10_0_GCS | ARMMMUIdxBit_Stage2 | ARMMMUIdxBit_Stage2_S); } @@ -788,12 +790,17 @@ static void scr_write(CPUARMState *env, const ARMCPRe= gInfo *ri, uint64_t value) */ if (changed & (SCR_NS | SCR_NSE)) { tlb_flush_by_mmuidx(env_cpu(env), (ARMMMUIdxBit_E10_0 | + ARMMMUIdxBit_E10_0_GCS | ARMMMUIdxBit_E20_0 | + ARMMMUIdxBit_E20_0_GCS | ARMMMUIdxBit_E10_1 | - ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E10_1_PAN | + ARMMMUIdxBit_E10_1_GCS | + ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_2_PAN | - ARMMMUIdxBit_E2)); + ARMMMUIdxBit_E20_2_GCS | + ARMMMUIdxBit_E2 | + ARMMMUIdxBit_E2_GCS)); } } =20 @@ -2759,7 +2766,9 @@ static void vmsa_tcr_ttbr_el2_write(CPUARMState *env,= const ARMCPRegInfo *ri, (arm_hcr_el2_eff(env) & HCR_E2H)) { uint16_t mask =3D ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_2_PAN | - ARMMMUIdxBit_E20_0; + ARMMMUIdxBit_E20_2_GCS | + ARMMMUIdxBit_E20_0 | + ARMMMUIdxBit_E20_0_GCS; tlb_flush_by_mmuidx(env_cpu(env), mask); } raw_write(env, ri, value); diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index 61a682e655..42b003db9c 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -15,22 +15,29 @@ #define USER R_MMUIDXINFO_USER_MASK #define S1 R_MMUIDXINFO_STAGE1_MASK #define S2 R_MMUIDXINFO_STAGE2_MASK +#define GCS R_MMUIDXINFO_GCS_MASK =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* * A-profile. */ [ARMMMUIdx_E10_0] =3D EL(0) | REL(1) | R2, + [ARMMMUIdx_E10_0_GCS] =3D EL(0) | REL(1) | R2 | GCS, [ARMMMUIdx_E10_1] =3D EL(1) | REL(1) | R2, [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1) | R2 | PAN, + [ARMMMUIdx_E10_1_GCS] =3D EL(1) | REL(1) | R2 | GCS, =20 [ARMMMUIdx_E20_0] =3D EL(0) | REL(2) | R2, + [ARMMMUIdx_E20_0_GCS] =3D EL(0) | REL(2) | R2 | GCS, [ARMMMUIdx_E20_2] =3D EL(2) | REL(2) | R2, [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2) | R2 | PAN, + [ARMMMUIdx_E20_2_GCS] =3D EL(2) | REL(2) | R2 | GCS, =20 [ARMMMUIdx_E2] =3D EL(2) | REL(2), + [ARMMMUIdx_E2_GCS] =3D EL(2) | REL(2) | GCS, =20 [ARMMMUIdx_E3] =3D EL(3) | REL(3), + [ARMMMUIdx_E3_GCS] =3D EL(3) | REL(3) | GCS, [ARMMMUIdx_E30_0] =3D EL(0) | REL(3), [ARMMMUIdx_E30_3_PAN] =3D EL(3) | REL(3) | PAN, =20 @@ -38,8 +45,10 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { [ARMMMUIdx_Stage2] =3D REL(2) | S2, =20 [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | S1 | USER, + [ARMMMUIdx_Stage1_E0_GCS] =3D REL(1) | R2 | S1 | USER | GCS, [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2 | S1, [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | S1 | PAN, + [ARMMMUIdx_Stage1_E1_GCS] =3D REL(1) | R2 | S1 | GCS, =20 /* * M-profile. diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 493ec78c1a..ee887d9a02 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -166,6 +166,10 @@ ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) return ARMMMUIdx_Stage1_E1; case ARMMMUIdx_E10_1_PAN: return ARMMMUIdx_Stage1_E1_PAN; + case ARMMMUIdx_E10_0_GCS: + return ARMMMUIdx_Stage1_E0_GCS; + case ARMMMUIdx_E10_1_GCS: + return ARMMMUIdx_Stage1_E1_GCS; default: return mmu_idx; } @@ -273,8 +277,10 @@ static bool regime_translation_disabled(CPUARMState *e= nv, ARMMMUIdx mmu_idx, return (hcr_el2 & (HCR_DC | HCR_VM)) =3D=3D 0; =20 case ARMMMUIdx_E10_0: + case ARMMMUIdx_E10_0_GCS: case ARMMMUIdx_E10_1: case ARMMMUIdx_E10_1_PAN: + case ARMMMUIdx_E10_1_GCS: /* TGE means that EL0/1 act as if SCTLR_EL1.M is zero */ hcr_el2 =3D arm_hcr_el2_eff_secstate(env, space); if (hcr_el2 & HCR_TGE) { @@ -283,8 +289,10 @@ static bool regime_translation_disabled(CPUARMState *e= nv, ARMMMUIdx mmu_idx, break; =20 case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E0_GCS: case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_Stage1_E1_PAN: + case ARMMMUIdx_Stage1_E1_GCS: /* HCR.DC means SCTLR_EL1.M behaves as 0 */ hcr_el2 =3D arm_hcr_el2_eff_secstate(env, space); if (hcr_el2 & HCR_DC) { @@ -293,10 +301,14 @@ static bool regime_translation_disabled(CPUARMState *= env, ARMMMUIdx mmu_idx, break; =20 case ARMMMUIdx_E20_0: + case ARMMMUIdx_E20_0_GCS: case ARMMMUIdx_E20_2: case ARMMMUIdx_E20_2_PAN: + case ARMMMUIdx_E20_2_GCS: case ARMMMUIdx_E2: + case ARMMMUIdx_E2_GCS: case ARMMMUIdx_E3: + case ARMMMUIdx_E3_GCS: case ARMMMUIdx_E30_0: case ARMMMUIdx_E30_3_PAN: break; @@ -3761,15 +3773,22 @@ arm_mmu_idx_to_security_space(CPUARMState *env, ARM= MMUIdx mmu_idx) =20 switch (mmu_idx) { case ARMMMUIdx_E10_0: + case ARMMMUIdx_E10_0_GCS: case ARMMMUIdx_E10_1: case ARMMMUIdx_E10_1_PAN: + case ARMMMUIdx_E10_1_GCS: case ARMMMUIdx_E20_0: + case ARMMMUIdx_E20_0_GCS: case ARMMMUIdx_E20_2: case ARMMMUIdx_E20_2_PAN: + case ARMMMUIdx_E20_2_GCS: case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E0_GCS: case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_Stage1_E1_PAN: + case ARMMMUIdx_Stage1_E1_GCS: case ARMMMUIdx_E2: + case ARMMMUIdx_E2_GCS: ss =3D arm_security_space_below_el3(env); break; case ARMMMUIdx_Stage2: @@ -3798,6 +3817,7 @@ arm_mmu_idx_to_security_space(CPUARMState *env, ARMMM= UIdx mmu_idx) ss =3D ARMSS_Secure; break; case ARMMMUIdx_E3: + case ARMMMUIdx_E3_GCS: case ARMMMUIdx_E30_0: case ARMMMUIdx_E30_3_PAN: if (arm_feature(env, ARM_FEATURE_AARCH64) && diff --git a/target/arm/tcg/tlb-insns.c b/target/arm/tcg/tlb-insns.c index 95c26c6d46..1a0a332583 100644 --- a/target/arm/tcg/tlb-insns.c +++ b/target/arm/tcg/tlb-insns.c @@ -149,7 +149,8 @@ static void tlbimva_hyp_write(CPUARMState *env, const A= RMCPRegInfo *ri, CPUState *cs =3D env_cpu(env); uint64_t pageaddr =3D value & ~MAKE_64BIT_MASK(0, 12); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, + ARMMMUIdxBit_E2 | ARMMMUIdxBit_E2_GCS); } =20 static void tlbimva_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -159,7 +160,8 @@ static void tlbimva_hyp_is_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, uint64_t pageaddr =3D value & ~MAKE_64BIT_MASK(0, 12); =20 tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_E2); + ARMMMUIdxBit_E2 | + ARMMMUIdxBit_E2_GCS); } =20 static void tlbiipas2_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -202,7 +204,7 @@ static void tlbiall_hyp_write(CPUARMState *env, const A= RMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); =20 - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2 | ARMMMUIdxBit_E2_GCS); } =20 static void tlbiall_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -210,7 +212,8 @@ static void tlbiall_hyp_is_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); =20 - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2 | + ARMMMUIdxBit_E2_GCS); } =20 /* @@ -228,12 +231,16 @@ static int vae1_tlbmask(CPUARMState *env) if ((hcr & (HCR_E2H | HCR_TGE)) =3D=3D (HCR_E2H | HCR_TGE)) { mask =3D ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_2_PAN | - ARMMMUIdxBit_E20_0; + ARMMMUIdxBit_E20_2_GCS | + ARMMMUIdxBit_E20_0 | + ARMMMUIdxBit_E20_0_GCS; } else { /* This is AArch64 only, so we don't need to touch the EL30_x TLBs= */ mask =3D ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_1_PAN | - ARMMMUIdxBit_E10_0; + ARMMMUIdxBit_E10_1_GCS | + ARMMMUIdxBit_E10_0 | + ARMMMUIdxBit_E10_0_GCS; } return mask; } @@ -246,13 +253,20 @@ static int vae2_tlbmask(CPUARMState *env) if (hcr & HCR_E2H) { mask =3D ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_2_PAN | - ARMMMUIdxBit_E20_0; + ARMMMUIdxBit_E20_2_GCS | + ARMMMUIdxBit_E20_0 | + ARMMMUIdxBit_E20_0_GCS; } else { - mask =3D ARMMMUIdxBit_E2; + mask =3D ARMMMUIdxBit_E2 | ARMMMUIdxBit_E2_GCS; } return mask; } =20 +static int vae3_tlbmask(void) +{ + return ARMMMUIdxBit_E3 | ARMMMUIdxBit_E3_GCS; +} + /* Return 56 if TBI is enabled, 64 otherwise. */ static int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx, uint64_t addr) @@ -325,9 +339,12 @@ static void tlbi_aa64_vmalle1_write(CPUARMState *env, = const ARMCPRegInfo *ri, static int e2_tlbmask(CPUARMState *env) { return (ARMMMUIdxBit_E20_0 | + ARMMMUIdxBit_E20_0_GCS | ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_2_PAN | - ARMMMUIdxBit_E2); + ARMMMUIdxBit_E20_2_GCS | + ARMMMUIdxBit_E2 | + ARMMMUIdxBit_E2_GCS); } =20 static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -354,7 +371,7 @@ static void tlbi_aa64_alle3_write(CPUARMState *env, con= st ARMCPRegInfo *ri, ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D CPU(cpu); =20 - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E3); + tlb_flush_by_mmuidx(cs, vae3_tlbmask()); } =20 static void tlbi_aa64_alle1is_write(CPUARMState *env, const ARMCPRegInfo *= ri, @@ -380,7 +397,7 @@ static void tlbi_aa64_alle3is_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); =20 - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E3); + tlb_flush_by_mmuidx_all_cpus_synced(cs, vae3_tlbmask()); } =20 static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -411,7 +428,7 @@ static void tlbi_aa64_vae3_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, CPUState *cs =3D CPU(cpu); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); =20 - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E3); + tlb_flush_page_by_mmuidx(cs, pageaddr, vae3_tlbmask()); } =20 static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *r= i, @@ -465,7 +482,7 @@ static void tlbi_aa64_vae3is_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, int bits =3D tlbbits_for_regime(env, ARMMMUIdx_E3, pageaddr); =20 tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_E3, bits); + vae3_tlbmask(), bits); } =20 static int ipas2e1_tlbmask(CPUARMState *env, int64_t value) @@ -963,7 +980,7 @@ static void tlbi_aa64_rvae3_write(CPUARMState *env, * flush-last-level-only. */ =20 - do_rvae_write(env, value, ARMMMUIdxBit_E3, tlb_force_broadcast(env)); + do_rvae_write(env, value, vae3_tlbmask(), tlb_force_broadcast(env)); } =20 static void tlbi_aa64_rvae3is_write(CPUARMState *env, @@ -977,7 +994,7 @@ static void tlbi_aa64_rvae3is_write(CPUARMState *env, * flush-last-level-only or inner/outer specific flushes. */ =20 - do_rvae_write(env, value, ARMMMUIdxBit_E3, true); + do_rvae_write(env, value, vae3_tlbmask(), true); } =20 static void tlbi_aa64_ripas2e1_write(CPUARMState *env, const ARMCPRegInfo = *ri, --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178477; cv=none; d=zohomail.com; s=zohoarc; b=Qfa67SI7YnSona7k3KmeRHMK9/VBaEZTOhWmLjb0nsV3IVsbdf7heXSuM1mKyka5TPOEffOVWDylmfAyBFayEqbKCXv4w9vWptlS9cO9gjsCPlrZAHxRB+bFKU4bnRNH8JUzDF0LI95QPfjXYi3JZsnaaDWwxOyJiaOFm4XUSSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178477; 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=cr6Y93u/SVkcU+goxAfQSNSlnm3F8dUSxwzHBpcNsX8=; b=V2FGn80IIxq+5YvbekmGjhqWReeDmIfnP5ZkZoBosUuJ1BFGq3L61gNzW3p7rqcfsEKCwt+F8vGN6lnUQkj/7hScGJbg7aI3RiAokPEGKM5TGA8avUh/ded3riiwApVaGIarwBZyhNn6+lWagayOI5gVAKPantMqaY+SK87uidM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178477664560.036714646657; Sat, 2 Aug 2025 16:47:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLo9-0005hj-FV; Sat, 02 Aug 2025 19:38:33 -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 1uiLmI-0002wX-Nx for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:41 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmH-0005jc-83 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:38 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-741ab3e03aeso295443a34.2 for ; Sat, 02 Aug 2025 16:36:36 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177796; x=1754782596; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cr6Y93u/SVkcU+goxAfQSNSlnm3F8dUSxwzHBpcNsX8=; b=MUeOcpDuQxYyOPe3Obva67eDahrbz11tUXGeoj0TRBDoKCM4A4gHEfPgNNp7nUmssT i06XbqqbM4xJ1RgaIV1l+yWv5oqIKjiG81T+2xRa4BvtZ+XYFRGC0YuGzojdQdu7ijoV KpZoT0FxcK7X8G/m9NvO5pFfkFb7DcFD4ce4ATsX0fUHyg3RsCNURwOO9ISEZbZIUa5A dJEntHLre/ueRANLWIWYwsFnvod/7fXiljsgptxL/TDVqXcWU5Prollkj0B8+emQeAE0 gBp7yox9VDgqpwvtaeK2UCvkJpXqT4X1UbPv3Z9xTu0mpXeaUa3MUo4Zk391+y2r87MG 2i1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177796; x=1754782596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cr6Y93u/SVkcU+goxAfQSNSlnm3F8dUSxwzHBpcNsX8=; b=SiA2LKcTRzd9uiaj/npcLeIruwDFpXzV4CYo8pRU4QTrR1H5FZ/dfVcA/ka5PU8aGq VohbkIb8MGiwIEL7xByieR+6KQgSCtqkApONOWOk/POlfNy0GQyBSFhl0jUFWYVpB+cV 0VwLANyZMg2ogXtmy5X1+JHC5QP6Qhy58qn90m3vzSoVFCnkAQk67Cbln78ICPaKnzl9 IK85FNU53+MP2HWWWcX/+cgWzrGSMcSvgXIZweYwosLwfXyu8tqKk0K5NvUTuooKAg0h M+0oJyUxMxhxrbKYfmEdDkAJOixSNbTpKVxg6sf5mhgdAuCM0eU0PyK2eWbpll1Yiio7 IGDw== X-Gm-Message-State: AOJu0YxjG/IR3CwTk6rnxumvxsKtp5injnNspWTyRETVFS+AEL1vpquK knVXFR/8EsVWwUYOAgRwRhWWfrZTX5l0ptrCP4v+tzHyEjluf8soGu3rBH7xwgZJs7CGGy1f6N6 Dl4gMFDw= X-Gm-Gg: ASbGncvAXqwrZ1uKkiy3SqlTHhYFPKk7jCQY3dFw8KsdC1PZ6v8rHFNV83gEZhW7ksI sFMvKbanc0XDgvzoKhad7+FAX0tE0OMQjZw8rMoPzJJcECHLU1RNZ+u06AfgJ7+SlwrEeAa6TpS K+U9S0t2TE7DY8BkaVLVqzaW6kyThr0HlIi42t5eXWBjrM97SpWENQWVjtCho2Pv8BfB4yWFYwu /RHVgF3zXk2cDTgx3vkCa82GbHrRw/++pmXqW03frvmARZby3zrt9ct4TGZxIY5BEo5Y2Gf6tVL rpIW/SzP1az3G1zzHd2riaEsAiqT/BRQZIn+tYeLcRpA3K9BnvYhzp7mu/3Rf0e48dkMFGYEp6b ytGtgZNqu11wUMKFe7CZmlL70GcvHHNzgmR/RjscEziS8Oz4bZWf6 X-Google-Smtp-Source: AGHT+IHXM+tDmp9KRG4oQchqwWwx5+59/wRU8Y+FF1E+d0V9ILPbYx4EKLHYLheDA96CT5puzYOrig== X-Received: by 2002:a05:6830:7192:b0:741:a36f:7a1f with SMTP id 46e09a7af769-741a36f7cc5mr1772068a34.16.1754177796170; Sat, 02 Aug 2025 16:36:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 44/85] target/arm: Introduce regime_to_gcs Date: Sun, 3 Aug 2025 09:29:12 +1000 Message-ID: <20250802232953.413294-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178479078116600 Content-Type: text/plain; charset="utf-8" Add a lookup from any a64 mmu index to the gcs mmu index within the same translation regime. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/mmuidx-internal.h | 10 ++++++++++ target/arm/mmuidx.c | 24 +++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/target/arm/mmuidx-internal.h b/target/arm/mmuidx-internal.h index f494ec348d..962b053852 100644 --- a/target/arm/mmuidx-internal.h +++ b/target/arm/mmuidx-internal.h @@ -21,6 +21,7 @@ FIELD(MMUIDXINFO, USER, 8, 1) FIELD(MMUIDXINFO, STAGE1, 9, 1) FIELD(MMUIDXINFO, STAGE2, 10, 1) FIELD(MMUIDXINFO, GCS, 11, 1) +FIELD(MMUIDXINFO, TG, 12, 5) =20 extern const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8]; =20 @@ -100,4 +101,13 @@ static inline bool regime_is_gcs(ARMMMUIdx idx) return FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, GCS); } =20 +/* Return the GCS MMUIdx for a given regime. */ +static inline ARMMMUIdx regime_to_gcs(ARMMMUIdx idx) +{ + tcg_debug_assert(arm_mmuidx_is_valid(idx)); + uint32_t core =3D FIELD_EX32(arm_mmuidx_table[idx], MMUIDXINFO, TG); + tcg_debug_assert(core !=3D 0); /* core 0 is E10_0, not a GCS index */ + return core | ARM_MMU_IDX_A; +} + #endif /* TARGET_ARM_MMUIDX_INTERNAL_H */ diff --git a/target/arm/mmuidx.c b/target/arm/mmuidx.c index 42b003db9c..a4663c8d87 100644 --- a/target/arm/mmuidx.c +++ b/target/arm/mmuidx.c @@ -16,27 +16,29 @@ #define S1 R_MMUIDXINFO_STAGE1_MASK #define S2 R_MMUIDXINFO_STAGE2_MASK #define GCS R_MMUIDXINFO_GCS_MASK +#define TG(X) \ + ((ARMMMUIdx_##X##_GCS & ARM_MMU_IDX_COREIDX_MASK) << R_MMUIDXINFO_TG_S= HIFT) =20 const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { /* * A-profile. */ - [ARMMMUIdx_E10_0] =3D EL(0) | REL(1) | R2, + [ARMMMUIdx_E10_0] =3D EL(0) | REL(1) | R2 | TG(E10_0), [ARMMMUIdx_E10_0_GCS] =3D EL(0) | REL(1) | R2 | GCS, - [ARMMMUIdx_E10_1] =3D EL(1) | REL(1) | R2, - [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1) | R2 | PAN, + [ARMMMUIdx_E10_1] =3D EL(1) | REL(1) | R2 | TG(E10_1), + [ARMMMUIdx_E10_1_PAN] =3D EL(1) | REL(1) | R2 | TG(E10_1) | PAN, [ARMMMUIdx_E10_1_GCS] =3D EL(1) | REL(1) | R2 | GCS, =20 - [ARMMMUIdx_E20_0] =3D EL(0) | REL(2) | R2, + [ARMMMUIdx_E20_0] =3D EL(0) | REL(2) | R2 | TG(E20_0), [ARMMMUIdx_E20_0_GCS] =3D EL(0) | REL(2) | R2 | GCS, - [ARMMMUIdx_E20_2] =3D EL(2) | REL(2) | R2, - [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2) | R2 | PAN, + [ARMMMUIdx_E20_2] =3D EL(2) | REL(2) | R2 | TG(E20_2), + [ARMMMUIdx_E20_2_PAN] =3D EL(2) | REL(2) | R2 | TG(E20_2) | PAN, [ARMMMUIdx_E20_2_GCS] =3D EL(2) | REL(2) | R2 | GCS, =20 - [ARMMMUIdx_E2] =3D EL(2) | REL(2), + [ARMMMUIdx_E2] =3D EL(2) | REL(2) | TG(E2), [ARMMMUIdx_E2_GCS] =3D EL(2) | REL(2) | GCS, =20 - [ARMMMUIdx_E3] =3D EL(3) | REL(3), + [ARMMMUIdx_E3] =3D EL(3) | REL(3) | TG(E3), [ARMMMUIdx_E3_GCS] =3D EL(3) | REL(3) | GCS, [ARMMMUIdx_E30_0] =3D EL(0) | REL(3), [ARMMMUIdx_E30_3_PAN] =3D EL(3) | REL(3) | PAN, @@ -44,10 +46,10 @@ const uint32_t arm_mmuidx_table[ARM_MMU_IDX_M + 8] =3D { [ARMMMUIdx_Stage2_S] =3D REL(2) | S2, [ARMMMUIdx_Stage2] =3D REL(2) | S2, =20 - [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | S1 | USER, + [ARMMMUIdx_Stage1_E0] =3D REL(1) | R2 | S1 | USER | TG(Stage1_E0= ), [ARMMMUIdx_Stage1_E0_GCS] =3D REL(1) | R2 | S1 | USER | GCS, - [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2 | S1, - [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | S1 | PAN, + [ARMMMUIdx_Stage1_E1] =3D REL(1) | R2 | S1 | TG(Stage1_E1), + [ARMMMUIdx_Stage1_E1_PAN] =3D REL(1) | R2 | S1 | TG(Stage1_E1) | PAN, [ARMMMUIdx_Stage1_E1_GCS] =3D REL(1) | R2 | S1 | GCS, =20 /* --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178121; cv=none; d=zohomail.com; s=zohoarc; b=dteiosJhbyHMDdhAqpjgjbTjHUfVQiRlviYoIE5bJGtRQmoPkVCUpjx2q5Ce9fQZUh8npRNZx+e+loQWsoVCoG0aJ8Koko+GMre6YmW6g8SoCFJpHYjEFxdww46OBZFH43pB5jieaMeqcaOsQJ/phqAXDYx3ASr2bQBZSRzVGO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178121; 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=6yp6GjOVr5sFSu+DGzVCc+heSPSS1fAAC7M3WZ7lFas=; b=DHn21NFaBTjRvEUuAhYwurPQwOelXpo9d9oh/t/eZ6o/QTikqjrdaicfx/+JV9+oJbL3wdHjUHZmgCZcB/yjhgneVwg7VpVGyoTzrVxOBBK141qTpdkFfTYikD+v2YU3RlMEBX8XHVb98ETXNbiOTMS+vPUCUAmL45TASSMYFKs= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178121574309.37279317876573; Sat, 2 Aug 2025 16:42:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpD-0007OL-TK; Sat, 02 Aug 2025 19:39: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 1uiLmM-00032H-GP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:46 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmL-0005k7-18 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:42 -0400 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-7419f3428c9so269028a34.2 for ; Sat, 02 Aug 2025 16:36:40 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177800; x=1754782600; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6yp6GjOVr5sFSu+DGzVCc+heSPSS1fAAC7M3WZ7lFas=; b=t2G21qyD6z3sJtMIcRkgALemGiZDl86Cbx+2aN5SJ2YxHvbbne8onvriflDH4vjaMu ff+4HX2SFvEIIxxo1fba6c6997hJxVTw8Ch/ylaLphiHwZFOkuYBW0Vqc039xN3mibpl YfufyHih6+4D0ySFnqJrkMAPTOwCIlA10JT5UlSjU1XoINVCyUR2JRlUpgngS5WR0+le HXkS0v+GmT7XOoqLm5yyo0xYY6NAl0tMTkMuN0SssxA29kio4rdhEvpHFAS9OypfOaOX uNr2PLKt/ghKzw0mG553rmRpSPhEq0vbeJfZU9RYZV7gFuCuy7G99cT1eBYKLvuSFng4 MhOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177800; x=1754782600; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6yp6GjOVr5sFSu+DGzVCc+heSPSS1fAAC7M3WZ7lFas=; b=SKq8PNex+mhcIwhRyuIl49CDUsnWSjuwVeGo9Jy61RWXZxQNHAobON5+AUNoLir7fR KxtJnC9WbDb9KQ+EYmzah1sALzRjfab5mB/oNV/l02CurUxotZDmqofvu6anmHsBqEEz aWwqSPLt+wJXLmnI2SczAjkUCvZKr/iYhFKVcYdjn53SZvGOrpp1Rx5bFSKcRqG18CwN BaJ96b5egi3oBGcPKvDyKx1zl7VszQLMtjnOjJvg80os5XGbCxX6amHPFYvxvuYBGgmT 0ViW+fy0ObnxKd2Soii1mMWIkui+A6LPVNEIhJdBjDGwcwzvp569yaSVS+9uC0/gYICA C44Q== X-Gm-Message-State: AOJu0YwmTImi4wrfpIpQYbqhhuPrvGLldIQ9e+bdU5+uF9YNVdRNJ0Xp NFdeOJ/V1q+UtjH9smTC+D6wyUvqvN/jZQOLF6si6RBXMSglkGtwmWEUlbLGIFZjjCd2RfXhChv 4VBQ5jaE= X-Gm-Gg: ASbGncunCUdbccwPrXvH+btxa28wikw369un2bUlFJgbNDVoTM5hDHhAI1MWGWf/Ojn EBjUGgriBykpISDJmaV3iM+V9vDh2/WXjWo8Fz3KfeKg3+0XioijFIzmaNrn7zK1kWd3yCN7I4Q GwDOvBEH8djE5x6Y3q5Ju47waRRdVLERAKMBBGk4g0x6X3cBbEpkr0ukZR/2a+hwKVlIMZYEPSO naPchW9lXckDEsPZkkkOmn1J4yscaXiyzubWOxtMUgsr/mAQ437I3fADIqJ/7diziioxKGre+4P keeAxCD46EkOOssTSRztPE9M+Of2fYUB97lvkF3vh+roNbrAaFsN5FmNSujRe9PZjriJ8Ews8Uc OOol46dkbbT5PyoT6DBdeLuTYrhs/IqKn4XhmEOe9iQCSswF96Xcw6wzAT0Y3CHE= X-Google-Smtp-Source: AGHT+IEivDBOTGrUqtjbaUTfs4h1AUX7M7oii1pwKBAEuNKV+Qq2kwLGsXHhwpn1JzXgzPzCB8QDaw== X-Received: by 2002:a05:6830:411b:b0:73e:5710:cfa with SMTP id 46e09a7af769-7419d1ff199mr2563144a34.15.1754177799740; Sat, 02 Aug 2025 16:36:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 45/85] target/arm: Support page protections for GCS mmu indexes Date: Sun, 3 Aug 2025 09:29:13 +1000 Message-ID: <20250802232953.413294-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32e.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178122281116600 Content-Type: text/plain; charset="utf-8" Take read and write from the s1perms.gcs bit computed by the Arm pseudocode. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/ptw.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index ee887d9a02..3c84f0f024 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1584,12 +1584,16 @@ static int get_S1prot_indirect(CPUARMState *env, S1= Translate *ptw, } } =20 - if (perm & PAGE_WXN) { + if (regime_is_gcs(mmu_idx)) { + /* + * Note that the one s1perms.gcs bit controls both read and write + * access via AccessType_GCS. See AArch64.S1CheckPermissions. + */ + perm =3D (perm & PAGE_GCS ? PAGE_READ | PAGE_WRITE : 0); + } else if (perm & PAGE_WXN) { perm &=3D ~PAGE_EXEC; } =20 - /* TODO: FEAT_GCS */ - return perm & PAGE_RWX; } =20 @@ -2236,6 +2240,13 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, */ prot =3D get_S1prot_indirect(env, ptw, mmu_idx, pi, po, result->f.attrs.space, out_space); + } else if (regime_is_gcs(mmu_idx)) { + /* + * While one must use indirect permissions to successfully + * use GCS instructions, AArch64.S1DirectBasePermissions + * faithfully supplies s1perms.gcs =3D 0, Just In Case. + */ + prot =3D 0; } else { int xn =3D extract64(attrs, 54, 1); int pxn =3D extract64(attrs, 53, 1); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178460; cv=none; d=zohomail.com; s=zohoarc; b=Tf1OGsQ6Nu3UCFmCxvf7gSq+A3M028oXauJoGmbcVaIgDgsWqOkeAn+LxBYsbQa6gJ+jBTh1uOM8t0VJ86lEiNZGZ61rioU6/t1Gbe1VDU4AcT7eTEKv5C4XowZG05eyLoXu4OIiG9ix1fyJPZQCWAGntLmXQxoPeTvvA6uQlvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178460; 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=H5djZzXS5Dinimievq/95HDV9TuYnTpWymA6EcqizEU=; b=iYJ2XloWgqr8jWkVe5SMATV9UrDNw3PSOMr2rJfjnTyzz5ygkuy2d+WNhUcImRL+9FZ2+kWZQNWNBHeIGpdSa6K3uAbRDZ8UVhiUvJQlweFGMJtnKoG9wNZCgJtw+fUYhRps8a5c4shtKPBtEFK2X2TO/jMaWOujUXurtLhUMfQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178460214530.7165797192806; Sat, 2 Aug 2025 16:47:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLoh-00066t-5V; Sat, 02 Aug 2025 19:39:07 -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 1uiLmS-00035J-CZ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:49 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmP-0005kS-Ui for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:48 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2e95ab2704fso2744422fac.3 for ; Sat, 02 Aug 2025 16:36:44 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177804; x=1754782604; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H5djZzXS5Dinimievq/95HDV9TuYnTpWymA6EcqizEU=; b=WewFUTzrhMyAaMPW16MAi/D0aolrbYQglpWe54n3vZa28NtVYYBcbVWKt3Obh2Us6O aKFGZPDvaELkv92xH2f6gasiD0LJNnGNQOR3aa3/t6+YHNRyKM61tboK/NE18wnENh04 jXum7ebydV3w99WkIMMHwKVwSx+tD3G4vE8PfsnWOe+VaUtD+Defwyb34bwI0Kti2EXr 41YyWR+hDMVd0XqJeTDG3jvBDGSUB7hZBKVRJAMcRPw7ODGbUnIM9UHtIrIancsMR4rS bUZiTtWB7S29NhXBiI+GhuFdL1MH/shLnk12ALabYebcLMbQdnVqn/yK4lINxd8gsHNO mKsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177804; x=1754782604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H5djZzXS5Dinimievq/95HDV9TuYnTpWymA6EcqizEU=; b=K9AymI6+P4K75JTEly8+ynLd4TdVB4yspFTMQnJ+OxV6CMgJTVYIes5z+S4U8YVXWB Q3YfzJK5IErG59MG9U80xGZTlqXjh7O7YkPCF4j5+uFGfh0PZ4INcRzKl2nza6e92sxG wfp7Qbu3K135Nax3Obkx8cu339q4JiKk7l/z3WL5eLm4rzxyuEUW9CjY6ejVDKmmWkit VG0WTMzqPQzk9czXXeWG4mrmtTVdG9WkVBxpqCw6LWdCHwyn7rNqxTCrpLEeUsIz1dWp FJIC8ti2/YIyZCVyVvz0B1cS6thhFRqLBk9w4KTla1P86jj050MyK1PeXxdfTZyWu1uz A2UA== X-Gm-Message-State: AOJu0YxdEpBLMy/R+6zlJS1WKiSMRt1LOxhYwRDStyAhDShzCBCE7Cq6 10UoKVoSuIhpzW/VSRQAJTdkwe/JoaQTPtUTSfdFs5s18kBG4tjGGB+4OxSSMGV9Eu4jc8/fKNi +z96kzAs= X-Gm-Gg: ASbGncsJ1nAbqh8IOduidY44BbLt+L2pPmASkdD6xcAbNDJA1CU8ipn2VL5zaHNRclk Y2GmFTeC7VqpgOoWPN1QiMvsfok1GNkEudnoOF/7tJunksN3WYf4nqJ5P8CUjQ14eOJVfYm2P19 LiY7m+4DWTJmfXAR+yT++zS15JnF4BRya7ZvAQ9rkdkvKTcitdlEIsraeoFeGyQGIr2/K/NP1Do 1L8Gi5/5EH5U+h8QoGtYT5pHYbrVpRxB/jekfzGhBtXwjyfkpbIBCJ4xj7q45hj77g03EtXA5PB 78Ci2FbKOBlT9NuT6TzBlcz2NfJcCSoHhFbjumqHXxpwII8dG56sqaldD+KjzulljL8p2nQvGZR EnKcvO5Uhni9dlGF5Qut9yppU2Y7w74TFzwaZUSfVVxhUeBU63E3e X-Google-Smtp-Source: AGHT+IE4Wrfck9OUylO4HcW2JLy6SCukYXLWAEj+KiTJ/TuJwyvRkCA2EjU5ISzUVsUPpkabZqFXWg== X-Received: by 2002:a05:6870:a9a3:b0:2f4:da72:5689 with SMTP id 586e51a60fabf-30b67739802mr2633111fac.15.1754177804040; Sat, 02 Aug 2025 16:36:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 46/85] target/arm: Implement gcs bit for data abort Date: Sun, 3 Aug 2025 09:29:14 +1000 Message-ID: <20250802232953.413294-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178460932116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/internals.h | 1 + target/arm/ptw.c | 1 + target/arm/tcg/tlb_helper.c | 1 + 3 files changed, 3 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 805f4a1876..7a42f8be0b 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -756,6 +756,7 @@ struct ARMMMUFaultInfo { bool s1ns; bool ea; bool dirtybit; /* FEAT_S1PIE, FEAT_S2PIE */ + bool gcs; }; =20 /** diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 3c84f0f024..ce9626b627 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2393,6 +2393,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, fi->stage2 =3D regime_is_stage2(mmu_idx); } fi->s1ns =3D fault_s1ns(ptw->in_space, mmu_idx); + fi->gcs =3D regime_is_gcs(mmu_idx); return true; } =20 diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index ae2acd6727..37c7651799 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -78,6 +78,7 @@ static inline uint64_t merge_syn_data_abort(uint32_t temp= late_syn, =20 /* Form ISS2 at the top of the syndrome. */ syn |=3D (uint64_t)fi->dirtybit << 37; + syn |=3D (uint64_t)fi->gcs << 40; =20 return syn; } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178667; cv=none; d=zohomail.com; s=zohoarc; b=Ir3OGmxoo+D5aaZ4PpCpD9ChAuGdJ4MNGN7AVbkO9a9h1ILJ00cvVGzw18DxR+VNxweYXBgVWMmt4MUz5gStLuIw1vEciTchQ5+Tja0oRHVSAEy+CFl4kcN9dUwjcCzK1k0o7RfVmCtcjX5eA9a1ea4lKjG48IXIawx0AQgDLXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178667; 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=pPOkQLbvkqPVPEJfSSp8FNRSZcEhCTwT9zh6ylUUUcE=; b=XQ7yFnlS0l4nY4uW3CYEomM/jyQzfkbjCCdna9oupCRDdOxWFzxlgKmhkLWI07yNDroqleNohs1IxM7JS4hrVpYvuZqTiWRbCb5xKIOpa3vUFUW2L3Df+paUqZMWibT8XZCT8FozixIlz8haeuN2TAB2QcGSo/rM7gkgryA+hFI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178667981923.7338955342492; Sat, 2 Aug 2025 16:51:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpK-0007oG-Ie; Sat, 02 Aug 2025 19:39:46 -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 1uiLmV-00038v-At for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:51 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmT-0005ky-Bq for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:51 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-741a905439eso355123a34.0 for ; Sat, 02 Aug 2025 16:36:48 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177808; x=1754782608; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pPOkQLbvkqPVPEJfSSp8FNRSZcEhCTwT9zh6ylUUUcE=; b=mKTmhvD2i3axDnt3++MlgTaY1iyD93I8zDBvzxov26ZgzILwFwDIg5aDm4MbJGiOil GFn6V+lCbMCR3IdlWVRsdztfLDfJCbjMG3nw6zYgFc8uC+9so8X4TjplCYobrS4wlYKh He3ezYWduafAZg0MhzsRPuEaTFTV8oC8P6Gw9WFItM9ZHGHS26MfB/7QHvMWfNr9NtHD xkH0LkU+0KuOYEPKqukeACTUGsy6DIpnGeeVjTBqtI+wmiY0JOQbQVZQX51rS0q+yG52 W6wSC8mRoPjU4wCddJjdGfE4yiEd45BaF2H0VxbX0xIpCB+YQGOF2sAhvGzngAKzgs/m iHWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177808; x=1754782608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pPOkQLbvkqPVPEJfSSp8FNRSZcEhCTwT9zh6ylUUUcE=; b=opQyxZs09jSaUPJylAk8XVceEDZAn8J0oljeR2UjkVtxjM7BMwg40lHWFzqBUovype 52nIuFqVKoZyU8pSlgJLrG3KTNyXMqA20c+5bZ7N/DLkTPgL4gJtD0CvsyLz0Ex2VEw2 k44N0XkRGS9GY3OpZXf77aqbbfFZzNfD72aS1L8X1nk+0vfic2RvJ887ao/HJLeBLr3w pWyJwJ+BpnDjdqVryKOcRRpcn2NX+P1CP3JJNg/zZM5vdF2MsLC09Mb8Kw6wqLzEcYgc /4Xd0WYNrnYJvHzfgFWjLVRDscRVKdJ67AspH0EDVi/x+PmVnZ9ySxo2BuYFzizaYEOJ KexA== X-Gm-Message-State: AOJu0YyIYGB7UMIuupgg3CWmbAW2KayaganH4+XDVyYT/7InONkbVhKH vYYUfWHWNexbi7aiLr3+GHK8sBVs6vWNvI54iM9l4pmSezs5h/7/BjBNmNMWoUrw3mYzrOr8Ao1 hQS7XiVs= X-Gm-Gg: ASbGncsEFo0YLrH9lerMJpY605jcIPcTr/vXhYLl/CnGuVJRucowX983Rm/EuOfJCGB MdACdGROr84ohfJdp/6c8Mw7KZWrYou7SpJILYmHWIEHxoVK98gYjjjjcrvOPprkolZ6wreSiO9 By8WftBooFTgSz0SZBf69grRFnltIfNgn1KS1RFYqi5iLEbt/Rjxp/LYFWACvSLaa0CLnPpY3MC pzRBJ3ypWnULufkVrhr8DP9igKuzX/Vxg6OHS4QICgm6TXc/aN4IYN0GymtHqg30ayMsXbQFZgr yToqvhQvKLbVZcV+U0T0/TkGJo1rbw1ehoBrZav4BoPrfUHBAMGuNEtMnMmOyGOykrlfUNIrhew 7zrTxwNooyzF9iS1G2wRvgjjnROJi1ItvX0UA7Y4Wq8+9+KHqZV9pcCDab0pM1U0= X-Google-Smtp-Source: AGHT+IHG1ISxY0xlxMUVz+SdWzgFLkkxUCfeT1YpjCd72I1UHDfLz+A6e3SBm4UTqm2z0u47fh5jpg== X-Received: by 2002:a05:6830:927:b0:73c:e29c:3fdc with SMTP id 46e09a7af769-7419d27d146mr2249149a34.18.1754177808001; Sat, 02 Aug 2025 16:36:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 47/85] target/arm: Add GCS cpregs Date: Sun, 3 Aug 2025 09:29:15 +1000 Message-ID: <20250802232953.413294-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178668536116600 Content-Type: text/plain; charset="utf-8" Add isar_feature_aa64_gcs. Enable SCR_GCSEN in scr_write. Enable HCRX_GCSEN in hcrx_write. Default HCRX_GCSEN on if EL2 disabled. Add the GCSCR* and GCSPR* registers. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 2 + target/arm/cpu-features.h | 5 +++ target/arm/cpu.h | 12 ++++++ target/arm/internals.h | 3 ++ target/arm/cpregs-gcs.c | 79 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 3 ++ target/arm/helper.c | 10 +++++ target/arm/meson.build | 2 + 8 files changed, 116 insertions(+) create mode 100644 target/arm/cpregs-gcs.c diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 9efe9238c1..bc6adf5956 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -774,6 +774,8 @@ typedef enum FGTBit { DO_BIT(HFGRTR, VBAR_EL1), DO_BIT(HFGRTR, ICC_IGRPENN_EL1), DO_BIT(HFGRTR, ERRIDR_EL1), + DO_REV_BIT(HFGRTR, NGCS_EL0), + DO_REV_BIT(HFGRTR, NGCS_EL1), DO_REV_BIT(HFGRTR, NSMPRI_EL1), DO_REV_BIT(HFGRTR, NTPIDR2_EL0), DO_REV_BIT(HFGRTR, NPIRE0_EL1), diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 83875c06bb..e3754df786 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -719,6 +719,11 @@ static inline bool isar_feature_aa64_nmi(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64PFR1, NMI) !=3D 0; } =20 +static inline bool isar_feature_aa64_gcs(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64PFR1, GCS) !=3D 0; +} + static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) { return FIELD_SEX64_IDREG(id, ID_AA64MMFR0, TGRAN4) >=3D 1; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index da42bd4466..1da73196f0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -591,6 +591,9 @@ typedef struct CPUArchState { uint64_t mecid_rl_a_el3; uint64_t vmecid_p_el2; uint64_t vmecid_a_el2; + + uint64_t gcscr_el[4]; /* GCSCRE0_EL1, GCSCR_EL[123] */ + uint64_t gcspr_el[4]; /* GCSPR_EL[0123] */ } cp15; =20 struct { @@ -1735,6 +1738,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_ENAS0 (1ULL << 36) #define SCR_ADEN (1ULL << 37) #define SCR_HXEN (1ULL << 38) +#define SCR_GCSEN (1ULL << 39) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) #define SCR_TCR2EN (1ULL << 43) @@ -1744,6 +1748,14 @@ static inline void xpsr_write(CPUARMState *env, uint= 32_t val, uint32_t mask) #define SCR_MECEN (1ULL << 49) #define SCR_NSE (1ULL << 62) =20 +/* GCSCR_ELx fields */ +#define GCSCR_PCRSEL (1ULL << 0) +#define GCSCR_RVCHKEN (1ULL << 5) +#define GCSCR_EXLOCKEN (1ULL << 6) +#define GCSCR_PUSHMEN (1ULL << 8) +#define GCSCR_STREN (1ULL << 9) +#define GCSCRE0_NTR (1ULL << 10) + /* Return the current FPSCR value. */ uint32_t vfp_get_fpscr(CPUARMState *env); void vfp_set_fpscr(CPUARMState *env, uint32_t val); diff --git a/target/arm/internals.h b/target/arm/internals.h index 7a42f8be0b..350b8bc678 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -253,6 +253,7 @@ FIELD(VTCR, SL2, 33, 1) #define HCRX_MSCEN (1ULL << 11) #define HCRX_TCR2EN (1ULL << 14) #define HCRX_SCTLR2EN (1ULL << 15) +#define HCRX_GCSEN (1ULL << 22) =20 #define HPFAR_NS (1ULL << 63) =20 @@ -1778,6 +1779,8 @@ void define_tlb_insn_regs(ARMCPU *cpu); void define_at_insn_regs(ARMCPU *cpu); /* Add the cpreg definitions for PM cpregs */ void define_pm_cpregs(ARMCPU *cpu); +/* Add the cpreg definitions for GCS cpregs */ +void define_gcs_cpregs(ARMCPU *cpu); =20 /* Effective value of MDCR_EL2 */ static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env) diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c new file mode 100644 index 0000000000..9c06100d2b --- /dev/null +++ b/target/arm/cpregs-gcs.c @@ -0,0 +1,79 @@ +/* + * QEMU ARM CP Register GCS regiters and instructions + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/timer.h" +#include "exec/icount.h" +#include "hw/irq.h" +#include "cpu.h" +#include "cpu-features.h" +#include "cpregs.h" +#include "internals.h" + + +static CPAccessResult access_gcs(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) < 3 + && arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_GCSEN)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static CPAccessResult access_gcs_el0(CPUARMState *env, const ARMCPRegInfo = *ri, + bool isread) +{ + if (arm_current_el(env) =3D=3D 0 && !(env->cp15.gcscr_el[0] & GCSCRE0_= NTR)) { + return CP_ACCESS_TRAP_EL1; + } + return access_gcs(env, ri, isread); +} + +static const ARMCPRegInfo gcs_reginfo[] =3D { + { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, + .access =3D PL1_RW, .accessfn =3D access_gcs, .fgt =3D FGT_NGCS_EL0, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[0]) }, + { .name =3D "GCSCR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 0, + .access =3D PL1_RW, .accessfn =3D access_gcs, .fgt =3D FGT_NGCS_EL1, + .nv2_redirect_offset =3D 0x8d0 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[1]) }, + { .name =3D "GCSCR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 5, .opc2 =3D 0, + .access =3D PL2_RW, .accessfn =3D access_gcs, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[2]) }, + { .name =3D "GCSCR_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 5, .opc2 =3D 0, + .access =3D PL3_RW, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[3]) }, + + { .name =3D "GCSPR_EL0", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 3, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL0_R | PL1_W, .accessfn =3D access_gcs_el0, .fgt =3D FG= T_NGCS_EL0, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[0]) }, + { .name =3D "GCSPR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL1_RW, .accessfn =3D access_gcs, .fgt =3D FGT_NGCS_EL1, + .nv2_redirect_offset =3D 0x8c0 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[1]) }, + { .name =3D "GCSPR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL2_RW, .accessfn =3D access_gcs, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[2]) }, + { .name =3D "GCSPR_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL3_RW, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[2]) }, +}; + +void define_gcs_cpregs(ARMCPU *cpu) +{ + if (cpu_isar_feature(aa64_gcs, cpu)) { + define_arm_cp_regs(cpu, gcs_reginfo); + } +} diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b472992b4a..d9318c5325 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -644,6 +644,9 @@ void arm_emulate_firmware_reset(CPUState *cpustate, int= target_el) if (cpu_isar_feature(aa64_fgt, cpu)) { env->cp15.scr_el3 |=3D SCR_FGTEN; } + if (cpu_isar_feature(aa64_gcs, cpu)) { + env->cp15.scr_el3 |=3D SCR_GCSEN; + } if (cpu_isar_feature(aa64_tcr2, cpu)) { env->cp15.scr_el3 |=3D SCR_TCR2EN; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 1b21ae5d8e..14f7129607 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -743,6 +743,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegI= nfo *ri, uint64_t value) if (cpu_isar_feature(aa64_ecv, cpu)) { valid_mask |=3D SCR_ECVEN; } + if (cpu_isar_feature(aa64_gcs, cpu)) { + valid_mask |=3D SCR_GCSEN; + } if (cpu_isar_feature(aa64_tcr2, cpu)) { valid_mask |=3D SCR_TCR2EN; } @@ -3947,6 +3950,9 @@ static void hcrx_write(CPUARMState *env, const ARMCPR= egInfo *ri, if (cpu_isar_feature(aa64_sctlr2, cpu)) { valid_mask |=3D HCRX_SCTLR2EN; } + if (cpu_isar_feature(aa64_gcs, cpu)) { + valid_mask |=3D HCRX_GCSEN; + } =20 /* Clear RES0 bits. */ env->cp15.hcrx_el2 =3D value & valid_mask; @@ -4017,6 +4023,9 @@ uint64_t arm_hcrx_el2_eff(CPUARMState *env) if (cpu_isar_feature(aa64_sctlr2, cpu)) { hcrx |=3D HCRX_SCTLR2EN; } + if (cpu_isar_feature(aa64_gcs, cpu)) { + hcrx |=3D HCRX_GCSEN; + } return hcrx; } if (arm_feature(env, ARM_FEATURE_EL3) && !(env->cp15.scr_el3 & SCR_HXE= N)) { @@ -7574,6 +7583,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) } =20 define_pm_cpregs(cpu); + define_gcs_cpregs(cpu); =20 #ifndef CONFIG_USER_ONLY /* diff --git a/target/arm/meson.build b/target/arm/meson.build index 91630a1f72..8c82304fde 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -27,6 +27,7 @@ arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files( 'cpu32-stubs.c', )) arm_user_ss.add(files( + 'cpregs-gcs.c', 'cpregs-pmu.c', 'debug_helper.c', 'helper.c', @@ -42,6 +43,7 @@ arm_common_system_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', 'cortex-regs.c', + 'cpregs-gcs.c', 'cpregs-pmu.c', 'debug_helper.c', 'helper.c', --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178105; cv=none; d=zohomail.com; s=zohoarc; b=khlu/KC4wpuTUSXykbIHIMD7UyFMqG3YTTWv76TzFm/u9olW29rYGmSHHQMlg/jY37h3hCCk4JiKpBMkgHRL+ECrKUE9OuCokIh4gK0mcbNqRnRVrCzQdz9ohoFsBrJAmLsPwbZX6q4eNUH6/qgk1PYYyEUKux4PzWeBdKUHSCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178105; 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=c9sc0ZUHCkfd2ykNLWaRo5wL6kxQj6o6jh7+7rjjEiA=; b=GFG5bX8Kh8AV2zxBhH6k1ILhwjGJ8S28M5C+kHX1m58PtwVJdv37sLiYguenCndo8evdNamjeMpSIZnjPLikWm8Ddp3nZbcxydN0sNUSFZGRW8inuSzdy7yZhNP3trW9dvlOn5Ly7iVZHVWrgg90c5g5r11XTIF+ewvCO2MJ9jg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178105237704.9487393733081; Sat, 2 Aug 2025 16:41:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpR-0008H0-Lh; Sat, 02 Aug 2025 19:39:53 -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 1uiLmZ-0003CT-SK for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:02 -0400 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmY-0005lb-0J for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:36:55 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-30b79c7c918so94045fac.0 for ; Sat, 02 Aug 2025 16:36:53 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177813; x=1754782613; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c9sc0ZUHCkfd2ykNLWaRo5wL6kxQj6o6jh7+7rjjEiA=; b=PsGb57sAvmUpp7566bDDQkCvcmi4Ba58Y6ENpMLZZi4+gtfHtJJ/sAyns0Fx8sMKkU SkrMa+67PAbxgOVukXv5ge4G+QsjpYYNcWOvUn9OU5ycya7aU5YO75dWkAGYSKW7BDpG hC+tMykWRZ+AMAkduADg83hz2d9UB4GEBV3uxa/tdGUL7qCS8k/8agAT1NNISi+gFoy8 5lu7wFxXBtsCvgMb6JFjlNAlw1d8HZ4Tvvtwf9JBcu9GdLa8IQFTGOOMnPBsd3CYHIck 2YtULaItXYMC5WgaHqZYTFg4QOzhFcYVJqpe2NI2MBqVklXyuMsb3mCnTaXHvzJFMQbb AMbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177813; x=1754782613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c9sc0ZUHCkfd2ykNLWaRo5wL6kxQj6o6jh7+7rjjEiA=; b=nJEBsHz4d/Yrvz3aFQCvSjGXPCEZzP3Un9Oab5LSNiSLL+IFSM51txdQGU+xLQ17Zd l6VmAL1VqzPMYV1XBFdVmAJlcx4/i+nr4KCJW989YnD2IZKFmgCemzApsZ8Am5SSLgH6 Of8GMVHajSz1DSPR8lFKlMK69GW+vXp4IXOEH5DH0XJCIcYqOjnuzQIq7ZyLwINMI9rB ZQTHDUxy11piONIz/cFVuTgd4CjzYIFxKw1l0uCXCzZikRsF/XhejBtvE2DiroVDEFN9 nlISXyVaYTJV16YgTLhfzcUXFi5hII+u1qbrSRa3w/N2KwrWhh6VPWH0Zfd1lk88mJ6b z5pA== X-Gm-Message-State: AOJu0YyrPkqwKnsJ77paHZ6IhlPu6PlNaTg0RJ250rzyTiVf7liw2P/x ObCx5A59iH6ubMgXdzBY5LXQlguo7k4Wo8AHoovTtDZfzWrM2cnNEA1x6pkWPEjrjdyRbweByTV HdmINODw= X-Gm-Gg: ASbGncuSwTwSPQ88RhxWPKD5/uBT8kkP14vuAzJEZo3lrpp9AyWqYol5gy4lDpgzFWP do0moXZvOoO6LOK5nuq8W38hTJUQxm2fHoWcMsIv09/ZU0GzUQXg0IGZJ2BiBI1tw/EjpLNj1ed sjbocD4G2PBFxCNqS1Pr2SB/+sJL3YqtgniRTQ/TksHdfxnMFY8Axph2Q8l5iDAkLiwPadS58Sv grenHazxET2Biw9i459IuzErShYlr/LSFO94FIjndMv/h4o+QWVmQDlZwxOxk1zAj6ajUaMIrj+ 83qT8bkHTLZqGHBpPFdRVdkvMOjWbxa9z0OWohXeJaip35HpLjM71EttbRE0i3cI0KFKgX9jX4k o23CC8vweSVZm/BpRbXPuS/PmYRA1dvmR/Wrt2VusgEs31AVC9NDu X-Google-Smtp-Source: AGHT+IHPPtSoPCdMabycVwcngJY5dpHgLs3nkTKarm5M0N/WEvcIcnSd667BBvldygEpobuhIL+gxw== X-Received: by 2002:a05:6871:e028:b0:2f5:2b87:416a with SMTP id 586e51a60fabf-30b679b8735mr2341907fac.37.1754177812811; Sat, 02 Aug 2025 16:36:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 48/85] target/arm: Add GCS enable and trap levels to DisasContext Date: Sun, 3 Aug 2025 09:29:16 +1000 Message-ID: <20250802232953.413294-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178106088116600 Content-Type: text/plain; charset="utf-8" Pipe GCSEnabled, GCSReturnValueCheckEnabled, and CheckGCSSTREnabled through hflags to the translator. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpu.h | 3 +++ target/arm/tcg/translate.h | 6 ++++++ target/arm/tcg/hflags.c | 38 ++++++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 3 +++ 4 files changed, 50 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1da73196f0..98360b70b8 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2918,6 +2918,9 @@ FIELD(TBFLAG_A64, NV2_MEM_BE, 36, 1) FIELD(TBFLAG_A64, AH, 37, 1) /* FPCR.AH */ FIELD(TBFLAG_A64, NEP, 38, 1) /* FPCR.NEP */ FIELD(TBFLAG_A64, ZT0EXC_EL, 39, 2) +FIELD(TBFLAG_A64, GCS_EN, 41, 1) +FIELD(TBFLAG_A64, GCS_RVCEN, 42, 1) +FIELD(TBFLAG_A64, GCSSTR_EL, 43, 2) =20 /* * Helpers for using the above. Note that only the A64 accessors use diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index f974996f3f..3e63dad2b6 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -164,6 +164,12 @@ typedef struct DisasContext { bool fpcr_ah; /* True if FPCR.NEP is 1 (FEAT_AFP scalar upper-element result handlin= g) */ bool fpcr_nep; + /* True if GCSEnabled. */ + bool gcs_en; + /* True if GCSReturnValueCheckEnabled. */ + bool gcs_rvcen; + /* GCSSTR exception EL or 0 if enabled */ + uint8_t gcsstr_el; /* * >=3D 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. * < 0, set by the current instruction. diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c index 59ab526375..2e3a9cf0d3 100644 --- a/target/arm/tcg/hflags.c +++ b/target/arm/tcg/hflags.c @@ -449,6 +449,44 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *e= nv, int el, int fp_el, DP_TBFLAG_A64(flags, TCMA, aa64_va_parameter_tcma(tcr, mmu_idx)); } =20 + if (cpu_isar_feature(aa64_gcs, env_archcpu(env))) { + /* C.f. GCSEnabled */ + if (env->cp15.gcscr_el[el] & GCSCR_PCRSEL) { + switch (el) { + default: + if (!el_is_in_host(env, el) + && !(arm_hcrx_el2_eff(env) & HCRX_GCSEN)) { + break; + } + /* fall through */ + case 2: + if (arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_GCSEN)) { + break; + } + /* fall through */ + case 3: + DP_TBFLAG_A64(flags, GCS_EN, 1); + break; + } + } + + /* C.f. GCSReturnValueCheckEnabled */ + if (env->cp15.gcscr_el[el] & GCSCR_RVCHKEN) { + DP_TBFLAG_A64(flags, GCS_RVCEN, 1); + } + + /* C.f. CheckGCSSTREnabled */ + if (!(env->cp15.gcscr_el[el] & GCSCR_STREN)) { + DP_TBFLAG_A64(flags, GCSSTR_EL, el ? el : 1); + } else if (el =3D=3D 1 + && EX_TBFLAG_ANY(flags, FGT_ACTIVE) + && !FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], + HFGITR_EL2, NGCSSTR_EL1)) { + DP_TBFLAG_A64(flags, GCSSTR_EL, 2); + } + } + if (env->vfp.fpcr & FPCR_AH) { DP_TBFLAG_A64(flags, AH, 1); } diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index dbf47595db..7831b3dab3 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -10162,6 +10162,9 @@ static void aarch64_tr_init_disas_context(DisasCont= extBase *dcbase, dc->nv2_mem_be =3D EX_TBFLAG_A64(tb_flags, NV2_MEM_BE); dc->fpcr_ah =3D EX_TBFLAG_A64(tb_flags, AH); dc->fpcr_nep =3D EX_TBFLAG_A64(tb_flags, NEP); + dc->gcs_en =3D EX_TBFLAG_A64(tb_flags, GCS_EN); + dc->gcs_rvcen =3D EX_TBFLAG_A64(tb_flags, GCS_RVCEN); + dc->gcsstr_el =3D EX_TBFLAG_A64(tb_flags, GCSSTR_EL); dc->vec_len =3D 0; dc->vec_stride =3D 0; dc->cp_regs =3D arm_cpu->cp_regs; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179237; cv=none; d=zohomail.com; s=zohoarc; b=K8fahH9qp1HUJM7F/q3+2Hrz8oNqH7xIup8q+W7UohJqP2a7W7jln6SGDxV31dChFMsXMyKIectnkWGidVk/BpkkCsON+hS/MtyMoSSKDOyra4RTMPXJVz/Lan5fMOqDGYXQSd/yp85PAlC9EW9syXL5bcKuIekkRZx9OMjTKQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179237; 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=17nAzkO3yEHAvK6PxJmaLfoSw+fDYNwVzEXoZ0CbSlE=; b=mk68j0Th67oqVr7KmO/0tlctKpxSfDr13q1Yl66XferYtrL1ro87WL7in/THQAoeQ1ARFoGPCHs3WtoRs2CZFWTh/WTfH3k1Xs1oQ97kzX7pf/E0sA62ZKC7taq9c85El+yDtspy0h8lahCJhQZU3Iw7TBgNkk2U7RNpyDOF3jA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417923761941.51461003420184; Sat, 2 Aug 2025 17:00:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLop-0006iD-1Q; Sat, 02 Aug 2025 19:39: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 1uiLmf-0003DS-E7 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:02 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmd-0005nQ-IT for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:01 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-741a905439eso355177a34.0 for ; Sat, 02 Aug 2025 16:36:59 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177818; x=1754782618; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=17nAzkO3yEHAvK6PxJmaLfoSw+fDYNwVzEXoZ0CbSlE=; b=MP+EdUn3FiwqRuFPcIt9vfzqoI/1OLofvtnDwxuF+/d+g1MH+MLXqFC0lEIAUS/1DW O2d0X40iO73GduSV7wCARsRGQbSxi59u8f2+vcr4rwt5e9yd/nzBZiHaa6qcBX/pJ68D f9cF3kSr65cEp2xbUX7S6tn+J89B+r1sLFgb+smFd1DM8G7JQ2cyuYpy9MO/pTOwCKmy GjRBcgb+sslfSLxUGBxh6IFfCGXnPVoX6zokD7wliGrQ3I1vuKvyQy8d3xAa2A6LOAwr x0+AZ7rgU2Q9pxTmSae38jsIxXDZIkrzFZYBs+oRFAwmakGqpyeUEbGIKbM9bAyAT1dq RAyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177818; x=1754782618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=17nAzkO3yEHAvK6PxJmaLfoSw+fDYNwVzEXoZ0CbSlE=; b=C5h5nK8RTSJWr2fNaTBGj82zwfvAf2PCDSY8KC286VWmucw2Fw3gHLh9WMQt/iLEZE nJTEvkxuaKwTS390I/QqB2DygaOMZGWss9FxUOKaDRjtVIzEQgo0WJlPwN/KvTnvV5H4 zR3zu86OCoRI2xTIb021vjAIdWdHwc6YiIw6H9UYZCRj503br7fawYnqxKyQ8Kv03n6q HGAowoRqV3v1T1UQPqvzaay5N4A8f5Xxz6LPEhmL60xwR3cxHMYQzNwyGeyBwLx7u6yt wFcN93RBRz4s59im2gqmyZB666/vqOvzf0/zJNnH37VbIuAxjP2bvXiKs72tAojwXLHP naJg== X-Gm-Message-State: AOJu0YzksI8b4HhRy665V/6qrYZTTHcJZ0QRtgEV1a9IXRYNswOFx31p ionIktj+eF4qTNIv5B3O/LbN1a3XNBh3x+/i7r6UGpoqCrX9rfc0cll1Za822flFJNl9/8BYGLP oiLE2lAs= X-Gm-Gg: ASbGncvHXIgFk0K7GIwhKln4maQXjeGfMVgSM0QN3z9q2o9ShM8pXKZP8YNal9qo684 KWqfjRYgC3X1Wl/IVtjXqlubA2/j8/Ni8FXnmk8Lv5t2Qbf/Rzt4NFwpT/9nh+Z2I9FwIVbbA/j WMLKPouII42BYJaie1sqEHhXc6B1sNJhsGZMb5zm0ZVJ9v5kj6jAhiF/9zHjCOepDqO82TLotyc B7Yxi2hdmavNazxhTYnyx9WMIPgJjJglXCKMkt1+ll4+4d1FsIey+TgJhJpmU6a6qGP5nA+TcqE jdi4EbUJikqWpuP+wqKNYbPbhi46YPbJdLitY3kP3iqY1S2mRJUvqxm6OCym5W4WSut6S5GPkvM h2XBHKbszjrimgpg89Qr4wo/crV9SyKpLONqCuQALqVimxgfQzZPb X-Google-Smtp-Source: AGHT+IGNEoZQRBSkKLRdE+bqDlOwx7EMMpp1hV1yn3I20OGToewTUSmXvTjn8nwD5qqaHCPTjubGZQ== X-Received: by 2002:a05:6830:4489:b0:741:b197:514b with SMTP id 46e09a7af769-741b197596fmr191017a34.6.1754177818256; Sat, 02 Aug 2025 16:36:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Gustavo Romero , Pierrick Bouvier Subject: [PATCH v2 49/85] target/arm: Implement FEAT_CHK Date: Sun, 3 Aug 2025 09:29:17 +1000 Message-ID: <20250802232953.413294-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179240280124100 Content-Type: text/plain; charset="utf-8" This feature contains only the CHKFEAT instruction. It has no ID enable, being back-allocated into the hint nop space. Reviewed-by: Gustavo Romero Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 14 ++++++++++++++ docs/system/arm/emulation.rst | 1 + target/arm/tcg/a64.decode | 1 + 3 files changed, 16 insertions(+) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 7831b3dab3..34d22cac8a 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2124,6 +2124,20 @@ static bool trans_AUTIBSP(DisasContext *s, arg_AUTIB= SP *a) return true; } =20 +static bool trans_CHKFEAT(DisasContext *s, arg_CHKFEAT *a) +{ + uint64_t feat_en =3D 0; + + if (s->gcs_en) { + feat_en |=3D 1 << 0; + } + if (feat_en) { + TCGv_i64 x16 =3D cpu_reg(s, 16); + tcg_gen_andi_i64(x16, x16, ~feat_en); + } + return true; +} + static bool trans_CLREX(DisasContext *s, arg_CLREX *a) { tcg_gen_movi_i64(cpu_exclusive_addr, -1); diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 6ebf9c9ce9..b894aced89 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -28,6 +28,7 @@ the following architecture extensions: - FEAT_BF16 (AArch64 BFloat16 instructions) - FEAT_BTI (Branch Target Identification) - FEAT_CCIDX (Extended cache index) +- FEAT_CHK (Check Feature Status) - FEAT_CMOW (Control for cache maintenance permission) - FEAT_CRC32 (CRC32 instructions) - FEAT_Crypto (Cryptographic Extension) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 8c798cde2b..4315ed8dab 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -246,6 +246,7 @@ ERETA 1101011 0100 11111 00001 m:1 11111 1111= 1 &reta # ERETAA, ERETAB AUTIASP 1101 0101 0000 0011 0010 0011 101 11111 AUTIBZ 1101 0101 0000 0011 0010 0011 110 11111 AUTIBSP 1101 0101 0000 0011 0010 0011 111 11111 + CHKFEAT 1101 0101 0000 0011 0010 0101 000 11111 ] # The canonical NOP has CRm =3D=3D op2 =3D=3D 0, but all of the space # that isn't specifically allocated to an instruction must NOP --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178128; cv=none; d=zohomail.com; s=zohoarc; b=GEgpvKFw4ln/RpEtf4Kly8l0AFVH48aAZ/ZNSZsH6DegGd6a3yejPfNsUC8MAGih6w8Pta/rB2fi1TDBRAXWC/CdyCFCuP06Hn52P2nZ61seE5HCXvWN267yV14vwXaTDxAciQkiFSp0zx32bW0Urv3oqkFhhNTYjivBXsq/8XU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178128; 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=l3XZMcwBjJXnPY4lNj+AUr3+cWHNiNQf1Iz6BMHE4g8=; b=b4+ED233OY2d1EAnHb/yoxRTIa6yKCmcc09wAwA3gmB2fG93tY4iPkMN+J9cFNc65u9oxpwAQH3p1Ss7wi5G7W+FgMTea1+mBgacP+tWIZgPcNGJYA1n4/0KKyLRa/REoQNULL1SwJZouvT6fE+vA84o8ZRFTGiZ0d2miBAYXQQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178128034264.2502931007474; Sat, 2 Aug 2025 16:42:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLp9-00074q-Mu; Sat, 02 Aug 2025 19:39:35 -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 1uiLml-0003KW-Oe for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:09 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmi-0005oX-4b for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:07 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-74197e72d3dso709582a34.3 for ; Sat, 02 Aug 2025 16:37:03 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177823; x=1754782623; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l3XZMcwBjJXnPY4lNj+AUr3+cWHNiNQf1Iz6BMHE4g8=; b=vAdFYpRETpihuLnlcUMoZfTYC2XPRDyxUy0FDBdHSYKNHd3lvVR9rwBz9sdABi88Ku lzJM41iUwkaP84PjUwY4MQCauKXveiTAG17+5iFzOp4GXPdTHCVfTU82V4kSUadJRE3V iPtTv/hakIdrUXXgpF3tCkU0Oc++QmPBM40CJhVYCCPt+V+/tWP0SmXEisXEQ/7J/Rnd n/N0y4DPfsO70y9BgB7hxCt+TStpXH2WRR2X/fvBCiA5wxVPujVKT0PK4CInRjK+2O6P c/lIj9IlDeJNO7EEp8cH3Gze8VSWJIR0/pzYcWWJnhf0k8JnyEtTi9YgJ5ynVB4Jp5ng bWTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177823; x=1754782623; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l3XZMcwBjJXnPY4lNj+AUr3+cWHNiNQf1Iz6BMHE4g8=; b=rYWiGpJdq10awipTy8rXN6w45VmDpAsyr1TtIlnkyuNCI0vzfxsTDgM3Oky6KotUCS WNIOTi3uTSuMEFRUt683E3/otUeLvFDGKOdejASvyTHxW+KYKbe2i8lfmpUfbRCeoeZ1 jIrA0HBzI1Q3ohlUmX6CPXTKkstcRnWvCt38KZv2Ih8fVcg1z+HhngyYgLlFYzOlyNAn QuEq8vaRzFPzacG6FOORuzLd2Nq7XTx0XD3uV2XYDLkbIBBGQToVWV4rSFdVmpghBLhq A/HPM8n+nrPTk01zU2/Mv+WyLHZ1oCHAQBHrfW+Ja7dtSmXbx1NklSPiq34rV0JyG4Pe 0Htg== X-Gm-Message-State: AOJu0Ywy5S2tXwx6wBCp+pmzLW6Krn+2rhh96dwNc7x9LyoOLBR6s580 CvmLLR1aZ58zNg4B0+ObQvXSDtpZBo/FGJSeFD+6G0pOCMEE7/gY02aXBNYP2q5AMgXE/WwUuPT npFshUAU= X-Gm-Gg: ASbGncsjHVMf6AqBnDBkQ7mhXXAjrVNL67BsYpNIn5GMs0fgXFQvuYJ3VlfOtnrcRZv +w3JlyLOOutDrNHBwdldDrEoZM2VtFoKDauS1OZwhYjK6uMdgSt1/dQayT8nVBASdUKBZiba0RU TtZ6bZyJZqgzK9ytjvCyW33eA0SO4W/EOt1RoCZe/dpowQU+kRhdmIV3Y35MOMzvyiqc8SVvwuJ Zq0AmpmK6sf9Zvg3RGuIViqUpGLgDqGAzgnUKQDdjvrkuWTieTP9gaWUqki4kygLletnQHWHAy4 HpzZBMwYN04qwWVDWoYSZoPyfYuViSiANFeVmgEdCAl3ngUy5BeWN90p4OXOxa+Y5kwtwed+ZTa RIVIi9diL0B+iCxT9mqgE8V1tKmMNVEdGSeVUbD5nBkHFCXO82FbE X-Google-Smtp-Source: AGHT+IE1i68RnBI9XqegkDp8fxmKpiGmB4UXVRbUhQkOT8Zsj5w4GieJaicgQ/RKNOfRGW62PGtodg== X-Received: by 2002:a05:6830:3486:b0:739:fcb4:db29 with SMTP id 46e09a7af769-7419d10edc1mr2932812a34.8.1754177822679; Sat, 02 Aug 2025 16:37:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 50/85] target/arm: Expand pstate to 64 bits Date: Sun, 3 Aug 2025 09:29:18 +1000 Message-ID: <20250802232953.413294-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178130465124100 Content-Type: text/plain; charset="utf-8" The ARM now defines 36 bits in SPSR_ELx in aarch64 mode, so it's time to bite the bullet and extend PSTATE to match. Most changes are straightforward, adjusting printf formats, changing local variable types. More complex is migration, where to maintain backward compatibility a new pstate64 record is introduced, and only when one of the extensions that sets bits 32-35 are active. The fate of gdbstub is left undecided for the moment. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpu.h | 8 +++--- target/arm/tcg/translate.h | 20 ++++++------- target/arm/cpu.c | 6 ++-- target/arm/gdbstub64.c | 1 + target/arm/helper.c | 11 ++++---- target/arm/machine.c | 56 +++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper-a64.c | 2 +- 7 files changed, 81 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 98360b70b8..7769c4ae3c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -268,7 +268,7 @@ typedef struct CPUArchState { uint64_t xregs[32]; uint64_t pc; /* PSTATE isn't an architectural register for ARMv8. However, it is - * convenient for us to assemble the underlying state into a 32 bit fo= rmat + * convenient for us to assemble the underlying state into a 64 bit fo= rmat * identical to the architectural format used for the SPSR. (This is a= lso * what the Linux kernel's 'pstate' field in signal handlers and KVM's * 'pstate' register are.) Of the PSTATE bits: @@ -280,7 +280,7 @@ typedef struct CPUArchState { * SM and ZA are kept in env->svcr * all other bits are stored in their correct places in env->pstate */ - uint32_t pstate; + uint64_t pstate; bool aarch64; /* True if CPU is in aarch64 state; inverse of PSTATE.nR= W */ bool thumb; /* True if CPU is in thumb mode; cpsr[5] */ =20 @@ -1556,7 +1556,7 @@ static inline unsigned int aarch64_pstate_mode(unsign= ed int el, bool handler) * interprocessing, so we don't attempt to sync with the cpsr state used by * the 32 bit decoder. */ -static inline uint32_t pstate_read(CPUARMState *env) +static inline uint64_t pstate_read(CPUARMState *env) { int ZF; =20 @@ -1566,7 +1566,7 @@ static inline uint32_t pstate_read(CPUARMState *env) | env->pstate | env->daif | (env->btype << 10); } =20 -static inline void pstate_write(CPUARMState *env, uint32_t val) +static inline void pstate_write(CPUARMState *env, uint64_t val) { env->ZF =3D (~val) & PSTATE_Z; env->NF =3D val; diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 3e63dad2b6..1479f5bf74 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -378,27 +378,27 @@ static inline TCGv_i32 get_ahp_flag(void) } =20 /* Set bits within PSTATE. */ -static inline void set_pstate_bits(uint32_t bits) +static inline void set_pstate_bits(uint64_t bits) { - TCGv_i32 p =3D tcg_temp_new_i32(); + TCGv_i64 p =3D tcg_temp_new_i64(); =20 tcg_debug_assert(!(bits & CACHED_PSTATE_BITS)); =20 - tcg_gen_ld_i32(p, tcg_env, offsetof(CPUARMState, pstate)); - tcg_gen_ori_i32(p, p, bits); - tcg_gen_st_i32(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_ld_i64(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_ori_i64(p, p, bits); + tcg_gen_st_i64(p, tcg_env, offsetof(CPUARMState, pstate)); } =20 /* Clear bits within PSTATE. */ -static inline void clear_pstate_bits(uint32_t bits) +static inline void clear_pstate_bits(uint64_t bits) { - TCGv_i32 p =3D tcg_temp_new_i32(); + TCGv_i64 p =3D tcg_temp_new_i64(); =20 tcg_debug_assert(!(bits & CACHED_PSTATE_BITS)); =20 - tcg_gen_ld_i32(p, tcg_env, offsetof(CPUARMState, pstate)); - tcg_gen_andi_i32(p, p, ~bits); - tcg_gen_st_i32(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_ld_i64(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_andi_i64(p, p, ~bits); + tcg_gen_st_i64(p, tcg_env, offsetof(CPUARMState, pstate)); } =20 /* If the singlestep state is Active-not-pending, advance to Active-pendin= g. */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d9318c5325..ec63297165 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1208,7 +1208,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; - uint32_t psr =3D pstate_read(env); + uint64_t psr =3D pstate_read(env); int i, j; int el =3D arm_current_el(env); uint64_t hcr =3D arm_hcr_el2_eff(env); @@ -1230,7 +1230,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) } else { ns_status =3D ""; } - qemu_fprintf(f, "PSTATE=3D%08x %c%c%c%c %sEL%d%c", + qemu_fprintf(f, "PSTATE=3D%016" PRIx64 " %c%c%c%c %sEL%d%c", psr, psr & PSTATE_N ? 'N' : '-', psr & PSTATE_Z ? 'Z' : '-', @@ -1247,7 +1247,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) (FIELD_EX64(env->svcr, SVCR, SM) ? 'S' : '-')); } if (cpu_isar_feature(aa64_bti, cpu)) { - qemu_fprintf(f, " BTYPE=3D%d", (psr & PSTATE_BTYPE) >> 10); + qemu_fprintf(f, " BTYPE=3D%d", (int)(psr & PSTATE_BTYPE) >> 10); } qemu_fprintf(f, "%s%s%s", (hcr & HCR_NV) ? " NV" : "", diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 64ee9b3b56..3cef47281a 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -47,6 +47,7 @@ int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArra= y *mem_buf, int n) case 32: return gdb_get_reg64(mem_buf, env->pc); case 33: + /* pstate is now a 64-bit value; can we simply adjust the xml? */ return gdb_get_reg32(mem_buf, pstate_read(env)); } /* Unknown register. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 14f7129607..7d9b2762cf 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9185,8 +9185,8 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) CPUARMState *env =3D &cpu->env; unsigned int new_el =3D env->exception.target_el; vaddr addr =3D env->cp15.vbar_el[new_el]; - unsigned int new_mode =3D aarch64_pstate_mode(new_el, true); - unsigned int old_mode; + uint64_t new_mode =3D aarch64_pstate_mode(new_el, true); + uint64_t old_mode; unsigned int cur_el =3D arm_current_el(env); int rt; =20 @@ -9334,7 +9334,7 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) * If NV2 is disabled, change SPSR when NV,NV1 =3D=3D 1,0 = (I_ZJRNN) * If NV2 is enabled, change SPSR when NV is 1 (I_DBTLM) */ - old_mode =3D deposit32(old_mode, 2, 2, 2); + old_mode =3D deposit64(old_mode, 2, 2, 2); } } } else { @@ -9347,7 +9347,7 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) } env->banked_spsr[aarch64_banked_spsr_index(new_el)] =3D old_mode; =20 - qemu_log_mask(CPU_LOG_INT, "...with SPSR 0x%x\n", old_mode); + qemu_log_mask(CPU_LOG_INT, "...with SPSR 0x%" PRIx64 "\n", old_mode); qemu_log_mask(CPU_LOG_INT, "...with ELR 0x%" PRIx64 "\n", env->elr_el[new_el]); =20 @@ -9401,7 +9401,8 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) =20 env->pc =3D addr; =20 - qemu_log_mask(CPU_LOG_INT, "...to EL%d PC 0x%" PRIx64 " PSTATE 0x%x\n", + qemu_log_mask(CPU_LOG_INT, "...to EL%d PC 0x%" PRIx64 + " PSTATE 0x%" PRIx64 "\n", new_el, env->pc, pstate_read(env)); } =20 diff --git a/target/arm/machine.c b/target/arm/machine.c index 8dbeca2867..9b00c14b4a 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -836,6 +836,61 @@ static const VMStateInfo vmstate_cpsr =3D { .put =3D put_cpsr, }; =20 +static int get_pstate64_1(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field) +{ + ARMCPU *cpu =3D opaque; + CPUARMState *env =3D &cpu->env; + uint64_t val =3D qemu_get_be64(f); + + env->aarch64 =3D ((val & PSTATE_nRW) =3D=3D 0); + pstate_write(env, val); + return 0; +} + +static int put_pstate64_1(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field, JSONWriter *vmdesc) +{ + ARMCPU *cpu =3D opaque; + CPUARMState *env =3D &cpu->env; + uint64_t val =3D pstate_read(env); + + qemu_put_be64(f, val); + return 0; +} + +static const VMStateInfo vmstate_pstate64_1 =3D { + .name =3D "pstate64", + .get =3D get_pstate64_1, + .put =3D put_pstate64_1, +}; + +static bool pstate64_needed(void *opaque) +{ + ARMCPU *cpu =3D opaque; + CPUARMState *env =3D &cpu->env; + + return is_a64(env) && pstate_read(env) > UINT32_MAX; +} + +static const VMStateDescription vmstate_pstate64 =3D { + .name =3D "cpu/pstate64", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D pstate64_needed, + .fields =3D (const VMStateField[]) { + { + .name =3D "pstate64", + .version_id =3D 0, + .size =3D sizeof(uint64_t), + .info =3D &vmstate_pstate64_1, + .flags =3D VMS_SINGLE, + .offset =3D 0, + }, + VMSTATE_END_OF_LIST() + }, +}; + static int get_power(QEMUFile *f, void *opaque, size_t size, const VMStateField *field) { @@ -1119,6 +1174,7 @@ const VMStateDescription vmstate_arm_cpu =3D { &vmstate_serror, &vmstate_irq_line_state, &vmstate_wfxt_timer, + &vmstate_pstate64, NULL } }; diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 71c6c44ee8..f61adf1f80 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -639,7 +639,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_= t new_pc) ARMCPU *cpu =3D env_archcpu(env); int cur_el =3D arm_current_el(env); unsigned int spsr_idx =3D aarch64_banked_spsr_index(cur_el); - uint32_t spsr =3D env->banked_spsr[spsr_idx]; + uint64_t spsr =3D env->banked_spsr[spsr_idx]; int new_el; bool return_to_aa64 =3D (spsr & PSTATE_nRW) =3D=3D 0; =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178645; cv=none; d=zohomail.com; s=zohoarc; b=HTIHjx0e+3ixJoLPKQKeGrdroj41W0bIYPJBUuu6mqRwSdZPDTjXADm1PpetzlG+0KVYyQtvdpSyrNPC7znEHF0GHSWyT7Whq6ik+lY950dzEfAAf38Hb+4hafRhKYxE4K9Kz7vuAbs/abWr/j/klogxeJYh0zX+HBs9h1YeIGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178645; 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=QDW+HxP2J6pK8IxGshUeq+u65rBy5XdnKzmGA8gxmkE=; b=Kd7dFdnWzZ+UpXTHsSkngIpdyeUR7OHj5g1fnirKNieGukVX4OOiQoQLlpQPkd9Ldg2INZX7bQKQe9M3IeWeS1yvJpdVLT3qf95vVgAeDmDf9+OHClY3TFJv2Hmc6fW9GBC0a444T1PkB0+js/bp8QQbVhvpxO9juUM1qNne6w0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178645711957.1416138488547; Sat, 2 Aug 2025 16:50:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpK-0007oC-D5; Sat, 02 Aug 2025 19:39:46 -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 1uiLmn-0003O7-R8 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:13 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmm-0005p4-6k for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:09 -0400 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-741a254d4a0so895154a34.1 for ; Sat, 02 Aug 2025 16:37:07 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177827; x=1754782627; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QDW+HxP2J6pK8IxGshUeq+u65rBy5XdnKzmGA8gxmkE=; b=zgNzMZ5gZmutdY63P0kzAQy0XvqblCPUoD/wmwy5Qo5h+RCqMuVNLU+wgP8pRV8sy2 t6sta85KpQY/8bOfuj1EZi+dQoalNCP2/2SyixYIRZ5JBvojQstuJ1r/XtSJt6+tEAkY HIaRlp366mlWUjc7kAHGqfNbrHMR6rXZI7cv1jYemQwdtHQmdVVRKE/B2frnOtxRTxAu +iHG4WSEluFDCamNihUgDZlrkSw52wGTJmNg7N9NX8UKvPSX9m97FDqcBQ5MC2CdaaKf 8A2RwCMWFYrdPMBYZh2e2TvfcorvGBPVBFPFautxwD3znjeFKQUD4vlh7hXEpvTLfqgV B1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177827; x=1754782627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QDW+HxP2J6pK8IxGshUeq+u65rBy5XdnKzmGA8gxmkE=; b=AKCK7PDAW9TsAezp96+h1Qxkg02Rfh0XFmis2QpUzM0Hwr8Sim9pcWFxSJG6tPzhen b0lXg8018QMvqET9EJ2GZ44CjMejQlQESVBeo+ZNiCGZtpF5nq1JNu6MlN3Z3cBaaTSe N/Bfb55IrJ5dl8qNf0lKuYLkWl/ru8KmdPzdI7yREyfcGNf177WXeyJ5TmdU18Hjdzc+ UBLGONMAQJRnuQulUPHMC9q2iFPBDJ1gg1rUFJHbvUiHI2du9CCJlgfG1i7PgoqsEi29 9pIgrcwx+f+jVHSgrLLLAEbbJUGb6L/U3nSZROiLZFb5yIv2yutJLam9CaEU0xBl4xj2 b6Cw== X-Gm-Message-State: AOJu0Yz5Lp2ktPRwyIcXxKqvcyypTwFQ+/Qco2+3iZFU/asmb3CxeL2g vu6jQ+7mdvWjEAhnOcQlaBDMJQQk4aVWFSlWE3Mo0a9U9i6FEZsaRYFlt9bYOBqgtH7iTDcGnkO 4nv0m4vA= X-Gm-Gg: ASbGnctPoY79J0GbePtHXR5LjwGymQ4oVizeHq1m2RbNM1+mlWIIDvdJ1pv6uMJoysM vl9Zzu06dqTwSh0aHlsVV5kw22v/1R58aq4FNAxJ/C77nx54rL//jJnk2AhcfPrbIZ8+x6wISEe XxrSsj7k2xY6AbI6dwSLFwGWfxpytXH6SpqLtpzzjPcJL0Cum50AMzN4rJOq7Vq4UkVq2e1V1HI JLt4ZF3imrpFYjhyLthP/mYk8sUDRInpbdwA/ZgQGMmsowAy8hFvaVmU4IEnYSltiHKIPwe3Owx T62AV40O6/sVKWaO8PsWGv0xW7F7E0OswwB5faz/QyWvqXDotFKJQ0hlm4feNn0rgC1W2Mw5BUA 64qDB1GL/mI7CXmuHCUHfCdq3vo/XHcfTy6boBinHtztCdawuVmRdmG5ayqwCTuI= X-Google-Smtp-Source: AGHT+IGgqgUGJEh5uREVUzo7c6Stkqf7FbMPojwGUIG5RxDFYviN3DTEDm3Vllc7hd1GAy4o+hZA0w== X-Received: by 2002:a05:6830:3112:b0:740:79df:9026 with SMTP id 46e09a7af769-7419c4cdcb8mr2889465a34.0.1754177826850; Sat, 02 Aug 2025 16:37:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 51/85] target/arm: Add syndrome data for EC_GCS Date: Sun, 3 Aug 2025 09:29:19 +1000 Message-ID: <20250802232953.413294-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x335.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178646465116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/syndrome.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h index c48d3b8587..bff61f052c 100644 --- a/target/arm/syndrome.h +++ b/target/arm/syndrome.h @@ -63,6 +63,7 @@ enum arm_exception_class { EC_MOP =3D 0x27, EC_AA32_FPTRAP =3D 0x28, EC_AA64_FPTRAP =3D 0x2c, + EC_GCS =3D 0x2d, EC_SERROR =3D 0x2f, EC_BREAKPOINT =3D 0x30, EC_BREAKPOINT_SAME_EL =3D 0x31, @@ -83,6 +84,23 @@ typedef enum { SME_ET_InaccessibleZT0, } SMEExceptionType; =20 +typedef enum { + GCS_ET_DataCheck, + GCS_ET_EXLOCK, + GCS_ET_GCSSTR_GCSSTTR, +} GCSExceptionType; + +typedef enum { + GCS_IT_RET_nPauth =3D 0, + GCS_IT_GCSPOPM =3D 1, + GCS_IT_RET_PauthA =3D 2, + GCS_IT_RET_PauthB =3D 3, + GCS_IT_GCSSS1 =3D 4, + GCS_IT_GCSSS2 =3D 5, + GCS_IT_GCSPOPCX =3D 8, + GCS_IT_GCSPOPX =3D 9, +} GCSInstructionType; + #define ARM_EL_EC_LENGTH 6 #define ARM_EL_EC_SHIFT 26 #define ARM_EL_IL_SHIFT 25 @@ -351,6 +369,23 @@ static inline uint32_t syn_pcalignment(void) return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; } =20 +static inline uint32_t syn_gcs_data_check(GCSInstructionType it, int rn) +{ + return ((EC_GCS << ARM_EL_EC_SHIFT) | ARM_EL_IL | + (GCS_ET_DataCheck << 20) | (rn << 5) | it); +} + +static inline uint32_t syn_gcs_exlock(void) +{ + return (EC_GCS << ARM_EL_EC_SHIFT) | ARM_EL_IL | (GCS_ET_EXLOCK << 20); +} + +static inline uint32_t syn_gcs_gcsstr(int ra, int rn) +{ + return ((EC_GCS << ARM_EL_EC_SHIFT) | ARM_EL_IL | + (GCS_ET_GCSSTR_GCSSTTR << 20) | (ra << 10) | (rn << 5)); +} + static inline uint32_t syn_serror(uint32_t extra) { return (EC_SERROR << ARM_EL_EC_SHIFT) | ARM_EL_IL | extra; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179102; cv=none; d=zohomail.com; s=zohoarc; b=Yoc+/6tgrlXHulHR89tUxqzgKqtOKaY1DQVWrt5vloJ5tpoMrDuJO44We7aQNNuIgBXUvDAd6hHg3yrP39958VUS7rxXU0TW/b7l9NEJNNuwkxC/N4zHpEryuP+2XUHqaJEOLdaVWrA8XHIyKUCpEhOSRhGtnwt4Y3tDaUpkaDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179102; 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=m+3uEC+2riiyjp23nwcw8E7cRhcW/LL6NmP5HEJ1ke8=; b=cPffT391+Uv6Ud96z4Tml0pVCAc+7zp9EqV6Jag4AbgKhyTA3FE/4QrdYCKSYfFEbCHq2VFPCpq8WGSx/UDpGWOqb+tHnInJJuyjpGupTmnbx6Iaq9p2wp3V1V2mfAVpfWQC9l0um2b2nTJ/V7aBfkgtzo2CwRJdHkeLDccAeWo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179102328680.4135072053118; Sat, 2 Aug 2025 16:58:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLou-0006tY-0Z; Sat, 02 Aug 2025 19:39:22 -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 1uiLms-0003To-P5 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:14 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmq-0005pb-Eb for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:14 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-741a1ee9366so584365a34.2 for ; Sat, 02 Aug 2025 16:37:11 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177831; x=1754782631; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m+3uEC+2riiyjp23nwcw8E7cRhcW/LL6NmP5HEJ1ke8=; b=A5GR94RcaWr01avcniYLYznWWoTj7uMdjEgx9Sk3GJz2bckbErffpwgZNFwG9yaEVB 3OWCc2FLCBJACAHX/bhoc6iHTu6iIgZIImTu3eOPSSRVomosYma94vDLKcEMnXuUqAwW D7i6Z/PVJ4OLT3Yt5ZYW207IBn55qR2kb4w8pZZ8MVUjdqXZ0joyd10euwPFlecxc5G9 Axa5hH7ALq8JxgWzZ9r9LRtHgILeyEwtGUZlJyD+OdIDRrPIHY5VvEgXRvBHxVZIPhlx TYHFZThIK1MlK78U0m3g/bL7IiqZWQVCptMCqUkEEU1t5k1UQ08VQQRWZUA/JUuBluqc VfFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177831; x=1754782631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m+3uEC+2riiyjp23nwcw8E7cRhcW/LL6NmP5HEJ1ke8=; b=NGIi5iJOe91f0VPL0DhaeAKDNZIUyCHo66MhJxWE/nJmAafb6v7blZHCJEYkvU8k8/ f3aF2jLsKdJooPXc7olt/H8sFgcjQ+f6IDwtt0aCgD7D9ECm8b/LGDupeMs3ubHvmwS8 AIFEnizooJU0ts/sHcJgeQICVm6guhhR6T3cDaynXhgtaS7Ibjugr9QDwDmW6x4nwHRl sstQAu/ESu8DTSDwqTkyuD1UEPP++nGJzEdmPfRoDpHXFEgjAGoKQWbgkJzmiyGPvCNL fccwp9a/BrwM2tabyKkW4KfWJX9qiVjt2GHwlFWF+KvMnYFUIjLsiZGSWhjnyM2FxBFv xORw== X-Gm-Message-State: AOJu0YxCl/8MJv10ptbvQUDL945+v7pJVTeidsEbN9SYC8X2dYiJ6RBn bqd+aMVt++TGG5HP07ocU/UnAGTDJiGfJhA9UhulV7hYOUH/tSE5RqSIYUMOsyk86qpfAJcddrf vt6QvdgI= X-Gm-Gg: ASbGnctT7oe4vKuEkY4Zec1HxFPgj8F670wPRDxfch24XfwWrcSeU+Mr6awED+lSRqh SzmdHptc2pQek0Iq3HM+wtwfv8u+bo1FcazTvXO2ORUrWjYcGFnFDe5IAxLwVkng02Re8nSoQrF WDPE3HquWDk4e0Ht4R/frKY/l3vAZuLLta/PGwWPdg69w4nLDTW0MLCPjdWLvDyYhJmP++Ev/0q X8KY9GK7MnI1IVHT27m1DoA4VKFCpOq8xNJjZluXQ4p5FFL+lIRMU5MTYxupdoSW2NlZAF6hA7Z D/Th/GUtOxYBwsoRstMBHxgNcqgkJ9O3BrsIpFIPtaSX0xsnxYowSCPy2JfO3PHbJCNQswqj4oo 110SduNwMF3tjqVkmZlsESeBVScHTwSrCHYYnOmKIRi2OMPe+aTYi X-Google-Smtp-Source: AGHT+IF2j/FLMWL28I0rt8qkVG/eKsXp4gWxPC8O7RutzfDaoiIg8eZ4aM/BnzW5rQkZcuFaknbJZw== X-Received: by 2002:a05:6830:dc4:b0:741:290f:4a8c with SMTP id 46e09a7af769-7419d0ab11fmr2666637a34.7.1754177831201; Sat, 02 Aug 2025 16:37:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 52/85] target/arm: Implement EXLOCKException for ELR_ELx and SPSR_ELx Date: Sun, 3 Aug 2025 09:29:20 +1000 Message-ID: <20250802232953.413294-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179104645124100 Content-Type: text/plain; charset="utf-8" If PSTATE.EXLOCK is set, and the GCS EXLOCK enable bit is set, and nested virt is in the appropriate state, then we need to raise an EXLOCK exception. Since PSTATE.EXLOCK cannot be set without GCS being present and enabled, no explicit check for GCS is required. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 3 ++ target/arm/cpu.h | 1 + target/arm/helper.c | 83 +++++++++++++++++++++++++++++++++++--- target/arm/tcg/op_helper.c | 4 ++ 4 files changed, 85 insertions(+), 6 deletions(-) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index bc6adf5956..15894332b2 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -346,6 +346,9 @@ typedef enum CPAccessResult { * specified target EL. */ CP_ACCESS_UNDEFINED =3D (2 << 2), + + /* Access fails with EXLOCK, a GCS exception syndrome. */ + CP_ACCESS_EXLOCK =3D (3 << 2), } CPAccessResult; =20 /* Indexes into fgt_read[] */ diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 7769c4ae3c..8eee722a9e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1520,6 +1520,7 @@ void pmu_init(ARMCPU *cpu); #define PSTATE_C (1U << 29) #define PSTATE_Z (1U << 30) #define PSTATE_N (1U << 31) +#define PSTATE_EXLOCK (1ULL << 34) #define PSTATE_NZCV (PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V) #define PSTATE_DAIF (PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F) #define CACHED_PSTATE_BITS (PSTATE_NZCV | PSTATE_DAIF | PSTATE_BTYPE) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7d9b2762cf..4495433ce4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3435,6 +3435,77 @@ static CPAccessResult access_nv1(CPUARMState *env, c= onst ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +static CPAccessResult access_exlock_el1(CPUARMState *env, + const ARMCPRegInfo *ri, bool isrea= d) +{ + int el =3D arm_current_el(env); + + if (el =3D=3D 1) { + uint64_t hcr =3D arm_hcr_el2_eff(env); + + /* + * EXLOCK check is disabled for NVx in 'x11'. + * Since we have to diagnose that, dispatch NV1 trap too. + */ + if ((hcr & HCR_NV) && (hcr & HCR_NV1)) { + if (hcr & HCR_NV2) { + return CP_ACCESS_OK; + } + return CP_ACCESS_TRAP_EL2; + } + } + + if (!isread && + (env->pstate & PSTATE_EXLOCK) && + (el_is_in_host(env, el) ? el =3D=3D 2 : el =3D=3D 1) && + (env->cp15.gcscr_el[el] & GCSCR_EXLOCKEN)) { + return CP_ACCESS_EXLOCK; + } + return CP_ACCESS_OK; +} + +static CPAccessResult access_exlock_el2(CPUARMState *env, + const ARMCPRegInfo *ri, bool isrea= d) +{ + int el =3D arm_current_el(env); + + if (el =3D=3D 3) { + return CP_ACCESS_OK; + } + if (el =3D=3D 1) { + uint64_t hcr =3D arm_hcr_el2_eff(env); + + /* + * EXLOCK check is disabled for NVx in 'xx1'. + * Since we have to diagnose that, dispatch NV1 trap too. + */ + if (hcr & HCR_NV) { + if (hcr & HCR_NV2) { + return CP_ACCESS_OK; + } + return CP_ACCESS_TRAP_EL2; + } + } + + if (!isread && + (env->pstate & PSTATE_EXLOCK) && + (env->cp15.gcscr_el[el] & GCSCR_EXLOCKEN)) { + return CP_ACCESS_EXLOCK; + } + return CP_ACCESS_OK; +} + +static CPAccessResult access_exlock_el3(CPUARMState *env, + const ARMCPRegInfo *ri, bool isrea= d) +{ + if (!isread && + (env->pstate & PSTATE_EXLOCK) && + (env->cp15.gcscr_el[3] & GCSCR_EXLOCKEN)) { + return CP_ACCESS_EXLOCK; + } + return CP_ACCESS_OK; +} + #ifdef CONFIG_USER_ONLY /* * `IC IVAU` is handled to improve compatibility with JITs that dual-map t= heir @@ -3606,13 +3677,13 @@ static const ARMCPRegInfo v8_cp_reginfo[] =3D { { .name =3D "ELR_EL1", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_ALIAS, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 4, .crm =3D 0, .opc2 =3D 1, - .access =3D PL1_RW, .accessfn =3D access_nv1, + .access =3D PL1_RW, .accessfn =3D access_exlock_el1, .nv2_redirect_offset =3D 0x230 | NV2_REDIR_NV1, .fieldoffset =3D offsetof(CPUARMState, elr_el[1]) }, { .name =3D "SPSR_EL1", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_ALIAS, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 4, .crm =3D 0, .opc2 =3D 0, - .access =3D PL1_RW, .accessfn =3D access_nv1, + .access =3D PL1_RW, .accessfn =3D access_exlock_el1, .nv2_redirect_offset =3D 0x160 | NV2_REDIR_NV1, .fieldoffset =3D offsetof(CPUARMState, banked_spsr[BANK_SVC]) }, /* @@ -4083,7 +4154,7 @@ static const ARMCPRegInfo el2_cp_reginfo[] =3D { { .name =3D "ELR_EL2", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_ALIAS | ARM_CP_NV2_REDIRECT, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 4, .crm =3D 0, .opc2 =3D 1, - .access =3D PL2_RW, + .access =3D PL2_RW, .accessfn =3D access_exlock_el2, .fieldoffset =3D offsetof(CPUARMState, elr_el[2]) }, { .name =3D "ESR_EL2", .state =3D ARM_CP_STATE_BOTH, .type =3D ARM_CP_NV2_REDIRECT, @@ -4101,7 +4172,7 @@ static const ARMCPRegInfo el2_cp_reginfo[] =3D { { .name =3D "SPSR_EL2", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_ALIAS | ARM_CP_NV2_REDIRECT, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 4, .crm =3D 0, .opc2 =3D 0, - .access =3D PL2_RW, + .access =3D PL2_RW, .accessfn =3D access_exlock_el2, .fieldoffset =3D offsetof(CPUARMState, banked_spsr[BANK_HYP]) }, { .name =3D "VBAR_EL2", .state =3D ARM_CP_STATE_BOTH, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 0, .opc2 =3D 0, @@ -4383,7 +4454,7 @@ static const ARMCPRegInfo el3_cp_reginfo[] =3D { { .name =3D "ELR_EL3", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_ALIAS, .opc0 =3D 3, .opc1 =3D 6, .crn =3D 4, .crm =3D 0, .opc2 =3D 1, - .access =3D PL3_RW, + .access =3D PL3_RW, .accessfn =3D access_exlock_el3, .fieldoffset =3D offsetof(CPUARMState, elr_el[3]) }, { .name =3D "ESR_EL3", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 6, .crn =3D 5, .crm =3D 2, .opc2 =3D 0, @@ -4394,7 +4465,7 @@ static const ARMCPRegInfo el3_cp_reginfo[] =3D { { .name =3D "SPSR_EL3", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_ALIAS, .opc0 =3D 3, .opc1 =3D 6, .crn =3D 4, .crm =3D 0, .opc2 =3D 0, - .access =3D PL3_RW, + .access =3D PL3_RW, .accessfn =3D access_exlock_el3, .fieldoffset =3D offsetof(CPUARMState, banked_spsr[BANK_MON]) }, { .name =3D "VBAR_EL3", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 6, .crn =3D 12, .crm =3D 0, .opc2 =3D 0, diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index 46a3b911ec..56e117c01e 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -887,6 +887,10 @@ const void *HELPER(access_check_cp_reg)(CPUARMState *e= nv, uint32_t key, } syndrome =3D syn_uncategorized(); break; + case CP_ACCESS_EXLOCK: + /* CP_ACCESS_EXLOCK is always directed to the current EL */ + syndrome =3D syn_gcs_exlock(); + break; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178995; cv=none; d=zohomail.com; s=zohoarc; b=WAXV1O1Xiugb4Wuv1w72250zuvGzyDvvJtimP5mUnkEm8pa03hn3vKH4fikUqOV1ql4KPir7oCYMnlCv4EzvRh7lqcB2m87qvACjqbbvQunVm9bUL0s7O4CktitnsGre3WZYTKztmrFBGOzimOe8JbtVLE7U4X4x7BVtPsDxr0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178995; 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=hPINWJ4nV+k9v7TwnsVQ/3E97hW4E8lZ7vTBhJUQGXg=; b=EOLZwJycot/WnGF7L7XQ9/AuDvJSt69otWsuhv43v0TtFsmYsVGQ7Mm4LI+YlCdBaBAu/0OCuhr+LSETzzlUOHGyhPFnQIbJzB6ye77y7q7/Qph2PZ+6hvWFAxa3YAbe4KMyHZB3iEzr/J3jlLgZmC3JwV64y7X/8B1ojDDhecM= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178995065371.0267819349564; Sat, 2 Aug 2025 16:56:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpn-0000vl-0D; Sat, 02 Aug 2025 19:40: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 1uiLmw-0003ej-Ik for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:18 -0400 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmu-0005qI-Pd for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:18 -0400 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-61998205433so136681eaf.1 for ; Sat, 02 Aug 2025 16:37:16 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177835; x=1754782635; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hPINWJ4nV+k9v7TwnsVQ/3E97hW4E8lZ7vTBhJUQGXg=; b=fsZFQ9bIaigcSSUZeH6XfDA9+d8REqpMU5wTIDg4y9XXmWGlnHtGqnqoa+NaibUmcY BQljaH2QWWCnv6NjtVx6Dpo5lXDbgSFcx3X/z/gBgJQSHxlMqh10r0JvglX20KpGDkPa MpCXhaFCwO9VJpagHP+4TnkDPoaUNvdzt+tksDHKctVsWWdgz68Nc3i2CjWCftCew5qv MmqFPuTpP2vv1EdODxpcBunAPBoEzvYJqk1vUa7ngQdhdcsfexjyf67G79U8pDWN8hW3 Yv9jwx/WXLrdU9IEjp6et6RB54yp+qr3kOW3yvSaiRPxY5xq53TREcIxRtNQMsHlgx42 EQBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177835; x=1754782635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hPINWJ4nV+k9v7TwnsVQ/3E97hW4E8lZ7vTBhJUQGXg=; b=C6r+NnSI/QwUeaKGPIPZNeCI9dbE1v3bepHOCPix1XPVTimfIoeOu4LcBYmY7gBWCo 8KEOspOrSwUmmSg1/AoJXqcn45qix1bp0nIV4518Kp7eP5eDPs87pIHfC5CG8yCRhyi3 pVOv7pbDAHp9cZy5qYtb36mwhbahfALLSbjMwhuP96mEi2thGjD6fwKDWiuxBAMOaasY 7FK6ua//ltXFu54G+az5JNSayW/UfGXdH56jYZEpQkbcCtKbgv2qJlbk/ukEDxcdw9Gx McC8v8X97QXRxYzd21LVeqj3LQ/qJFSmranayJtNEr/HV/Akl5q4sNAK5r/uN+8bM4XM opWQ== X-Gm-Message-State: AOJu0YxzmP4o3SqUKvrTm+2jmUdLce11pYgMwNCsl+NmH9zDdcgosOEH 362tcjdnEBpEYXY0Vt8wF2hGYrv/BG+2nLy/rYphyA8g1+bPRu/go2aCUaahHLO8S50+yMk8KXY a23xXn5o= X-Gm-Gg: ASbGncvGPPUavxE/nF1xEepJI7eMbxk/ID566BBH7bntrI/SglWq3RNLUjoxmszlb+R jf2z/I4oez6DJM+POl95yu3Pc8OPqtJ97N/badqnO1zhVnaF1SqwnW6+8nuGp8zcZXfjlp7eP+j rDYA4krSNbbHiE8Mm5zadZ5KlDecAzAJkMjldEBRD7kC0ZxoutWypIscwt/vdGyke1XifcGw9xa UYUxYrwzS9/yQ8LUHC07byjnNZfe4H8RvYobI1xIbB3mpcLhSF9gc27iebVX1rq+NNSXUPj32Nd 6XjOrtuRzErZ0RNkAu+hYtcAEJV4eN0m8JKjhMnv/7YrP6kdOsaK2zCe3w1aSgSYzk2xn6TAt+V h1gzCJAIR/P9EzGlMVEFPwMMJfBf1cYRNX6QDIksKATKZN4gZeWIF X-Google-Smtp-Source: AGHT+IFKBO01QSsPJmGFPI6hp9qf4npZLHfLYe4dXDFxd5CVvvKIooEMSseNUlwPPfwkk9z9pzwLvw== X-Received: by 2002:a05:6870:b027:b0:307:b2c9:9f99 with SMTP id 586e51a60fabf-30b679b882fmr2247296fac.39.1754177835233; Sat, 02 Aug 2025 16:37:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 53/85] target/arm: Split {arm,core}_user_mem_index Date: Sun, 3 Aug 2025 09:29:21 +1000 Message-ID: <20250802232953.413294-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c30; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc30.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178997665124100 Content-Type: text/plain; charset="utf-8" Separate current to unpriv and arm to core mmu conversions into two separate functions. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 34d22cac8a..eaeafdf138 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -93,7 +93,7 @@ void a64_translate_init(void) } =20 /* - * Return the core mmu_idx to use for A64 load/store insns which + * Return the full arm mmu_idx to use for A64 load/store insns which * have a "unprivileged load/store" variant. Those insns access * EL0 if executed from an EL which has control over EL0 (usually * EL1) but behave like normal loads and stores if executed from @@ -103,7 +103,7 @@ void a64_translate_init(void) * normal encoding (in which case we will return the same * thing as get_mem_index(). */ -static int get_a64_user_mem_index(DisasContext *s, bool unpriv) +static ARMMMUIdx arm_user_mem_index(DisasContext *s, bool unpriv) { /* * If AccType_UNPRIV is not used, the insn uses AccType_NORMAL, @@ -130,7 +130,13 @@ static int get_a64_user_mem_index(DisasContext *s, boo= l unpriv) g_assert_not_reached(); } } - return arm_to_core_mmu_idx(useridx); + return useridx; +} + +/* Return the core mmu_idx per above. */ +static int core_user_mem_index(DisasContext *s, bool unpriv) +{ + return arm_to_core_mmu_idx(arm_user_mem_index(s, unpriv)); } =20 static void set_btype_raw(int val) @@ -3539,7 +3545,7 @@ static void op_addr_ldst_imm_pre(DisasContext *s, arg= _ldst_imm *a, if (!a->p) { tcg_gen_addi_i64(*dirty_addr, *dirty_addr, offset); } - memidx =3D get_a64_user_mem_index(s, a->unpriv); + memidx =3D core_user_mem_index(s, a->unpriv); *clean_addr =3D gen_mte_check1_mmuidx(s, *dirty_addr, is_store, a->w || a->rn !=3D 31, mop, a->unpriv, memidx); @@ -3560,7 +3566,7 @@ static bool trans_STR_i(DisasContext *s, arg_ldst_imm= *a) { bool iss_sf, iss_valid =3D !a->w; TCGv_i64 clean_addr, dirty_addr, tcg_rt; - int memidx =3D get_a64_user_mem_index(s, a->unpriv); + int memidx =3D core_user_mem_index(s, a->unpriv); MemOp mop =3D finalize_memop(s, a->sz + a->sign * MO_SIGN); =20 op_addr_ldst_imm_pre(s, a, &clean_addr, &dirty_addr, a->imm, true, mop= ); @@ -3578,7 +3584,7 @@ static bool trans_LDR_i(DisasContext *s, arg_ldst_imm= *a) { bool iss_sf, iss_valid =3D !a->w; TCGv_i64 clean_addr, dirty_addr, tcg_rt; - int memidx =3D get_a64_user_mem_index(s, a->unpriv); + int memidx =3D core_user_mem_index(s, a->unpriv); MemOp mop =3D finalize_memop(s, a->sz + a->sign * MO_SIGN); =20 op_addr_ldst_imm_pre(s, a, &clean_addr, &dirty_addr, a->imm, false, mo= p); @@ -4427,7 +4433,7 @@ static bool do_SET(DisasContext *s, arg_set *a, bool = is_epilogue, return false; } =20 - memidx =3D get_a64_user_mem_index(s, a->unpriv); + memidx =3D core_user_mem_index(s, a->unpriv); =20 /* * We pass option_a =3D=3D true, matching our implementation; @@ -4481,8 +4487,8 @@ static bool do_CPY(DisasContext *s, arg_cpy *a, bool = is_epilogue, CpyFn fn) return false; } =20 - rmemidx =3D get_a64_user_mem_index(s, runpriv); - wmemidx =3D get_a64_user_mem_index(s, wunpriv); + rmemidx =3D core_user_mem_index(s, runpriv); + wmemidx =3D core_user_mem_index(s, wunpriv); =20 /* * We pass option_a =3D=3D true, matching our implementation; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178469; cv=none; d=zohomail.com; s=zohoarc; b=T1hDLv5M9naxezAGC2JvKbDrlsC9Sc79gGO1eX4BDZIv5vnyVWNAORNkdjnGhs+E3w5vhQ4CDZQa/+RgVCIjodY+hMj4FHzGuEHwYeOgF4WMcvVIfW5OtTv5p6IMILf4YUHvKl8X32lbRhICaGDtz1XoJTOwejp6/eU5UwA8BnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178469; 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=AlJgHJEmHUYZe6YiGfVDRPRDT1LVN/rOSO+BbVvbmBY=; b=UCg51G9HuVeNPiVoG00wN7uEFRi0qe5uanCP/jZe1QXf5cykXAgbZSktphgAZr8TIHWBDJ4fzz07LKTKTTMR3OQ+nMbHu/W4gDPv5x1Q0JXDLDzNUaqxLpiPS0CFy9zQGILvH6ifZLJV7qTBfeo47FlqWyWGvfYsF9JOioumuAI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178469391288.334899896564; Sat, 2 Aug 2025 16:47:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpS-0008Je-Md; Sat, 02 Aug 2025 19:39:55 -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 1uiLn0-0003xm-P6 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:23 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLmy-0005s8-W3 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:22 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-741a6272c8fso141528a34.3 for ; Sat, 02 Aug 2025 16:37:20 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177840; x=1754782640; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AlJgHJEmHUYZe6YiGfVDRPRDT1LVN/rOSO+BbVvbmBY=; b=mMvL+atL40EcvhCjB9g6Ckn5/EgwJ6r+dvrSv5cS7t8zMtE6F78SK+x36hHJvpjMTt l5/zmDpTUd1b3LrVeX0TGRW8wyX3Ij2E2249dN+2ZgNmcHdO0xO6aD+y3QweAfHpLpu5 HlQ3w9UvNflfx0lS6mDQD2uGFI9Hr0j5QYSwu4wvVpFAlPvozPFl2BLOiFBDpXLLvZoN BAdJ19z2y3Id8EEWrPvR0k3hL4mTkxKcFulB8+bE9miOAKOMyl9/2dlSjkSxUixfxb0u LKATGmzpkE0pkU6VdNOmEjR8qOhYIOo4Dvhr5kgcN5dWGLSFgRW7k9djgijeN8DDxhJL MPdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177840; x=1754782640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AlJgHJEmHUYZe6YiGfVDRPRDT1LVN/rOSO+BbVvbmBY=; b=UFrePSIlQTnO3aj/TXINNlUNFXkWZDLhqX0tbLBlUZvku0dWAFT6HbbUtzUlX1plUB U72BpZn60cuBRfwzPhMVLwbxTtcaZ5L3xuEPmPqFCgPXs5jqDnhf/mOEC26qmYkT3z7D +yJVn+d4pOVaQCUHujFPjZX010MNXxg/dbZxBKoFEJc5D599m5B+ImzBIkBPT2+VwAY+ VQu1mf4ldkJUH2idOxCyqFhUwRqFwQfEVQROZC7pdZvfIih77gixh5DH5maQt2oXlz2V +JPqHGZzW9j0lYcdxYG5BQPEw9CjdMKWQ/5tovzFuVJ+7CL/GVSRPpREx51eigQGBudi g7uw== X-Gm-Message-State: AOJu0YxbqMZEn4/fgO8xnIOSyIN3p4fS6CpdUdpRK3b/sUpQy/WqUD+l qV/lcWQMJErLhKQ7UU/gDuuqP4VHsN1uSmlTqhMZ/nuL0Kv0CWgG9kUF8P6fZK31o67O4G3HOQd hGUNjpWk= X-Gm-Gg: ASbGncsv7xflI1vnTwaGGFhsN9RGyFtqvV4bwxkJWvx29+DAuUGd7DAfR8X0qf3oLNT EP7AjkybcC3et0QwNeTt27mej5dgvgtTPNIL7IpyITld3blbkyfQKWLP92ZlU8ZZqxc7pGXJjzc F6H3hjg4B3KgfQT4KH6bkt5t+M8W64F2PgPbZRZorPZo4SKF69+XmUNn4/GkWUgVMlg2gi6j4d7 /z61ZnOx5/QAhDL2rCNbxN8JEIc2XLiEVr4SN3v7zAxzXGs5/kAHoc20BNoS4Y93FlTF4aztKNA 5nqRjr7een+rEjhbZcgFgOsHQItFxf4uTF49vj7xkIbygcAUgVaaB0Zefl4sTnOkeVvD849Fj+H 8qOD6md2K+xH9sa8wbl4Qr1TlAkfpVDfe6+XBoHv3U/j4TH1OtrBX X-Google-Smtp-Source: AGHT+IEiADQITXKqrTtvLpkKeLd5ZP/13dXIR55ECySImnxNRI6Oo9cZt9NLGVlU4Oy/Vl5eB89F0g== X-Received: by 2002:a05:6830:448f:b0:73e:6313:3fdf with SMTP id 46e09a7af769-7419d284629mr2472616a34.16.1754177839784; Sat, 02 Aug 2025 16:37:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 54/85] target/arm: Introduce delay_exception{_el} Date: Sun, 3 Aug 2025 09:29:22 +1000 Message-ID: <20250802232953.413294-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178472016124100 Content-Type: text/plain; charset="utf-8" Add infrastructure to raise an exception out of line. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate.h | 20 +++++++++++++ target/arm/tcg/translate-a64.c | 2 ++ target/arm/tcg/translate.c | 53 ++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 1479f5bf74..a40cbd4479 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -21,9 +21,25 @@ typedef struct DisasLabel { target_ulong pc_save; } DisasLabel; =20 +/* + * Emit an exception call out of line. + */ +typedef struct DisasDelayException { + struct DisasDelayException *next; + TCGLabel *lab; + target_long pc_curr; + target_long pc_save; + int condexec_mask; + int condexec_cond; + uint32_t excp; + uint32_t syn; + uint32_t target_el; +} DisasDelayException; + typedef struct DisasContext { DisasContextBase base; const ARMISARegisters *isar; + DisasDelayException *delay_excp_list; =20 /* The address of the current instruction being translated. */ target_ulong pc_curr; @@ -365,6 +381,10 @@ void gen_exception_insn_el(DisasContext *s, target_lon= g pc_diff, int excp, uint32_t syn, uint32_t target_el); void gen_exception_insn(DisasContext *s, target_long pc_diff, int excp, uint32_t syn); +TCGLabel *delay_exception_el(DisasContext *s, int excp, + uint32_t syn, uint32_t target_el); +TCGLabel *delay_exception(DisasContext *s, int excp, uint32_t syn); +void emit_delayed_exceptions(DisasContext *s); =20 /* Return state of Alternate Half-precision flag, caller frees result */ static inline TCGv_i32 get_ahp_flag(void) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index eaeafdf138..d803c10ac7 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -10411,6 +10411,8 @@ static void aarch64_tr_tb_stop(DisasContextBase *dc= base, CPUState *cpu) break; } } + + emit_delayed_exceptions(dc); } =20 const TranslatorOps aarch64_translator_ops =3D { diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index f7d6d8ce19..c4dd3a747c 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -1090,6 +1090,57 @@ void gen_exception_insn(DisasContext *s, target_long= pc_diff, s->base.is_jmp =3D DISAS_NORETURN; } =20 +TCGLabel *delay_exception_el(DisasContext *s, int excp, + uint32_t syn, uint32_t target_el) +{ + /* Use tcg_malloc for automatic release on longjmp out of translation.= */ + DisasDelayException *e =3D tcg_malloc(sizeof(DisasDelayException)); + + memset(e, 0, sizeof(*e)); + + /* Save enough of the current state to satisfy gen_exception_insn. */ + e->pc_curr =3D s->pc_curr; + e->pc_save =3D s->pc_save; + if (!s->aarch64) { + e->condexec_cond =3D s->condexec_cond; + e->condexec_mask =3D s->condexec_mask; + } + + e->excp =3D excp; + e->syn =3D syn; + e->target_el =3D target_el; + + e->next =3D s->delay_excp_list; + s->delay_excp_list =3D e; + + e->lab =3D gen_new_label(); + return e->lab; +} + +TCGLabel *delay_exception(DisasContext *s, int excp, uint32_t syn) +{ + return delay_exception_el(s, excp, syn, 0); +} + +void emit_delayed_exceptions(DisasContext *s) +{ + for (DisasDelayException *e =3D s->delay_excp_list; e ; e =3D e->next)= { + gen_set_label(e->lab); + + /* Restore the insn state to satisfy gen_exception_insn. */ + s->pc_curr =3D e->pc_curr; + s->pc_save =3D e->pc_save; + s->condexec_cond =3D e->condexec_cond; + s->condexec_mask =3D e->condexec_mask; + + if (e->target_el) { + gen_exception_insn_el(s, 0, e->excp, e->syn, e->target_el); + } else { + gen_exception_insn(s, 0, e->excp, e->syn); + } + } +} + static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) { gen_set_condexec(s); @@ -8107,6 +8158,8 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, = CPUState *cpu) gen_goto_tb(dc, 1, curr_insn_len(dc)); } } + + emit_delayed_exceptions(dc); } =20 static const TranslatorOps arm_translator_ops =3D { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179058; cv=none; d=zohomail.com; s=zohoarc; b=NXxMrFt0f555s069Nq+8lNZRIM8ktPml/v0NnkWTnZDNUzgK8xpeZk5aDZgPnKw62m1QyrUECgztvEGvk1jfCJqQMgocV3uQAhFALN0zrXs0UUPI8LWzen/kSQ565kHM+kLEe+CsRnDB7ukO5OwRo0VnnhWh+iOqVoEPQaKho+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179058; 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=5UYaNg4HgCgaMfA5VDdSs+JLi614JTEFfBBOaKuI9nc=; b=FDWeY6qa0JaPlVrKrOdVjgiDR0jT3mcVf4kpndJw48TePslSxPoxyEeLEwwyu8o1M3x4mSXbSeORISOQotziy3av2D7PIh6nUcb/h26CShbeisgsuINrC7hQGsBSSoXclcOrvev9wwkU0sQePOxNPfyPy9MX0o7eezn9b5EJKLE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179058157743.3757119470578; Sat, 2 Aug 2025 16:57:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpQ-0008Az-8N; Sat, 02 Aug 2025 19:39:52 -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 1uiLnC-0004Nm-GK for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:36 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLn3-0005tt-VQ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:33 -0400 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-73e88bc38bbso1153130a34.3 for ; Sat, 02 Aug 2025 16:37:25 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177845; x=1754782645; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5UYaNg4HgCgaMfA5VDdSs+JLi614JTEFfBBOaKuI9nc=; b=Zsag0+7plfiu6d33/UfqWFJcGnjXQoG2ZoXDSax4OyJCszjI+m9HXoGPCmzcx8n+Zc wriBvLowjoJIC//fhcvBE+t546wzkm1+hRs8BFgHxCp8RGnTnaXOrl1M3fwlGWb/meHQ 63uH/rm+VXq7mw5mNIXZEWkiZueaTyqKdvesuqOKtyGrMK8xtTHsBNf4xoRJJGFVvlFO KnMUo18Rb/TFcKz8satbgzGugShfyp1ZJiRc64pKblErR+vMzReKLOu2xuOYMTLp2eCA VM1bSbkhMfkPV+ahsbZ2wzUiciadPGhrZYjSQMeHEqqr8H9wjG8YTMS82C7ihNPIMgT/ Ycwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177845; x=1754782645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5UYaNg4HgCgaMfA5VDdSs+JLi614JTEFfBBOaKuI9nc=; b=AItb7dBk7MfF+UxofrLAI4wLFOU7ChARUx5eabW93P2LOd79BbqPieTQ4aJ3Z1JKkX a5ZncRaRz4trI1ZeXARTcCPTppLf3Rp9dpoBiT/Y/yn+PVvmXbSX5ltFtilYUINcHFJw P9cHk4j33iRC7fZ82u2DBNCw+J95z/ww89tPlthFdIwtcyCOMHiomkCZjprE2zPedn9R wQBxDYppqgzRoWexSRkJkxDTh3pvsZRw4oMx7K30g77ZgMQ4sEppkkfLGATbQpeOJRGh d/A+8fuMBL+bblWuOZtmO+mWT6Yq5fXjq/lSNd9mKfO8QFfj8Cas1aUsCBlJPlA3gmE2 2Wrw== X-Gm-Message-State: AOJu0YyZpY5dui08H9yF59RS2KvUw+ldUOKWs6C2BoEAB9hqPCz4cb9w J8Pj8hr3Ea79O54VPA1o9cDsGVhCm7xEXaW1dlLJjHl7pquljuqITVBp+l0wkZllUMm+f79dkSy xE2Tv8Ak= X-Gm-Gg: ASbGnctV/ceLiclqUr5Ro9uvjoTljUucGqGOXgQabT44m9+J2HQglFjLpdotPzTlI18 kK5bh9HPfin9lNkxqrnDCCDgdY54y4OSd4hidR+t0KOL06bPMOd1sYfTzHMjTiwyohiPfv7t+Z6 1gDP7BWsgZakIqzD0yBarkQ8D/rTxmU7Zg9zOh6hZ7bpo2NOj1QK7BbuUfChyBXORUP3Ktla26d ofuvLCQm5XLpHhIDNkEpLnCdx6VujiC354oBuG3z3jY58Ln1FdttjspyQifI4odXUS7U4UyO1lv 5EzdSrkGSsrU7lrMJ19UPdaZpIXa0aUu6KCGLjscAvMrr0eTBKZGZ25yhbToZHYasb9JnOgjWUA fnpFwDcG/VRcgnpvtuwE0P1ExHxVViDwHDiXfYLAvkU+6V2qhadgi X-Google-Smtp-Source: AGHT+IHKIfci5+yeHTN2LwNVSz9wmI34VB4fSl/XWAJJxBkB6a8QEUPA3VHuZE7MyK4FgIUxsqGbqw== X-Received: by 2002:a05:6830:6686:b0:73d:6f86:f256 with SMTP id 46e09a7af769-7419d1f66f6mr2975789a34.17.1754177844928; Sat, 02 Aug 2025 16:37:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 55/85] target/arm: Emit HSTR trap exception out of line Date: Sun, 3 Aug 2025 09:29:23 +1000 Message-ID: <20250802232953.413294-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179058484116600 Content-Type: text/plain; charset="utf-8" Use delay_exception_el to move the exception out of line. Use TCG_COND_TSTNE instead of separate AND+NE. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index c4dd3a747c..f6fdfaa551 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -3033,21 +3033,11 @@ static void do_coproc_insn(DisasContext *s, int cpn= um, int is64, =20 if (maskbit !=3D 4 && maskbit !=3D 14) { /* T4 and T14 are RES0 so never cause traps */ - TCGv_i32 t; - DisasLabel over =3D gen_disas_label(s); + TCGLabel *fail =3D delay_exception_el(s, EXCP_UDEF, syndrome, = 2); + TCGv_i32 t =3D + load_cpu_offset(offsetoflow32(CPUARMState, cp15.hstr_el2)); =20 - t =3D load_cpu_offset(offsetoflow32(CPUARMState, cp15.hstr_el2= )); - tcg_gen_andi_i32(t, t, 1u << maskbit); - tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label); - - gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); - /* - * gen_exception_insn() will set is_jmp to DISAS_NORETURN, - * but since we're conditionally branching over it, we want - * to assume continue-to-next-instruction. - */ - s->base.is_jmp =3D DISAS_NEXT; - set_disas_label(s, over); + tcg_gen_brcondi_i32(TCG_COND_TSTNE, t, 1u << maskbit, fail); } } =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179122; cv=none; d=zohomail.com; s=zohoarc; b=nb1kkR57NIYhFmsAyZW6TiRKrgKnStYxbF1TIIIlr9MU2iZ/NDLVW4WhhRCxPjRkTdGQNj/KFftF2xqA0L5tfunZlFKsECF1AHCBdxaD7ZYDh7BGENqj11F+GCDowZY7Bc94iM6SczGwv9ntebzsntxH3LrPTk40QTMATm//Egc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179122; 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=1dB1cHT1ha866F85MzBv2WZgn+PHcRylb/+Q2tL/eLA=; b=B5pgyYqPD7YirAlO1UzslU4Q1K4UOfI4o7bTZIAWT45k7D2d75LJtRqiwAqHyeMxf0QGlcAVzr2J5AqjuwqfMONvScRcS2sVvaxqmFI3Mtq0WvZopXBKBaClK1O/xxe0sXU7Hr2fcKI1bftiCrzLg6/WZf2Cx0bndO1m7hm03IY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179122670161.26653970292318; Sat, 2 Aug 2025 16:58:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpu-0001Kp-JZ; Sat, 02 Aug 2025 19:40:24 -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 1uiLnE-0004QJ-NY for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:38 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnC-0005v6-86 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:35 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-7419f3e5f9dso856193a34.0 for ; Sat, 02 Aug 2025 16:37:30 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177850; x=1754782650; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1dB1cHT1ha866F85MzBv2WZgn+PHcRylb/+Q2tL/eLA=; b=lbSK57HoubrZylrWfx+AX3sR6T2Gx7wfHzgbU8PodysBStd0OAUui8KBMMm7PuuBTm Pnhnuqd6c/ISSfhuZMakdbKe8+7vJlXhK0PruqBGR848r9s42NJu+QvZLsOVDfLyt+ly 610b3jbOymw2OLBgNSaYGHBEgHgowURdD+gDbT0Rwr1G9e+Y9J7JyBQT6Whtr26tGsIk CF9JXmDFKhx63K0Odt89EhFMgM3/66klBwcK19VhsxaSXPgrYcDDO1fviFsHLOfMWc2f 3UCVA1xsSgX8US9L3vWUm+tV9uMiEoWKzLxaOLH/FviUqiy9BN6qOq0wMqLQPBXrHr/8 lEag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177850; x=1754782650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1dB1cHT1ha866F85MzBv2WZgn+PHcRylb/+Q2tL/eLA=; b=EJAD8W+hs3dgJL+lL97qdKU1F9YMuJyCiPjVri3/b5+UPrN9k6i3XvruSTjl/nGa53 CkLv7GXHsiS15/kimoQWWeGckYhKxXslTY61n1WmAz81z5M3ivcm9hczzY/Q6SAaOE6i PKlJjnIH3nv/F9tHSR0ysZqFJgIwf8GRbTizAXGf6mD/vkcctFfz6WTHh09sl+sC+bXY kKAHepnJnj5ei5Jbb5N9q5zaoXpURZbAafyd6dJ4B9CBZlnWHKddlCwMmRTtO846qHzV bibbgq7Exjd9CT1zw9GBXQD0SvriYWbrBZr9p1ogY7Elq2Sq0Ov9B5mXgqKWXWylcSJv PSzg== X-Gm-Message-State: AOJu0YzT3eABVFcDGlMIrWiKOkwljHjUfGOhW5KC6pSz+FRA0ISLh1Ms 95taOuR9mN1mxDrhrtIs0Anp2AvfX3ymdJxkI2znLoPlyUXc5O/7TxbG5gCEiOmsuK4BsYwUBsA l9ci5O9M= X-Gm-Gg: ASbGncuoxidRY0m/wjOXxCCNj7hqZL3g/N1cRc5lBgChJ7Orlvi6ADrnIK5yPVfaf0B WJ73xX5XpVf3c0NcBtNDgoO4IJTWLlBbAW7G5OLY8KLB2xaqk8e7mjRUiw4kd2ST8/6Azzbezib YuLOnNMYGyVgoQXIOGBzAGql9c7Ia7GeGDw13Yvyh4vrzu6JSoi9kTzIeHlmiF1SuQQX07znhfU tcP+JITI5xVmmNKbfhvDtjGg9ChwRk3vWaAHhimuzWYsADwbOwRPYz+Jmr0BXp6ogLXLuY/4LJM sEs2Av6xcbPEK4WPlL0cq7e2lueG3pGygfN4+hzYoWfGdoVNDsIfy9RfdZwmkKrnSKeEr0FBO+7 PljLEgkv0tisgbzb0uOCwMm6wUrwTVu5YpeebOs/O9ahg0nFxLrWw X-Google-Smtp-Source: AGHT+IEXhEhNo7CnpN0vQxN9axj3V2wowQr9vlAAiYarC9ZntpXwBeY2DEyV21f8+JOEyCRz+DmlIQ== X-Received: by 2002:a05:6830:3901:b0:741:213e:2212 with SMTP id 46e09a7af769-7419d1d4362mr2703195a34.17.1754177849810; Sat, 02 Aug 2025 16:37:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 56/85] target/arm: Emit v7m LTPSIZE exception out of line Date: Sun, 3 Aug 2025 09:29:24 +1000 Message-ID: <20250802232953.413294-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179145374124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index f6fdfaa551..e787acfc66 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -6885,11 +6885,10 @@ static bool trans_LE(DisasContext *s, arg_LE *a) =20 if (!a->tp && dc_isar_feature(aa32_mve, s) && fpu_active) { /* Need to do a runtime check for LTPSIZE !=3D 4 */ - DisasLabel skipexc =3D gen_disas_label(s); + TCGLabel *fail =3D delay_exception(s, EXCP_INVSTATE, syn_uncategor= ized()); + tmp =3D load_cpu_field(v7m.ltpsize); - tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc.label); - gen_exception_insn(s, 0, EXCP_INVSTATE, syn_uncategorized()); - set_disas_label(s, skipexc); + tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 4, fail); } =20 if (a->f) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179054; cv=none; d=zohomail.com; s=zohoarc; b=Pr/9pmADR7EpbxcfHWXUmrHTWMpMv5Bif6Z5V+QL4TPuY326g9+4fTrTAz/I8UQs/mCrDb7MpMeaYtcaKyrJaKQaA95q3xotyI44Yf4KmMAA6XNwk/QA4+ECFW5dQifIGmOkoQcINEeH6qK7ussxQKX/rc0TsYbprppCHNWE/4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179054; 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=NHjAyHFO49Xnsrf4XYBbOWKhIj7dGvot2d9bfnaFFuQ=; b=clFtOeru2+qzw2/PaMIL+SAEtoDmgLLAhGguA0B9muVjgf6iVlIcN5XbJJcX9JRjgyjqLsvFhWB3FO3ICSysaD7cblYQZSxfhHdv8+YNjghgE4jVTJE8D1W1UhVJhhNVH3RTg7rfwuNOI/a50MIzslUIzhy/Xg2kdHsnEZDhm3M= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179053941848.5822553650021; Sat, 2 Aug 2025 16:57:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLpt-0001Fc-FA; Sat, 02 Aug 2025 19:40:22 -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 1uiLnG-0004Rx-MU for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:40 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnE-0005vx-Ec for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:37 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2ff9b45aec2so1830276fac.2 for ; Sat, 02 Aug 2025 16:37:35 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177854; x=1754782654; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NHjAyHFO49Xnsrf4XYBbOWKhIj7dGvot2d9bfnaFFuQ=; b=fsbsQFxQlCuTgx7ql4nXivXeEXhxnXXDgx6w4lTmIDXgG921JGeJSFwYa+UkDzjZsx 6nri7E6zzalb9VhpftvYJ8fGW998es25jVyVQf4ynlStEGj+krC/pd67/6oRodEBwa0o ThS0WdxsVzrJo9roNVA9rCxwtKEjuIxCrxiD6XHMeyECLq3bkpgvFowyQgJPUXalAplk wCH3kcY5SpBxrzB5TJt35hWV0QKCD4YDpJBJS9PEZ6ZAyDPlhQSBNLDFwkV51drOh9k7 O3H9Ft8SP59xjzlXS2GEz6m1Alx5fitmzE/qZ+ErzIr+7pmaKuA1yekvO+8nRK5SqXN1 BV7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177854; x=1754782654; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NHjAyHFO49Xnsrf4XYBbOWKhIj7dGvot2d9bfnaFFuQ=; b=Xlur2FIhp+ZAASMGivAdrYVhj3gzPn0Nql4mPijqrj8a30AGdiO4QIUSU3Pr4NgkE5 I+o2zw3pLKZRwGot/tCFdZDj7uzHMWm4xxGMhE8epVEDCbyjFfiuqQK7ZfiAxtddPP2/ v8isafuRu05i51VJSuR9W9LLiWMw2kQndveA2aSu4YPCNN/jP/32S44qwGztbN+hCtQc 2B1EFbSrgwPmCWT96uGfQXphGVIbxDT0o0wcyoPewV2hrhmgR/kOYo6x49nD6h9tOIpd m7D9Ti0HkAguNZCWJwtbfKPAAG4/yXeu2KfxVuT7C0UYB50mbZ369RyadZNO7oLu6AW7 oJnA== X-Gm-Message-State: AOJu0Ywe+/Dplfboa6gGZwpi45WZBCZvyOLYnp1PQqrMXeimE0GRB0Rx TBbYmApwPSM/ebz7P8GbGLx1RmpKT+eIZ/3OZ5sZnKUocA6LLBU2RN1xdq+nldHMTTrxOjUXrEj S+yfDzyI= X-Gm-Gg: ASbGnctyA/pRSLriPJeY3ct99vDCYZ91wKPYp/xgIhbVKUGMxBo2VxYCM6FT5GC6XXE MyJkIAsQRX4nMTbaqyc48MXB0tKSsIGvtKEFCPFH1MBZxfYdKingHf+CX18R9H6sRXElN3SBrok rBWTOQ2rEfkJA1QO1Xiry2WVDI76ojS1JK3o5vIYBcaKduroKxMVNvo8Lej9kgivkvY3FnmmxFz z1HAuWnHvVu9cfBP1B8BDkYkSekiiILtftQXyEExzmeosPOr5LUER7GWp/RsewOV940Ey+CxaNG Xj7jTZSZ9wD7cLROH3Z7QuC1kfdTivBpluJ240NZsdLeIQGnTpSXwV4gNJp/kSoedLRByrQSRwA 6tuzf+mfbqQGNekIiTqWq4dF2v9M/rdchejF4CsOdqphdPVwW0TKR X-Google-Smtp-Source: AGHT+IF6DdBYDKadFZwvjh9hfAMUww+WfpFdDzFVvLzL40PrhzE93bF0/DnfvmnJr2WZbf2weTYPcg== X-Received: by 2002:a05:6870:e393:b0:2d4:ce45:6987 with SMTP id 586e51a60fabf-30b67730912mr2401969fac.9.1754177854545; Sat, 02 Aug 2025 16:37:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 57/85] target/arm: Implement GCSSTR, GCSSTTR Date: Sun, 3 Aug 2025 09:29:25 +1000 Message-ID: <20250802232953.413294-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179056127124100 Content-Type: text/plain; charset="utf-8" Note that CreateAccDescGCS() does not enable tagchecked, and Data Aborts from GCS instructions do not set iss.isv. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 42 ++++++++++++++++++++++++++++++++++ target/arm/tcg/a64.decode | 3 +++ 2 files changed, 45 insertions(+) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index d803c10ac7..e0548f7180 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -139,6 +139,12 @@ static int core_user_mem_index(DisasContext *s, bool u= npriv) return arm_to_core_mmu_idx(arm_user_mem_index(s, unpriv)); } =20 +/* For a given translation regime, return the core mmu_idx for gcs access.= */ +static int core_gcs_mem_index(ARMMMUIdx armidx) +{ + return arm_to_core_mmu_idx(regime_to_gcs(armidx)); +} + static void set_btype_raw(int val) { tcg_gen_st_i32(tcg_constant_i32(val), tcg_env, @@ -3902,6 +3908,42 @@ static bool trans_STLR_i(DisasContext *s, arg_ldapr_= stlr_i *a) return true; } =20 +static bool trans_GCSSTR(DisasContext *s, arg_GCSSTR *a) +{ + ARMMMUIdx armidx; + + if (!dc_isar_feature(aa64_gcs, s)) { + return false; + } + + /* + * The pseudocode for GCSSTTR is + * + * effective_el =3D AArch64.IsUnprivAccessPriv() ? PSTATE.EL : EL0; + * if (effective_el =3D=3D PSTATE.EL) CheckGCSSTREnabled(); + * + * We have cached the result of IsUnprivAccessPriv in DisasContext, + * but since we need the result of arm_user_mem_index anyway, use + * the mmu_idx test as a proxy for the effective_el test. + */ + armidx =3D arm_user_mem_index(s, a->unpriv); + if (armidx =3D=3D s->mmu_idx && s->gcsstr_el !=3D 0) { + gen_exception_insn_el(s, 0, EXCP_UDEF, + syn_gcs_gcsstr(a->rn, a->rt), + s->gcsstr_el); + return true; + } + + if (a->rn =3D=3D 31) { + gen_check_sp_alignment(s); + } + tcg_gen_qemu_st_i64(cpu_reg(s, a->rt), + clean_data_tbi(s, cpu_reg_sp(s, a->rn)), + core_gcs_mem_index(armidx), + finalize_memop(s, MO_64 | MO_ALIGN)); + return true; +} + static bool trans_LD_mult(DisasContext *s, arg_ldst_mult *a) { TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 4315ed8dab..d034d96b37 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -554,6 +554,9 @@ LDAPR_i 10 011001 10 0 ......... 00 ..... .....= @ldapr_stlr_i sign=3D1 ext LDAPR_i 00 011001 11 0 ......... 00 ..... ..... @ldapr_stlr_i sign= =3D1 ext=3D1 sz=3D0 LDAPR_i 01 011001 11 0 ......... 00 ..... ..... @ldapr_stlr_i sign= =3D1 ext=3D1 sz=3D1 =20 +# GCSSTR, GCSSTTR +GCSSTR 11011001 000 11111 000 unpriv:1 11 rn:5 rt:5 + # Load/store multiple structures # The 4-bit opcode in [15:12] encodes repeat count and structure elements &ldst_mult rm rn rt sz q p rpt selem --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178207; cv=none; d=zohomail.com; s=zohoarc; b=FY+K9OrWco500J/kupzZIEZxFJmhO8dU6unmpCb2/toOlqlCkJeIEV5qly9KkLx4PjYVCsWvozPswBSQpQYaK+GP7S5QXpawLZVWgUL5DW9Wv7SZHug1EyfK/a7zh5NIg0PsP4sf856ZEfSk8XyO44dJI6rRLkZObuQGwFQt+Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178207; 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=xwpjIKFwZpPOs1MrHyzWBavKC4efZpu/4iinDNh8yuo=; b=dOQrib193pT2iCaFtS+KvcAC9Hs8lalHlt3SVbnhBNKArHsGZ0thD/4HWl7311ET+Vu9gNvCg8i/ixCe0TSD7ZTTI0wYksBHyttoEpdYOY1cFthDnu9dLE0hzkPs2gy9k5z+ABNyKTPaaeubV47KD91IS6Hu3BKPwFkvTcJcjO8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178207257424.99486577765924; Sat, 2 Aug 2025 16:43:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLqb-0002Ks-Er; Sat, 02 Aug 2025 19:41:05 -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 1uiLnO-0004eu-9m for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:52 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnK-0005zM-6L for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:45 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-301a83477e5so2808814fac.1 for ; Sat, 02 Aug 2025 16:37:41 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177860; x=1754782660; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xwpjIKFwZpPOs1MrHyzWBavKC4efZpu/4iinDNh8yuo=; b=rXIm+/0r3ubRRQUiBCA7hbOb6f9URQQ9Pw0fNK3VtcfkbqU+iBsr7uWl7Gpj4+Qy4o Sj6R6GksV7PA0vnIkke39NVCLcWeFmZfLpMgO7N904ybMrXdOKIdSf4XppQ2QMyFBFXs N00OD5U+7R85XaLrfKDaDQToykh/hyQZQy3KwoivP9q5WanetZPBzdesMqwOP2SkZ/Eu dcrra41SfxnCM6uoXnEplj3cmFI6yho1eJiqrS2xeEhhGGM8ze1C8d4Mw8KyiJFhiaGu JCOo3/nI585TRDqPVIBi5UlH6glrI2dMR+5yr5HHe2jQv1iHXMA97SuL+HFXYxwVLZix F4LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177860; x=1754782660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xwpjIKFwZpPOs1MrHyzWBavKC4efZpu/4iinDNh8yuo=; b=FsrXvzXHXXwdy7wP0JB+P76ZfKrcruut04tAkdgsEGrCxdnCy0GKkrj0abNWBmhVCZ F2fEwaYweqqrftYK997If2kAXYn5fB2nYEzitHxuhdSKLoB04BidCD5+mK2p+3M+UPS7 izaHKZTMMQ4wBUGZuSx6FmVycXdgnMcv4Wtadz5HffZOEgyBgNyejqr5tjxirhxx1qeO jUuXpuFjwg3Lfpll1rrxCndFlVuFDonZ7tMdGfTIq4SWtOBdtpgOclAD0D87QMOzE+fn q99v9nOgtC3bjT0hIzSZwe8yLkNu1YEK9YZyTQQgBy+RdWDr/R+aKoT44dAAwIxlFYtJ Az3A== X-Gm-Message-State: AOJu0YzN4HGihAwJt9n3VlujY7iukl/vvRqX9tE3AbtcdSneholZtWXL yq44/v5o3sVmzOCQYFFuJEexOiGXxB+Zc/yeQGiRdyNHF4ugou/IKqxU4gtQVOoybzQtHh5fHdY QwTTVrMI= X-Gm-Gg: ASbGncsJn0L1h5Yn4btaImTh2c8cSZFrdpBj3t21fHZ0/Bf0Lj6tyyut+ng5Z1upgGU lTwjiKXoBE9iPilOzovCgjDHjnXxCj9tzI4eVmHxCOdPpNCmCpq4uGXAUqS3u3lRiJ9yIYc13ua P5mL7l8XgzDbziwHh0LrYvByUJavXlYEzdGZLTRvWVmp1M6ubDMdHwAbzzP5QuNo8otev737/08 U7gJjRtLBgQVlZ7sCRVF7OPNw4banmwD6eKhp/HpO8NgQMiP5N5J/wsA3GD15Z7u0pKuMMOh4rb 7AvtCrW5Ij31MgdNGnEOcrxNPgQDTYrwSQtfJNukRcVaWnWK5Cm8aWn9OK5IdnshU2SY8JA2AZr i4AgN04fURoyIiVBAbp2diOGTNaMaNCkhk5iwxItM40K74gciM8UW X-Google-Smtp-Source: AGHT+IEKH/KntxcCjvRSkAjlK8IZVrRHAV4Zkn0dscop5y38l99zhU4CyVGurC2n/eEMoUsim5N3uA== X-Received: by 2002:a05:6871:6a0b:b0:30b:8821:aba4 with SMTP id 586e51a60fabf-30b8821b1a0mr305076fac.20.1754177860403; Sat, 02 Aug 2025 16:37:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 58/85] target/arm: Implement GCSB Date: Sun, 3 Aug 2025 09:29:26 +1000 Message-ID: <20250802232953.413294-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178209019116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 8 ++++++++ target/arm/tcg/a64.decode | 1 + 2 files changed, 9 insertions(+) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index e0548f7180..45ff7bb0b2 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2072,6 +2072,14 @@ static bool trans_ESB(DisasContext *s, arg_ESB *a) return true; } =20 +static bool trans_GCSB(DisasContext *s, arg_GCSB *a) +{ + if (dc_isar_feature(aa64_gcs, s)) { + tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); + } + return true; +} + static bool trans_PACIAZ(DisasContext *s, arg_PACIAZ *a) { if (s->pauth_active) { diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index d034d96b37..e8b0ef07eb 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -238,6 +238,7 @@ ERETA 1101011 0100 11111 00001 m:1 11111 1111= 1 &reta # ERETAA, ERETAB AUTIA1716 1101 0101 0000 0011 0010 0001 100 11111 AUTIB1716 1101 0101 0000 0011 0010 0001 110 11111 ESB 1101 0101 0000 0011 0010 0010 000 11111 + GCSB 1101 0101 0000 0011 0010 0010 011 11111 PACIAZ 1101 0101 0000 0011 0010 0011 000 11111 PACIASP 1101 0101 0000 0011 0010 0011 001 11111 PACIBZ 1101 0101 0000 0011 0010 0011 010 11111 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178190; cv=none; d=zohomail.com; s=zohoarc; b=KbAKuEcNktQJCCyyYjIIybefzYvF59WEVp7eRsmw6bYDVN5jhD5jhkNZR/5lh67DBTYOcoEQyXPv91Re68yPGvYw/yI/EvELuUJ01kX8SlmUqKlBnoRrRDk3b2eCLhiJbQ125GubrJ+5fFi6oAGNNpw0RoOrch2qvp6BJpffVsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178190; 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=GheDyyaEk32LhV4XyorEEP22MgDBMiF8XtCyvBQ0qqg=; b=gjpKNwuUr4EjlDXYbalMcBYse26Vx3/JPlu6H1/QH4PK1KVJ+qUWwQGjhnx7/WhQo78CsJYsdLeWtpGqeRlBx/qNjH0PbntFU6n9UrNPQXXrAUiTZm0j7KaO5i3CFzu1f0vFjNQb7uyZaW74+h7A7AfoIxskyF+zyOrr4p4RISo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417819052639.9958929210793; Sat, 2 Aug 2025 16:43:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLrU-0003nS-Ja; Sat, 02 Aug 2025 19:42:00 -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 1uiLnS-0004fd-2N for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:52 -0400 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnO-00061J-Du for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:49 -0400 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-61998205433so136756eaf.1 for ; Sat, 02 Aug 2025 16:37:46 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177865; x=1754782665; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GheDyyaEk32LhV4XyorEEP22MgDBMiF8XtCyvBQ0qqg=; b=mPc1mzuUU9+LWB1FGOb8vsIjYPYzusCzYtX/aOiN2rta06AsxdPm4ULiFpwj0qQYge Sx/I7AATSi2KcIr1DsydmXfzzHYVjG8mu5BY2UkKO48xPgTGhlX/6S2gxKgXMcwQuK0r grpzAGlgfLmoruW24gCAUiKmqE9shPi9yVts25oSyLA++8HzjPQcOw1IxhQqWsHy9bXu RvM5BfjkMMkOVAmjd0nAoabG3Kd+ywjMglEKnEJ54fPKxj0mWEhHZqxBQ6KDHpkwv5Xa yknGnvjt/RuAH+6mowhgbItYo59qu6QjBMklxjoP2FGB1m6QQhspxw6HOqGuDSzNs8tc kISw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177865; x=1754782665; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GheDyyaEk32LhV4XyorEEP22MgDBMiF8XtCyvBQ0qqg=; b=jIp4iKBzwGOPCbp2uzwXsk7eewyQYH8SSOLiruhiOzqdCdw73dqcYqKk60nxxVJf5i liLtP2Mf8R+A0w4XBK/1pGDMs9p4MvQImzDoBRPG8qkSXEI1jkCMeH4Ow1f93EyMktdn aIGjQJtF0lsECiTHMtpC5xxEl7hExL9jbuC/P7dLIzVnvUG6ke+tZMrFSMqlNdI7dKxe P9jrVKdhBxxI8v8vvtADZPCl9QV2KhKDqBLNa8VGurlsOjhbP9z4eVnesSEJkyXHS0j9 YYl0YJSPUe0pSEcB8e+Qe+NfQENuhp8yRjUXuB1gd79FnPwH82W48xY7drM72mG4RqNS nUTA== X-Gm-Message-State: AOJu0YxZRfp09XM2i0kSwI2vWclLXGRf6sqiimvK94eTvIGx9hRsFHqP tH5nj1Ca/VhCvjbXNs3v4frnlu0L/PR1RHq8ZKJEiiTRbN3s7Te+epQo4cYX1GEMdo0/3wIGBwc FNNvmpjU= X-Gm-Gg: ASbGncvKpb6C8a7aLOKdyvsxdVgrjQxt0sUXFRKHQq4jNwTuj8OjC26qzZoCCWALDlB vls1ZrJqBapNPU+cgofXOpjZtzzTmil92c3GjkrLlcOboXcDkXd/RuDyIN01tAM1BD/ut+giY8m 7LJU+ln8nxNHbXpIE60MJFXwYZe0bR2+mQuv46bUmjE0S3l54Y8A9w6d3SreSV+3nzX34jVWZAZ B1pwmL54T0QTvObXP9Fk+4mlHEv4dFq2GIQ+ofVJ49aIaxeubGxuXASNCmPZkJMTEo9eNpJ420p hihdV4ZL+nnyyv4cl7vjronDMoIqbYK/aP+/KeDIu1bZ5+5axULG4X2W0H6V2kJX1o3qFS9DJRv MQXi5+cfdfvST7NqFzO4aXGAIlMso3q72biTWhxglLA5lgA6xCYr+BizPj6RQeDg= X-Google-Smtp-Source: AGHT+IFewqVC4SNhO6rrtWPibAa56fYiOEsq/jSUOXgufIElODhPoHbawwFjA+CSROR4yt4d5lYN5w== X-Received: by 2002:a05:6870:6196:b0:2e8:f5d4:6077 with SMTP id 586e51a60fabf-30b679b7e9emr2447620fac.38.1754177865220; Sat, 02 Aug 2025 16:37:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 59/85] target/arm: Implement GCSPUSHM Date: Sun, 3 Aug 2025 09:29:27 +1000 Message-ID: <20250802232953.413294-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c2e; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2e.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178193026124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 3 +++ target/arm/cpregs-gcs.c | 16 ++++++++++++++++ target/arm/tcg/translate-a64.c | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 15894332b2..93358e6123 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -46,6 +46,8 @@ enum { ARM_CP_DC_ZVA =3D 0x0005, ARM_CP_DC_GVA =3D 0x0006, ARM_CP_DC_GZVA =3D 0x0007, + /* Special: gcs instructions */ + ARM_CP_GCSPUSHM =3D 0x0008, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, @@ -861,6 +863,7 @@ typedef enum FGTBit { DO_BIT(HFGITR, DVPRCTX), DO_BIT(HFGITR, CPPRCTX), DO_BIT(HFGITR, DCCVAC), + DO_REV_BIT(HFGITR, NGCSPUSHM_EL1), DO_BIT(HFGITR, ATS1E1A), } FGTBit; =20 diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 9c06100d2b..38987372c9 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -33,6 +33,17 @@ static CPAccessResult access_gcs_el0(CPUARMState *env, c= onst ARMCPRegInfo *ri, return access_gcs(env, ri, isread); } =20 +static CPAccessResult access_gcspushm(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + int el =3D arm_current_el(env); + + if (!(env->cp15.gcscr_el[el] & GCSCR_PUSHMEN)) { + return CP_ACCESS_TRAP_BIT | (el ? el : 1); + } + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, @@ -69,6 +80,11 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, .access =3D PL3_RW, .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[2]) }, + + { .name =3D "GCSPUSHM", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 0, + .access =3D PL0_W, .accessfn =3D access_gcspushm, + .fgt =3D FGT_NGCSPUSHM_EL1, .type =3D ARM_CP_GCSPUSHM }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 45ff7bb0b2..a5810be2f7 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -420,6 +420,19 @@ static MemOp check_ordered_align(DisasContext *s, int = rn, int imm, return finalize_memop(s, mop); } =20 +static void gen_add_gcs_record(DisasContext *s, TCGv_i64 value) +{ + TCGv_i64 addr =3D tcg_temp_new_i64(); + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(value, clean_data_tbi(s, addr), mmuidx, mop); + tcg_gen_st_i64(addr, tcg_env, sp_off); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value; @@ -2765,6 +2778,11 @@ static void handle_sys(DisasContext *s, bool isread, } } return; + case ARM_CP_GCSPUSHM: + if (s->gcs_en) { + gen_add_gcs_record(s, cpu_reg(s, rt)); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178663; cv=none; d=zohomail.com; s=zohoarc; b=XhZLMuyso0mfhrpbd54bKSQZh+cZJxX8bt3apVNlF4Iy5WKPpiWOfkPM8ZZtcsmEUN8wK72nuypfxDX9idyZiU1okGLP9noFxD/NF+h5c2CoC69j92jx1Twvp33lIFaMONWTkr5/F1c/8hWWf3LKZdNBeIqAmDTbaj3B8pxpLDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178663; 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=q74k1doV7rOJwdP5GZXviD3TwtdNF1EHpji2am7Z7NE=; b=lufRP6V+AfmIkKomAENavXJbX1+SOsjUZsoyGzkroUsxPQbjdahuCx99/m53sKq3uLGsIbuLSC4fUJlkm5NchAjVeJJFlemuHQg0IHV21yi5d/tmbq8ePeQCUQHp6emjmSiqS+oyiwwyegWK6i1sH3otm60pFYGring9m5sR0Jo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178663509512.9797030627135; Sat, 2 Aug 2025 16:51:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLr9-00030h-GX; Sat, 02 Aug 2025 19:41:44 -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 1uiLnV-0004h1-7o for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:54 -0400 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnS-00062f-QY for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:52 -0400 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-741ab3e03aeso295882a34.2 for ; Sat, 02 Aug 2025 16:37:50 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177869; x=1754782669; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q74k1doV7rOJwdP5GZXviD3TwtdNF1EHpji2am7Z7NE=; b=ZQL8Kj07eEBwfWJtwtURAX/DDGreAnWOqSLo/MlZ5e0cCBEdCbGAdwUOiqEbpkUsaO KApC5mUn0u0Oua95VmwSgSsPofAh663o9HlFItkCSitIDcIUNX0YsfZBrhopyjQE503a TTwc+Qw1G1hAoPEQSfgMo/YzkwTk5hr9yFyrzn+1b3DmmGYUQp1bObIV1S83VVn2792D yXYsoOrrHsSz6L6NyT0xB2KmE9ra66rZ4R0i/vgbYOOZ2qfv2/wmXNxBVti64YAsE8iM fp/sP+g9LR7EgtXTj3ODuHUpXfTl1PvdoBG+JsRg/GAseBsEUDTLwe+AiUnhnmWaPJXM zKVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177869; x=1754782669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q74k1doV7rOJwdP5GZXviD3TwtdNF1EHpji2am7Z7NE=; b=aRHVlLRN08+GlPRm63QqMY8rdl70TeDcVB5ykazuf2M+TQ3MV5Mc3VdzmWS0kjkmGx 2jSB5Hy4Az9G5yFnyMpQ5V3CFYgplZ/CaguTNQd0unjtcM6RYy3Fk3dD8H5/Pyp/b9PU PMtVIuQ6dX1jRb8HOIyXhitdazKWzRgINNua1aMzJZxkwbEPJXQFaAiMfPLew/FCH+c8 TdTgh+LtSERAkoBrW3wtsYIlN3eNECOqmMKybL78mLX6Bh1E55FOBwYp+o9A7sesuDQA o4DNa1BuV8izspn9un1uBoy4x7bEMA8aQFoHKGtJElPeEfuL9VRXc9+8ZGNZ2qXKpPsi F3Uw== X-Gm-Message-State: AOJu0YzEUd1fEuxYY5SMrasFuPulBXqNcb29E2oHIwdK0X58YliBnHJH bt8jz7F3dYr+8khLIl3zc4H9P9jLKD5alIkJSc36zKF25kANPvncRtJc0taEp1Sp8vNg3fNuK5v 0Ky/Uw08= X-Gm-Gg: ASbGncshXed1g3ZvSrYKUC5iTiyCY23y/q3BDK5iAW8amkM67f+7s2PiaLrNWQXeT4g usI6NdwEk4mGM6yjtdA4nv7ZpAl64O/YKHUDaOBhlb5p3boXUzCYvHIou5zlMiFj5D+g7AtNmK+ L3thusBS0QHPQ4e3JHmnu0jhjlbic3d26jUmkg5XT6Scs7oNGIIFJcFQnIiepWhgQ9NcvR2kKe5 C2Sqj2ZWMbqA7irwUIXFv+9KJ2GY9kM0Hhc5qlIUT4Oov13QNqrVikkJoy7U/Gb/kyX+NRLIDoC 9tIsigmBvU8JCPAyoh4uC7ocfSYUEZMB6zaBs/Y/Czer1CfdtsEh7MuccfTaHDHQ0KP5ifdF3pc cuNwCZweYJhss9nhsEFI5Hajyga9ReW8IALXnYRgJXAb0W03xy3by X-Google-Smtp-Source: AGHT+IHZRjP/K3CZXIuG6xGZ2kt+rDHARV5zzqL0huNPKjDiVDU63pHJl/sFZoivCUaNwhZ65B1R9w== X-Received: by 2002:a05:6830:26d6:b0:741:9157:7179 with SMTP id 46e09a7af769-7419d2a511amr2394469a34.21.1754177869467; Sat, 02 Aug 2025 16:37:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 60/85] target/arm: Implement GCSPOPM Date: Sun, 3 Aug 2025 09:29:28 +1000 Message-ID: <20250802232953.413294-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32b; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32b.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178664631116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 93358e6123..9b19520346 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -48,6 +48,7 @@ enum { ARM_CP_DC_GZVA =3D 0x0007, /* Special: gcs instructions */ ARM_CP_GCSPUSHM =3D 0x0008, + ARM_CP_GCSPOPM =3D 0x0009, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 38987372c9..74a1697840 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -85,6 +85,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 0, .access =3D PL0_W, .accessfn =3D access_gcspushm, .fgt =3D FGT_NGCSPUSHM_EL1, .type =3D ARM_CP_GCSPUSHM }, + { .name =3D "GCSPOPM", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 1, + .access =3D PL0_R, .type =3D ARM_CP_GCSPOPM }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a5810be2f7..0279111cd2 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2502,6 +2502,27 @@ static void gen_sysreg_undef(DisasContext *s, bool i= sread, gen_exception_insn(s, 0, EXCP_UDEF, syndrome); } =20 +static void gen_gcspopm(DisasContext *s, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 value =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSPOPM, r= t)); + + /* The value at top-of-stack must have low 2 bits clear. */ + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(value, clean_data_tbi(s, addr), mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_TSTNE, value, 3, fail_label); + + /* Complete the pop and return the value. */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); + tcg_gen_mov_i64(cpu_reg(s, rt), value); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2783,6 +2804,12 @@ static void handle_sys(DisasContext *s, bool isread, gen_add_gcs_record(s, cpu_reg(s, rt)); } return; + case ARM_CP_GCSPOPM: + /* Note that X[rt] is unchanged if !GCSEnabled. */ + if (s->gcs_en) { + gen_gcspopm(s, rt); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178483; cv=none; d=zohomail.com; s=zohoarc; b=JSCvLQ0NWfBPgzuTAmOAXU84qInwAFEZp2jPQ5/VqhUXaWJSyqLxz+MGedIBgTcwzk4sGAzI5OZzISNj4gZAiS8/9GqYjJSyfrWltTEvjWMz/SejYSa+ML7NYaETppRQkc6PnP3c97B1X4/banEbRbt+oc+/H6E5khO8P3/WdZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178483; 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=KUfIu25DnJupV1Db/3EipBIrM+Ws30vdyubQzMZmUk4=; b=FPYoYxOdToFFEYavNgUFiYvupFsPVzdhno8zHjoDbKNFh8A/Rk/OYWnWu/8WO8Zq9OtSMdf8hIx/Vmw5ln/Dig1yVID2S4TGMrNqimgBeCy7+Id9diURMj2WbJcAoI9elaxXxVl+Wh65wQ4/Pr7cZwWzQ/Zo2dAcovXEjR+bYDc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178483975773.9361601531132; Sat, 2 Aug 2025 16:48:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLrS-0003eC-3A; Sat, 02 Aug 2025 19:41:58 -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 1uiLnf-0004tr-50 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:03 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnX-00065Y-4m for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:37:56 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-741a59f64c8so422636a34.3 for ; Sat, 02 Aug 2025 16:37:54 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177874; x=1754782674; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KUfIu25DnJupV1Db/3EipBIrM+Ws30vdyubQzMZmUk4=; b=v7XNIWFaM19gOBoXAnq2aLciuW0nVb4Rtka8tTkZUjfdXDDNaf1kiAHOigERhINAb9 5Am+uJXC992CSICxIkOxoc5hCLGO1ezTaYcjntp8BxsYvEZ/7f4UYd6qOMfVgToSFG9G 3GtxzIMgAIcVBuwvofeBMr6bKgjJSsrOlkI1+Y85jxhdd87R+y9igW8ETTu/6qCxiePG I8Oe44ZzmnGHmDGpiglYnSNzsQ8S4n9mbZCCo301H4szE6vQ+6Su99bDYr+uyh1p4Y/p 5+jSWo6SKyVPb9Z+NXDDJYxrWc6u4HDo5r3uhDPqxWQqtjsxdroHVezGUQgFG1zQ1dUK 7eLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177874; x=1754782674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KUfIu25DnJupV1Db/3EipBIrM+Ws30vdyubQzMZmUk4=; b=Gu0nB6aMtcB+/cCID8mbnW0JiNc5NpkfP3DE/QPvVH+NGmxplxd+eZJXH11yGSLf00 8BxO3Ziw0JkVo+2O0p9dCg5psinqSmL9J6TiAUwvty3Y6e49IWn/uYQEMlmGkDraDusB kjoq3B8x+k/M8shTvLvCuc23v1RO/VFQczariPPQe9hW61dmf2/3Zd4eYL/vvjHVfZLW K0K+z1wdwPe9/QijdxFHozCUMnBu1G9bhvjfIeVtG5BPWb/7ugWaM9QW5wc42E0D+iY4 kV5Z0CHDfItyQf+n+yyw/5nmB7EtNXz1JzufL2lZwIyxAbu/pauUZTHlDZWzWSShfijs KfVw== X-Gm-Message-State: AOJu0YzL6r0pKEkBbS3uzGmMXn0T7Nx8BDKh/bchBuVbokNUXCfzWsvo 5wd5Rhxj+QtpmwpL49mggr/eb8WK4CtK04ZkNApOxX0WRNEUbNCSpKMM6cB2JMAIevL+BaBNoel b1OKBV4E= X-Gm-Gg: ASbGncuDcJZk3Qpq9k4V20Jsb2A3haRlMUuBp6SMok/ddRo4VFbOTE6gbuXWRSJWicp cRgYKrldBSqd/8ubIfrr/FbbqdjafEKk9GztRxdiMQGQxXCDDKGSM9NufD6m/gRbUmb0AY6CF2q vTwkNGiFbeHqB0Do+YPClltBhAD+W8y8eBHGZNvqdJlT/Vy+O6xQhaDhGBcRVzYShSte+4Q6qu5 srJpRbCqw5Ks+QZXjjy6jQToYqdfop8ct3ix5Xpup94H47I04i0EQAR7TjvybRz1rfwbLqDdZ7r K7/En1oT0IH6RfCZOQ8e4YumzxBL9qxYWJrY3AFbsUMZAHr0e4mYEN5//7zzKxyab8wBZdCLYM9 1q/oFa51XmiWdJ/1DdX2lLurPGAaTXZB2c49yT4UVo1wDXct0BnzA2STm9i1kLN4= X-Google-Smtp-Source: AGHT+IFewyR+NKTxigr57KKZtJeEIDW4hl7Ge1LzWxNDgYZ8i8NeO1XFaJUo7A+HpnIc9eSgo2efMw== X-Received: by 2002:a05:6830:60c1:10b0:739:f3b2:80f6 with SMTP id 46e09a7af769-7419d284cabmr1592006a34.14.1754177874063; Sat, 02 Aug 2025 16:37:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 61/85] target/arm: Implement GCSPUSHX Date: Sun, 3 Aug 2025 09:29:29 +1000 Message-ID: <20250802232953.413294-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178485198116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 2 ++ target/arm/cpregs-gcs.c | 17 +++++++++++++++ target/arm/tcg/translate-a64.c | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 9b19520346..3d76afd20b 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -49,6 +49,7 @@ enum { /* Special: gcs instructions */ ARM_CP_GCSPUSHM =3D 0x0008, ARM_CP_GCSPOPM =3D 0x0009, + ARM_CP_GCSPUSHX =3D 0x000a, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, @@ -865,6 +866,7 @@ typedef enum FGTBit { DO_BIT(HFGITR, CPPRCTX), DO_BIT(HFGITR, DCCVAC), DO_REV_BIT(HFGITR, NGCSPUSHM_EL1), + DO_REV_BIT(HFGITR, NGCSEPP), DO_BIT(HFGITR, ATS1E1A), } FGTBit; =20 diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 74a1697840..6f25543426 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -44,6 +44,19 @@ static CPAccessResult access_gcspushm(CPUARMState *env, = const ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +static CPAccessResult access_gcspushx(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + /* Trap if lock taken, and enabled. */ + if (!(env->pstate & PSTATE_EXLOCK)) { + int el =3D arm_current_el(env); + if (env->cp15.gcscr_el[el] & GCSCR_EXLOCKEN) { + return CP_ACCESS_EXLOCK; + } + } + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, @@ -88,6 +101,10 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSPOPM", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 1, .access =3D PL0_R, .type =3D ARM_CP_GCSPOPM }, + { .name =3D "GCSPUSHX", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, + .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, + .type =3D ARM_CP_GCSPUSHX }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 0279111cd2..732d65f54e 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2523,6 +2523,38 @@ static void gen_gcspopm(DisasContext *s, int rt) tcg_gen_mov_i64(cpu_reg(s, rt), value); } =20 +static void gen_gcspushx(DisasContext *s) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int spsr_idx =3D aarch64_banked_spsr_index(s->current_el); + int spsr_off =3D offsetof(CPUARMState, banked_spsr[spsr_idx]); + int elr_off =3D offsetof(CPUARMState, elr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + + tcg_gen_ld_i64(addr, tcg_env, sp_off); + + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(cpu_reg(s, 30), addr, mmuidx, mop); + + tcg_gen_ld_i64(tmp, tcg_env, spsr_off); + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(tmp, addr, mmuidx, mop); + + tcg_gen_ld_i64(tmp, tcg_env, elr_off); + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(tmp, addr, mmuidx, mop); + + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(tcg_constant_i64(0b1001), addr, mmuidx, mop); + + tcg_gen_st_i64(addr, tcg_env, sp_off); + + clear_pstate_bits(PSTATE_EXLOCK); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2810,6 +2842,14 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspopm(s, rt); } return; + case ARM_CP_GCSPUSHX: + /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ + if (rt !=3D 31) { + unallocated_encoding(s); + } else if (s->gcs_en) { + gen_gcspushx(s); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180009; cv=none; d=zohomail.com; s=zohoarc; b=ICWR5y5fsj1nFid5b1gVFjS1RouC9JWrw5CI80T5pVtgVvjxa09Zq3zeXnNlBRQn9SdimyTO5MjfxYOvwgZL27MQH6XYAbh+kICISgG6gq685Inp4pWMHdOV5L/U0tmleVKXf7B8a6dCklURcMUWM0nfQGLkLh7riM+djdYIbd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180009; 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=fFYULMXdmph1Fy+p8frpDVXsvxY/1zoPtIAPaTVVJgc=; b=gJ+rvsnX9vtXKNrQKMZDLSWO/h/HEd0bNYTtB7C/Cfir1G5PzQqXbGWhYgKUeDA7suR3m2Cme9rWP3tKwlfGWMz5wgMG52vi80dgRh5T01AOchjojto60xplSToC81jvm+2RcI4f9i4KNzoPSwiJcT22jbFW4YbhOJnPy5zOyn0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180009433232.15041688172641; Sat, 2 Aug 2025 17:13:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLrM-0003Jy-As; Sat, 02 Aug 2025 19:41:52 -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 1uiLng-00050K-PG for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:05 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLne-00066V-Rk for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:04 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-74177394e77so2382715a34.0 for ; Sat, 02 Aug 2025 16:37:59 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177878; x=1754782678; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fFYULMXdmph1Fy+p8frpDVXsvxY/1zoPtIAPaTVVJgc=; b=eZHyBC6Ol4S5SOsuqRI8KpcarId61sOhsEIghXuiNlf77kpYRuidi+hJNpyw6s7fWF vd/4Lw9EYDfw1KvvIVCBXB0b1RIMWqvBZBsQHNAg5WUuC55xLrKm21wVEIgeXbF15Omj q4KZpOBlYd4Zp9lvQbTF2F2LQ9yg14fjeAYtWIALxL1BgkflUerUKpKa728I/7k1tKeQ WlJ27HLDEmeWEuAQ617SXw3K9ShHlwpIip72U0boa5ixVenv9HYJWR1+Vfrtet31zADU fufPob0AmA0lP4Gvxv1IcaLDhk5G0yotfpy8W1JMQ2toJjLV+5KaLfiC/EXxClKUP4iQ ldOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177878; x=1754782678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fFYULMXdmph1Fy+p8frpDVXsvxY/1zoPtIAPaTVVJgc=; b=bwNKYrdxD47zhwYkCUagh8wF5YTxuGTyiOp/KIfDPP5PRnZGFstz9e0VpdPJWe2o9D P6amRKee0WRUoy+ATg3LhD8geoRafI5pNM94lRZnUpeHCVmgBLMy7VocGIqJzZHX2l2L X30D7cWAskra6Qbm5b6Y0AXwKcM2x1TD0W58WfGXKmA9fmBAJZeYS6xg9KSDO8lLzcDy HUVVJthsgd98fcctBuqvJor7uBYmwwi+XMTjoBAONfCPn4vEeo8oDwL71IE5S7i/snGb T59CExa0osKN3D6xZXfyjdS6E2QxhL7mXj7zzd6adVPDQLECfBGNund4V0ow6bBHiXnK aaoQ== X-Gm-Message-State: AOJu0YxzJ0g4VyB+Bq1/PfpAkshhDg7mM0wFE/yp/dVRmPnONiqAfDlS hC6PUkr1isSauDGuv4IATfrZISaFAToTLftD2wobtb8a1ly2jCRbsvdnrTQ0NbOYgrP7KLUwOA9 itQOjUUw= X-Gm-Gg: ASbGncsZt1+56908IwMR8OVJvjVd0l45PcorweexDh2eY5JLyvi6W7qUqFeQpqFIMAH owICQzQXVKYkXfRXliyv2pM0BuzbrqMLxZWMHA9A7d8iJSdfZ2u9J5Cely4X6JjNzmbcBVoaXNg +gEWLm/eECo/hfbyQtaob3t1RWgaotYKuHOe4eK/ag6LgXYNzKIZIcWlK5MTDGzwM97cZRGNgAu eQChPCu3c4nYg45K84/idqFqBgthhElPpdRJm1Ccht2nI+AuVe1oRQ9Nan8h8VDckflaGJbhAWT jeeLDa1PqT+TGdGAvuPis+VwKviTSBWwx3fLGlgAZXPWM5SfbtRvPsKXTRx+ScZ7P+UxPCa75U4 KoDF1FRgvA8vMUuYixZYkOMrw2VH6WwzqwVdfylukuVi4V9us+Lvn X-Google-Smtp-Source: AGHT+IG7VwlykyFJ/WATYH+//r8SW5N5oBZkPQAbHJep5aZRzhj1BMqX7pl8Dfi7F8pJfavlScZLuA== X-Received: by 2002:a05:6830:2b25:b0:72b:974f:de49 with SMTP id 46e09a7af769-7419c638ce8mr2984751a34.7.1754177878351; Sat, 02 Aug 2025 16:37:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 62/85] target/arm: Implement GCSPOPX Date: Sun, 3 Aug 2025 09:29:30 +1000 Message-ID: <20250802232953.413294-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754180011163116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 3d76afd20b..084ea00e51 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -50,6 +50,7 @@ enum { ARM_CP_GCSPUSHM =3D 0x0008, ARM_CP_GCSPOPM =3D 0x0009, ARM_CP_GCSPUSHX =3D 0x000a, + ARM_CP_GCSPOPX =3D 0x000b, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 6f25543426..2bdd41c796 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -105,6 +105,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, .type =3D ARM_CP_GCSPUSHX }, + { .name =3D "GCSPOPX", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 6, + .access =3D PL1_W, .type =3D ARM_CP_GCSPOPX }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 732d65f54e..773ed3044d 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2555,6 +2555,35 @@ static void gen_gcspushx(DisasContext *s) clear_pstate_bits(PSTATE_EXLOCK); } =20 +static void gen_gcspopx(DisasContext *s) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSPOPX, 3= 1)); + + /* The value at top-of-stack must be an exception token. */ + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0b1001, fail_label); + + /* + * The other three values in the exception return record + * are ignored, but are loaded anyway to raise faults. + */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2850,6 +2879,14 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspushx(s); } return; + case ARM_CP_GCSPOPX: + /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ + if (rt !=3D 31) { + unallocated_encoding(s); + } else if (s->gcs_en) { + gen_gcspopx(s); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180196; cv=none; d=zohomail.com; s=zohoarc; b=LSTTGXvYrlGBbUO/UQwbzJZ+sWmKuJmdldrE3eSzRLOkzHjJI8UU8CVbvkiqkZt+ITosASOW+UZio763vVWI/ex45f3fwqh/+MH/IB/U56gmi4rOGyoHFS9Hk/fPi33XgLlSEloMDlm1uh55pujwyy7dv2FbIHPZiWnP6L6hnwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180196; 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=IyjvE7tLoNvvOOPaDRanKy/MG4hCXN6uGYfK1f3CD2s=; b=OXlzMXivdKlsnvbT9dYEj4M5Ip23qrT1hYQjV0dNdM0PmuI+JMbFs7wRqnEvJaKfNdrzUK5g/75r+HNCt4Z7SXbw46dL++cC38B6OG44xPPZHx+Q6DX015i20ykD/KyDFvKhNGd8gfHMOglzodchsKmrG3PF7QQHcrJWDWLGBis= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180196729823.490121904995; Sat, 2 Aug 2025 17:16:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLrd-0004Hs-Af; Sat, 02 Aug 2025 19:42:11 -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 1uiLni-00054B-DF for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:06 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLng-000685-7s for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:06 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2ea34731c5dso2676116fac.0 for ; Sat, 02 Aug 2025 16:38:03 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177883; x=1754782683; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IyjvE7tLoNvvOOPaDRanKy/MG4hCXN6uGYfK1f3CD2s=; b=Wg7iVRtNprMX/1N5QnXTD3tuXzqdWaZd725NHL0wnGJDGheMF5QXCeYlBmX/UQsSdl At5mkDCpIVEVPBKl6/hW24fblJD/rYduNhF78LC5ci1tqPL2lHuH8r8A3F2tRvsCQtoS kX1zh5H2588bS86Mb3BLTmAjoWIQ50F8EmNtiLM7a7WGKgRvplQ00y1pHhhXTeZXWUAt j56Cn4sE9iezCNp9+0lELoKKAUvbtQslx/lRgcOB9qtJB3Kj/dx0cq9A476L/JezcZNa zAJ088xpjViDSm3n96/nxBKfpguyr+wL4mZWrRWpe0kqAC2oZIxz/gxgLuA39Me569GV IRPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177883; x=1754782683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IyjvE7tLoNvvOOPaDRanKy/MG4hCXN6uGYfK1f3CD2s=; b=cKxIU6wiNSE5Xz1lH+8uzmNuUdFhBxAEC1Ahggwt3FGw3stIilhVpSffmqGhBg/Sj6 1OVG0rV0b89hYFk6fW0PpNZCAKiij7ZkJq51ZPk3KB25IeiJR/VK+qtq6FvKXsFFppKV cnpYpq8CfkUcuQzYwSi1wLP0yRfk6BQJuyy7gM1cZTaoJGYnV5TlaVcTr2IsUhHYJMbM R11Pf0BfF5Km7g258crtwE07BEt46MHdZpySp5j+inJywuLbpOwuKNhiNYeEkvgwHLAr AnjsBxYfa6vkVjUrixP24BF1Qk9xSp6KAh1qvnF6+MUiM9vSahypURsNBhKIT5tPPbrV ri9g== X-Gm-Message-State: AOJu0Yxdmnz470aNvHMxoMKqBWSdRNK3Nl6hIscFbmmPFaeJ6CmoSRx6 pUMRHfm/rNUmgU2khJlkKA1WCF8aWWzpfHWdwS+axc46ei3mzolj+naXRzu9M3lypOfF++9/GFd vGbHXYd8= X-Gm-Gg: ASbGnctGcLRRzOE3APB9mYMB4740PDDSJX3J7bcGVK8TFI9OB/ZBnTJZZREZ9exCsGY H/7eCgmP/as380IMWbQPZy00vSiPobp9RO9eEePPh6mCbvqXAinpYVQbCAspcNhXjFXgGsPI/2V /vTQOo/EZvayMIL5dqU/sc7ZAcaEfTFnD7yQHGRw26e/mQFC59XTU3nwgm6vIhD3U1TdDy35wkX bkAK914dSuxlXQKPCH6NffdClis9kWZEiI4bq0v6to579sV56u1ymS66Irs7llWJuq4EbSk6OLq YV0jejQ/y/bxzBwsB4E7vpeqjzGW1VyjE3gu9y83xIOS19qV+5ilLg07wIP+a3UoylwEQw4INBg QsSnzaQeUCyP/Vxg10hvuVP2dRDhMN6/GlRzk+f2PD/XpMIXdF15m X-Google-Smtp-Source: AGHT+IGQTKEiQuPwZkmJFElGWsiEZ7SaKWPLGf3LS/p1YtViZ0Q8a0+2WSXNtXXeolQTafvKVSFTdA== X-Received: by 2002:a05:6870:3750:b0:29d:c764:f873 with SMTP id 586e51a60fabf-30b67ab1096mr2769470fac.31.1754177883036; Sat, 02 Aug 2025 16:38:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 63/85] target/arm: Implement GCSPOPCX Date: Sun, 3 Aug 2025 09:29:31 +1000 Message-ID: <20250802232953.413294-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754180227168124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 17 ++++++++++ target/arm/tcg/translate-a64.c | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 084ea00e51..392a0a264f 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -51,6 +51,7 @@ enum { ARM_CP_GCSPOPM =3D 0x0009, ARM_CP_GCSPUSHX =3D 0x000a, ARM_CP_GCSPOPX =3D 0x000b, + ARM_CP_GCSPOPCX =3D 0x000c, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 2bdd41c796..ab53a4314f 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -57,6 +57,19 @@ static CPAccessResult access_gcspushx(CPUARMState *env, = const ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +static CPAccessResult access_gcspopcx(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + /* Trap if lock not taken, and enabled. */ + if (env->pstate & PSTATE_EXLOCK) { + int el =3D arm_current_el(env); + if (env->cp15.gcscr_el[el] & GCSCR_EXLOCKEN) { + return CP_ACCESS_EXLOCK; + } + } + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, @@ -105,6 +118,10 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, .type =3D ARM_CP_GCSPUSHX }, + { .name =3D "GCSPOPCX", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 5, + .access =3D PL1_W, .accessfn =3D access_gcspopcx, .fgt =3D FGT_NGCSE= PP, + .type =3D ARM_CP_GCSPOPCX }, { .name =3D "GCSPOPX", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 6, .access =3D PL1_W, .type =3D ARM_CP_GCSPOPX }, diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 773ed3044d..af91b7f95f 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2555,6 +2555,56 @@ static void gen_gcspushx(DisasContext *s) clear_pstate_bits(PSTATE_EXLOCK); } =20 +static void gen_gcspopcx(DisasContext *s) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int spsr_idx =3D aarch64_banked_spsr_index(s->current_el); + int spsr_off =3D offsetof(CPUARMState, banked_spsr[spsr_idx]); + int elr_off =3D offsetof(CPUARMState, elr_el[s->current_el]); + int gcscr_off =3D offsetof(CPUARMState, cp15.gcscr_el[s->current_el]); + int pstate_off =3D offsetof(CPUARMState, pstate); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 tmp1 =3D tcg_temp_new_i64(); + TCGv_i64 tmp2 =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSPOPCX, = 31)); + + /* The value at top-of-stack must be an exception token. */ + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp1, 0b1001, fail_label); + + /* Validate in turn, ELR ... */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_ld_i64(tmp2, tcg_env, elr_off); + tcg_gen_brcond_i64(TCG_COND_NE, tmp1, tmp2, fail_label); + + /* ... SPSR ... */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_ld_i64(tmp2, tcg_env, spsr_off); + tcg_gen_brcond_i64(TCG_COND_NE, tmp1, tmp2, fail_label); + + /* ... and LR. */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_brcond_i64(TCG_COND_NE, tmp1, cpu_reg(s, 30), fail_label); + + /* Writeback stack pointer after pop. */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); + + /* PSTATE.EXLOCK =3D GetCurrentEXLOCKEN(). */ + tcg_gen_ld_i64(tmp1, tcg_env, gcscr_off); + tcg_gen_ld_i64(tmp2, tcg_env, pstate_off); + tcg_gen_shri_i64(tmp1, tmp1, ctz64(GCSCR_EXLOCKEN)); + tcg_gen_deposit_i64(tmp2, tmp2, tmp1, ctz64(PSTATE_EXLOCK), 1); + tcg_gen_st_i64(tmp2, tcg_env, pstate_off); +} + static void gen_gcspopx(DisasContext *s) { int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); @@ -2879,6 +2929,14 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspushx(s); } return; + case ARM_CP_GCSPOPCX: + /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ + if (rt !=3D 31) { + unallocated_encoding(s); + } else if (s->gcs_en) { + gen_gcspopcx(s); + } + return; case ARM_CP_GCSPOPX: /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ if (rt !=3D 31) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180081; cv=none; d=zohomail.com; s=zohoarc; b=NJnh1wIOCZM1NW4eyUxVtJk6DLaL0vsiqMYmoyyMLxPLnLsm7fIoRseNVMy6jCkiyttvkKsVPLRgc2s6SX3dLvNGQ5UJefnxIDKZWDgBxRr8WRgNOFpRjY6AMlxhQNZjNwLKTXgk1iWlaaJcjmLXBm/fXLwF19lA3nGeeOUZrJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180081; 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=kLrPSxlaNo5aIzGG0k94HX9nSYOrYMBFtOF/2lNnhCA=; b=WSZUlDZ0dfxxvFjrd5G0KTFG3DL1MuoL4KMhVHwBv7TPfHkmmENlqZNWJN7AIVvYdU5FlWsD8Mwa3rVOu8mSoCMP1okYKDSMpmgcTnkj1C1MsUNN4xFAmdlEjArW01b1nP3RjRDcbiGurIGWeGd3KBX14eYgygVDa37/7vnSB98= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180081361850.3117711008282; Sat, 2 Aug 2025 17:14:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLrV-0003uk-NR; Sat, 02 Aug 2025 19:42:01 -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 1uiLnm-0005H9-97 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:10 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnk-0006BP-Jp for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:09 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-741518e14d4so938312a34.3 for ; Sat, 02 Aug 2025 16:38:08 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177887; x=1754782687; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kLrPSxlaNo5aIzGG0k94HX9nSYOrYMBFtOF/2lNnhCA=; b=ILuH8adg/YsYV5GhLJA3MSheigYaEPmbvlSd+cVLXAQhqCHy5VPicTMemOwKP1yPGE 4ahQCF5fnbY61epahJjJ3LdtFNxiolSw0TKXpmx/s0JI/Z4DBuU0LoIZrTRyJ4GtkAGt 0m314dlfqp0Ja03uNN9loevL0u2b+/ow9lBVsZkKi0hMUc3QysiwobUiLEv/z64kk0rI 9JrhaoIxw5NIf6c2ooqAKbNNB9Oq/8SDwgbP8qiWc2AVMJK/26JKLS+MVJ/M4bbO9lra Uohx/gYc99U0wwiHBGNqPP6kms51JY7sd0Rp9AxDAHWjjoh+CA+901WEso+Yw/F6I7mm Z20Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177887; x=1754782687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kLrPSxlaNo5aIzGG0k94HX9nSYOrYMBFtOF/2lNnhCA=; b=rIBOoYcnynflgj8i3k+MmX7ye48048WpFS/f9eSJX0XUMfez7zUM7aV3qUQYUJAeFO SJlNbLd+lh4lwZjlgY0mfUey212R2b+VpzKVfply2sdYh5sa4vkRBM5FDG6Ss1s7TQ+u y9ILdhbdXVBylslaXyFJ14rP+7K4YbiCOpTmyjd9PJRLVsDaO1QKWJ0uzxCrAOAUmGFH f+kJZt36MUNJ++xZ2QKVuSGdaIUjVpsLZfdltoGHO4Kzp8rrJtCPSuoEUeZS8SCxWiMo uPwGt3UXOdhoLPaxKH+guF/pMhEyB2hlV5fs8CgN+UIavO14qV0uOkKHHbGU8W2dhx7F 7xJg== X-Gm-Message-State: AOJu0YyM8gZ8xbN9TMAUUl9O7y3jzhxm6/f4G57M0snJj/sSIjvfK0kn 8HvO7fKJKDkmsqRIFqHi+XedOQrRwyNa+loEG5sfJxHzJfE+M6mRCIUsH1McypGl9vT8s3hnXkt oIAS5sb0= X-Gm-Gg: ASbGnctJpb6VbO6FwREI7GPJVXOmuyzTg3z/po9h809efd/zSByaeEOZUyABR/zcZxM Hd7EardrKPdASoOUi87z4npW97wYcaVF+vBKbX7x5WHeDdU6OYhagOy7kD8apfwEuV+oiGeMcMR kCY6II0Jo1y5kYFznofknksz9gYzVFzuIuF+ODppp303SHtFxt2lKK0lcn71PDSiH7m8bJe7EcT jzfiLiALBg33z0awzssZax6pdMaHf+mLtZ46Ct3vPVXVekK2ATv9y9REdSqx7ipkHmU5kXcDgCp NN7togkl51umJc6+3H0/dmSf4EngPQwzg7R57H7PO0Uw9J9qBqYn389CDg3BRgfQ/2Ragb60pYn GmiDvi9NpIPjnfxqaYsgzB7irW5lMCOxYRBLqgUQsPWGLDSpMD/im X-Google-Smtp-Source: AGHT+IGnrfl3K6zV+Yw+dxhNPFIQUBnuSuKgH/rMi0VWR4j3eufc+T7fHM6sVaAuIIMAtQF0XhEMaw== X-Received: by 2002:a05:6830:369b:b0:73e:9ee1:3d86 with SMTP id 46e09a7af769-7419d0941e4mr1994164a34.3.1754177887362; Sat, 02 Aug 2025 16:38:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 64/85] target/arm: Implement GCSSS1 Date: Sun, 3 Aug 2025 09:29:32 +1000 Message-ID: <20250802232953.413294-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754180083566124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 392a0a264f..ee8b870e17 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -52,6 +52,7 @@ enum { ARM_CP_GCSPUSHX =3D 0x000a, ARM_CP_GCSPOPX =3D 0x000b, ARM_CP_GCSPOPCX =3D 0x000c, + ARM_CP_GCSSS1 =3D 0x000d, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index ab53a4314f..bdafc60786 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -114,6 +114,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSPOPM", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 1, .access =3D PL0_R, .type =3D ARM_CP_GCSPOPM }, + { .name =3D "GCSSS1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 2, + .access =3D PL0_W, .type =3D ARM_CP_GCSSS1 }, { .name =3D "GCSPUSHX", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index af91b7f95f..e4c7801740 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2634,6 +2634,33 @@ static void gen_gcspopx(DisasContext *s) tcg_gen_st_i64(addr, tcg_env, sp_off); } =20 +static void gen_gcsss1(DisasContext *s, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 inptr =3D cpu_reg(s, rt); + TCGv_i64 cmp =3D tcg_temp_new_i64(); + TCGv_i64 new =3D tcg_temp_new_i64(); + TCGv_i64 old =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSSS1, rt= )); + + /* Compute the valid cap entry that the new stack must have. */ + tcg_gen_ld_i64(new, tcg_env, sp_off); + tcg_gen_deposit_i64(cmp, inptr, tcg_constant_i64(1), 0, 12); + /* Compute the in-progress cap entry for the old stack. */ + tcg_gen_deposit_i64(new, new, tcg_constant_i64(5), 0, 3); + + /* Swap the valid cap the with the in-progress cap. */ + tcg_gen_atomic_cmpxchg_i64(old, inptr, cmp, new, mmuidx, mop); + tcg_gen_brcond_i64(TCG_COND_NE, old, cmp, fail_label); + + /* The new stack had a valid cap: change gcspr. */ + tcg_gen_andi_i64(new, inptr, ~7); + tcg_gen_st_i64(new, tcg_env, sp_off); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2945,6 +2972,11 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspopx(s); } return; + case ARM_CP_GCSSS1: + if (s->gcs_en) { + gen_gcsss1(s, rt); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178240; cv=none; d=zohomail.com; s=zohoarc; b=Y9+BH8sjw+bU0Ymt175SKjs67pvFPin8oXGN9SUNMGsZ5wyXz3qs8TdXb2bcXKJtZUwnfrMkXDV3+/GpIJFxrFDEhTiaK+Qd2bNKTzzuPgkrvLqRP2fW69cBwWaX27WMTNructgLCRvyvEzxPzkj8/qWtLLkSNHH3+lPespIOkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178240; 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=2+2sYw5dexelP5iay1eLTthnTiCAulcagt8ELvDOM0c=; b=VqjZfrsIpERWLsIVlX5M9xXL6vDtVaVh/nLHQSPU33PsmLFFtgHMozCItjXfgOSGeB17eOmoJi0ygELmDoFyI57/F1fjOcGoBGr0R/InUM64rzSOLh+p+1zSzmRsqrHwesDDMTcBaLO768Oef61QLGaIsUGEzGkFHNwwUOUT8mQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178240371712.204882926173; Sat, 2 Aug 2025 16:44:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLrb-0004Ba-FO; Sat, 02 Aug 2025 19:42:07 -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 1uiLnr-0005Rl-Eb for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:17 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLno-0006Ex-M7 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:14 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-302fdd379faso734257fac.1 for ; Sat, 02 Aug 2025 16:38:12 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177891; x=1754782691; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2+2sYw5dexelP5iay1eLTthnTiCAulcagt8ELvDOM0c=; b=yKp4EJYYxt1AqhfE+6WxT4XWQ9/DZELLPgHyi2RC2X+l6mnuYgdlxHLNfZmAupG1Ho pz6yN0WUmsPZNIODZ9nq2vxiogcTWO0qLuF6e1EZOD5nQjxTP3sjpWCf+Ph/xxYwpbxP e7P1LIIC1YW+lfLqdS+oJB+WNaWtCUdI+bLih944Z0ggKL9zmHuAuq1o4IfGyjqwDd+C tChtcQsUo1rTDc8pn/8BrBxhO1OQX2a2bAggTIg921vBkx4rm82wVaZKcgt/hPwUgPHL AiWq1kulw9Ros2ACsqiJTer7d/pLw6gLPEjj3WaR6cKO3ZG/RBIViTymQWnjPWX91mWp PAig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177891; x=1754782691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2+2sYw5dexelP5iay1eLTthnTiCAulcagt8ELvDOM0c=; b=EUXDyaw5ts1ezOp//w0RHFqrXQ3I4isUt0olEhWq/hLAgbEVo2O7vsq+aPc/bXOPfT pPlZMqCs7h1ZS04aUhLrRMgShQc/oaY8kUjJIbVLTJydNEGBVAsiMDtntTQNuvBcOQpk 6FFRtKKsocv5nYNh3Db5IgtmeTLfUwiH3fsMVTyEtNoCFQM8p5B7CzhuI+eWQqE2BsO4 JVOJXuQsbmPP4555bNUbE8WmiKJ+972YUEDBjCuhdZKuuPcvP26zMXH9VO6c2XJBfPQj QIMTjakb+YtSZARcf5yyx+WHEhhLq4BixZMSsJaZ8Zx3pP+od8tiF+VG4QPuI01Ukwa5 0RuA== X-Gm-Message-State: AOJu0YxoFFmtsnjeqhNAZmHhMGN3Lth5nBW6K4K6bj4wxeortOmZR8wc QoYcFw4iggeu1qMVMBGOj7TeoEObU0tnANf71N/9lojIeZmnXIcTfDzScc0AXRRbl1eKasWJWfq WWsEx1ks= X-Gm-Gg: ASbGncv1yu7b2nQEbI27ENa5Nl08b/Q1LxB0iq6t0S9/xmehKdKYKonhHcDA7lVDKMT 70Fw+EOw5Y2XDbkiQAeY8/+m9p3PbysTGECpEbyMwCG1Bl+RYKJMR3P2jgjOQndCl/vuTss5oDO VhnL8VJ59ps8y2bAF2SruFYr+glfYx8/AWrWRc1sFlfEVDijwbU28Jns5t7c6hLXSLEFism8FQj ULysdvbyVb++/+LnhE/M2+pjdaEpmr+KHlSshVDcego4kLL3B1EqdwO0H3U1DBXdVS3oqU7QPrg tTLAFoWCmNReoq8h0pol4e04P+IHkkuPG/qeSUbTRfBBETRhkjLUuRcmNEDjWhpad66w3QQlCSu 3dpncq6hDENDisX9epB1aBjeJHSaa9RcagzMOyb6C6KDtkn4k5Oiu X-Google-Smtp-Source: AGHT+IGf+tk+NWmDKKJvSHfK5DScXr4aIAs3qz3s1nNFum29R6VHILKB7zNHdrcwv3DGRjc1YC2jqw== X-Received: by 2002:a05:6870:cb8f:b0:296:aef8:fe9a with SMTP id 586e51a60fabf-30b67569de5mr2634804fac.7.1754177891472; Sat, 02 Aug 2025 16:38:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 65/85] target/arm: Implement GCSSS2 Date: Sun, 3 Aug 2025 09:29:33 +1000 Message-ID: <20250802232953.413294-66-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178243594124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index ee8b870e17..1ee0bfd132 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -53,6 +53,7 @@ enum { ARM_CP_GCSPOPX =3D 0x000b, ARM_CP_GCSPOPCX =3D 0x000c, ARM_CP_GCSSS1 =3D 0x000d, + ARM_CP_GCSSS2 =3D 0x000e, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index bdafc60786..558e223838 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -117,6 +117,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSSS1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 2, .access =3D PL0_W, .type =3D ARM_CP_GCSSS1 }, + { .name =3D "GCSSS2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 3, + .access =3D PL0_R, .type =3D ARM_CP_GCSSS2 }, { .name =3D "GCSPUSHX", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index e4c7801740..88fe5ac4ef 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2661,6 +2661,38 @@ static void gen_gcsss1(DisasContext *s, int rt) tcg_gen_st_i64(new, tcg_env, sp_off); } =20 +static void gen_gcsss2(DisasContext *s, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 inptr =3D tcg_temp_new_i64(); + TCGv_i64 outptr =3D tcg_temp_new_i64(); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSSS2, rt= )); + + /* Validate that the new stack has an in-progress cap. */ + tcg_gen_ld_i64(inptr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(outptr, inptr, mmuidx, mop); + tcg_gen_andi_i64(tmp, outptr, 7); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 5, fail_label); + + /* Push a valid cap to the old stack. */ + tcg_gen_andi_i64(outptr, outptr, ~7); + tcg_gen_addi_i64(outptr, outptr, -8); + tcg_gen_deposit_i64(tmp, outptr, tcg_constant_i64(1), 0, 12); + tcg_gen_qemu_st_i64(tmp, outptr, mmuidx, mop); + + /* Pop the in-progress cap from the new stack. */ + tcg_gen_addi_i64(inptr, inptr, 8); + tcg_gen_st_i64(inptr, tcg_env, sp_off); + tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); + + /* Return a pointer to the old stack cap. */ + tcg_gen_mov_i64(cpu_reg(s, rt), outptr); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2977,6 +3009,11 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcsss1(s, rt); } return; + case ARM_CP_GCSSS2: + if (s->gcs_en) { + gen_gcsss2(s, rt); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180228; cv=none; d=zohomail.com; s=zohoarc; b=UPHz4wktcSgDivXNf+KVfOAx0e09RG7Icqmk44Vhq5P6bsGjTkM7DcjdjsRXmsmLoSekY0rgNiJ0WOvKusaKvzOXpnfP31/mHOrUbLYMsg8gH6h9pMVUxjNHWJwpZCNYGkxM368goHv2TYLvXzgWB4K7qco9LKm+lCllNZ9bHKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180228; 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=btTy/xuxxPZif0L5vFjFow988XjxZLXwQbU1+T1I7Ec=; b=FUdmFni+7dCon5DQX+BRK1BD9qGMReOwDz+C0VI5sBVhYnIqBMM4++drFNnCa4Vuy8xICDoOhpwAd9U4mVV/hvuQ+1gU70GIbqCoHFtcrqxUCESxbTUqRlpbMZqaDh/c+meWKWp8ZjT6FUX/x16OfB3HsXNtwzUeGCwy1whiBOQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180228115463.4750682611559; Sat, 2 Aug 2025 17:17:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLsP-0004ge-SY; Sat, 02 Aug 2025 19:42:58 -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 1uiLnv-0005Xz-Ob for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:22 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLnt-0006H4-9S for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:18 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-741b1657dd8so52596a34.2 for ; Sat, 02 Aug 2025 16:38:16 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177896; x=1754782696; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=btTy/xuxxPZif0L5vFjFow988XjxZLXwQbU1+T1I7Ec=; b=YL68KsBGMzX8ZDDJnOCwod7eUatVB3/vyaRMQ1AKAmgK8ZdNY+jcoAfzdUT4rVOQI0 +B2SNAmW/n5IMFRWrWSmOk+bigatVth5tiW/fcy+q6vT/ObKNPadbLe1teDa8poK0r67 A3DedF73j5pnh7+cqymd8OezRFg1iVc1L1/t1Z0zeEqe2euvRfH6Veuq+rlvuW8UcrQI j/JU7bPcN3MBHO473lO3FCga6U1iYjETPg4QCLnmZ2x4pLlnFY8GDdkIlvL72iMYN1GV AsV6hhDnXTiJiNtNd1GjIDyGtbHFbwYw19FGIkH2UY2ZpP7PkFoGsX1fxg8jGc7oTYe4 0eiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177896; x=1754782696; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=btTy/xuxxPZif0L5vFjFow988XjxZLXwQbU1+T1I7Ec=; b=kf4yqOgQZ3Wu26spNxsI7KrePKfb+dFyFtokliKHx/3WJSw1CWwVfra7AiuR1558rW KjFKQPdHDgGujx6ptHRWrcpjBhDCEy4IOyRVpw75ajsDuPscuygX+boAkeTbZJPc6PFZ h+bKEBStCRjJB0tj7MmsQPMGW+kJNOFnEF37cjCO4sIWJH3nDb9hWOtZ8vaq9yGJV2EI mgV1XY6w2osaW5CZrngTD14TgqRKdMx8EFCREeLsVHovc0cf9RP59ojn64cgY6R24x1U OXvhAXwzEpaQ1gznJTgCNjJ8dRPL9+ZUgRLh1C1rSEjUYS2bXnq3roEfWUXr55+jHukQ pZAQ== X-Gm-Message-State: AOJu0YygWPRfK3Sxc5FQHw405l6AmkRhd/9H+5v74wI8u/1EJREhSgd8 y8dWSWVmIFoGNItE1oCVTWfiSB7ozDSTwZuDFxzYF96SDzcSD4dVdVoDqTTnMkPmUKNea6YZWXI 8kj7lltw= X-Gm-Gg: ASbGnctWSs2C7JNwTgbdFQcpnAMw3qki6dyYs3diAVwrdS7vX8lqfvUcebnizcd2Hs+ GT+flZpBKHtc0r3jm5uNCnx0TFwg0oY36U/NQLlsovTv6+ua+Po78yPlAHbS3rDh2yFM0eAyY0H zTDkDo8xvFCTaGQHK5fmANCIyY/L5qghrhOW4lpzlq0PVKiW7ib6bajfebGDTrQ3R9EmAAfjSOB VRpiimMGgev9njz09gL5nKzBtZlLECb/58QVyHAOR9064OQVkVekV1YAYeSlnyCnUWTYKpwsgSQ /MH2TWrVwfaDDyI1PQTFbYQ+6XloqdGazqhg/3eDBYNEmmUii7m/I8ViqCGyMaIge2kdRKi8Ok5 6tYhSEdoCmhUSO19T7GGmpxOqR8u3j6ZyJyTGLvS05mwRB71zhGRJ X-Google-Smtp-Source: AGHT+IFfW/VOhELQyAK1RRVMLp33MerZKerr1BG7dgrViRqJqs2qb0/KKsthf7RfPQU7kkF1k+DyBA== X-Received: by 2002:a05:6830:3345:b0:741:a4a2:88bc with SMTP id 46e09a7af769-741a4a28c5bmr1527662a34.8.1754177896186; Sat, 02 Aug 2025 16:38:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 66/85] target/arm: Add gcs record for BL Date: Sun, 3 Aug 2025 09:29:34 +1000 Message-ID: <20250802232953.413294-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754180228991116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 88fe5ac4ef..6fd3032613 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1667,7 +1667,14 @@ static bool trans_B(DisasContext *s, arg_i *a) =20 static bool trans_BL(DisasContext *s, arg_i *a) { - gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); + TCGv_i64 link =3D tcg_temp_new_i64(); + + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); + } + tcg_gen_mov_i64(cpu_reg(s, 30), link); + reset_btype(s); gen_goto_tb(s, 0, a->imm); return true; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178496; cv=none; d=zohomail.com; s=zohoarc; b=Pm/N6gdekKijz7ZXieLu+yi2XUe6PKg+qKSH9ava419GUBAPhhmQb7zwpZLtBW7IEIIpaHgsbIsZ1iGu14t7ju05NLQodtusviUR6mvBvc+2n3bzMc1b7B7Lg7Hac/AvfAxiVrGwJ5IeXzAiQLUDVPThbZrfFCE1HSylAasBue0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178496; 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=U+KcO3RwrbURwPiGEiM0k/8PzgvqrFmZdld21Sd1wzw=; b=XF7+IH/IRtfCJImjqFbrccLNHhMlVbbnPKnsnVc+6gaQnLygy1U3Cz5DWrmqnr+A5q+cply6+pjyMmXU6R+FJHNxwGXfK0hTg8sIBA/MDHr69kS14tjnXA0vdwMAvnGAEK3As4YFCFwHo0lG/oWRRWmC0zp32XkGAGUn96H0EEg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178496754411.7024594703138; Sat, 2 Aug 2025 16:48:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLtH-0006be-2N; Sat, 02 Aug 2025 19:43:51 -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 1uiLnz-0005ak-U4 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:28 -0400 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLny-0006J3-5c for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:23 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-30b7448b777so514003fac.0 for ; Sat, 02 Aug 2025 16:38:21 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177901; x=1754782701; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U+KcO3RwrbURwPiGEiM0k/8PzgvqrFmZdld21Sd1wzw=; b=r645oQwOPO6HW7lSPAL4u11tkC/0WrWggMCR3mSDkTDzBHNBoZvLfxb0xsTbTe9IjL L+r1tTvK+91ylqZ8epErdREHiMwRAtt0o4G37lzDQUHl3c2oNTLHOMB+iXJahfGdcr/+ hx1I1uOMe50h5RL4WZfZJw/M/jbrkW8l7ovT8DfG57vrqMMbSSGs2wth5c6/ElqL7k+D YbF0Sc1ZdISKrWgzBs/OI9k8SCzL1TwnNu8pcj0GxFbG6ijirYLTKHVMbj6dnD8a+Z69 991nxarm+u7eHnpl+02ejkub3/ThS3zLz9QDaXx7jphEzL9ikWmkUcXmz1leXxTdfpcw 5C3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177901; x=1754782701; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U+KcO3RwrbURwPiGEiM0k/8PzgvqrFmZdld21Sd1wzw=; b=aQHoENhaH2zQPv4a54skIvHWWy/kZDsxmAV5h+M9AG6/Aysw/4WehczaHzSDyMnUVS QlP2/Os2GYxDMOFwReo77fyrzXS8TDKMBKKpa56feqbY2KkPQPNLKGSvmp/K+CXxP5Ou 6KrT6dl5o9WeT5Xouz3cenQ5YE4BxoNYEf207j0RjCHToWOVzCwawJWq1GdrS9Zsnk2+ SJCY59fFLexJICmnUWbZTKBXT87JCpO8b9em81BIOfaAjmGh6fZskKmarrdbz2rnTQsK fPpeE3iPxRbAfvD+SxiYZ6p+L2X8CWvHtuC2dMCGOSkpZe72qXLrP5vfLShfvCQbUTQC m4rQ== X-Gm-Message-State: AOJu0YzpRExssj8T8D9nIeILNSWyesu1dw5KsviCCD51K/aOHlK+1oU9 rba/Srp6Cwztk3s5nhbU84og4GVPGE4DhLb5lJAzeP9OjdMFBy3MsqNK3B8EiTEFRBWBVqqtsxD ERamPasI= X-Gm-Gg: ASbGncs0MbkESDyASO0fY3yP1UwLBgByH9iB74cWtsRuSPRwyG6HO66JEzFZqCP7CCR 3YGCph04chw6SPtWJngbLU7xnb9X8G4iDmxfXH+sVkBcjUMCSp+gmZlPcrLgJHnfRubKrQE+Zsb 6XTmEpBpXORn9KV3T8ZFwscMzB8ROzz1Pw3U3xr5s65LO0tRAFH6LOPotieVu7CBOKPy9qhCtXY 4yTE81i+p5xTqM+x8QupE7dXxJnpfU+68uJ//fhgm5dXkmrrEhtOom+Edt+gIQ8bczzr93TxNT+ 9QebKyu4fKqYudSqu6Zmm7stnBqZH7rHXcu1Cn1GZyUY/U7ltbMh8tkhkFG2xrPv11mUiH7VNnd v1Rc6fYEn5LYRre8ApPaaw4Qg4TiO6no7yEcVW0ef1eMLUemaVgdb X-Google-Smtp-Source: AGHT+IHxX9Cmf2XGJW+9jNfSBRoymrGA7LUe6Iv99m2+G/JTMksu4sdJW/wpLyeGj7pyKa2UE1Milg== X-Received: by 2002:a05:6870:b1c5:b0:2d5:2955:aa5c with SMTP id 586e51a60fabf-30b670b9c63mr2525534fac.0.1754177901045; Sat, 02 Aug 2025 16:38:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 67/85] target/arm: Add gcs record for BLR Date: Sun, 3 Aug 2025 09:29:35 +1000 Message-ID: <20250802232953.413294-68-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178497259116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 6fd3032613..4c3cc3d943 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1771,15 +1771,15 @@ static bool trans_BR(DisasContext *s, arg_r *a) =20 static bool trans_BLR(DisasContext *s, arg_r *a) { - TCGv_i64 dst =3D cpu_reg(s, a->rn); - TCGv_i64 lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; + TCGv_i64 link =3D tcg_temp_new_i64(); + + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); - gen_a64_set_pc(s, dst); + gen_a64_set_pc(s, cpu_reg(s, a->rn)); + tcg_gen_mov_i64(cpu_reg(s, 30), link); + set_btype_for_blr(s); s->base.is_jmp =3D DISAS_JUMP; return true; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179090; cv=none; d=zohomail.com; s=zohoarc; b=D8EHlODG1TRcvKbjhIjGu20dWFMv00sj3Od9XQCAgRiv1/ctrhznxdgXgNvu5DtJ2PuI/svrZNDRnUzKqKVXE0rq8cO/pMa/Ck2haujwitxnrsWB49cWecvxrDIhY98awm8pR76LFCiKNQVHhiJgQvTEw+xY5LhdNgY87lPmnBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179090; 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=2HSPiExRqazCWebE64TbzRDEiXNPirvZyWGgI8CApPM=; b=Fqu4UmNlVVfYgzGafFrdKd8gRQfJwUJB/MwQB01EEBDGAkqI+ve3mez9VQjGZ9DX6pdpwQirM31Gj4EDnjHblkC0J0ElbLr0Zq0QTdJqZzthNY3MYhkghBtH9bGbzUnUydmwFEKw05V9LUyw+63BV+Kz6ixW6N5E/SmHhOOsFO0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179090495351.2475703085363; Sat, 2 Aug 2025 16:58:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLsT-0004rj-J8; Sat, 02 Aug 2025 19:43:01 -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 1uiLo4-0005gn-IE for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:28 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLo2-0006Mb-Jp for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:28 -0400 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-741a905439eso355581a34.0 for ; Sat, 02 Aug 2025 16:38:26 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177905; x=1754782705; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2HSPiExRqazCWebE64TbzRDEiXNPirvZyWGgI8CApPM=; b=OPCcABU6y0IOr45LebLqf6U2UGLvtV43hU9gdX+IKN65KtnlvAwhD9+wKsVZwe7T21 NkWommxbyeGXGQNTz9SbkiubI1NRZqmEjhlxWcYUYc+dffSp7RYQUlHCRxZs2ngGBu5l ofPexncoaU53l6RwgzAOyH9coYSdsMmbDIubez6pRU7VkqoJ3S/tykboBDqAjJQ+l0f9 Zr0Ntppl4Wbv4SaT95Ubf7nLj3khIlJqhmafmFa8dMWzzkofLCJXmGkFmX/SlapVj74t 2HetQav4njuqcSDzo71SV09lpNvGpCIvqKZPDXV/Ij2K5aw1ok6lbXXwJsVZGqjcQCHG R8hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177905; x=1754782705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2HSPiExRqazCWebE64TbzRDEiXNPirvZyWGgI8CApPM=; b=MSkXujVke1CWRcM7p9JL3+/RgqfuFAPP8nNy7DyYLNnBhSB2XLJG37wYJMpOzndv6Q GSi1tlI3cGo8MLH1yIKu58AwJOAl3R1DEgf5dvGzMNdzHj1rUSfXLim/ws/DcB1EfPOR /VNJoVwTxkZ41q+llVXgr/fiq6q5dkyyXEeHD70X+XXtVWpvNqZA0Gd0vYejGgfeZSnv 0XL2/zgbX+s4pUJxmreB92CAd6V4wN9r1CHJ5R4/OFv/1vUXqtK8JldQx6V0ukw6FBv9 kSa2yvp/B3mbJvGiHcbGSdcxQR4FhLo2z07Y+1EmCYtkChUvot+RaHAw3xcbaEJ3YPNr KPRg== X-Gm-Message-State: AOJu0YyNSjSHpfOaDqIQGcwXH1AdKIIO1WTUfH+/Pco6VVfGQjyd79ew WUzbpA6GqGVFLsB+Kvbc38JcBq/OQyU4DZvnNKRwyHDki/xi28isTQGdfkACXPcROqHO4yc5KHA iaDcYN0M= X-Gm-Gg: ASbGncvAP6rA24SJ47MEcKGXqlJtBsGEzo07SOTPNoRXT5I6FAolzezW/fB//Vl9f+E GEHHxd5AdlXZkmOpZBN/I1KN8S08XDPiRKH/IkYK2B3fMyXVNUxSCeuVLrBscQrNI02FXAPeR5g dgs3dFkdNw9e15RZ/4w1xGaXgCFcrtgAHvk5zYK4lzwN6k4UVd2ldsd2O/3KTJgCuDus6abmyDK jbTPKU6eQ/gVgtKkZlzPkHXAfZ45vkiEhgeEqGLy8g4mkX5DKNeDLD06aZgccYQRF6j1yrX4IOh eVvJFzUXXtBdizy5iiZw0S8OcVlmb/1aZ26zHcbkjjcAxFDvttRMcKFxTtE5/3lUSo6mkSLlmo3 yfdyxWzpKTnEaRbzK2CSumaqwanpVst+Qo1kcSWjBc3dOEkAuuM8iRC30a6/J6uc= X-Google-Smtp-Source: AGHT+IHzLx0oInWui1kROALJKuRaUkC5LQsMNaopnf4EU4XtlCa0lC2gcrcZhiGYeCkHRO+qUwquhg== X-Received: by 2002:a05:6830:660d:b0:73b:2751:eee2 with SMTP id 46e09a7af769-7419d2d3e9emr2503781a34.23.1754177905569; Sat, 02 Aug 2025 16:38:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 68/85] target/arm: Add gcs record for BLR with PAuth Date: Sun, 3 Aug 2025 09:29:36 +1000 Message-ID: <20250802232953.413294-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32e.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179092446124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 4c3cc3d943..a945fd3b33 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1831,20 +1831,20 @@ static bool trans_BRAZ(DisasContext *s, arg_braz *a) =20 static bool trans_BLRAZ(DisasContext *s, arg_braz *a) { - TCGv_i64 dst, lr; + TCGv_i64 dst, link; =20 if (!dc_isar_feature(aa64_pauth, s)) { return false; } - dst =3D auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), = !a->m); - lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; + + link =3D tcg_temp_new_i64(); + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); + tcg_gen_mov_i64(cpu_reg(s, 30), link); + gen_a64_set_pc(s, dst); set_btype_for_blr(s); s->base.is_jmp =3D DISAS_JUMP; @@ -1881,19 +1881,20 @@ static bool trans_BRA(DisasContext *s, arg_bra *a) =20 static bool trans_BLRA(DisasContext *s, arg_bra *a) { - TCGv_i64 dst, lr; + TCGv_i64 dst, link; =20 if (!dc_isar_feature(aa64_pauth, s)) { return false; } dst =3D auth_branch_target(s, cpu_reg(s, a->rn), cpu_reg_sp(s, a->rm),= !a->m); - lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; + + link =3D tcg_temp_new_i64(); + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); + tcg_gen_mov_i64(cpu_reg(s, 30), link); + gen_a64_set_pc(s, dst); set_btype_for_blr(s); s->base.is_jmp =3D DISAS_JUMP; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179158; cv=none; d=zohomail.com; s=zohoarc; b=TanmM3LDcIvrPwwd6EUA7HcWyOyyJ1Is6mlt/5FdeUg+r61V/MZf8JNKlBM4VUmyDiLD0XPI03mwT0XUWlSHl1hD5PHMdYiKJar7mltTa+ZciVx5SPIwoqSe4d1bzxWKJ5PS1fFTCwlFZykpRtdvrscB7jBQvl0WngK4oYO4GKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179158; 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=JAfp6bTpWJ7rWG/lC4sI7VzgGDIC3qOJcK2xhfFXPGU=; b=kJmM+EktoW2zs1z8jLKIK34uEOs/NJsfZfJ5eAfy1hwxMMdtSBphSN3MqpgpGJ6tzlxGdQrInROvTdM5A7xbfxS9CgLkm1RvoSvIO9VOOqD81RanB27aXrVvA7vEmxSs1O0Uj6ziHwfXE6tT85lvZ78DkIvye8Rl4/LLcrhSsXI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179158704125.45476118091892; Sat, 2 Aug 2025 16:59:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLso-0005Tv-Da; Sat, 02 Aug 2025 19:43:22 -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 1uiLo8-0005kx-Tq for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:33 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLo6-0006NK-VQ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:32 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-741ad8d0c15so190980a34.1 for ; Sat, 02 Aug 2025 16:38:30 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177909; x=1754782709; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JAfp6bTpWJ7rWG/lC4sI7VzgGDIC3qOJcK2xhfFXPGU=; b=IeLBOXNGfXRp+riNmbIckADC8Wh2xQYBZV3JBFPboDmYdGIjje6Q8TqrRiwrXhUywQ Pjx227MC+0yJEsznm0qhpe6JdNepi2cYYc4LNiffJ+RY7ZRc5yHvtofkWyKC8B8Ro0my EAZoRUJJe/TRr3kEImw0KslFGEBZqgI4Oy17gakWBZqgLlm2/5aHlGAWnb9dAmq5Onta Okh19zPN6Ll0f7WCRGwe/jfrZM3Kp5USe+VjN8M1EF4Gn8DXPo5Lvwrobu3gRhza/kHu /onyHqEnLghHQDIgtZzfKTJB6+/JgxySMZL8YJOUFInv6kOuy17GJtL07RUEztzm8aJE Xz0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177909; x=1754782709; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JAfp6bTpWJ7rWG/lC4sI7VzgGDIC3qOJcK2xhfFXPGU=; b=gtdpcql0ko/L2pn7BFvtmA0qt0tz8wKn9eOyM0/aHxJ9eyMysBJdt/uiYwTHg+CqCC ISBdg2nl8r44Kg8s7cOXj8CBZrAJYjxVNgz4Zb568OdjeUxfYE5o5ziqaoHVan0AFELM COxyePxRgJ+Ilts5qo2TCFnrsQ/eRbdyEHYVejaYnz0R+WHFJ2BCC/gz/2XLTvRBIwDt 32ktArLob4FP7T74APrk3/PwMOEBtxdfjnjAm/MoyoZbIzJy/YNJ8VYmHsU8wok28rh2 qpjOS4AWXMNSuwaHtijIucqR9ORaQynZCsrZfKvzx+/wNFNwxtJh17HyMhZaSqLLRnEM ubaA== X-Gm-Message-State: AOJu0YxsXRqDd5zl9ZjwjhDOufTBun34H7W2UtexxEo/FjRImPSytvDC EDB9dT+9/UvyFE8eibTl8Inxheh9ENTlkX4Ftkru2Rdsp8onTKtmYLo+T1Ikk97pp1+z+MqnVT7 frTn06uA= X-Gm-Gg: ASbGnctdqZPdgR8MShN/B4OfYENpGvbm3CsRvwJxPyPr0Cs4QKJs/2CGWg/8+BedDSr UP/lg+TiSciw63A2uPF/IgpCqZD5hzHiTguUmf9xPAPwNDo0+Yq8qhsTLzR8VQJPPEtQjCAsI44 j1xTfwYx6X6z9Y+beWZd1AhNYo1SXzHuKfjLq//adoPpI8awn+ruzGCFpeESLWmb0oQoxCJV0Rm tNKmEgp09BUzv0kTxl8TuXCoJ/S0C6BfxQugxxf3MnF6zAMxyOzPVsjnh0tNVwEves7Rl84nALh 6U9NA+2PVB5L2Gz5Q95tk29G2FRSB+xRKeb98nsL8WKo4GJ17Vp54z8G3x1qNVO1Ah+asfazZGP C+b9FWQKzFUHi/r1kmJJYdlw1Zjx+sRiWjE8YukgTZ0kg4Vwm3+6u X-Google-Smtp-Source: AGHT+IGU8l7PHTZZiEYGKKhmQE6ypxNwY2CwLsUSaftUThFPLqs90JjUliDHkLStKZI6DE+kLJcFBQ== X-Received: by 2002:a05:6830:920:b0:73c:bb23:3d38 with SMTP id 46e09a7af769-7419d27ff95mr2720129a34.20.1754177909608; Sat, 02 Aug 2025 16:38:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 69/85] target/arm: Load gcs record for RET Date: Sun, 3 Aug 2025 09:29:37 +1000 Message-ID: <20250802232953.413294-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179159343116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a945fd3b33..49e17548c1 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -433,6 +433,30 @@ static void gen_add_gcs_record(DisasContext *s, TCGv_i= 64 value) tcg_gen_st_i64(addr, tcg_env, sp_off); } =20 +static void gen_load_check_gcs_record(DisasContext *s, TCGv_i64 target, + GCSInstructionType it, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 rec_va =3D tcg_temp_new_i64(); + + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(rec_va, clean_data_tbi(s, addr), mmuidx, mop); + + if (s->gcs_rvcen) { + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(it, rt)); + + tcg_gen_brcond_i64(TCG_COND_NE, rec_va, target, fail_label); + } + + gen_a64_set_pc(s, rec_va); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value; @@ -1787,7 +1811,13 @@ static bool trans_BLR(DisasContext *s, arg_r *a) =20 static bool trans_RET(DisasContext *s, arg_r *a) { - gen_a64_set_pc(s, cpu_reg(s, a->rn)); + TCGv_i64 target =3D cpu_reg(s, a->rn); + + if (s->gcs_en) { + gen_load_check_gcs_record(s, target, GCS_IT_RET_nPauth, a->rn); + } else { + gen_a64_set_pc(s, target); + } s->base.is_jmp =3D DISAS_JUMP; return true; } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178645; cv=none; d=zohomail.com; s=zohoarc; b=dlQPMFS0Bm8GWwQhk7J9HzRjnxyitJfUfnCSCEtx/LJd3kHLMV5nHoUn4ArcjvvVDzCdKYGFskjInsTF7ra2ApUEaJZ4Qx3MBK7AdyDk4Vrets+vHXhbl+wH5HrZQ3VLz/qi4SzhIv8izUolNeseOjs5j4z6bKFM0ejhC5OJFC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178645; 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=+95ujyjR79+yagfD63HNcgJD7lOK+ke9LaFMk4/bVTM=; b=lXbdgv6NTp6176e02XcWMH/2kvc2dSa0EVplvuxot2uG4vcITqBiBxSVGAF9mrtjWAr6FOFVHKyKJnnTSk4gb1G0QszxqR9elE68SG+SSKOzn1i8NFKRt53qLxW4mCupxdfV7ThXsGO94a9b2vKHKIqmjCjt1z9u5DAgOEXiaY8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178645214149.0969055946632; Sat, 2 Aug 2025 16:50:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLti-0007LY-Fi; Sat, 02 Aug 2025 19:44:20 -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 1uiLoC-0005oO-2c for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:40 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoA-0006O0-Ep for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:35 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-741a5e8fa94so126815a34.2 for ; Sat, 02 Aug 2025 16:38:34 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177913; x=1754782713; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+95ujyjR79+yagfD63HNcgJD7lOK+ke9LaFMk4/bVTM=; b=W/cJibt97b7N02R/IdXY/0q5rGXo52AYX0DamkvnWWmFEwCAunTpE8MynWCSVnXEPF iQxCUO+t1VcVyPytDAjFNpgudmE3njSltXr+QeOSeu86He8Et0A7EX33bMk4fKdfpsty zCD6dlYBgI43grhLzeJptDo0HStpal2l7O475Ore68/6wNipbDh3SBQCilgFqlmMZJ01 KUQdesHarvVtUHjYLXp8Q/Oj+DGkNJjVJ4lxD15srAtXO4jlSanDYwC/FCQAezaQ0Fvr lCQ+S4s+Nqj7QsWyPQCqNQ73rdYEU4U/PWT6KsdjbDQse7DjPBHPfeJyCzInpDuIv+rm ghOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177913; x=1754782713; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+95ujyjR79+yagfD63HNcgJD7lOK+ke9LaFMk4/bVTM=; b=SW5S3o7x9YhQb4KDmmSx8Fh8eKkQVvB0arqKtdh4DI2xG+T8C+uYNbpYjBtnJNd81k q0TYFUhvZmge0KYNcZOCLMHQtNju4cgSFxfpEbu+VuqgR6KkpugtMfrnzgDJRfdsT+18 7rY8x54byT157snAcFB0XIlM/uasvTjx2zDjss+VyDQxCDoByEs5+2vGCq8/oho4vjYB dzpNu8N/GI1Zn0xrdjXUn6xU1JnDtkPusIxC7gswGQIotBtjiJiHUwE/aUQyC054Ff6/ GbQEMMUsSCD5gq0A9c7otAYKrQ4WcDPmLF4DJahmVEONDxXq8PxyLgPrLE44HmBNpGET 5arA== X-Gm-Message-State: AOJu0Yyw2aMkv2iOeNhN6RwkWBDXmvvMlclPJMBrmp25XGb5MZlhfv74 4Oqdj53TOTO3byCLIoFw1Ls0E4204PEvmhDn7nzIvlZB+YbsLFOFWSjAnaEU7Vf+S6q4BBGdUDR QAduPiso= X-Gm-Gg: ASbGnctuvcQfAv/Eng8Y69qH5kOnaJvu3Zwjs/epW9btx2DWJMOGRWi0Cs2GMO4rSEM o/4skvFxziWMJ67WnHiWVAhN0G+gjh4wf9egYFB5g5JKX/UMiEV0pk8fY/ubbsrSq2iUnyug6Dy DTsKcwTdr+kmlPIiIg8Z44TsTGG87ZGUddNE32SbOWTPPBcOKl8df/CbSBVqU0ub5NXdsDGZqqi 42Yt17Y47fT0TCdoebJwTaQILbLlX1EBIpC2HjM7V2LyQPUEUwqlQJ3PPsF3zquyza3FCDMlR8R 8FCSQpe2HBtJAKxgpF8PFOZjF46UTe6kG4V4LQwR5zjcpEyfpnM9EI5B+541/9gpns0KoQQkt6p 80UxAVjTSDko8rIxj73S/9qa1BVdol4+vHfvBSv456uA/tKEzzyEX X-Google-Smtp-Source: AGHT+IGgEIY4k9w6d93Tg8cM/mOs+27WfhssD8yRLC/6Ql4Cc1ax6aosm+M8yyJ9vbEJ7bybUhvu9A== X-Received: by 2002:a05:6830:60d6:20b0:73e:996d:cccd with SMTP id 46e09a7af769-7419d23774dmr1753543a34.22.1754177913322; Sat, 02 Aug 2025 16:38:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 70/85] target/arm: Load gcs record for RET with PAuth Date: Sun, 3 Aug 2025 09:29:38 +1000 Message-ID: <20250802232953.413294-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178647833124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 49e17548c1..23186850f8 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1890,7 +1890,12 @@ static bool trans_RETA(DisasContext *s, arg_reta *a) } =20 dst =3D auth_branch_target(s, cpu_reg(s, 30), cpu_X[31], !a->m); - gen_a64_set_pc(s, dst); + if (s->gcs_en) { + GCSInstructionType it =3D a->m ? GCS_IT_RET_PauthB : GCS_IT_RET_Pa= uthA; + gen_load_check_gcs_record(s, dst, it, 30); + } else { + gen_a64_set_pc(s, dst); + } s->base.is_jmp =3D DISAS_JUMP; return true; } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179053; cv=none; d=zohomail.com; s=zohoarc; b=OsTPs3kJMZFGvToRYcvYAFhNykoPCq9iCeRwPTYeQJPTWk5OX2TP8hGCYphP2G83XWDpzVRlyujelOaovyTGHtNERR4g9n4uIW0ctXkorXw3shykQHnhuel1z9SZkBeGgo7ROlgIpbTxY8omTRnc7SR5fQ+wELLjk4g3GoTZNaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179053; 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=XPFrNGF25aedFkFai4tvzmqvnXD7XuO5UqpCg3WnHEs=; b=nrJlslqav4Nxqf7QyOo22EYoXz9h2ND8dZnMVbfnGjHAUV105af5fKYUaGYgCW7gIdJ9AA5HsZ56YTciLolczsVM4XaMYfBjq+o09viCtyJIzIFhCDxoJRE59/l+cmcPRKeGuuvklHT7WeM0DqR3I2ZQq7DP6I6fY8VHbYwDXKo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17541790536715.065451176390525; Sat, 2 Aug 2025 16:57:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLvu-0001c8-1O; Sat, 02 Aug 2025 19:46:34 -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 1uiLoH-0005tB-8D for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:59 -0400 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoE-0006Oi-He for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:40 -0400 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-3005517e7d0so698727fac.0 for ; Sat, 02 Aug 2025 16:38:38 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177917; x=1754782717; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XPFrNGF25aedFkFai4tvzmqvnXD7XuO5UqpCg3WnHEs=; b=ox97CxEPhKkrW8iWn/3o70VPKh5Of//V+0y0wt/sfPJi+DKqQNjV0LVKq0Krl18sDw VpjB6HqvlSoeCVRYmqLyBr6SmKLIpCsHoMRriHJyak/84zNmnLUbuC+9MUH+P0UNoaKb 0jSJkMAka1JAz9TfCWbOJPJMI+LaO7XOAphcmjn1ndKL3oHNJAfcvZ+cD+eGm3c7AlwF AYb879Gsm4C+bQqMAbyFTO0c7olgpMgr8eEMOo5VEDeJMh7fmLvbBV+2bUA5NUOf9pnI O90SL4XBNRSwxhjbH68Cg0U2IOBUnbzA0oAACJvhoXSO0O7yFK/jinozspynAx1dHtEJ lfZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177917; x=1754782717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XPFrNGF25aedFkFai4tvzmqvnXD7XuO5UqpCg3WnHEs=; b=LCLwjxuk/Qom0KxXuNUxyxeQ2uENFiLNVeo1FgtOAOZjtmuv8fWgJQAb07ISogFbNu xKidXuzYNIWl2qfojjp/cp7J6sgoiEj7AAJPLuJwEeFJ+zdWaqOXOyth0+AEhtKnW4Ue 9dXqvJ+s/DK/pBexBcEbNCucMQ32nNKqnhYEn9Zs3GDZ/q1dEn1zeSufcGDP0KZZU8yr Ato1WjUFqDoVlYnB7BWSNIx+K7gFcq0+h0pZgzPOl+uRxSvwUAq/2qnHBJvgtAgzs6uH TDy87ggclPfih1Jf2asjDrmrrmzSjm14sH7VZeze8091j8Hev/v3MvHZs8cHvkfK5Rvu NE8g== X-Gm-Message-State: AOJu0Yycud69vIt8B0dumw609Id5sIlEROYdmNs7fWehbZFowZwzrP+6 DFVFeMXQ3OXXPcwZW+8hT/I1/djqMQPNb4ExFQlDktkzXk36vw3NKdPnYeRC8unKfChNu90C57Q qBzOKIDA= X-Gm-Gg: ASbGncuuaZEmEOFAkH8g8Nm5ScpzgaMjTtgzfOkdHN4w2M80QJNiUha0yzX97bksRw3 qq6SUbGCCN54ebxIn7pu6s5ID3fUwHuML+HFuD2Xh/al/JaV0VnPXHR/eWkmhfEdtLRzxCik1iJ zFzIhVSD8Z23NlHWlD3L6eRvyGo/gMbtwk8tUqMrRpeZNByW8Y+5I0YjjTjVocv6KwlUcDNmgTQ 83TUq5ysox04nWLXtXphmqodlG9L3ZuMoVoAAiBEGjq9YarDBXRZdQ1JkpDp5woib99q+QWq9Yl zjPToZczJz59GOIswXTRlsFPkD9EyYJYF4P1FTBr49ESQCDzH9H8UMfGaQtRXiobtp7qOlwEIcd JJOvBglryM6gQ5dfOKAf7FrSseVbxxsras9ZlryDidhDEeLaCiPga X-Google-Smtp-Source: AGHT+IGeQSMY+FW0DjbFjOYNnd6dgvGh/W5Cm3KemhEGjvP0pUgocTD5IKFkIZa/BLgpvLDJ3o40OQ== X-Received: by 2002:a05:6871:6b01:b0:30b:85e1:d3ea with SMTP id 586e51a60fabf-30b85e1e1e4mr385551fac.21.1754177917194; Sat, 02 Aug 2025 16:38:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 71/85] target/arm: Copy EXLOCKEn to EXLOCK on exception to the same EL Date: Sun, 3 Aug 2025 09:29:39 +1000 Message-ID: <20250802232953.413294-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::35; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x35.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179054427116600 Content-Type: text/plain; charset="utf-8" Per R_WTXBY, PSTATE.EXLOCK is 0 on an exception to a higher EL, and copied from EXLOCKEn otherwise. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 4495433ce4..b2754b1678 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9300,8 +9300,13 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *c= s) } else { addr +=3D 0x600; } - } else if (pstate_read(env) & PSTATE_SP) { - addr +=3D 0x200; + } else { + if (pstate_read(env) & PSTATE_SP) { + addr +=3D 0x200; + } + if (is_a64(env) && (env->cp15.gcscr_el[new_el] & GCSCR_EXLOCKEN)) { + new_mode |=3D PSTATE_EXLOCK; + } } =20 switch (cs->exception_index) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178496; cv=none; d=zohomail.com; s=zohoarc; b=UXQ/AgfeHNWF5NogflKPHO1hfOuUo6CpdP/QBDtkmIJgm1me5CjM/mnjatNgRmS/8MP7PG0fxRm5pvAFdE7kzrXNcrtc1usAITym3nVQavEtdh8bJzXQaSifCl68xUuVZ+XSQjt4FeuUo98yNrrP+Kb+nonz1U0LYeeQKWeLjts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178496; 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=52VfTzYDSgjyTkCxi2KMOJnfbsQ5A6/k4xx3za3L80c=; b=MBSFxOvM2m6SpEOa9NPi2bstj9IvpkqM+Q0aFCAl+DTWFPqrkPDA3um10KgJ/9sr7m2f77ovu50lkyB451SMhjaj/SYNfbPe9LjoQOheGlzUaZywdMYHgM57nT/TUkbptlt2SIk92a+uX2pybXV6uZu4zGG6+XGgWv2WAiBcNvs= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178496508461.08307641146007; Sat, 2 Aug 2025 16:48:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLtB-0006Km-Ge; Sat, 02 Aug 2025 19:43:46 -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 1uiLoK-0005xL-Da for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:00 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoI-0006PV-63 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:43 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-73e88bc38bbso1153457a34.3 for ; Sat, 02 Aug 2025 16:38:41 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177921; x=1754782721; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=52VfTzYDSgjyTkCxi2KMOJnfbsQ5A6/k4xx3za3L80c=; b=ZlYkBCKgG8koU5DxEEJdIRXmYBmgJH/ns9lrpFyMkzqgZXpClcQfdO+BVej89tNtoj Ckt9oEPXNwgWeES+ztta04CRvqGx+a4LcEvAhpFj+rL5KbIU4QU7dOuzu2VZ2szlnUJT 4y/u/jcWYhMFFhGiOTPCW63Hb1Ap67AP6fd4PksYdrcchrvRUqX1jIqFSSrCSbmilPBN yFtCsmrRblim4MR/Ph/HWj/hc+Pkl6vUvUeHDvFEAIFBpZQq2YTjuyNxR87IEciTT89/ aDjVCwfkaCR8cKbBPfm2euKdiD+/Tk3E1Ohq45eTs32etVDp2MmYz65RhHahhP7DjFCP MVTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177921; x=1754782721; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=52VfTzYDSgjyTkCxi2KMOJnfbsQ5A6/k4xx3za3L80c=; b=ebj3FSocHgTvQazqJW1OCybe8daCviJOHq1dbz5VtNGNi2pRP02cSSzg4AuBhPzJFr 7e/JFC/23H/ssYzrzpMsmsdJZ8q1zbNyXoz8fhD79HwvRxipDK+5LExQ6/NIYQB7sodg UJ2eLHRQ52M7UpGobfIa9SKJQY5x6ttA/gzap3CiDiubasx9FGLQDIY/Csq8MCJcSrf/ CV53LiXy4NmKmKCw6Ql2Hi7STtf5WrOSjG/dpy7GUwBO+cxp3ds5d77bbQ4ST+3Jv/k7 ZCQmnx/XWKNd6ygeJIT6o+KPEK05uYKAUr4vYsGPuxOHBxkxoKnuVseQHkfOG7DeoMNc v7/A== X-Gm-Message-State: AOJu0YykpMGqw0x5o0B9vTYLLymgh9ffybo0M3LNb3mPn6WbkUkoRZOv PDn1U6v6ijSWp5JmGxDo6TCeIUUPW41ISwN5/bGwzh0hhcijkW2DlzsIQCzQnr0KXubItuH066G gClxJpd4= X-Gm-Gg: ASbGnctVM9Xy/teGXY9vMg0uymuhMD+HRSX174lxoQ3ju62SmOfSGHBgUN+yxs5uadj GGG1ocrRIkz8ZNind3HHIRbdnQGrOZ+IKLKcS41xqCltLwIC3AXtD7kqLpDV1xNxNJjmsXuZa+e kXHEtXc/xHnnyfx1Du27fgti4sBFCopx7F/Ir4oj79uT4otmlJhzbgHJMmeCdlcONsvx70DHFHq o/seevx/9mZSFl+6+v5ts3B6PaxJsWrzEj21ftx4N5zdVbq71nHMg0Zz6UoH4QRp1J1O8ObxxOy 1UXCQ9rws1ew6+oKo0Oqtf8cKcEX6xXmGaqRSLIvexs5MypmtI3mY4a42e055qAUMqvpqLpayTg UlbsUBMIlMN/4OpmjT6Yqiuvv6Fq6AK7X4uuOqGjC6eLt+3zO/UXy X-Google-Smtp-Source: AGHT+IHY5Yif+IvfbKW28B3C6m3Kjri8XCaeK9q2Zy1SptcBJ6C3vm8+u6ATT05tOPsOwM7VqUpUyA== X-Received: by 2002:a05:6830:264c:b0:73e:a0ab:39bd with SMTP id 46e09a7af769-7419d0e1115mr3008697a34.8.1754177921044; Sat, 02 Aug 2025 16:38:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 72/85] target/arm: Implement EXLOCK check during exception return Date: Sun, 3 Aug 2025 09:29:40 +1000 Message-ID: <20250802232953.413294-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178498390124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/helper-a64.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index f61adf1f80..7ab7ddf7c4 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -694,6 +694,17 @@ void HELPER(exception_return)(CPUARMState *env, uint64= _t new_pc) goto illegal_return; } =20 + /* + * If GetCurrentEXLOCKEN, the exception return path must use GCSPOPCX, + * which will set PSTATE.EXLOCK. We need not explicitly check FEAT_GC= S, + * because GCSCR_ELx cannot be set without it. + */ + if (new_el =3D=3D cur_el && + (env->cp15.gcscr_el[cur_el] & GCSCR_EXLOCKEN) && + !(env->pstate & PSTATE_EXLOCK)) { + goto illegal_return; + } + bql_lock(); arm_call_pre_el_change_hook(cpu); bql_unlock(); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178991; cv=none; d=zohomail.com; s=zohoarc; b=VnSXnX8fwJtm3F6pcncZvfnImP+eE7C0oL5NZZ27SWrLBu/XPbzzuQsc6UFg7+qdkd7ys82CVxa4GlikRjeBdh3FKccmVJ5iBPI9krEncgLEVkZJcumGiiltmFYIp81fwJcVpsdWddJMgx+TrF9jsMq3VOuSqYZroC52gvuHCo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178991; 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=YTzILFxOh9VPP18+18G2a8oDIZLGKqGhECeVoAfm6S8=; b=NErJr3IvE3ND7U5l5QDrDbRK9H+9QoHErSXRpRSoUJYHek7zkJKMIqPlHdPuhSv13ALUlTEaRth4zzMMUrm9ue39twwqvrKLrhZccXqP90g4naCtIjKrjcUc9s87vGtUohtl0k2W1zAsBLpLLiD7oOocZhjwD+6Is8eCwN/3sng= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178991389741.3630079309968; Sat, 2 Aug 2025 16:56:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLuN-0008Ab-3A; Sat, 02 Aug 2025 19:44:59 -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 1uiLoO-0005xp-BJ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:00 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoM-0006QG-HQ for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:47 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-741a905439eso355688a34.0 for ; Sat, 02 Aug 2025 16:38:46 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177925; x=1754782725; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YTzILFxOh9VPP18+18G2a8oDIZLGKqGhECeVoAfm6S8=; b=icmaofe8UF45dVB16S7oCRIwyioDB6Izi660iSe1r7XF40Dq2Z/sdEY47KlD9KpQqv Kll8PB8494RitGB7kr7mijlwQaWPhEzInyapBFll1mep/U/TyFtTOSP/YaDCCvWivFOV C3EwqUbb1j8+SFXEV9zY9t2tZGFHiFE3x9jnY9drHGqAVJ56yEMbmSbhg4X4mabTOOJQ arBlZ02NPNGku+m2PSgnSHsl1vMnv5WDwqmSItqOq8kpF4y2Jvo+g1jrfVT+JIGIzQWp 1hDxQDf0HLRgrE4PwVYq3uQIKLi1YFiCjYywSFNn66BNShCJcJ/ZcpGiFiUTsFoveEfV YiCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177925; x=1754782725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YTzILFxOh9VPP18+18G2a8oDIZLGKqGhECeVoAfm6S8=; b=durooslD4HK9NyafEP7SruBaVf5Qn4yc6S66wWqdk/TrvfFBjtMgsV4Tel+1L8ecia klDIVOxTb3TqrEUMQrRVcdRl+l0ElXB6joOpsaoqGhAadRynK6w045LHj1Y/kZQRJ+IU xH/seQ70HPDUn3VgASe91i9AGcbPBSfgeaM5WGXgUqFiG+VwICCoj9PNA0e7rvpn9TQY DnhV2JAcvv8Ha89jDP9w2THyPKhwXdCTZnrLUw1pvEj/7AuI/T75pWHmGqxEyomQSOUs 5su5TNh/t6M2HOiNxbo8Oq9qGwHw0XV8yBvFwGGuoh3HgL6HDr1zujhv0nIQsYVc2kzU W69w== X-Gm-Message-State: AOJu0YxtTTUN0BqtxFR3rBBgHyVbkgKkgpGMmjisH1uVG4PoCiqzZjL7 cK+/aM/+iOQiFOhvTzghPdYp8wUGTyWfkQoo1jT0xBteLQRSThfctZLX1NnjuMIZZ50AnMsy87e gkLG4w5M= X-Gm-Gg: ASbGncvXiOSE3VUL9qWKT0VRIieHm6C9FJcNWCHVRYsx8jjqn6Azxl8B86g79nywVD2 rlM/aRAoatVABzzACluSvWGX7LeRuqr/ioE5hpPLUdRB+HTc1+l85Xfu+HrFKSu6Ob/GKrrEf3m 5dVZ1l7MMCU3p+C9xxjytJpcK1oh5v1gpSKT1wCVV6JmS5omGXjIsjyDFadS8iJScNULHvErS5m RRAlkpLbEOEU5F5ZjZI8ChXfkeIvJorQEDvIQLoNIe9RKn7OKYZ75HvnMj0tvrSlM1Ai+6kdKzb 4NeFvryAKpPQVRXW1BlGu8O0dkCeevoDNew6iOd9G77xz7L9k43FTCOfO+vnAIbX4LCSww1ED/9 FvdkC42wtqOXPW7ouXFIyya3J1JL80oFI+A9Hz+1stLQpIXrEpaP2 X-Google-Smtp-Source: AGHT+IHv6Tll2VlaRQZobRCYQXySwVjiTgz0KMfDFVfvDsK/j/LnBUag0Bs6BjwToIeFGRXP6lDEeg== X-Received: by 2002:a05:6830:3345:b0:741:a4a2:88bc with SMTP id 46e09a7af769-741a4a28c5bmr1528275a34.8.1754177925504; Sat, 02 Aug 2025 16:38:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 73/85] target/arm: Enable FEAT_GCS with -cpu max Date: Sun, 3 Aug 2025 09:29:41 +1000 Message-ID: <20250802232953.413294-74-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178994151116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/tcg/cpu64.c | 1 + docs/system/arm/emulation.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index f4a41c854f..0c3408c0a0 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1205,6 +1205,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64PFR1, SME, 2); /* FEAT_SME2 */ t =3D FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_3 */ t =3D FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */ + t =3D FIELD_DP64(t, ID_AA64PFR1, GCS, 1); /* FEAT_GCS */ SET_IDREG(isar, ID_AA64PFR1, t); =20 t =3D GET_IDREG(isar, ID_AA64MMFR0); diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index b894aced89..9e3df48e00 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -72,6 +72,7 @@ the following architecture extensions: - FEAT_FRINTTS (Floating-point to integer instructions) - FEAT_FlagM (Flag manipulation instructions v2) - FEAT_FlagM2 (Enhancements to flag manipulation instructions) +- FEAT_GCS (Guarded Control Stack Extension) - FEAT_GTG (Guest translation granule size) - FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) - FEAT_HBC (Hinted conditional branches) --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179152; cv=none; d=zohomail.com; s=zohoarc; b=lJ1d2+zL4Fp9d+qyBMyZXNwTlWUBHaCotrO3quTk7XvGQZaLnW8wWCiYj4PAt1K8spQAYtpQpXg2ft/uRUhjuPi9e3HvXqJEG8lMy3aSEyBggv0ELczGDZnBCVaYcJm881cpN8vE5MQ9INBq/FRL0SO3reShJzlN2kt4UefeQ2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179152; 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=lflJ+SmP9/WjBOPLau+3bavo7afA8IIGWLBMr9HKB4c=; b=V1DzUQ2YCy4KYwA45vBxTCoOVURlClkjeeTRbZ4X7CZSj7YQzhD+pNCukQTm9oR3ReIFqXx8TbkCP+BKLHiZciRIwTs6kVrt4735g5C78NxuZeY/ASoxOByZCJIDfu72moa/0vzKMRgHmP9oK5l4asXXCwNJHbXjWTpxnjgUqIk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175417915210695.68456125018213; Sat, 2 Aug 2025 16:59:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLtF-0006X8-WC; Sat, 02 Aug 2025 19:43:50 -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 1uiLoS-0005yg-Mo for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:03 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoQ-0006Qy-ND for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:52 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-73e58d51060so736667a34.0 for ; Sat, 02 Aug 2025 16:38:50 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177929; x=1754782729; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lflJ+SmP9/WjBOPLau+3bavo7afA8IIGWLBMr9HKB4c=; b=tHevbo9/aQzb/+shwL+6MtCZE24uMlWonxndulCq0V4/h/cWYvTmuT5oPVw21FJNYm XNRMaOo6SBVKWkuUc/2BVel1eydGKvSnt//o1luqxNtUL4vF2SFIOG1u2yoTBdbYzz4b MfQnI6WWKc50EganVM0jUQ2tbJTfa6G3A6ljoxCTXrcyA005g3+5duZgQJxmB+yJRb1r mHB8rEBHyBrNn2MZLfoseCkXUi3Izg8mZPBPk3qR5I4Dp3iVP658NtQpIQ90SUosjuGF +/CdSdqQlLb+lZAIWRMpcrw4Neg6Rmp8cfLRXUijGVuV2THnf3IBcWO/oXq99cwEOeKA 6KEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177929; x=1754782729; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lflJ+SmP9/WjBOPLau+3bavo7afA8IIGWLBMr9HKB4c=; b=mUA1PKyiamYG+Bx+6Rj2aHhOJzfp0yM1hrn4Hi1GsFzUmcyWcg6dZghbFGRsJyLACv J2s19yc1+OQjiYMS9Ot/0McTlaAaiuoUgELNdmQ/mk5znTYfE9AUvWb4rkkqSSjhB8ft fjN0+wm9ol7Er5reTOqsAszqBcfV+/aooVvU0s0nPVKSgPGoQb5RP06dTKFFMS5tUlJS p+Ru+Br30OWHln6zWFXxIauFwJ+l++1z6vALNis5wvuXP9RsSYyaNGlwKNEh6/R9bo4z W/D+wB7DqIUGFmr1/nz6mh/tKD4I76d617Y8sLmo38CzSAj8rBhcZ/bR0ehNKHgJodpo zNlg== X-Gm-Message-State: AOJu0YzTviPT5xldJVP11bfaNera2Xo837YezMzYnk/no63pd64T4nEc rTKAcUgBbVxODysBulG1e8bA7edSylofE3JKRTxza7NPXkwaFTOVkRcCcSA6WemT1G506UK2ZAs r/FWS2LE= X-Gm-Gg: ASbGnct5llsWPhb4plji6MIDMz1fRxwL6P2bLcOzVHED0UAABiUFZRRItkSEC788K+h zW3kJG/c/S4U7sug38KIqkQKu9ilcmsjh90UIsxaRoIU62cVv5boWbnKpGXwoFOde6/hy8MDQQC frjyqvgcCN+bIdbxNUS8bnPogsGtnicdVdfweCn6HqwxvM0CViy+SF9L006A9eJFF2MbFRQqIHc Tjdf4F3gFCnE5yY3wiitNOyA0GRa2XjXdBcQxX7nn0IEGZfcja7p9dWiiFayHwddPul0S64iOoL T7NsaCdIumgcVmCJ+JKj9d9VhrkkPZDs9QBaHT2I7ZyMIUUhL4ZBPVEqnKml7Zbkfk3RjNJ73RU k+cyuPQwkAFl6jYV5rzJU+f2HUP2PVGAdckW076c3SXM6CotQE4D04FP2HQu9Cy0= X-Google-Smtp-Source: AGHT+IHUnvNoLk3MlLa8ec3EshU7F7ZOyeck/zWtKVfShr+3m2JlXLKZvKrO+UmRReCToudBPx5sCA== X-Received: by 2002:a05:6830:6308:b0:73e:9cdc:a6d3 with SMTP id 46e09a7af769-7419d24f11emr2553239a34.25.1754177929534; Sat, 02 Aug 2025 16:38:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 74/85] linux-user/aarch64: Implement prctls for GCS Date: Sun, 3 Aug 2025 09:29:42 +1000 Message-ID: <20250802232953.413294-75-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179153425116600 Content-Type: text/plain; charset="utf-8" This is PR_GET_SHADOW_STACK_STATUS, PR_SET_SHADOW_STACK_STATUS, and PR_LOCK_SHADOW_STACK_STATUS. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/aarch64/gcs-internal.h | 38 ++++++++++++ linux-user/aarch64/target_prctl.h | 96 +++++++++++++++++++++++++++++++ linux-user/qemu.h | 5 ++ linux-user/syscall.c | 29 ++++++++++ 4 files changed, 168 insertions(+) create mode 100644 linux-user/aarch64/gcs-internal.h diff --git a/linux-user/aarch64/gcs-internal.h b/linux-user/aarch64/gcs-int= ernal.h new file mode 100644 index 0000000000..e586c7e80e --- /dev/null +++ b/linux-user/aarch64/gcs-internal.h @@ -0,0 +1,38 @@ +/* + * AArch64 gcs functions for linux-user + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef AARCH64_GCS_INTERNAL_H +#define AARCH64_GCS_INTERNAL_H + +#ifndef PR_SHADOW_STACK_ENABLE +# define PR_SHADOW_STACK_ENABLE (1U << 0) +# define PR_SHADOW_STACK_WRITE (1U << 1) +# define PR_SHADOW_STACK_PUSH (1U << 2) +#endif + +static inline uint64_t gcs_get_el0_mode(CPUArchState *env) +{ + uint64_t cr =3D env->cp15.gcscr_el[0]; + abi_ulong flags =3D 0; + + flags |=3D cr & GCSCR_PCRSEL ? PR_SHADOW_STACK_ENABLE : 0; + flags |=3D cr & GCSCR_STREN ? PR_SHADOW_STACK_WRITE : 0; + flags |=3D cr & GCSCR_PUSHMEN ? PR_SHADOW_STACK_PUSH : 0; + + return flags; +} + +static inline void gcs_set_el0_mode(CPUArchState *env, uint64_t flags) +{ + uint64_t cr =3D GCSCRE0_NTR; + + cr |=3D flags & PR_SHADOW_STACK_ENABLE ? GCSCR_RVCHKEN | GCSCR_PCRSEL = : 0; + cr |=3D flags & PR_SHADOW_STACK_WRITE ? GCSCR_STREN : 0; + cr |=3D flags & PR_SHADOW_STACK_PUSH ? GCSCR_PUSHMEN : 0; + + env->cp15.gcscr_el[0] =3D cr; +} + +#endif diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_= prctl.h index ed75b9e4b5..621be5727f 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -6,8 +6,10 @@ #ifndef AARCH64_TARGET_PRCTL_H #define AARCH64_TARGET_PRCTL_H =20 +#include "qemu/units.h" #include "target/arm/cpu-features.h" #include "mte_user_helper.h" +#include "gcs-internal.h" =20 static abi_long do_prctl_sve_get_vl(CPUArchState *env) { @@ -206,4 +208,98 @@ static abi_long do_prctl_get_tagged_addr_ctrl(CPUArchS= tate *env) } #define do_prctl_get_tagged_addr_ctrl do_prctl_get_tagged_addr_ctrl =20 +static abi_long do_prctl_get_shadow_stack_status(CPUArchState *env, + abi_long arg2) +{ + ARMCPU *cpu =3D env_archcpu(env); + + if (!cpu_isar_feature(aa64_gcs, cpu)) { + return -TARGET_EINVAL; + } + return put_user_ual(gcs_get_el0_mode(env), arg2); +} +#define do_prctl_get_shadow_stack_status do_prctl_get_shadow_stack_status + +static abi_long gcs_alloc(abi_ulong hint, abi_ulong size) +{ + /* + * Without softmmu, we cannot protect GCS memory properly. + * Make do with normal read/write permissions. This at least allows + * emulation of correct programs which don't access the gcs stack + * with normal instructions. + */ + return target_mmap(hint, size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | + (hint ? MAP_FIXED_NOREPLACE : 0), -1, 0); +} + +static abi_ulong gcs_new_stack(TaskState *ts) +{ + /* Use guest_stack_size as a proxy for RLIMIT_STACK. */ + abi_ulong size =3D MIN(MAX(guest_stack_size / 2, TARGET_PAGE_SIZE), 2 = * GiB); + abi_ulong base =3D gcs_alloc(0, size); + + if (base =3D=3D -1) { + return -1; + } + + ts->gcs_base =3D base; + ts->gcs_size =3D size; + return base + size - 8; +} + +static abi_long do_prctl_set_shadow_stack_status(CPUArchState *env, + abi_long new_mode) +{ + ARMCPU *cpu =3D env_archcpu(env); + TaskState *ts =3D get_task_state(env_cpu(env)); + abi_long cur_mode; + + if (!cpu_isar_feature(aa64_gcs, cpu)) { + return -TARGET_EINVAL; + } + if (new_mode & ~(PR_SHADOW_STACK_ENABLE | + PR_SHADOW_STACK_WRITE | + PR_SHADOW_STACK_PUSH)) { + return -TARGET_EINVAL; + } + + cur_mode =3D gcs_get_el0_mode(env); + if ((new_mode ^ cur_mode) & ts->gcs_el0_locked) { + return -TARGET_EBUSY; + } + + if (new_mode & ~cur_mode & PR_SHADOW_STACK_ENABLE) { + abi_long gcspr; + + if (ts->gcs_base || env->cp15.gcspr_el[0]) { + return -EINVAL; + } + gcspr =3D gcs_new_stack(ts); + if (gcspr =3D=3D -1) { + return -TARGET_ENOMEM; + } + env->cp15.gcspr_el[0] =3D gcspr; + } + + gcs_set_el0_mode(env, new_mode); + arm_rebuild_hflags(env); + return 0; +} +#define do_prctl_set_shadow_stack_status do_prctl_set_shadow_stack_status + +static abi_long do_prctl_lock_shadow_stack_status(CPUArchState *env, + abi_long arg2) +{ + ARMCPU *cpu =3D env_archcpu(env); + TaskState *ts =3D get_task_state(env_cpu(env)); + + if (!cpu_isar_feature(aa64_gcs, cpu)) { + return -EINVAL; + } + ts->gcs_el0_locked |=3D arg2; + return 0; +} +#define do_prctl_lock_shadow_stack_status do_prctl_lock_shadow_stack_status + #endif /* AARCH64_TARGET_PRCTL_H */ diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 0b19fa43e6..6f0bfa83db 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -126,6 +126,11 @@ struct TaskState { /* Extra fields for semihosted binaries. */ abi_ulong heap_base; abi_ulong heap_limit; +#endif +#if defined(TARGET_AARCH64) + vaddr gcs_base; + abi_ulong gcs_size; + abi_ulong gcs_el0_locked; #endif abi_ulong stack_base; int used; /* non zero if used */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 91360a072c..2f1e881046 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6351,6 +6351,11 @@ abi_long do_arch_prctl(CPUX86State *env, int code, a= bi_ulong addr) # define PR_SME_VL_LEN_MASK 0xffff # define PR_SME_VL_INHERIT (1 << 17) #endif +#ifndef PR_GET_SHADOW_STACK_STATUS +# define PR_GET_SHADOW_STACK_STATUS 74 +# define PR_SET_SHADOW_STACK_STATUS 75 +# define PR_LOCK_SHADOW_STACK_STATUS 76 +#endif =20 #include "target_prctl.h" =20 @@ -6397,6 +6402,15 @@ static abi_long do_prctl_inval1(CPUArchState *env, a= bi_long arg2) #ifndef do_prctl_sme_set_vl #define do_prctl_sme_set_vl do_prctl_inval1 #endif +#ifndef do_prctl_get_shadow_stack_status +#define do_prctl_get_shadow_stack_status do_prctl_inval1 +#endif +#ifndef do_prctl_set_shadow_stack_status +#define do_prctl_set_shadow_stack_status do_prctl_inval1 +#endif +#ifndef do_prctl_lock_shadow_stack_status +#define do_prctl_lock_shadow_stack_status do_prctl_inval1 +#endif =20 static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) @@ -6467,6 +6481,21 @@ static abi_long do_prctl(CPUArchState *env, abi_long= option, abi_long arg2, return -TARGET_EINVAL; } return do_prctl_get_tagged_addr_ctrl(env); + case PR_GET_SHADOW_STACK_STATUS: + if (arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + return do_prctl_get_shadow_stack_status(env, arg2); + case PR_SET_SHADOW_STACK_STATUS: + if (arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + return do_prctl_set_shadow_stack_status(env, arg2); + case PR_LOCK_SHADOW_STACK_STATUS: + if (arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + return do_prctl_lock_shadow_stack_status(env, arg2); =20 case PR_GET_UNALIGN: return do_prctl_get_unalign(env, arg2); --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179085; cv=none; d=zohomail.com; s=zohoarc; b=I3M+Z4Bo5aC7Ag+A2HrJmmCx8kgfR71RS6emJbyYfGOWGnFWNLzD8epjS4S+j98bLcuiow8+L01erc4mPWj1WpkAj6uPMuKNB8l3o//ZiLCiVr4DBIJocU7XQFb5U1e1z7MltAk1znA2YoLlOGVTVjwVP5TVLPB9hARofhlkYeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179085; 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=RrRDTwGDphkvvBtsV/mK2pHDoMT9L4tWZDtSjWVgm+E=; b=mPSq8ZoouQ0ta7H1s2EF6D937Gz1Ge+TYRZgVzKAHm5lvtJBr+R02YtVlah+MTpJhl6vqevFzXYbUxEViYBGwjwtn21w2KkfI9VvsSBvJK6ba6rQnNZgpAMaHWAEgeivdQw2+XyeeAY72TnZ0PA6/BH5slSHLjlnrfZDeo8//+w= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179085360484.8758241663428; Sat, 2 Aug 2025 16:58:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLwj-00031t-I6; Sat, 02 Aug 2025 19:47:27 -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 1uiLoX-0005ze-KH for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:03 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoW-0006Rr-5E for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:38:57 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-741a254d4a0so895680a34.1 for ; Sat, 02 Aug 2025 16:38:54 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177934; x=1754782734; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RrRDTwGDphkvvBtsV/mK2pHDoMT9L4tWZDtSjWVgm+E=; b=Wfk0ZuNYhfQNg9bgl1kFYjOelfS6gyUWT0rtWjc8aWSEpgzVYvTJ6d1L+VzVbw3HXK Utl3/vBScFk2EJM4yxz4uwJY2VA1Jo3b7wMguhFTxVEz02D/7HYRJD4tLh3SfR2hNSu+ bl5dpINX5RQwKYbbT13Kuwta3vzLOFxCSA/Rc+KMf7GzdTdwcl4EDYfTxXtYcifGARdu cinekQzsvVz8qUnGgJaKB1NeHS3U1S3xqLM7B1ZB11wi34a/OctaK+CSXztZrzfRZ6Wf GuEY8FW/gsII7+++vJYHqD9zUVuPiPoHU6VER9In8IkScNjiaRMUq/VIY8YRBKYZvOF7 pQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177934; x=1754782734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RrRDTwGDphkvvBtsV/mK2pHDoMT9L4tWZDtSjWVgm+E=; b=BpeOzMA11+HI+kAyXXknkIdTNkr0GIZHlny++wqVb2Z0ZV76dOtNxII/r2tFEi4Vgw sHsCazSUhKsXYq14TtFa0YyxQreuu8USJ/fispbu8rS7ggAVGBlWPfty7q61ulnhLxYj fLY/jc0kfFD08HgUG4E8icEA3esUEKjFNna5y8wQ4lP6QixWF1QhD2hQxC9ue92PpAT6 XPLhKH3xm/hogU2DOu5LfXWufXNz5Wjv/6fkUdCJGEDz7la9i4bsZufRN4inSI+WB1R7 pRFRuT/SXf83cHJMZDdGGfmEPnXQzJ/W+kvYKUw/KQOLuu9YU/l5tIzbMjaUXAhdB1gJ NiMw== X-Gm-Message-State: AOJu0YyesgZ5bHOY3waAOA9FGVEqtZOCIkxHYEAZvCoyFyixm0fsKIrC 5GXpsD0wu82Sf18hn+nYrn9qALxKOkOKbUscsTjOaq4OZjymnT3xraTMJ7tYCSH/yqUbErbkpZR d1bHjetk= X-Gm-Gg: ASbGncu+yJoinjG2JjFZpGI7MfSpSpBtV45IN7iy/zQYjaK3yAMubAsoBTyyFXpXrOp mI+3HQHHlKIYooO74HsYdh6cF72Af61ROr2EfPSr1lpxM7ScgFlw4Hs7WPNrG9/tExlkofe/L1y 16VvxcBdAYgGGyLwsqG+UVGyrL7G5Wn5cggWpp2lK3NoWb9C62SwutINjTYvO8F7FksFNHSLM6C SZOkfL9XUSFgiV4igUvUvq6LDGUeKuTwFLEzS+lkwtzD4WfxlvVG/co1O/LoWRX/0xyqSCAjZUl e4P5GeJHeMVsQbW2vjQm/nSNsr47GUO2m6RxWiIdjOyHnTopVzp50un1a1GADKTnEGgo2qQxp2K 6KkqbBfqUxoShR0EioMrX+4hpRAY/m49c6ZyaCsL6dsCzh04a58Cn X-Google-Smtp-Source: AGHT+IGw1bzQ4Rg/QOqe126gdbj/vnQBc0bhhNVwYVofR6EJ80zR6O5rhc3XIZCixKktVa9F3169iA== X-Received: by 2002:a05:6830:651a:b0:741:4a0f:b869 with SMTP id 46e09a7af769-74187ab6780mr7075066a34.13.1754177933982; Sat, 02 Aug 2025 16:38:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 75/85] linux-user/aarch64: Allocate new gcs stack on clone Date: Sun, 3 Aug 2025 09:29:43 +1000 Message-ID: <20250802232953.413294-76-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179086810116600 Content-Type: text/plain; charset="utf-8" Allocate the new stack early, so that error reporting need not clean up other objects. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2f1e881046..91210775ed 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6652,6 +6652,21 @@ static int do_fork(CPUArchState *env, unsigned int f= lags, abi_ulong newsp, ts =3D g_new0(TaskState, 1); init_task_state(ts); =20 +#ifdef TARGET_AARCH64 + /* + * If GCS is enabled in the parent thread, it is also enabled + * in the child thread, but with a newly allocated stack. + */ + abi_long new_gcspr =3D 0; + if (env->cp15.gcscr_el[0] & GCSCR_PCRSEL) { + new_gcspr =3D gcs_new_stack(ts); + if (new_gcspr =3D=3D -1) { + g_free(ts); + return -TARGET_ENOMEM; + } + } +#endif + /* Grab a mutex so that thread setup appears atomic. */ pthread_mutex_lock(&clone_lock); =20 @@ -6676,6 +6691,11 @@ static int do_fork(CPUArchState *env, unsigned int f= lags, abi_ulong newsp, ts->info =3D parent_ts->info; ts->signal_mask =3D parent_ts->signal_mask; =20 +#ifdef TARGET_AARCH64 + ts->gcs_el0_locked =3D parent_ts->gcs_el0_locked; + new_env->cp15.gcspr_el[0] =3D new_gcspr; +#endif + if (flags & CLONE_CHILD_CLEARTID) { ts->child_tidptr =3D child_tidptr; } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180165; cv=none; d=zohomail.com; s=zohoarc; b=j4w1UHMtWDZCOpK6dsXXYJZJTydzasGiE99MqzMIcr7fFc96ZaGQzemLgVrdq2rCUqnjtyqk1mLOArbOY4x+gObDGOz2qpEt6h5VkSxGkovULWW0JTENkZuhcbp8aakocxXMwjkR4GGZ2MQ97uXFb61nA3cw5WEcV0w0TslURiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180165; 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=Bac99cWBoODM0lZjzPV8FafpKsc60jTDKb6XVoHXo24=; b=S2kBrDm4+C/JiayYocPIXlCJ2Obf3NphMjV2yxV7VNQ+bXIicwwfUKTMK6PUiLXBssUcj995s6HnA3HJX5bXIvnP6pCsNhTOjdDVDgvrWw8Rce+g0XCA+KTAayCFOqoT89gj6e90FmruoYGbL3YIrpi0Fn454yvBIzmYljSk85o= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180165490610.7730738106793; Sat, 2 Aug 2025 17:16:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLws-0003WQ-Jo; Sat, 02 Aug 2025 19:47:34 -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 1uiLoc-00060a-Fk for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:03 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoZ-0006Se-Gp for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:00 -0400 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-74197e72d3dso709956a34.3 for ; Sat, 02 Aug 2025 16:38:59 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177938; x=1754782738; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bac99cWBoODM0lZjzPV8FafpKsc60jTDKb6XVoHXo24=; b=bFIi8dMk6OPSVq6xjeSi6zKmtZ+Wh9uUsmbiZ/woS4hYBrv7pnDhGfGqRU638FnLED bYORC45c1tgvByKKXA15UZkNwLTsNkR5iGLJTSFCF68q7kxsoH7gIZI9bRjjni4Dqnjd QDZi3hWiDuIEyjDfRmI1tG/zCIJ0aZlMVuY1YYUmtfrYh76ze0Zy8Q/GCsk1ijom27KV Z5ntaYVWuWa/3EycP0Wl+T2Qsha9fPPsQWysWd367Xq/eX4BLUa+Lxpadr/EZfMARgWu e7HKO2teqccoypnXugimTnL46gyInkUlBVzeZ8IRs9J/v28xVI69IIJWOluZizGkq+su cPKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177938; x=1754782738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bac99cWBoODM0lZjzPV8FafpKsc60jTDKb6XVoHXo24=; b=WDfmK/TFPfSkz3/BsbEnZT8givdMkiFrlHltPiozZ/XAzPnUeXATrN4FtvlA29m9QF Qr5fN2Ld3aXKLryG+4gEhCUcm5+p5T1zQr3l8bLr5cg35gjYOPF5mH3APQEuYSIytk9U mAY9wl3y0miKGDnLmT1xFBgF2LFSYW0OY9vfoL9rp2BIzRSnB1wl7KG8i5+qBLzLLSJQ /1fFXTWZ1Eg0U+D8L8In1ndpRUpn0hzZg0omNCLXK1ggiPnbuZR47BATjjmWVTvplz3E hzvhvwDoEf2a+0gqMWoMdpInx+C84Q91wxlo31PXn/st4mxJdZbaN1RwqIhHKU8enxrU /nhg== X-Gm-Message-State: AOJu0Yys3Elj3GL/ajPA47qoMBdVU2Ig2BqQNo998oPB1e1bj0fSrTYF f0hzH00KSc5Vg+n+xoyioFJHCgi6HtqIkdx6F6B5vMhY7gEXwXtg4PaG7sBORT+qDPSv4EzDgLe K1aPebz8= X-Gm-Gg: ASbGncuXcxbXD6pliMQT+IjhDeJAowSmWS8DzJ9xcXP7oyjBTcoGG/lAqvYGXgti0EY 0WaGHx7p0rDzYpHkFwylW0A8wgRnrn+jwZh4+fP37LBup6wRZ4crNakGhFhMgoZGxLNahsUBtzd wVgMbUkTCTWUnSlf1S0zEnBPwqX+bQJhI+n5JvlEidLnvbjRHJVDqvet06yca1Jwif69klOk7je smPOp9Lak7tQQrEMzkRZH0010JpmSyqlG1nmCE8A9lgkckkjpDnaF3l4Ek0IbUoPhnHl9FKXigK 9/MCEkdVuYNxH6GHaPzExfJQX+bBav45B2Hl6HsZW6wZkcbrLWr9Voed5QWIk52psOYpGDfwIMV 7pzoursTB1m5Dt3VAvVOvugV2SktfqvHv4E2qVZXg+AoWy8YXtgOx X-Google-Smtp-Source: AGHT+IFd12Afo8QLFxyH/ZRsIH+89fl14VFvq+w7cMHvbMzfQ9zIJGF7ErYF9J5a6uxYhzuZOijjdQ== X-Received: by 2002:a05:6830:448c:b0:741:afb2:7ad0 with SMTP id 46e09a7af769-741afb27de7mr357618a34.17.1754177938449; Sat, 02 Aug 2025 16:38:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 76/85] linux-user/aarch64: Release gcs stack on thread exit Date: Sun, 3 Aug 2025 09:29:44 +1000 Message-ID: <20250802232953.413294-77-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754180168581124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 91210775ed..dfe114ceb3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9309,6 +9309,12 @@ static abi_long do_syscall1(CPUArchState *cpu_env, i= nt num, abi_long arg1, FUTEX_WAKE, INT_MAX, NULL, NULL, 0); } =20 +#ifdef TARGET_AARCH64 + if (ts->gcs_base) { + target_munmap(ts->gcs_base, ts->gcs_size); + } +#endif + object_unparent(OBJECT(cpu)); object_unref(OBJECT(cpu)); /* --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178496; cv=none; d=zohomail.com; s=zohoarc; b=FIq6f7jwC7bE3845dXv7VLdRdaPTF8VRfW7SbW6w+PEaYavo2cX2+TVRzlP1DQT/pleQ/0itpbXTFLLk67aDMG4BGVMFTJSmjdWaANsiBT/xKaxNU/xUmpxgeCzsvhywNbsb0nXA6FXMgpiXkHBoRTKUHrf+u+dNSriNwRoXFqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178496; 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=H0WgDnjZZbQNGrZHbHxQl5y/Vvc/Dh17BYKXEKy/nEk=; b=e2Er/ZYkWJjoPClJPzbxDv+IBVAjKbRCQoJIaI8v4FMvU3lOKGeebX7M3HwpTyEfGevrD3s/VsrxVvjHRGTu7bKXu5KkWRSLArMTPqPiI8jejZJ1JmJUEjPZYwdAg+u+MTr2P8eILQSZU6xnDLZCRq3vxUivJPDu2Ohrvu4dkwI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178496623473.3817713767809; Sat, 2 Aug 2025 16:48:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLtS-00075w-EA; Sat, 02 Aug 2025 19:44:02 -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 1uiLoh-00068r-6e for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:07 -0400 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoe-0006TY-8r for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:06 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-30b83108f7aso194766fac.2 for ; Sat, 02 Aug 2025 16:39:03 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177943; x=1754782743; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H0WgDnjZZbQNGrZHbHxQl5y/Vvc/Dh17BYKXEKy/nEk=; b=XLNK9DFOGsoL+ETKzxTAt0uFk/g/elcs7d644a2bykN+GD7gngUKyfNiW4AoR/7hZO PAirobPNPnc9TN+fG2V+EYNVybRDhggdln1NseOCabf4zfu+pn/W6/J6/OWaL3w3psKD RkyyLYEEGtSmi+bv1PXxsFYKeLtHbh+mFTZbzRbO0hBAJVdzclpEUh/bNZqlmSN1Z63Y +wPyHnulQtfbB7T1hlGA+FNc5BDEZag488ttjeDwVsavvSEvdkCW+cTVjGQSFeKJz7VB VbVXyHsZaXVZ6M5NNhgbewS8T03VC0uciPk3LDYQhYG2P1y92X+ZfJnP5ObAaJLvj+Uf Eeqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177943; x=1754782743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H0WgDnjZZbQNGrZHbHxQl5y/Vvc/Dh17BYKXEKy/nEk=; b=q+aDcFF5NTYG+x6LV8SoCWsMkrA6Sx58AzEOrAstHrWzTsA73AdzQ1md61mCW4ogBe AlTsKbpu1r97tzZ4vwGMMJbmpsw1RhaZFPXWuKNI+2tL0evjXwBBCZMzmpue/3kYQMRD Ri8Xerr91wRqCfVulXWisNEf/C0XpPCcKMfadoo7KWN3xjg5X9GJ7fmii0xFy0qSesZm 5SYgOGvyAv42JKUwhOHbv8QaBsl3Qq7AsPJwIC0aQuQG6XUmpITD/cHuGQXuGToagX5L J7HXhzr59x7OAo+hdtDTPaLwdP6eg0lbblsMhajPmLOoQqRoXW33UvrgeTwb2oKjU4kj z3kw== X-Gm-Message-State: AOJu0Yy2iBiOpQZCtVt5CCLSsBnVi+Ce99p4l8Evd4jMAeszr27OL0DS B0fJnHVpw5jlJroMmSJ/jmSCiJDRdXWUjJuw7Z0+DkU8SICP/z4JG1co2dCroVQNv1kGNrljf/w 10mbluJ4= X-Gm-Gg: ASbGncviiEtAeSLxyel/0pXGgFwkVrlfvmkXF5AfRoBg5nTSjObL/8Jq8ji0wdl85dD 6yrBZbQWWt1kkssEfVMQXlWZubfWvlj1YWMZBKyfV25eGP6caaBOFQ2MsvqTJappofJCgATYWmf WYi517VvWV6kpoyaMrOCWZEgxRMwdT5D5fDpEgnQwItYhgGlKU2xdTNJA954wztg0mmrAQV4EAB PbRVFnODrQAHd/ufcNBCl8kx3n76Yc76nHf8p1riSgxFFgpkkfBBczMpd4/AJ5PRCZglkpC/GB8 N7s5OKJZ7SlGbJ4LZ7ngPDqS1a0JqIK5aagv1VQalLa1X9+q1acQBKeBi+1nypiNtWsWzv56aRA K1m9jbMdnAPNzu3VPR9SlbNq9wrAcq7CsMq+OGvZMdaB+FbJKqy1p X-Google-Smtp-Source: AGHT+IEGEGmJuSQXKJr3IW7VWVlfBgvkWJqCLESU5QFN8Z83xsCW4qPWXnqDsMWhihuxVbCwsF4OwQ== X-Received: by 2002:a05:6870:e24e:b0:306:9f1d:da2a with SMTP id 586e51a60fabf-30b675e5adcmr2628388fac.5.1754177943018; Sat, 02 Aug 2025 16:39:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 77/85] linux-user/aarch64: Implement map_shadow_stack syscall Date: Sun, 3 Aug 2025 09:29:45 +1000 Message-ID: <20250802232953.413294-78-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178498413124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dfe114ceb3..0a7ce7a262 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6356,6 +6356,12 @@ abi_long do_arch_prctl(CPUX86State *env, int code, a= bi_ulong addr) # define PR_SET_SHADOW_STACK_STATUS 75 # define PR_LOCK_SHADOW_STACK_STATUS 76 #endif +#ifndef SHADOW_STACK_SET_TOKEN +# define SHADOW_STACK_SET_TOKEN (1u << 0) +#endif +#ifndef SHADOW_STACK_SET_MARKER +# define SHADOW_STACK_SET_MARKER (1u << 1) +#endif =20 #include "target_prctl.h" =20 @@ -6571,6 +6577,54 @@ static abi_long do_prctl(CPUArchState *env, abi_long= option, abi_long arg2, } } =20 +#ifdef TARGET_AARCH64 +static abi_long do_map_shadow_stack(CPUArchState *env, abi_ulong addr, + abi_ulong size, abi_int flags) +{ + ARMCPU *cpu =3D env_archcpu(env); + abi_ulong alloc_size; + + if (!cpu_isar_feature(aa64_gcs, cpu)) { + return -TARGET_EOPNOTSUPP; + } + if (flags & ~(SHADOW_STACK_SET_TOKEN | SHADOW_STACK_SET_MARKER)) { + return -TARGET_EINVAL; + } + if (addr & ~TARGET_PAGE_MASK) { + return -TARGET_EINVAL; + } + if (size =3D=3D 8 || !QEMU_IS_ALIGNED(size, 8)) { + return -TARGET_EINVAL; + } + + alloc_size =3D TARGET_PAGE_ALIGN(size); + if (alloc_size < size) { + return -TARGET_EOVERFLOW; + } + + mmap_lock(); + addr =3D gcs_alloc(addr, alloc_size); + if (addr !=3D -1) { + if (flags & SHADOW_STACK_SET_TOKEN) { + abi_ptr cap_ptr =3D addr + size - 8; + uint64_t cap_val; + + if (flags & SHADOW_STACK_SET_MARKER) { + /* Leave an extra empty frame at top-of-stack. */ + cap_ptr -=3D 8; + } + cap_val =3D (cap_ptr & TARGET_PAGE_MASK) | 1; + if (put_user_u64(cap_val, cap_ptr)) { + /* Allocation succeeded above. */ + g_assert_not_reached(); + } + } + } + mmap_unlock(); + return get_errno(addr); +} +#endif + #define NEW_STACK_SIZE 0x40000 =20 =20 @@ -13945,6 +13999,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env,= int num, abi_long arg1, return do_riscv_hwprobe(cpu_env, arg1, arg2, arg3, arg4, arg5); #endif =20 +#ifdef TARGET_AARCH64 + case TARGET_NR_map_shadow_stack: + return do_map_shadow_stack(cpu_env, arg1, arg2, arg3); +#endif + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178673; cv=none; d=zohomail.com; s=zohoarc; b=ViS0cYSMamIvMJS3M6UVg2sGcBvKSW4vJl/bVqSGogigW2R2oGG3W5aJKEEFLAGf9o7ihJ8czOl7/OYQoWsATnKDyl3oYKbpVxg3M/3l8b4Ek0K5+pnCXBwjfBvrwD+hzs/h23F8+yuiCUjBsIlt6VkHN5hgnpWoG4n5zyAOrIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178673; 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=ZELB4+c17Zgz1LBTVaRPLkTpYEUU2ZnNce3ABKyIZzo=; b=T0O324W5GS7cglX97mZZEtGLxOUhSKDFwUeuXxYaVHbldzhT+C7gEYUXytl36FTTF4xD3ysdt5ueC3po9Ul1CT/PQE3gVPAT/fi6JCIBrT/jjTWJ4OsSzfd5wRSk327J7bBzgnHFRkDrlXnXztjTIvb+fDPcmFGvJsspbN448VQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178673883211.64064432121063; Sat, 2 Aug 2025 16:51:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLtg-0007J9-7h; Sat, 02 Aug 2025 19:44:20 -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 1uiLol-0006Rb-BW for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:11 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLoi-0006Uy-Qt for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:11 -0400 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-741a254d4a0so895752a34.1 for ; Sat, 02 Aug 2025 16:39:08 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177947; x=1754782747; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZELB4+c17Zgz1LBTVaRPLkTpYEUU2ZnNce3ABKyIZzo=; b=mYO2mnHTTdnJMV2qUKKrAUu5gk/FoQ+EeKMnANZaQoe0QEcWCS7SGK+S06yWbv5VrC JprO0MHsAhyIf19rtm4dt0kAaA1aJHQt6WNvzgRUMNSUozJH61/hzQ1rhCxnOQx38HxU rVKqUF1wHUWOJmQ7VL4vGNfyDEUs71Ypa9HV2XL0Xc1zEGRQn/fUr48oN+F3P+7FQW7P f1sgnmxP3Rqlb+gqsX0LoNL6NSxrwMY8HKn40wwL9OoFx5Zyy/Aaw5P6ifO/h6kIuWLA cs6o1VNC/IhrVAgbxWIk+QIxcfoSt7uPrCGIyw9KyjkLinss6pJf4pRgjgiebwlRNzpZ jwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177947; x=1754782747; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZELB4+c17Zgz1LBTVaRPLkTpYEUU2ZnNce3ABKyIZzo=; b=kPaJr/O7t8wJHLSURoK/D5TKrlK9AeIgwuBjVvIRl+1C8C2Pp687i+UZh/7PIQWSA6 sGSeBcvzX4uk/TT2idlJhs1UJ0VH5oh+r4X25wgOCbTO4rYVPp2PwxmYSImcGlywmEOg i/CjsmPeAQI9/mwiJJyL7MP37Xghy0NVKB1CVrF4HvWa7dGMSAS49V6NPCAKn8iaJrtu ZYCEdSZHRqTKdXGjOOXsgJJ1FGktNio20sACVXJJJa+zZKlQLCMZgmzSDUEFBVagLios HBHF+gMlVELBZ28kpzzv0Y1kdyTFQMgKjEn6/C17Y6vkUeqN6ZDHwALQw1CK25iG26bA Tnnw== X-Gm-Message-State: AOJu0YzC48E3tht+dnwRZ8u2QH3eP8wEk3etQ8dRf+bwVX112q4lh6TY 5ToNOJTO07LRW2NpJz4BI5QoRl9uKmj+DJAmNXAGxyTEpMbawAUpFX7I8NTT1bI1+DR0QnaPuo0 XM1EcQig= X-Gm-Gg: ASbGncs9vWAi/yiuf9/3tXVsVYNURqFDLELnjuA/2rxd6Xqkf32wGBK6Y1TuOf/Ms3z aO4lVZ8urrgYx5gxJ3PKack01pski7RdZK9W+R1GDuROCzTZyyj5G53EKZsOf8eaCjb3FNgOcFh dR+LMMBYQX5uuDONughDWfDvEOpR9rTpnP0P+XqropJ9sHmWeliPpdAWWEXwd1mKXp7wTlnbyx6 lm5EGGSPl/4SIsbvZqabNDVoLwjPtcVtpUhFabrJ7NrcSlnH3MvN5ZznqJViO4I/zxbjRN0mTL1 m19haWC8UaYBE1z6HNspLcM+8o1509+CSL3FHaxhWi7lQWHiHMRc2YVLknessarvInvJ/cP+GRy xLV5OOCNnvB4PpnSOI0dYXqkUgQ2LkSvjyJInFiiYJMMicB1HZ+ST X-Google-Smtp-Source: AGHT+IHnCCpJSDXAGpmY2SYqxwmeyMlu0IYldiLnS6LWJvYlivhbMTL8TMZTDe1RMcG1s6ZkhQun9Q== X-Received: by 2002:a05:6830:308a:b0:741:a8f0:db5f with SMTP id 46e09a7af769-741a8f0dde3mr980023a34.7.1754177947502; Sat, 02 Aug 2025 16:39:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 78/85] target/arm: Enable GCSPR_EL0 for read in user-mode Date: Sun, 3 Aug 2025 09:29:46 +1000 Message-ID: <20250802232953.413294-79-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x335.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754178675880124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ec63297165..284d1870ec 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -317,6 +317,10 @@ static void arm_cpu_reset_hold(Object *obj, ResetType = type) env->cp15.mdscr_el1 |=3D 1 << 12; /* Enable FEAT_MOPS */ env->cp15.sctlr_el[1] |=3D SCTLR_MSCEN; + /* For Linux, GCSPR_EL0 is always readable. */ + if (cpu_isar_feature(aa64_gcs, cpu)) { + env->cp15.gcscr_el[0] =3D GCSCRE0_NTR; + } #else /* Reset into the highest available EL */ if (arm_feature(env, ARM_FEATURE_EL3)) { --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179409; cv=none; d=zohomail.com; s=zohoarc; b=ZXM9eki3yNIo6GlwSaNsf3e7bqmZElZURfWnqgB1Q93reu5/ZjP4oCgGv1qx/C3Ph52zlF2k6Dla69hA2J2Xb4F2om1/MR8ZP10dTBP+7LHvuNrQGWI+WBd602pZ8bMpXShjgco09qRSmCt+2AWioyfVBZFy9QmPIzvl6UNWSXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179409; 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=t8F7bykdU84vRmZk6Tsw4VS33Ms7cDyMlR3YasKxJts=; b=GcB0Oj2GSoUtS9JurGV2RZ/fnR16niox7eaD3yrEhiLGNsF9gZloOhtiDJH7R/GYA2VJgQdtYGO/th5XdewVLJStpTS1UYv4aUz02STpA3EkQBXe5+0AAB+cl6D6QPD9A/WcEUmJpvfY7gGVyLO8KTQvTBqn5YEGiMg5f2fhx8c= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179409684383.3672793616404; Sat, 2 Aug 2025 17:03:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLur-0000JW-Gw; Sat, 02 Aug 2025 19:45:30 -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 1uiLoo-0006gz-7k for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:14 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLom-0006Vn-KP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:39:13 -0400 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-741a5e8fa94so126888a34.2 for ; Sat, 02 Aug 2025 16:39:12 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741a71dc78asm380409a34.30.2025.08.02.16.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177951; x=1754782751; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t8F7bykdU84vRmZk6Tsw4VS33Ms7cDyMlR3YasKxJts=; b=FesdFGAB9tGBIVC85akEQV/42L/1VKN6m+KXq66lN5DwS59/P8SZWi6vHX7GXBCNjh kgIoJaSBD5BchEthhmNLnLQyxt8pk7II9w8fNWhy9tM7hY1MalqE2ihn4XFaEWu3gEva ptDHBGo6pSApRpgfiqXSOiYl3RfyXXN4cy6S2XKkd5/rUEccau1+/T45Q1fh72drHpDz iImSp0zJMkElXPW37SMYeFLfVqGSNE8vA/D1segjBU6ewyAZy6Kl/Xi+0y9p9F2o84Ki 1Qsi7QHa/TR2UDqokd/w3SXCD7L0tkiMdYb5r4TmGNFq1E+Npw+AY9vtaYyLxwUABmhT esBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177951; x=1754782751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t8F7bykdU84vRmZk6Tsw4VS33Ms7cDyMlR3YasKxJts=; b=hIfvbMgAmZOQmzHGQpkTqemLkVy2niFiQjOhOc5TprrNwZFywJxHX8Cb+7zrNArKW7 F8oTUOZmZGtuMx01O07UiH3WqNJSX/QxY0diQZXtRzR0b4HtuDuA+IPZhs4pynCfxi6J eHLET6fV+MjUs9vKp2PfV8+wmxfHDVt6YzzW1jjEFa9Qxs3ebbExuVE+cbkqCU+Ms6NB 6TTTxiwI0pMFCdUS9bOYXK32/K56VMCwOzNG0DQLCObK20oRqQrQa5PjN+6lgEJ+Uwp8 2koKJcWYqDBJw7OgLlYdGoROveub6OjRnHPoCpXm/04cKCBhgV3Xr4zjKcUi/Rlh4qgB iHcQ== X-Gm-Message-State: AOJu0YwL+PgGBzv3+zjq0Y+PBkzuoUBxS7npEwnl2MWntawoUWcJH3Ov JVHv59Rv7Jw5VOdqfW5LHGjQD9A2f63ZqGcNWBIgNWjkyzP2zzInOZNn7NNtaFGvdBcTpMJhfIT ZkVtx2D8= X-Gm-Gg: ASbGnctuvQ8ddlq8T7nyBvwLEafdLz/e2iceDezLDvasxBCmqJe1B3smc53v2PN7BST B0ag9Ihi1QtVwUsLjKV/GwD63YFT0bK4q+/2evAvvET9mYa1VhCo9RMKEXe/GSIIHtEHLuRl54s z5gDXg96u+0ifmzdP/9vpPiHhmrlEX0XbOEsyFnJQQ+CLEBUq5divhM8wcyjJ57U6+whAzBTnkf T1/Xines9AMzGh6cgraMcC2QmWqC5AI7er2rXUdy6LFkt2tRhg69kAVQWEbqOluXhjpkrkoPyE4 sDHcyK27pYEEZQSaQ66wVMMDEuto3ceAEejydyWBHbcizn6NYdLza7mj+Dk5wYn+9a0OJY2w2ZH uPJo/5L/zY7tj7X/nj/NUrouZuBrwHSvDidZ4pM5glGdPaOfTxEto X-Google-Smtp-Source: AGHT+IHa9BMw9HS0OAMrYFi0TYiHgavg1XJPlvZn+O6noh9C4jNmWqaRZas8VfBs21o4UKewUl7HDA== X-Received: by 2002:a05:6808:4f29:b0:401:ea7b:e535 with SMTP id 5614622812f47-433f030038fmr2709795b6e.22.1754177951427; Sat, 02 Aug 2025 16:39:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 79/85] linux-user/aarch64: Inject SIGSEGV for GCS faults Date: Sun, 3 Aug 2025 09:29:47 +1000 Message-ID: <20250802232953.413294-80-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x334.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179411900116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 1 + linux-user/aarch64/cpu_loop.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target= _signal.h index 6f66a50bfd..e509ac1032 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -7,6 +7,7 @@ =20 #define TARGET_SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */ #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ +#define TARGET_SEGV_CPERR 10 /* Control protection fault */ =20 #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 7e9788abfb..00ff51c883 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -89,6 +89,11 @@ static void signal_for_exception(CPUARMState *env, vaddr= addr) si_code =3D TARGET_ILL_ILLOPN; break; =20 + case EC_GCS: + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_CPERR; + break; + case EC_MOP: /* * FIXME: The kernel fixes up wrong-option exceptions. --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179796; cv=none; d=zohomail.com; s=zohoarc; b=meQz5QCCXc97c52Kh4wj8R+5QEV2X++EH60wgRozf8Cqjq+yfqed+pMTAmJkzsSUM4Dll1LTe7t4+f37f3F3dcw5r3F1flvto6ckZEtifEcgvHzNzNNezMwTshdQ0vIhWssI539UNG9+I62oqhMOwjJ7WbAGZEkGQ3yrzCQa/1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179796; 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=phDl6U0/TZY10JtlMKITPjr54ln3Z6W42+gDjn37lAM=; b=mkUPFw0RXi0tOys1Q9stuD9VnB+hAZGV+lE+ZOznS8v/epHSjVHh2yjNefj45ea5WDduO7/dSQxXBxou0vqNYfy10qE3ThREoHAdXd22fjKeXI3q2oV7NoYj+gaUgh5nh8aoUiis2qPX1A0pb9RiifXNoIA7KrXabG1aZbQ6MS8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179796713953.0160133305977; Sat, 2 Aug 2025 17:09:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLwr-0003Q4-Mo; Sat, 02 Aug 2025 19:47:34 -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 1uiLrv-0004Th-3h for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:33 -0400 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLrr-0006rq-CG for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:26 -0400 Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-e8e14cf9e2aso2812615276.0 for ; Sat, 02 Aug 2025 16:42:22 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a423f38sm18461527b3.40.2025.08.02.16.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754178142; x=1754782942; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=phDl6U0/TZY10JtlMKITPjr54ln3Z6W42+gDjn37lAM=; b=tWCtX7LwASaP/BqLJ/VLgg2nEC+kHs2LjF1v3ytqcxU9gcW6KpOSJhypWK3U5ayXoT HoKE0iyiP8v1lkQhB0yHnvGA55zgkmjnZBn6N2YsPoEOskTd1hS+HdaS7WEGvs2Qa4er Pchc3til7wg1JK01/wuMwYOPHQi5xPG61eF+93e7jq7tMA7hgr6e+alau/p6L4XJRATJ XxnFSG5m8WQSu1mtiDIpPaY0SrXCXMD3hJlx4IdlK4A8utIJ596OvZgtAwTkPxC9JZH7 ab5kX2U2AYVEfnXUO82qqOPzs4OGWxtRkEXY3lxKE1ysgICWrGRlkn7XTpa0hdzgSMtR h4eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754178142; x=1754782942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=phDl6U0/TZY10JtlMKITPjr54ln3Z6W42+gDjn37lAM=; b=GUaAZ4J3P29WNalGID6Z4CAPEOMyTSGtiBb7rqralQp5sy9hbH41b+qy/DuxQNuVCo xfLGtd2BZUamcQPYxvb5dlN7L1mcWuLcWS1DnfGsFpaYcKf+6zNkldHImboyrJWvRTgc eT9LGorQIFeoU73mvHm/f+mRbTzQD0ROSSafKBpZZx3TNyXvgctL1wkJK9kL9K1QJubA phcpqTubAJd3rYoF0jK79XoQ0KY70OIQ5uk3wmuW4LdlM3tjwwr4y7TRtsrOVH5OAxNq e+lHr+mop5Qy5EWhsJPccJhXcyWd4jf73AfSnj6YWGrRuB1gqO+raQQwV8KsmLuR2x+I +88g== X-Gm-Message-State: AOJu0YwolvSZiOJhaeDf4T1rjrg7VMn/maG9Osn+s7cLtEKa+c3u1hAO ymmnsyfpo392LGcGCGbgbBzLFaMOaJ2pG/mnsLhK5uMBIC9chyVDMiFDFeJ1wHnfGm+uifr4Jo6 yWGJSVpY= X-Gm-Gg: ASbGncuWMSOHOKabnmdgeorQkLA+HtoRx8s8WjE4Cux5w3zQH5D02hSHziQLxDAPQ6v 6Mb8gtUhxiD2wPTQo6u2YCtP9uMwxLA0E4XDzwwn8CopnQ11vA6ms3jClzEUguMXYwwTdxrs7mL BGE+Bv+e0xkGZiEpWbRnOXx+V9th/OidI9vi8mpCaZnp95rXgcllTfVLoRBbQfMtyAkzIZC0XkO LWeg042kzexxs31h1ufWLmmWQUk2mxoQ+aqEZd1MM0rpdy8E9ZO0vOczDcbJii5fihbI/HKMLIP VaQJfY2D7oxYoHmncgrgVV2UzeLfysYpBgQwdDAF8OrP0SmJGfFE2vguY3AagMf8YFp3BeOBwBs ZpkNm7BQrt+WJ8ZslQvz5vXjtw8iDPsPV15VPCv743pgVwv6mkIKe X-Google-Smtp-Source: AGHT+IE3bDgsSnl3CeKolhCyxCECEKWFA/O0rIw8LtgXpByTX17bPwVucPiIzOCrCflSSg/Yzzgn7g== X-Received: by 2002:a05:690c:4c12:b0:719:5664:87fd with SMTP id 00721157ae682-71b7f8ca292mr57516807b3.37.1754178141977; Sat, 02 Aug 2025 16:42:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 80/85] linux-user/aarch64: Generate GCS signal records Date: Sun, 3 Aug 2025 09:29:48 +1000 Message-ID: <20250802232953.413294-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::b35; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb35.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179806665124100 Content-Type: text/plain; charset="utf-8" Here we must push and pop a cap on the GCS stack as well as the gcs record on the normal stack. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/aarch64/signal.c | 129 ++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 6 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index ef97be3ac7..a1957a330c 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -22,6 +22,7 @@ #include "signal-common.h" #include "linux-user/trace.h" #include "target/arm/cpu-features.h" +#include "gcs-internal.h" =20 struct target_sigcontext { uint64_t fault_address; @@ -152,6 +153,16 @@ struct target_zt_context { QEMU_BUILD_BUG_ON(TARGET_ZT_SIG_REG_BYTES !=3D \ sizeof_field(CPUARMState, za_state.zt0)); =20 +#define TARGET_GCS_MAGIC 0x47435300 +#define GCS_SIGNAL_CAP(X) ((X) & TARGET_PAGE_MASK) + +struct target_gcs_context { + struct target_aarch64_ctx head; + uint64_t gcspr; + uint64_t features_enabled; + uint64_t reserved; +}; + struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; @@ -322,6 +333,35 @@ static void target_setup_zt_record(struct target_zt_co= ntext *zt, } } =20 +static bool target_setup_gcs_record(struct target_gcs_context *ctx, + CPUARMState *env, uint64_t return_addr) +{ + uint64_t mode =3D gcs_get_el0_mode(env); + uint64_t gcspr =3D env->cp15.gcspr_el[0]; + + if (mode & PR_SHADOW_STACK_ENABLE) { + /* Push a cap for the signal frame. */ + gcspr -=3D 8; + if (put_user_u64(GCS_SIGNAL_CAP(gcspr), gcspr)) { + return false; + } + + /* Push a gcs entry for the trampoline. */ + if (put_user_u64(return_addr, gcspr - 8)) { + return false; + } + env->cp15.gcspr_el[0] =3D gcspr - 8; + } + + __put_user(TARGET_GCS_MAGIC, &ctx->head.magic); + __put_user(sizeof(*ctx), &ctx->head.size); + __put_user(gcspr, &ctx->gcspr); + __put_user(mode, &ctx->features_enabled); + __put_user(0, &ctx->reserved); + + return true; +} + static void target_restore_general_frame(CPUARMState *env, struct target_rt_sigframe *sf) { @@ -502,6 +542,55 @@ static bool target_restore_zt_record(CPUARMState *env, return true; } =20 +static bool target_restore_gcs_record(CPUARMState *env, + struct target_gcs_context *ctx, + bool *rebuild_hflags) +{ + TaskState *ts =3D get_task_state(env_cpu(env)); + uint64_t cur_mode =3D gcs_get_el0_mode(env); + uint64_t new_mode, gcspr; + + __get_user(new_mode, &ctx->features_enabled); + __get_user(gcspr, &ctx->gcspr); + + if (new_mode & ~(PR_SHADOW_STACK_ENABLE | + PR_SHADOW_STACK_WRITE | + PR_SHADOW_STACK_PUSH)) { + return false; + } + if ((new_mode ^ cur_mode) & ts->gcs_el0_locked) { + return false; + } + if (new_mode & ~cur_mode & PR_SHADOW_STACK_ENABLE) { + return false; + } + + if (new_mode & PR_SHADOW_STACK_ENABLE) { + uint64_t cap; + + /* Pop and clear the signal cap. */ + if (get_user_u64(cap, gcspr)) { + return false; + } + if (cap !=3D GCS_SIGNAL_CAP(gcspr)) { + return false; + } + if (put_user_u64(0, gcspr)) { + return false; + } + gcspr +=3D 8; + } else { + new_mode =3D 0; + } + + env->cp15.gcspr_el[0] =3D gcspr; + if (new_mode !=3D cur_mode) { + *rebuild_hflags =3D true; + gcs_set_el0_mode(env, new_mode); + } + return true; +} + static int target_restore_sigframe(CPUARMState *env, struct target_rt_sigframe *sf) { @@ -511,8 +600,10 @@ static int target_restore_sigframe(CPUARMState *env, struct target_za_context *za =3D NULL; struct target_tpidr2_context *tpidr2 =3D NULL; struct target_zt_context *zt =3D NULL; + struct target_gcs_context *gcs =3D NULL; uint64_t extra_datap =3D 0; bool used_extra =3D false; + bool rebuild_hflags =3D false; int sve_size =3D 0; int za_size =3D 0; int zt_size =3D 0; @@ -582,6 +673,15 @@ static int target_restore_sigframe(CPUARMState *env, zt_size =3D size; break; =20 + case TARGET_GCS_MAGIC: + if (gcs + || size !=3D sizeof(struct target_gcs_context) + || !cpu_isar_feature(aa64_gcs, env_archcpu(env))) { + goto err; + } + gcs =3D (struct target_gcs_context *)ctx; + break; + case TARGET_EXTRA_MAGIC: if (extra || size !=3D sizeof(struct target_extra_context)) { goto err; @@ -612,6 +712,10 @@ static int target_restore_sigframe(CPUARMState *env, goto err; } =20 + if (gcs && !target_restore_gcs_record(env, gcs, &rebuild_hflags)) { + goto err; + } + /* SVE data, if present, overwrites FPSIMD data. */ if (sve && !target_restore_sve_record(env, sve, sve_size, &svcr)) { goto err; @@ -631,6 +735,9 @@ static int target_restore_sigframe(CPUARMState *env, } if (env->svcr !=3D svcr) { env->svcr =3D svcr; + rebuild_hflags =3D true; + } + if (rebuild_hflags) { arm_rebuild_hflags(env); } unlock_user(extra, extra_datap, 0); @@ -701,7 +808,7 @@ static void target_setup_frame(int usig, struct target_= sigaction *ka, uc.tuc_mcontext.__reserved), }; int fpsimd_ofs, fr_ofs, sve_ofs =3D 0, za_ofs =3D 0, tpidr2_ofs =3D 0; - int zt_ofs =3D 0, esr_ofs =3D 0; + int zt_ofs =3D 0, esr_ofs =3D 0, gcs_ofs =3D 0; int sve_size =3D 0, za_size =3D 0, tpidr2_size =3D 0, zt_size =3D 0; struct target_rt_sigframe *frame; struct target_rt_frame_record *fr; @@ -720,6 +827,11 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, &layout); } =20 + if (env->cp15.gcspr_el[0]) { + gcs_ofs =3D alloc_sigframe_space(sizeof(struct target_gcs_context), + &layout); + } + /* SVE state needs saving only if it exists. */ if (cpu_isar_feature(aa64_sve, env_archcpu(env)) || cpu_isar_feature(aa64_sme, env_archcpu(env))) { @@ -779,6 +891,12 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, goto give_sigsegv; } =20 + if (ka->sa_flags & TARGET_SA_RESTORER) { + return_addr =3D ka->sa_restorer; + } else { + return_addr =3D default_rt_sigreturn; + } + target_setup_general_frame(frame, env, set); target_setup_fpsimd_record((void *)frame + fpsimd_ofs, env); if (esr_ofs) { @@ -786,6 +904,10 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, /* Leave ESR_EL1 clear while it's not relevant. */ env->cp15.esr_el[1] =3D 0; } + if (gcs_ofs && + !target_setup_gcs_record((void *)frame + gcs_ofs, env, return_addr= )) { + goto give_sigsegv; + } target_setup_end_record((void *)frame + layout.std_end_ofs); if (layout.extra_ofs) { target_setup_extra_record((void *)frame + layout.extra_ofs, @@ -811,11 +933,6 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, __put_user(env->xregs[29], &fr->fp); __put_user(env->xregs[30], &fr->lr); =20 - if (ka->sa_flags & TARGET_SA_RESTORER) { - return_addr =3D ka->sa_restorer; - } else { - return_addr =3D default_rt_sigreturn; - } env->xregs[0] =3D usig; env->xregs[29] =3D frame_addr + fr_ofs; env->xregs[30] =3D return_addr; --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179204; cv=none; d=zohomail.com; s=zohoarc; b=bt94yTJCO5GNpRsGtZr5mUE7QcRhETUX/L9su7zEhTL/6buizjTg1UYGnfKImmEnOaKbGam+LbBpDrmOpaw9FDOxhbbw5okHcup+jz43H3+Fr/YjaH0zIPKCq7dPxeDflpEZd1RT+scmCPA4gaPB9ZZJM3Z8T661axlq4jueffQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179204; 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=Mn1fK5l3yCLKQ4lorT8vlvbr/nAjsRIkl737awJXwL4=; b=KvZdKsDkaGisG7HwxijZBCMPTDgWtRXtPlIpSp56GQh9GcBkjznP6PlgMkpgwIatHhQ40fWBnhYVxd2TDujoogmgdpwItJis24TmOhmeVpGKwGQBZlcpw4PhValJII764miQiciP7vOlYmb+iMt7MYA8ZJ6Kdq3x8q25O6JMX0Q= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179204971668.1487046907475; Sat, 2 Aug 2025 17:00:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLxN-0005RY-I2; Sat, 02 Aug 2025 19:48:05 -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 1uiLrw-0004Tp-Sf for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:35 -0400 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLrv-0006sC-Al for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:28 -0400 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e8e0aa2e3f9so2765253276.1 for ; Sat, 02 Aug 2025 16:42:27 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a423f38sm18461527b3.40.2025.08.02.16.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754178146; x=1754782946; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mn1fK5l3yCLKQ4lorT8vlvbr/nAjsRIkl737awJXwL4=; b=FMoQagPF/kptnQjqXSc/DbxrJ/yzLftiH7fMIhFOT53Ll6sKsFEWZAk4YeXsxpqXTA Xgnowh4nOy3yqdBlrs8Q5/qbhuJDPByvk2vVrSD1dBckq6T9F/nS8ar0sugPKPpCCi95 4plyr6cxclpw7sgU71HkQ73geV9FfZQb3ex+X4kHku6sm8Wt41/79yQFrS8BVoxV7TAo pqPU1pKSPE4PcTODr6KhrlfupwRyRHo8EfMCYl6bUuqM5DvoDWttiW+1uSlcmt8FSMbT OkpAmSg1QRqmwpCNajwDRMdbJAOXGK+qvERxagrlPbJg6SXmSl1Q/4CyhXq+REhnC0eF qi5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754178146; x=1754782946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mn1fK5l3yCLKQ4lorT8vlvbr/nAjsRIkl737awJXwL4=; b=JQV0D/N7EtymaWd0sz7DJIJ5wPKjMFFt5cm8Y80U0G4aeHEEEo+r5zAoiIhVLmWyRp Zzr95ztRl6Sp9G+Ji7ai0cAHdB+MId/+p4dMe9L3kWy/V+MCcL1mQLql8Uuy9rpnmaYX LI2ryrpWQa0k4WTytEpM3+anxhbfZzSQ/z/+y8HbYTw/NAha25wTjwlzzV/qRBcW1j+z xq9Dr1eRFIKdQSHZhsxB/DHUi93kLLLVIm52LzOUMBW5GMbjE10ODKs1vY7t8+IamfJ1 xN2c6vxluAF0TN9aXZZavLVqd271TV1o0oy/TZe4c6ox6ZlR3TniRz5MTLCENbcLYgnA +ajg== X-Gm-Message-State: AOJu0YxMwBqS6lMVAgSuGb7kxkR9q9LWiBzshwWZrURm3SN/M0AoSyub wnWfCYxvqEKYYttNOFdIBaYWO4jL4GpRLGQ4g8QvgP0GlboB4V+yjexIRZ6SbSCHvRkYi/F1Cq8 m8+/VvEA= X-Gm-Gg: ASbGncu/UrYdXoA/Tt5TDF5co4JW9rGj87ZhwVbYuAjQS0UeM3lBkUvxFDIDlTKEWWl LFvHgj7Q/sv6hGmbof8gqwkVublS14DoTzzifrt4BSa4SImo//FzUfX/O6v/Ni+d6RTtgA0pFRn x9r4cMtrkgANcgpSBaOOp/TL7JyjuVzcpoOBPrjKDd0j2Rxd5b/0b/IRAw43igHTbKPdKADGAbF pAhe3zksrSkSIx+1cRiZ2ymWeo413oSBowD+97avFCJdohWo1QufGILw7TIMMmQ1aIq2DrFOBSd a/c7a3WbGdu1qo0D7/rtBoTUimhxI2voVyutPVjs0RrvcUfzowx+GP4E4AGEww2j3khX77EiaA9 OkvsxQM8GdvD83zn79RDKs5HDsWhtRE7HLsDhizCywoVpDuFIp53OlP/l2GojOjg= X-Google-Smtp-Source: AGHT+IFOq8CxVLu0H363YNAcS5STFfcNfrykWc7MhpYsZbR2WCOwTRF5jFjICzn/kIuETJ5Bg7eyig== X-Received: by 2002:a05:6902:4388:b0:e8d:72d0:9733 with SMTP id 3f1490d57ef6-e8fee1ecb03mr4836191276.32.1754178146249; Sat, 02 Aug 2025 16:42:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 81/85] linux-user: Change exported get_elf_hwcap to abi_ulong Date: Sun, 3 Aug 2025 09:29:49 +1000 Message-ID: <20250802232953.413294-82-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::b2a; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb2a.google.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_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1754179235524124100 Content-Type: text/plain; charset="utf-8" AArch64 is about to add the first 64-bit hwcap bit, so we have to expand the return type. Since the only user assigns this to a abi_ulong, match that type. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/loader.h | 2 +- linux-user/elfload.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/linux-user/loader.h b/linux-user/loader.h index e102e6f410..e1badd4393 100644 --- a/linux-user/loader.h +++ b/linux-user/loader.h @@ -99,7 +99,7 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src, extern unsigned long guest_stack_size; =20 #if defined(TARGET_S390X) || defined(TARGET_AARCH64) || defined(TARGET_ARM) -uint32_t get_elf_hwcap(void); +abi_ulong get_elf_hwcap(void); const char *elf_hwcap_str(uint32_t bit); #endif #if defined(TARGET_AARCH64) || defined(TARGET_ARM) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ea214105ff..d87d1a16e0 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -511,10 +511,10 @@ static bool init_guest_commpage(void) #define ELF_HWCAP get_elf_hwcap() #define ELF_HWCAP2 get_elf_hwcap2() =20 -uint32_t get_elf_hwcap(void) +abi_ulong get_elf_hwcap(void) { ARMCPU *cpu =3D ARM_CPU(thread_cpu); - uint32_t hwcaps =3D 0; + abi_ulong hwcaps =3D 0; =20 hwcaps |=3D ARM_HWCAP_ARM_SWP; hwcaps |=3D ARM_HWCAP_ARM_HALF; @@ -841,10 +841,10 @@ enum { #define GET_FEATURE_ID(feat, hwcap) \ do { if (cpu_isar_feature(feat, cpu)) { hwcaps |=3D hwcap; } } while (= 0) =20 -uint32_t get_elf_hwcap(void) +abi_ulong get_elf_hwcap(void) { ARMCPU *cpu =3D ARM_CPU(thread_cpu); - uint32_t hwcaps =3D 0; + abi_ulong hwcaps =3D 0; =20 hwcaps |=3D ARM_HWCAP_A64_FP; hwcaps |=3D ARM_HWCAP_A64_ASIMD; @@ -1824,7 +1824,7 @@ static inline void init_thread(struct target_pt_regs = *regs, #define GET_FEATURE(_feat, _hwcap) \ do { if (s390_has_feat(_feat)) { hwcap |=3D _hwcap; } } while (0) =20 -uint32_t get_elf_hwcap(void) +abi_ulong get_elf_hwcap(void) { /* * Let's assume we always have esan3 and zarch. --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754178991; cv=none; d=zohomail.com; s=zohoarc; b=hPjhAKMFsKHKez09lejdTTShCXGL/S7o50L7hc1oKd7TujN3q2CVb/2nziIzNmyg1qP6/G/4LThu+6PYKlPAuN9y6vZPB2jDDz4FsVLMqRJdYe/xRk82vLbKX3+hhCK0V2SFJUv+OJ/bhCMUiiHJhgPi02j41huy0Nf4Pbsn/jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178991; 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=vVlQwNjtMgvAbm23dBCZDYeq1xNwwku3Aggvwl5C6uU=; b=QFTZ2LuVR9hZ61G7T0Q8pCuU5qrU5oAC7X6OeqI8SfKVC/1OuT5mUdPMRQ4sUgMTPtXCsarNgv1wMwZYzrZKw7mqey1CUZf/gzqUKaISl4gUzMMoqmydV2I6SzHRRgTxnwZIZKVqeZT7tzr+BRAy/8k9aa0qkeXkfn3Otg+CsG0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754178991408101.48900779641178; Sat, 2 Aug 2025 16:56:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLww-0003rm-9d; Sat, 02 Aug 2025 19:47:38 -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 1uiLs1-0004V6-26 for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:38 -0400 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLrz-0006sZ-KA for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:32 -0400 Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-e7311e66a8eso1825117276.2 for ; Sat, 02 Aug 2025 16:42:31 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a423f38sm18461527b3.40.2025.08.02.16.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754178150; x=1754782950; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vVlQwNjtMgvAbm23dBCZDYeq1xNwwku3Aggvwl5C6uU=; b=ukx/UYgqmTymtJCnoJ6CvQi7G98zgUZKUz6C1DlXgr/x/u9JiEMZTsRk2uUbRT65UH 80Shw2xIiDCzqmJS6hOGd9oHHjEj3+IsoFWqcmeFqb8wKT1FWbPgikUDyxFHPbKM7Eo5 UF/jMDjW9EfQmNUvHb9pSHsj+7Sham8EiA5jl03lArgLHxKdERKguVlhimkVyr06dPm9 5kzlIENZ1+uGWhtTt3eYyT1HLZ4CRxC8dBK3q7JDUh/WbHfGwodchblrzW47psniV5qo wXCzrsEgprk18u43PO1G3r6C4amLeXUia0paNmM5bDV1iMIIXxDXHu5dMDniQOBZQsUf FaCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754178150; x=1754782950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vVlQwNjtMgvAbm23dBCZDYeq1xNwwku3Aggvwl5C6uU=; b=iwJkUUBmjCxMtZ6bP50aOfcwG4hB5Y3SGGdkIQ02Qy+CSwqsjjLP/DqN2P04SglzdG +fyW5pK/mr/SmlPRRWsmT7/XEUHIH/CcMvXDs5gQhq+zjzSQbBAatB5XHMfn2YoAnHqo C3pi6GFRkUohXBCKVTnqX2pcmp2dcUTDtILpVMBlyxhmt1qBCjEAMFxLc880sooHa1iM vRevwk3cW+cXRPaRJ0a6gZxfTz936cje77LWw1C1AaCW/8ODv0NTl+bK5wecVCfbo9Kv Roq0uHR32JA8wxMe2IKmD4dSa1Y+8j6fMCe3THGCwn+WwfnSRPsWNcosROSu9OEjrD5I 3vxw== X-Gm-Message-State: AOJu0YxseLFlPpFGtnSZDqkvT53l/mZc/ud5NpoH7jmy8gRMOnuc0RD/ Oj/TokciqEUlwvUvGcVz5GFdqxp1jHSppSKGOhs/EBQMybxe9JpI7BmemC2WE/SginC/PRhcwaK sSLGOPBc= X-Gm-Gg: ASbGncvFyf7pa3H7l525ZvJPlPgLgTBFCbtDRmWMF9bxKN02vftsF/uRVgya3nrzS95 iC8Wzl6YDt/9XFTW+5EkBberblKPNVSKFbgYHuRE45OJ5Dy0ez77PviZN6iX5IsN0DUPOST9FzI eg/FMHX+O6960rQQqcH6f35Wkt4lf4zf4yPd7u2534svF20mrcRCehR+Atrbpb7RXsaZhgdU+Ak v0M5shLI/uQGUKVW8azPsUdutc1B0LFbSoXmZRxU05jjI1PxuBOCpqc1OwjmI9Jy7tnP1BuE7iP 046v/KnyBDff1p5tpCX+6cry1SfVeb8cBZhQ90zJ4yRqO6C6MbQILLdqJp35UIykyxMKMffyo5d q9VMDGCFtCdBIfDFwaFpybtWk+AZUr1kKcr7/AH/8iM32dnvEB+Tn X-Google-Smtp-Source: AGHT+IF5iQbg12HR9p2AMt8U1Te7fBcbAkW3+9V7bHxGML+WczUYQ8QtzRGrLfRZvZDoKQdtTJblNw== X-Received: by 2002:a05:690c:17:b0:71a:1f26:5d1a with SMTP id 00721157ae682-71b7ed84355mr49527207b3.11.1754178150515; Sat, 02 Aug 2025 16:42:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 82/85] linux-user/aarch64: Enable GCS in HWCAP Date: Sun, 3 Aug 2025 09:29:50 +1000 Message-ID: <20250802232953.413294-83-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::b30; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb30.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754178994107116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- linux-user/elfload.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index d87d1a16e0..e71dcdec1b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -877,6 +877,7 @@ abi_ulong get_elf_hwcap(void) GET_FEATURE_ID(aa64_dcpop, ARM_HWCAP_A64_DCPOP); GET_FEATURE_ID(aa64_rcpc_8_3, ARM_HWCAP_A64_LRCPC); GET_FEATURE_ID(aa64_rcpc_8_4, ARM_HWCAP_A64_ILRCPC); + GET_FEATURE_ID(aa64_gcs, ARM_HWCAP_A64_GCS); =20 return hwcaps; } --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179088; cv=none; d=zohomail.com; s=zohoarc; b=apX0cZ9p5NZBnYnDgx+4CIGuWzvyB7BA+cSYMhVdkR7wvNNBsJiO1NnvwJW8JXziDMe1mXP3yoseHfKEg865Ep5uPkDfrJw0C54OYt5mINqo8D6ENqByzsbue1bHskSD0lZvp7KaHn26K3zf+P1MfqWYIMbsAhA//N8q78LfJEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179088; 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=7QFj8gESh/eq5jJW2e2RUPuhA+cwRUSiqjJJ5xCzpQk=; b=Y34Qux/nc3hyjO16fF4pXVTnRaZCYa4QfPTJ8TemFSB1zDZRwHp5dHGjN5//Dya4x0Z3pdR/vi9sPalao7iOYm/LGt6MaGVpr2rUNUYzRB9yLq4QeRJQL8vWptWXAA63r0VQMg/mN5H2MDLL8NRysOQflrj5P0PHSdXG2FvbmyU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179088282412.9526475519583; Sat, 2 Aug 2025 16:58:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLxS-0005lS-Gu; Sat, 02 Aug 2025 19:48:10 -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 1uiLs5-0004Wn-IP for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:40 -0400 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLs4-0006sy-0W for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:37 -0400 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e8e2a260926so2894583276.1 for ; Sat, 02 Aug 2025 16:42:34 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a423f38sm18461527b3.40.2025.08.02.16.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754178154; x=1754782954; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7QFj8gESh/eq5jJW2e2RUPuhA+cwRUSiqjJJ5xCzpQk=; b=a3Rztez4k/4hNiHCrzXl3AhGJukOGvWNmKy5dtapiVe4uKnsV9gCyzVevy312gBSqB +03BCqVQk5v4NHmuU1DlscNVI/onLXOZXMZyWodXN+NSnD61StLBQuPGRMfI3o4qKV64 MIB5CvOeGPL6fe/mCO+Cp3dnooQw3qgpZxO9BQgg7g5uaBN7CHP1RuZIr9NKP7xLzIfe Hf5nWrLcGbhnT+AMiMYWoGGIzTlcZLuvInIet1SpU5pdg79ODuKiATos1ITekHmxA+jh JRnFK47fXTEuTVPDgyhMTCbFYA3u5Pz7KIiF2k0mkCSCx0WlYYINzqcQ+8MM9IAJXW0W F6ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754178154; x=1754782954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7QFj8gESh/eq5jJW2e2RUPuhA+cwRUSiqjJJ5xCzpQk=; b=suSq/cgC0oxnk/FftCRJb9feKhybN9DSN0H8nLOHFcsdmX2ORExj5TO0wN0J3iVo2O NSmohXMD0nXRHLn0evCdnRJnPs8ZL8TWD5hq0/hOL5NHhATySGJ7SkOtf0mvGUdQHtsP r6bVlnLT4/YArFvoGy/kpkYIx/f0mBvmA67AzqG0ehglLfSHgQMKbR9VbIr4kDkw2J2V 8ReVjLxD0EK3bQnSrjR9ZkwGha8w0NuM/zVxFV8TCcbGYQocg2avCo+9wWksANlFgtRF VejjScKwzJ3/RnpMPHHqCgUE0VGhmhOFG8NNTFP8+W2eG/seysQvggs1/R4Jf2WwoN0I uNnQ== X-Gm-Message-State: AOJu0YyfaY7gbF27jxwYMn/l4cPAugOJx9dxuujGJZBkEEcgufG5dZie c/WyfKAsvh3mKJIGsReHPZsj7suXo0A0PEMoI+aRJCD+RzjmAEXBWtHUS6zOO4z5N43EeiIkX2t +EP1Xt+0= X-Gm-Gg: ASbGncs5SIG53+3p+A1XljRC0c9TX0u4m666fHCwCvTc8fpYxbwxaSBJ5Jxeps3Trf8 pPGuG5g38C7GMEQJec2y5li3ZbO8npvHWMmQo0ae6yfDBP9lMmTUV8vtgjn9AIYrUmLAbEQ1b+G plofDLaPSoLW/Gdv4czCpsCnluxJcUUG3FzohxX0OOHVcjdACgZvCKNPFoiGw6tYnizEM2fKoKv t4Juod3lxDAL4orp6B1i7/TnGp0eGMh4S7vQevKGPYFJy5c6CKYM66YFMm6+vmKpeBrxfrNTmU1 Kxw3D/PjJ0gbIKhrIRxdmtV3KXlZqNU1yPckrdEIpN2BAQbQtsOEAdqMFOZj0wgnay6j8aQoZDt Iwsca/rfZ/vfz0tg74T+SdzlROYpV5whHswSfwafW7Q3aemAZNsCkyNBbZ3nYZm0= X-Google-Smtp-Source: AGHT+IHwbPBZqcAskzzAbai35QDmedvuArmT8sNZACP/fgu8f87SPEu8xANkoaeaPJD+ft3UQhj64Q== X-Received: by 2002:a05:690c:9a82:b0:71a:3f0:b474 with SMTP id 00721157ae682-71b7f3ce0c6mr56501287b3.15.1754178154228; Sat, 02 Aug 2025 16:42:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 83/85] tests/tcg/aarch64: Add gcsstr Date: Sun, 3 Aug 2025 09:29:51 +1000 Message-ID: <20250802232953.413294-84-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::b2a; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb2a.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179088933116600 Content-Type: text/plain; charset="utf-8" Add some infrastructure for testing gcs in userspace. Validate successful and trapped executions of GCSSTR. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tests/tcg/aarch64/gcs.h | 71 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/gcsstr.c | 48 +++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 5 +++ 3 files changed, 124 insertions(+) create mode 100644 tests/tcg/aarch64/gcs.h create mode 100644 tests/tcg/aarch64/gcsstr.c diff --git a/tests/tcg/aarch64/gcs.h b/tests/tcg/aarch64/gcs.h new file mode 100644 index 0000000000..99cb4d4e38 --- /dev/null +++ b/tests/tcg/aarch64/gcs.h @@ -0,0 +1,71 @@ +/* + * Linux kernel fallback API definitions for GCS and test helpers. + * + * Copyright (c) 2025 Linaro Ltd + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef PR_GET_SHADOW_STACK_STATUS +#define PR_GET_SHADOW_STACK_STATUS 74 +#endif +#ifndef PR_SET_SHADOW_STACK_STATUS +#define PR_SET_SHADOW_STACK_STATUS 75 +#endif +#ifndef PR_LOCK_SHADOW_STACK_STATUS +#define PR_LOCK_SHADOW_STACK_STATUS 76 +#endif +#ifndef PR_SHADOW_STACK_ENABLE +# define PR_SHADOW_STACK_ENABLE (1 << 0) +# define PR_SHADOW_STACK_WRITE (1 << 1) +# define PR_SHADOW_STACK_PUSH (1 << 2) +#endif +#ifndef SHADOW_STACK_SET_TOKEN +#define SHADOW_STACK_SET_TOKEN (1 << 0) +#endif +#ifndef SHADOW_STACK_SET_MARKER +#define SHADOW_STACK_SET_MARKER (1 << 1) +#endif +#ifndef SEGV_CPERR +#define SEGV_CPERR 10 +#endif +#ifndef __NR_map_shadow_stack +#define __NR_map_shadow_stack 453 +#endif + +/* + * Macros, and implement the syscall inline, lest we fail + * the checked return from any function call. + */ +#define enable_gcs(flags) \ + do { = \ + register long num __asm__ ("x8") =3D __NR_prctl; = \ + register long arg1 __asm__ ("x0") =3D PR_SET_SHADOW_STACK_STATUS; = \ + register long arg2 __asm__ ("x1") =3D PR_SHADOW_STACK_ENABLE | fla= gs; \ + register long arg3 __asm__ ("x2") =3D 0; = \ + register long arg4 __asm__ ("x3") =3D 0; = \ + register long arg5 __asm__ ("x4") =3D 0; = \ + asm volatile("svc #0" = \ + : "+r"(arg1) = \ + : "r"(arg2), "r"(arg3), "r"(arg4), "r"(arg5), "r"(num= ) \ + : "memory", "cc"); = \ + if (arg1) { = \ + errno =3D -arg1; = \ + perror("PR_SET_SHADOW_STACK_STATUS"); = \ + exit(2); = \ + } = \ + } while (0) + +#define gcspr() \ + ({ uint64_t *r; asm volatile("mrs %0, s3_3_c2_c5_1" : "=3Dr"(r)); r; }) diff --git a/tests/tcg/aarch64/gcsstr.c b/tests/tcg/aarch64/gcsstr.c new file mode 100644 index 0000000000..b045aee925 --- /dev/null +++ b/tests/tcg/aarch64/gcsstr.c @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "gcs.h" + +/* + * A single garbage store to the gcs stack. + * The asm inside must be unique, so disallow inlining. + */ +void __attribute__((noinline)) +test_gcsstr(void) +{ + register uint64_t *ptr __asm__("x0") =3D gcspr(); + /* GCSSTR x1, x0 */ + __asm__("inst_gcsstr: .inst 0xd91f1c01" : : "r"(--ptr)); +} + +static void test_sigsegv(int sig, siginfo_t *info, void *vuc) +{ + ucontext_t *uc =3D vuc; + uint64_t inst_gcsstr; + + __asm__("adr %0, inst_gcsstr" : "=3Dr"(inst_gcsstr)); + assert(uc->uc_mcontext.pc =3D=3D inst_gcsstr); + assert(info->si_code =3D=3D SEGV_CPERR); + /* TODO: Dig for ESR and verify syndrome. */ + exit(0); +} + +int main() +{ + struct sigaction sa =3D { + .sa_sigaction =3D test_sigsegv, + .sa_flags =3D SA_SIGINFO, + }; + + /* Enable GCSSTR and test the store succeeds. */ + enable_gcs(PR_SHADOW_STACK_WRITE); + test_gcsstr(); + + /* Disable GCSSTR and test the resulting sigsegv. */ + enable_gcs(0); + if (sigaction(SIGSEGV, &sa, NULL) < 0) { + perror("sigaction"); + exit(1); + } + test_gcsstr(); + abort(); +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index 16ddcf4f88..0347a36e8d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -75,6 +75,11 @@ AARCH64_TESTS +=3D $(SME_TESTS) $(SME_TESTS): CFLAGS +=3D $(CROSS_AS_HAS_ARMV9_SME) endif =20 +# GCS Tests +GCS_TESTS +=3D gcsstr +AARCH64_TESTS +=3D $(GCS_TESTS) +$(GCS_TESTS): gcs.h + # System Registers Tests AARCH64_TESTS +=3D sysregs =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754179599; cv=none; d=zohomail.com; s=zohoarc; b=kohbzavtwnaotGchN5h0tpOExirGmSRPRi0SduKqTHOP2OKGv0CJXbRCOSbpZdafWZzzEce1aDFLwDZmLrJMJWkopLza90oJiYFGYdHZVCdR/6ZqFR3quktyRx2fd98ib05xUliQWWyv50xf0MPkqx+4NYPgpf+earbQULuVlqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754179599; 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=SotLYLgeVo+CKYkDdlihGsrrJawGkZPr42hZuKBjr+k=; b=LVfaa6xeq4tpAXgCRdXmQvAWZJr6x4rM+dGVz3vaNwT868wFJdMsEncihXvHKTN8S7emZDhcd7+vHIexGTFSHhXOwdWabBIr1qRHQE2jpuPYvMdzwckAT5JsHd+N4eVK4G4ODm6P6iEll4b7C7LsDQDyBwb3badeQWuNnZg6Be0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754179599085611.8158824834223; Sat, 2 Aug 2025 17:06:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLwQ-0002aY-IJ; Sat, 02 Aug 2025 19:47:10 -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 1uiLsB-0004ZW-BD for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:53 -0400 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLs9-0006tG-ME for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:42 -0400 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e8ffb1c5f3cso149393276.1 for ; Sat, 02 Aug 2025 16:42:39 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a423f38sm18461527b3.40.2025.08.02.16.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754178159; x=1754782959; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SotLYLgeVo+CKYkDdlihGsrrJawGkZPr42hZuKBjr+k=; b=uMcg4CrkZC9tQ2bNall8ZCSMmN+F8ejXvXYMWmmhit+uvchN3ZMjkJ9l5bKbjEDspj 0OeUlV7OoMZNMQ4XSeutl/PUxIA8AgSBiNAwggnc5SOh3gHkoRErf+I1de5z3r9MZR3D BXU3q4pK7BX4JRN7uh+s66QvVD+s/9GzmrYImgZUB9gmVlGynCf9SduMjf8gfri6geKQ Hsdb8nUroxnKbve27AAvsAyz79DtxMFgVdH2h1VLP9maSKnRCepb5pvWqUE4uHs2nuhG +XFk0SaSIUE3dZgyjH61bpFhsqQgWZwqhonK6A7a5xmuUj0dwIGDWldtdtqRbLjlBN0M 2bqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754178159; x=1754782959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SotLYLgeVo+CKYkDdlihGsrrJawGkZPr42hZuKBjr+k=; b=ILu9sBKuKPyjFwKT5wfdZQrRELpkwUU16qajUV1NebgTTk+/WF15Hoq5a/evDsseD8 qfuw8Q7bP7bJbDEE72GjbwGM6HsQqjlwjdiYC4QNK7IEBnntMshUaqbv3DInMCFmLb/B YfyC4z0L9vHKekJAs3Um9XTPuFWvwMxXlU8ccx2tohNbqjVGXNQqqUasu/zU/1xbjbh4 vKKdSE5h913FCyga7zWq8hvYkvThwgmOBPnmidOzc3CnmOPtWF+g/MDVTqkf3P4UzZNQ ugLw0mICXYj79cdJt+erYBWhKlYJncxf5glz/uw8LylrrvKzWZgFF1PSf1PHA/Td9slc eSXQ== X-Gm-Message-State: AOJu0YyNHEy1CTLQleEdaP/bTohBlPANoolvFZe6R2K2/IbEgzyuoqkI 6u9vhksIjD3j9r7aDWi8/oKPF3EgtjSnMA0cSgkKLWo8Y+eRCEy8EbRR7Td9sMqKznhZYtRVJYH MGgJNRaM= X-Gm-Gg: ASbGncs5Df1/RSOy+eqoCxBKNg50ALbGj3/hyX2NbHYh0hNX4O/47IN2bDSiyEtu+Qb jWUs0QipM07DqruYPDDEFTkG4O5yU1LU8QHqID7u3uPIpvuEBPGUqAQwGayb0khHoNwC/9TjbmG k5Z4mVsb+mCId6RDobZHFl5xx8kib1Smu9aNzTT2I4iIMoIa2WexiNSne73Jdvk7IcQWP4uBu+x 4KDuN+2E3sqPOfsKyFtH1eiPYqOYkDHmdSEMb85Gd/0sWI/HQrZa/MXgcSwvHRh+FYN7kXlyitk MKhdUpH1ePwSeEanVxvJX1zmwzZTZoOvoEPb8NN62s/vXC/tKMzEru9ywCAO5NyeoSidHKWGGbd Oe7e+FjsUpR88lD6qfnD4hCVanoKMex+i6O9pS2BGSuqOmQqmZhpd X-Google-Smtp-Source: AGHT+IHAvWQEApRen2ThMrR4i1yfCwvNavAmxZmDFh3njuIad3m5De3XsBTj2kXn+gHPzT6iPLabnw== X-Received: by 2002:a05:6902:2a8e:b0:e8f:d5c8:64fd with SMTP id 3f1490d57ef6-e8fee1de7e4mr4853215276.41.1754178158890; Sat, 02 Aug 2025 16:42:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 84/85] tests/tcg/aarch64: Add gcspushm Date: Sun, 3 Aug 2025 09:29:52 +1000 Message-ID: <20250802232953.413294-85-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::b29; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb29.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754179599740116600 Content-Type: text/plain; charset="utf-8" Validate successful and trapped executions of GCSPUSHM, GCSPOPM. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tests/tcg/aarch64/gcspushm.c | 71 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/gcspushm.c diff --git a/tests/tcg/aarch64/gcspushm.c b/tests/tcg/aarch64/gcspushm.c new file mode 100644 index 0000000000..c330417a2f --- /dev/null +++ b/tests/tcg/aarch64/gcspushm.c @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "gcs.h" + + +#define GCSPUSHM "sys #3, c7, c7, #0, %[push]" +#define GCSPOPM "sysl %[pop], #3, c7, c7, #1" + +static void test_sigsegv(int sig, siginfo_t *info, void *vuc) +{ + ucontext_t *uc =3D vuc; + uint64_t inst_sigsegv; + + __asm__("adr %0, inst_sigsegv" : "=3Dr"(inst_sigsegv)); + assert(uc->uc_mcontext.pc =3D=3D inst_sigsegv); + assert(info->si_code =3D=3D SEGV_CPERR); + /* TODO: Dig for ESR and verify syndrome. */ + uc->uc_mcontext.pc +=3D 4; +} + +static void test_sigill(int sig, siginfo_t *info, void *vuc) +{ + ucontext_t *uc =3D vuc; + uint64_t inst_sigill; + + __asm__("adr %0, inst_sigill" : "=3Dr"(inst_sigill)); + assert(uc->uc_mcontext.pc =3D=3D inst_sigill); + assert(info->si_code =3D=3D ILL_ILLOPC); + uc->uc_mcontext.pc +=3D 4; +} + +int main() +{ + struct sigaction sa =3D { .sa_flags =3D SA_SIGINFO }; + uint64_t old, new; + + sa.sa_sigaction =3D test_sigsegv; + if (sigaction(SIGSEGV, &sa, NULL) < 0) { + perror("sigaction"); + exit(1); + } + + sa.sa_sigaction =3D test_sigill; + if (sigaction(SIGILL, &sa, NULL) < 0) { + perror("sigaction"); + exit(1); + } + + /* Pushm is disabled -- SIGILL via EC_SYSTEMREGISTERTRAP */ + asm volatile("inst_sigill:\t" GCSPUSHM + : : [push] "r" (1)); + + enable_gcs(PR_SHADOW_STACK_PUSH); + + /* Valid value -- low 2 bits clear */ + old =3D 0xdeadbeeffeedcaec; + asm volatile(GCSPUSHM "\n\t" GCSPOPM + : [pop] "=3Dr" (new) + : [push] "r" (old) + : "memory"); + assert(old =3D=3D new); + + /* Invalid value -- SIGSEGV via EC_GCS */ + asm volatile(GCSPUSHM "\n" + "inst_sigsegv:\t" GCSPOPM + : [pop] "=3Dr" (new) + : [push] "r" (1) + : "memory"); + + exit(0); +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index 0347a36e8d..c6f401c317 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -76,7 +76,7 @@ $(SME_TESTS): CFLAGS +=3D $(CROSS_AS_HAS_ARMV9_SME) endif =20 # GCS Tests -GCS_TESTS +=3D gcsstr +GCS_TESTS +=3D gcsstr gcspushm AARCH64_TESTS +=3D $(GCS_TESTS) $(GCS_TESTS): gcs.h =20 --=20 2.43.0 From nobody Sat Nov 15 07:40:52 2025 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1754180227; cv=none; d=zohomail.com; s=zohoarc; b=TdQNykPPbMWWwq/FfOUMDn0M60JGTN+FrSJZN0BBjc49T6aExxbpJL+S2qGnDJAKBd/1PpH35tXJm1FHUMtXWWvE+m7il9IYqsxUxa50IWdsWqIWNBVwOhypVPo7yBeyo2REs/pGE+B8GPmheSTE4uj4YXtXTXwlbRzFP+iDlhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754180227; 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=L1ak1ZU/AR0+1y4HNoJj/qDB25/smzJJgjU2bzP6iSw=; b=FN3bLn924PakcaHnOzhalFag49gfaPDZmXoSwWQqsx9l3QpmU46zX886cKlZkvQAJ9+rKWv+VPHpUxDnUhFbO5IYbxcco+J+6WEDTBDC4EiFVInKD1Tgclpps7eIYIdW7XBru/PCoWAfgvziFU2YW1oRRAyI83nCMW5x8y0Xqpw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1754180227131205.19615411767086; Sat, 2 Aug 2025 17:17:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLxs-0006De-FA; Sat, 02 Aug 2025 19:48:38 -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 1uiLsE-0004aX-FV for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:53 -0400 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLsC-0006tl-Rj for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:42:46 -0400 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-71a39f93879so43443217b3.0 for ; Sat, 02 Aug 2025 16:42:44 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a423f38sm18461527b3.40.2025.08.02.16.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754178163; x=1754782963; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L1ak1ZU/AR0+1y4HNoJj/qDB25/smzJJgjU2bzP6iSw=; b=bHVFX6cRhnJ5h2MOrnOub9olzuajmAnB5ToZ4/h/vhjlXtna3EnbbS32KCr2lYLi7v t9Kl4Ml8IyjzIsY1GsCM/5Av8uwQlzRvOFAdcSBs56Hw7SpCkug3KnI/P0ASO8kfe2fy 4WMdicdTrRlP2xrlCpizJeZJF4cDBsqaxBIU0W0sjJUKM2dfWJ8/WXTcbnkosv+wyK/G L+m54hJhEaIeunNAeXir+QGzArrlwb4iUoJUCSsvkrFMbi4acBf5XIUbqQqyfnlOkGMj oMo9s0dquRJzo8fn+/W4c5YPriXfcwvA3pPQ9hXP6OTylfy0kMzEs78+F55Y8+mrmKhU BfJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754178163; x=1754782963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L1ak1ZU/AR0+1y4HNoJj/qDB25/smzJJgjU2bzP6iSw=; b=Oga5TPoBuqJExaDCxQjwvtGEQeAxdDs31CoDmqFI2W5M+cI/6A8GDTPNTtVk/MYTXK 2ZWu3Wh/UQ/deESJaW5osbOCULfk7uO/1linzhlgf3WCEZt84afiYJ5mQf7lYO9Gqgae CRRGwPfjo6G9HVd6c1i3UVJH+1wgmWWjlQvuzxb2GyMKbzpg+CFSl9gt+TFbPOhMcoLD ahQaIt+3+4xGgPrVEeYm+640H1ssdpzwxhauvWE32uB8C+3XaITUCZ8e4cRPYbTZ1PLf dTm/N2EZvtiYPtNZIcDSlzT/TQ4oJ1I7Sccg5EcuS8V4PX25d0ih9svxwT0qx2WEF3Gf Fn1g== X-Gm-Message-State: AOJu0YzIYquU6yPSVvb+ldi9OOVLZuvQDvA+uZv5OIvO2/JoHH2Opm3F Dgc7UBSZ7Tu1eAwwAoFy/pj1DXMa8yIWEtEjtxvKR6mT5BDFe0UNnoes8NCncs/+/8ohYwpOMy3 lV5As/zI= X-Gm-Gg: ASbGncs7m9h3qUui17LcRNag0yTfXZ10d/bFrBiN0MCy+I16rXAuEiaBwVRQhVJKD2Q 2qvTp/aI6Pjz10oj/h7shMUx4HobGTLOvWTB+682/NOs7NMnMlv+r00AQdj69edoO8xFML8B4gA KLU6Si82Qn6irj+g6R4cTuEixhCdMTQ/hDIrU99B8vyH7XW501cFc4jArFIU7Xgbuhq2ErVwUaE nb0yuJgJoKcsR7JVNxAnCmokOJ071HEy11Zvti32ag7+7cAshw2NMQCGkruEKOF5xvWZ2O3qAsT ysIR1yZR004all1vHsgmxV2AZd1bkd+nOvK+UFYOSk3TyhipedmobTCXVCC+7U7AwJm5rLQuhUe N8G1aUKhuSKOSt7WS0SgRoMLnpI2hPJU89K76verevEudbnsQ4JHE X-Google-Smtp-Source: AGHT+IF9NFvaNOKhXcz62pjxStwnQKSB/FE6G2Hf22mP9LCryNxA4mVg0eE/bEQplMzcpntFJv0hWA== X-Received: by 2002:a05:690c:660f:b0:71a:231b:d046 with SMTP id 00721157ae682-71b5a6e54fbmr143797507b3.2.1754178163565; Sat, 02 Aug 2025 16:42:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 85/85] tests/tcg/aarch64: Add gcsss Date: Sun, 3 Aug 2025 09:29:53 +1000 Message-ID: <20250802232953.413294-86-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::1132; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1132.google.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_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1754180229147124100 Content-Type: text/plain; charset="utf-8" Validate stack switching and recursion depth. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tests/tcg/aarch64/gcs.h | 9 ++++ tests/tcg/aarch64/gcsss.c | 74 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/gcsss.c diff --git a/tests/tcg/aarch64/gcs.h b/tests/tcg/aarch64/gcs.h index 99cb4d4e38..e821963cb8 100644 --- a/tests/tcg/aarch64/gcs.h +++ b/tests/tcg/aarch64/gcs.h @@ -69,3 +69,12 @@ =20 #define gcspr() \ ({ uint64_t *r; asm volatile("mrs %0, s3_3_c2_c5_1" : "=3Dr"(r)); r; }) + +#define gcsss1(val) \ + do { = \ + asm volatile("sys #3, c7, c7, #2, %0" : : "r"(val) : "memory"); = \ + } while (0) + +#define gcsss2() \ + ({ uint64_t *r; = \ + asm volatile("sysl %0, #3, c7, c7, #3" : "=3Dr"(r) : : "memory"); r= ; }) diff --git a/tests/tcg/aarch64/gcsss.c b/tests/tcg/aarch64/gcsss.c new file mode 100644 index 0000000000..9550c68e7e --- /dev/null +++ b/tests/tcg/aarch64/gcsss.c @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "gcs.h" + +#define IN_PROGRESS(X) ((uint64_t)(X) | 5) +#define CAP(X) (((uint64_t)(X) & ~0xfff) + 1) + +static uint64_t * __attribute__((noinline)) recurse(size_t index) +{ + if (index =3D=3D 0) { + return gcspr(); + } + return recurse(index - 1); +} + +int main() +{ + void *tmp; + uint64_t *alt_stack, *alt_cap; + uint64_t *orig_pr, *orig_cap; + uint64_t *bottom; + size_t pagesize =3D getpagesize(); + size_t words; + + enable_gcs(0); + orig_pr =3D gcspr(); + + /* Allocate a guard page before and after. */ + tmp =3D mmap(0, 3 * pagesize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0= ); + assert(tmp !=3D MAP_FAILED); + + /* map_shadow_stack won't replace existing mappings */ + munmap(tmp + pagesize, pagesize); + + /* Allocate a new stack between the guards. */ + alt_stack =3D (uint64_t *) + syscall(__NR_map_shadow_stack, tmp + pagesize, pagesize, + SHADOW_STACK_SET_TOKEN); + assert(alt_stack =3D=3D tmp + pagesize); + + words =3D pagesize / 8; + alt_cap =3D alt_stack + words - 1; + + /* SHADOW_STACK_SET_TOKEN set the cap. */ + assert(*alt_cap =3D=3D CAP(alt_cap)); + + /* Swap to the alt stack, one step at a time. */ + gcsss1(alt_cap); + + assert(gcspr() =3D=3D alt_cap); + assert(*alt_cap =3D=3D IN_PROGRESS(orig_pr)); + + orig_cap =3D gcsss2(); + + assert(orig_cap =3D=3D orig_pr - 1); + assert(*orig_cap =3D=3D CAP(orig_cap)); + assert(gcspr() =3D=3D alt_stack + words); + + /* We should be able to use the whole stack. */ + bottom =3D recurse(words - 1); + assert(bottom =3D=3D alt_stack); + + /* We should be back where we started. */ + assert(gcspr() =3D=3D alt_stack + words); + + /* Swap back to the original stack. */ + gcsss1(orig_cap); + tmp =3D gcsss2(); + + assert(gcspr() =3D=3D orig_pr); + assert(tmp =3D=3D alt_cap); + + exit(0); +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index c6f401c317..b858f8692e 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -76,7 +76,7 @@ $(SME_TESTS): CFLAGS +=3D $(CROSS_AS_HAS_ARMV9_SME) endif =20 # GCS Tests -GCS_TESTS +=3D gcsstr gcspushm +GCS_TESTS +=3D gcsstr gcspushm gcsss AARCH64_TESTS +=3D $(GCS_TESTS) $(GCS_TESTS): gcs.h =20 --=20 2.43.0