From nobody Sun Dec 14 20:30:53 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=1755176364; cv=none; d=zohomail.com; s=zohoarc; b=QKaUBK6521Wrx+XV9prUsCXBTCZSFl7lKDOzugsdNBHNniL0kZNf8oqK4qLRAdsA6i0lmbnBzuBLoXS5+o7utoD5tEKPavHZZ8LhI2U5+TgxzChFNk2BD7Gwky5ocTTS26H5er15ZZLSo+s/sC1jedZrhmIL147xc4nAtHG6YwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176364; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fXFPXM3hA75ijMb6S6fD97bAchtn4q6g88SCdLIAfR0=; b=nMVE69xp6oGjmV4kA49GB72hfJ3auEf0d/RQ3tgRa9zffAIBMWKCuQDYxB6p411dc6Kp4jRBhG2qyzbLrvXcV7I9qmvg/FHiuPLnBEl2rjZfNquzn+qsdSe2VEJ9B3PBxQ9Mz1J2w+6Fzz7UB/tBzdDTCJiVdTJ3KMlzyAmVQUo= 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 1755176364648130.78713306114332; Thu, 14 Aug 2025 05:59:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXX5-0001CZ-Sk; Thu, 14 Aug 2025 08:58: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 1umXX4-0001C6-BL for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:14 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXWx-00047g-9P for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:13 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-32326e69f1dso956802a91.3 for ; Thu, 14 Aug 2025 05:58:06 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176284; x=1755781084; 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=fXFPXM3hA75ijMb6S6fD97bAchtn4q6g88SCdLIAfR0=; b=Cyiv/JhbyYXnYqB+otslFW/fp+tABskE7Q1m9T4hK0b2TnktsDEftrUyt9tnyWdvtX 7EZmIgw7Zqt0U35j1oIgNQ3Rl+yHBIjVAd7dYLfFzsArfpU6k4yI/J5CY/AQx0Ygp5e3 jZbkYsr257juH9y1tc7+NiXzJd2FWblpm8knhzJz77PSg3ZkDLQAgr3b04eG1QaUcrU+ jouMig8Gn1faso4ro3ciX2qT18AZxbwEi9e4qbzbbgQxN9Ga7vraNNuRgpR+JM4HDWwp 4T0iGXn3d/a4ncGl5E+RkWH0/pIj7yucRCdzbIxSTbXHAla3OZJhdGaM6rZRWZRL5/ca aYLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176284; x=1755781084; 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=fXFPXM3hA75ijMb6S6fD97bAchtn4q6g88SCdLIAfR0=; b=apMc+7EkVL25N3VRXO6uguumX1BgZKx0hndjRoMZx+6SxOQeCcbgFA0cVSA3O9cRZO HCWSpNPMFpFn0hOuTChHHyox/VefrphsNX8u9cfD7Q4mP7usB0TChodXOggFw5F25Ttg Vw5hXDp9SwJ9F5bCLZXA9tvrVjT5Q1xkwPn3Ro3vptOauq9KJzF5yW/D1gx+SCZxyAIE EEtpa5PJwvMjGWgHc6z6gd7fGW4NGJAjZdHes8w9HZyG04dL0Yaxjo5BiQRkOHhkqKi1 w6DwribHBZH/2+6u5c4H74Lq/eLHoqDJiU4aQ4KdVJWvVYGNrwK58XxJLmjvwKd3yc8S +Y7g== X-Gm-Message-State: AOJu0YwpspVivS0MX9naHxk/P8/1lIvTY6JQ3hVBVNirz/TD/UsR4CF8 /0O6SiPsawwOnRK1QfOWIsKBsxSqtOUylg6dTvmUS4KK47HLBb86WWbs/MEay7Ff4IXN8oI6GmD TpTf0/eM= X-Gm-Gg: ASbGncuQOQEBUY0sOexD5imHorWd9SpIMEIcK7azyFGqv3yzQAXlvnDWFv62G7KFSLI wiQCPyTp8wHHfvK9KstX2dX1l9FO2KGT3UjN9+HLW8P2+tRlOWNxOU4wRDUyd8+5mTqH59V0qh/ xuubJ4LMhdzL01b57pqBalq5hJj8ghBifqtiO4K9Tr5YqBFWg+5wXyjEqM2Qv3A3f5e5URN3tL/ qkpE0HO2xCgABfehDdqDcnUqbcXkuE8hLQQ0EP5n6sdcq+Z1+m/XN7CEr1Ef+UcSFbtTiy6AZ8j 9pSczryoHzXWeR2waAiiv0FNy3iqJUDdwrfocN1xnx9G8/il0P53xFwboQROBh3sNkE4mBGDuU/ o6RoO2hK8CLJmLLuUJD0qo9361tEKY7nkRG167FWaLuFoUjE= X-Google-Smtp-Source: AGHT+IFXACubsrmkv2hoTYG83FYMxnPYdCnxYQbJlHc46BjnMg5JwI97On6Ik9/1bhOJdQM5Wrtc8Q== X-Received: by 2002:a17:90b:5627:b0:31f:b51:eef9 with SMTP id 98e67ed59e1d1-32327c87748mr4967466a91.17.1755176284229; Thu, 14 Aug 2025 05:58:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 01/85] linux-user/aarch64: Split out signal_for_exception Date: Thu, 14 Aug 2025 22:56:28 +1000 Message-ID: <20250814125752.164107-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1755176366138124100 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176506; cv=none; d=zohomail.com; s=zohoarc; b=ZtkG2/NwA1d+s9ec9dgt4sM+sMqK77pu6kPosh1j2LhwV10b+qjeszT/CRdSZ0IhVzN0TmZz+mBiVsCyzdZnmf1L7NYKUhBolBvZUBXN5xdkGpGacInPs84Q77Tgt7JLaz4KeJdelz5oElO30Msv5euOtvaJ8JuxJouk1rHUAPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176506; 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=we2kBP9OJLrPPGq7QOJ6TSid+ia1Le92lE2F6Wh2Zjg=; b=Qq4EQt6M005Sj+S6nnuzGM7R08++ghMupvlsyi6RZDqqqzzMac/qKRyKCyGyzVC0q7YwkKInDTx0WvQSRWCzYAxYg/vprIEI9Bt61vW8xjKG8hVQyRARLs8lU5BTtxLLt8kXouDigDhhwdB7x0yQpoMtxnVTRrSzUfpFkhDCofg= 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 1755176506365573.344088691838; Thu, 14 Aug 2025 06:01:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXD-0001Gc-Qo; Thu, 14 Aug 2025 08:58: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 1umXXC-0001FP-6f for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:22 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXX3-00048W-33 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:20 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-76e2e5c0d4fso766383b3a.0 for ; Thu, 14 Aug 2025 05:58:10 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176287; x=1755781087; 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=we2kBP9OJLrPPGq7QOJ6TSid+ia1Le92lE2F6Wh2Zjg=; b=iDWZ1IGNvEB7gRGXOU7o781uyTKmw7Cv0irBoLyNVipTZs7JDma6XtfeivDYHvpnou XqPaQFsIocSzW8flOGEILwMnUypTCVfhz+pawz+FaisGAtQYiTo+AtAQU7yZprp2rts3 SdSe4UH3dOWJUIaK3I/7w9OkibpIITKqUobg2poWCa8jK/SkS8J2hW6v0s5TUmazlt6D Zgq1kOsO05WsvGPXETcZ5QB5+UtI0IQTM2XfWZ7wFqN5iPHLDeOxqdX9s/4oQ4HSxqnq tHBwGXU8Wf7h9zGK8x60tpvVUy7uHWtcjypsEVszoXBqRO1al6JIweaJN7z8hmnM8RGo jHUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176287; x=1755781087; 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=we2kBP9OJLrPPGq7QOJ6TSid+ia1Le92lE2F6Wh2Zjg=; b=rothQdfIVBa8vWEC9YnS8EfHwRDfaiQeIfQVfRSR2Kgn38HCCPipetCd55xVhtLnIm QZef6qI+n7XyvDO4DIrNyiogAUm3cyH6lCQIvnq62QhAusT2w2VqKqufp6nCFR6iaTzK 1QDh4HzSFZ92qxvAmREABmp8DdDf/l0ZL3EAHJFzMhPnc2QsuaRq6mxFSVsvk+K7KsFi 63Gvt0rI/NYa/IY/6tinlr8MNiajAqITbuAyZixIPRPsXrrCoQ/8//L7XRxyEBA+9awX TF0BYyJQlRyDP8IGHaE9JCEQIaviIfF+TAFKJxk34P2b9L5ziAaPMgCozE//bDmrtL5a +oSg== X-Gm-Message-State: AOJu0YxJwAN1c3BtkTXxsnMgvwzRSNsloWOJ+J7AQAHKpteoJr7e/2l5 qTKfK+mBKMqGDz8RFk0eVfgp2yid75sPZd0te170V8n9NT0C4bR2nhKwhjvcmVybXjjA8wh+0ej LXv6Mrc0= X-Gm-Gg: ASbGncvchwWVGUtoqf1Mg4lO/A4GT9EgPoYiWdt4qO9o6p89VFoPpo7drqJCG7rdO8t 3JXW7N4qPxYHI8pbk4++YMnKHT/b3VFYdhZgltD/OqcuKaKii7k+ycfsnRoF1r2o2AkTYSIKeLF 4bbmpW3q9Joh28ifB4tir9OSDKqvYvdooMy5LWGAhNJG36mdMoVJDjtYGEfMZJUbKGqy4VzISrW AMOCm83ldf93N4jQCSJetxEukFXqZKTCpwQCIdhQIfAK8BBAgkTHrspoGePdR24SUKH6gTHBtlv MKx/7AfyCDqkf/mKaUfxdEQwSZQ8DAZl74xNQ4uurgZR5ybjWnUa+ltcSJFT7lAZQoYgaZilWOP Ubou5huqvOJGgtYcRFUdMHJNq+8htcsrxzJiDhEkNOW3VQxE= X-Google-Smtp-Source: AGHT+IHMUxnQ4jnW83NGm4cUAtCXOwkEMFLQAShZOd+Ym4yKsYbUm9PxxqPxFk36q1Hm6+OwyQjWpg== X-Received: by 2002:a17:903:240b:b0:243:12d5:db5f with SMTP id d9443c01a7336-244586d9dedmr49353575ad.48.1755176287439; Thu, 14 Aug 2025 05:58:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 02/85] linux-user/aarch64: Check syndrome for EXCP_UDEF Date: Thu, 14 Aug 2025 22:56:29 +1000 Message-ID: <20250814125752.164107-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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, T_SPF_TEMPERROR=0.01 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: 1755176507531116600 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 Tested-by: Thiago Jung Bauermann --- linux-user/aarch64/cpu_loop.c | 75 ++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 85d455d018..deb45eaa73 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -65,6 +65,79 @@ 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. + * For QEMU linux-user mode, you can only get these if + * the process is doing something silly (not executing + * the MOPS instructions in the required P/M/E sequence), + * so it is not a problem in practice that we do not. + * + * We ought ideally to implement the same "rewind to the + * start of the sequence" logic that the kernel does in + * arm64_mops_reset_regs(). In the meantime, deliver + * the guest a SIGILL, with the same ILLOPN si_code + * we've always used for this. + */ + 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 +181,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 Sun Dec 14 20:30:53 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=1755176365; cv=none; d=zohomail.com; s=zohoarc; b=GOoVVeahcJX5xZu+BMnXWTt51fd1cRd4jTqiFoFGv55xPMpfuY+4DyA/JMRGJLHtqhCTIfbTgDJiTyVNrbBRTVhLCZZCbUMXiLSwAaKDkyzIMAF5+YnxXrDnflqmIqr8FMjazRGBrzlTVDo9ny+xy5870x0+5X2zTQQk478NBGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176365; 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=YD/jwVv7EfeMO//G4w/i2o2BFpzhHqMIzR3A1RI5g5E=; b=ACTRB5S+42IOcAdam012rEjmUmFVxGs9qjKDUkVT2YlVz21++bftm2Mky7r8MeWNZJh5yCDPkB86o2Yroz6i2H35pJ1ElOe+7EFhaYxL+Bqb6mSH/waxNtc3p/hmwi7KnCi7GywyM/gO1cSFuN16sx9NSqcJS2PBfXvtFM5uMI0= 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 1755176365368768.2357648494134; Thu, 14 Aug 2025 05:59:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXC-0001GO-Va; Thu, 14 Aug 2025 08:58: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 1umXXB-0001FA-CG for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:21 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXX3-000496-OS for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:20 -0400 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-321cf75482fso1868988a91.0 for ; Thu, 14 Aug 2025 05:58:12 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176291; x=1755781091; 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=YD/jwVv7EfeMO//G4w/i2o2BFpzhHqMIzR3A1RI5g5E=; b=vfYICvMRVOReTUiIhmYCzNkX2urSd+JdQZ5d9xosRPIEZOCvCgG3HSWE2ti2AW9JLf SR3fzRDOzzirhfjvJjQRKVCg0hGTE5mhIZDzP66ygvFwhYTqbKghtRJmexcjb8UlmNcU Cc9CD4Njny2IRgFCSeG67liefqzbdW4gsQb4SoExcNe+dleHqxBRe1sxFEVWLXFXvYXJ 9emevXbX+Wr+dU6FIdIWHND5YcIRCUQE4w43/LMTdMTtDygTLTo9iHMtNjil2bIzOr8t excUjIWhZ0LeAkajfaC6e6PZL9IW+SzbC00e6R7IFhZL6l6XHNJ4Z5ohr0YwKb1tpRPe /+8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176291; x=1755781091; 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=YD/jwVv7EfeMO//G4w/i2o2BFpzhHqMIzR3A1RI5g5E=; b=DQyj9WNI9ve9UBxe6S/0KbPiFouhRCr13kf0dmboMAPxcPbQeyVgW9OzRHQY+eaKYY 2AwcoBi98rcuDdxbNUiBSAqsay/ERFvTUHqKsrQpGV/XBCCyL3mZ09vhNjEFGxUHuhBW WUH2jLzl42+htKPYcXhnVHIGpy2zj8QbWCuMkR0sLTqyvjj6QhMSsU26Qog2Ejplno9B 3yEVoKG38i5EuNM9yKlNoP/N8x1d/R+Mu4/ZUYU9+5mMKHnYHzLnALInMMYv8r7Dtg4h xUya4S27Ksb4V3/09ta+MoYYw5DG2fRhYpYAdRW3eYSSw0pX9HXaktMZ/PURj8D+ie2h JpJA== X-Gm-Message-State: AOJu0YzBQd78yihRNzWejkP0GcN5cW7fQGe5HEuxzqV/jr3yfBJpeh+4 ZRBk5/hpZ5MM0Jj7S8Qr5qQIn7csXYHMHGPN5BKto5OafIlLVX+dYPjQ3yco0hQygMdE1lTcAl5 2K1oAkKU= X-Gm-Gg: ASbGnct8iyzslQ5d2tuVqA+uO2ka/UYtnTFNWd10K1LCVuJSilWoNQfQafK1d+EaSf3 Nv1YssBSHmWd6Hz4tFPq382HoQ/nqBSmYf7VxpSUvcj1rlDwnODsN+ErG5QEfsWXvn5IWXMAi4E WjnBPQg2rDEfrcf2+KgCtZOAtuXEj+XqWiUnx5GsKTabO5uuCv6A9aM/RNAUIK/F/hTwlTAcItt Gx8YSVtnA6gGPCO1C+2jn7ZQJqTZ4rKGIe/snoT2k6mPoLHDcJqegR8zAtBvlruS5Ieh24NWXkL PXTY3lp7T9oQE1y4uCGLU6UD0XGBFR9rUnFjBRLl2P1ag5j84CseXEzGIQ8pssLSNCJcC8Ouc8I esC0eMcilTs0HuHN3AVdXEjVdh5HtqWck2ybPcCXpuDuBZR8= X-Google-Smtp-Source: AGHT+IF6yX1KhP668hLs+JOev07XbD8FRQTEqCJ+l1jMPo6gvzcqTztzNHiCYQ2qyNul8lAzflaPjg== X-Received: by 2002:a17:90b:4c44:b0:321:335e:19cc with SMTP id 98e67ed59e1d1-3232969b32emr3539245a91.4.1755176290685; Thu, 14 Aug 2025 05:58:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 03/85] linux-user/aarch64: Generate ESR signal records Date: Thu, 14 Aug 2025 22:56:30 +1000 Message-ID: <20250814125752.164107-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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: 1755176366014124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 deb45eaa73..da89dbb095 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 Sun Dec 14 20:30:53 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=1755176674; cv=none; d=zohomail.com; s=zohoarc; b=XeQzseFw3YCOmBeZU4cs34Wbtf/QWsP1Gl2kt5k7/SufUE9U+aOuOz+jD/KJPAmXaOMewdMZi0y5bxpbYFSjyvBuukDax/Hu7+0CvtjhTN5oV2pyYZiXGbTumXyVhZET7NPsiefzVKlHCjUuyQmH2ejhn7WPips3K9hq3jqcvYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176674; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=81S2M/79YurLIilhsbyfpTd1bD3tCzQZKOlyAZGCKkc=; b=nVLIgEj0VITQXZ9JifKEJoRjP66lRXYMycm69z76eMp4DtZYUS/QYyfcu36+g6QPhU3sZKq6OcQZKYgqiUgnmDhvS+ObeWl+NpJNoBRmACWp6Il3QXz2BdnqJxAvYU6Wo+YKJrQPr2vHJbM1VFFzC5xCP+ZKX6Rc01oqLDFV3R0= 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 1755176674790820.4008307914264; Thu, 14 Aug 2025 06:04:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXI-0001J0-O8; Thu, 14 Aug 2025 08:58:28 -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 1umXXI-0001IZ-0t for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:28 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXX9-00049s-3w for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:27 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-b47175587c1so553558a12.3 for ; Thu, 14 Aug 2025 05:58:17 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176294; x=1755781094; 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=81S2M/79YurLIilhsbyfpTd1bD3tCzQZKOlyAZGCKkc=; b=mNBvnfrrfy4LRmw81z3r4ay8YAzjpIUsO9b7wUNWO9M6teGWNXpuUl8f7SnKgYoNGO b3nBl0DdRYGoRxIeI78cBDHYg9uhHKleXnebwTInkNvMfy5xhUbluidLpMyQpNL7FlJY 22rs8HQKySqbZD5RjhGGbWScDq7OpGt8Tt5JqEjWUKnCv8adwfXpG5Y49awTTgr+w+U0 5Vz992+j+T9jEJHiR7JpTC3dWFJPaf2USj/EsFLev58uvUjwGcGhaLo48UokOCJ8m0kh JdwSSg/T1nrd2H+SmYvamxEn9N2ITyKlQvRQX8WlnE9PWDLcWcsELgls5QpBTZbJCWHG Jobg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176294; x=1755781094; 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=81S2M/79YurLIilhsbyfpTd1bD3tCzQZKOlyAZGCKkc=; b=UZUOvWUO8vYr8Yko8kJ+tbA109sPfw/tMAnSH92aBgDLigwOGYiz5vfDfrVlHEutUU /U6SbPeWPdInu44YXGCJTh2Y+SRIXRbP+SAA6JGfftIWbwsviD0Za12jkSe/dWVPqg3R tcWHOU0pGmuOTLWhf6Traqr+cTFgo+3PlHfR3/4z7pyf5y0emv1DGy99ym77Zhkm/t2i K3RtNppVOIJt/dBjKmpnyGpUKkKoP4fJ0kCTfwKt0egGbdCNXnIAOJXy87rg7tvN81vd a2sj9YLARNcdQclJOtb3kJIo04MVteUa5OOyeggPbBy6ECuwmXKi8gNhXq6IkcHDofNe 8/CQ== X-Gm-Message-State: AOJu0YzWEMAMTRVLW4+JVY4SR1u4AZOE5guRfRXrPJK1k+IX/+vK6zub H8SgZSFCqW/fxsCENjlxIoiR+TVSfeqklAkFCfd78/duCNmN56BP7y50aveHnUZU88DZF16dD3q tn1tiDp8= X-Gm-Gg: ASbGncvvaQXma0pmBCBNB8u5AZlM7FoTYQeETxIknIXJD0qTFPQD4jIUjzB0oxgEWja Ikuif5zC5rCqRvxaGFPs2GvoEYyNsqBlNJ+VzYPzTk/ay9kcEhSzt/9vtt9N7sNR3P05jiR65aq mEWWmvN1rnE+gOQu0FZMniJYrQY9LYb51vcYJ92TJ2OhSfXYA++ElqVnnbiFOpcGwsRKcksXnDU NV2UvcmRZuRmHrLBHTNMpx1EK5QZ1E0yOnmBwA3GngfRpDDFoZ6gJsd//SNgy96W6o7RUcNmiZL JL2ZBsrceiTBsQQx7D8BLK9ucQPBkGonksoBc6x2TICCnXZDJ45bGC3dsxokEiaMLivYSTRX5GE J+4uYRqxu1lO9JYZ+js1dygIgSCp7E0c/29GvnUbf0dOLw8c= X-Google-Smtp-Source: AGHT+IFN6cCenHOTgCeQUsKMztGXpIJf1BUxGjvLzlMSZNTxOUVsFQSPTym1V7e0Yd7alZVE8lfc9A== X-Received: by 2002:a17:90b:2891:b0:31e:8203:4b9d with SMTP id 98e67ed59e1d1-32327b49c7fmr5034867a91.29.1755176294145; Thu, 14 Aug 2025 05:58:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 04/85] target/arm: Add prot_check parameter to pmsav8_mpu_lookup Date: Thu, 14 Aug 2025 22:56:31 +1000 Message-ID: <20250814125752.164107-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: 1755176677584124100 Separate the access_type from the protection check. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176652; cv=none; d=zohomail.com; s=zohoarc; b=OCv9js03aTTkx4cqVejxQ8R3BT9W6bt/RBsLfdaAEcPmrI4h1UOh4kbMYKldVTTFiAlKVRs9iMXxZ5xwcvZfaVbCTKJhc0Yj3792QmP8zqyPaQUsjcKzR186XNF7BKQtzeVlgQOhgoonSZ2fMnRDLpbdralW0VTNnc8KzEHTHCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176652; 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=I3/z//sU8lUmyes12YwY4V86zKjX/5H9nJ8YVA/wfrhOnZuh6TF6evDmsNtEosPjBObLz8URyRkE7JxV8wJu7DY2GPGsQAV8Y6XsHAWSy211PUmzItg8i4kzb6DkIgrhJiInLxq0OkdF2BVXknLp7derxUr05OudLbhHJCWJmIs= 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 1755176652798417.0477665306222; Thu, 14 Aug 2025 06:04:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXK-0001K6-TC; Thu, 14 Aug 2025 08:58: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 1umXXH-0001IB-Ic for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:27 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXC-0004Ae-W7 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:27 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-323266cdf64so748090a91.0 for ; Thu, 14 Aug 2025 05:58:18 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176297; x=1755781097; 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=wU/UF/LtqXwxLwAAdGA0hYotCBfItlXvX92se0qYn7/6Dg8wZ4sA/mDgul8U8daD1k Jrc9aLbD1iCowuAftWRovDeCWU+t82R+kFK8/eqZaIH8N/taJj9uUY1+Mqurx6/QUaE9 py5hKZjHKOi0HxW34/ROyBIfR4wVQL7zFvVb9LF6RKz5DFTKBtIM5f8nJty5mkeYkoVN d+BCp08Nz3LLcNk8mAydbcViT1ZDkZBeq6/X1MrcWhgFh3UFij5ZPQeJ1QJLFiNN0v6H iLsZD2ySmHD5BoLhvPf5NSnoAFoTR/8+AN7WQXLtlEqEB/+2UB4cN1EYJLCt07O1sZgg aPUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176297; x=1755781097; 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=prBSBHOmv3ukEXVwxlOPNtHuW++/trCRWMfjoPxAh7QWS1Lo/cHedKcJoBgCcSZauY D553mT5w7jUN4bTpXQnGaHVmxwjS8nuIbCAyUKJUnBlR+gXZeLzI0R5pfIOF3WT6r1wd KRig52uursXkhuWrhlQRPXTwP84H091FEs1Q+i19LYuc0fCRQHEwo/3tKTW7EaqIyxJ2 mFG8eYTYM9z/r4/oWm7AoXs0qBbQ5X5NcCd2XFB3PAMITalNKSg7lbn4VVNhjeogQtG2 sStkSVZ/iymynSF0MRhHq/IWAK5WOMLBC6iXMBczfI7CYq4lqSU3d+e0DkOQniN7roRl ZGxg== X-Gm-Message-State: AOJu0YwTvWS5DGF5pP8fjaj/0wODk2cwVt6R/cL09NQXgg/2tW6frR2T +joVARgZiEIlVxpODH8lEjQ0bguZpiVLLB5J3jL3viYEa6CTkR1sKqi4ju7JfjGW7M/eaaqxHaK 0MRRVqIY= X-Gm-Gg: ASbGncuGxw1Ps6fNn3ceKkudzWpPz/YyUaiI1lDpMc03LFrbFXhuKI0AK7kFD14Uj8M +J1KnG9OJpjNjufpRteEZ2x72OtOS8uW3hXab2Diu5lGPGhcegSf63kuJwZoFu7KkD0vwcxJYtX lFVRUJegJ/lJKDQywRaRA1hAq2LaASJU1B9UP8M6NWN/heWZZrlKx7bJbtJov7Iu7XKTgUw3eaZ LsAr7+VZE3ECnrU8dvyjLlQapMzfF8K/evE4JDkHR8iQsHl9zTmzjHe4L1WOKFp74wNIebvYPBh rLQmScsHysxf8DIBXgdDsAyEorRF7j2BUGWWWDM2dk0EVNJSF5xB41K66fZpPzS9ucxKJw/aK8+ 0wkjDOiJaEdzTyi8cv20jB6ju3H+9JL+vVCSTCIv5hJRwjEU= X-Google-Smtp-Source: AGHT+IEEkDVwUeo+0flKhXVYEd0xWuYXNa9nYpOvcpzops/r3tb904L+7jb+0KLEwtrcUz1vXsJBJQ== X-Received: by 2002:a17:90b:224f:b0:31f:2bd7:a4d2 with SMTP id 98e67ed59e1d1-32327aa7402mr4464031a91.35.1755176297217; Thu, 14 Aug 2025 05:58:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 05/85] target/arm: Add in_prot_check to S1Translate Date: Thu, 14 Aug 2025 22:56:32 +1000 Message-ID: <20250814125752.164107-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1755176653357116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755178003; cv=none; d=zohomail.com; s=zohoarc; b=HtDuCszNnePJfUdj3GNc0loVPoIJItIUYjXal6hdnlxL38fAWKzmtPIKAufHXBNTJh8FWBReRkRoJNYIpU9CsgdtATIuHurCHvxGQBls5PzgK90tEW7eL50azS6b+x0OJEL99lNmAeuBdZneclXgO4gDSmivLRMb84CLuxBNRJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755178003; 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=VcXbZ2CpiDjk+wakdQCbtOsZjpbtXBi0ihmvVVYW6I9fDckgG6uAPGElOSSDUbRTbyVxe0uqh02VBOgbmjVlUd6dAzHQwxH0lUpM1uKPtjdgKmpirwigpC/lmGV2SNDiKBcJlQzEKvIOGKRTLtbxKFTGtz+PgC+BjviEZSHazNA= 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 1755178003760718.0936725935609; Thu, 14 Aug 2025 06:26:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXQ-0001Ml-8X; Thu, 14 Aug 2025 08:58: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 1umXXL-0001Kw-Ps for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:33 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXF-0004BM-FP for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:31 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-321cf75482fso1869299a91.0 for ; Thu, 14 Aug 2025 05:58:22 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176301; x=1755781101; 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=kScnhijMkh4fK2TAPt87EurG5Y/CEYpuG1KGasSqvmKgIcu8LnkzIkQRCZWGnyKERg rTcre6mD2BoALSiUVZxmXxNEdWOhVgn8iB9FwyQm6eb/2dpOgeK+IokUwen/qozZeSKb 2nNYGK4DTtMdNiPteMAvIpA/Z4P1EP40YdEACoEvXPvUyIxBBvgJ5zWj4sgPgCNLEbWw 59bREfJGZeUwlhgN7nDKBnX6tD6OpldOAvgVZTy72z262zYIN23kg2ATyp2h6LvsptQi FIjrA4DUeg1GZkVCe50PCx/hIZXVJPuqP28CBUfHJWLYKVTSRs5+/PrXAOJb9iVUzZgm kQ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176301; x=1755781101; 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=QR7nqWnU78PFGsKz0I9aDExeX0gh40nLV0ygZNORIC51A4SuvAGgAIqaqwlbB+oyDa egUg+jFMK3VN/i4r68XbnCcsjHNDUNocAuIeEntn0XktmPI0n9jiTY2Aw0INFVzfztz+ y9EHYKTG5fHzmuld6LYLNg3zinEP+Oy8K3V/aLscMlC2Yk7YTj67GGoyA2C4/nkrRyw8 zD0W8iBpmpQkVBCi/JAQyetz+dcXx3DlFPTPbnvrjzusjAv4yTQRYr/LaRGroEgLzF0y +lgfhkFHG86e82wbvFA8l/Hr3+fEFOzMZrbCFgt+WWJGfz8/IO4kzKEFhNg6Nh9q3Wss TX0A== X-Gm-Message-State: AOJu0YxPNQMKwRq1R9ce22TxveO2Czmbv2lV0ptagS8yW2RCPDuTl9ZX oJOOPBrETGxNE074p7CUyBhjGFy9hGPYevp7vHs6Fvhaci53n5DncoPOyP8/g1XfkS0hpr3xXVi /em8tE3s= X-Gm-Gg: ASbGncvtutXBROVsfH+Lo9tw38NdI1+JplQZKZhXPPvCh4M3ixCyly/0GmoS5wrIAMK rnzbas9hN80M2xke+i9qodk1BMXxRyxF8yKrdDkdttblXsNfSwiWLVoGfndU6+UMU5Le5J1TK/T EIIry3A5v+Koo8xppQb7Has2o3Z3WaLoQwTPX9RsibZi1UjIfQSDt46QzRgfG8N1Zw01vI7MmB1 IrkSvNl2QKlZZRvSF4pBV8FSDU6qYLaSHz1zV3wr5uat58tgCs2Nu18dHHlUa6+7XfCXkFJk8w3 ldsYf4jy2VwepZ7h+I7R2fio9yedlDPzui9KtAZSf49x8p2QiPWju+WiMCf9y8PtTON1dMY0M6y zxNu4NRKAxVd1JjFVs1h1YX3m700NuONImZG5Cc46M5tqLRc= X-Google-Smtp-Source: AGHT+IFZ5p52PRXa1B5zoo+oD3zwqhlKplNSRUKode8dH/AgWf95c1aSo4HrroWTDanby1M1KeMciQ== X-Received: by 2002:a17:90b:17cb:b0:31e:a8c4:c188 with SMTP id 98e67ed59e1d1-32329ae5446mr3782241a91.14.1755176300530; Thu, 14 Aug 2025 05:58:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 06/85] target/arm: Skip permission check from arm_cpu_get_phys_page_attrs_debug Date: Thu, 14 Aug 2025 22:56:33 +1000 Message-ID: <20250814125752.164107-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1755178005900124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176858; cv=none; d=zohomail.com; s=zohoarc; b=hZ95qi6EB6fvBAGSLPpvCJTi2FcQWSd4qxaSJY3aDa9DbW8SFbLmxsDnhIFZ948DmXKCrP6LkeLMyi2XG5QDCS/0hfWs5aefcwJC5F5JKa6JIttE91mhljIia41G4du1+Mpj3ZRk/tX7z1R7EcaVA8xsDX3f6gUhTH5oerUhalI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176858; 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=IeqZkNW/nZVj3TiDA3YqKMPBiuT2Ux3EcdJP6IR9wrrtr2PRVE35CFHjIV/xuyZbBcwhRIsBKZgp8ieKp+sa4iSqVCLEeo39dluBPKR+t39hUWP73Dp3uDnoNSUL4diBvpZ1Lk1A1KkKBbKkdX/B2TaIeUCuqyoDU4OyeaCL+l0= 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 1755176858210236.3217434504769; Thu, 14 Aug 2025 06:07:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXN-0001Lf-HH; Thu, 14 Aug 2025 08:58: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 1umXXM-0001L3-Gx for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:32 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXH-0004C0-It for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:32 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-323267b98a4so864010a91.1 for ; Thu, 14 Aug 2025 05:58:25 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176304; x=1755781104; 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=Kiw3YMvkJYp6/PzjKQ0ot4YbSkRAKZ6Mf5fh9OOGQM0Ebiz4bqUPiD3SK29XZhRppe XWuIB9RtKXRruRnWFUqPZE5jIcHzss2krZFkrYrlycSuokr6pTXl/j1s7jGwStl64bln SbrRh5+ElCDYijShrzDtWYjapQLvq48spF4DOPSKs8YQ0GN/j3bJkbNJwoSIEBSU2hhr LjSCa4Qc/0mclni6akK48gOuoNrszs+0k0Vjxsh1orda3QBdWrWWHEUvpdxIxUzOdIeS k+AipZIKQHcpolOxKi/OuawKM8Hi3Q1WLV1o2bAmGRLpmesAlYJVHA5yNH0kDbEbIwkP Tesw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176304; x=1755781104; 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=OfzPZq9zFKCObbqMsWS7jfMcbiSr3nMJjqQnLcMxMGYFGbNHiKQbatDpt//VdjADY5 +q1OvL2RKhvcgj4tERoXcOy7RnHBRztDj4aYVFP4h8iLI1znBk9dp9qBOWkCH0S/bK/r 62r/jNWOYtxF1LVMPDFPnc5R2swNGvawq1jvZxSYEXbfTrtlmFJGg4obZO4y7w8HgfyJ dq9A23vcAuJbsAbTi86QU4yyKiPwq8cwMFyHF7cyAliMwbPasRwjsuq91kGRbVtuNlhV Tc+g5YYbeJ5jI4e9FSFe2n5FH7+u2apptl5OuMP/X7lR0PuxnqnXcdP6I2Dt9yp2r76r TP9g== X-Gm-Message-State: AOJu0YyqK5DaLH0kGdjOZdVgN+Gfsar3YLTBKcciNv4axNMUR4jjeBU1 D9aAjwEXk+cKR5iIVXcst564B5zl23C61DSjOJd/NhlLTW+yx1BdF8ZdJWyDOuFwElElA46r0wL ejkN43Ns= X-Gm-Gg: ASbGnctV5ojhpw0fXSHRe6S8UlsuwwYKdtVWgqBa1i2dROPDh2vThtmK9r51Awz7Dyv kDIhS/+dxrywvlLKmK6IaICFQt5NVlUwSuTU2yohhDRBbICHvQT+B10HDY27JsSHRkO+1GDwDZa F5ooD7m5/BqPstHEFHbhNusiB7fmpA1DY6vj88dXwLCA69WQmK9L/20a+ex9uOsqBValt3KlXAn RILo0PJDJmC3NqF5Kff+s1epfPswKh9R02Sl1GKwJcbWX3vUkYyTEN4IXZDpdJZSjscFDuXgd51 MoJX0glFWsIsX7JHMw0o/sLs8zmx9W2GmLT/+2Yoxp3p6f3gIcrienn42szh9RZ1xNgZTGMu9Wd DegE2FExPNXz5UbRcCk0aMelx02P6xgKrDEFSdynH/RuZZd8= X-Google-Smtp-Source: AGHT+IFkliGFbRD4ynwrlexJaSlOn3qSueStZwUB9d27eiOMUHT68oz+UIBNKMm6fTd+Dp9x1+lBjg== X-Received: by 2002:a17:90b:28cd:b0:31f:134:94ae with SMTP id 98e67ed59e1d1-323279c853cmr5224610a91.11.1755176303832; Thu, 14 Aug 2025 05:58:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 07/85] target/arm: Introduce get_phys_addr_for_at Date: Thu, 14 Aug 2025 22:56:34 +1000 Message-ID: <20250814125752.164107-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: 1755176859487116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755178009; cv=none; d=zohomail.com; s=zohoarc; b=V1RC7tbc+AT1hqFRg6XIQ1cZ95U4dyqB7VLx8divgXuabEMPSIa+ZhzcegUn6yFjKnYlVLAK4ZFt/Y72asMnGxmZT5fJ5DJgVO90zXInZ4jNqLVPJGbfp0uhxvWT0IuNMsT6zFTeqb0yrO/NDMHzvNuhreE4zb1jmmhtrs+Z0wQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755178009; 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=dADr1hkCoPbAKFrFDPChMvcn3XSmIdgX9L49C4Bywo0ACLwkscoXtAefOwqYJagfRnRe5MlWDfajLCgDOIIldUOX5Mfq0tOMrAS3ONk52TUFOBOtKgcVF4JAsjX3XJv2trrh7man7yVyVYHRkR8Dz+ImD66vHoGOxZUbUCNyZDY= 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 1755178009011122.67081520391798; Thu, 14 Aug 2025 06:26:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXQ-0001N8-BW; Thu, 14 Aug 2025 08:58: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 1umXXN-0001Lk-JR for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:33 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXL-0004CZ-2O for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:33 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-b4717330f9eso568669a12.1 for ; Thu, 14 Aug 2025 05:58:29 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176307; x=1755781107; 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=NRDPQGx1ul3iqlXKzAN9IXJK3LbThPD+Jjz7u0RTP+BtkLiUHLENzid67z+thzyV3/ 7JRl9StfYn9ylyqndYdkIufCFSVjVA4FgiCp01cbOi0ceRjclyMzTg9cyvTiUSKOeglU 7fV/9fbfuO6zoho019f4WhgOY+3hPs8moqaY0JEnpYnNXAefwJhw1NechAdZbafcOzE6 4aDRZnHOAjLYj8t0icCx81PlDtJud9VPoFbOd4zI5QMZ9B+jgK1iNF5hGcGvogbB0bD1 2PAyI/J8goWghVnodpoKA7EdWtrexRKYDMfAJGWzsLWlr71rPI9oyRlWGJav0LQ6A9rQ pwJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176307; x=1755781107; 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=G6UWaMewFMNjM/lHHAIjhtfCVbgrMi79lMSBdNFMOMcBjQyB1csWJLrNd2zLygdccI oe3ajEUudHX43OZxYpK6zyfJYoDuzpCyjAggCZkenLn5p8XQOoaYbwHIVv3x0tiBcnGt yDuyn6iJ36oUfjsc1zPC8o3kM4Qu3o2UGD2WyNBCLwU1n0Ena60DIPY1uN4akoPPT5Vl ixN3GioE5rgIlWu4nSl8voUGlZXXUp7Sq7d7OgdQSEEGIuqyFunj4EBX2PI5N2jqODQP 3EYZZk4GzAXlLVUDduNapCj/hbimRJeuzA7hw+3U+yUhBSCiLjnGvZ5as37bRFBLXksA jODQ== X-Gm-Message-State: AOJu0Yw9TYAvTHV8iMgeCpwbtLIzj8JVUFji/GcfpysW0fM1w6nNT83l /iMYC8ZVWIMqgBkgMRKbxBlz+G9FIQEA1NDQWmjzJn69o73jJR4KlE7HL5/lt8CIIStOhNz7G7L Vaa8Cahg= X-Gm-Gg: ASbGncuGG40IWrNcAWs74zc+qOE8llyrJFeDOyCf4j2A40u7gQE+6CVzQCzERZl0Bcb IO9ED1CTeleE5SJVMhEsIopTVB9RKjUJG6d5l1f2T1Xti5XDhzPH3Jgd/8jzpC6HQsTyDpzVJyQ loGeiQoQbs82XwO282Y7G4bHfQJ5qyEBGz8H2jd5y8qHZ8LrSg9Lw/Ad8sSn2Ap5c9sIfh4+ww+ 3n0Nhk5xDhKzcfyADpFMCmZm8PJ7KGt21DpTE5ENBzpU/0dyZHsb63sFZohwrucFKOCzNn3RAZ7 C979dCxfq8RGN/VhzkqINalHLKchhMCG4GOTvSOTo4mnq05PaEvBYrSHDgLjO58VGcXKpXXTENo qzsavrbx/Ax0Jx2x8T5a+HemRdI1le+NfMNM0C8Uxzf+iUAq5fUBe3uHpag== X-Google-Smtp-Source: AGHT+IECq0JE5COud0a+nzlFdnsijjbMdL0xA7g4PhadWGlBtWnVyjtO9zQPvjGS9wyG+/kyrlsCfw== X-Received: by 2002:a17:90b:2b8f:b0:31f:22f:a23e with SMTP id 98e67ed59e1d1-32327a9455amr4348588a91.27.1755176306889; Thu, 14 Aug 2025 05:58:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 08/85] target/arm: Skip AF and DB updates for AccessType_AT Date: Thu, 14 Aug 2025 22:56:35 +1000 Message-ID: <20250814125752.164107-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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: 1755178009772116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176858; cv=none; d=zohomail.com; s=zohoarc; b=AXEEMv7IlXMH32HOTquPDb14WAzc2ayzB/Bij3F6/A5OjB/iZaCbM1/Yfnr0GgRR28TzF3NG7BJ6TTiABvJWJ+ciUou3uPVw5WeEMpaH3Y0GjkTXqCJ9ghDcCkrjOnI1na6958Lf12QfsmH6iTVmG6sfULNUZ6FxdrVp/opo1BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176858; 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=U/TvoisTGYhpKENEPKMSRau6XBDV8ZC9qc02yIxYkO/2wYjTqIpDYCwZ/USXo1FP/+yJ4iDMGeKiFv7FBdbUS2t9XLW+nLrwNMW3cz4e5EAheVkHwfd0UZH1MpFCibVi+PTKkWv7mpnpRtKeW88FaN2VXJ8Eo5Tk/dvPDWqNGrU= 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 1755176858627916.50056159572; Thu, 14 Aug 2025 06:07:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXT-0001Nq-Gg; Thu, 14 Aug 2025 08:58: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 1umXXR-0001Na-Pm for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:37 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXP-0004DZ-FG for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:37 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-323266cdf64so748293a91.0 for ; Thu, 14 Aug 2025 05:58:33 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176310; x=1755781110; 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=fY9w0w/6c0Zg4Nl6JXczKAeJmVctqb5A+j+YqpB95Dw6wpSPsyapRxSepzq6tQXc/6 s5hc+mtyMHetjxnRbAfGi0i/GR8HKjd22RlDtGHmy0j6XfHD8XB99X1UCAtTLDQO0KRi pRZNToXQKktBy5lerYx8IlIj0C1KqClmOby+hmnvD1oLtU3TdKHdi5dZIywjsFOvLVZJ vPlaBZPh21SMJ5J2QUNW/XtXkZK0Vz2XImjnJTMci+WDNaNl3EsILJU6hO5Jbij6aGbx grMfEWttvPyK02zSYbxRBydvqx74mi9X2VPFZMa3fThhrYSIytNEC5iMEkQtfDvzDbXX L8xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176310; x=1755781110; 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=vw2i5EtlUyDlRR5WfPkVPoldEbdpP2T4PYscKtzOu7bAYdX2zDoPXDLjQe+ocOSmwL PoKSMUuq7T/KHtt2ky37zePkrPzWmsgZ8XKhiAg/qInbdjHyIUQzERE+jnE2BfqUa3UY enyLUGAPqJ0XbEuKEMd6XZ6h7tDgRmKiC5/4DME/jh7sFyvVQ2WG+/t0FqytwqC7joug y/9Sdgjoy4NS5IR9SDezjE9usN+7M7z03aH0qy6KO3zFL+p+I8xPiWstp1wy06Njn19e hXi9MASFt8vHmy6yqGur49AEKN8U0v9FKEbuS2fh2Q936Ju0jK9i6zIzWtgVqP5C2Vhn 4wZg== X-Gm-Message-State: AOJu0YyUjrFpLRbye/B2jtsC8GttZqsLzAYPmiCFk0k5ZI9Uxg1pCe/k NIcCJO/yXgxB2srb8VHhm0h049J64H4vRaYIVgj7lRW0GH0pe+LAdV8osOhKTpoPBrsR5F+JO6E m406tJU8= X-Gm-Gg: ASbGncuE6Up2WJVAE+oFRLxlxtbw5Tchx1wTn/NcS0/hINZb/+AN8CZJjoDxXqxgKHk BHZ/Yfu824Kg93cZI9BJJsDe1459MMlYTTvag8RqNb+n/WR7bPSVSI2f9zHXJVyzDAP9ML2JBhG 5s0zvP+Oyz9RvfBWKukOOcn73mon35aOywA8E/wE+HT1UJX9BvbSP/91g/xgksU3CkRKGiZK5tV O0FPa+LzMJrq8h6OVeIFC8QXzA7Z9Q//SqwiRlysez6H3MrY/zgoXM1cQ6UFwzmEdN7aOG3Ct3y qQfKSzaaEDAU6rzF+4dQ8JBK/ubAAgp12ml/4deMix6txgZY2G/9aG91incaum5mKDjgQoYfmLk toUzRHu8BoO3UpS/U2JGppuS6p2/uYkFlbnu1nhLDp6q+wTg= X-Google-Smtp-Source: AGHT+IF4Y30jvP0HWnCtxUnYio+Q/TDeSeOEuvch3KUZ9tt/V+EakCJ9VOy0H9jIGqTD/saLIFPNzQ== X-Received: by 2002:a17:90b:5630:b0:31f:ca:63cd with SMTP id 98e67ed59e1d1-3232795b07fmr4581596a91.2.1755176310282; Thu, 14 Aug 2025 05:58:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 09/85] target/arm: Add prot_check parameter to do_ats_write Date: Thu, 14 Aug 2025 22:56:36 +1000 Message-ID: <20250814125752.164107-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: 1755176861664124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176802; cv=none; d=zohomail.com; s=zohoarc; b=JhHWLqBJloAvGhn5nHbgiCbZt10EU6zvLuGngN5SvqKxUFWA6yIDE4INzNe1Ek2ZVxuLBk5VrSbEMIsFuZEO4aZc/IotRckbfiEhLQde2BNYncwaGJCjGasGhzUztqLgVgLNctEVAZVfTozCIR01Hxcr2uy39vlVAE48nkbNWXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176802; 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=mxzmvv598e1LGiPuDxTw30esaq+H2N3wojyGzMtFJVywxscgp/OhwlEBFWkxgHOcmCJwi9h5BWM4NOWh7rCaGIAwHPOlZ2FDw/dgvnfE1oIVEy/vAW1EanlYCETc5GoJXVwxNdAbDwDy2l9IMwDo78p+AKJrZf/D9Oqu/YRYGzI= 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 1755176802586773.9091045261936; Thu, 14 Aug 2025 06:06:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXV-0001PT-E3; Thu, 14 Aug 2025 08:58: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 1umXXT-0001OQ-Ss for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:39 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXQ-0004EB-Nr for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:39 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-32326e67c95so1319538a91.3 for ; Thu, 14 Aug 2025 05:58:34 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176313; x=1755781113; 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=hMscfo7bcA81xcf0jJ3cJ8fo5Bu/x0+wH6rmYzZ5mkr2vJGmwTJI7f5TgLXGtRIcEI idBji1EgF/KxKp4M6Tjej9FbcF3iwGNMRzZaUX3SbXgEwZ1idRqysdkaxeM/42EV5rgR rtl2nS4+Rk2SwbLQC+jR79VoqjcnnitkTJyiPY3hhxh+XBGhupkUWH9gzr0PwzXKLDsw D51n1ydtH6gRdghedUxvhMSNOGhwQubzbIKoO+a6Gs34J1mbIUPbC9SpnOLFpkod5z4C L1HB/60hLhDSL5lrqgnIIEqtQwNJNKj/5pVABacTzXADO5JWxXLf5qFSlgOH9DnISptR ibgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176313; x=1755781113; 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=QF+GyB5RTwxpKunKpGiBusOkyQQTdfGwHyeM/x+pKJIsaRZZIjMOYw6Xn4DsVvxNVm ETVipYo59zaEKl6mbF7XjXpXCUzug0iQydZrO7nb+j5NBhX5wrmEltcZTc0wDn5yrfFS hyNVDus0UrGnyz8ArfCIKlAfjHOOKkINHDSZy7oZHtOlUmOSAyBmUyrSgY3M8LX5ZIwn FuFAKcuEgM1pXsulWrbKLA1yf4nuaXrGbIKZ1WWJ19U8O5qDvLemEAC/n5atFDX6hIu3 iI/BhJimQCh9y7CWie6gtJ3JeKVZRCVRiKW8cwJP789u73VFHmhc8RQN923mCuM9xMSq 7Yfg== X-Gm-Message-State: AOJu0YzgsW2uHlBE3y4vaKZT4BOtePVfVHI/jPEgMFKu8Ck1ewAY0HZ0 ENPM6tSBQKKbBCWMOmrX4bkeC1/8np6CAmvgF1HFX9r7Bm6LJs7oR8/BFO34iWhZ5k5OAdD8zA2 XwFbtSJw= X-Gm-Gg: ASbGncurzZtpc/hcjYovBnL2hGN+fTobE4ucbhKmC74iyQp6lbH0hEumC5/YFVZcpNT zlxrlcyErtnEg1ja26LFhwL0a+sHqyTqTTGVNPLItTSmg1P0dWE3j8KFaqKiKe9sIeVguwaULRL C+nkHX99S+NLrUjPduIDPKhMnXwdF6ZZBj9XIekOMSjpcBssGl9H9zjm2dq6BrxzK8u1BkdYHbr 2PLGN0QZZO6avv5/Zh1h8FtJe3+0tWE4RhYDLNFI+88IGZcrfNWTKXmNNEF33Rd1GheeoJFewIJ MW7rIcjsIvFyNs8PchAxQ4QeNC8NUViN21xSSPDQYBsOKv44GCE/CxsQ29YqvYgAlhDCzHYRTxL 0m353lzwF5UBjeCIpa4zLst92SOWMpaSAiCbSn5sPI3X9ab/n6Bjw9QkdLw== X-Google-Smtp-Source: AGHT+IFRJUfoCzm3PtL2k4jQEUZ3CSNgU83jsQX7Qd3e1UnzTBACi0q7w71dAOK4Cl6HgJ1ThTAR1A== X-Received: by 2002:a17:90a:d00c:b0:31e:ec02:229b with SMTP id 98e67ed59e1d1-32327a4e21cmr5178322a91.20.1755176313324; Thu, 14 Aug 2025 05:58:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 10/85] target/arm: Fill in HFG[RWI]TR_EL2 bits for Arm v9.5 Date: Thu, 14 Aug 2025 22:56:37 +1000 Message-ID: <20250814125752.164107-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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: 1755176804970124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176857; cv=none; d=zohomail.com; s=zohoarc; b=PaUSqdikNCWjHEuSajJO7FQAvzQfaMrvsw9oClt7jga1DaGpgMs7T5b41mK4htCRXk1chKIUdQhBMzu3w0T/ppXX/LyWQ3jrZ92oZiSJpECQXuhLrvA+9pShffHE+WT1OEqFAz/J3bZgj2DS4v++LYggz8PEZUJJat/1TDUGUNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176857; 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=XLz1zRz6uFE4CsJ60tWVQx1JC+e0JD3DoIe+DUe2/tULPbaT3iMPjVvnoT3Hb0WSWuIXGntHc+Qv6Vj12RcF7ukslM27vVQBM7SEmtVa9Ri/MXIUiMMWrJEexebwyd8ibJ6jgjC6wQgJdOLjZ89Hh20iDjXFU8nSWn3Fh4xvIBI= 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 17551768578247.542538030520859; Thu, 14 Aug 2025 06:07:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXe-0001T3-0H; Thu, 14 Aug 2025 08:58: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 1umXXa-0001Ra-8O for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:46 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXU-0004Eb-2N for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:45 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-323266d74b0so802749a91.0 for ; Thu, 14 Aug 2025 05:58:38 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176317; x=1755781117; 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=aBVmYSDTH90lnrn/Oamdh7ZVnLQDp+3V4qUxGr1HQSdag4vajOfz4y4KrWIFeMgbxi 8979vaCETboj07CHjn4cDixEC0X8vDMbHyJnYo/lzOPqOofoTEJ1wPUal/y1xkFkWcCT St5W5EuTyrQRN+p4ol5KHGyLzV2LMwbQLr+CmjURdDiieRYGDn+mEvbCJwUAoJEHOCXV AjR0VFAGhVxVD05oexKKn16Y3XytPbZnAOtQ0lyOKcqpD4kGGLRsoAUxAGIyfyOvFgsT cea0xxR8dx0hwSVR3ZScqTxQ4vVSKtc5TFWi8JpJtEC5Wz4QyWkGXU4JAcIdQnd2+ADW pIMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176317; x=1755781117; 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=raW7y2nrZS4/SNk1wS5zYx0i6OGWhTF3xXCFLVmSf0Pv2meSzl/O44TErouxcIUHc7 bydv0HrKt+gXtEy3L5fwbQv8P5cJjR5qEk/43GDeeWof2EESNXZFBlEM0ZCQTV+xhuuz vuy4Tvf4mhoV9NXpqnaNl30Kx6e3sOj0T/hGqw5WYO+G/j031tA7DiWo7cbEA4YLMvzO PfnuAW4BjcjQnAvS7q9vcYyzGg1Lg0MGmZ28I5LVmrNQAHTp+ZrqMsUmaeAjuRaLzEe1 oAm8cdYC51NM7mvYl0yBtvyn7un5HuhA4WIFekHGTnqKJ6ALAp6F+Z3ri3dRFP8XpS8E pm8Q== X-Gm-Message-State: AOJu0YyvtTKRcXbVplpX76E27nArdDj0I5naucpVg0bqSgLKRc1DefYr DPvXrwt9QVj4ja8xWtfGLpWsPQsM/3TOZsPKKsfEa1bavpnE9N9bxR4+HUMQnDNhRWt6Jp+Ckw2 nvqNJ0zA= X-Gm-Gg: ASbGncuVRNP2dafHeLvX+f11cCaVvwBcir5TrkvXaJnvpi+JcenJnHH+yzHKZHmOxv5 k1dpTc8htJmGVmZgl33gGF+2ZAkTrFAdjrYDH3/Yq/vAnrzlKf0M+s+5ilz1mXqaU/MjUwC7iiC YwhI3C2JwVmCQGPu3YkxTO/crvfE2lUnpLnuD55Uo40xZ6e5aIzIXUl4FR/VLwNa4Va0gQHRgz7 k5y+BE6NBrwHcVj2uHuYu05wvWvauu6WAIX7byvX3aIcPTYyJIBJzPqS3EC+ixyGvprYA026Tss hiE7DjJi72sxulxCEgVFsH5rweKl5sh87mrjiBR4ZTHRQJbS86B6UL9h+qXph23Ht2o7Lc9MPUd l/aIdf6S6fky8D+AhvpWTYzrIWEyebEZrcDIE5DzZo+OdmPU= X-Google-Smtp-Source: AGHT+IHw/SYpKLV0B8loiRS8XqqSKUM+uNoE2b+an8n5OSmL3dnr3c8Ey072KF1FAmXDzJQm/HDhwg== X-Received: by 2002:a17:90a:d403:b0:321:752b:6c95 with SMTP id 98e67ed59e1d1-323279d75ddmr5259238a91.10.1755176316630; Thu, 14 Aug 2025 05:58:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 11/85] target/arm: Remove outdated comment for ZCR_EL12 Date: Thu, 14 Aug 2025 22:56:38 +1000 Message-ID: <20250814125752.164107-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1755176859349116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176401; cv=none; d=zohomail.com; s=zohoarc; b=gjyBQxD4/YwL3x15QV/RxjjgC67YEcsY3eiBF2zabhzTGXQWZ2hQdLOikQx8HmNyjhn4/2yKm4A/wCmEiRcXoBTvtI3XAsC/8vGR91+kes62E9Uxm7Wd7Q8py9gPvb7H0B62Lw2kJDtHckdO8sZSSNsmM3zO7VehYbWfSuNSmKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176401; 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=ARXTZQ/j6ZgMpcv+eeE66Tj5PThto5VQl+hamSLgup5AM+5QSEd4NY1mXoRrikfYqfaLtcjW6AB8gUr+stTg7NM5/6sHT71VQeg+06fJ3Zu639xWPED9aeSJRwxn0Rj8PNMXoRPdNVbCNpYXku2B3WYHlsTtvXc1ZuiBEUyWbCc= 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 1755176401633165.11326425887535; Thu, 14 Aug 2025 06:00:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXn-0001VY-B7; Thu, 14 Aug 2025 08:58: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 1umXXj-0001Um-KO for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:55 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXa-0004FW-0i for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:52 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b4716f92a0aso552178a12.0 for ; Thu, 14 Aug 2025 05:58:41 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176320; x=1755781120; 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=PQTzIHM1X7puemPNKrcLyET4wfCzQIvhZ/hvEVqnexxFj9Jw6060EMeTquIsRu/upv oYJKXo2LdH0y84/ZRUcoWmGgaMi3i6leC7Q8dzZyJDpmRqYc7GJJoi10I5ruL0YSuUp4 pQM9i94COp+Sxx0f5BrmxNHeQZKzvz9wG3KsNkPxZjM1eV5l+WI7VXrovH0vLVX9OXzM 39JFoPz4KpD1twMRHNyHBwFdaq6aZ+BSCSUksdkK23EYwRj1cA2kipsqtM5XzuvPAtGs 5KB0XtitDw2lupvh6kcawJoy9dHCGfrEkkI0mClM4B3x0PhEM3OnjSAP2ftWOfhJfGFh Q+UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176320; x=1755781120; 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=FIb+p8uBPRbHbCc4VQF9NnqBGbSGIcdXPbYnvXm/JKeEcmnQmR/gNJMxxTwPhHi5RY PZkpAEyq0iZAqzv/JrVBIxVtft6gZPs0SOUC8V9acvb4QNepTdP/aICCTTVMZy9U6j6Q t5dp6qWApTJyHS9ua6By1PE/sGoat6o7XFiyO6TsefvLukdeJ3ohP1Um4pc7ytMzsQVc swxYap5J/+t82tPgD3fEuHu1PfXak8J9R2972J2Z5hJ1wgWm82UkfNzF0JSYk/YiUfMr C86W91gritF1MqpHF2A59AOeHjh3VO5gxCndMyZ7tIrjSPKaplwW2oTinXPuPtmZybLL l+8g== X-Gm-Message-State: AOJu0Yw7rYt43j5zos91Yg6MbINdBNIHtclzhIBUx6hv6xSnhHH2Ff3H CQYdZ/xExUlrXQrsNmEY1PVLNlvkJLmpsx1+XOMEcZ1tfJ1KUrgooIM9oA4AAuxRiBWXGBlE4cK pail7W6k= X-Gm-Gg: ASbGncvlgUMg1M5gu7K1reU8pCPwxzlntPTHQ4yZP5RvO+QrjxwRF7hJGhL6jSgXz0L NNX3eQWnh/p+ldV/tDv2ZQHRJ4WYzoOjv/krMmVzv1GDOsbrd2SUia2KhAe+ndW7O1MadGsplJQ Wx7w+lmvnaH86AfgrA0ujYFpH3yhXSv0egvVW/6XcgKmrmYc4SnfI5wkJZrPCsk+d9sg46RbRNn ei/RhD15wQH8FX3BOjIiraaAPeTdSphufD+cVzC/7hxIsqPYKl2zb65sNvMMbuMqpMKQcQ/Wiio 6Fxc4dbWAVNm9gxMBGcfif41F14ylm0VBYT8qSxrvqgfTfa3Y3p/mB1L+TfENiK77qqnPmZBQVC c92ggCxPDORZTcIyn7lZXBIsAeAYNY5cjozEtQpB6O/zgRho= X-Google-Smtp-Source: AGHT+IFGW6z2+qhpPP18yxumJxky4jsPk1WbluDtVucS3hjxYl3kze5/axHu1yqLi/XJyjupWOt/WQ== X-Received: by 2002:a17:90b:17cc:b0:321:4182:2b9e with SMTP id 98e67ed59e1d1-32327ab2df2mr4999422a91.12.1755176320026; Thu, 14 Aug 2025 05:58:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 12/85] target/arm: Implement FEAT_ATS1A Date: Thu, 14 Aug 2025 22:56:39 +1000 Message-ID: <20250814125752.164107-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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: 1755176404821124100 Content-Type: text/plain; charset="utf-8" Implement FEAT_ATS1A and enable for -cpu max. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176625; cv=none; d=zohomail.com; s=zohoarc; b=aCdbt9fdHTNB/EllPJi6fiuLsuFEQstv3HFvuYhicKzkm0/HWfbzrAAQYwzd6aH4MYSf4+sX9CPj8+n4k7uM/NOyjLbKV4h+i9GMtAc1FSYZcNQnIjHH+sO3ZYOXM0F8hr5QdHY9N7M9JWouMVWde2CeBOgBFWet4WTpoFq/Kxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176625; 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=LNsjNaNauh3UMxl7JuNDgumnWToR3i7gwLHW3FndbslYNi6r5z5JXcw2QsBsukedZAVShEisEf9YHFLwP3nOsRPKJQ/CyobwG2F7kPghWnYOu6YlbAWzGypStluAUSboZWW9KZKZbqbddxiTDnq2KA89T18OuMNOkQKk6OrxLgw= 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 1755176625217477.5273291487845; Thu, 14 Aug 2025 06:03:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXo-0001XL-QX; Thu, 14 Aug 2025 08:59: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 1umXXj-0001Un-ME for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:55 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXa-0004G0-0m for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:53 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-24458298aedso8005825ad.3 for ; Thu, 14 Aug 2025 05:58:45 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176323; x=1755781123; 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=m42BEU381FgNZ4SozdJtRDmgR3/KIjESREHcYSJtZE86Xg2BNC5yBSRoPUYvqTYFxn TCZFun8uv9x2xKJQvnWiu/OJCh8ua0RouiLxRcvY5p3mQGe4RB9IEBOBtPUkxWHBP3MD 1FKRJ/jszg/TAnIYrvcJp4LW9fW7iVjZdw/RtHkpLm4ACUP7+rjtlmjwIyC2BFNcmjis X1p3TpZVj1xtiraqeggvxRxNR6+ewi4Czm+PFYJ34zgbJ/YaszDGUQWZ6OOcYcWoqsLX 4gf19p/PRytdsMmOTBK0KtFh6ePQDr0lfcpAYetFkdl8wPvIxGO7S+ceMRDjqt/xZdVz 25bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176323; x=1755781123; 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=l8ecxUHoaxLAMyZV95LwkcRwTe/mWfiC767feFhfKU4L60DIb1KzV/e77Mbf5Ifa+C WkTmsUWIyymotjND5rIB7JSGPuDtBG9RM6u/gWuvUFpErWJFa+NpyMuMFXP6shiFFU77 v0v5LGwecdCWTdZ3yKy2vftdxFjMOqgxQI2aYiotjYqhsVp0iGD93cAr9QeT6erqg0Es iVGvzZPdkhZ0s8yx0WFdy50pZBT+VZU0UEVR7914eTGTt/MyxASjh3ueDncufnqYJlXp q5iahQag03uefQhIM6qyYu83aln1OdVd3oSMlXZ87jqljhKMKf7oxI79jWs9BV5LqZeG tCTg== X-Gm-Message-State: AOJu0YxfVZ7FQNjDbXh+usDTBtg3DNbcLCoKQNxNo0HJ91+y7EVv8OHi WQQHH6kKf8W2HCjq5jqdsbhC/AF/fpMltf9OWdye0O047wlUf8pQpVImMfoGm8f6DYku7UNyF2V KeTs9++E= X-Gm-Gg: ASbGnctrkJOHQL6PkhMFZSGmtT0fbFELx4+Ioww6lGgEgD+vbpmHkW+kbKEmTjrAGwB yyi37rQXm6M2/pLc12JvrSSzSPn4YV5ztYoCTvfmlXXd13bMXQnwRDdx+oNJ1Yep3KI1fxrRcWM N0YTiCD3Q7kSyFxyooP9fNRY1rYkfzFGUmjEHTTAXaMZOP8wuUgt2EJQqdrKVR9GAlc74Sg6M8z rOka+AvKeFg781Q+k6+ukKg2j0Zr5zscj8YhMmEsK/9sUuw+X9GU43FEEjb7SptSBpe/kGIJ4T2 YfbCMucf6IR3wkgOcyq9JcLTyaTMfb7KkwAOZUG9BDa1FLaAMR7Mlcp3KJHFb17ERc8GB41QwdN bUguWsayRE227ljKyLsqpQPpqDPHRws5E6pBdX5WdszCr9kE= X-Google-Smtp-Source: AGHT+IGj5yB0d1ShlTVoJsVLT8+9MrMZWzhgwawR9hoaK8Sv+u2CEFTzBYu8//3+dJCYYs5abF9VDg== X-Received: by 2002:a17:902:e790:b0:240:9dd8:2194 with SMTP id d9443c01a7336-244584f4d84mr42849855ad.22.1755176323204; Thu, 14 Aug 2025 05:58:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 13/85] target/arm: Add isar feature test for FEAT_S1PIE, FEAT_S2PIE Date: Thu, 14 Aug 2025 22:56:40 +1000 Message-ID: <20250814125752.164107-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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, T_SPF_TEMPERROR=0.01 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: 1755176626809116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176653; cv=none; d=zohomail.com; s=zohoarc; b=UDREiKZuP/w/wN4pPy/rfgxWuN7VjMwelT0+6uAebanlUpSVwTWJa5L1Wf0Mjs8fj0UTGIEGndzo4eNlYgJvcuLDQBqnhfb4Sn6r0RJuwDc6j3e2E0kbT7GnHcc3eu4ocHL21i6h4VnunUKRvqNjRUdAfn8OJ9YMzKg2tVQSKdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176653; 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=U23ZZpsy7oER7++FUVm/qaqZZqCEBvSbLoTukwz6bX01C+4pR1mVxt3ut8AHnf6DbauTQT3IPY+r67P6aIjkw/RN4rt3hrNF0kqPFeeRZFl/aXyIgnS+mProD5oLNIRD0q7RHM3d1KkuXj8WOkJPPcyG2MJ4QNHsNvRChp4iQ9s= 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 1755176653513870.0383797067274; Thu, 14 Aug 2025 06:04:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXo-0001Wz-Pl; Thu, 14 Aug 2025 08:59: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 1umXXj-0001Uo-ME for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:55 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXd-0004Ga-NJ for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:58:53 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-24457f53d2eso9804605ad.0 for ; Thu, 14 Aug 2025 05:58:47 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176326; x=1755781126; 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=x0lHaTzt6TZBSikpARdGQT8ac7FUiTgLOPWVeWRkQ7J8ACpt1eYWUpeLnZXxyGD9Hr kPHq733EWgW9ZnVCZSl93RCF7o9/zuw6/Q0m5jzwZzRWlB3kLsHPU9Ik2fR9cgKVnr74 rbhXdGpQO8mHJqblHf1y81hW5maDKSLfteXO8PzOjHEY3v3y66PddyX0TR+KJv9osg0e 1RJ0c3fo3qTG+8QMFnKFIvWNIcTeTN+oKT7IQujlX1SOMLla8QGybG/V0X+49z/fHir/ RUdLJjyIGknmAShip2IzYcq2TDiiTBh9cK+w937yuSiSeSRqL1txz1wvOn/zZBUXI+PN 7Gew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176326; x=1755781126; 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=XL7nPHQqjP5KXpnsvjdqL+q75WaK+9bUcsPihmfSVHVUwVjvTb0XK60L3I/x1BTPjQ 8H61YR5/D11Cko49TKMiNvBhMlenIxyvc2nYTSTtVNHnNO1wmHpiEew1lZwFTrhd4lbw Z9tyTRaCoNqbM47Z/UEtoM7qfJ2JR+utGYOdeSLsbf9gZHoXXL124IggQqHM26HpyVys 7sRiTdP6QqVIYAoQq1l5YUjjvSZ+5BMpkydyWeR9fEfBI65ML71/AHu9vmX73snSR0Gx dkm28pMFSeV7zipAqWNIDOaLsDIUYLHXAap+gg37ZdTcPpqIn68pnyfEgyCQf0SBWCT1 1LTg== X-Gm-Message-State: AOJu0Yw9siLTnOgl9E3w0GqqL9SHdERtEmtPP/sCKUEgSUNgT2ZW9ujP lHXXYddEkvPnBuTU1tayUAnc6jdgCE6SQf2zk/37A0tq9Fybjh8DuLLkWvnTwtp1+EgbOcaLP+1 dt1/P3fQ= X-Gm-Gg: ASbGnculw1pnoKTnWehsNggrh+MzMO7gnHuvjh17jMk7+VPFIm8k74uIicwAHTi1ALs ee+iRFnJerqEHOex4m+3UmB9xCBzpeqkXizaUcx5xTpVqbQD3bPmi9PiZb1JIycMXifw4VhTt8W vmEnYYogpByxr7JNuXJXC6uyZt5/kkUoCj5Hq+C4LcK6fUd6PWRJAbLvoqIbYhxYnoDMiYAW4n4 XY5szel/UJ6DzIKiD5kMtCT5Cd1SyNmRQZH0OP4sFvb0uJJwc7TRgjISi7QbiYlSE9TNi3ecXxc 1YJSH2ZQEb5Hsc7H+01g7O3JjWpoQlPJT1ovHbOCanz05E3aiqNUXFXkOAxvxc0WmL2UxSFkxIW SYkzZzJlD9TMqGXMn5bzgfrViZ2i/vAv9oVcdvmjatPAwR00= X-Google-Smtp-Source: AGHT+IHMMM9NEorIRv+IGI1ALhTbjr3AfaKaZt/UFSpCJYushYCGd2T7IrT0USdKYOoehAskaxosDQ== X-Received: by 2002:a17:902:d509:b0:240:7c39:9e25 with SMTP id d9443c01a7336-244586c4d96mr38699325ad.27.1755176326196; Thu, 14 Aug 2025 05:58:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 14/85] target/arm: Enable TCR2_ELx.PIE Date: Thu, 14 Aug 2025 22:56:41 +1000 Message-ID: <20250814125752.164107-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: 1755176656260116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176881; cv=none; d=zohomail.com; s=zohoarc; b=WGjhQ8BQuO96loD3js8wVhTFWBfwIlctmtmKsDFAUv90W0+WuCGdj5WH4k7o0YyIiP5kgiC3Lc6JWw6OMOJSGM+bek17atV2YcRr1EBJuFCE096IpbE8X3eR/40LkVWEqDRPcSO8hsofdYli2ca4Ewtjbu3SGs70gY47LTiqAhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176881; 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=Es+PsUjUyWbMbpt98mH8mnPy6VmggJoJn2iqcF+vswywrXtH81vQGACjcAtbYjMq2QErkfGJn09kadH/agMuFW/TDGvqZEgqdzhT3ovUs6+qs5CbfgNhd84BmMxYlXb2Xb9+epM7uRquYsSvhMfoDkP+Pq7VSvxNt9GB+r0+GCY= 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 1755176881325327.0241250819889; Thu, 14 Aug 2025 06:08:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXXu-0001Yu-LL; Thu, 14 Aug 2025 08:59: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 1umXXp-0001Xm-Ne for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:01 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXj-0004Gt-Bn for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:01 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-32326e09f58so1121892a91.2 for ; Thu, 14 Aug 2025 05:58:51 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176329; x=1755781129; 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=S+RWeGqKCn3pfJaj/sIAya6Os7/7YbeGuMRp4sV1f9Blkvt+ULfv1D9B/6jnk/dGBZ P5tQmoEEwlgN3rGENZpw2Zy4z2Yht5Sks4S97dLxn70cNfKEZRRCeyT/PXBp7fy+arDw 2KOdMGdsA5eijFhRw3oLAXdbSm+xc5CTh4/phywpu96P0iuSOSK3I5J06i71Ao6qOnN6 s4uP3bfTCXQWRXsI8+ZG1JqGUmsZIUUnZOP9Xj0Cb3C5gyDhE4iN2DkwONuwnWn5h+45 /ayxO+H0H+tEbTLQhetdzPRydBPgIYUSMxu3cx80fMO6XSE+RGA3Q+FFELJl9AIYPaS6 PJCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176329; x=1755781129; 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=KKvkeIo3vgBoDZaGSt6VKj4MO1mAn/Cny3SbLx2zNKHN6OyStNLxJYrfAkIubID9dX uNBDejgTGkwivWMz9eARXh8z8plqh0HcP1Yi7pev80GQEnq+OOUOJRw8wxVX7g1+AKYj o3HRh5OaMbOZHvXjqeD6WjijVUMQp9BXN3pAfBNTXuFAtIYDCq9bi3Xy9qzOW4P7ZqMC Pfx48qqIZGAkBanlMg6Nq/bjNFsJtMHJSm21vEiJYDbDRtYSpCPhVWr7pZQIp4xjsa3i 4hKk/oPoQkewI0UyrAS/05KcLRwEjI6dOHvun3p2ZTvjuO94JYBsMOGWVmQO1WsAXb/y 3RRQ== X-Gm-Message-State: AOJu0YxokLucyzMpqZ0rQVRhIrqtR+vXx0XtEnJULHkF2qtGv4jpA1ub 3N2q0q8dAePD41ch//RZWxZpZ2/jl36Bgu5J/W9Ubi45KRD6U8Z4yu/MqsQuZL0C3U7ni3GpEB0 li2PgzQs= X-Gm-Gg: ASbGncueQ/dW5Qsr+Y6L06eGa98C4DQCWN/kCezgcmpizdGa/eqdN7sQhBFw2ExEpT5 JciD/v5Up4bahKp+gjmR4h4VZKSMUKIMr13qPfrbIgicjaLS0ycCUUsSXlhfjwBdO3SnzB/lHX5 H7SViFGK6pb4mZzjg2JaL5AcDa1LOik29UztkXgbh4PqHaWwd2+NDTLkCsDkF0JCDrRyrtTfc/U ptcCrC7erYPAJnCCSC59E5tw+cDLG+ggfQ5iKNHqgp6anc1mlvyGKeKgZZT4rQedNVYjCDqV4Ng P7jam5SNqOkcB86J+oTu5iSF0bnN+8bPCZERJXg6MzJsjdSTU1WwOnVMOzyNUk26jNtwcuBJ7x2 jM8rYuFeOtiCTyZXkZlDoHjQmn3SzOzHIRH0WRwijXIAaQ+s= X-Google-Smtp-Source: AGHT+IF7ixE7gr+nynLlPYG7ZbMSXM8AQtGolV790Hz3ZjrRZFKFUo5Mg7BJTTjNTdjIoso3HCB0ng== X-Received: by 2002:a17:90b:264b:b0:321:1682:2d49 with SMTP id 98e67ed59e1d1-32327cc148dmr4016860a91.32.1755176329156; Thu, 14 Aug 2025 05:58:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 15/85] target/arm: Implement PIR_ELx, PIRE0_ELx, S2PIR_EL2 registers Date: Thu, 14 Aug 2025 22:56:42 +1000 Message-ID: <20250814125752.164107-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: 1755176881695116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176765; cv=none; d=zohomail.com; s=zohoarc; b=HmgeDNrqJAZo/vIU3HzS3aV0sDmsoucNwdbDrss3Q7FIz+81evlLkLDvASOQM40JlmwSxDqF5mo6MoTSAOaBUgg9tnFlnIpAas0bSutJ5TddUPoLwUIjryyhT0NWT9yrIVGcUp6ltvASPp6tWcSxVM5m9L55zLf/RJo+qQzqy2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176765; 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=K5fAePCkqVpk7WlMuVg8d7XLAjETU4H2gn1AkotesuByH6lsXuBPDFiYGWq+TZMSiRi3EZ78wAvbcNH6WWfC8hoBMOaEV+U7eMEE3lx+VggTMBm+MftUGRzoJ168oM8HJASNcneHPIXxqeqNXfb8vpGWzZGClLX9FqCZjoLE0VA= 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 1755176765751824.225825323958; Thu, 14 Aug 2025 06:06:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXY5-0001iY-1t; Thu, 14 Aug 2025 08:59: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 1umXXr-0001Yi-IK for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:04 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXl-0004HO-MF for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:03 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-b47174c8e45so718430a12.2 for ; Thu, 14 Aug 2025 05:58:54 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176332; x=1755781132; 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=yY9CW6hw2aZO8AtL96t4zM1RHKaFCfnm53NR9LjO/CFfD8bWZTKHf7uR0sszWbRQKW 8SrREVRo2fx5cjZT6nsunxAsvckf75OJnlFEDXJEwz7N5uMfsYQ7P7u79xVJnsoMceuy oc2ex7B/XTzU+Zut7mfOss5ryjZaxcU+0llnN9tuYA/W6bBj+hz7uvk1O5JemNXAzdFt Y1GrNTPYw2NIT35qYOVlpU9xYxX2WbcHQnYwEEwDupVumPqYwOu6sblTei8FemGfaS4G CmFQ+/gGXhnm8407TrJi/ToT9v1uvnhZ2GBIW0plqi7GmkbfsV/gxh3f7HqCWLNdrb2f H/DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176332; x=1755781132; 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=a1HVIuCU2bwkr4tz71ItohEBkR+jqF4AgPiUBEV3VIhJ60on0VYorkq4F3DYnXH8yW nBdVFTPomDU7mIXeyD3Al2TpAtIwwWzot0rl/B7Sh152jq+yxw7ci1tC8GHSoUxFguRV W8yxJRYgnVpwzUgnCpBftrHzbYmWR2/2R6nFyN1497bL8HNdOWi1bP+06VunbGTw05sr GRASuzr/kydxvgO40o/8DXWfshOMVC1eZOE9JW6I8Y0skYZRk9w04QW/Z+gnfA9tuNB8 FI1/1TbdZhmrp9qyhOasDZjqbJiTrq+4IkKyUghwYkpOxJXHqRgxsPYtqBMBeu/LhDjF eFSw== X-Gm-Message-State: AOJu0YxcrMPAgOzw0cNTm4sQxIRYEswH2t393WsOk7uGvQx54+6gWQpe pZvXeuPsY2LJZMqvIP9Z3uvKmPv/VijfDBkP6iCFxX4hni8oKnmTskxOJn10aNIlDbKqh+r3FoP shNk0Ocg= X-Gm-Gg: ASbGncu12DIUJUeJf7UBXiqLiWjJpwGsJ0fUeqNXXTuV8vPh9pwj1A4+RzjXVPSQCq0 mtJXL/s2Sr3Py3Wneqqk9lsqKpZhMDUsq4elfMIQxAYGMD4fmEfJhHI9INtdLmXbc5Qu/PpXAbm CexhdRTwDsEBu9eWx59q+Fx4uuyPcb/3QAGK7sohxwktb/KxjHFEpPYCWIaV//qDoVyyV7g1YCZ A0AkVBkO+sRv4E2X0R+n34vim2P+OlwavLdQ/zScHiXAcv8MCukrdGb48q+nLJNOBtCbosyV1dN iVSuwLn4vDAh87tkaGsA54+hmGcmOlcHnLvu+kdBmb0P2X9GC4ubN5sdL4tR4GOk4SahyMeh+Sd XKCfFVg3HtZyowMRCS1LbehYe5BykNx9fkUOZH/Ixnd5CrGw= X-Google-Smtp-Source: AGHT+IGM+/VwnTutCdMcVaUZ8A4cwwtf8eMGEIrC3kgkgNCekm1yt3ayWa3zifnR/wlHeeuA1R6t1A== X-Received: by 2002:a17:903:40d1:b0:240:2a0:c449 with SMTP id d9443c01a7336-244584ed083mr43883645ad.8.1755176332006; Thu, 14 Aug 2025 05:58:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 16/85] target/arm: Force HPD for stage2 translations Date: Thu, 14 Aug 2025 22:56:43 +1000 Message-ID: <20250814125752.164107-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: 1755176768633124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176404; cv=none; d=zohomail.com; s=zohoarc; b=Ts162a87AovnGvmMKABURXC8M7fzuN7GXB/FixrQi4EcCN76d2Y6En+N/MElpHNYlIXCDBk52r+cf/P/DVoeKoYpXnpzo2pqJ9RVdhVY9/SrPw3VODFspfn9utr8VUhsuIZ8YuwfqZOIycQA40l1/381eErLesIFzflfIMJYoig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176404; 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=Y2gr+2qkh9rO66/859uh69f+f7TY3i+oCFz4rwBpVx4J3gzPxABULl51tEcY/nqDNOFy+j94ek+hehA9my2//A53CGg3L76z+/n9J/wCftzNPeuQ2xz7sRQUJF+4xAb0P/qr1fOGJZY5TEkb7nyrvWxZB0r8zzTnOFBJ2TwO1fI= 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 1755176404296953.5060791772866; Thu, 14 Aug 2025 06: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 1umXXw-0001aa-Ib; Thu, 14 Aug 2025 08:59: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 1umXXq-0001Yb-Rr for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:03 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXo-0004I5-2J for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:02 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2445818eb6eso6365415ad.2 for ; Thu, 14 Aug 2025 05:58:58 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176336; x=1755781136; 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=Uftm2kTVMo19R7eQg3KDzpGt3M55Pf1h77SHXIBFqUuk73OTdbsXSquN1cqbmQuFVQ uKPTIos9gx9K0T5AX5l/4M1GitursXessLFpJKj/b7zGwBht+wu07aWhQvWtJtLbIaYU ay8IhDMUzBuvNVWH4GLl9iGk1t/yBhrHe2YfSsAi1LOfQbmcbu/ASD11WRAXj30bIhQO z4eJXlH4xShiwjW+/kP+jT1zB54kjsBFHfLhXOazHnEFOawCJj0DIVsrHXqn22/zkzrE U5maoULqtg7L+YC1blY7E5OsJeoWAETOd7ZY1M6ilNfkd8GRtLvS1S1EBvFKVb2c2Rol 3PVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176336; x=1755781136; 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=XhnO0C38bYQaLDW8wg1LfGTBtgq75hNRwL7/T/xDAG8NMc80+MYvs49wWAr0KFZ8SX mtPItBO0o0G67iyExe8hjAXIILfxoewIcJcmJXWMo82SIrAYvdBU6/ljMSuR00ZvkPDk DKu4gNJPhr10qqdpSw5FnX1YaOKnOKYHmwp4vlL27h+qSqJ8PCFEogtJPGRLfHd4Ianq xmuUFmSGUOhAzgC+IBOal5DG0tqdYHcQEUqK7GdKFX8W9Wr9R4I0zw2nYbchdNukygpt wzaPhivLFuMWutFDQx1ya89psYMsr6aj9Ru/AAAs8w/zujuMyD9+TlFsOXpf8RpNzyOm XSBQ== X-Gm-Message-State: AOJu0YwH7n4OXeTsAsr9TA6/5mhLJGHQSkQQxEhBG2B4BZARKQF68Dd2 jBv0YAXEtwbl8G6U2RD0vWsaTZLFfUcoXyzYdsu1NxJHPOq1Ak8xE8xmF3ThpeHqH1p56viAQ/H lqQv/ECs= X-Gm-Gg: ASbGncuacpZmUqF6EbnO28Uve+l0iKNjqaCaJwSjMsEDk4TS7tWIugzmVBf1+WJrbZp PDPd+PyrtXSGUNHlDdwvwteu8n1uqNvCOnHKyth8vOXiCKVCm6+LPvrpL1rXTUX5XSZ9NZ1VmkD UaW6EKjpWoOuf7WTzpRZNMvnyDfKvNNX8dBJcmLTwBPYwfgAUVvFhbjPavekh6jboX1oxLMDYZV FJv3b8EbZUJSg0FFZZcThgNPh52+BaiRqy1mEwofBq67HNM1M02EAp6unL4vyDkIj9z4AqNEkNZ yLzhxG5xMCxSErSoFvmejP5xLh7Y4mOgSw9nI+fiDNlFYivwaRnx9hfFw4qmX1x6KuQF2Ou//ns ZUVoglPB0Y9+/qxj0ROm+Cq5T2gKeNhqERZ5B4mcnhwmB3zM= X-Google-Smtp-Source: AGHT+IHnamsCCV0tsjR9bpb7rjKBGfm/yptYw6KeVHE0W3ybUYieVbp1FphFsMyRFNCw5qhagGwBWg== X-Received: by 2002:a17:902:f548:b0:23f:f983:5ca1 with SMTP id d9443c01a7336-244584af3f9mr46825365ad.12.1755176335800; Thu, 14 Aug 2025 05:58:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 17/85] target/arm: Cache NV1 early in get_phys_addr_lpae Date: Thu, 14 Aug 2025 22:56:44 +1000 Message-ID: <20250814125752.164107-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: 1755176406344116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177435; cv=none; d=zohomail.com; s=zohoarc; b=WHcO4BxMTN6PSvF3dypXtZnu3Vuh09DnuqzTghkB2/BobMofHQI0ep9YfQlMK6S9QKG6PKklz26mYE61D4QPPjDMW+SP2Fd+zZfwB/L81axFLHqZU7iqx6oTgmWlym7NvUVp2odX8Gy+a5p3e/EYKQ3cl498BGWZiRnOY4R4bpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177435; 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=ikGsSlZrgkAx1CC+Npm+qhqOXPcYBCaNpvVKkdoEooebgAgXQdY+aHKX6wc9wPk86BzVTAZGNcbP85W5Rhuc+xiECrh6/F+XloX8xyxR1gxmC3l8D6f2QK1DqNHAY+UgQY1I2fzCyGDxVD/5c9jMqLGTUiOw9ZQHLWHqby9UdmI= 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 1755177435598460.5001377827376; Thu, 14 Aug 2025 06:17:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXY2-0001dG-W6; Thu, 14 Aug 2025 08:59:17 -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 1umXXt-0001a6-OX for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:06 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXr-0004Ie-5u for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:05 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-24456f3f669so9876725ad.1 for ; Thu, 14 Aug 2025 05:59:00 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176339; x=1755781139; 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=vHDy5ow/CC+HMQjhna1u4+gZgzwxnZs6a4Yoz1tqP+qleVduYkxL3H5sG/6pHdvJtQ pU/Tm2sfxBGvav7sybGgaP+kVNKu279KbZLjaZBzgCD3eMhEZqEB1xYvxWvXjngidvZb GvyWWYFGXVMwbaLtXefh4CisMosXkrt+v0NJxDgJliNcCdwe7nkZRjbaLVHEakGNi9kr DolY9oMJSrKIiDfG5LmfIHmM4QRAwYwGlfXT54QOc2oRmndLFJIosrhDQXO9ZJvDyeqv cEyNiOuO+Y8mw+NyZywmBnVQ8mfCSqSu1p5SAI8NLi3O9GlxR2ev1NGLQivP/EkT760l k1UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176339; x=1755781139; 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=E7UUSiDZ9R5g853OlaC7edLU9bmhJJFC21GsFAdbLm2mDE+7ynRAeJYOVqBYkarNTv x+pi4cA8Yq7pSNJ/U/ge9LtiyFoAluukR21SFYXaFWxqqpnKC6hor50q3Q5xLMa0IQHV N8J+pDW62UuoKEkQJZz3U6wWMoPV6sLb/JStEb4PCWVysVDfR2YRkpgxGRm1VUAFWKQS T1W1vpDUpsioHUZBQSvFM+aOG8cVN1ZPu3hkZeXrgYlMiCAEZUQrp+0XsYK8vpEPYb6Y 5Oy/XOohJ8l3RLpkulRcYxCXTyd0L5fmwOXtVxdjAAd7C64PXYMaTNfpFg36qCqUMZIm 075A== X-Gm-Message-State: AOJu0YyBillMbxhIAJTZIaOBp+Fkd3bDvIy1489Jo6tEYdnihQDo5oFn BEOhePYFj8uL6KF4A6SfzakTCY/BKCGo9oGfsh/FyzOaU1vxjfRRPMH818p9BEahvYAu3+YDvBD 6GRWfxq8= X-Gm-Gg: ASbGnct9bhp3R58SAWz5/0kZPIeY4M/9g+Cy0mNez+C5ciH0TubFH6mWaKT+n+Hx3KI xXkejlwNfsckorH5HPSz9sYOi7c3mtv+9/KFB5hETGoK5cV0ykg5XBQB7hQMYxF6WFWeTp6KcLO Wg7MBCbtih3QBZnHDuR5clrd1yynrBdqNR36iK5GzLn3dN6fFGK9RAsHqYm8jIjPG4JR5vfMjci d0qqi2tfhmd76Zkw7dj76u3wWC+E9ee14t3LlsLfXo7P9dP6Y05GEH3wWR1QNgg4ckwdtphisy7 TY1DoZ2vcE9mZpeXTt+v/t9hUJI4+/+gzNwnSC3EtZ+ZkwGw91sJdMuJkIHvu5z/duUir+1GXGf Tkr6WC3GlbWn+r3U+ZBtvHPXpveqejAjQof5BL7PrIJTGG7I= X-Google-Smtp-Source: AGHT+IH/+tUVIaRxwAwWnYd269nYTRMP6TwFO0dpa4n+F/O0bDEX9Cg2IYQRZU0PJ/WQXdwEnqeaEA== X-Received: by 2002:a17:902:ecd2:b0:23f:fa47:f933 with SMTP id d9443c01a7336-244594c7a4amr40027455ad.8.1755176339131; Thu, 14 Aug 2025 05:58:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 18/85] target/arm: Populate PIE in aa64_va_parameters Date: Thu, 14 Aug 2025 22:56:45 +1000 Message-ID: <20250814125752.164107-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: 1755177437964124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176878; cv=none; d=zohomail.com; s=zohoarc; b=fuA8lkT+WyKhns7o81Bac4damCoQVoTHyzxMq0nG+PqDZqBnHqxELZUV99IdcvYo4u/+YGNZUtK4qprx9s9+u5ihwZH5gO/di017J0VWGVb1qbaahEAhP8fXAChEsTTbtMzCpnOE9pzaV2Zpdx0Hh8HR6MkKZE9hqrdGE4MAt/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176878; 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=XovyEQZXkad3Bwek6SQOb9Jixm1vZRYmExSxf9qZQ1qpyvypMn6kcb6+k66EKS8tTs83KD7ubjh0AvWkVWc9XinxnuFKRbkvxEosBTpCoZ7eT1lS8YEU+Zun9Sxi5uF9XdAkR5mipLcpUVyltt/k4HgBCbdB2aRb8cOoMeTGjjI= 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 1755176878899222.4643656864498; Thu, 14 Aug 2025 06:07:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYV-0002CC-HT; Thu, 14 Aug 2025 08:59: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 1umXY0-0001cm-LC for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:14 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXu-0004JJ-OT for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:10 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-323267b98a4so864577a91.1 for ; Thu, 14 Aug 2025 05:59:04 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176343; x=1755781143; 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=GBheAmHT9clc6V5DO2JEdTkv6pLvjtX8hQlct51VZC7TMJGU1CzD3AKGk4INBJzvzn bE/NQvAv7YvDziPFM9ra6Wcpvl04W/Fd1WiuLGe/RGDEpxNI0NvgEjxqghwZY4M9n3Ay PHAuVxdkMeuGIwDe2zLFwEnrvLGoHcXwQlbLf6QYlXSaMhaq+5lbpccbvuficQAGtm0Z jHSzXTFMAAvf0sUAase59j8yU+cVOD2zK7U4dlqd0zIxXLzJVkZ/3dnTi2iU4UkcJ6Fw z5Iec96Tujr+1c3IJ5SgNsQeeHnRhrb+Yq6fFFxZJtVv/yEUjBBFqspQG/f1GhiCodkH j3wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176343; x=1755781143; 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=VLSYTMnslluKHCB02mxBaGtkgWEEyy1BG8MnnMtKfHgOkkpGxsHQJA9TDSqB2Lgubj Y5ZvuOABaAMBvK1maxiX/fOkYbkMq7ntxyYCXcEh7/yd4bHvsYRwbEyUhnZkU0/61/dQ YtX0uDIM9fbxLEyuvOQP2WPBIcTgZVaf+wyVsXmksv5BhqYMBlcy91XhiI0NHPCvzc4q MlaZHT/RDLnMn0UW/IYM9x0u3JZUju5825uF6nujQakxL9p5KsM/mk5l8nqBsA/TFjjn sHzYcT+8/uM8fYBIcXeNW1fKvwp1MI+qoMjLlUCWvctIxRxMlHyTWYbJMaSqO/jxXLOn QNyw== X-Gm-Message-State: AOJu0Yyi5+zzKUh4kvTzdXFjNeErhq3ok3TvjbXrGog8l2/wY/HCNPBu Oiid/J35AX54/E+TRkeacf2g8WNwh0AdNL4dFiUqzhzSFvkO/5EayrJ8i6X4sreDahG7eG3S+Kp fx7h8f+0= X-Gm-Gg: ASbGncsxPgGqGnT2+DxNKn3sbKEsrd35EL6bN6ynUhXy1FdTpmUkILn9LF/bBB0dqwd 0EtpmPJxMBqIGbTFqJj0XCxprWfRoI00BLBCJweUGuQzoaetlsP15xbg6Htxbr7jv4a76wHYnff nvRFlR6Bbqm1JZ8OHqa57LEGggLGLe0JvV+cTR0QI37EoJI2R/mwNGlEnGTb1/ZKbf91pCZ/LZf CeOOZGgCjoIwTqY5ef2w+AZJjuCOrZxbB0IWBT25f7QztdgnGNcXeU/FbPSh0X1CmQIidcMk4nu fgzIsw8c6NqjsTGCNY/pBm2v/eBeqJShq8DDHR+iLvWjT52TlR/nRx4i1ylIdj4YDGPNzGzucaG rZXYK4UbRN8EDb1oR7+c6g75b9pzbAkQT0CJitZIz1gDLlpMnSNwTzzibDQ== X-Google-Smtp-Source: AGHT+IGXAFI7M7KM7N0ERBSSfYGA+hDuJTTvR3xanknyyUSfCc0Y8TqbStSP6ChtYnFujdxKt4itxg== X-Received: by 2002:a17:90b:38ce:b0:31a:ab75:6e45 with SMTP id 98e67ed59e1d1-32327ac0f4cmr4479086a91.28.1755176342433; Thu, 14 Aug 2025 05:59:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 19/85] target/arm: Implement get_S1prot_indirect Date: Thu, 14 Aug 2025 22:56:46 +1000 Message-ID: <20250814125752.164107-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: 1755176879834116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176855; cv=none; d=zohomail.com; s=zohoarc; b=LfojZSmg2I3zmMMVc3FkAsYYvmF9P/hwj6hLZYdN/eV+vJurtit0sPnkm8xAaSUzYZvFI0zvDe+w+Bd2b6G1hSCEUfo5A5MqC1DXN0tWIqCknK6ifBb54boQMd0MaEy0OTqvQ/c31Ko0NuQggWlPBH60VKrvI667VmuHJ/m/zLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176855; 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=KJnq509Fcgt7HY1NAB/9DG3eDaMmt/XD/dHB+oOQbF092UCFwj/w2RDsJwyiu8ivFysdNexTFzJiA/8NURfa//mofj7tpy7JnmAVCba1UiL9EsC5IU/C1UExiZCaS2LdXEtq5wCJELubpiYkZ9F71E5ANyZjlhUt4PxcFfhMmRg= 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 1755176855343227.19920539431087; Thu, 14 Aug 2025 06:07:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYI-0001te-Uy; Thu, 14 Aug 2025 08:59: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 1umXY1-0001dh-1m for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:14 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXXw-0004Ju-J4 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:12 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-b4716fb320cso676007a12.0 for ; Thu, 14 Aug 2025 05:59:07 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176346; x=1755781146; 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=teFSNPv2TtzVVlfDOjkCy4X/OEMvmgAs2xvn1h9LBcQ6k++DRXBPzbUzl25JuqqXns NPURY1gO9IlojdeaXyj9xBxmcC0YEo3uO6Qo3fs1o0wDRdwP9P0zheHBTVXlmzpjMNNZ BthR2hnD/Z2vFrcpS6LUT4r13FrXNwjxz1iWMeMWi90K2i0wJRW33acTeWtWhBqgxOn4 tkhzZLISnDP23IXPQ6w2MGmvG35mPt/w8t+8n+mA52gJioai7yORuHo4i1RDdV21iFe3 n/zxhEOLD+Mcz/uxfbyBNAgWlwqNkY8FRj5nWBPA3dhZ2OGOA2X6Xq4eF7lrj1oLtXBG nPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176346; x=1755781146; 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=P4qQjJE2oYcXrJUyfxwwLkD5jdwWRD+7jjBzD8Ll/B1cO3bW0LYeV4nu9H6taG5VtV /bBvqvIrTAMlbVD+/FYKHCDHhoVxcqR+yjDuwoJLAn7vLmrNhw26AIa1azb+kM/2mv7S PinEpbrtCCF3HpGu4r9jgj6ldQZIV8xMj+kaR+BusbjL/D6fI9woFPsBNm0UyXMe0oLh sEdXtQX5V5BrXG9+rT2OWWg2W8x8X1aXdCXw+mo4CRJG5io53yXKCGpBtrCWzCCEdcpA cbVxfImraYqTO5p7a+2eZAZZgx1UrSsc9EIH+Z7I/0DBD7qtsayoEqrMzk1KsfwPQ4Fd 2jdA== X-Gm-Message-State: AOJu0YyyztbLI48f9u+md7vLEpQaYHOp9FSM2Drm0IUdVrbkHnSLMqKb IC6XlZgTdm6JcGhWwv4UXYEPMRpeZ6JTzkd4iQbL1CZvTgGFFP+T6n/voFXzvS7xk+y1G95GIdB wQlNZHjw= X-Gm-Gg: ASbGncsm5BVM4MbqRuKrFbz3ttncz7HGuXibLHc3OxCCU+YmsPr5+SmxfdpZ7MSvQyv W/EfPEBiYNY/dmfuO/DVy4DX3MaYasv9z02nqx3R54YL3BbqwIsFV+USuTTsb6aPskCaNSuUR82 2FpQtz63b4fVvcBFP07B89IQZLiQMAQLktcAsnCulTrwnQibGjLXhb7D03Ldd6oq0Rkp3xm89O6 QzpmxbZvnWxrb6FHVJPjNg0SM8oCSSwo8XiVeAMQRXJLb7InYrwsxABA2MtBfkIjm769L91BS7b r1DTmsoJgaZF5dSmXr+nHDYag6MUxvqGhCtr3Pbt0gW93gDpFLlpu4uZMfLsZp5oPDn2e0VbVRH +tn5I4hStV4o8OUgmai9L/7VWIj0QCVU6Ku1N+csZvuSNuR8= X-Google-Smtp-Source: AGHT+IFB6U9zJ7oAiygXjitTIjVCvMq/IRna1nKlVidWsbHv5RfLNBXioQ9Duc4JgRSsJNAYyf6wiQ== X-Received: by 2002:a17:903:234c:b0:240:1831:eeeb with SMTP id d9443c01a7336-244586c6c05mr44277765ad.40.1755176345533; Thu, 14 Aug 2025 05:59:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 20/85] target/arm: Implement get_S2prot_indirect Date: Thu, 14 Aug 2025 22:56:47 +1000 Message-ID: <20250814125752.164107-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: 1755176857548116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176749; cv=none; d=zohomail.com; s=zohoarc; b=FAnYCdDE3r7rFA1nQTU+sBGglX4c3p618bpWLJEfofo3NPy59z+CiSOwwFjmBDDJ3WJ/kdyX2S3q4AA3WY8ewwCx5wyoWRy0566OPX+wgFds0hYD8V3TAlnREQUYxPzpDIwTUgmwonMxNND7c6BoG1FeXyCvup2OKSck3R8G868= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176749; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PIk54x6Ar31mjPJaW9KswvmHAxIEFie35EtC6Q/lqj0=; b=NHg/DTrDAj/Cnz09bfXcopS3WIH6zTExYnV5TY3qsfLycuYFJKLieYg5HxNvMYTYqXwi4jaAVGjxnKsfK1NXlpFdHOdx+B48eYbjeVHRlFSnEABw92kZIUaApP0Jyc8MyGtKjpe9fb3NVml5uX/ut4mqZ17i4UJK6SaTGZBw7FA= 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 17551767496851019.1055201331287; Thu, 14 Aug 2025 06:05:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYX-0002Io-7D; Thu, 14 Aug 2025 08:59: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 1umXY4-0001kt-6I for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:16 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXY1-0004KL-CW for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:15 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-32326e66dbaso658941a91.3 for ; Thu, 14 Aug 2025 05:59:11 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176349; x=1755781149; 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=PIk54x6Ar31mjPJaW9KswvmHAxIEFie35EtC6Q/lqj0=; b=uYSPIyQfp8P732Biz37FbgYE2jb8rY0MjwxbWagudgW16nafQdCKpcs7fC0ZKp3J9n 4/1Bam2yGc2/gkb+5AukY6SgAVaHZlLBIciamKySXwTzSAI+ssrob9vH+luFwT6pnmBm la8/D2arYq2N3J1zIu6CPI7jtNkpfl61uAMFcdb660wuXBOcGeSR7MkaNtTgr8ix2Rcp lTBnERhC+gehV29NkxBmYEXOM8Gb8V0ro4OEIXKs5XbwEy6/KnoHQxbcPuA1L1chCUfR qfEIZXNoOP6kuHQf42sW5O6a0QYrorHgLSW9kegnoMj38z10ieZ9YXsDbE1PzgSxzb1h g84w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176349; x=1755781149; 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=PIk54x6Ar31mjPJaW9KswvmHAxIEFie35EtC6Q/lqj0=; b=xUR+YRM6QUQ8sONZgQUreyIOtkvTAdeLTpNIwNJ0zEbQlbunpHG8YxqUgtppm2kGHj 5EqMBzPzOd3TyQTXg4AnKStwHPJTd8cdVdSU/MNxh1V6bysgTw6PzY+0YCs8x3iF3hAA 14z0fXxQYSBHs7J/bfwjW/qykMhBhhCk1Ch7TU3l/Oxb2DV+SQFXzclsshdncnl5D+df dw64i0ja74PYttuRkmqhnbx1OFv48I6xOpAa0RuNun/bfZz2O2KQcrsAtyX4NsC4IIRg 2Z2DqCHMpcsG0HQ+AqdGljEF8onPUv0uUWZTMUK5CVtUnJFU/vrT31nXR1GN8g2hkq2x jrNg== X-Gm-Message-State: AOJu0YzL3YZxyL+hEzzm8p9VkAIC0WbOUPL9geEq4HPLOMNKb2zWNaST nlyO2INF1R0NQoVKlLCiHAoTfqp7QOPaYNlbd9DWDFidqH8M5L09itLjqFKIGw/+mo2C3Hdej1L 2l0QHu0k= X-Gm-Gg: ASbGncsrwmsD4FjAcWgIVy0e7ym4rdVSCVIKC0ZA5NABTOpgsqfDDL7bihqHUPF9Uw5 DjFwrxlpyJjtaEiwIgWJ5bRt64+677U6c3ZS5lBwOPXE+cRNfNjF7Pe9+u9Zuz2A6/UhKP2juBH nE+LTzIVV7vmamjJFltsZmpk8bY3F8FlBkp1gKdoTyqgC4GWPdEoDG3JuglVypnnZvoAhOVjoLr 7mNjnFS+Hfd8/dmVToHgZAm479QsJWjSSF2WpWBQWHAhXvokxMOWGArvT9yAixRO0uVzpoSjIpe d0vhTq3mnPfGNMLz1cC9+rGnakgVXkb1ufD4UQucGYqR1T50yaHUI6KSexEDKpNkVfBis6Haoi7 iZ3Ay7Na67kFM0cfLrK6yzDAZn2EqeoqUmSKx7PC1tqH/T+Y= X-Google-Smtp-Source: AGHT+IH2SrOCJcXzbfqJwesiJLb3orJdB4G6FVXiprlTyjYZ62LJwGuryXI0P0o/jCpZgCnUL/Oxtw== X-Received: by 2002:a17:90b:2882:b0:321:c9e7:d9ef with SMTP id 98e67ed59e1d1-32327a3e51cmr5119106a91.21.1755176349165; Thu, 14 Aug 2025 05:59:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 21/85] target/arm: Do not migrate env->exception Date: Thu, 14 Aug 2025 22:56:48 +1000 Message-ID: <20250814125752.164107-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: 1755176752381124100 These are not architectural state, only placeholders between identifying the exception and delivering it. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177815; cv=none; d=zohomail.com; s=zohoarc; b=DHiVvva6DVSIuRolFQvuXCNrLHAGYaFbAxAtK/b68laoyCzEv79DpuiYk/JOM00WN2GdG4u6TqtmMMidT2H/MKBJ5rMENPSTWy2flGostBLcnOX7rrGZ9/XwcmIurdjB1WALATuqjugbuGfGu7qwMRigp2jeRRslCwn1uwoQzOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177815; 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=bx7jo2acX9bHwXJcqkc+nbRcr3bo/wn5VAKq457l9YjHYBCrPxbl2Ro7wkrgP9wrlWCRxFFYCIufx9X4JNYfYTIOmY65hIpLMuLiSM1/Z12LiRM52oLjnYwdnOsx3DAC81USDbPldkfrZH6G7XM8hCeq9BQTeb50qAPxtFkREAQ= 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 1755177815462796.0187241090756; Thu, 14 Aug 2025 06:23:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYa-0002QV-12; Thu, 14 Aug 2025 08:59: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 1umXYA-0001tH-4O for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:24 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXY3-0004Kx-2D for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:21 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-323266baa22so793910a91.0 for ; Thu, 14 Aug 2025 05:59:13 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176352; x=1755781152; 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=nncKknFeoKGtKUk/uqhRJ4h0wnXToyjQs3NkF4qJRGD5vX2FITHUC5rnK1O0NTR/Il q+0dNnWQC39bZj3xin+SK4MpnEPZkLGVz+AU+/6xf483SEwCX8QYnvuEwxfS3jrOHwMf Odf0IeMJ/MvLTaIYC6QLZzSZxhb2nIxOMF9GhuPqY3yAVqWW7vDYCcYRbIytXNOXo4IX GmpZsHFjPANh+lDMSTHoygXQnRFgx8ha3xHekZBoouI5AcAO9EfksVldYciXefuzu7mQ boxBStOJ3p274WrEayliHeCWF8cyT07dLvX2vr8gCbPvIDscwqRDj2Qxgy0ouXrr337Z HdNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176352; x=1755781152; 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=bRPmchmmiHFRH5/DTPvBp6477BAyJVv3EEjUODF9G+yZACx/MEuTgWgCLheNmn1rOf ErORKzgEvnTUfyNS36DwLj6g7ntBoOj8yTqpi1gLeJ8zNfGegkBBPch8N0nFmzRwM6Q5 3YAjTpb+jafBB/WLILbhc/JDYv8wXulp/lf50G+vc34F6bxCFv7+MYX6BtNc7IO1eq9m FYdnnWQ9zR7Ke8UIHOAzmL9f4Ekc2oZNcOmbWHSZ7UfoNApBRmxC/s96yeARzM6hidVf XrsKl0UZKQuiaHnniuHIZuRokSFuRAqUr0kOA4DkulN6CpNux1cwdBhXDwK9ZM8Cc8Vm pNhQ== X-Gm-Message-State: AOJu0YyabeOOsAYDILG/mZDqnNRG8+dVvtwHJtTM0QpMO0QWgk63RS7J DZdQWdREo6yjVIqIwqDkdp1DGDazgA9uP8AkkFwDIbOme9EjiSTRj1xC8fuQpv0nJAtrCvFeVDO chr6kBTw= X-Gm-Gg: ASbGncsPH8CrMsjf9S9i8cxpCxgmTnQFTMwZYoaEm/IdSQmNJXF8k6N877g0GlQkA98 3+jM+b0hNpsjfzSH+1G8ryQTyn2s0uEJ2NN1i5+H2Id+OPYaNFE9w4PIabKTxImox904j54tYFB O9DkaFGwnMYEjmKCEoCYzFmDCyAgyKLVlxBbU9szxiJ600AdawVf8ugmmi20VpUen8M206eYTKS GFkhRWyrolzI3jGe9+jU/n0z8uPsCSYr+Vg8OPLqXRcoQicUVEBpxaVlhIoFQpsunvY9pn/COxr iZTje5inZB4GuTUpKpymw1Jiv7Kp1WOLVqsz9P/0R+yrw+BdRC+s0pCm602RGMhAVr5gqXCZWq3 /oQs8u0ZKrM6YaLN8BzVcySBSxxf0Q11lojcmDqW/CrcAGyQ= X-Google-Smtp-Source: AGHT+IE16wTyEHV4JHno6gXkn6uhGWf7om6i/p+FiFSpzgamHVtEGX9G807pNxxqiOacP8NPU84E9Q== X-Received: by 2002:a17:90b:3f85:b0:31e:9cdb:32df with SMTP id 98e67ed59e1d1-32327ab3dfdmr5237021a91.10.1755176352072; Thu, 14 Aug 2025 05:59:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 22/85] target/arm: Expand CPUARMState.exception.syndrome to 64 bits Date: Thu, 14 Aug 2025 22:56:49 +1000 Message-ID: <20250814125752.164107-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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: 1755177817659116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177225; cv=none; d=zohomail.com; s=zohoarc; b=QH/tzj4Q/JLpqpb1hilk0HeQzGvEMB7zgC44+nwQdRWk7OT47+Pl1pOcydF8E5uUkGxFK+QSeB/f3O1HFXqQjYgomaDxshpMlGxpQOMBMy4O6GO7qT6LDQgUKsxuvME8AkRHKpZqdZiHZDjuicwRRtYpeO7gfSgwc1YjW7xKRec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177225; 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=BBu9uOpWJQsz6qooQ0Cvdfupw9DDBlHFpRoi1VxIEjgN0dlaRQjSUpCF5OPVBRb/YIU4fHMsyLvUBnSI3lzPMgEUlisZrJ9j1VRutFJrQELA4EGodPeDH24wH1NhMIVdsP82hs5ANIcfyf1tgt3zIsrKO8XS3qU5O+iSB5CYpA8= 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 1755177224980593.2114655036515; Thu, 14 Aug 2025 06:13:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYg-0002af-FD; Thu, 14 Aug 2025 08:59: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 1umXYH-0001zP-V2 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:32 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYA-0004LY-Tn for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:29 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-32326e5f0bfso874680a91.3 for ; Thu, 14 Aug 2025 05:59:19 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176355; x=1755781155; 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=yW5a5+dGpsslyK88x6O45q9JKjThEdF0XzbvKYEI95HyMb/er4lPlHmpWDRKX7Y/aC s7GBZkdZdYMBwixx52Gu0zyGjIUv5xpffdmkxfbNurL4lJIUc44TgjJI7OeeicOajwfz oD99Gu1nCfSgCovS9J3Rm9BJhp58cijSftuLm9ezW82TqivmbUmq9xqZ1LHEjX6rfmMM yI7LMpsXgDAUDl0VK7i2N99nefgFOooNc0mp/AU6Si2pRZ5yHKSm4k8e30pmCPb2vX3t XY7explZJbkev4T3ZanNRyXtxZ/SdfkRdjXz4MNDvR6GJI7DsA1C5XaXGtzg4bbJCAsC r1/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176355; x=1755781155; 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=b0aEMgsIqWfEKgVtAwCo6mQZcoayizjT1Ha2cHda4uAxAj8cHI+3CcszKEjLukO016 H2xa1tA5EQ0ozC6OOV6jz5Rnh12H2oV9v2U+oyZeZAYtyYp1TQ13sJQIMlTKtMIx6VJ5 yzUD2M7N4nOubWaEZUvZZSEMFI0Jr6H0621IKI40sPfVwGePuBNIOm/eLZKbgIDFP9vk udeUgwYMAu/yNEcXDmynCJsaWgQ5aH9eYJGdn+J0ohFYMI1zjR2y9Sn1Fo4NjxuZJwkB hgxzdscicPyz9XTD51zO+UlxW/oGsEvM6zkktjong0+d3weI9lH0k9s+Wf+X7QfXKw7d 94gQ== X-Gm-Message-State: AOJu0YzdTn/WJoskt28grsrW5ipYQaKuTdHR2EAXMjElGROZFiWtRPRu /n++wk2XQ6lvnbVnLMNr/KdZVuh9PmHjdIRBmVvCGyBCQKPB/yjrFQxB7cJMuow4rUdASNCyly4 CjSdw/8c= X-Gm-Gg: ASbGncvkDVxAFA5US0jLVE4lCT/Gbj7ChluNYIlgmP0hc6it87My5uHiChmbr4OEMnP Y8OlAjp+myurkNE8Bqfrw4zBW+B8hwWHyPOrmuxbPGQ4EJGO6px50P7M+6V5qJlk+BQpv1wwLsL 5t0DykLUGfAVWGNQ/XcrR+9RTORAjzx6xuJyxbKyUziIrO+J7CKsQaXf1Wvt9p/GOHHRGhB6QEs lM/+EEctBSH5puljccfMqbU+NvqvnFPlzwug3GNDNwXHefrhEytxXkTVMjB07QqaSlmB4Io9x4K rzAxOHCe6ulJVmn8wj6hqQJjlt8b3bN1IQEIw2Vpt64/4q2utO03Bpz/RA9e9q7VroGzRyfPrlG oW2wGN4rrTxucvZ5t5qGi24IOJ1aBZefKFYy6xPU7eRd4+uXlktpRyKzvTw== X-Google-Smtp-Source: AGHT+IFFMfxm3JZhenTz0m+BsUhIP3eUhPlUhnkJDjenD52/ZfxQRr8DM4Kn04sV+Ad2vXjvNMUZiQ== X-Received: by 2002:a17:90b:3e8e:b0:31e:c95a:cef8 with SMTP id 98e67ed59e1d1-3232b7b7707mr3016530a91.32.1755176355187; Thu, 14 Aug 2025 05:59:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 23/85] target/arm: Expand syndrome parameter to raise_exception* Date: Thu, 14 Aug 2025 22:56:50 +1000 Message-ID: <20250814125752.164107-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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, T_SPF_TEMPERROR=0.01 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: 1755177227013116600 Content-Type: text/plain; charset="utf-8" Prepare for raising exceptions with 64-bit syndromes. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177523; cv=none; d=zohomail.com; s=zohoarc; b=erQ7hz5/tbk6wDma7WIBEUaJ8ejbPG/8OLefyXTU1CKAdBH/PL7LOM5+VyUbsxLhQ4OZUci5J4JlMIZ92yJEFJnRjFX5sf2L8UuDcafR1RwJ5ZyUcH76CA/CH5K4KJOG4xhUTI7TWXHhQDOAFMpMwl4kOOhzBJ6MDlP9qLQ5/tI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177523; 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=dhcXEoAhfYGNZ5ORgIhE0Th26ZhclEqeoYif9cPpIfQd7/YINYRdX7AWz6N5UjXlBVUrnRGU22Qr1KBDAay5ceOyHIKf4Wfnlv0r2M5l/jx6Lf0oC3PI3eeapjq0JmRuWlGW9u4+lebUSjnNYT5h7xDozSeu90/+aGSpt76H56o= 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 1755177523981723.6657612486558; Thu, 14 Aug 2025 06:18:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYd-0002SX-2y; Thu, 14 Aug 2025 08:59: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 1umXYD-0001xD-VA for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:29 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXY9-0004M0-Vs for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:25 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b471aaa085aso315465a12.0 for ; Thu, 14 Aug 2025 05:59:19 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176358; x=1755781158; 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=u6Wj8GbZjd7NG2WsqcDGmtczA2EVdZ7lKtYcglKN8Gn9xPmkUnXPT0z2T4+WDnCKYV qCPbcNP6Qg+e9zB1nSMwoFEWW035op+XbRhWHYmi47A+G6tFuBibkCTCejSnC2cbiCwy 1KWlOgEKhKtlSzHtNvdTLgLdiCf+pjUEGRpHukHLI0Is8WyoFwue29GfOTs+w1bdxigh huU8fS4Zd1Rt4hecxCk6xBpLvbdeTE0FlBefSHQnPiJn74PB8lO5chGHRLOvxj46adwW Ent1otspFQ6IRQJ3EDGWJR6wh/cropbGDV5qQPRZJ4uwL9qauveORK+29CxH3kIhThy8 xPEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176358; x=1755781158; 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=J48mtQNfQlDVoHQ7IXClNVajTVims9YGndsxk50LnHnCLRT79uaZfoyGbrqyFTfiA5 rSZ89znk52cAcfwmvwpZwZW5T4J8VNNJpF6KCB+l1awLOUaLc+FPSXY0HPrKEmvmvkjp nMbLJH95lAzH4/XrRuJTbOgCz0vj4K982xD82zt8Wi/J0KKwGX4Y6CEflMya+3cH40kc QRBhx/Um8p58gcbD98AFYhw9ssIuMEmKbXbP9G/8T6lUNCaudRC6FmzV+8XN1TgOhfIU m8mRuKpRhgRrTcx1CGdH9tyP0aYKwg5dIgHCuGdGVcy1Ac2sXQg+4kLwTxQCifzzQ8w0 ZkKQ== X-Gm-Message-State: AOJu0YyRUxXBNiapRbtlqaGpimQ2ZXoQDgkukkttHHOadmq5joMApP50 6n+S06JZzS1DyF3a34FTFDW1Z2KUjx9mjh10iuDeEQmMjnz2uOfuMfiSlNaaF/iBY2g4yWyJGs8 3zZLfakY= X-Gm-Gg: ASbGncsDZJpxR/d3hh2TEhfNAxHxfu+635zUqCeiDp4r8jJld0hxeR0dx1d4RtiCYUe EWMCNxB6sK8oZMpcOg1ADoqfmcBvbOMvVsKz6YQkxwKnH3IaEf+ov017bbX4ZvHnZ+dO3u0i/FY UrHHPil++IM1v3jNE/N0zzytL/Zyn8Pp/i5Ej2iV54VESvAEv9wH1KR+OSNF239itvOOFi3hVHo jpScYT4x8knUec9EcyzxQRvpKSXEpGwJ6PNvbp2qPbXRMGemgXZWdQuwpuikgMJvmpmbsUxIVNK rvF5gKoLaNotGW1rH/aOtn8qsTxFPqtDLlMFzSduuwe7DxdNjMEvMGpKMnWQq/0cgmTIFAtbZKF xi6cuDgDZk5v35yv7NEqtNsh2uPifmGkRW4KE+rZOey90P3g= X-Google-Smtp-Source: AGHT+IHUu2SKS6s2twlsSDcYkb1o2jT1mppq37RTXokyeHNTId+wXbr6ypQy3cDGYWATr6Qh3lLSVQ== X-Received: by 2002:a17:90b:1e01:b0:321:d5e8:ec9a with SMTP id 98e67ed59e1d1-323297ac230mr3513698a91.16.1755176358111; Thu, 14 Aug 2025 05:59:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 24/85] target/arm: Implement dirtybit check for PIE Date: Thu, 14 Aug 2025 22:56:51 +1000 Message-ID: <20250814125752.164107-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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: 1755177525154124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177177; cv=none; d=zohomail.com; s=zohoarc; b=I6qO7laTAoiRD3/kRCYvst6WpZSXs0vdrdUzccyZ2kQ90Uc1aMC96yAMltWs3MYXfvn0sdK9czqm4DX6gtjSjYnn4xOgvDmHKngIIT5AsMJqZlIs0PnimaGvfFWILeHXrAhI66ryxvcTJWJOkz25puVuxAx5zvFbk2fIxm5HQYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177177; 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=hdA25vy+pxeH+D52Ub1Wp8RhnBSNmN1S5QO8PlOVo44zKiN1C9+VbdCl/66cQ4YIs5qPSB1uo9QDNjapzSiKvKu8+O5PwKbZXYitPnvmC6kFANVqUorYE5Vz4v/pEQ5CsS+6wArS6e5iyxrR0urrt6R9ijx2vcFJttB+pPnQQfw= 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 1755177177617298.6493018786937; Thu, 14 Aug 2025 06:12:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYY-0002N8-GG; Thu, 14 Aug 2025 08:59: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 1umXYM-00021f-07 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:37 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYD-0004Me-MK for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:32 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-76e2ea6ccb7so683529b3a.2 for ; Thu, 14 Aug 2025 05:59:24 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176362; x=1755781162; 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=LOYregu/nFrdvOixy2X3yi8KHvJvSGSE3cM4BIhx55RM5e5fm+Fw4NW1zgyE0fSPSi 1bT8t9PDxrOVo04do9B4SYDEBohvUx/OVPxmxsWzZEPnObgHesputwhy9ZCmLkUv4WhC dEuxNygA516wWNrvIzj7Zu7VxceRMQPczeUtu5QsExqLHE9DAxGydRkWNkkg8GkLWlG2 Cv7Yj5w97eJg+6zLBQeCrfrBeDJX0mLkuHkYLdJLF+SVvvRj4BlzbbOQEB6vKHYZji4V nfY+TQsSivG1om5OmHnl5FRKvpdPhtcVfdKZzxgBDs0rOrf4M64Q6ANHQ9H5d9ZudgbE RZOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176362; x=1755781162; 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=HbtxNlTUEC7U/qNNPYPf8OGLgqQ+ZDwDpWDn3MPm7tuWMB4JyE1M38//R562Nqqupy jnkwgks7WuekKBCkNGnY/s9DTfhmBKG2uAbqCOZuSzJw1uxU3f1a9NW1eMfQdVA8Gjhx wLhQON81Tc2WjJOTym/nRqr9YGOLETxiNvEmqgkJVTXQ+xMwV+9JF+uCnMYp9WviHOK1 G58cBCJoWCozsDVbzjD98DWaoByc58O78C5L8zXXx/Dm71VljrAZrRCiq3HUPU1q0cCW C4kE68l7wAr39DdwZVGr+tnXr4W0KpmgU295q2znyt4FK09/ULgjbdUJXJl2jrU7wAkD Vdqg== X-Gm-Message-State: AOJu0YzTLsuTTaanC7FUavptm0DLR5F3xg+zlVRE+W9wt1cT8JXr6FTD mBsRGLwTN/ILoDd81IvcHgHFBYuQIg0mYcQmvfz4iSm7i2R1SVFMp227EywfPQi72Zevsq3AZjl yWnp2gVQ= X-Gm-Gg: ASbGncsZhdO22wV3Nhm42KeOVvTq+opgxHqaMlBAVRW+hFp8vyh3LtqKY2zPKcfamKW NkY7PwKo/RwopiaBQBYZRXPoYOgtGXofncCkHVx2y6npMQBmbxMcQO44LXAK/ty85VZ7BbrzXg/ PKLbEsLlpewusPNAtu8l30OIzqNTFdVITHvId38oIvJTdfol3zw05DbkSRVMCdGatkZTJvx1MYa Ph+b1N4hJK0UVvS0v3w5U5j2Yl8Rg4PquyunCtb9mpTEm57onm0lYwLRG6xlhZpoolv4kZjO0vr vs2gU4kTmzf+VzsAUf1BtPY3J8u8cPS0St5TezZfQJf5NZm3m2gDOgrCKwgssJtVXIUppLX8pmV WMhpGMYWcQiv/RO9zve/mq1QUUlltTiqq9tkLipm4fbp3Q/A= X-Google-Smtp-Source: AGHT+IHhYC0xNlnUEaGC2fWjEHijjpRhl8GIo8wE01KmXFl0fmZtqNNfvsrhGALl8yukwaPyVTdD0A== X-Received: by 2002:a17:902:c410:b0:242:a0b0:3c28 with SMTP id d9443c01a7336-24458b9cd96mr46529665ad.51.1755176361692; Thu, 14 Aug 2025 05:59:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 25/85] target/arm: Enable FEAT_S1PIE and FEAT_S2PIE on -cpu max Date: Thu, 14 Aug 2025 22:56:52 +1000 Message-ID: <20250814125752.164107-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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: 1755177179233124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176962; cv=none; d=zohomail.com; s=zohoarc; b=GFBGn1vsHiF6zzD9WBtuecH12ktCN5SdAuV06O4caq7opjIfDRJqpTqYk+4owaM/iROv1N5neV09kz9+sKjZN2NUVncjRdX05FRAww6UgVLyVyQL+wAzdHu1gwKbvRqftR+8NKRTBG0jl5uqJRnLXFE4KViEy9DthYOOjthJCxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176962; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0Ree5Gpr8l0LtLySxeEcXv5FgIq91JPtdUEJ2fumBaw=; b=hPy/+RA0STYPAC/1ZtUDObaSTaTpIu/w4cWUHxfH1dDnBB1XGVLooUTgCD/lrbXpqx8EWlbKfp9T0nEJYj1aRlSuP0g+V8VPY4p58YdqRC9+e1/K0y8CufuCGmgDpzlJcMMdGQXMTgkkG1ahgqLtIWZTeQzwzrSbb1cScQ3bM24= 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 1755176962271419.9877962922192; Thu, 14 Aug 2025 06:09:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZ7-00031X-6n; Thu, 14 Aug 2025 09:00:21 -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 1umXYR-00026Z-10 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:40 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYJ-0004N5-FE for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:38 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-b4717390ad7so539303a12.1 for ; Thu, 14 Aug 2025 05:59:27 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176366; x=1755781166; 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=0Ree5Gpr8l0LtLySxeEcXv5FgIq91JPtdUEJ2fumBaw=; b=IxbULsdLoPUL4ytjL9ChWBmt0YFHXbCWRF81LTedGdUoZxxq4MfGpquJHFDh9Q0wBw vb3UxLCP9gNVIQQzD+uvX2NyrkRAMKQJbxkDDg3udsveC60cJncNt5anLEKL8p41amh5 37QhgWOQHwcXCRl5+z+7SKD8/whK1d7zmIvM1GyWVtGQMO/MNv2+L4kfoqmEIjjH/Z4c b4r2ONGLU5ZERv17gB2tL6bMC5i+HzfVwbNIviS/14m2pWhYmIVNJr7xw8wZdsB+E8XY 9/ge4CYtu1KHUHVT4vZkVDqfO1r+2lp9LHaR6hGP/3CLYPJ0BrJ57UlB5a6KBsna4CZ2 uxCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176366; x=1755781166; 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=0Ree5Gpr8l0LtLySxeEcXv5FgIq91JPtdUEJ2fumBaw=; b=nqOHIHoRNckwvhV4L0A8yTcTjXdMPHd1lhN/TYEuyKOnD2k1YsKtf0cHyGvfA8wEo6 1hWsG5/5TOS4K5QW7H0MmpP7sVy/1DwabTucfhFZOll1GMqe7T/AtGEp1MxdQFeVkkG8 7lMHTvxXNYdcRnWEFN70pjscbp63Z4DavYyH5IHCMyG+NfFgmQu/eOEL+ELseF4Gyfva eBCFNE89uPCITu1FzUABssASat/SxpfU9JE4uE2BXlOZ1MFqhkmHZy3GlrMD2eRxw4ZY YeTIONkcIqK7iW1RW8U6/ep249od2YKImxDl6YnXZO4jrePtAnMb/4Tz3n6TuZ2thOdE 4jYw== X-Gm-Message-State: AOJu0YwjQIBfM5/FUMCVDkN55r4ox4XNH8a+8eXbfgodNc+lylM44f3u /oAQj3uktNUflReL42W2eH9lXoNNek+W2r7y8fQ1gcsEHeD2KAle0LtONfJ3yfX2XDuAsl6MDw/ LSaPxumI= X-Gm-Gg: ASbGncsesaIAXzDykQUOaaGjUgfLHSvW6RnkhahFzdB4920ZnQa8qepU+Pnk+idiqLj 3CrpC/IeMvi5tGOxj8zEZFNjq5TeQQfv5hxV+zBRJzTv2alK6ZaAxDDn3tm8s6UeRin5qXlmLKX JZO4CIS7kYYoUWm5FKUA8JSEA4qWEXY4muoRrQiXdUQoFHqoJEYQWQuRP3ZtaqeAUVeRJnCDwd9 MfuNkAia3+NzFdWCjtMqnvYmLLUWmBbKHfn3WoDoYlaB2vrlLro4G/RGjYXVCzYBWXE3JRdARtU r0SbgCGalAoM9khgkWhdWmzMGOHWrAmVKJXgQsK25YYlF7Fs4e+LDBoSBVWDCFQ2bzrYwvLML8a BL9dMHkpy6QKUsV7el0bUQdDdtlMJ8WYf7Bgk0l40M3+DnR0= X-Google-Smtp-Source: AGHT+IFbWZ3puoFHM6gtSEMrTveevwnOvjH+Ha30d9pT0d2nkhq3/6B4lSQydzrkgQWjYd3tlYU2aA== X-Received: by 2002:a17:902:e78f:b0:240:3c62:6194 with SMTP id d9443c01a7336-244584f5206mr41555695ad.20.1755176365473; Thu, 14 Aug 2025 05:59:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 26/85] include/hw/core/cpu: Introduce MMUIdxMap Date: Thu, 14 Aug 2025 22:56:53 +1000 Message-ID: <20250814125752.164107-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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, T_SPF_TEMPERROR=0.01 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: 1755176964703116600 Use a typedef instead of uint16_t directly when describing sets of mmu indexes. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176706; cv=none; d=zohomail.com; s=zohoarc; b=easfcmePkqZnl38IiBRlxrdok9TZLXOgqomuBkYuoT2Mp7BJT1Con0A/UZ9doLO+GCmFMz+/haRkHM/8RYLAMHhMtLla/o2q4+hbDJdQ3SvBwwBbXP2C2cNbNhJu47bDQxjKoLbdoiF0DoUDDa++nFpkGYmgSn0MQBbBhZHWZTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176706; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jdo4eXfghXIxBtW7gGLE9m9wdInFFP/OSUyrEzGuH10=; b=Qv0TTyK5w+JYwNKZBFfuHXWVV80weD3CJkyOz509+bflxqQcYnSPlsF2AYugSoxL+mysgoXp526ACVCdTFp4dziURy2EfhkjjsenQz6NOkKD9OQnGo9doMjSDbX5m6PeHbOebpsTPejz2zvuQ7smLdvgCDDwKnBD+Bl754BHJX4= 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 17551767064521018.01828037194; Thu, 14 Aug 2025 06:05:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYh-0002bq-Q4; Thu, 14 Aug 2025 08:59: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 1umXYQ-00025n-EG for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:39 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYM-0004Ni-PK for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:37 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-b47173a7e50so688804a12.1 for ; Thu, 14 Aug 2025 05:59:31 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176369; x=1755781169; 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=Jdo4eXfghXIxBtW7gGLE9m9wdInFFP/OSUyrEzGuH10=; b=njMNS517BsMxeezFBT0knnO+Bp7Vns0lsSAhUiVjKsradGXKcUjQWZtx38R7oO4yz8 Ccg1xt/Tq2XFRALFMN/YkiDmFV3OKON66M5VtV5fW2db8Z/qdf4tj5wSqUC5KUzFQv7E RuleMARGkLV4SzPO+7F2r6O4hAT/HhdcU56z+u28GkIWZfxqdR+OJ4BhV1Jxs2X1N+Mu PhyTlUb4QeULciODpPmFGvGdd+48/6VoICiYfi04Un3QaBLWZFElxr2tKYiD5lk4wvAv pSqbWqfD3xaWIUaxcHedz5KzXSkotGR6qRdVJ1RajuwJNmPLJo+mpydEGCspPYpIYwNp 6QZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176369; x=1755781169; 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=Jdo4eXfghXIxBtW7gGLE9m9wdInFFP/OSUyrEzGuH10=; b=IobWvTJWYbXSaA/WNoqKSObd5O+vf2qucPJVLanvF14hGZYBhhMfZKlAE8ckM4OoBJ Jn7icdJnF9TfYHCI2fHXUubzFhvcZ9VZ4olZPDGzV7a2hGrKaaL183deAZ5kPGRBM/8g diadFhbIfMji9Ldl1nfz+BdT03qqoaE8cJnilzQjhXZPzqoDjdQJXuVAzhFt6LNmUSOn oXqVe8Piw/ep6sKNZqtSIfkKgO+vVw0bnpC4eVSV0f2KVw7AQCIULy+OMnM9kEsjqi/t 4aaRjz3VIUzoj1LkEDxkC8kYT4vcgOLr6gu7sMwiLDjMudlC9KSojL4lhY13IArKmGre xlOQ== X-Gm-Message-State: AOJu0Yznnsap4hYlPgeDaG4svjHoETCKs4sHo5Kw8CdGqDx2wqR66i0N N1xQD7/x92qu3KTxrqEHEmsp6e8fgmTKfnVPSFjPepf7tofzRPxde9nRjKqJlX0Jhk41QRXCb5p dOlmkqQs= X-Gm-Gg: ASbGncuwPc4SHSoyeu20b1sFl9TOyHwPlWJ7JZn9rV0MY0LBZ5/q1t0ivJ4S1aWQGPQ n/UdMui25YbmrkeZ/PUw0PYcvX/KebPfyjNSsEBx8sXzuPRi+kUM/EFJ7+Q4OuIe8W1cZtAy3tp 3ZLZEak3kQgxko/w0UrQ2QIh/Uhta+p5X/Lf1xlEqp3rrgtxjibNQTM1ZQEuBHC6H9e8VFGpv1l 9owhvWAEz477LZQGwZ8mKTaBTiAH0qMN/IFGcwdVlcQMo0AVOxSTZtSrXx7u4xrTK+u0mNcVsKS jDpBzRqQohCIcG+7o8DvIA3jlA72L19nhvo7DHARx25kClD2Ij4mIoiLKgDc79t38bGfrgF53Z/ M+aoJv/uYYMVnpQZ3WAtKgE5mRprVFc9XXxxbKpybt7A2QcbZ2DbZN5ZcFA== X-Google-Smtp-Source: AGHT+IEvxep0ddBysjSncdLsBtT9oAN/OtvciwliqINkZ20j0iir6ZhDTscjlsIwpA1fZq9BZHpihA== X-Received: by 2002:a17:903:380e:b0:235:ec11:f0ee with SMTP id d9443c01a7336-244584db9damr34586375ad.14.1755176369489; Thu, 14 Aug 2025 05:59:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 27/85] include/hw/core/cpu: Introduce cpu_tlb_fast Date: Thu, 14 Aug 2025 22:56:54 +1000 Message-ID: <20250814125752.164107-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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: 1755176707799116600 Encapsulate access to cpu->neg.tlb.f[] in a function. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176909; cv=none; d=zohomail.com; s=zohoarc; b=eFfbBogQMqn/OvdLoHsTqwQN5gYlS0CUPeG2aHlIz3r1f8lSzQUuWMwh1bQW64qxYftyG1RLd0L1xguqfh+eBnkwwVRmQrhTpypSo9b57ZRxOErZLKWTKpZWipVgXEDppE+UyGVmJQmst93vzzo/6bxeA8ME38jdJ2TC70Y359c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176909; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6jXVVpPrnUxKOJDwLJ9Z6F/DAfv+srkdIqMUZ2+d07Y=; b=KBvpUxssEqkVJzkGlnbscyUY2/1Dd4sL/7ZcL4Ud7OroPs+V/axwUnHMl9wl7w5BjJyrJJtgdc8LzmYz3zY8+sJvLCIyH6Z9vuF4I3hrNXXxOOObAIDhGgZoYa1Y2cXbHGiFxbqLV0nCe58wapVO5nIvqXhfHolg6xWjNXvj+7s= 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 1755176909572951.9252437520843; Thu, 14 Aug 2025 06:08:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZ7-00031K-6J; Thu, 14 Aug 2025 09:00:21 -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 1umXYW-0002HK-6P for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:44 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYN-0004OE-52 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:43 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-323267bc0a8so1527305a91.1 for ; Thu, 14 Aug 2025 05:59:34 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176373; x=1755781173; 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=6jXVVpPrnUxKOJDwLJ9Z6F/DAfv+srkdIqMUZ2+d07Y=; b=NoOd+bNTKGdFMEF2obRXwrnPTJE3/x2Tn2VNhDut91ztaXENeXQAeHq0opn3ZTjW4V oclM6GybcRr2opaJK7X3YRXu0OiYx04Atd2QQ1dK+7w3UY2gxjOT9bfmxKCa4/WjL4ov NOR2tgCWtJFQfWomG4nxZeDG1x+e2cwKGKciPX1DVKCljCTbDDktEeQn5GXBe1MXrEKe xfGvguDRNMv11ZWjUZ5J5OIYeOfTAKU9VtBuJ17suUVx+RfgYA3RwtSqZkp27myoElb4 +Gupe1hNqnVzQgi15brvRZ/CPvGRi8dYgG+l3gBXR93lK+Ml+9MX1XSqW3P9Kt4kp9dF BGhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176373; x=1755781173; 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=6jXVVpPrnUxKOJDwLJ9Z6F/DAfv+srkdIqMUZ2+d07Y=; b=AcOn3sy81PMDp3y03lfBLRuUP2wkdsgUORHVKNsc02RM5x2vAVE9+Sm/EiPEp8qOYG 4bYAkahT2CAZqhk2DQgemEpK23dLnV3mn1I8rn7O2hrOsULp0un3bi/jz9LRrccZvGpJ GwOOCpoI2aCOGsjvUSlirIhejOD0I0a2MbMThRzNF1f7MDSKLTohhVdxYCoIHw0Py7ow w6ONk3rDjCbob/El+2b6HxLXD7UnM58KSc4bZ/3WuPfQy5N/ZK6KEMQ1iPQ3vfuQtCz0 3YVZis1m/WkSJe8dwtg/eqwDLyLhquLklOd8pGcKYocHWc2FJ2c1VBA084C4RiEmSfuL y//w== X-Gm-Message-State: AOJu0YynT0BPiSfu2Nr+Ywvy/Yb2N3LbnIevFYd4ma3m+9xvWLjNaEz5 MCSNBORxpIlsVyhmyqB1JT7HeVRSBseigeYgAhZAXfFJ8QQ/nQB+wKDC6KCMhGCXYQMpWJg+HeT UI9V6S70= X-Gm-Gg: ASbGncvFnXSqRRTdKnoQWEnEKll5lv5K/V5t/naTwQZcyY2SOZ4R6tZqNPZ276WdnTb DQr1ghqRiVlJsbj28N9tcQ/PX74WKaNBBC8VBe/PJQzFaRlLAd5v2I38bD3OOd3NkLRSOaKLNwf jfF8Viz3yvqaDOJtp244xU+xGTpvXDDerlFGgDFxoHXp41/NSQ+HmywMVrx3AAwm2h7i7OCyJoJ sKYk73P3yGQMErwmRIEoN7vkjIB99tTuKyfJipu6crSMRAj0ULxldFcfGwrGYxkcFRZlEv4F9b2 X6POC8hOzZeY9kc+bPLtuTdKnC8n5NPNqszZ+LuWGusyQwGq+H2doEZI8VLmrAjbyM6eXQ8yTXV iT39QhTVuaiibkpD46PoUVp5ItVOVkLF14TcgAfiSUSarmU8= X-Google-Smtp-Source: AGHT+IFf5KlrS5MZdN5NRx/elB0yvd3BtzYzpNp8fYM2FyZXxs70S8zW/rap1cDozRx1KdvKVbGdVA== X-Received: by 2002:a17:90a:c2c4:b0:321:6e1a:1b71 with SMTP id 98e67ed59e1d1-32327a8a851mr4399164a91.29.1755176372685; Thu, 14 Aug 2025 05:59:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 28/85] include/hw/core/cpu: Invert the indexing into CPUTLBDescFast Date: Thu, 14 Aug 2025 22:56:55 +1000 Message-ID: <20250814125752.164107-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: 1755176911375116600 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: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177116; cv=none; d=zohomail.com; s=zohoarc; b=j7EPLfNlx2bGYY3eJpZyVGvOMcyUEifs3S8owmwmZEsf2x58TLVTm2JbQIKHbSG4Oz0N+5BjbWSk7AlJXpw55yQvVw90eYUlsn46KMtn18KJXEdfhSSA7GIIWWlObaUFG693dElCB5ccRHkczT8gAtnKk1+TaWpI9S/RN7pzDVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177116; 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=eIbywSYas8xjrWbrW3Z76xxyhw689dHqJSou3Xe/zz1dliZYtIPOaVZUukrJRYfJ9GYogIuhhW81Wz9wJxtn7IaqoajqnO0q2nJXf6zl0l8lORaohPnjDwc/HmYrsf+HZ5zeH962E3XJ72YrCkK8oyaZUcgtRcvHvQ12r6SZ0PQ= 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 1755177116362644.8170943417338; Thu, 14 Aug 2025 06:11:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZE-0003LY-Eq; Thu, 14 Aug 2025 09:00:28 -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 1umXYY-0002N9-29 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:46 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYS-0004On-Hq for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:45 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-323267b7dfcso895477a91.1 for ; Thu, 14 Aug 2025 05:59:38 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176375; x=1755781175; 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=fIGz5x0vwJL7x1qrsVTbKMi4nhNND2CkaP43gdrCzKowXxXGXno1TP/AGo6/7a4z5U i9bqcF+csbeLEQzi3G5sBW2C7CjiXITXsD/HW09+I4WnHhFjbL+JT0wU9GtL4x/SORvG +WZTSKf4UvK+RqpmUowIACR6Eh6NiaGuMyU8vDMdXg9DG8OiIAcg1Ln+Ldacx8OxNYmW og4q1Cq+Y5/n2hsfsr48H/f/q/3Vki3hfOOUeIynd+FAW3bRTIgK94PL4Z2y4qFeLXSQ 1aqSiq1s+TRtge9VLT4yf9Ko8qD325y42ZFuRQcqA8YwI9vv2Z3Qfb+b8qw2UcWxiddM ELnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176375; x=1755781175; 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=NLtwbTgGYLgAhQgnFwIFg9txEv1P8r1dS6IkObeYeErIODpl0C4Zx/Y0Jt7D07zsuK OejeZOUheMBdglIKb3Fq2MX/IR3+sozFMefrG7Iq6uv/XYI+6FRJD/j69c6JLADswSTU cmoMluMw3pZoN+E11gQgTYqJKmSneovYyotKnA8jIJ4I7Kn4ez5LPKJ9G/RefrAFPTvZ 1uSqI030aR50TYOJsZeZLqY3UJ2gzPAiRbxi1AYyB9ckp1kOLSzuHMS92CaMWdnN+ZRU pJIdJ+WuieLq9lbFZaTGnho9TU3sBJKZVyNRkM14z0aqP3/Glpg3eVyX0kf+1ZqiUtH7 dP0A== X-Gm-Message-State: AOJu0YwpYk752GqxXHT5RB4Fj8pyi8tb6QMNU+ICZK7CF5qLgC4cdAM+ 2Cv1GU/EkZ1ewviPxOsNh4mOuTJ1zP9JAxBWl2hGg3tPQDbre0bosiMOyK7cdsCDCMdDcZtxtQD d8KwaZZs= X-Gm-Gg: ASbGncvonKVOZflX5m47FBRjc3r6H3Vxsjsgywy/G8n3VmK1QyUVAcVldDjJkjQuYw0 GHD8il9AoOcaoBr09ofoO8k7pXSmLE/U7DgHaxq9eJosdSwSXx8KhYBzU2NOH/KD8jlUEnQCZth SQTPNqlT/YEXxNsnJeQ9PQ8tldQqwNvkH+BWl8HHs5aAAY3dFgQsb6IG1U6qgUaqW8qITqqqwkq QYF7s98pju/EwK/JbC8U/JFFRgjDtbeCV1Y3Op9SRA2JUZhcoJGTjKX2uKju4aqKai3uO7VErbI gE3QzqsfHhnBLz7lSvTPySVx9dgqZ2gIRwt+wPWyfz9pLVZzmaYS4QghlG0OtnH3IKMZYPqoG7G B92vKkJiykX8LnyuKhJ97xKaU+N3DLfc4rVeoOIERagpCg0TAPnOqSFKEHw== X-Google-Smtp-Source: AGHT+IFz/etwsmckVxbDZJDwvEZMxWQ3BURMk1QYcQ6O9jYPl1e3MgJcOCrqFTVKHMHeVp6GgzkaSA== X-Received: by 2002:a17:90b:5107:b0:321:9366:5865 with SMTP id 98e67ed59e1d1-32327aa63bemr5106483a91.33.1755176375579; Thu, 14 Aug 2025 05:59:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 29/85] target/hppa: Adjust mmu indexes to begin with 0 Date: Thu, 14 Aug 2025 22:56:56 +1000 Message-ID: <20250814125752.164107-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: 1755177117673116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177009; cv=none; d=zohomail.com; s=zohoarc; b=lV68qyX5zJykphS70n/WoZuzv8h8q/Ex5bvfO9K22EbVuENAgmXAVc91E4hkvR9KZXFojb7kRDFJXwyBsVaPbTaF1w5yPb09BdgKgVTpCu76gTfIqLvylYMopyoSFeWgqHkF6B/GTPgACM0hitSpjYkNB7oJxlkaI1sFCDjEqi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177009; 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=BfUmedvNjcC30QaZDDb7VClb85eGDG+64ZYpLipaxprIip2VCwZgRi/jfGtdt+iHRVNsFbjLuOCONFdBPwRZd7SCria45KBwlPzDwRnuH/GP3ehtS12yIWpbF2FBMeMHCM6CIc/PFidGCuZIsxgUjGotiVsjeNpCtdFxh1ru6lc= 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 1755177009896402.4897790616387; Thu, 14 Aug 2025 06:10:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYf-0002aO-VU; Thu, 14 Aug 2025 08:59: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 1umXYa-0002RF-4Z for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:49 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYW-0004PG-FS for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:47 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-32326de9f4eso810918a91.2 for ; Thu, 14 Aug 2025 05:59:41 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176379; x=1755781179; 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=XLHYs7y9RNKJjUNF9jng37BF+QPVh+op4kRJy35/wj0MgAm73Ag0xOUJBTV41/7Nx5 mSYbB21B8msg5RrSHyIiuJYpQ2uZHezUxJdPY32lKv9whmilGRVHncezbk4pBStAMLNp zv9AEubXDQrZaix2K1MmrAdVlB5dR1ZFJQ3mfg0HwYnglLmUjSbTeI08Tb4rwlE73B/1 piaALfmRQjtefWYRgHLVBNCIcU+OMcGc0sS4tvduce6fiO4J7l1naVa51vGwJ+FCZlx5 YlAW6jxY8gvkMpsjXvvQJ9m3MB0km7Y8T2WYRJvSRSfT/GKYSJ9AcsKgsO1Um2NeECen EI5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176379; x=1755781179; 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=vqMzF4wxaSuEo5PxWzg9jS8gdR/Q/+e37BGbk8be6eTZbGQblKkplEMhEbfQjuV03t OdLMDrKf+BepLjT1VlPuFKI1h5Yahz7sLzgwOjA6S8YFkRfkfbkIsqyXhsLjaEkSHJZp Rku1MzUpbvvSlsSlbx9b73Jb/qErbLw+HIOq8ybErgYlollKiUianJHQpKVGL5as/vl9 CUsQPlTl1KYOkAzzSjoFpMVPbAX8KLziiGuErE5AUmZ2EzekY+h09HRx5kI+C4LkPg/V 2h4Y4QO3crJFOxnB0mzGQWgywECXHJiCX9qlzpiRSvB7nraERhQ66JklrSG6uKeo4tDD Cc4g== X-Gm-Message-State: AOJu0YwpapxHOp5S5iUATl8o+2r7BR9RL9hVzvA5GPRWCrwdiPHxI86l tfvUCzwuzIS8HMDOtfBIVovg4mNxI0SRduIRxrbU9toZdGyTMYCy2vv+5NA14FDgoRq50S0lPVn n5sSzKho= X-Gm-Gg: ASbGnctn09MASZWz/V9C7JPMA9R2awI+1Wd5HVrQbgUc31HNnAkn5eK0HsXe41p0zsX 62lwjWymEeOYw9oi2OSTayEAAJiib3NrOswdugzozq/BtNg7IfiLjYpF+lm9yjoLMURzZnINE/s ntqudYRxtn127R8K1ZOBn/CxN79QgUFqapyHpjE/R61rTksNtt1t88ij2C1JxW8sIJf6PGmhRRZ TtvNbHm5DjN4mwe1s/UfYsAFxS09zZFMGjEX3cNMlVKAKy7G1A49I0d13WEyKLeEBjfyp4Vpq+R zrGRu5mkZUZvLI3xJhIk26nZr4HXn3jizu5hPxN1C/wSPc6aZFqo/BjFH5TMx1+qYX/uh1r+9Cb yQV0SQb9dhbBGwAMvg4Nbrws24Tktpg3O7kmFeFqSNlb6D3Q= X-Google-Smtp-Source: AGHT+IF1wmKY9MmDTwxHy7FIkgF2CAJJ2uVf4fo7it9i5WUI1Iv/muQj/UO7ebCQ2zagCFxL7cGg2Q== X-Received: by 2002:a17:90b:1844:b0:31f:336a:f0db with SMTP id 98e67ed59e1d1-32327aadbcbmr5085805a91.10.1755176378784; Thu, 14 Aug 2025 05:59:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 30/85] include/exec/memopidx: Adjust for 32 mmu indexes Date: Thu, 14 Aug 2025 22:56:57 +1000 Message-ID: <20250814125752.164107-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: 1755177011182116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176794; cv=none; d=zohomail.com; s=zohoarc; b=AhPsXWuw0CaEYycV3xsUDu5wewQpakEBnafeiEYGpAM5WhiC2lRuTCQPGGNz6n/VK2Cq+XH4+TCnxv1Vd8JWtD/LvA3SqsKjhTzw6fKIQ9SgYbCoCdT+ZJJyTNnwtplMRf5ASnYYKw2lggyyfOO7johiMVrfCdboB1C/ZYmcziw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176794; 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=aOA+wuZoBNfAMUsUeayP4wNLT1CYZMdTNckt5LMHhieideIbNTE0qzfdjd0Uj0fMtWFDUtFla2AbKvUJn64gqyoYYmidJdVJMxr/RRfaQzkB4NELZml/t7/A2iZgbV5lbZbFjeArszjm7WkEo4xrH0Rpi3Q5xRCiHbM6Tqvuo4w= 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 1755176794156965.3778690589425; Thu, 14 Aug 2025 06:06:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXYh-0002bW-5i; Thu, 14 Aug 2025 08:59:57 -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 1umXYc-0002TO-QS for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:51 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYY-0004Pp-0K for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:50 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-323267b98a4so865259a91.1 for ; Thu, 14 Aug 2025 05:59:44 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176382; x=1755781182; 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=mheFYxyBDRZLrY5TvamzybUb9rNG2GBM/BwFcgfEOSB6n9KISQY5yWuj0qq9mwBiB7 O06qj9XcVDcl0o3b0DkBqN7Gkiz08QUZs/JXGmND7j/uzUe09woedkGRUTg1xKZAP4Kq GhAPOf2dwsz0sQ9trLCi9mlWoTsLBzdNsrFSG0ad6BTlYLcQ3IDzzH6ReqFJO8LXdavU AwJlvPKCtm28gCjT68h2yqNM5E49p4ZOvcTxf/I9NRZxrGg6T9r6wIUTqNJJkSFH4BzL c+zMy7rQH6vpJUSjiUARkFWJslU3GI2VAi4iFjgAlrtPPi2P4GbRVgmCSYwP9QgTxhBB 5raw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176382; x=1755781182; 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=Ljxv4XIVneCccq84Dm4KpBRUY9Qv8MEXsZfWs+0J0mFQcTPeWB36ve4xYYPi3EIazZ Eqa8ASghY/87rlZqzvruS+a0Q8XOkulEyfJPfdQPsOLnTN6aDWG3jAKumIrjJwSgPqo9 cxObp5mgVBN38gYFMrQ2M7eIrOo0Xwp5uIdnkn+YRvy6fVsd+DjiraRBOfrReV+VQ5P+ yHFq3JbETZgNwSa7VAAzjNjrE9ZgXSSPSYbhloCVPOeyLT3ShS5fnzV6uWIUVm4CfbEp kP+9z/cf2J8kv8nyNNnsZivAc/e4SljNv8EogQr+e8D3n55qK6wEqqHpInUFd92gDlOk aXgA== X-Gm-Message-State: AOJu0YyM5F9hu97oDZ+FGAsH3MLV6cf45YykazaYp973aMbkufr8zDjs RG8f6tQAjQxEjZtihbIt7Ikf1IZxjJledPereAUG6FpLwQ88dUk5/iO1gV8D3wIU1WEhd4gRJ6x /S4VdI4g= X-Gm-Gg: ASbGncvfQjz47p2eNa2VGPXpeqksACse1UDInf6NMrFtwpmiJhzIuSyaF11zV6ALuGh PtunMbFU0AbAodVjv6zlO1RYUyaGyHGiCRpWueyWzZlilkpdxohRVDnINGwVKyaxXKHgqsonZIz 0JhOMlBkZM2drW7NKrEhDOe94dnpWRqnmnGZQzBZoEq9qDP7q6S3OliXzcEOQ4Fom19t0BNe2CQ oFp/WqSX5rQgTUKdNbB5SjPJzmTip9+AYJ4eoTvAWj3TGUlVNSS2q04boJ36nCNwTsWfdHQin22 1nUVEArG3RqyG1aPWLlsXcLFXgRKkSgskADF/MA7X7QsvyU13XtulylOFoQQ8HVprBdCjD3z3gY wuEHootAP7CqvdhuY4tbV4MYnbTRr0LKSI4EFo/mCCPoqJHOIT9bORUwEFw== X-Google-Smtp-Source: AGHT+IF/5OGQwj2P8DxePsEitnkzCqjvCoXizhVH7dHkrv1QXC2y7F1jR7qp/b7jGKXt8vkKzwQ6Aw== X-Received: by 2002:a17:90b:35d2:b0:321:b7ed:75f2 with SMTP id 98e67ed59e1d1-32327accd91mr3983378a91.32.1755176382027; Thu, 14 Aug 2025 05:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 31/85] include/hw/core/cpu: Widen MMUIdxMap Date: Thu, 14 Aug 2025 22:56:58 +1000 Message-ID: <20250814125752.164107-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1755176794566116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177844; cv=none; d=zohomail.com; s=zohoarc; b=BJqbuOnLa0gf82VjMs529A+BnZNNNPKA8n8m3y/2xraS1JXZXXZM+jV6X13kQsa0FaoJs5wt6huxUFC+ZIH3j/qY/T8Du08aQY6uTw3VvZDVhk8g+4iwsTfWa93olMqkBeQq6dZHH6IJ7C+oUOKKHqsdqseyI4dMLTsqKVjNj/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177844; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2gffaQ9erEJl6Cpuxyf45+FvP+94m/M5e8TzVBlqSnU=; b=ODEMdzCKwMqaBlAvj054RZMw0Q0I3RbpWC1oU9b9m1brsug3LQEXCmdF+5kjSADWtQN+wH/nuHswn4ZsFTB4rhmoE7A2Tzy1MkBKZDjEAjho4eHc9TE+bH5l4s+ijxhALhf6fXjLgZS+8n84ipwz5/Qb1i+aYuSIYM/vLn5gKR8= 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 1755177844879202.07721688205743; Thu, 14 Aug 2025 06:24:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZL-0003sO-M8; Thu, 14 Aug 2025 09:00:37 -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 1umXYm-0002fE-78 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:00 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYc-0004Qa-GL for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:57 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-323266baa22so794380a91.0 for ; Thu, 14 Aug 2025 05:59:47 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176386; x=1755781186; 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=2gffaQ9erEJl6Cpuxyf45+FvP+94m/M5e8TzVBlqSnU=; b=YFNKi+qvn2Kq6AtdbCnMGYEsN6iGuk024rEdo3+tLl6e5krrBsZdeUBwiIm4nHyG3w cbf0mUl7U66fBJBppXvafiEtpafmdLllwqYcF1bfJfUNV7n0GOzolb2j8XSsv8Scj9Gd yBVhucYvHckkJ0KkC8uxXi8XtTuOUaoEorcYW8ssmCluUOrir29a7mVlXPHbXuGV7PB4 7au2RnkgQ9lH0WM1EvAxLyzFAevbDw/hVJBs8j12FIntZw7lVzcd+Lq1CGjJtL2vq7OP GntwMUX7+CldIEaMYLZjK16uao5r+fKqCs0n7WmwZJDvkBo8VGZ/8bz0pvASPhHSlz4j uAEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176386; x=1755781186; 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=2gffaQ9erEJl6Cpuxyf45+FvP+94m/M5e8TzVBlqSnU=; b=SuXSdXevzy3kIth7Pp1tvEyX4zGGEqJ3jiJVAwwuKd1z9LPOf1GueHk71W3j/cfWxD b73DuivLB1vLD+a71oC3cnlK5oNwhJZnMmO+GX+Bj7YsFFo8VrKu/X/f766SMNXjjuL2 /2RbuASCEPSbiLy99BXRVpZPrSo7/SX+flFdin5fQYyiJ6hHcBr/GacrU5oY6vE+6Rng yfjOrDlHZSNnOgJbxokc0Bj+OrumnaIxTjqX1cuB37i+w/r+gAm2KK3yGh1TJBo3STgm dTNZonNRivnn1C2IdigKW0B0mZOWkb+mBt7mZXnA7KrJPI/BSa4hji1vCr2LDfyz0eoO 1CFQ== X-Gm-Message-State: AOJu0Yz88qaltobWWKHxxgFZMG3uwZDpWWOWq5exdFfq6dYDjgoTQ+Fv 1S/MUJ0787wR4iwFKmlhOhBhj/CfR5vSa9hUwhJEUt4eHOq8uXm7b3TxFN6SJovJzk2PqJoRpxV /URIYiJ8= X-Gm-Gg: ASbGnctUaiBrxdPzS1Xu+eZAE8CSO/8dydebLglr0//GhQ6v6DCljdUpGOekISPV2yZ Ajo8PlcMR86YYAum0tLy5lW4fLhAbmR0EBDXrbcdY5yCkpRylokawL8ebjXaxJLumRdSm1HvWYg pu6gH61wzRIOfT/l4UQjCzEEdOoRc5b2qZRDAlKHVfhDXt6/9F6dXU4zmrpsjJLvgsghgS3heKO Pyknj9gzsQiBkRyo19gA2vCpolhtoZ20TMSz0YLMI7MX/12Ii+gmyRr+LPPSwja4wq23L/5wMZo 8ihmKPhfb7+JpJGmipPspERZkaBNl4+kAaEc/qaR3ZtuR8eosVh7mR68cl/YILQ8G7wnUiwiKnZ OksotS2Ruxe9aP/WYlGQ7ndAr+YkFL2YH0CF7omlnav5wfpY= X-Google-Smtp-Source: AGHT+IF/KKUfMGG/4yqONAnKLVz38uI4fT8fC++4eNAGnNGjJLZHcJoI89v6gELyb0TIzsw8qT8vXg== X-Received: by 2002:a17:90b:3f85:b0:31e:9cdb:32df with SMTP id 98e67ed59e1d1-32327ab3dfdmr5239796a91.10.1755176385533; Thu, 14 Aug 2025 05:59:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 32/85] target/arm: Split out mmuidx.h from cpu.h Date: Thu, 14 Aug 2025 22:56:59 +1000 Message-ID: <20250814125752.164107-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: 1755177846012116600 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176883; cv=none; d=zohomail.com; s=zohoarc; b=XBM2SqCeQPWuK/ZinvMEHpVqaeC4SAcixAx1YSBSMnfZNQaWWlPkmAMYxyimVkpaUJMGOR7152TcV9e7V2KAeq43ERFKFPebcFIv8YfjQyQYW0BuMnBoZZdllRvH99yglopb47PlcIU6l9BqwLKzFZaFYJdIK9FR9b/iThBWnJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176883; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EbyUERQdqYPEwnGqMNfJLK0fIa1Qiwxd4WxE3mzFNtc=; b=VQ46B+ZIO4/pbAzZ7LPzc9N8K4rGOZ/kJ6meN14+ktKYPgr9tHXBIOvSQej+wVtiAOOW5bmLCVONJ4v10u9fEqKA2RNcwo3/IX4oX2cQKzbAtCj8/3nmcyX0/q+kI5xuFDBjUlWrvak2io5FMx11Ftwg+lzNzWKHjaPMzsH5Hb0= 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 1755176883518920.5771038672143; Thu, 14 Aug 2025 06:08:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZN-00041u-S4; Thu, 14 Aug 2025 09:00:37 -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 1umXYm-0002fH-AG for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:00 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYd-0004R5-AM for qemu-devel@nongnu.org; Thu, 14 Aug 2025 08:59:57 -0400 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-323266b1d1aso559582a91.0 for ; Thu, 14 Aug 2025 05:59:50 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176389; x=1755781189; 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=EbyUERQdqYPEwnGqMNfJLK0fIa1Qiwxd4WxE3mzFNtc=; b=JSxIoEUzv8ZGonhUfBd6NHUemLK2Z5TwPPCeBsb9lu8Z0DhfmtFNuCVypHwBqDp05N 2X65KyKwL7Y6dE30px6BY1qGhlkS0KkXAWdRyfWM5rYSr+ipsa3wVEIC1425LD3Yi5Ji u3xRn3PhnY474MnjlmYHHR6aD2fDLlhUPIJMnC9V723ueB6BFGYVneOtDeSBxPBVgTh0 3jVetbQsjVmLB7ksZUyTibVxXAUn5Kaw9lF2HDEQw9gv0jIHzBcjgP0YyUrQlKDtB3GR Hn2RdgCZMUDveIh5sAwZ7VpVTg9/LeOBpahvZAuHvKCBJydg0v3Ime9Tw0Cc/XxFWvBJ aBNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176389; x=1755781189; 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=EbyUERQdqYPEwnGqMNfJLK0fIa1Qiwxd4WxE3mzFNtc=; b=riKm7k0b7YHe7/wZQZroAk3OUR3CxlvnKrLvFPhnwslMPVRy42anzVIk94Zjk933CL U35qTb10iPefbgIuaWDzMeVWWcHqNJ5z0p2eLflewTQeIKSzi4LTTqcvm0/fBuuyN8VO OFYrSXLoTYFSIGa1lr3uXjZEWj3ULQMJ5g965u/RWbqOEVM3S/5Zg/crsOmZAgo1PkRO IcpuckWrsNfb1U0FXKeAaqth/TwFvMwbnZXTgQgNGXguL7lwU85yvHnBMtycS5vkaARF pDjaExu84CQY2Zke9vP6eTd0Zet2r5/ydFpba46Prt06cdPcF+TnAmUbcXiLk4pk/Jc9 Hi8g== X-Gm-Message-State: AOJu0YwgzEjWJtrSR3y8MCPVOVylD9/0VSUcr6ILr9HvnQ+Eo5iJiCee Mq0gW5v2MaBNuGfaxK9BsKZPhgv+bnAbbGO28WmJPI1s5EguytynLW6M/EI1Dm/vPDVl+15KsE3 RHVD9Si8= X-Gm-Gg: ASbGncuaU+PKjZKn95tNrg5LXqd10TLo8Htv1GIZP8EbJ0Tzuhzdo5tIy3s5SOOhuXk 3lKRZYYTtqTVAhQdgfCEg4IOiSmwPX2oqhZOPcHoR4826dM5BktpKJav85gsOMneC8+c1vhjIXI +/QalaGXFlY6r6kknA706X3XOjuMqnREdGROllsp4OsZ+p//yeCRfjlChvmz+JVTO60Qx7Rc0qh 1csOkUcOjixoyHjkck9oCUJaLlY+VFW9uAy+7B3s2OJMtrXvROIUURGo42kGlyI6tx/9cM4vF0b 5Kv+OHCS1Xs4gDFdWv8UCOQXYGL4uT92wUq5om5mZ58MzG6ARkuGt1W7ZS8U+q5IH0kKgBXEnev diPLcKDeq2kl/UDiB1gy0QgwrVwg8wpAizwBCCF7olJmce7E= X-Google-Smtp-Source: AGHT+IFiLuG6/Oe1FbBltvAHS+HmHdriAAvjLDp8GmJWUSvEJDiNOV9W1v/9qRHo5NPCNp//w6BF5A== X-Received: by 2002:a17:90b:4e8e:b0:31e:6f0a:6a1a with SMTP id 98e67ed59e1d1-32327a71564mr3865759a91.3.1755176389030; Thu, 14 Aug 2025 05:59:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 33/85] target/arm: Convert arm_mmu_idx_to_el from switch to table Date: Thu, 14 Aug 2025 22:57:00 +1000 Message-ID: <20250814125752.164107-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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: 1755176885936124100 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. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176651; cv=none; d=zohomail.com; s=zohoarc; b=AMZpqt5+v7x3Z81ekNrFi6922fAkN7ug12O2N1mfdQBHCboq9k8dHq78sil7G5HmPi6ZJm181MORofJTpVR9RfThI1BK0NumySi/1kkrZEonSQiYA8x7mLrGllmfTyAz0w4PhtKZilWaGaw/Mw5yrvS/lCtRsIY6gwnUOtvisw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176651; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LQ+8y37epe2XnhLdBmGfBFQy97VMfyMTxB36KkE7wvY=; b=IJZzNRIh6SEHnJeJ5DsJr7mzt1sIzvP966ZuIykh3Cp+zPBQXvWGSJeHq3Pqeon7HkU4oWjez4ZeyTOOfqVCJTPKMMXm5YQE2Y/e2qpt+CLKcddmLSXHpnqGHfXqscKy1qk1TAvAPIkfqgib8+gG5qnrlD7OKsjf5053j706R5o= 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 1755176651496737.470309420413; Thu, 14 Aug 2025 06:04:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZn-0004G3-NR; Thu, 14 Aug 2025 09:01: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 1umXYx-0002rR-6x for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:14 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYm-0004Ra-KC for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:08 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-32326e7baa1so813574a91.3 for ; Thu, 14 Aug 2025 05:59:54 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176393; x=1755781193; 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=LQ+8y37epe2XnhLdBmGfBFQy97VMfyMTxB36KkE7wvY=; b=Gewqvjx2sCEVcS6YFSUmgzO/tpoEjZ8FuPF9uGkWW1MgUgCalyf3ZQo2G2KHWNKuUt 1yZzyNT4Tc2TTUTLsanEE+VoA1lz5ELc7L+tb6tkaRCsBWq5UzYL5ZyO3CZu9mHcfmzi UbcvsHaJWq5Ba8/9loSSMAiF1u9GIzoVDvJVlED2xBvVkNFhI+xko1KP/vS+lnXOprwt 8hod3TF7v/gHR2vSh7kmeaHb3iZvDr6HFdjLR7Hl6g1uUr8qaiWlqelTusLEnHTKfsyJ MnDYffKowRxZJ4Gz8LmLztr9SYC9Uua1UUS353ACUtuKoZIhGFRl/hkM7f83BCHBrpKb zwGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176393; x=1755781193; 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=LQ+8y37epe2XnhLdBmGfBFQy97VMfyMTxB36KkE7wvY=; b=XA6bAIk0xUrRhXBkhZPKyzoVsO2TvtBrZ0UZKF4aRLXAqi/aScoNXRnmcild096FYu LbPpPwoPyeocVFY5g3pkgz9UUuF4rYiQuRiRjvkhAKqDarLQCdyI/bCABMrovLcz68jL OjROWErQKWBWZ1tq16fW2i/8OAEHlpm1t1IX3wPRhbtsqowafmSyG2fqzQ1rWp7sgKst ztx+GesdnSaVbqImzS/aXNhaXAbpmDwA/GiZyoc9W7tXJg/if8UVhrYNAcQBESUrxSdy Q6Uj25uuXEXcZ5zxtWa7Qosqq9olMi4dVWnNxa2qfYTcDPCzJ5QY8j/wCs+UP9j5CYVP 66zQ== X-Gm-Message-State: AOJu0YzM52LabBYcahbmtFg49Z9bYw93/AXNGBIF+6r/Zh84+pCkeZ4i a8f1kJUEKot3HXafAdEzRhIBiZCCGiTFqp4tUjfnwol4EJnEpWVwWHPFrKlXY1zp8NsqohA0U39 eJ1ahc00= X-Gm-Gg: ASbGncuTDay7r2jj2yNgTxLsPZjw3AkKQCuFIGSutzJaG5ls6/B9qJcx/XRTP9EreTC G35z32aOqHTwa6ZWdvjIdQ636Lbxmed0o2zIhV06Rg3zNyXtl6CEgm3J+P/6ZPNRLnT7IYrlsNI uMWGfK1L1IQDrse8rdYmrJ7kNKVXrIdj3PQtDCgnYX1l/3owK74T5t+LGVP1AZSkJ4RtFiFGcdW aqz6haJi1r2lfTlTPXyCjPmN2hZepdkDxiMRXQhCU6QI2sD3b9sIGET/Q7a2zUsGIMHjEcIEowb DdKa2i63MfvZB4T5o4uvrgIBwD+EylG2UJbuoUpqowd3+zpBXbQ06/4Qk37Z1EpnAOXWyoAR9x9 Nbrc0XR4DypBToQpnuz3BX2DbXh69zFcH6Wr7Q1hRHU46aq8= X-Google-Smtp-Source: AGHT+IE8V4EEeTq15gyskiIlRgJ+g7LmxSxMu1IcZUmz1XaZ0P0CgmCbvxtqbXRi/X74E+G0pm575Q== X-Received: by 2002:a17:90b:3d92:b0:321:38a:dd17 with SMTP id 98e67ed59e1d1-32327a62f91mr4812417a91.20.1755176392677; Thu, 14 Aug 2025 05:59:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 34/85] target/arm: Remove unused env argument from regime_el Date: Thu, 14 Aug 2025 22:57:01 +1000 Message-ID: <20250814125752.164107-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: 1755176653229116600 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176969; cv=none; d=zohomail.com; s=zohoarc; b=jdAaOk0gXvAGCDNXdFBrHVBDDdybp7V3okrN4a+4i9fcwrqj+F+51kHUweIyWch+g/e7NiZczNUYdzeBDx6abAubDkN+orzpXrVsIkuu4FYUDUiN8+DsAlXjRgFMkWWGs05I7BycOlpqdPdYWo8HbsrtyBNIlfs1Psd9JcgYSoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176969; 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=O80cWQwrptcZ+GfZHkOSt/Oq4AweJKy6oX1cDI24G2U8VLgVoPkL5rDpGJCCLfvGumLCl104ZMM6aPyt8gWkU+suLW+luh0jYIcuMb2EW8awa35MFfq3He9QSGHxJj/rKUn7DHa5aZ02pkhefrIfojuCicJUpiWRp3nyNmpz1wk= 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 1755176969974579.2084124961382; Thu, 14 Aug 2025 06:09:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZF-0003N6-70; Thu, 14 Aug 2025 09:00:29 -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 1umXZ0-0002yC-HY for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:16 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYp-0004S3-KC for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:11 -0400 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-323267adb81so1160116a91.1 for ; Thu, 14 Aug 2025 05:59:59 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176396; x=1755781196; 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=B9IGs4F2yu/tm1hfnh4GXbzPXe5VSWQnJuBGmMMmy6o+DkXuWR1aF9/QOi/MA7jrP1 UNZfVSVctTvXJhRT7eebAVD5AjGtaZ6thDvRZwb/pO69I0QDXMY5pGXLCMdmdfQjrfkN AD3MazG7NPJWpTqPC+pQOpUYHQN9typ3uoWM2ZHragUl64bL3Q/hsOq2M6PYCljiYbyz 2aD3LBeB1pYBW+yRPSOyVgInNCr6EcffS0qW+1PM8yYRosnAivST7TQbH4dSFfZMaPnw DB/RJZsWD4SXzSh0vocTR/szF5A5Rghcbn2n5QhijX9rtKHUOIJJJQGDWoR5ZEc0OGle plbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176396; x=1755781196; 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=BJ3Xgm6sj0M0jyEAqfwmmVmHh6HySui2SVHRnxTwt6gAEUeQ/PgPdj7jDh/01jhMO5 MNzX9bBwoxClgQrUBxigaulpTVyfK7+j4dPasMZ92LlZfJYfYADcXfviIt/2HTaJtp41 P5bwP1PfTITTLJEKVY3uIU5JfzNNvDqPM/WXnrnR5xBwT8UfX3Ul6dfoVtQglJNM5TSN DL4TrMwgAaxeDYFd0HhsqQi4XMa6mQKTK7cLXoXG4BAQo1gC7J0n28TVPxEOpHbfMVvw vFkmX2sEa6QdnxLgLQTRUhIw1O1Tgrjr2zLIMBxfn6wShn9/z/OynCpRne/wdvgQ3VLB SwRQ== X-Gm-Message-State: AOJu0YzpNqefx0H654gr4a6BkTRrNbbxe8UKcU3hqpQFyPkmLP+UoAtI wo+Ab/i8BvaHoRAHk9nytcfAC7Ek8Rl9pGrCnZzUBYk9Vk6PGTlZwRDOvaHCXKKjd+igVsWE3YP 1wbXjduQ= X-Gm-Gg: ASbGncu0yDmmwq1tsHphAvV74Nb4M0/fFpnqs7bUiw5rtBWk13f23k4gLa+E9NCO2HH Kl/hiGz7mPqtQU7i6Lfhca7eBzq+P8Smpd3BtG3gb7vg5tC5qKSwwoOkGRp6Y1VGox3KORpki+I 8bhepxXaBj3+Iv8yIyML0u/byogRh64rUUtjvNe2hKa9M1mtTxVfCjYASnl7hgOlTjBDZqyFBum jWhihxtJMuFhvNX5wlt8uFqB1+m/4vBUkITI+J7l1023pfNPJdjkRAaBXUE8e3DqdQlWqMczRLc oeaaOImGfN7kvyzdhH+WoD39aXn71Eq7VxhDZ/tiyMKZ+veEynZe1Er25gynNUZ6JZ2Ccr9rAq0 52BKSz2je0neh66PbQfhZvxQ+gKhiql4jCCs0vPo2TV5o5hw= X-Google-Smtp-Source: AGHT+IHydQRiQWvuTUx+VAeYs5iBxaim/qM6KkhjeJwzVf4J5wIGvSZbkXP/XKpE+RwJ4NPABoF98Q== X-Received: by 2002:a17:90b:3a45:b0:312:1d2d:18df with SMTP id 98e67ed59e1d1-32327a86d2cmr4627140a91.23.1755176395810; Thu, 14 Aug 2025 05:59:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 35/85] target/arm: Convert regime_el from switch to table Date: Thu, 14 Aug 2025 22:57:02 +1000 Message-ID: <20250814125752.164107-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 1755176972659124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755177080; cv=none; d=zohomail.com; s=zohoarc; b=nRLahP3VqvvgHIdEtasjDdFlyYrmyYXxQaIYE5Y2Fg/uHiv++fkhX+OxkIBVA7Xefr5uCdvTi+qu11attLCwfTJQ5qytaMRk0HSC6ifNLHeybgij0uTsuY6PqQJ1Fjx+TXwK8h/3uwkVWjNf5qy+edU+lCAK8X5udG+JFMrlQlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177080; 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=WxawmofiUBLJZvWCEk1D1W0qjEezEWesHAA3NZR0rQ7R2mEAQi464RUSzTIWPfoRZlkXa2FlcEANRghV/2q5ii2b0tm3zmCNxBTfNTcU8/RyI2h1X9fp942WrSbPrjvQ04ie5yHBEXzehjE+/Ox/pEnjWhWWctuAQewPgdzx4P0= 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 1755177080171652.8869234066677; Thu, 14 Aug 2025 06:11:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXa7-0005J5-Jj; Thu, 14 Aug 2025 09:01: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 1umXZB-0003C7-2S for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:26 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYx-0004Sb-0s for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:24 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-323266d74b0so803808a91.0 for ; Thu, 14 Aug 2025 06:00:01 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 05:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176399; x=1755781199; 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=kWz15/k5Hj3bUUpXt68x1Mj1Xilzo+SkroISuG1K/8nVTmbZj38VWwg8NUnmskLVj7 sMT8EZEFDY0E/K0uXT8fk5rx1c1ZanC1yNd4K9SBHOSv2JhlaenvSWBZcaaXYq3Hrr13 gUyP0ttC7sINH0xjkIYjtZ1SZPWfmITSqL9oWRrNm34zWjfwSuWoPL03Pc6PyEeanvdA bz7QdzYJQJGyOoKJYmOjQLpaNaIY9iu1l/rIgbh1F0jME6QOBVXxhxE9PQQoU4zAX8RX YjpPRw1xwwuRF+Xu6pkKODCe3g9LPpUh10pAcBzLWl7xHCTB5HkO4ggAdIvV3O0LrINP kjsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176399; x=1755781199; 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=UenjEhJzEBZwf3qCFmBktaKJsagpu6dIfXbeZ4+JYTZ2oh38LX4outI3ATCCF+bZ3d eMc3D+V+ILAZ9mM5bSB32UBii8wAs693UfWmYwUAeC9NYKswjByDndNiFEVj7xGEfdZh 37IkcSS0yueHpBTHB27fb61gaP5IN5as/i52cAMIxhQ2wd49CpvxlATqBegK+7GLmFnP BayDgeiZnog0tMuCvW7ozcz67/v9rLgraFB9xErTL6EMjUjz2bGGLR9Fh2Cj+AiSizi4 KI3zO8UhB1knOXWankJWguaJJ+abEzMEobU2/pbv3abh2pA4g0p5bbV6Ha6j6UfE/jZy Tv4Q== X-Gm-Message-State: AOJu0YwUR8nQl1aYAKwRkAWXgOBjMrcHmrg9ReCEiJQKcgpqo/g2UZMm pf1ITwzbnIYqwvEd6qrffIjPyEObE/hNId8tiO4ABxJ1kG9UxFOjKMFakw55S0eh3iPSdiv+MFI u9YIe6Ls= X-Gm-Gg: ASbGncuHHyw0oGYNW4r2GZIFAWKSNvi7SXXwngzsA5SCI7ZuhG22ze2Zs0pFXwonn67 X/IE6QnjkvNBp1dNtx++WT/mXhwl73VJNyFGG5yQoDTlZDjXMcuzul+e6R0cYHeCDBXffFL57j0 WxnCDtMhZPjYZ9Es8ywseLUxrojDz6P2johHb2ggq9HEARsvnmoNOCjgTXIghalZRytXK6jzTfl x97Qr1pHMPAYYOouVcLb/FwQpgpVO4MPBvhDaa6BqYub0NMhYNRkD1mFvYnKsSIleQVb3OznxY6 LYemTXcFrJq2y66DMlgQz9YXjXJUoLxfNkSdaGred0SiAgqKQyKLORi74shye8QBhoma+pU77bp WX0YlOiCnldRHF1eEGl01S0yDmhu56FRUYCTiWENmnx+WViQ= X-Google-Smtp-Source: AGHT+IGt5iE48eJJ0d/V5uShbX0QKnwKM91+FOHwhmYjiUWIm4/FXo0N/fxpL/yjNs+yxmuJXntLgw== X-Received: by 2002:a17:90b:4b4f:b0:321:4fb4:2e9f with SMTP id 98e67ed59e1d1-323279d8795mr5503916a91.14.1755176398738; Thu, 14 Aug 2025 05:59:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 36/85] target/arm: Convert regime_has_2_ranges from switch to table Date: Thu, 14 Aug 2025 22:57:03 +1000 Message-ID: <20250814125752.164107-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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, 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: 1755177081995124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:53 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=1755176456; cv=none; d=zohomail.com; s=zohoarc; b=VH8em+aayx1CCGhwWtipr4vFsBAtdtGoucZQrVAtFdFg3PfuGFop3DNwDHwog1LpHQjpAi2A0G/0cD0hLm20UlC6rS603xZ4SKrjiRHU880xuWn8QAWt2SokAcfpDNwoo3Z6KePONClxRUkuM1Yj5bPXRTRy4jb/oBeSOMP36tE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176456; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W/0IpRgg6t34zaimtrRMdlDr3oUmrGBXYyd7BxUgZh4=; b=eW/ybmGtqoRe7sTvKlZXrd0IWYWqsmcw9u2tDm/5ZDDRqjvU+7NQjwPhb7dkgQ/qacea0IsF0zpVYxTqIRrocErH3+LNmbDre430ob70J8rGUbQBHFzJvDcjlurDHfiJl/snZKYHVeeL4FhHBSMGe4mmv20vGcdNhismOejmfNg= 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 1755176456630430.6731238679025; Thu, 14 Aug 2025 06:00:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZ9-000381-B1; Thu, 14 Aug 2025 09:00: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 1umXZ0-0002yD-Go for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:16 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYw-0004U9-VU for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:13 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-321cf75482fso1870772a91.0 for ; Thu, 14 Aug 2025 06:00:04 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.05.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176402; x=1755781202; 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=W/0IpRgg6t34zaimtrRMdlDr3oUmrGBXYyd7BxUgZh4=; b=Ytsj21XNAg+1gqn6o9VdkWHnuX35807UqFGg+HqdlO2V3zuwTfnYnbNoQQVkn1PwQG TmQXJslYzBBBYZJUKLdafqbssk+tChuaQTK9aD6VkX+MOqgACKfQxTF4hFV3Alyb9WbA hiF+il1xZzldiJIeIvfKArgQS5sl2soWnolNkJITnDHgaudef2d7PC44ef4kKMsxIiMx d38UZj4TvHc9koMQS49iK/7ADRNrvsGHemiZ5CMzQPcEkXMtethX/F7JL4LKd1IKF61q jbxggA6Yu1clhoYA74znY1UXHUet/cZNtQl8MKLLvagBV9+JT2Japd9n8M+JM9lXRyG9 ILXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176402; x=1755781202; 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=W/0IpRgg6t34zaimtrRMdlDr3oUmrGBXYyd7BxUgZh4=; b=vb+Wkg6jug9fowRo1aRVLkITevo51pug8LMV0OS/NebOZAytKrpoijLfXfTUCUmFQ9 mYx527dO8MzvCF3h4d01Ue9LLSMa6McTrQ2SlC4608Q9e4FOOxhHL8JBFhYfxHMWf6jX KVPt0J2YfCcC2EQroLjfYfOM8aWvEwpgfVoNfS/5HbCMkO1Q5Qe6sg6BNX1HIpkvpzqn tLGCG1Cpwz0c23T3k1M3yJ3dtKvosGrkxQZDJnFk+4z4fJgPCmVyNT51GyshtAnC/xI7 Ri97l1ZZSci7SsartZUVFKROZIF/eBDTkBc1lbmrKzkws8oav7Vd5r7i2FQsUh9Xnxlq 9whA== X-Gm-Message-State: AOJu0YwD9TTghfPQ2P9ZC+tEKYdh/B2/VpXUKdsCrsi7qbxRxyIjaQ0a HWh1sJ237ZMDJ82FzzkxYt6jjY+gXQ06+MVly+S5qxPEArkmPpbAMICWQyyo/71OAkCHYHI10KT 4TELZTS0= X-Gm-Gg: ASbGncv9GlFB+Sm5snHZ6owj332EdDaRnPxRpHnMz3O+lgFJK3uA1jTbRsTq0wZtw3v tSnBfkfc7jIlgVufgEaJ1j9PWTgwrXFdYhJjJqHSCy2JgSm2h3fLwr1wEdOgughFvHRuXfk9VoG eWhu+srTeDePEDCT1vNXzkUjdhswqKllnh6UeaRTS5n6S9Qm2KWrfYQ+f0LONVgmxB4EzyRTjsq 6MBeIgXCQ6ntLtrjkwOLiFmz75Nb0PifdJAUS+eRaQmKHxKqSZZjAU3ZJwkuTH7x80EXhxcXESU bCOqoHS6JXlhcz77U0jQwzPY4sy0uycJXci1QyBtuepQYRLpUxANpWsiIb5PdZhA4jEhstDGvTn KFgh4HHf/mszEqb8HkF3yFlwI2Bd0rX/OQcWEptyXA1VJAhY= X-Google-Smtp-Source: AGHT+IGt5QpqCa5lWoGezXXfy9akMqbB1GCv3xNXn4zTk2H/Ex+69winOrS5ok6KAIb1OjAMal08XA== X-Received: by 2002:a17:90a:c2cd:b0:312:dbcd:b94f with SMTP id 98e67ed59e1d1-32329ab24f7mr4201738a91.11.1755176402488; Thu, 14 Aug 2025 06:00:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 37/85] target/arm: Remove unused env argument from regime_is_pan Date: Thu, 14 Aug 2025 22:57:04 +1000 Message-ID: <20250814125752.164107-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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: 1755176460114124100 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755176755; cv=none; d=zohomail.com; s=zohoarc; b=Qov1U2QXxXqHXVMNiNayWgloa5yb/BE74jrKLrIjxqPhzciOyUiQQ464wysdOvXh9C/MsujxtwYnYo7hgTqHmJqJen8iJvO6DhuZuKVTMh9IJrIMVvgEVVXEo0Z5mKxg8Q1FJgLzXuWWEQNIfQIDsIJbTirEkOyqn6ICzghmcKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176755; 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=iBFvbG2FoLi7Y6jW/jzZlaEA02o3U2gu1QwaFafajBKNQmIrgm3vkrLFM9P7bcPLHsEUaY/ichfPA20RLivawI6IBPLJ5C1EEfiej604ihj9K2CNYcb2adONp2sy2stgSPypeAWifGvepGe+FIDwwR6eqe+YKcO1/lMQaPNPJ9Q= 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 1755176755727867.4136339567436; Thu, 14 Aug 2025 06:05:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXZz-0004dG-FA; Thu, 14 Aug 2025 09:01: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 1umXZL-0003ym-CH for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:35 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXYx-0004Uh-1Y for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:35 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-b47174c3b3fso521310a12.2 for ; Thu, 14 Aug 2025 06:00:09 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.06.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176405; x=1755781205; 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=MhrZGxs4UbHUpY+6FKdxTjZtIO1MxnY6o6jBCmhLxfKRCmbGPE61Etzxn/W0etlkH/ eeHJUvbPzOG0Ej6bU+EGPq4cS8KRkN7hjlKYBxQ1zV44RQ/OjbrpOHs/78JO4zqVELNl 0VldC44RJKhZn1I5vWFoFsY97ifyH3Llb902XtOfg+lYzcCiPXHAoHfe39e5IiMYZowy wccAo6oeDlyuC27P16wUEc+S2mSpu5j4iCkavmqftwcXN65vqV810W1YBEIFfdHABSLv jTtKlNqucpRKN7GzXrhVlo5LELzdryi+eWM5LVMkELWFX1ciBA13jSzzyT+ANhh+IOZC La/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176405; x=1755781205; 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=u6RqJm7q8cxGCbRZaMOE74oxX3av5DjuaJkXAA0c7Gj414MrxeJNYvuutTFdEUs5Qv LacYgRSnGWJ+WJNTddE11FIDUbTQX+Bgj5heJGCo6TTLN9OoC2TudmbEQpgewb2N/KJ6 QUSB0TgDqv1rqkZ+KjLfXjPojABXRnkzGK6k0amxbp64/VQB8hhWrCsAAS53yWoriNLP bHJ2RZCH7/6UyIyrg+LWL1BOGC/ySAR4ktjVza93mpNYvLLRaQ9Cciah6sIj+5+hofYS MgdkVd3dGOs8drmg49pTyCY9Cs9GkicJAMOLdBmKWJVg9k4kIn8nVsjMHL6q/M7fBwqb qOhQ== X-Gm-Message-State: AOJu0Yx2yJ2Jw8ditQHrCxobQUrHArEIIF1kaKCW2tgrHCGYrrFQNXMv 5YrLAqisvlnngWJPPWyOJOb4mQEBXwzdO33xtizmKIB7NuwXDRd3ooaMCC+2U9XEw74YIBkYHUl byjQ9Ax4= X-Gm-Gg: ASbGncveINQrK5wDUaanmKN36O45S3W/VngdurVeR6dk47isKOpGZeC6sjq2lm186Rh MQSW1dqkNZH67lU3ysQWNnVPvdWhLCTDQBrxkSGC9NMkmwnCCJa+DF+c9UtxVf/fpWNKK4SJzTF 2LwzqkGm44gmXdwVEkAgzNLTq3h/Id4KQQDmROyKNyVLc3//6dGNqIkePXxpngNEIRUaA7rRGmk fLJzfITwHCSElF+r7/oyVKkn+kIBo1tlNQs2S/SCsJWgdUSTRtrDE/w0o5Icnfco7fc18k+Jsqw tKJ/lf3iXaMZDlTkfLHsT5P/sJzBXNHU9ajXa8deG0ozYCmolIRpe/dI1Q0CuXv0E6I6FXXLhpY fm98cEIsCyY6oMZ2gXDovXx4kOdyX9TMZ3oAHY0Mp1nJMtAM= X-Google-Smtp-Source: AGHT+IF1feypvFahF1ADfsXFSA/M8KBqervXiIV62lURlMYRe0V0X8puestAwBQep2iWCTihDh45hQ== X-Received: by 2002:a17:903:a90:b0:235:c9a7:d5f5 with SMTP id d9443c01a7336-244584d6ccbmr42660365ad.13.1755176405274; Thu, 14 Aug 2025 06:00:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 38/85] target/arm: Convert regime_is_pan from switch to table Date: Thu, 14 Aug 2025 22:57:05 +1000 Message-ID: <20250814125752.164107-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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, T_SPF_TEMPERROR=0.01 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: 1755176758527124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177454; cv=none; d=zohomail.com; s=zohoarc; b=C1pP/z7+sy6hRqQAkNHSzfqeG+fEQBMEA0iKGY1O2S3Cp4L/6n8YUIR2VBlErZApXfd9yr0TVy3RTeoPhZ+oaxBsfGsKsmD898zd9LMo7jiIMGflkES3B1Xfa0B2LUOFIl4e/3i930kic802dAhRjjHqmrnoxMOH893L+RwkWdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177454; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SL4FJWjHVfku8XpR/Kx1zBnrguDoHqeN3UFqZHuwYME=; b=TzHMVbiUJeaAq2Y7ycfYArO7JQdENz7SjEtrS2RUWj7MA7SJgLMgU+bYi3uE7SS52bhb96z9b3aOB/IrPmCvrGr125qxBM1imlyB1aMRmNvQZRg9/F2i8IHEc2/Y5Z3ZPg70LpSk3FgMiRT/g3gSMGWF2fJsinFSnlNwcnAkjF0= 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 175517745492163.82932625729643; Thu, 14 Aug 2025 06:17:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXaA-0005Sc-Ov; Thu, 14 Aug 2025 09:01:26 -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 1umXZH-0003ef-Sc for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:32 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXZ0-0004VA-7s for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:00:31 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-32326e20aadso1162680a91.2 for ; Thu, 14 Aug 2025 06:00:10 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3233100c994sm1766256a91.21.2025.08.14.06.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176409; x=1755781209; 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=SL4FJWjHVfku8XpR/Kx1zBnrguDoHqeN3UFqZHuwYME=; b=dwBMhiMZxoJ966dvPv7yHuLO+4yu+V4m4E9Yrut2uYB1uR5i1Twxey3tvsfg0FTDrk VBHkiTOphldD1CBVw1E870gT9nrTalEOBNY8c5ZZct8uSxc9kCGqls36bs9xn5NzrDaK Q4lR22iJQvh9mx5I1dNYwYLLC2cQVcTPE3X+4L9cgcT6Rvy+4v9aj36WUONSDU4ZUCEw OIpTvsXw6vNkkNFGLxDMx4jrssOzAc1KUyfLW5eq+Fu8gUL4hBZNDl3ixMChZ5IRDd0P DAXlfnF1065tDAFMjdzGbBHibwNUjipv/IrxsJ352UNYSLewW200vB4PgFeQBWa2ZBj2 +1ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176409; x=1755781209; 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=SL4FJWjHVfku8XpR/Kx1zBnrguDoHqeN3UFqZHuwYME=; b=hIWDcCSLDKyradiiUimCsjyZq1fElnGVfD+YpVLlwxWwrpVU53v0+ai2upVP6/ZCQK 1EwQ4x2/HNlf3pfwDudsvxYVPilW2QBDg1IW/hwMphatS6X7m5YnS13BkOlGMoIiIzAs vyEv/HcfjMiz8kFRKYC5JHsW8J/fcviUqBLhGjRd/Z2SOYkOkDFz4+gEEluQdkq5rJsq ihKHS5m1NAh19x/gC+n57++HewRxU9+sCrDbL4Wx5Xc+sswjJzDF+i94K94mNYmHzyug +cOiQ/9b1uvwrQ1oTlZ7WnRaygjn8fyZs6R4/mXN8llgmIXpcsrKwzDBYVizf6nDgztx SE8A== X-Gm-Message-State: AOJu0Yw6VeFGh9dCfqGasOKUt0IlzwrAetnw6zr7fJQ6VHd/e2uE/0nO RmLFY4eqnrvgzBJPaWxhQ03PzpDigExl2xhe8uMWXGqOLMcf+qKbTrkca8Bbe9TdqZvnUutS85x mGTohhXw= X-Gm-Gg: ASbGncsbrIUDwD6n8zBhJVC9WH1vkvRFcBaJrDPmTeXX80uwj/LIFYrz2Eb668pAb6K 1WDaI0YpBCkliHM84OV8ZVDxbVEMF4cKSvQRXz4aPEXPScaoUUzNJEhnJRhdc3/isNk1zXoT7z8 HarWYAUAZv4NcvR9vbYttzBlO2pQHthvQ3Z6LxcvnG5wK9uPOgZWiCGSBKEBZ2GXhG02wzwMsYn UAb6fq3pDZMv/JpJxwQkK0cVfAOvwUVHOy29ZAIkT2k2g8RWVJN3jRiTUbvs7+7LP6GuCCd4mp2 REPu/WyHOaCrRwzBdy03MevaonmhbqhLqQ6NPEpzfzAKa9lR06bTmIychIdDqOVEgvmffU9ZO62 zVY5TMfW9/xYHE1POFGTc88s/J/1ptx+68PnFNsjtXpeJNv0= X-Google-Smtp-Source: AGHT+IHHixtE0CCLByu2UB7j6b8DlwqRsUbmd/yqYtQESdCITjnwH38cxygPi1yri5123x6Y0ZNssg== X-Received: by 2002:a17:90b:39c7:b0:312:1d2d:18e2 with SMTP id 98e67ed59e1d1-32327a51eecmr4877407a91.20.1755176408943; Thu, 14 Aug 2025 06:00:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 39/85] target/arm: Remove unused env argument from regime_is_user Date: Thu, 14 Aug 2025 22:57:06 +1000 Message-ID: <20250814125752.164107-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1755177455924116600 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755176736; cv=none; d=zohomail.com; s=zohoarc; b=g7d/BLDgElakXK8/SA8GNy44qsYxiW+rMKrPrX4Y6LbforHcHfX4NQzC65frm0aE7H/28SYHM0rJROiUo6TfXHYARoxUw8KG4QztdVAdU6IjOYZ48n4C9s5xeNYKYLDQ3e3dnAthewhGjJp3Ngz8azeRP00T+xIK6qGVGnBuVV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176736; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+pIUQoqIgDqvDhrh04QrLTmJNySBZbca5o7+NnmcCMU=; b=Y2+Irs2zG0+5UkcFwf7bA9aQ311O7Dzs8SLZb5Hrj/oUSGexgFr0Ktw82gNGPIdQ40AuNc99QMsb7N0t/QcDh4DCz2Uoa/9PM1d5e91vBs4XtTOQU7PKyhgEVw7kRmv0lt+RvgC0lrw6rnyrDeWMJUPubDz9h2DPi4o2O994+pA= 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 1755176736313433.84836546111615; Thu, 14 Aug 2025 06:05:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXcC-0001HB-Tp; Thu, 14 Aug 2025 09:03: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 1umXc9-000196-5J for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:29 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXc1-00051u-F2 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:28 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2e88c6a6so863427b3a.1 for ; Thu, 14 Aug 2025 06:03:19 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176597; x=1755781397; 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=+pIUQoqIgDqvDhrh04QrLTmJNySBZbca5o7+NnmcCMU=; b=u9FM4XTHlW/SsDwTk6H2ECKaVd+GHWNHqumi/nbbSzEuKoiNKj6JW9HdWdcObGK1Zw cb38RjE31zfiO832tybvNuqPIWOCIkSnKpohGcdTUw4O5IQcGoc3svnWjhiI4fGm1xtj LefUT2Dfp1lbMthe6dxPWt/k7viU33kCzLJx0pyVduqXUjTHvRiGqXyCKZW6Ki0/YqRh vPXKY6dvSpx8CUvySlhPRoA84u7kJE+zxhpET0wiNIpfE9nUI5rOo141zlNnh+4IP6BQ Wc9omnIZU2k+SLChO3mWr+X9m/vyYcbWxIssiBqXhTLZQSn1Imv2JYkrI3OWRm89UnDQ kzxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176597; x=1755781397; 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=+pIUQoqIgDqvDhrh04QrLTmJNySBZbca5o7+NnmcCMU=; b=DzHCxnAwJRuUIybls7UsihMLsizy/DiPIHoMxXJCt5FTso9MBpKS5zpqtik6OkPn4W sMvp8/+t/64/2Vs9/7WZrzheeHGD9mhz+C9BivcHOe/vQNKk+P2z50qBLrhNrEKslBOZ M/6rDsnj+bzfCEhDUwQdtBwpd75j4P0lkXN9t56D+X+J/5My30hn4oMIkn1RD+1FMFiA YPvk2snjIYLfIwFMhH5DANeBJeOxx4ozAl5CeyXscz04iUSQA4CYfR7ARpKY3rzk29IC Oo1OxxDc+SHxOqMV7laugZ5lMwCexUQCYSh9na5VA/rfsPB+JR5Zz4yaXS9a7XWAAju0 ezfw== X-Gm-Message-State: AOJu0YyPZsTEdxvD80MaIxK2RevDbjiEOwVaHIOWvjhinQSmnlLHQdrK VngaHlVv/x20eSvT9sr2djQsarbkDIwDeA3yLJVqrm+89zDVfqNwwD5k03wJULnlZdNL+UhxwZL rIrbPNJM= X-Gm-Gg: ASbGncunlneis7iJ8TpLjCND8JX3PjqS7jQhhzCRM/TcS/d3bXEV0lh+BAU/z0wiygy VodeqFtgD2Vdvnn2XvrHJ4P2/mkmpsPG8AZfp9ODt+z9jMzkzXZIGeFMwDa1mJAzNFcWBTKr3hf J55Pz3bPhSRg9A/nZgc9ggBHUa5JIwp6PwJmDHXKF3DvUoVWGpTpASRBta50lmUlcV9Vr7vuKC2 Gkck9QrXMTJjHCpD+bWriCdqxpspm4Yc/xtKcRARwhs0Q76b3Mo+m583ImxiK5zeGkgO0KwWm+v QJOQOD82LGho2tTO3I/RPNUCTI+JPUO08gNFJPefwGpJ16WjzXBmgf8TOW2vWRzsjnBMQM4bmBq LV1wiGqotsh2+HTgoHMFRHyjrA5rmvIcJ07po7U6Q2FvNBAE= X-Google-Smtp-Source: AGHT+IERID6z8JeVXdbJdrFkGDYo1qDrLz1HxbvTDZ6AFlzHYl+QLndd1KLK9PP4ClqTHOH3ZFLVPw== X-Received: by 2002:a05:6a00:1a89:b0:76b:ed75:81a with SMTP id d2e1a72fcca58-76e2fbe363cmr3510973b3a.5.1755176596922; Thu, 14 Aug 2025 06:03:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 40/85] target/arm: Convert regime_is_user from switch to table Date: Thu, 14 Aug 2025 22:57:07 +1000 Message-ID: <20250814125752.164107-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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: 1755176738395124101 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177319; cv=none; d=zohomail.com; s=zohoarc; b=mxHlthkNbkawmclBapdBAEp37Rv95yzNN5rHCzuP59yVQHdX0vcc4JfZzQLLmIEj5X8RfA4ZIipB36w9+86sKhf/fKHfwnKS1tSlnsk7Ef/K0JNamhc6gY2rTMlPXL3lgVY9Pb3JUbGIzmc3ThSFDKiIREROmjAtUPXxGy4Jsro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177319; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ufhXOkFFiQ9xg40jDZ1CMA8qL889kDviEVXXcrUgfT0=; b=P0NP5cQOgkG6IeqUNsr/EhzcgxoOdsOJc1wlNdhCYMd4hZbX1JVGtORTHZFoH0t2VFEPebaIx3CGu0t4IvynZEImJRA/PyYysPzoKBfbjAHO2OBZDS8dTAxu4RDuWFzX5Y/lNFfV+KpWxggLakQ/RZaWadWgtCTc7xwm5c+4PnA= 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 1755177319942138.27600129785742; Thu, 14 Aug 2025 06:15:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXcF-0001Pg-3Y; Thu, 14 Aug 2025 09:03: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 1umXcC-0001Ce-2g for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:32 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXc5-00052q-L0 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:30 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-76e2ea79219so1116224b3a.2 for ; Thu, 14 Aug 2025 06:03:25 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176601; x=1755781401; 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=ufhXOkFFiQ9xg40jDZ1CMA8qL889kDviEVXXcrUgfT0=; b=BUyUOkOPLXTJ3rY5Z/f5iGEb42YeZWbwOncEfoYcbYBcI0P++30m1tW2KJvyH0Gxv8 Z/qKmHJIUW6oXXVrKf/P64i7Rnhq0chpdD5pxwZ4Vq2Kt5CbLNW7s6qqFE/7+RtstJ+P 0VG9Wv9b+ENEkCZ+iN5ha40yEglu5y9XOLF4ks1AlS0E6yzOGMryUvvFfVVbnCO/qVu7 BoYKpdEE9nHKf2KsAHfIXJ0m+UnFojcgIM4j90cKrZ7zeboCLUyogpEDrY4oeFk7G3mF bZAiby0mqciWVknHzvq0DhsC9Co2PAAFCdNMTTnwP3R8O8PZdOkEg14eiHQZeigC3lr5 fgSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176601; x=1755781401; 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=ufhXOkFFiQ9xg40jDZ1CMA8qL889kDviEVXXcrUgfT0=; b=w1YExkvPaD+a95W3bueKOBRtcXJryHOLOQf5NJFbAGIncPBSgM6xs7fWBovQ8QROFl j9aAbEjnz+T1nh0zpD0Pio/aRdsGn9usH35dpOqOsfDuSBdqdYUqFDdsUINOtPW5USsO cCQPUMwSPxQzeAXBsk5Ext/ls4Ax/zDBDU1kj/kpFrshVvVkGF+aZaTLc59OZdZxPhER n+BAbNLxum4xp8I0rijr6X+jcjPld8iJbTT4joczH5yCLLyiNIcN1u7k1AUv3eYcDztI BeVUm+6Vcc0b84Hia3R2OkMZ8yHWbkkI0Q4vHJ6qwGRSUR1wGxPCCsZJCZNWeSRBq8Ls y/hw== X-Gm-Message-State: AOJu0YzUkjB8DSyrbkf7wxZXXcID0EQTVFUnrHd+AecF9wf/DrXZL6Hf 0GCuEz2ZVfsKzTj80rj1U5oZO6NlZWB07CjvzttKEge7Hr2JrAMsjGRuic3fFNpMRy+7dUnfij7 voyG8LFg= X-Gm-Gg: ASbGncuX/vvoje6zugnzOhLkCJ5wTy/AtAGSw6FYjCu2DjtJYvaeWcPXYRIgBXMcuWP /M0pkFBUaGq4kQ+jX99Wp0l+MTfd6b9SYytxtM76qhIZkHxbutbwGZvUp8GLI6RKMyag/eHNI8i LDrCwWRd+pDSmf/Q1qDJuWELRxADgn/NSl+XtgZZab7F6oU/jYbwlLBTrjOtFiX+DBA0IK8D1nn jfIQuuC5KDi3JUTJW2BbQZvGk0KijDoaC2ZZ44VkQ1lVQSpVbBao184ArOc+P11kj6EJjq3Go9h lqWK/7/c0mLBnQslPBRduryiQBI075y4rN1PBkrMW/kskLoD0GmmMO4zK6IUkJkhrHvp6ammK+Z 4kQNEQQV1PrXWcQjFP7e410n3s4BS1QZOck7Tj/9COzi4U+s= X-Google-Smtp-Source: AGHT+IFmDrAyz88bKgSQd69skwtjmu65pDol5AX9IISn7CYdR34qURYraJqH1MtuX1XvsnU1COb+qg== X-Received: by 2002:a05:6a00:180e:b0:736:2a73:6756 with SMTP id d2e1a72fcca58-76e2fdcf721mr3909277b3a.21.1755176600777; Thu, 14 Aug 2025 06:03:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 41/85] target/arm: Convert arm_mmu_idx_is_stage1_of_2 from switch to table Date: Thu, 14 Aug 2025 22:57:08 +1000 Message-ID: <20250814125752.164107-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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: 1755177320840124100 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177886; cv=none; d=zohomail.com; s=zohoarc; b=lUMPwbGo8craUJKznkH0/90ichD1w87oEjUJMk1WedwuoeDryftz6vZ8m3NzX/fiMvcCIAprjfC2lvCqNIBJPf4l/pIe7nmZgKemrhhQKoN47t/2OY1pH8tgX/x0DgY70OgEm/zGq4gtC/4tspCbYBPUGUk+C+lNhOeepp178Ns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177886; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vIH4ns6evSuoDle8SRNEFdzHb/qidDpm/3DmttrGIbU=; b=bGEELzRHnPyOLuW6Sgs/VqkMYQGjh+EE3czjoFlrrnGXT0+0hal6BIS326Fmll9L1P6zPWSBMy5QqfkQY13H79rzowK3yDSe38rf4jzxjDMSVBwrtsNUMJrrgRkqkG/R+5szAgAA6ITxnBPIBBtfFqOuP6wXmWRo8NWsMRBPgTg= 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 1755177885970801.2694743839676; Thu, 14 Aug 2025 06:24:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXci-00025X-5S; Thu, 14 Aug 2025 09:04: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 1umXcK-0001gQ-1G for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:41 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcB-00053B-6M for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:38 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-32326df0e75so776991a91.2 for ; Thu, 14 Aug 2025 06:03:26 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176604; x=1755781404; 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=vIH4ns6evSuoDle8SRNEFdzHb/qidDpm/3DmttrGIbU=; b=nzYltbE/Y08OOrRCNWNG14YaM4sCmMzwKLiksn9Rj4opSBgUF/bsuaxs6ntUH3wH8b qV7htzlECKVP//tmOmsmmrbtyUtw9Azj9uPqtz7CLVnxPG4oYMt0er/b/KL9kzoyREF3 iXpxH0OSgNl3lKjZV00ayse4bqsWJLLxUHeCxbzWe+rwkoHzsbOwZbqQ2KaFBlic/Vka 0K6nvL23Hap1GeqPMUAJoPhFzUu0G64zlt0+L6HdJnntlB7nyOyaGgUxFrdnrIXKBCWW cc7gqm4ITZL4C10DNILbKmIw/EaoiphRcimGYDa7ksdjDaeiReTUB4tm5e/yKiZsdpyq zkFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176604; x=1755781404; 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=vIH4ns6evSuoDle8SRNEFdzHb/qidDpm/3DmttrGIbU=; b=dGY3Qx0vBDH/PU2y3AA4xGtPnJcq0FDyTsj8lEw/x5ehbKtTkntK4SYN6WwU06UD34 j2RLhe+oQxuze8LsuZkaZ/KmS+FczYMNEAdQiZZQF+bhIurgKV+hopmCr6Yob4+mO/2O x1UpJ5BnOFWKKySQnHXRJblxy723H8VeKXTmu6KFIGz1KYR2BoOgOG0bgfjwYzt0hcC9 jsHlxauG30mDpQZuHCMXYphmrOCCyPAxstp53tok6YHxe+1anlu676dPnOXWb/wx3mR4 e4liBuN6jBUrvr9CundZv5AMmppUVe78P9gOMhszcgVmLv8bedj9tbC1Ad1hwXFTp+Ns +5zg== X-Gm-Message-State: AOJu0YyRe89DdbkfgeInkJZWmFY43wvHKgd7g45qdvyhBm1xNMVM86kU I67MpvUlXcHXs+5WlCuU6IEzyM5aYu8Jrj0btRs5i86ugRKG5SIVgdD3aSvRwj7WnwH+e1oi0L3 pem3Q8pY= X-Gm-Gg: ASbGnctaXq9PKqwRQJLUBwB4bmySGVqdpWjzpOC8W0LC53vpmcpfsBaFqJRUstMjiC3 z15fzUEUOb/+1AWPCQ9uGFrqvLyRVCO12sh4pDje3meJU5Cg3SgxjBuFtKE17JbUiZSRj6ERLmE NGRYIKhf4LrcZ1MMXIRv1GyGMrBtsDMJTWghBx8o0n6WfF088AkUPHouSv6H3oTPuLut+dQY30J 7OIrLKyD/2cDdTLI20aO8nv0n4DGVRT9oLjql8SQgEVHtafYozYeZv5yCWqBQXaU3JJHDgRjqAX V8q6NdijxryKFHxG0jilzm0ynxtWL0+23gprMFdOy7f2JpD0Nlr9Zfk+XG1wV594qrSwZF4aaip evLvOYKbp8EPyKCUBHCmeGwh+SviHXN98paONmBkJtdbUN+A= X-Google-Smtp-Source: AGHT+IGu+Lg15H0v+ZfanwZeO5dTaRzYe+6X7f8+0yF9/RL7ArxQcTNL293XNGrYqJBqKGqE0nFrIw== X-Received: by 2002:a17:90b:6cd:b0:315:c77b:37d6 with SMTP id 98e67ed59e1d1-32327b48f6cmr4659662a91.23.1755176604246; Thu, 14 Aug 2025 06:03:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 42/85] target/arm: Convert regime_is_stage2 to table Date: Thu, 14 Aug 2025 22:57:09 +1000 Message-ID: <20250814125752.164107-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: 1755177888403116600 This wasn't using a switch, but two comparisons. Convert it to arm_mmuidx_table for consistency. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177617; cv=none; d=zohomail.com; s=zohoarc; b=hMjw0rke9woTYj+DZGpenEKy9J4haEqnOhyj5oqM9LadMNabsq2KqRwx9B/RKutC2SxL7cWZ7IC6G0neDoesWSbdWq2MpH124SD01EgQAx7I2jk8labGNOTaXy/EYf5eoMqtoaXd1rWlGnolNjlmLf/hZziuKU63PIReb4fN1es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177617; 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=kcmdMbHAOSLz/nqXT4+bxYkIUEWmCh2FGI+lGhRoLk4eWvJBEIXGMX6yWauxpkBWvU4LjGLGFFtq+P8ByLMyLn969O6F9J9FF5f5oG003jo0B1TSXSNyfWWjZ36Wu1yrLvMGcLw9jLKu1Uzf+q5pSMrL9dMOmv306e5rjmsCd+g= 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 1755177617702785.5501373077082; Thu, 14 Aug 2025 06:20:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXcR-0001nk-Lr; Thu, 14 Aug 2025 09:03: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 1umXcK-0001iy-JQ for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:40 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcC-000546-Rd for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:40 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-76e2eb49b83so526894b3a.3 for ; Thu, 14 Aug 2025 06:03:30 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176608; x=1755781408; 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=ky4wvmxIu5rSJ1FDfNFcBCly7gy15eYEk6gEVYq7hFHjPiXlO4oqG+2nETdZSN7fG2 WviFhqcYf4l8C5h7FYfVxhe/0otWMqHbTrW+KauGdIK0QjRiVl9lkOX8EWQ8jyJd2Upm IuAH/6InuwETfpP57MgGB31BHHYHycDIc2Wlj/BCwJKeMephsz2ojiEELfmRk3ul3PaZ E/rYMmJ85l/pMJ9MFQ+ZUV+Q6vpyDK88QoHsT+M646q/3pSyqHmNQd+YIVZ2nv4a7LBl CTLF2oG2nnq0n0Zxz7IRRaOKLMHQmbv0q1D9L/hGl6H8Lyej5TtNmRa5QNLW+it69+5X 9RwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176608; x=1755781408; 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=Lj8/Am2YinuBjul+uRzZolVxBJQSxE/pUb0zT2mOzJ6662LiBTygforXfbavCNEw7f xv70RUPxwk+AyBV+DA3NyWuC+kiYMP9FGQV12CfyUE2WoHEEgGAPbwUjgzadvF9oGkHA lXcLcDs6kwDm7ExyDFBCVcVogX+8Z6xhLu+1d7vOzcRvbq29eMA5g5ekzbcpir6/DYLc 509epl/EKQZ8l8c4inQlq9VN2mDv2kk83rT1fXXcaN0RcSgwP4Gi9A0TuwokTUUXDF54 /wTpnihQQjo9jox0E+zZnIX8Sac5mI3iJvr80Ns9PsEDjKm04sj6bYAGq91QSYqL+E2/ Q90Q== X-Gm-Message-State: AOJu0YyId1kuNVi1mpTBx2w7cTKASx7DUnwAnQbIY+YjGP9w/Tzs4fGQ QOL27zjJj0EFaTjNAzEvEgRDXSIwlmyEt+lvvASQFl7shvyjXRdsninJY0vpNG1J8Ci5jFJHEjW RQfpqlaQ= X-Gm-Gg: ASbGnctg1U3Cj8R31BUWoAvzsp6/koBPc3qNleCqh5hv5ePZ7KNnFBsS9RcvJ35nwDA BXh1kOHMSuniigYd1wQav8g7u3bhJqElj43N6LrVcAOl74QIY+UTr3waxMe0Fq7Wwjm2dwPu6sL 2NhDCXdXv8RfNZKHzrBhOdM9Vp2Y8zWPs3jSmex+nd6ojiSMvgUpBAJhVjCmhDL6C9bYeMbQhP/ qQNnTHSwsu0tporKNkp1HnfpXOd6zHgrOvtrzVlNeM7uSIJ3y/j2bmTcR236tnIrVuYck6w3kX2 rPNHxgBMpuu3e3A/ZKp6aGqYXxtkWw/j6HTfQw0FCXMMrzuXYEd4WdnTc60VmTPk/7ckh2cLdHs Ji3ZSHRQ8viJx/9OUM2S4ywG3V9U6EuNkA4zIJG+4ZBb/JVM= X-Google-Smtp-Source: AGHT+IH0DVepESu1gB06lknC6gVmWL1tL14xv5N1i/pSH7YHvFDGTg+CPBPQrRGVixZl5Jr4qgdKWA== X-Received: by 2002:a05:6a00:2381:b0:76b:e1c6:35d6 with SMTP id d2e1a72fcca58-76e2f92d56bmr4683592b3a.0.1755176607676; Thu, 14 Aug 2025 06:03:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 43/85] target/arm: Introduce mmu indexes for GCS Date: Thu, 14 Aug 2025 22:57:10 +1000 Message-ID: <20250814125752.164107-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: 1755177619600116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177167; cv=none; d=zohomail.com; s=zohoarc; b=mPt4+M17QILhFBrukudJtLrhhNDT9SVtdTTwcz5ZtlvHJ3we4I3O3W/0Cv5FuqWx6HDCLMsQIZbhz7zJXRox9dktIv428l7UL59iocStq89QHeuGE2p8Z8SIdGFuAQdwG+OhIppJRFGNhnlF8Mlx3OCzv0H8l5Gj0hqzszRXm1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177167; 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=JY7/WUsKwL8VynF3jHeSxCwETzVIx7rTVo/aFBPnTqbXMR9nLxWRpHgPO/hcukmyUNFLEsFR9bF8VonLtK0Dze12f1Pd+0cktTjci0w83yGDtj2hB7NN6F79mDe6XkT3VTJirVHarg27WRq57fSPanuGZeZ8m7+jazgkqief1Iw= 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 1755177167076731.5066615678611; Thu, 14 Aug 2025 06:12:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXd7-0002Se-SX; Thu, 14 Aug 2025 09:04: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 1umXcO-0001q4-Mb for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:45 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcG-00054c-NL for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:44 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-76e2e629fc4so1023868b3a.0 for ; Thu, 14 Aug 2025 06:03:34 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176612; x=1755781412; 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=BmRJ4gymdbOIQbrzAjnk7TGC/UpDjre+TKyxlFagPdzyRpK3tUzCJp8IESidsg8Su5 3rNfnvl3kC8eADLCbLjrRHYathcgG3XGiT+Gu8HC7sQ5KkoSRf8Qvaap6tcQ6GtLxcFR nd7F+BxIQBhgXezBHkZf2+1A3JchbBmjMAzoSYSKAi3lMB8RoPQ9lG+igN+m8uXwDgEl 4pFWX2TehNHy3L0vliFqLsie/qQ2XA6iCmNYzq/5EVAgGKgafoCxIV5KDD3Jzr/bXRx5 LV9AgPfoC+OXAvbG2zQOqKR24CnK2dXDaF4aI8t1XYgj1Ap70SbRolNoTZUxJ2ULuQx1 6CVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176612; x=1755781412; 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=IFatZuh26/QoxK6hISliEWuWf8s7JlBmecvOOJ9YBAgDOcFVS6biSl3cPIQc6Qq1oD PWzLglJ9cdEkifx3/rEihcdYrFVyUI727tqYNNeAN1GXZiVFPF+0kFwZPr4EAtV4plpm 52//VG6cTiQ8IUvRPq90FvehAlSocvYi3HM7YJZN8EF/X3GgyoQCwNilnBskgSpsIN8m 8DJ5NyDoVjoOANJOZfrU5YXZGfXgCSTFUvPhiLjxr0qpVbEXi/e//BP9663a+W6yfQJ8 DmV38eLTdVG0SLSnFVy06ZpScbMRRaQlJv4sPkIc/O80ZLtVPM3el1C93vrK/zoXJ7y1 60Jg== X-Gm-Message-State: AOJu0YyLfoihmOIuDaf2l7Jh42+Ii9rexC6QGUnghsHV3panFbAe3SQV Qw4UrjB4aaG7mwWrjYfAlGpr4KHrPdo9MZN/MssAT4M7PzJI3rsHZzcpZad5gQ/BbXPE9aJMj/h EoU1aSY8= X-Gm-Gg: ASbGncuxGC127CDzwBCB0wvdMy+zwgr/OJKck0ComDv4RzlopkOj8URPZN0KLhX9J0i nQhh5I05wD9OY2FwvCXgFCixxEgLhS2veFqGyNEaqqgw79izoMY04c4k2bsuOppATwSK4Khuwew oRuX3NZRd9IYihfe7Rg77NTrS3Ldd3+asXodn47JtcT3y+7ILSijHXyX8Moxe3Ztoph4cuLKa7c rRGOLDZ/iEpIxNU3ag+Ar1V14shXQFVGfQad2DEmimc/1CtSbNatWvrDhIjt/I72GmPkDs8PjIn 3Z+S5Y1Qwn7dsreQ2TSqMTXXS6XOlflROg4kyf/AB/fSZe8TkcQUOrMYjMbaeVNNUS11LH+ohPu BUqNo919Vhffb04puJNx3ivOHDXYW/kSlkM71dSiUbBleVug= X-Google-Smtp-Source: AGHT+IGZ6Epoat/SBDYH8oMA//p7h4T+X7TKt8wI148ESybBmR+lJWS1eltEru/S8kvkXnUrQvj6kA== X-Received: by 2002:a05:6a00:1142:b0:76b:f8ee:4eaa with SMTP id d2e1a72fcca58-76e2fa6e615mr4209220b3a.9.1755176611393; Thu, 14 Aug 2025 06:03:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 44/85] target/arm: Introduce regime_to_gcs Date: Thu, 14 Aug 2025 22:57:11 +1000 Message-ID: <20250814125752.164107-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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: 1755177169292124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177578; cv=none; d=zohomail.com; s=zohoarc; b=YN3cQpIYBFJSbYFdw52ritRQ5FTrEJOe7Q854uAYyL+TOB3gayiFjxUB7XSUVKETcX5h60fiPa8wpz+yueBYkH8hGxRGlkDbg8lf3SI8Ov/V8Ev+bi0kJIgRyeZe2Rd5p7u+Yht6JTQpsV/Dacf0ylWGDUMdGxD6LtZVYg4ZyNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177578; 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=PMVyLnrWsRq8ZRUDvtUn8R0Sx7RqoWjMK8x8WZ6NYP0uQjkQyE9LjGqKo5X8DT41FITrmWw++p2da9zz5/YV+QZxPIOBLvUcu+EPIu1NTMnXTyOCePupeJp4vN/jw1lxF4H4u9lJqL/s+gBPd1uvrxfDAgv5j6/oSul2Q5aTx6U= 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 1755177578065364.58128784708936; Thu, 14 Aug 2025 06:19:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXcZ-0001zs-Kx; Thu, 14 Aug 2025 09:03:56 -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 1umXcM-0001nF-Kh for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:42 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcK-00055I-7E for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:42 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-76e2e618a98so723933b3a.0 for ; Thu, 14 Aug 2025 06:03:37 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176615; x=1755781415; 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=PrSW7HjfMN8woCbZ/B3ORMCGhXyNHIu0BJ5uXGqokPIDsgs/iTxywq6hlbaZ7NOOsE KnmDr7ojpXkn3wOXtJRR6XX7vDuKAcPENZo6R/fb6hZ+OuIhyqqvZSxGxAnjEGSrBaxE iijivDnvOKoMmowY2p+HoBbl0uVHqnP2u5BQrxR4zNRf9Wa5yEWrteGaGw+E3IYa5r4Z EFV5Fv1Nrvt6Ai/WE+NXmkTtBLUUuMZAbPv2QlSCbKmE8Ez8EgfA+qzAuPWNMZKaO1Mu 0j8wK3IYnrEYSWBZfFKleBhfb0MMHSsnnFm7wzaEOitw9QGr8K6TFZglDWmTdYnEHLVn oRIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176615; x=1755781415; 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=jnzTWtRT94gUyvS3zGxljFOUD8qCuOmBSblcfwB+VU6qVEZQ0FD9bZ+B2+Y1//gAbt AxPaY0QQhduNYh3Z7kg6IRVvdTCfjDP5tQwbSXZucix7t6vOeFA5X/4NjEUrPLe9uzmx zMqGRfAFIi9xtmQW3pIlCaoiMMNaSko59dNC0RvG7Fyiyu4jP5HUxI0id8fLxEjyqHDv JKxyN5krar8SIZ6HFMJmpzy9Laq+pv5NO3BhvyZ7MEvorMBLRvgYN7Cw7uQ5WQDCfkFv GQMpamLS7WNRWnR0xq+F0vz5I1nlp6VGV5J2g/lsaSw/qEIw0RK/KjX2vcDzVDg66k/6 Dxaw== X-Gm-Message-State: AOJu0Yzs5FxObtZJbjM+T7LBKU3xFs8CqA4/h+OjEoU25mZY7XIL1AVC ciu7HJCIe8pHZ0m94+9hcfac8WLeN7W+Z8g0IA7xwoFwTiZyXlmSYEIMywW1fWcyM+bFbhMWr6S 53oWPKg4= X-Gm-Gg: ASbGncvOP2nTmxSWabfpZKxBksJmENlA5/xsY6O59SDWo55WOo1jxDtiAV/J6R9yBCi Nbf+0SNRMHj6IoiDWtXR03uhWFa+yNKmpA5oUlXmjISLudfkqpKlI2uRAGWbqQ547baMZavWkNZ s2EwVEyLj1PLRNEFpdtgCwhOTxy5/grQ17jMWM6lTD9fLtqC29ZRIk5fDAFRHzRdjE4NolCvyEu yy4MHu1I+epmdqLlDNI2a6Ir3PXqkxSxH7Pgw/W3gTmbVzpnMcin94gqdhmGFRIDThbFC5c3y36 gcte57jPBj438DuFxonTp6BWRGWuHgI8uF8DxBuLvKCtZmxTG8ookegT72fUe1lxgHsOn7ZVgJj PIU/olOyyldWrHJmTIaq9woM+R0MvAkFJ2wpchh/szNV8EXw= X-Google-Smtp-Source: AGHT+IFOC0GrVvjWN9ArDtg6B4W1m8X3ZTuXEPQhDMMDlj2ImnQHbJKuKAvBLAvloAAY6281VHG0Nw== X-Received: by 2002:a05:6a21:6d95:b0:220:7cd5:e803 with SMTP id adf61e73a8af0-240bd220406mr4524143637.21.1755176614440; Thu, 14 Aug 2025 06:03:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 45/85] target/arm: Support page protections for GCS mmu indexes Date: Thu, 14 Aug 2025 22:57:12 +1000 Message-ID: <20250814125752.164107-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: 1755177579341124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177468; cv=none; d=zohomail.com; s=zohoarc; b=WLA1Ou5DwdgTLWDOFuOa5vc/Jm5G/9pA5r7/UuMO1iD77qna5iiXEyqoFFeiplu0q9mcFxVbjKLeX9cF2Vfi2fqyvMiNKozxPptDt3apl2Q5P20wjMnpYIKiD5ncuyjlA2J51PZIkejGBuiTODnd6Hh0VbDd9Gx9sixI/WrI7tg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177468; 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=ZnGv3gaWQ9shrmt0WGxn8YCEO4EdUIFI2jl/MhJPR7Y=; b=mSTQWp/WqATBA/CmUZNLTbUnzHiJD45WoaGCfi/KXyfLw12RsXqisyruuPXeyd63RRjqyJ15Y3X0T96kpRB/7AyFMHLP2kFxUTjX+ewLXf0wyUxsQ78JdLs8nI941UVIXkD339Sf7KapC2VpKSz7cKvnC3BGJvrhYY9XiAQ9ERc= 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 1755177468744845.2470684610015; Thu, 14 Aug 2025 06:17:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXct-0002EV-Px; Thu, 14 Aug 2025 09:04:17 -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 1umXcT-0001td-8o for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:49 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcN-00055x-Ba for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:47 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2ea94c7dso1332223b3a.2 for ; Thu, 14 Aug 2025 06:03:42 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176618; x=1755781418; 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=ZnGv3gaWQ9shrmt0WGxn8YCEO4EdUIFI2jl/MhJPR7Y=; b=mBUhvRP4DAKA7pa1C+HJF/Uqh2PMDcHzBdQve9YWXjpQbo/36cqlZGRSDf6KhQEg7C 1JZzi/dLCZc+j/HAVCPGqCphsvND/lH5kLVA4lsQ6CFvVB8K6Dp8G/1xAZH/DvTm2Ad2 wS+J9yq3KAgAqPvOkB1dLmxKOZLrjbT6RGkoyZw6yQNW23Zz3RE/u92309qjfzH3qbO/ aPvnrsZbv1DT9OICbjCKO804liJIGSgA5COnYNJtn8+nE7BRADklsgJ43ZgKHtFm/vof 8r+o+KR/DLaSZK64Quey4dM8hNv8/hyVSsmLsx7Jp7iVqz+Fe/5yyawlQmhVifFSHDT7 weaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176618; x=1755781418; 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=ZnGv3gaWQ9shrmt0WGxn8YCEO4EdUIFI2jl/MhJPR7Y=; b=dsRefpUg35JT9PMvc6V4+cSRQrfldeE+Ki1qqB1legudLyCfPd9AZ4cTkJV54fk08e +bg1sKyEPNiFQz58rOM36iSO/mElKuV4y0Gaqn9+NTM+LWaw+GBhQvkikj/huHEmeXLQ qYKbvGfPppC82gDZznS5JjEZz6U3bAU184tQhGmKb8evMFRBBoAbG+nhTz/2yK4dkIZC Xjtj4NdYP+QR/d6e7p7W7Ptp50TQO3bJIM0jjZwrkybhCU34TLH6bqTZWMIhLATqYcb8 lm4h1soLV60uODbveTLd9V/PWvgiGARuRU/u/n9jHcWhs4XLlbTQf3/Q8Np/aEH1Izmb iOqA== X-Gm-Message-State: AOJu0Yz7TWENQWt9dwGzNsNvYifbZZlsxBbGcoW5nV6P5F12fT19fgaA JM51C23Jb4/CpVi72L99c/ZF0cU0WacVTzw4eGNUMGEBevlCsO7SPFuYOGsMUSnZDUoDo3zggnD Mw/wS5ZM= X-Gm-Gg: ASbGncvGRKQ0hLMI9q8Kni7zRR41w7qFk2OWsuFWE15msNhVrxu+z1qBQrC6e+FBTMg xqyeCS/g4dCuU9uoWwo22WXz1A5iPs5NWvblUnQaxHcHWX6i5/RO9ObJ6s8V6miL0g5DTfTj8d9 Jsj4OtH8I5jLNPavHaLa4QWWu3m05d8jBuljbs/g80kBdvXt+PvllxDI+kA2z+yTlf7grXLnIne BotIHk3fhIU+jrirgfVqroB1okLeo0BXKoSFhjbcgFcvXUBI75y8KDzi4jE5WIs/GkYIfDhFonY 2FEiNp7V1Oi5xScWNVC2nmuwAVlJgrCTi+bPFlA7X0Aw+VZ7X04wm9cDaw++WqZ8yskrPhHcSxE O3qmc2n+2jSB4j3L55ZWXAXJvlOEQ3xDUYpI5UQngvV9z0LA= X-Google-Smtp-Source: AGHT+IF/JNCY4v0x4Lk4N++1yMphTgYbY1dOTRMD8YFOhXWbC7eG2cXbUZREL/n5MSHYmFZ4BMh60A== X-Received: by 2002:a05:6a00:4f91:b0:76b:f828:34e4 with SMTP id d2e1a72fcca58-76e2fc2629cmr3915200b3a.6.1755176618032; Thu, 14 Aug 2025 06:03:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 46/85] target/arm: Implement gcs bit for data abort Date: Thu, 14 Aug 2025 22:57:13 +1000 Message-ID: <20250814125752.164107-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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: 1755177470335124101 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/tcg/tlb_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index ae2acd6727..f1983a5732 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -28,7 +28,7 @@ static inline uint64_t merge_syn_data_abort(uint32_t temp= late_syn, ARMMMUFaultInfo *fi, unsigned int target_el, bool same_el, bool is_write, - int fsc) + int fsc, bool gcs) { uint64_t syn; =20 @@ -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)gcs << 40; =20 return syn; } @@ -252,9 +253,10 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, syn =3D syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); exc =3D EXCP_PREFETCH_ABORT; } else { + bool gcs =3D regime_is_gcs(core_to_arm_mmu_idx(env, mmu_idx)); syn =3D merge_syn_data_abort(env->exception.syndrome, fi, target_e= l, same_el, access_type =3D=3D MMU_DATA_ST= ORE, - fsc); + fsc, gcs); if (access_type =3D=3D MMU_DATA_STORE && arm_feature(env, ARM_FEATURE_V6)) { fsr |=3D (1 << 11); --=20 2.43.0 From nobody Sun Dec 14 20:30:54 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=1755176993; cv=none; d=zohomail.com; s=zohoarc; b=dAcZOeTpyCGN24nxBxybjHz1aotc9xdMoHstZNebQA4T7iLMBXexS+33ANNAzLLvvsqX4mqEKCHpDWROj0RwgzdAGYeMPCQjtHckIXa9+EI0S6VYh2urQRnkiBReFkfFgiEd+HLef6i1YTVWkLyXSCXqd1XqsvBF/ajYgCH3hP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176993; 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=PGoBaPI9YdbcahbR3TKVmmYjuDxcjQqW1lAo/n6M0zk=; b=P1eXc6f8n/DS+NATdZUaXB+FoF+CSWxYFevnejfgXjDsdBq+doJQb+NX1geH7mlgd8Mrs+Lz51OFw5KF09GWn0w2FvI+eH/Zvwv8C4nc9lJ4XWaLt8Sz9GnlJz4vT3/RHR0/vz/edL6ahvjZvw3F3jWx0B62oqvrnQnQImcFzxM= 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 1755176993305127.65615449635027; Thu, 14 Aug 2025 06:09:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXdl-00038G-F9; Thu, 14 Aug 2025 09:05: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 1umXcX-0001zt-Od for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:55 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcP-00056Q-EO for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:53 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2e60433eso785156b3a.0 for ; Thu, 14 Aug 2025 06:03:43 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176621; x=1755781421; 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=PGoBaPI9YdbcahbR3TKVmmYjuDxcjQqW1lAo/n6M0zk=; b=aJrb3UkkOMbRBnBcDDYIaLLbAV5xUj6qnDUNltiqIcphvAsD6IYkUixZjIzZ8lIxzE tTPS8/VcAHt4QbF3CpAW2j0aQWIt4Tzb3PTN02KEBTbYnu2BLOqR69Pf6yasx6uqZ+sL Mo2xn7zNjbFLRDZ6XMTqSM89Zt8PF6dWp6i3MSGv+dNJUZK3ZPsfcDB3DYe5xsZTK8P+ NrDtka9is3pXPSWSsT+JMlnuaf94intlwl5/M0GajQu/Ra+kgM0XwSclQ/TiiDdfPvYt W4+tY7MN4N85KwEa9gC8wCC4CImtj06VK2VaMeJOfwtDY0LgFOW4BwzGuYpJx3Tjvrs3 zgSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176621; x=1755781421; 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=PGoBaPI9YdbcahbR3TKVmmYjuDxcjQqW1lAo/n6M0zk=; b=NBUwxLZJj3pmbEsNlIb6eRHpQyDoL/H6YjQTL+nvquVTN8tsdGZbVRWfZ2sU9+e8Vi e6zqVwbhYXCQxaEl4UAFSe427SymeqrDZu3PJEOx/5OkxozYJRLFBykWmUxXythriCZn YJVCIhUJQW1EdEvvN/WVajzY1LFn0/7WiF4bWpVZRDlODi0Ge/11bF3Inye0WHhBeHpy AqcON0sJPneWKwJHb8/p651Daf2j16XMfEmxcEvRh+EIVrsg+rnzFMHgQlYgdwcjVpLf Q1p8upkc57Ox7B1G9nUH0gzf3xRfHnEqD8Zh6pH16Uga7HBnZpwxOeb3xVDEaqN2/hC5 JBTQ== X-Gm-Message-State: AOJu0YzUaaePbvvInq1XyPWFLaVcT0kGdULfaf8W4/JeUf7+As+quCrZ mZ+w4D1T3IYz9UeKWdlRRU/2VKHuOYG2/mvi2599YIR3RsSbXkq4GiKkUetWy0t7TlT7J3s07aA 54AE4hTU= X-Gm-Gg: ASbGncvthdMY5ihe7m9zbsAFayuw1f76mdupy/LumtqwjO6m9VIVntBcUjCECnz6ScX X38WF0VB11xheX4vFrdE7wG9vhWXAt+E1CER6vTOF/fJr8PbZHllYxZKknPeIonmhtHxqR4dRAf bKHWY5ATgKaDpqhUQGMqIHq7GtlpEonrC2+UamtUNmxb0NAQjO6q61BCXBo4DjumHxQpfJ5RbUN ZxFqM6mKQ+H8MhGaKwaAY05InQNmKLrdocwZrk0rgEuEwg0+j4YUyE4N/snoiDJCduFH0WhlJwX TrO/WVjokPC44uBsVg03o1wQm4SifJuHxs7fh88ySu6XOFJYAhYvZgJTF/5a8OrXpZYCOzucYdD iRpJrfvpuuNfuvKc65sujtc+edWelMxxNugwxcfqRphduf/A2Brf8VHjIIQ== X-Google-Smtp-Source: AGHT+IFDZJjAhfJjl0nQoc2+aHIb44hyR5BVJjHQZG4I3OrzqgxMpWdxYRbyae6790HPbP6s3Pl/TQ== X-Received: by 2002:a05:6a00:1303:b0:76b:dbe2:40f4 with SMTP id d2e1a72fcca58-76e31fef1bamr3661631b3a.16.1755176621310; Thu, 14 Aug 2025 06:03:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 47/85] target/arm: Add GCS cpregs Date: Thu, 14 Aug 2025 22:57:14 +1000 Message-ID: <20250814125752.164107-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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: 1755176994868124100 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 Tested-by: Thiago Jung Bauermann --- 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 | 91 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 3 ++ target/arm/helper.c | 10 +++++ target/arm/meson.build | 2 + 8 files changed, 128 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 805f4a1876..4f5b42af12 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 @@ -1777,6 +1778,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..1a64acd584 --- /dev/null +++ b/target/arm/cpregs-gcs.c @@ -0,0 +1,91 @@ +/* + * 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 void gcspr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* + * Bits [2:0] are RES0, so we might as well clear them now, + * rather than upon each usage a-la GetCurrentGCSPointer. + */ + raw_write(env, ri, value & ~7); +} + +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 FGT_NGCS_EL0, .writefn =3D gcspr_write, + .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, .writefn =3D gcspr_write, + .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, .writefn =3D gcspr_wri= te, + .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, .writefn =3D gcspr_write, + .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 Sun Dec 14 20:30:54 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=1755176786; cv=none; d=zohomail.com; s=zohoarc; b=VFGvykLw2nWNWCwwzSAz7rz1gB8ifipLFa+tLDX5z4KDjOrF3ucRCVCbAAPjmEPosmAnvzSN/UvgZIZL+jwtgXw9aRyUO3ZR8C5Wg8EZfEeP+7ou0hSQnGZOt/SZXJ+vUtCI3qrkhahXyoFbfT6mEmdQ6GWN4OjespVgU5WzjT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176786; 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=m9vYL0ws1JHOkmGjcLNXd19wlWFXQrCZXjiO8wuC2k1elaB7vkCqBTX48TVnDKYnfrBblGRqXV6+ooHb4MEXwvRBlYR8pymufaz/5wKH/Qdbhu1LYgILQ6hEkHfMWmQSs8cO7oh63ilSVUoCdsxz1bskHtbcpoqHS6NtT06HYBY= 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 175517678685219.80490095168352; Thu, 14 Aug 2025 06:06:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXd1-0002Mo-Lh; Thu, 14 Aug 2025 09:04: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 1umXcY-0001zu-KB for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:55 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcR-00056r-Eu for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:54 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-76e2e89e89fso1205969b3a.1 for ; Thu, 14 Aug 2025 06:03:46 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176625; x=1755781425; 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=WOkrIQzB0IAjYLDaN7oIXAPSeDyy83m8Y1KTUw0ksMl8iuMEmFj+rtkSlhWhzNMsys z5jCQqgINkI3Tzq6PhtoM9IRU4ThIWHDyjsUWtbdVvSqWT0R8201ZGd6RVTPFQlhAmB/ TUX4QWdstFDe4yNOT8O2lv9roAnN3mUzEYZNPbaU0ULcbfIRjass2W0LKe6nrF/ha0TK /oeU2I5j9HKlMLVTWnwcLVdPnXPPxy/bAt1fXf2iUf18udlLwtgB7fEb+9GGJ8pOviy1 GksbjLIteDezzcIyC8v8/bHE1ulNrRf8ct+32qZtKuoV4ilCfIkNXHCqtNdJu7Rr57MD A17A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176625; x=1755781425; 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=VAxQw9umPrE1cy1YEPTRwtrZ3hhS95xdzx5VpZYmckBHlFJAOHtX3hgEV/3rMH54gK /3zUg5GnkeSwMVd8v63ILMoEc4L9KGC220KYQ/TDCJmtrBHpPS/dqEgFTdrVYCnywOIm lRi/M07KMSEmQlqK6F8O4uJxLBDodvs4ARa4TqYYl6Xu7zuUzhpKNPKkpTuGXtWJWqUq Pnd7R9vmFxthCJkqdrz4M8QJ6rtsEJaXjZ0GdyYfZ7PmKN+dA4ZI34aa/ASHqfnQY/ss OGLhWdKKRQAn6Icb6LdhCGJM16EgrqipuA9U9f3VGUSBQ+wLsNqcIo4lqpTGDLGMz+td uH3A== X-Gm-Message-State: AOJu0Yy1c04fcnyS4RKXHurrvSmg+SvynEDEQX/2XTwditlrU5Wpo6N7 LjnQIJZsG1csijB/bOPxBD85w4ZLLQy6vMYl0XlH7H0avQDczdmn82GW0UXS3TySrBGLHH3Dm7C +a/3N3e8= X-Gm-Gg: ASbGncv67qbKe+SDqvOetAzJ67KIfzhEFqs0XECzHvy9O/EzOuYp1Lyr+Shj6udHwYN wfKsJNhTrciLEsVb+4R2Nf7YMIjcUhMvjGcdg/bD8sPDRyC4cgKksFOuyKRrAXnjPdOHv8jUTE0 1wgq3CdvjgBXauQM/hCs6C5IdPkdC+m73ervJeWM3omUcD6Hon/koZmTWJZuU+HheX3Bl4t3sjb 5PX63sMq7MsIGa3BR3YyOLxKAZ+vlMsMUynTkzBOKTAwS9AKdJdA/XWAmEwzkrg5HgsiLBBna3h cFGPVEp5sTCdVcMXGxO14DG51Qm1sOHUUM0Br1cVD0VUwOD6tdCDuyfyEarkM2lPA0QEG+oF5Z8 HPsWWq3Rw5+tikcgZfcdK5TRB5nedlGvTBrFO74/Gg5sR8EM= X-Google-Smtp-Source: AGHT+IGbyl2ibAjZX4aJX5cD0X2aJjoxo7/VCEseCnPTSGoYGCX+53Njtgo33ezzLhoLIOUEzZh9iw== X-Received: by 2002:a05:6a00:180e:b0:736:2a73:6756 with SMTP id d2e1a72fcca58-76e2fdcf721mr3912129b3a.21.1755176624532; Thu, 14 Aug 2025 06:03:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 48/85] target/arm: Add GCS enable and trap levels to DisasContext Date: Thu, 14 Aug 2025 22:57:15 +1000 Message-ID: <20250814125752.164107-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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, T_SPF_TEMPERROR=0.01 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: 1755176788881124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177990; cv=none; d=zohomail.com; s=zohoarc; b=boZIozrYSwm9uhv/oXHu6+hHNHGmvD4o8O/C8FhKlUNmEwc5cV+Jig+RWGrgfBnfT2bv+NZKqv5ZaJy5Vz908KcP1R/1mTb5FLi4vhiupLkNqAgCSzc3m/drp01ATU9uf9g0z5P4W34T1BhTyXVTOGd3v5w2D+harmtNtwLfrVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177990; 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=Dr0QbCUEAsUizyCdAxGuIkK6GtPPZGEjbTtqBiNaISajfy8vnAy6gFEHWqOPVpd6CVnsISbJj9grcqeGdxJ75HUzjQe46kzLPZcC9iIsaM69bWPaviFrjki4a+y8nS31kOeR2G5vW25L3Sqv+BBVn9fVkKB0WA93zW4qipH9/m4= 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 1755177990676272.50335610102854; Thu, 14 Aug 2025 06:26:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXdx-0003Nq-Qu; Thu, 14 Aug 2025 09:05: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 1umXcd-00024S-1Q for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:01 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcV-00057M-Bm for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:03:58 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-76e2e5d244cso971548b3a.0 for ; Thu, 14 Aug 2025 06:03:50 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176628; x=1755781428; 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=stKtHv4j14UsOj6/Uq52DqvklYuSfkVHzE9oIYq4QbQA4doZH4Flxxbg4NQbODtiPR RPCdDpTfB/F3PFoucdt6HkfEIUSlxd6RPLeCUfro1982Ezzfw8z2AiaUWntTCqCCEET1 8VuxlU6gCzT6TdXzc7JLhKs4iGulTpev19kTfj46zU0hhqlaSgH+gjJ2wmc2poOBMws7 E+1k8nb/N+eD0UUfP1mR6cZOQhweU52J/UEvHNV2e42exeH5x7pE/kFYaTdB+wiZuwYH QKy05Ux4ZKjkiJ4gyEcXLuITsLpeAnFK2OLeKiC3/YjS57EUgIFox3DlmMr+ZDYeb27G OQsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176628; x=1755781428; 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=XChColwjbr4MafyRUQ9bLbm7XOL2slmBZ/4B8R21+QoQdCFMpL8mz6LxmkzmHxW/0I +bnZ40iqpVaLZ2CrHOPFBiGhVLLp8DJPaXlFWrmUCY89LGyTEJCxpVXIZBzo5rb/MfXA bBRAo53PhpVIqmQGrRgVtn1RG76pchs0f+WO/sThTTVOiS/K2/A7TfBer/QwV1awEPvv oiXKtGZlxEw3rFpIxeQEf5mM4/KfusX/WTZtuGbMMuP8T/q53kpP5dTrACsCNVi0OnIr 80+KVtI3AIDI7wBEB+hC2QmHScdpzybTmNncMaEk0PjsEh4HNJCyHQYkpb1eZMf6hMKg yThQ== X-Gm-Message-State: AOJu0YyGL59k7IbrW0pHc4ma9/KFaA5CwN9vU+G/bt+OAOuRU1Hl12YH f88aqygqYpWB00p33HrijvFqFzWlxavgRa1n84Nh5YlCEKWitoLGxYobmzJcwgHSSjhVsofBXEF u9yW9b4Q= X-Gm-Gg: ASbGncsHsYOdg+7eR5Yvaisg0qh/6Bok4HFikH+1kyu6zdaljxTEKOtyN87kq10B1Yw zC/hnn4OKbIhVK3Z2+Dt1JMfqQcPavgnW20BfhKDUVPA8o0g1bV5OjWiPI9SkstJnZbFANtK8D/ N1D0k4YduCI19CiK12vgVMITiGGWpzblxUepiaiSlHV2/0xutd3FLydaKV7eQJeGMpNfFtGnoN1 nuJULGCV8petsPp1mxwTqwBHNQ5gPpkfdU9pOkg+2fnr7eTLjeN1O2eiiUu/pS9iNLQLhydQLdC cvYj3qYrzmEto9m/PDOCz37c9tzBkiBKV43Z0rMJjYLovNWnLJPAvRQTu8452WOFrSC9wX/0wlj W2VR3xl7FI4WWD+HvOh2UZP1wwoM1OBP0/8J2hOIh9RiIXv0= X-Google-Smtp-Source: AGHT+IEKMCY41tVjXnLGo5opjsqBfcU55L8MLOLvEE40XxwRC0FAIae+MuZJvCBDQZcNcGZScikipg== X-Received: by 2002:a05:6a00:9a7:b0:749:472:d3a7 with SMTP id d2e1a72fcca58-76e2fd6fa9bmr4595414b3a.18.1755176628021; Thu, 14 Aug 2025 06:03:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Gustavo Romero , Pierrick Bouvier Subject: [PATCH v3 49/85] target/arm: Implement FEAT_CHK Date: Thu, 14 Aug 2025 22:57:16 +1000 Message-ID: <20250814125752.164107-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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: 1755177991561116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177480; cv=none; d=zohomail.com; s=zohoarc; b=GdU1JUTdE37cKDmfub4OwOYp1pKYv8n7hBoX6KdGEeMruoPUGeR9j9dz+FmKF1530X3s6L5a25Uac8lcDTtTqQjZhBllORv9BJdhfA8NK3je9TuYdyXluiQD0B4z/U/4sM94r8uSeUsv0d88uxXLHNAz7iArGSwYg/tOXzHWGEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177480; 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=uBMtP5bnwUY/kOz2CYznbwGY+2US1QG1d74aNvB+ito=; b=Gl7Nw/EUgkGn5viYdzF1cH27ZlALXZ4kXx0woPYd4h4LI2arO4Ik4NqqmFFfS02Y0UTW+ClHS+UkyKV287MOjd8xe9fWPCHiQxaQW0/RDyM0MqEA2cGTdIMgk17dn8Der7K97zahrNmV3wFfJ0v3A0kfh8Ca9M5l2adlihyKWMg= 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 1755177480809952.7505404315662; Thu, 14 Aug 2025 06:18:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeC-0003gl-4m; Thu, 14 Aug 2025 09:05: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 1umXci-00026c-6u for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:05 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXca-00057k-Gs for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:03 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-76e2ebe86ecso1164045b3a.3 for ; Thu, 14 Aug 2025 06:03:54 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176632; x=1755781432; 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=uBMtP5bnwUY/kOz2CYznbwGY+2US1QG1d74aNvB+ito=; b=MH0DZwxWbaUaT8qWonkn07etoWkz5GMcR6tYP2ciO0Cfw7LFlRZDDQ4xJAh+IvYJ2g TpW0op2UsJrm/K0UcYBx1ZGZWXRWi0S+Q5DlLy6oLfTluOD7YgN72TR74fmUkUmBM4V/ v+BitFedv6uhhxJV0oghVy30OAX1kpjn2zc5Ifg3I3sWQUBqdzHR8koWsMmw9CcYU9aY HAemNVGogRbMzilydrQuf+HA88ZQfKEz8FtM/KoDXTQbO/EVkeduYCVsCcE5cHr4QxPF KPzAEefmf8KJOAXi0yDSssXX5kzn4wcrg3Y8Iyou7cZ0p+xKsObPmWtOMkGFsaclDlTe 6WcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176632; x=1755781432; 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=uBMtP5bnwUY/kOz2CYznbwGY+2US1QG1d74aNvB+ito=; b=u1B5Vre+18Hr6JXy6BL4cey1XGCeZCyiuNHBR1Z8kB7JqZu83p7D1chXRWwDalk22J xZjPrjBgkUWl82T8YT3KbgERB0AD60zQ5h/lkp3a0qFDUdkuPMpUqPh/56lpmuK6Imv/ DYzeBDTj2tBjCH9ZjX+NTZC6GPiRQurrFJL1YfPzcCARSmHJopg5yB03X3PcwWJ+UGkQ PgewG2FiD8czPkb8bKWf6XCac3bLhJvySVTjcS2RWvpWTwyzheEe9TZotojeyFzqIbCG DuQzbckYfog9wa8vqyRUCZaNLEQILtDgfjQa1CDD5kUeJwAMFm9X08cFDSewiDw0J/Mv xL0A== X-Gm-Message-State: AOJu0YyK2wP6aa+Y/ahh36uHPybyBopUpQeVRW2hkFn4fBrYk2y9DEPu 3mBpNmi7n4jrwyPFyF6Lyw7om6UiNLDBUVMPqeFzUmXObsirO8dRzH1gTohfbMdkUfUndFFAlFP xUrWGKiE= X-Gm-Gg: ASbGncuQJ3WIPKIN83G3YvYUhDC8ff3IxCgvcUC5fsDhgOAVQiNnjE1UmT794Yuoa1n NFn7w9MRhawu07f2CFcIci797+iDEY/Pfb/s02FdspfTjxECAElADyfpGHCJaYEqk3KD2/dXwlU nKXRTs6vzwqW7ZhDbV/D7Mu/WwtxJAtV4zIVU+a+gGWIHpFg1is4A+LTqgfAIiw2Ckm0GagoR2v Cvtuyy2IAhtWcOwEwNs6Ngfq69hJEQk1mwvBj8b+yAZsHzufiiH3WAu2bGn1quLHokIWeRLA4Ii fjWm8T4LYe0CUS2LT8ZJfsgdtmg1VGRuGLR2PlIV4ZU7rG3IITuoikbYogy5Y+JRRC4/wstFsZZ DxYPLL8N681SXazSMGgklOwdvddJWPiyYM/VRjVu+AEwP5W8= X-Google-Smtp-Source: AGHT+IFNos2VWgULK1iMCSyFTq9IvUx4efDcjhQoil4GiZdLWqHtC5UwC8gf7wNouUp0CsJ3/oXzow== X-Received: by 2002:a05:6a20:7f9a:b0:240:409:fa91 with SMTP id adf61e73a8af0-240bcffe837mr5073641637.18.1755176631477; Thu, 14 Aug 2025 06:03:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 50/85] target/arm: Expand pstate to 64 bits Date: Thu, 14 Aug 2025 22:57:17 +1000 Message-ID: <20250814125752.164107-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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: 1755177482649124101 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 Tested-by: Thiago Jung Bauermann --- target/arm/cpu.h | 8 +++--- target/arm/tcg/translate.h | 20 ++++++------- target/arm/cpu.c | 6 ++-- target/arm/gdbstub64.c | 2 ++ target/arm/helper.c | 11 ++++---- target/arm/machine.c | 56 +++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper-a64.c | 2 +- 7 files changed, 82 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 08e2858539..d0d769df53 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. */ @@ -75,6 +76,7 @@ int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t = *mem_buf, int n) return 8; case 33: /* CPSR */ + /* pstate is now a 64-bit value; can we simply adjust the xml? */ pstate_write(env, tmp); return 4; } 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 Sun Dec 14 20:30:54 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=1755176777; cv=none; d=zohomail.com; s=zohoarc; b=EJfm+rTxRBPEYBHYHRccgzbdvVUQ8v3eg5vHB0q/yLNMcnZ9OEb4ouatqK8IXgPq+pG1zW0Phba+mXfFagHmlLPO47AAUePfsZvf4MzYuK6tBO2+4IgJQMsccDpFXkDjBwDY1HfnBNFd8Cvk4ATDrRw0NGpysyIS45JiMUyoLrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176777; 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=kCYmNmQ8XLS2HnofAE4v4bImDCzKrFxqO/mv9z3TGRfjoYS6tojJhdZddCHW4RAy6+FpHsgX0uQ7xFQn5hYveGLoO4zvi9HmLXLwgY3td1iJbUj2BP1j7WfJt3j+oOZDk4j0uTYH5luY9T3cylPWXl7Ai+1v/dUfdIVDqzjuokY= 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 1755176776988636.175343251739; Thu, 14 Aug 2025 06:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXe1-0003Qn-3f; Thu, 14 Aug 2025 09:05:25 -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 1umXcp-0002Ec-Ng for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:13 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXch-00058B-UU for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:11 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-76e2ea79219so1116859b3a.2 for ; Thu, 14 Aug 2025 06:03:57 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176634; x=1755781434; 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=cgrCWCRGZdA4UnKTje3Q2RycP6YYUwCEVMsCzjwTSx9WJqgE2Zk6O27le0sg3DqJp3 iqR7JImTxbKgEcfVDqk8tTVW7udRzDz1JNCoh8D8Hqx9UoysU37I7vzIdseuCx0RBXTe JMNWTVTVbta76HY6xTi/fT8mx0kJIJYQfb275Py4h82OTO0uPjpUuxWNshwhWVev/tqq b+HUC+Ce0B92QirjUGGDFWdpqDXu4vKGTDMyLymjcruHJ6nlbxD5ocM4xUAoSi2Wu4vO BPWAUFPDiu7hQdoYrN58CTIwp+zGrZHp4DO73oNHGzysU+pzVGjwpgfCuulr+2Ejmtud EVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176634; x=1755781434; 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=fwIYADjwHg3d4D2u8Mx2pPkV7Vh00Hg8gvgguDBFxrCTkOxHBLaJacpP+lT+fbpIRG x0iVOq18pJI4pKqPsdLbsJ7HuO1NbUlKteLEuy5PVKAFXeL2T+ifacE5UzySSls9YUPp i4naBLQJ+/YOyUZ/Q7w16Xoo5NyMaOdvLqaV+x2rzBs2S9+/qAoEGN3tvwoTBkj0Wohy Gqqg67Pur5TFxgiyniIKEN+M6pxei0Vz4eHA7q2HXHobzI1ztiPIOonQMqDG5gpJCOx0 WWalLNg8BuC1u58G8gAOEX3angFvGa5Y148ryuLecuYhtfdCjdqUbT5EvteZ7wscJBCg 6PVQ== X-Gm-Message-State: AOJu0YyuLSYrtMm2nkZu5NoHZtQ7rGgywZfusnKa6vdveVxCNKdF0aWW TJ6K2q7IJvA/UZ7D3Y5CNTDQiG5MRzl9N5UrK8q3TLnGN8pknTg0gJx4+yaTIDca8We8jm/BIXw ZJ3Ih2vs= X-Gm-Gg: ASbGnct2mhJkme0btjbnxKpYCtA0lrN3qgb6iHaYpRK9Pc17v3umf9lXHZ4rsgGmfU4 oRafCHhNnuRD0LOgzpGl80JIYEFzD4s3Fw6K3L5oPLgS/OEtgN37m/q2kxHW6dhOLXOXSCD634w BCRVqkZ5wLVAWEH6ZQzEj62iEX+DwT0NdGw9BlzcE6fr+qfnxSw9My6ZduQesIWbwPgKfo4CSKt w/tGIbE/zNJ2c8GveCZIbTVE/jryo4xI15up+rWffFUe7AY0VJZ9m6e+6Wvnl4urOvZ2SQ7N0Th MOr54EwJMW1V0bujIqq5bnQEXAfxrUI6QfN2ZtyGcwTISPX8OupeTW2nVkCGm1IXLxsZCY5HFLB g1PsJpPM4t3kv7rfEgNON2DcYl7gydMPPgoLGWJqhe6d4JkY= X-Google-Smtp-Source: AGHT+IGEamxMvrYocxet/aTZQP6ijcQhpmNxzVnDf0Zka+EgWDe933VyF8cqARSCNxWakiORI9P4Ig== X-Received: by 2002:a05:6a00:1883:b0:76b:ef8f:c277 with SMTP id d2e1a72fcca58-76e2fd0f872mr4760406b3a.11.1755176634307; Thu, 14 Aug 2025 06:03:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 51/85] target/arm: Add syndrome data for EC_GCS Date: Thu, 14 Aug 2025 22:57:18 +1000 Message-ID: <20250814125752.164107-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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, 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: 1755176778741124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755176880; cv=none; d=zohomail.com; s=zohoarc; b=LYe5p9YvwurL5RaAmiw9s52M0waaTPGtXuDrFww4ats+qn3L/Voc50Cv9Bge9nA9muaHHKQq089E7/FyByLDWfcRkLE6RTZxhzK0lj6nFK7vwPwiO20HdxhNVuRuUk1x1SN6684FX17E1rYWem0o42OT9bx1MkyrcOyDJqlrQu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176880; 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=A5VNVBroeWrSTzvcoqG3m7tNiHCdmeVIh4imELFthq8zk9VZ//h3q8scNZjaNsG19Tg21AI3KUOsYkv/MkqifpnEQ5BVn5oUKzUd7CocVkfmRlW/9XDZzmHbyUcexsl6X+U+GzmstwUmU4uLTDYByjvGVHxdumuAMfF5dY0JfBo= 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 1755176880477269.2834728082605; Thu, 14 Aug 2025 06:08:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXd7-0002Rc-1u; Thu, 14 Aug 2025 09:04:29 -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 1umXcn-0002At-Dw for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:10 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcf-00058f-Tw for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:09 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-76e2ea94c7cso875128b3a.2 for ; Thu, 14 Aug 2025 06:03:59 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176638; x=1755781438; 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=tn1oTa+pmDLn7cyYSK9kPKL4cYV8ipBfUZOYx9pIPzXJ/ikiPFJLJv1AqQNQPwezzt OwdHWJcuwM7aX3P5WCEiZlY1V6FeGtGn+JVPd1kz/JFkHOzsdiEX28nruRsFuxrQN050 8p+xECIt+q2KiPyc1U9FL/IXErnlyrkfwvLnOfqdcoVBJ42qORonF5MPKPigxPQ1kdDd zyF/MMlgYhq6mtzkN3cRjyizDoZfOq47QH8vX/K7GO1lMfNTlrMPrgBg0QFBN44ZwGG3 6x/ze6L2Ow7echMm164LcuwbjvOoQplkYnda2gEd3vNTiVROMFG5kWITP1BthQXthnQ8 3D1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176638; x=1755781438; 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=frD8VnQnf2c88Q0+J7bXg4O27HhwwQd2QoBAmHE7qD4s+eGEcdJpOjmqkUkGaWd+OJ RXE2f2h5lmO32nQQrva92pIPzjQGyf35MKRiDg+Zo8K8YKIBoRfXKrL24f4QBfJ3Kknd qs7E5g/PMPeLaF/rkdZFbGh73DKJBln5D4ONzMoRapkjMVdAUfZ8mOHkUXooRzshx/9D oVVVsdUJB383J92wR5omAYY4/DBjh86JyjZEyfb+D7nPo3bpBC2YfO5wxe5l/9g66Ds3 XR1pJ90/ppX7eSSW2iI1K0Lirhl4RWPi1sWQYVhvn6cCU205ZTFo7D65ZxJTjR4tgzKA IROw== X-Gm-Message-State: AOJu0YzTu6rzq5bNTNhM+anRuAOqAuq3PAktnxTynzEU6U3utQdSfc1l haGjgkxLItVGv+Ea1PkC8UJCDEnK4w/7r/rCSnD7FR/bl8ObuhpfdzJ9bbSDvzbUxkPnnmy/Ya8 zDZyJXio= X-Gm-Gg: ASbGncvxkEhHhple/zyOgBcnmDi7SRA6VBXRUdlOochSRLDMGNPCla+aWRC/GzDXWta LJqt9IpdfgzhVx4GI3TWjcE/4ENuAxdNxIpM3VuUNiBRR7MivjzDFvlpV6ywTKHzcZvB6mlf8Qf z29cPe/rcjPSTXJQ/tf0YeBAzaefuqius7OS5hBkxhEMrKS7q4Sjn7VDW+dsIk6FBuNAAtGpt2O ru4IqnogmFYsl0W0SVg9CUE/V7O3+sf3QqcWMQf9WNh18j40ZoUqiZS6KWW4tDECWVUxgrSuVsW oySGrt1ATS96A0faAlGlWejqELyLVV5Qnf5ztI28Rp86H+LHsv/az89CozzNRLNfdhnVcOh6PP8 0xBzK0cF6R5nsxz/nXuZ+ksX5C5aI6Ab9ERMJyYjOrv8NiTaBEG+/yY7jnQ== X-Google-Smtp-Source: AGHT+IEL9qDLF5vz11BuqMZfKdEfZhhKyph/Nv1isgtnclzKCzdmqP1tfgC0yLOhUORBtV3juaLzxg== X-Received: by 2002:a05:6a20:3947:b0:240:1c36:7979 with SMTP id adf61e73a8af0-240bd2405e0mr4197040637.28.1755176637451; Thu, 14 Aug 2025 06:03:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 52/85] target/arm: Implement EXLOCKException for ELR_ELx and SPSR_ELx Date: Thu, 14 Aug 2025 22:57:19 +1000 Message-ID: <20250814125752.164107-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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, 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: 1755176881889124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755176782; cv=none; d=zohomail.com; s=zohoarc; b=h2kkthzHPbb9gz7/hGKqpLIXo6RYC3YHMQyOrjNIN6KATCnKNHQjHhJNrRn4T9FtdwoLYfZ6cbZTYKxohr+TYTDLJq/e6htLYiDiQJXyUKSvEMSpH8BCosb8OP7iuLN1L3N7mhwzYKZFHIE+4kIjsssqYEs08eMMU+ojtCeKlQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176782; 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=mqmDe6w/90AYf0L7p63YCs4DNQ0C7r8cOTIqdHyd11acuchCx9FX2ghIwnVKMsp34ZmnN5QbE99cQqrnoC2VkP/xqlOjsnGbxR8zOLUI4X97xHAUP+higRlz98N1orD9zOFE/aESfIZARTh3o4yhGskils/7lupTl1yuPr5A+E0= 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 1755176782516438.9810603891383; Thu, 14 Aug 2025 06:06:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeF-0003ok-1A; Thu, 14 Aug 2025 09:05: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 1umXcl-00027V-1C for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:09 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcg-000596-Qf for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:05 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-76e2e613e90so656985b3a.0 for ; Thu, 14 Aug 2025 06:04:02 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176640; x=1755781440; 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=FZp3Xh+Swexc23JNWzCCipi8U6MJcY8OguBqMgwPjX/iwMzrWUkC0D/Ea+Zc7WgvoX DhhD1z8EFh97qZeTkEq8FOiiUAgVV544fM/Jc1Z6WgzxFb+7VMfxn/RM3rcIy2oJHjsm MuzB9pVm1D7CuKLDa6eGzIkFcBt/6gjARbDUkE0POqhOYqCDAfh7hseVl1TW6F44yv5U C+SvSr/gKsrnDY6mR2eqW76jdgj4JvL2oTfu7lFCrCIH7VG/zXLrfnEKvucO1cq3YaQI fqyQdOSU9RfeU80gMkx+e5e4fAej5hgIqJXHawz3Ntg9lP66/bXE/F3P6yScQzbGXTl/ Nv7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176640; x=1755781440; 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=ebCa2sdyj91RL3I4zD6Dla/wrRlxe/xlcGJhIgeBzfPDKS9GeLHskoWIqYYPYTJbm5 q7V2scqau8Cj7HZhkLPyDj8Mz5B9KIcNuhxsGo1EhBx7elq6e592ivrxv51wyWYqBVjz mAsdGVNPVoaiwysfFwkdTLy0nkFULMKhiJStCn7tE17PrlXhUxvkWwCa1LBAYCP9oZEN 384/ZT4rjzShWxIES6388Jm+JyPj3KWI8qfYnMUGIgxd69HwdSlci1Nl8zReZ0WB2CvL gNFVQOw/8lub9Xc8mwYtn51u87hUs/4gVmWaINM2YpmL5JJxLg7mle5dbYiB/3uglBdR XrvQ== X-Gm-Message-State: AOJu0Yzh5htdganaPCsVRHvJu8+izkjdR5XaiuOZrtHZCCtyDORygHqb HUXoFOeHBluk4EPJOb6OO3AXgjS/Ol0UK00PjRHz6jFjrUY4uqdR3EqSNdZHiqvb5I+j1jLF0N8 Gqkcne8E= X-Gm-Gg: ASbGncsahOx4B9Yfp1hkZeLqinDbKdGKP1WTD6Cx9KI+0WKuISlw6we9AN9nJGjwrV7 pU8fAQCirUfAu+vaofZLLkJhjh4udL2h2RbiDttSwOtzT8HOrGADviDypBPLHZaiGFf0PaAs7de UDLPNhWNkX7IssWuNzKnCycEmTpwkoZaZLFofKyQkLRlBrREYSGQ/Ynzt1JiVz6CjqLy27rd6ER ujlHUaRBTq6HA4m0Q3mDhQ5kgpFvjDnqF3lFiHu82xthS000dMDzhKBDI+639m0UG9ZIZSvuRbZ w1zM9ulEXlRsI9OSk7+iE9u2XBUAdVO2Ps4akgFE1d3+/qemAk4HN9uj0fI+8Ha1uZygVtMBb/n pzJnHONp45TTv9YzhzqT/y+RBNbZPgRl3hOQLJGrtQCQvISM= X-Google-Smtp-Source: AGHT+IFJHh2BjyRpgAU4wUJUXEFilaka3qvCmU03AZkSOg50l2jHfefqGjhioZ1hSPwbLS5+1hh99Q== X-Received: by 2002:a05:6a20:914f:b0:23d:de52:a5f0 with SMTP id adf61e73a8af0-240bd261906mr5335555637.42.1755176640339; Thu, 14 Aug 2025 06:04:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 53/85] target/arm: Split {arm,core}_user_mem_index Date: Thu, 14 Aug 2025 22:57:20 +1000 Message-ID: <20250814125752.164107-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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: 1755176784837124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177489; cv=none; d=zohomail.com; s=zohoarc; b=CYb58nyge2qFl9gINY4m7+cW6yopdiUa3ZaEHgDpGRnI1r7FjUV2YaBL027EU4pFBBDHMr0Yigtn8cf40yRyVVQfsqh4XGHZw9BrE/pZNREne8jv2BvQaBo9k9Jng5WweyjCbsiJdCzDkUVTZJm1PFJIkGdulsXKy9u+fyd82nY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177489; 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=R6xF1vmSNWj1nt704e6YxiHy2bIvOsI/F/GaK2iGc09Z5HMKJ6efsajeQ+LM947tcRVHg8PKImpZG0qCQiDPBpUFOtXoZVRQHiO3fb2fBHDrkaJTy+npmTkf0giSwwqSEDSSW5fQteR2Kbx0FaZUdhMS6BIiE4ArNspDSEPZyfQ= 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 1755177489907389.19907476686774; Thu, 14 Aug 2025 06:18:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXdZ-00030N-3B; Thu, 14 Aug 2025 09:04: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 1umXcr-0002H2-Ay for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:15 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcj-00059j-GZ for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:12 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-76e2ebe86ecso1164279b3a.3 for ; Thu, 14 Aug 2025 06:04:04 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176643; x=1755781443; 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=ouu7aC72THOs+DwBpub2fCgKW55+N/ig/vNByebe1Hj1YfZ+cI9YOogLmqxS2jKLQJ 6ypOy1JWY2VOzBLY4dsdBniGz0iqG9g6j5E84vkaXwvl/qVjSCaaNsC1oKzJmDYFUmwn X8CFnQttZdxHYBrL245sZDxYTjb4S5teIwpDWlwgGV1nYcyHJLo7smHg9dkR8crGbFUi INe8xCqwqMAJQ+jjAvi4fVuzMRCGx+vJdEYseJZCstKoMc8qBuvqFpS9vndAOTNtl8f6 k6RmlYfJwv+3NAaxlftSbI+dKTlUr45IREs8C1G2LyeeMfWh4+Ufh9fTEfo7cVBnqI98 NzUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176643; x=1755781443; 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=re/vozfIFVhO6IGLVWznLdQens+bIjT3+xS5AWCmYp9V1W01McmgnBtpW2fBlB4xbt iSU6x8+JkCsDCf3G4rEwVrvclbxHW9LpUKx+BGTTgWl0TYQicOLH52iwC6B0ARJO58uY fRv5vy3kfAZ+agDLLG3icYl8YtRf3CrU8SsLcjzp5P3MCsaR2XauEL2/h748XGJqsekK wjV9kDuuy3wRcif/Y+i9WxBADK2/nYUQULgDfF1vPLkCiK3Q/vE45ESZwwi/E27cXLvt oFrMKIDZJOulrXXaXjVSUSa2FizPFXMvNd8MlQs95kbeNS9nja+cZSE7fLXWi8j09GMw K1ng== X-Gm-Message-State: AOJu0Yzw+jiBiCSeAyKFXfOaFBa0yTkCMMS5XOdFXH63Udx25qKjNXEg Rte1BQ8bB/c6Oh9K3M1DvWNG7In+VBSrDVs1g3ylIhZkmVIjkf2B/6kAmla4ACX1NkoSA/MLHLg sUmAXMx0= X-Gm-Gg: ASbGncv5kt6q5QJDmvlr1m7tqnAjkK/i+TKWEIvel3p/O3TPT3Tqdxr3DS3uhC95DUR TPXuRXR+gLrEivI6WcBxLIo1t5yZ7o7LmCVls9un2rziaetFDVbA5V44PSo+eTN8ylc5tPtddg6 kXrEDkmnlVKzhCUaAduJScjISdSvma+20glZkwm7e7jAyLw0JAwu3hq9T1/6nAkNtyHrxMHE8f2 deFryqLRD99RiMPdMOibOibajtkYrGXItbRhq65WPnBPZfqePIZnwqSPVY3BqMOPA87KG5uYgP0 7ApV22kMDhZ7zOECBqUF14edL894i6C/1qg4QtmBfnyDmaEsYol42XTPnHxX3sWFhyC0qEdCvmd hB4+gST5dwDEcZkf+1cx+jwclMkSVCeK6+fbm2LqkYHCuW0U= X-Google-Smtp-Source: AGHT+IHdz9z1AZIeiDbiBCSmPdmb0jtoHHdcEc3qz3/8wn3c7fQHIDhM8/3vpLiahSc5ynZHBl5SCw== X-Received: by 2002:a05:6a20:939e:b0:23f:f96c:1197 with SMTP id adf61e73a8af0-240bd23bd4cmr5262022637.24.1755176643328; Thu, 14 Aug 2025 06:04:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 54/85] target/arm: Introduce delay_exception{_el} Date: Thu, 14 Aug 2025 22:57:21 +1000 Message-ID: <20250814125752.164107-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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: 1755177492626124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177230; cv=none; d=zohomail.com; s=zohoarc; b=c64iMYi3m0QoCWBG1z3syuwtThFbT0VjAnzvhmO07fml0OBCwr8RtLtCaq2X9ZvzLH2N/yCBKLF86aM7oTzN+XafoVCaxmadDCdYaHk94zvWbExAs7CuZc5/LnUC1kB4dEIS353mt2G02rfX/kwmCdRWmC8j3i1qH67En8NhxZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177230; 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=V6ZlpuAOHFqAsQugESIKHJIx7nSjCMT1klf9/fDGbXKA2IUwquqoEpIifPOxaCV4XyZFrDGO6v4BVoFenPfDxmTPo/SZk8sLuGhdmv4Pwl2V4+/SrkgBgVZ2nChoay4KgemXwVDs5/PLa8Z/8gvH/gnNCTe0uCs4AK51UbfpvF0= 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 1755177230223106.14050455735094; Thu, 14 Aug 2025 06:13:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeF-0003oa-2x; Thu, 14 Aug 2025 09:05: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 1umXcy-0002Mi-96 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:22 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcn-0005AZ-N8 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:20 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-76e2ea933b7so931450b3a.1 for ; Thu, 14 Aug 2025 06:04:08 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176647; x=1755781447; 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=dDqUQKZ+K/mwr6XRXU+m/JUx9RaDOcOu5WoVfYePn3ZafRO+k0LWNynoPtW0kybpSv x5f91tP6YqYrf5EWxiNpQTqyZXLBYqSuFpHcjm8d2M7n+34gcvj9DG2N9ZvS9WZOrmj0 DfYieIvt1ir7t/ImR/qICJNuCkKwHv3SN2uZy4DkXwK67pbOy4m84Rw2G1cOjenNBO6U QLjI0cEB/i+tVGA+oqX3JL/DWyH99+OrYM/oYwWceKWpz5IPKNoBpARLKWUswjwE4nWe +DgAaUnsBzZhHodCh8amO7vpubIxOWP+Ocnx+1rnlyHsXJG651CTed+p06takgdMDC2o q5bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176647; x=1755781447; 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=Mya/DP756iVn6oujrFY+P97aro1mu8yEMz+2T6vj3RZpPgoRh8PvBLXCye2PmVwyHF DLRiU3IId99SyEiWwSGVpE5F+sKTAOnWSuNKQphGdWBYUD+majKKKzwgN/XSGL9G9aLO 2sSN5MRcpeBc9JRgxOyrZQ+DqEMTH34p8an98C0G8LaW3k74qbi6x3JWh008odZs7Kxk OvZz5nicex5YVNet/YW95Ar+g4I1tlMj2aOpS5CFQtSrPxYniowgBKeTnDxpqATTo6x7 CIOvOZWxLsFiePC+JDsQtvBCS0FJzjbG4NpVevPola6+wHfBtPJefRGmCMDmlRXvgUmw 08vA== X-Gm-Message-State: AOJu0YxWWBcf9TaG5zzhJqTGy9dkwmqHEl29yuecYYsLzIwgBlywhf/F KmSH1BkgXMttV0f/P/qE4dhu0R9cz3nxuCpAxJu20f38tiTHZ9oxrVqyMHH3U5NlYWj5U0aEN5r 4qtx1Y3g= X-Gm-Gg: ASbGncsJ5lXAvGLGv+urN1G/dNdODGpaUCiabFXGEDDP433mfN8ZM4KIepLpAlRd8Fj h18nNfC96oFVWIuW0EPmuC6oLxGP6xgSwugEcK2Zz0IGzE8bKP+E/uY6YfNPz+FM8GAwAjTfRq8 lzVpS9gkbe2vBKfE26aLcjYWzFd1zROJhraItW1NHS8XcOKoZPFp+0QgCdHBauFQs4ZLO6L4COn sNWAYLyIPighmC7qOkznngU/YtlKMu67vaSP7zieeykxES0YHSYsWpJW2j7BThFqceoAaNBr1Tk xxVGyrgx7G1yuXR7XXLJghi2Qf6Hqu5l1miNFRYEjWkd5Vv2E9Cn8SvuhudN7SPr35+YpImiOvu FoOgSKPdD2ooUnyR19oq9jM85koxrN9j0MXS/qG5KWewWfIk= X-Google-Smtp-Source: AGHT+IHbcL9yFtTdFvbJWhleQZlD98zUECBjX9xEHWFbaAH21wwuK1d4JHDgOj3pgY+eTw5tFboK8Q== X-Received: by 2002:a05:6a00:91d3:b0:742:aed4:3e1 with SMTP id d2e1a72fcca58-76e321f1e29mr3765791b3a.2.1755176646935; Thu, 14 Aug 2025 06:04:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 55/85] target/arm: Emit HSTR trap exception out of line Date: Thu, 14 Aug 2025 22:57:22 +1000 Message-ID: <20250814125752.164107-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 1755177231103116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177218; cv=none; d=zohomail.com; s=zohoarc; b=acpI7Ct1QqH+lhp4DOUJtKdoqUGG3edfokW6P6UjLFMLwOeX1AooQ7HqzFQne7B1RhZ6k8BAx4LKID9viE4APejDVsJ3apkG5yBGWKpKV59MEGwI4596nQ6Y+x1I8T0sdMXa4sGXNtiAKu3TZCTWBhxjIlz4xWdaLvb3Qm25Vhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177218; 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=Bh15SWtgiS5pscfsb+SINmiBEfhd0RukWazSXGWQ7EZMeeQebCDmt+/uhNh9L0Ag1UEeS4MwPA58ewg+Kv6ZX7Clp14gtauP12QwNyq093vS0A1OE8tDgkU0LuPD6DXx8M4gnYs+S+La6X15zNqLPhMX7lSWZ35xpFHgbsKZGio= 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 175517721887466.62353675341785; Thu, 14 Aug 2025 06:13:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeK-0003zT-7b; Thu, 14 Aug 2025 09:05: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 1umXd6-0002SI-2Q for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:28 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcx-0005CY-QV for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:27 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-76e2eb6ce24so871089b3a.3 for ; Thu, 14 Aug 2025 06:04:17 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176655; x=1755781455; 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=Xu2l+9doRa2p58XxoYGX/BMDhNS2uYREsS0/Sd4scXld7UAK8DomR0WxOs1ZMt5NY5 Egqv4oLTW8l7O/TOM/XM5kd4DzAJnKTxcfWGueFR2QJOP1ZZrOLf6ne8kZxJB+APSUK+ Nm0Os7h8CKEPuHpXitSy7pOjDyc6BnGXLddJ9fxkOKVlZa8p5JpSuVEua/Kag7F67xX4 dq4M2MyGSDrnG7k5Cmtd5/lbbWUAlf3grVdmUQBcu66E8oDO3r740bviVN34Lr66vg6X z1gAV/wIIrol7PLg+XDvO172rvVK4gffBeMABtDjfFMjKKtR9IMZfiMSQRewBh3rRAJr qjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176655; x=1755781455; 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=FR3odS62lWS4p0plzrWN95h1OJVRHs/pVI5npTWhHy3S6UVPvtD4cRSmpzbsgBSZew m5b4cqv6pQRZwTFQVfMO8GHhwMrCDBqR2fSeuqghLXf8Qy2gNHDPIv68v/EmDgNtew4v ZJEdVCqTBLDEHPfawQRUiSaiMKsuabrW8Ou+En9N/BXhxh5XvdQ88xFhuGMDmAo5Foxt G6+H9gJJIfie4XRAZZWoS5df493pKrxXigi3kznHLr5Lm1ISL7kpFsDU8wGuKT2O68TS oKGWAS2T9INGM4OG2CeQ8RJ7Cuna6DnDxaMz25ppncbp4IcNtuujf2DMVOA17hCQgRsV Tx4w== X-Gm-Message-State: AOJu0YzE37vBKvLRyzypS/Fr3gwdJF6Ybur1djkmPLgigx6FQIBeP6B/ uExn7Iqp1HVvzHPx6KmhGn77gWu55vXBx4WpXlB57lpWphbI1NgGx3VbTGTkfaLi+O9Lqw+k7RE xzLK7Hzw= X-Gm-Gg: ASbGnctywFvMpcoN0S/oHP32hieuEWSF6Ei5SaHH+3ZPfzbeo/ty1XZp+bZk+GqSy6r Hb6RwJYkgxKkOlXFVsz7pHKn1cJ7kfIlTlxe702VGf3pIAbShdL2y3POGcpQX1St1RP5Nn6Omdy z6r7G3aKq5UBUXgLpPy7YhLvJ36UgPl/t4XoecmucIeLDQ1W+oiSLuK+YEjgwvqfi6JjBg7BFuI fsSq05HP9OmJrfXRJTqlPAnY1fdlRTdKz6iSEjNzLLa9/3YqshbpoImTzMNQC7xctYQRgJu/s46 fu7zpxjLUgnmkrIXS6qGgVN5ffQwaLfDMRlX1/X5vc4r1Rrnd5vHyO63FR16jEjnQN2qQAR7J8q q7xlSJD8MCIdCc1QkI9OLOp0eiZZwWkSuKxE6p1BMfBg62ns= X-Google-Smtp-Source: AGHT+IHqdxRRDBrq443rv8jsjug/ztz2Gyg5PyVKaOZSVL3XJUjW2vsaadTCuLeGMw10heHkWfTDYA== X-Received: by 2002:a05:6a00:883:b0:740:afda:a742 with SMTP id d2e1a72fcca58-76e2f5cdfabmr4593689b3a.0.1755176650188; Thu, 14 Aug 2025 06:04:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 56/85] target/arm: Emit v7m LTPSIZE exception out of line Date: Thu, 14 Aug 2025 22:57:23 +1000 Message-ID: <20250814125752.164107-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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, T_SPF_TEMPERROR=0.01 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: 1755177220985116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177558; cv=none; d=zohomail.com; s=zohoarc; b=i3xvikLhRXHeEoougo2BRUVfYRzk+aonC9JuBrwgfFbJCgli4RaR1Fjrjd9/XrWp03flEFMuolaTni5zjHLNGYE5+xUI2yScotxRjJ5qYd1N0n701z+FFXJ7uU79RGZyO08mtGB/xJkq0MRQbtQxpzPjy8HNwTYrm3z/LVRHBFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177558; 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=J/Cc6zU3gwyQYgJhbuvQ34OXcHhjbQqcS46spbmDRntTkvdXudxMri9VYedHX7m4nqsaWdxjJj1glLFIHizakfXBfTOtEDTmJQXng0/qduo16f27uIqiyHfT0lf4PtDtAS7PrDgX49cokvXt10Vc2UmUxwgoY7pnDoWMXV3yiiE= 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 1755177558269877.4754014266022; Thu, 14 Aug 2025 06:19:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXdv-0003Ln-RO; Thu, 14 Aug 2025 09:05: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 1umXd2-0002PM-KR for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:26 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcx-0005C5-9m for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:24 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-76e2eb6d07bso918512b3a.3 for ; Thu, 14 Aug 2025 06:04:15 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176653; x=1755781453; 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=xSFtLu1fYuvWJtGQTx6g51ffCylKokfKa+akYiBujK70ISy5vYowH5w7y87mw0It1K zyAimLWb20a+Zqh+tiMta3dQjpR939wfngBOOuakBmBfzJu4fDweivjpDShKIZ/yi54e yXMECYOCeq+nt6/jJZ0C89SyDpaXDWhz9wra4UpV4NY/LCh5QtJ/7mwxg+9uPMfIANId L8f875R1XItjqIlc02EP1CMBpl6/b3edp2kgRQSNUO5yKNKR4CuQ5nIDvGo8t+AxJttT IMA7AsDdaZ1mjzZhMbp9BeoyR2MOsNoJgocmjyg61ucya11o7yaY9bEFFiAnl8wCfu3B gkEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176653; x=1755781453; 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=SqIECqy9Jjuo6m9vZfX3BTsp5uy/PebauGn+poPD5/0b+y1FgUaE0EvXgHnWfxKvds yMKqlDuZmcVq6xsBhJDvH6l2fy3b/ISjs7STKh7RYCILyhBoRA9bf4on5jMk4ecvrEYS g9euTdOoGpBBvFdoKAoNOVQ1Nz46gmiev2P46bkA6hDDlNaI5XDfUNSBGrWUtZYZLI3C 3nOXh5fMR5hrDoXoN13Qhr9gYncw2h0+oiBl9eI/iW5GBGPD/XLnTiwRQ5ZcN63BJAkc IA2bus+UOSK4NxcCoActDqnLjUXzx8F3LN5bvxRUxSz7fhhU7CLK8eU3ZPFbX51cn/9P +9rw== X-Gm-Message-State: AOJu0YwSQUL+7VsDHM6RvrgIGHWV5i9TwHma68f7miuOMqt83hPc0Ab+ ls8TeZmlFzw8mOzMJ7WI48L7HBF3RA8iZVZlnnIVXFUS6AN/izhU/tkd6MNo6cLAb7C5BLLLhpf H06xa5Kc= X-Gm-Gg: ASbGncstzleCaLLVbxeN0deb2e7+Wfbt88RRLXMBrlpe3ffKQu0Xa7SnkJAX795Op7U EzMZeqPURWpLdl0LxpgIgVlBHZhPms2zaDmddTXoMWHNcIMt83yoTOyruQZXuRkNFyt2N5K3rUq 5weWLXbUyN1rMBq3GCUy21Wt9BcnLp+l951ur7iIF/cp4MSa7Q32y8pvalNLxJo/1lKxj6GgWNF D/nZzVwgiP3Vi/k8/nZqxfhSI5pXa8xOxUvKRRXI4jGYulX1VIH0m87APKDYweE9gJwQoMGkGp+ OAxGZ6ff5mXQdg/KQtgaghylRW+V6fzhvq5V5OKFpMEtNW7cKMC6/RuUD0l0xoroPXTSC8WJe9O lCiV1YBR3dWrHO7xGk3BTLlGGO84bTgNod4Re6a5Hbgsov+I= X-Google-Smtp-Source: AGHT+IEvfvwkn3SJsnKBE8qpJUlA0Chrb3qugGLDUvIlAaAfKfoCZICZxRPH/UFwIPHFp3W0xhAWug== X-Received: by 2002:a05:6a00:23c4:b0:76b:ec81:bcc9 with SMTP id d2e1a72fcca58-76e2fb2f79emr4054458b3a.21.1755176653245; Thu, 14 Aug 2025 06:04:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 57/85] target/arm: Implement GCSSTR, GCSSTTR Date: Thu, 14 Aug 2025 22:57:24 +1000 Message-ID: <20250814125752.164107-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: 1755177561228124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177083; cv=none; d=zohomail.com; s=zohoarc; b=TOcN7lKYlKssmNpJLNTpZm1laEqcVV+9HoIPxu35nRk0Y38dumF8FzrKvUv8cFH59DpuMQBtyySYvTTXobIcjuv4vx/Sd85I90f6d70TMyIuPQ+jyijH11llmjt7+H8xbJkdJpWxmqehVV4O9zsUH6L39IECEIxzleQOw2uI0hc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177083; 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=jUXRh7z3oJfW7oj+A/mRfltOcnQRbRrx4ICpjRNt66Dt4bto5pIMTnALJznfJWj9eTU+KlapnDZ1lwaIe7mLlpHnqgbF7aFm8r5CJGMYg9jRfv/ObDHuC3Bor++mCtBh/YeJxocsJKMYhp6WgG4jdyHsrqMo//4oSZIS2XTD2IU= 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 1755177083070678.8204099422089; Thu, 14 Aug 2025 06:11:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeH-0003tO-Rs; Thu, 14 Aug 2025 09:05:42 -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 1umXd5-0002RE-Na for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:28 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXcx-0005Co-7r for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:25 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-76e2e8e54f8so765996b3a.1 for ; Thu, 14 Aug 2025 06:04:18 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176657; x=1755781457; 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=usTz9fTXBVkMY4ZuWxXPeIDns5tFcjOoXg2m6H9Q3ImOlj8xyYMooTEzGVC2aOjD+l 4lU6orl+cKpllZUvmwbZefGBrtunmwzHAabhYbr9Y0NPa437q9sLqzS36H+TAD1tdPQl D5pQDB5xu0lH61R7n+R9yLics7C/4jHhhSr1wKIl14Dp8WJxispdxMuZjSNwGNIL5mdr HsMPfUvNRP36eTagr3U3cESLG+oEuVl6ClUi/O70T+Bb9bJ8rsT15WQTDEAv19rsIRSW ggwwZwXqe7+trqyuAhFtW4I937NNnV4/uthDNsQ+Fn/AhCumPbRYpLTSspTMtk7/Gvoi zC3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176657; x=1755781457; 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=smEQVVUcY+d2iALOOMA20YMS0LB+jH/xZFWeIgNJdRb0HO7x0OafnDRfCQ5Uyt919Q 1kapuS3DLHsByLab1tymvLzPHBY98L47vb6usDpo7X9tiRQRLGdZfA1JC5nvOISVuv/I ypTqDKT8wsfi8OrYnb5xh9CPd0eAkX1k+TE+071jvppdt5YBnDFDFBfTvUeVws66N4z3 ckv1eO++Um+FZftYUYcelRBCuxm7FLv/D8GgTh9ke9MD8CY893KwrqHAVxqc44syxcAV I0PhIpjC4dgaG4nisq06Y6ATVFhRAC7Hzmd+V7xpgOzK8PIEG0Dvjm6bxe+YhHj2/PrY 4MMA== X-Gm-Message-State: AOJu0Yzu1DsNcry/t8Pc/aauPVXZjeCyJKdV49DAgsmNE78DI2LKv5wn T11HBnMPws4L30fpHKBEhab5OsIAGq3E7Y4Paawj13M7aCNofEhq61GluYuZvECaJU8hSRs6P80 8lRuCdAI= X-Gm-Gg: ASbGncvRIq42hOQ3Vz8I5iDz1KsahykrCasPP5oXQwdjymrvIwj12CBZY+PiWEUw65j i+7OEZ/N1ceIpIJt/fNSue6I7YKyg7ZbUdQkOCbAvLQj/rck2Csgu1c0CFlBawmd/XikLbr1+W7 a5ab7S98Us9hJ1RXVtffTRS2EfytthGR3/4xRj9P/tULVmvY9pj2962xvhoKUzhCz85sAqXaURJ obenptZW2XwdYzxviMpWvE4abeMIngK3KBNa65cdptywyMznLQarf4aN/9Az0/LjjkFOoSMRXAo 0gKEE6wzx0zMtNSw/UpEqT66qg41M5i31WUiLqIWhZlO7/YHJMeJO8G0Fx/SRxPgyW9QK+lvmGr y4dKQW3r75advOkw2H3B625nvqYdsjdlsDb2SPT+oVAaNjHM= X-Google-Smtp-Source: AGHT+IGi4STbiXxqX7ydKBk1Eo4SwY7tndTuha0jz1nEHtSfIrUp90SXc6DtzkroqEInQgPbtarhgA== X-Received: by 2002:a05:6a00:3d4b:b0:748:e9e4:d970 with SMTP id d2e1a72fcca58-76e2f8ce77bmr4073627b3a.1.1755176656425; Thu, 14 Aug 2025 06:04:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 58/85] target/arm: Implement GCSB Date: Thu, 14 Aug 2025 22:57:25 +1000 Message-ID: <20250814125752.164107-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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: 1755177085594116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177499; cv=none; d=zohomail.com; s=zohoarc; b=dL+c4XvILsTN1kts8upW1NvXhI0tJ19ymQtg9dcow8jjqDWILDt3ll8HE/TCBFhx8hZO/d+orsjYgrt594/6NRsfco7SheMu6DMyGWRXHNEQTrR2qE5fzhA3fXiuvnwXdIAggNPlw+IneI8avISIFUsx0z1dh/i2OLW4Ym0J+gM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177499; 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=ry0ZsXjHszKipidyoRWNoHHhZAabsET+1FA/mv45g1c=; b=B84C+xiKaz7EEb+9E0/I0WabmTDgpkpqc5ORuAWi7NOOlOZqyeqXhZH6H7Cpw7tHEsLfyxrWhGthOYxj5uOasgp5ROxQ75bqKyd5Y1Wlnt4FdheinkTgssxSV3+qnbkBtExN1eDfCc315fJds9GgVNeuAfzgFTbBNN7PS0GWqmI= 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 1755177499178416.60373784195224; Thu, 14 Aug 2025 06:18:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeC-0003hp-GM; Thu, 14 Aug 2025 09:05: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 1umXd6-0002SA-13 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:28 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXd1-0005DX-An for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:27 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-76e1fc69f86so1525288b3a.0 for ; Thu, 14 Aug 2025 06:04:22 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176659; x=1755781459; 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=ry0ZsXjHszKipidyoRWNoHHhZAabsET+1FA/mv45g1c=; b=PL8v9ZUCMtpYMeclbrcetE3gygjgd2cxLLttp45cdTW/mBYoM+lSrEPOULPDgSXXu8 dZDCtBcKmCNZoEtJrKingU7vrgXs5SKN6z1gF52t+J08ZItfh73VBXakBWYc4tUxPv0a FvObcCLVrbibeYglYmDp3vD3KFRzL6Ff5KDnPpaUEQxGRpmkSMK5C+giiG3jq9Tf18ag vQjC7ybwHwGw1E11cqmQ9w1Xqe7WBBPKqZIbB308ylKjUwX6Huaz6wdZdJK33M0Be+6W 8HyOHlltF2KNHWEuO+IKDIy2a4UsE6U04zN7upOxOlWLJmlEiZQD6QCbWz8EgDmYS9SU d8ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176659; x=1755781459; 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=ry0ZsXjHszKipidyoRWNoHHhZAabsET+1FA/mv45g1c=; b=rLUEdh7DqBpayW5Ak3rTBQHVuhvC3/iayp1DUyhjk2wYuZ6bpVDRxyNZ0VW2Qowtab yUsYVlTh9T4Yy/Xxp3Ai4g/mXfsNO4AentQynJFYk0QD7YEkjP8D9aX9S165RU5HmEG1 q45Qb5u3FiCZ0AXk+NyWn34znpDK44ssgH30cacNKKub9J5f2Ba6UV+pU3AyowM03icL i7ft1gkrWhFbeBzgmSzm0O8L7+KxyqvTE4XXO0/QHWVwFYSr8Tl2ouYbWaBudbqyG1Rc xKgSQxNTBRefGXN7EuYbDxTaSqPuUfGc/1ht7MNwkaYawdVaicuuFbJBM9ok6Uv6p9Nk M1Ig== X-Gm-Message-State: AOJu0Yz58w0iW8IwgovEApe1fYMMwJxxyyuVrsiTf26OXeOEAr2aYIJz oRLr+zTfNtZsjYyPMIMGmAfaGjcJ7e/vNtuPEduV1yi267l3r4VAmSajC1BFpoBv0B0yDVUnLKO J47SCs0o= X-Gm-Gg: ASbGnct6hmDPKUrOaq58us9xmBtgqSzuJyfBr43s7wlhOaiM4D+4Oxg+Rq7jVH4uAjP qrqD4ixo8C+ZkrqYVYG5bVR4lwnjRRzFwqlanEqZuspIU3o0Wqh3d3V8nO5LW3pfL3FT0PLf2QD SurEI8MgG8/bn08PvoPalXfwLwdsyNZK0/9P+rBwAYlizdpIrNVyn7hOCoKYX9/Wdq7fYWWrthQ WAlQKXQAi/m+AaVaklp/D15BrTV/59VlGmsQfff7Dc0MlwTkGYpckNAIgRStzM3mUHCGrluSne0 QNGqmugklmezd78B9NnT3UYQMleMsbnKRHfpzRBPVzylSb0JiJOhTYiMyGWd7hTfArR+MwAzX7W iQP4wsORBrC3IzU5LPV2vwxOfValHqYO9JyrefFaInFILWVo= X-Google-Smtp-Source: AGHT+IHcUiiGTiysj4DynzgleZ5bTP7cBa2fpAenTIDd1mKdI7UGnsVF2PmBzHEPTB7JGW7tEdHBjQ== X-Received: by 2002:a05:6a20:914d:b0:240:177:e820 with SMTP id adf61e73a8af0-240bdfad251mr4230479637.13.1755176659166; Thu, 14 Aug 2025 06:04:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v3 59/85] target/arm: Implement GCSPUSHM Date: Thu, 14 Aug 2025 22:57:26 +1000 Message-ID: <20250814125752.164107-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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: 1755177500700124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 3 +++ target/arm/cpregs-gcs.c | 15 +++++++++++++++ target/arm/tcg/translate-a64.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 47 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 1a64acd584..d17c17dcb7 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -43,6 +43,16 @@ static void gcspr_write(CPUARMState *env, const ARMCPReg= Info *ri, raw_write(env, ri, value & ~7); } =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, @@ -81,6 +91,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, .writefn =3D gcspr_write, .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..39b91eac6d 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -26,6 +26,7 @@ #include "cpregs.h" =20 static TCGv_i64 cpu_X[32]; +static TCGv_i64 cpu_gcspr[32]; static TCGv_i64 cpu_pc; =20 /* Load/store exclusive handling */ @@ -77,6 +78,10 @@ static int scale_by_log2_tag_granule(DisasContext *s, in= t x) /* initialize TCG globals. */ void a64_translate_init(void) { + static const char gcspr_names[4][12] =3D { + "gcspr_el0", "gcspr_el1", "gcspr_el2", "gcspr_el3" + }; + int i; =20 cpu_pc =3D tcg_global_mem_new_i64(tcg_env, @@ -90,6 +95,13 @@ void a64_translate_init(void) =20 cpu_exclusive_high =3D tcg_global_mem_new_i64(tcg_env, offsetof(CPUARMState, exclusive_high), "exclusive_high"); + + for (i =3D 0; i < 4; i++) { + cpu_gcspr[i] =3D + tcg_global_mem_new_i64(tcg_env, + offsetof(CPUARMState, cp15.gcspr_el[i]), + gcspr_names[i]); + } } =20 /* @@ -420,6 +432,18 @@ 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(); + TCGv_i64 gcspr =3D cpu_gcspr[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_addi_i64(addr, gcspr, -8); + tcg_gen_qemu_st_i64(value, clean_data_tbi(s, addr), mmuidx, mop); + tcg_gen_mov_i64(gcspr, addr); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value; @@ -2765,6 +2789,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 Sun Dec 14 20:30:54 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=1755177048; cv=none; d=zohomail.com; s=zohoarc; b=UWsillmHpmyCQXvDn6+yPcRnnhekAxmswEtdGOUu3HUkC10bmzS0E/5tC1GAEICSCPZ+lMZHoJzBw+uevl8b9RN06zHpsTeGL1kVKGJa4GhNhgBEqZsoE0p16sKwMCav7y59SwHl/O34VST+fa9EJ8ALBtfkgcCPoA2dRdEyK0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177048; 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=H4rbUlUKYWvRUhhOgTP67UqV9qz36nhYWL7wMK2fUqY=; b=Kf8cE/1DfigMO1CbgPH3eOQFq5P7DpQwR68j2McQIoCgZEZ6ZkcS2i0H0JDkFei4p/3nff9aVAMukzXb49kX3amPx8GriAqS0iMWRd22z1h0d+lLIXrEyR50U9xQX1rxunvzLc+IILQhSVrUSnHqoFP1mB8+SSl7l1ghuNDf6oc= 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 1755177048940268.2321853425839; Thu, 14 Aug 2025 06:10:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeJ-0003zD-Rr; Thu, 14 Aug 2025 09:05: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 1umXd8-0002Ui-Pe for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:31 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXd2-0005Dr-Vb for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:30 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-76e2e8aff06so852064b3a.1 for ; Thu, 14 Aug 2025 06:04:24 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176663; x=1755781463; 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=H4rbUlUKYWvRUhhOgTP67UqV9qz36nhYWL7wMK2fUqY=; b=XtU7emsDWx7sXgryjV40aeb3ngzunZ1ucBQBPG9FusL5R3y3yeN6Q+8shxQVlIPOGm Ck8U1bqeQrwZjKL40Nqn/7PODLeRDPpdUW/3i6kIURmWAHQPtUA/e5/O9p4YTFXSYVec BUr2J29pzy/mP8C5ddc2wxRbK1LE92mmPeCMjBMg/J4uGhil8pgB2VcOGjY6sWEz/MGy ITKraGSgyrwmQ7f7d0nfRdPPKiS/iK9vEpIR8P96WAajuw2hEtI6OskjyU0JOYXAcEP2 uhiBQVzP77bHXe4e0MgILrXL0MId9KzXEsCh/QwQkEWeylRPXkyQdJ3g8HZlg+Ywxuif HsDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176663; x=1755781463; 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=H4rbUlUKYWvRUhhOgTP67UqV9qz36nhYWL7wMK2fUqY=; b=Af0X4R+zgljPtQkQqhvu2FcexdPTR8Hd/AvXvKXVn4MLDWZtdIDIttUgBgJ0lsFBpT smCrDxsWVk6Rd57W4Iw49C6lIHHGV0IYF7lAAJ9SAfJVz/p2DFJ/bzi1mzZ6DwLYKHr5 HKTFMkA+95neLhM+fj68/X/5jhm/D7yHV3V/qTdFH7iGHc1Fzu9O0Lj0/h27/iUQi0bE hGFYjg+JArA2fXOe4WkYoh6m2GftzUQibiKbuZtKvE8o0W3veDbc2fcd9W/VDLrJKYNf oYt0AYuvgq9Ph+tHzBK8x9NGj3V+RHvwV3ufXH51l1TWFodznjO3r6na+XRZcbHNkCk2 oMug== X-Gm-Message-State: AOJu0Yw+i00uiomuC8sBjomD8BBrg10rGATvWIKZcK0sPHhGaVC6SZXO W7jgySvz9vROSfX/2kTnRpR2iXqkBoshXqA0qUtfIL8dpRR48g+o4gJnbYBHmMTVkbqj521ta3B D/BiCiFQ= X-Gm-Gg: ASbGncsL3Q2WJy1hB0xwCLE8vpji7Z+Y8c9PspZCjGFn4dXlhTB/Z5D4Hlq/0wKFPPv bNBCYJH6enyTcOs/E+ljJYx0PXtpm/3YzrnFYKG8oSEzxY9s8lrx5VIRb/dgfiPPSGSnKjKDw+v sNgI9pU/FryPyiAKsdsk5+OKMS68o7/2MqClS6NY/kchZWOp0mkgti/Aa7DG94UxejvOe6gDoHW 24K9ngJxA/KFhlvj0ZQZRil0IH9rEKkRCoLr/mXkzs0/t5D9h1+DpIQGTSY19fJkl6c/9fMvr0+ 9hbzY46vck9vXNilLArztDAf6IRL4EH9cgwTonjXBHTJOR0BgD5SMTdHRmwaCtJDSLF2iVjsWwG YGgZh++IFfVWrh0/ZjoZycaPquQZL4+X1WX3r7W6EesUKHPM= X-Google-Smtp-Source: AGHT+IG82eVdxhvJDWfj+yKrVbDMSXMaWE/VqfREe8j26gIqenmAqPc04llcRhKA0bWTcAlwZLVo1Q== X-Received: by 2002:aa7:88c5:0:b0:76a:d724:d6fe with SMTP id d2e1a72fcca58-76e2fcecb8emr4497737b3a.11.1755176662376; Thu, 14 Aug 2025 06:04:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 60/85] target/arm: Implement GCSPOPM Date: Thu, 14 Aug 2025 22:57:27 +1000 Message-ID: <20250814125752.164107-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: 1755177049490116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 24 ++++++++++++++++++++++++ 3 files changed, 28 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 d17c17dcb7..fdefb2e17a 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -96,6 +96,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 39b91eac6d..e0dddbdc25 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2513,6 +2513,24 @@ 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) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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 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_qemu_ld_i64(value, clean_data_tbi(s, gcspr), mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_TSTNE, value, 3, fail_label); + + /* Complete the pop and return the value. */ + tcg_gen_addi_i64(gcspr, gcspr, 8); + tcg_gen_mov_i64(cpu_reg(s, rt), value); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2794,6 +2812,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 Sun Dec 14 20:30:54 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=1755177418; cv=none; d=zohomail.com; s=zohoarc; b=iioxMwRuP5dUwHNWTMGIrFW+bZYO0clRS/NvkW8iWerN+VqKbavyA4n3whKHiOCmP4vOpti4dobDIKY+8uYIeAtpyxALadY8VbqsaDKe6y/3Hjkz/gPcyMRQ+sUgt88ksKCK2VtZMEnn0ZJ6QobPvnHRuK6dNRHKVkeIwLUM9Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177418; 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=MNbTDmlYWVvmzgANCnheua5XzqfUi57qMv8FEbGAPF4=; b=C5uSFQSDBQKmBtS14th/PcUTJZ8GMqCQl7OMHinAjKcP9azLVqMlm0rgtwrRJK18VNVQbjw47yaEWt++1xwRfPRdNv2E1Vy9CV22kVxt7juMmIoRFpqLK5XjOYkRk2qiMMMhm99gpNUIg2PgqYsMKKNH3r/gJ5AtwLo5oL5e3FQ= 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 17551774184731001.0253258031865; Thu, 14 Aug 2025 06:16:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeM-00040u-0P; Thu, 14 Aug 2025 09:05: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 1umXdD-0002aS-7s for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:36 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXd9-0005Eo-Rj for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:34 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-76e2ebe86ecso1164744b3a.3 for ; Thu, 14 Aug 2025 06:04:28 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176667; x=1755781467; 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=MNbTDmlYWVvmzgANCnheua5XzqfUi57qMv8FEbGAPF4=; b=vGVeME6uBJs17qa4D4Dau4dgrxATSMg2koOd84e1gTLDRwsK1JgKlNj2nmz2apBtT/ ix4iohcOZmTAqTf5eGhd3tulcC5vWseg4jMZVPTo5fEM6rHYwdd0CPaVeqMBJb13tUm2 kmamVqSd15kvlEPr5vbh9Vi1ecdw3iAkijkEYPDAjxmCmz/QZsM3L4DgM/QjdEssPzme 89Md9ovtqucOOMUOfYPZZcDvNsaDNoI5Y1joPP0Ni4NfswjjKSjo6tdgJA7vGuNCLtke ynDRE9Z/jCn/lJ6dY1gXitAkgcd5aIxmoDc4KTj8jXGk/Msu4AA0U29o918Jp+V6wLOy UF+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176667; x=1755781467; 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=MNbTDmlYWVvmzgANCnheua5XzqfUi57qMv8FEbGAPF4=; b=r76f2CCBkCVnFISIZzLpOMHY/dI6ibSeQVvtKmOkFAajtpLuOhkhIl/KC+P4X7dpY0 v/EiSgf5YeoMroq37NbPu3BPNQVHyRyAU0gp7qYddz9ySzOJWgyyQtLRsLnqIbQeis2+ TAtOsfJULGutSS8Q60wcQZiPh0Zcfu9mW06UbHJYF2EDRtG+Yg5Iz0ALtVfAWYjsmPo8 SdRUyolSvptddLYjcIaOIv9x4iacMRq0cpe+wLnJihzgqap2tGOBo4FFnRtmZQEewnNY +flKoUdDshfiyqNA/mlMZDOpX8spVsSjTqboyXQ/eQXRd2t42oauK69n72AQwMVR5tYa 0tUA== X-Gm-Message-State: AOJu0Yw1VZiHRjtGwcGilx8wowQAInMNlRpC5+gabBO+YFtJYjp7wBDs fgWFROUAIaz5qBCL5LE1m97xZigN/hjfp5mt7wjnduglVk/3gD6FnngzsFF7Ssa9cZRJV3Mat7P vG/pdba0= X-Gm-Gg: ASbGncsk0XtAlkadOEfrsH1M5QFunS/Kpd4Zb53SRNkjKa81FZxaYIfC6VLAh0fLimE E1kVAfj65HBY0sY3JNztDz/Qal+H98aclvlgBMMnh+78CvpHt+QlDSRhG2yiJa22jyWSdVZxuTQ emLeOJ0AR449coEnkeF5bIbPpp/xCnflELc1/ZyiFrt1va4aGqi/lBmID0pZk5tcm6XSmDST/9Q B3VHl/irTb6YUL3a3IsvhMKnaR0xuV5SOFpL6ZE4PA3i/v+Dt6t73vyVTYYcsk1TN4X7AqLDAd3 fK+SRjhUg8GnFVSuPqs09jqVD8Em6dx1yhtqm8ehth7SJbzcs/9e8+gJAKNO+xlRjMLkloNs4Zb q2UOqBLmNMXK+QLmrNqqjIRhCNXuvtp+ImU+z/0MDytP0UVA= X-Google-Smtp-Source: AGHT+IGfrDON/l96teX4hxiMx+0bA9hk3Vbkm5FNf+/2VwYcBrb2pbESzM2+q3uaYF8Tm67jaITQpA== X-Received: by 2002:a05:6a20:1592:b0:240:750:58d with SMTP id adf61e73a8af0-240bd23b59emr4472078637.27.1755176665449; Thu, 14 Aug 2025 06:04:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 61/85] target/arm: Implement GCSPUSHX Date: Thu, 14 Aug 2025 22:57:28 +1000 Message-ID: <20250814125752.164107-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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: 1755177419460116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 2 ++ target/arm/cpregs-gcs.c | 17 ++++++++++++++++ target/arm/tcg/translate-a64.c | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 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 fdefb2e17a..c688d0c391 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -53,6 +53,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, @@ -99,6 +112,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 e0dddbdc25..75a6ff0452 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2531,6 +2531,35 @@ static void gen_gcspopm(DisasContext *s, int rt) tcg_gen_mov_i64(cpu_reg(s, rt), value); } =20 +static void gen_gcspushx(DisasContext *s) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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_addi_i64(addr, gcspr, -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_mov_i64(gcspr, addr); + clear_pstate_bits(PSTATE_EXLOCK); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2818,6 +2847,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 Sun Dec 14 20:30:54 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=1755177632; cv=none; d=zohomail.com; s=zohoarc; b=Cus6Fg6CZuA0cI9BUwLgrzYwjjhW5p2me8Fi7onui2WfN3jw1TgD9a+SMxMI1Lenm+MitRxsMKTJfbjhZrZ1HJcBsS4gxM9Mn+UsPyLMWpSCy2g9Zdf49I2GDeZ2x0VKmaccIQ92nW7kbnwM5/QDvgtArusvvKXqu1N+Rt9Bu98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177632; 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=9ovJLOo5Iz7w9oyScfUfi5Nm6yOe9LOjZOdiP+PMnCQ=; b=gQTFpL8/oj7fqKcdIQCvfcVNS7v2vK7Dg4+1JVW/e0WpqR6R9Ixs1O0MYOYPA4U96T2y7PnjLaM1+ivcnVgELpy/ex0D7ZnpHr0mKYSOijk8nbpMuzAiQb4X0Z0uZwdq2z1HSAld6VNeW18Ik1q8JObsuOaGNf20qlphECOqDr0= 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 175517763025033.88214058498443; Thu, 14 Aug 2025 06:20:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeU-000474-KA; Thu, 14 Aug 2025 09:05: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 1umXdH-0002jj-Tw for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:40 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdD-0005FG-4e for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:39 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-76e2eb49b83so527788b3a.3 for ; Thu, 14 Aug 2025 06:04:31 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176668; x=1755781468; 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=9ovJLOo5Iz7w9oyScfUfi5Nm6yOe9LOjZOdiP+PMnCQ=; b=ubqVVZTNMXb7wo8jxmHu/XAAHFZr/6gWyzAwFC2RBc+svnC/U/nSKl+HUMGbOcKjqm pQQHrPSN/km+G+F0QtDpDSRMTBf8qVJWM6T3AuSz8HqSxuP4TBgJ7LXrhEMQ0Y/8fcVe SWKCAOgV7OWnBaSU5qIvTF5cVTnIyIi+0hN15gyBvdq2sTkQbiErRC62e1i5n7BPcmRU JqUjsggh/73b0Xm6Z9tdLVMJ3dzAmt76JDiIK3hLEFDEYPg+Yn2c4ugNq5D7bfFJBQip Rz+EDq3P+Myz9KW4DLv/fF5wGWfhqtuo/ia0JtTiO/IdpmHNm8jkNYymEqV1CKzsLMky 3b5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176668; x=1755781468; 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=9ovJLOo5Iz7w9oyScfUfi5Nm6yOe9LOjZOdiP+PMnCQ=; b=Zp0IV0zKs4v+avhHIBTE67lxY0m3Gezu57NIceFMWBD9KOr4OM1z28QANlkyWWaMA9 KRHSgoeFqg9dDwcPr3WyerdAwEBphIKStsxEnLd/hqmmtnVgZPcxske41v1IFFmysh7G P8lDWt5Vb2tJUr6wh0frNygTbHKRXfKFH1DU/I1aTi7SkBuoFbkNeJUj9shVMlBMKV0H tU7a34jEqbLTYtQBIjJSKfVGFf7hYxPFl9PLYFXiUc00Lm56CflRALaT5UXP5U+3QRyo C6iGlyAyEKP9kiVHQ7WR8QvXhZdd4opzx3Z90s0h2mv2X2Xc0V5C1BvHiunnXu5yivuk jcPw== X-Gm-Message-State: AOJu0YwhUh1tLv0SY14dMAvasbSnHm3EwlhVtYJeneqzAW+U6AuxYfLy Pf8HRLOfT8guIDtGmaD/fQz7e53MDmheQFpjIKyDDsgc//Tgis3vthBRAtl2WRo3+bTTk2DWd/g WrSjsHck= X-Gm-Gg: ASbGnct/84oguXUw4W/GHoAEBhgv1yBKVAJwODdHUN6CiXLW98JRdBs0qbSjOtMUaJw Y3hbXPYDmmA3cMQu9p5gHgW3YCZi4kd2kkzqIOlaZbSNM1UBmfajGmBvXRGeD4rzjTeulH1erg9 esVpQ6ZtHuyrbrWa5YikHoS8CtK/dP7bMQjm0SXZ8W2q/5Qcl/N47dMdySf9GfJG/28n2p93VpZ UyWTPp9vqu5o0WoO5NkR5fldB8hU1hUfXH4H/VIrKczTcus+D7wTPiQt2f+v4F9UHTP9qjywPGX QDY0ekZ9lkvJ/tmWfY5ftZ9PpPMmHI3QTr+Bk+TXvTXgw8sLIFP0FdmG0gi7m1PMImI9xPvt9of pYXJiC7dY8Efi8RKs8TYJr4rGmb0aYBCjNf8BAp1LQ6Pu3lk= X-Google-Smtp-Source: AGHT+IHhVG3d4/RQmmSImi5jHw22tv/coqFbAJRqG09RUr4+MwZWRZMtyvTr5Pv+5G3TqP4MhNUO/A== X-Received: by 2002:a05:6a00:2d0d:b0:749:bc7:1577 with SMTP id d2e1a72fcca58-76e2fc2af7amr4107904b3a.9.1755176668327; Thu, 14 Aug 2025 06:04:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 62/85] target/arm: Implement GCSPOPX Date: Thu, 14 Aug 2025 22:57:29 +1000 Message-ID: <20250814125752.164107-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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: 1755177636059124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 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 c688d0c391..2d39b17188 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -116,6 +116,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 75a6ff0452..7a51836cdc 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2560,6 +2560,33 @@ static void gen_gcspushx(DisasContext *s) clear_pstate_bits(PSTATE_EXLOCK); } =20 +static void gen_gcspopx(DisasContext *s) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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_qemu_ld_i64(tmp, gcspr, 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, gcspr, 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(gcspr, addr, 8); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2855,6 +2882,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 Sun Dec 14 20:30:54 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=1755177321; cv=none; d=zohomail.com; s=zohoarc; b=c6xpW5GF4T4gbZlsM6xYe4KETbtBXWydLRnKkXGlw/rMdSLb8CR4UPY2yhW84WopOs4HNMhxxkOsmw9dPBupaikf0/u3hd6/pkWRZTAypfSshAjQSYPjg6P3aO4YnlS5bkpTWKkl5gkubTElFeQBqzjON0ZhJaIKNA80gWQBA8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177321; 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=i/zcuC56Zj+TUzfAAs7ykKhwgtcOMzUZTNHIMAcbGcA=; b=KVVG9vLo+KR4313FBnWPgwS65tSCR89+VL9ZYVqX4gmPp1I7AieWq0j4QHq3G6cU+1kJnANPY8sP/FrK/7/bbZ4k/zPb706Ti2dhFowhxJptgwcMhVu+6Lsc4o/Li9gd8b5WUWBDH/LsM3izRWv8KWrzzDzv7O9jekNi1db6xc0= 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 1755177321497419.3805523865169; Thu, 14 Aug 2025 06:15:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeW-0004BZ-Dx; Thu, 14 Aug 2025 09:05:56 -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 1umXdQ-0002vr-T1 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:50 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdF-0005G0-As for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:48 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2ead794eso682295b3a.2 for ; Thu, 14 Aug 2025 06:04:32 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176671; x=1755781471; 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=i/zcuC56Zj+TUzfAAs7ykKhwgtcOMzUZTNHIMAcbGcA=; b=kRMZ09RxZIUHk5gv0uEaE8xGqh1kznfVBcFS7r5mohdu416S2yoFGdKLo8IgXpSEFI IN7YgFOYnWD638bMB1C7aurxP/vGlkP81oP4Yw6uePAmho6cWufbRTxVxIupTHFmfQAp iQEZdq0L6+dIK9rQQW+p6TYuq8wpq/QW7BCWoCyx+2LKvtg5ifj1VSYkh9MW97RApimL xM4EfLuxJxjr1AjUR3MgFJsg+c2z8ToXB3gcfEfFepxYXf2QCXreUPOJ/5d/XcffHiQt t4H/8TrTepK0knJgsw7GDhWrsVfoDtNRoFw41ju2/aliAyrE3THUzwMU4xSan2XUy5B3 m+Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176671; x=1755781471; 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=i/zcuC56Zj+TUzfAAs7ykKhwgtcOMzUZTNHIMAcbGcA=; b=TB8jq5gHJV7NL+wXL653jolHwSaCywpQyKn8u4e7chFkPEnrYWL2StO2UmH9Gnyk1s GNBJRFrADMfFBH0SI1qaqpX3OuqIfUgv8KTNeRRF0RJJ91L33viJujGnuEnn6eqBmJvJ 1skcSgIB3XTSNaG5utdax/dcPhNf/XKKL2PRkw1R3lCFHLjkdYEyjkPDScoatEOfuaLp /Lj7/MVOSiYxKihHfnSmI2dIDhzKFJTimHO8TULEv2uh5aB/M8YPh/6r+d2WSg50C7pn Fq5vtrHwFtwTK49WX9Y9R3BYovIUhzFWnZe7m51GlV68MWTu+L3tecMujvKYsPAfjfOj HIGg== X-Gm-Message-State: AOJu0YyHleJSyRL7wD+PI/xXMGg/uqLS1mKuEB3N0v/X1uPvjxDsVvR9 mfECFKqepQ5uEF4yIqi7Xm+ZflWusNGC9iLHsnTWT03Z0fRhNClzb9lMWDcBAM2v4FYraZ0nMrd gBsLaUAY= X-Gm-Gg: ASbGncuYZo0mukWwCBiIHQDDCUK1rU/yMBrZpE2bP1Eyl8Ml+BTcEjKOcuf/wxyUtQ7 mD6kMscWvv/gkrBtphbs1Yd15CZt+CNPxESKPe8PrNZt4OTB9PhjsrNC4nrtEdyx5IJUr+rgrEB O53HzhIOKp9FVrDPua3SRk/h/iA6Mt/xwHJwqbsPkCEoTJOHeiilOwQWH7hQFt9PSoDqshuKa4u n9TcRgGn/9/GG/1ZMDkBapwtpYk1a3kI95lUf2I+hvfhkD8lkeKsZOc0/8r83SUFiilE1A3EHOw emeohfDJJid8ds+/xMvh5m/XHzfmZNk68sC0thS4C/5lwqntbBDx027O8fRlN5wMZubjSBdmXEU llGjOfbAu0VCzznWAWF7N9Hduxmz8g6V3Ll9mKRnHAvd0pms= X-Google-Smtp-Source: AGHT+IET/HJ8ZWdmSMPJ5THKwFw8fkJ2kNw0DTmloHPE9oUVCpO5we3n2b9rVQq0eDS/QFuZas/Yyw== X-Received: by 2002:a05:6a00:1908:b0:76b:f61a:157 with SMTP id d2e1a72fcca58-76e2fb539d6mr4320530b3a.22.1755176671227; Thu, 14 Aug 2025 06:04:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 63/85] target/arm: Implement GCSPOPCX Date: Thu, 14 Aug 2025 22:57:30 +1000 Message-ID: <20250814125752.164107-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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: 1755177322505116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 17 +++++++++++ target/arm/tcg/translate-a64.c | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 74 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 2d39b17188..3236f607f3 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -66,6 +66,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, @@ -116,6 +129,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 7a51836cdc..e9a57bc077 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2560,6 +2560,54 @@ static void gen_gcspushx(DisasContext *s) clear_pstate_bits(PSTATE_EXLOCK); } =20 +static void gen_gcspopcx(DisasContext *s) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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_qemu_ld_i64(tmp1, gcspr, mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp1, 0b1001, fail_label); + + /* Validate in turn, ELR ... */ + tcg_gen_addi_i64(addr, gcspr, 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(gcspr, addr, 8); + + /* 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) { TCGv_i64 gcspr =3D cpu_gcspr[s->current_el]; @@ -2882,6 +2930,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 Sun Dec 14 20:30:54 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=1755177487; cv=none; d=zohomail.com; s=zohoarc; b=lBXYESaeBzv/xl2cnNNWtkyOKKj/rD7TpNu6Wgf8ySXgVJll75Sa9YDra/pG3tBN+lPqfaKkNucEcYlUUzMPSnuWgh6xxfm1PQTPTKOm17jLa4k0e5iwiWQUXmy6Py8id5BtuhGyU7wjz3xmLo9aGizr3Fl4Vg7tLArliBb72kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177487; 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=Tt9CH77Y2lUOxhrk+cP00hbiI8xUlvDa8YhAuow35VI=; b=XztgbyZEDhTaS6QYqWslcUXhotzTIouK+qTrZiP0ll8nanGf2KCW/b5MXwBkqwkfLeZKsaLu2ZkmxcxUNjbM0GIkil2h0on+xhMBhRh5JH9w8syV0snpVPoG8rbqQOzIgv2LUrgHlj/LcTCzRXAGSfaPyrqbKbH93NnX3DAhxQQ= 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 1755177487462152.06603767922616; Thu, 14 Aug 2025 06:18:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeg-0004S5-NR; Thu, 14 Aug 2025 09:06: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 1umXdr-0003KV-3M for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:16 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdd-0005Mh-Iv for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:13 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-76e2eb2bf30so1017509b3a.2 for ; Thu, 14 Aug 2025 06:04:59 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176697; x=1755781497; 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=Tt9CH77Y2lUOxhrk+cP00hbiI8xUlvDa8YhAuow35VI=; b=z6ooratjjaxm9hXGq95v2TiIFGanP520S3BbAT00u67mDr/g3GmHir8s9t50kUvvWq VzIMTcjW09JinWWrk6Bmqe2kzDyOBz/kw6HFOetbrq/DXxbdGPeBn60iY17ufRAkM2WV FBxnDMIWTvfW9bgys5r+03ABHR2zghkVJTualWdoeY447T7PQlrvJpTxctnGtBASczn/ JOFaOvNDRfiOvigN/nyoeo765A3Td4+DbGk1ZIl+Mrsoj1bddYjnLaz4Gm8xwtkOcH5G bO8y0V3L6CYOO7JZvynaSQ93mP2UN7qNqArjjNYFexp850FLJ9/UisxAj2IPKQ7bYvpT rawA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176697; x=1755781497; 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=Tt9CH77Y2lUOxhrk+cP00hbiI8xUlvDa8YhAuow35VI=; b=sPc1aV2oeQ4hr0f2TdFqfe/Uf0HdlkzJWNE+8dRU9FFXpV5ic1V411as37PMYdehrL s3F8Y535SSnrpPfMocA2EX7Dwf22p5OGUUJF4BDZiLwqSGYTlul6kN2XBlKbXhBYljnt H1vA1+C2if5OmtIjKXvktx0bSZ9RWAkzFAktkMUL0laldW0ImIoVem1fUVpJ64iLPli4 6F5qAzN60IBs9CvNco4beQw0EzTFCQxC4vnjI7XSLAPocDEKYu5WrRQtKSKSZ006gkON raDR03Fin3uqlon1ZFJ7wJGr9lFNt/98SYqEEGIqCGCVgXVyp+3bALQFKBeQSxU5HPT7 s4FQ== X-Gm-Message-State: AOJu0YxDmgBY8w0fD4K4JmLxYqurP/AggDi+nx92qShyv2o1Es8pejE0 n03/8Im4QC1bRcvxFaTAog4Gmg8RHnaKAfQONoGzS5shv8+oFBdxCg+MT5PGUy7sjEzVEiwU097 tlDfdH1k= X-Gm-Gg: ASbGncuoWJGZoUyR1YgbV0IY/SQSj5ZD+nWJ6p3MhrxiI1J78aq7tQRv9kWbIkMvi6j uV1HE2p9cygih/vBImUXaYgmlQt3GYYYP16qEN18cT6EPWwAUsRDGb+GbzI08EFAZ4EEyv9Thgi XoBnoMssaNMGSlXyha3FDkG9slhscveDOE71FPj3+Aq43r2WxnJm7fQHgSc3lWl5fBeNSWm/HxN qOTgR6yoQCNrhqe4BZgNkWTA7SEouJgpPb72urdwtHWvh+sj843fcLDnMO44m/Jagfcw1fyifqI xRn7K4D/yPMgwP7yjcz5ZuNBHjuoh/OaOoB1GPz/sW35J2nyLC+Gi56/su4ol30n9WOhEhFZX5k 1bOzRiB6F5jGn25yxdzbAHfHPOxz3YPpLvmYcszKCbQbNMZnDtGuIWqJ4zA== X-Google-Smtp-Source: AGHT+IFF3LDU0qOuAe+2y8eIUHzWfGNqILuMpy4xGkgB+NBm4PJYVSxy8+MUFg+Lghu5QVdruWLIRQ== X-Received: by 2002:a05:6a00:18a9:b0:74e:ab93:422b with SMTP id d2e1a72fcca58-76e2fa28175mr4807555b3a.4.1755176674310; Thu, 14 Aug 2025 06:04:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 64/85] target/arm: Implement GCSSS1 Date: Thu, 14 Aug 2025 22:57:31 +1000 Message-ID: <20250814125752.164107-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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, 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: 1755177488231116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 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 3236f607f3..51fc8298af 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -125,6 +125,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 e9a57bc077..d97d9bfcb7 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2635,6 +2635,31 @@ static void gen_gcspopx(DisasContext *s) tcg_gen_addi_i64(gcspr, addr, 8); } =20 +static void gen_gcsss1(DisasContext *s, int rt) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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_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, gcspr, 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(gcspr, inptr, ~7); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2946,6 +2971,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 Sun Dec 14 20:30:54 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=1755177068; cv=none; d=zohomail.com; s=zohoarc; b=V4Qz+cbYIAuTJJ9Sn1xSIo4JZ8CvAowZoN/QP5g8Of8CrIM/UN/3rRzA9K4vUj+tqXNJIcsejLXU2Y5JrgSjGHmpS4W/Nz3WjUFoKXATGRyIF7mUMZadlwGRpyLOk5cY7B8iPwtsKNEuIgjBlZB9MTdHHQRr0I2LQy634Z8xXI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177068; 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=i64S7qZsCHHdPDpq8ksGAk8kRM2Uh0PJ6yALnXosnoY=; b=AIFmnWrCdWmn3nC25TP6m+s7tI/1VvWMFkLSsmHXb148Wa9ty1o3in407TsVgk5X86AaD9MBUll67wVhnkSDx8XKL9NObuXzKXmDFv8Cr7NcI8uv4RDYBqJ3+2IHq2ECC0bkSeNfMn9RgD0prKt+h284aq7r1pYjjQgwPC35fCk= 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 175517706839467.98273315726556; Thu, 14 Aug 2025 06:11:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeJ-0003yh-Fc; Thu, 14 Aug 2025 09:05:43 -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 1umXdT-0002zv-1r for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:51 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdK-0005HL-0Z for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:50 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2e614b83so720210b3a.0 for ; Thu, 14 Aug 2025 06:04:39 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176677; x=1755781477; 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=i64S7qZsCHHdPDpq8ksGAk8kRM2Uh0PJ6yALnXosnoY=; b=ux8zKGCdC7botG/+LPEPlBMU1lOaW4bMGOmlB8QmT5E2LOEc+1S3tiK9oixQsZQBWo 9/hK1WLCl9gVk4jQ1xv2cRRcjbeMWqKipjbhyeDEcdY6axAYF91xME+Y8/kQp2JbZBc2 gcaVfrmr63PUojYI83Lnt4or3Wx0JdvVvpvfZnsIj8Xlo6u2nT5BGferHSV64w+G3DsE OzUCnAyxT3RQEfb1GJD1VEXzUxruoo0WTjBXdcS8V4BzkaZE2IwhE3TqkKSz46xi+XCR 76Bne//mkRxNDuzotWcsugojM0diT/qObWeo+/yEIgwLpUsJVLHKVbdID5yOp63COVDQ GJpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176677; x=1755781477; 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=i64S7qZsCHHdPDpq8ksGAk8kRM2Uh0PJ6yALnXosnoY=; b=E+GUIXh4oIEqsO1laKk6BCjOLzozvUlK7XSlyW1on6GFh19j0kVem/j/k/yXnVuo+7 LZVA59IAf5zYhOn3Mf8rr8YHWeqdGZOKgdG9mKEg0HaU3acmceoBg3gEMIKXs009ePvD 75Ug365OaobhwdW0LsgO2vVpBaG+9p0pSG9c1OUBPEieXs0EVzH99LQVIw9cxjY7yAr7 nuDmNifSkThb0F+4m8yjwbqKiH/RlA1BcO1C/+TgwHDdUUD4z7cuRUlPj2Pg2vbtL149 wLGPr1nmqUCOrc0oUolJhln7crcnJogEsLw5PF087lDv0do72KSYLhd3eHE6ottlP7Gv bnbw== X-Gm-Message-State: AOJu0Yz9+oaycd4LiAsgdXEBHxBhXihKEklqftLKLjZlKM6/peQzORl6 NbIRKjne+r4Bn6ulr4MHybGx+yHZQ7lkEQN+G2mgxjRVnH/DcF7vhqkzhvZdpA0XWpISI4PH6uB moahMy0k= X-Gm-Gg: ASbGncuLvRdSh+W4Hb4BSYBK5of92QGc13AU3S+g2YSuZsjQf9PnlHwOWcnxkQ7dnTh JasAWtq5ILWWiUsau6/I5qVJrUWP8REInQgkVmqVE/OHZevHU2Wan7Oon4geLq4oNlW4QFwAQ1Q gVsWSDBQUwBhjKNyHKu78lNwMxdXMYLUrQZ2j4+OXaNTQyZCjFvOwka933L3i9ZDjnehARKHTet Y4Ne32dGpkwkNK+XeCu7KvuZcQofpNiXZEvOOaA+3l9qlnUpUBCXBhoq8d17lui/QNcUredhaCk DP7DTJmT53oTAsuZJWQZuO5ds4MUDgSuMgdmOl2io4g528cj6BsbxjWFonlfT/57qQoOXVBvgJZ IatToNR04lcl0f9vDj6VU2kAESVhLZ7ZCHP0y+QS99HL5ESE= X-Google-Smtp-Source: AGHT+IEplvwIcDhEOnC2JwWRLbhEbcTy1X4Jl+h1EEjLQEiv0+y/akf33iQks9+DV0FTlr0krhXgew== X-Received: by 2002:a05:6a00:1746:b0:76b:fe65:71d2 with SMTP id d2e1a72fcca58-76e2f90907emr4062466b3a.10.1755176677389; Thu, 14 Aug 2025 06:04:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 65/85] target/arm: Implement GCSSS2 Date: Thu, 14 Aug 2025 22:57:32 +1000 Message-ID: <20250814125752.164107-66-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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, T_SPF_TEMPERROR=0.01 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: 1755177069837124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 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 51fc8298af..b70bf47fc6 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -128,6 +128,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 d97d9bfcb7..70dec7d505 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2660,6 +2660,35 @@ static void gen_gcsss1(DisasContext *s, int rt) tcg_gen_andi_i64(gcspr, inptr, ~7); } =20 +static void gen_gcsss2(DisasContext *s, int rt) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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 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_qemu_ld_i64(outptr, gcspr, 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); + tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); + + /* Pop the in-progress cap from the new stack. */ + tcg_gen_addi_i64(gcspr, gcspr, 8); + + /* 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 @@ -2976,6 +3005,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 Sun Dec 14 20:30:54 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=1755177296; cv=none; d=zohomail.com; s=zohoarc; b=NKklNQpz1Vxtz5BZzbH6jvB5TrJV2ljFGxWV5KSYKn4g3QbnKWu33sFEFgr9d0/PWRoFlo8ll9SZjFTlqfQDlIf9Ppza88iJKk8ABz3wiY67Bw6URuGw+N4kR2iu5kvG1Pq0Z5RFDK/D5mmEbdkxlMPwSdI8gmVwAVLsbCw34Uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177296; 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=aMm818X66sT18U4EvSX+LzaHZWMAavgmuMF/v8hEmOU=; b=DMH0e93B6dq7CbeHdQysMw5vhmPi5NWgXcpQyAFjpargpglfC4TizO0PLUyL3LBTejbqeZ6DRlWEpF1UIEfGJAvDqEGWgJ0DZow82XvOYAFfwgHlVoQYZ/kc1+fE7c8aJ8MjNvw6CA+5Fa4hhBeiKXtslx+ydT1dctGZEBDnCLk= 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 1755177296345274.0837729281627; Thu, 14 Aug 2025 06:14:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXed-0004Jv-Ps; Thu, 14 Aug 2025 09:06: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 1umXdS-0002y2-4i for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:50 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdM-0005IA-3a for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:49 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2e5c0d4fso772614b3a.0 for ; Thu, 14 Aug 2025 06:04:42 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176681; x=1755781481; 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=aMm818X66sT18U4EvSX+LzaHZWMAavgmuMF/v8hEmOU=; b=ZEVmrCDaTJXldo14UZk/3FSyzRU8J+Bj41yq39lNlMd/6/MQYB9Ql4/W3VX3rm6Z/Q tyt7gi9eY7BoxEaKvVgL0c/WJEIbGsWi3t5UxtDjqgroe3Z5d7JMujdrhCNbb1YD8EYD kr70zAV1sUHX66EmIGusfzEVUVSnj6wwKXI9EI29I5fnu3cDcIh1NwRdYMYicdlRp5dp E1rm63+R4AnzmYqBGGk7GDvwIPWM54sVVZEJQJaMvFeYqxtd4+wHmk7a2wdcFWbOuU+L 1OnC+6HzkUEJqjAjbo3l9qDowUlBUNNuisxLOVgrYv1mlVcgCmlruWnBlOT8Y4YWeVDi 2JDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176681; x=1755781481; 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=aMm818X66sT18U4EvSX+LzaHZWMAavgmuMF/v8hEmOU=; b=nyTlKLMph26I0U99QqYeaPFIcHlTRN9KPGZiIXU20fXVV4mQXzWkYl1fym1QSNuBc/ vpuy/9AAtfDG6xWatbyYeHfBsLPp8y44+CEx0q6S91NxvODKFgXGbRGWuCbjF4DcYVbU ypFjoNKAVmD2SKgniMu0NFzyApWma7ys5mKxiZbHvRW9YEJT/8kY3iTLyOcA4USXDLmf wH1Twn6kU+7p1Uk6J836+qJ7achs5MK3+CFmKTLbx4sixZsIEzF2MVyJHd/Zj58SVeuc CAspb8WbnhAQ0SCvw+hq/p58f3Wk9tk9m4DCypGsqdg6AHppeRwWr38FrELS5R+2fHGK /F4w== X-Gm-Message-State: AOJu0YyHEB81AzoWFUw8c+vcSFL3LSPDGlEwj1axrelHxLtGZNMlD0q9 BH4J2gRw9SIQ4Q8QvVGxXvPpcUSK0yB5S+l3jXYwBVb9X7u7AheLbphj46nYkYA4J3DqiIKfA7P 4JZO7k2w= X-Gm-Gg: ASbGncvTkHOa4G8CizXuvcilRUlRIlRMaCaY5B+A2VE9hkQ9UvhKWcq2XyDqMSEiGgX KVDlI/1+ars4cHdC+IVJZhuM1MPkb5dQHv+mkXc+QvtVN8x+CpeVQ6CrDC9vswwX8gAk0DGfs+3 NAf49ho1v6SkAG8GPsgB4CFYffXSun/YEGhzbwd614Yl89keh5n0RL4blIhfHlatblMddDU0pCd pATXJNEGywDnjPBgjMy5wrBHEWVHxGyuiFYDaqZ/w6V1FVpP0swg/LuqRfpbz8HzTrXTada8KEU orQlLfnThyf14wsmP0sB69ik76MDVjZWAL4VDecxmPuSlsDIeBLGXQMstOV3vitwoIs1Vwl3hm1 VmqsIGmY+l/lSeoCMOMt4wwhvBJgBcVb8Fgadgs3Mh2f5xN4= X-Google-Smtp-Source: AGHT+IFZ3tHNG6bgTRTtGlcYTNOF3O4qVjY5JDk8UZ+lVQ3VfXMg/b0K0CAo/DP/8Nq1lxwfI99GpQ== X-Received: by 2002:a05:6a00:1304:b0:76b:f260:8614 with SMTP id d2e1a72fcca58-76e2fbe8455mr5228441b3a.3.1755176680536; Thu, 14 Aug 2025 06:04:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 66/85] target/arm: Add gcs record for BL Date: Thu, 14 Aug 2025 22:57:33 +1000 Message-ID: <20250814125752.164107-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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: 1755177298004116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 70dec7d505..957ec232a8 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1678,7 +1678,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 Sun Dec 14 20:30:54 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=1755177168; cv=none; d=zohomail.com; s=zohoarc; b=l7YVmh60TisgqP79fTKgMm7yk0qKfDSGWC/lnjFGsJw1hN74ldOnWGz5QncSOMw6NNonPmh65FMo98SLB5aQI5/9E+GXpODcqcaybcmvqM7g/BK4tWct4/uvix3zS/9J+lthEyyyVOwiNTw5+t8tcsEdpShyFTSP5TqyMqq5H4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177168; 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=zUATJGpL2aZmNHvgdIJrCiimV4Ex+T+dDBuXOQXlrRM=; b=WzPEOG90WC8ZXxXxiRaRywqeeze9A1O/alrZb3rkwo4BAmG7P+absv696deUuetEaBXShALE7Z9wN9yfVzFDdwSw8BIfGPB4fjPLp72PPS8NgwPXiy4gY1u3LcpKu0dOXQA+CCCF7Imbuk4XYBOJyCaBfqJhAk0TZNLR/Y/U7Lw= 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 1755177168284465.26311758032364; Thu, 14 Aug 2025 06:12:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXef-0004Pw-AW; Thu, 14 Aug 2025 09:06: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 1umXda-00036a-TY for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:03 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdO-0005Ih-Ue for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:55 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-76e2ebe86ecso1165065b3a.3 for ; Thu, 14 Aug 2025 06:04:45 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176684; x=1755781484; 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=zUATJGpL2aZmNHvgdIJrCiimV4Ex+T+dDBuXOQXlrRM=; b=VQCW5FfuPuK1puZq4Wmpa0JrLyZJVHMGOt2MhX77FgFoOzgsmD11+1bMgbhs02qgx2 e1BDpMtIspILdedS0f3Y5EhLIVjYEIivGRLK+cTnnBlDrjWZLRNm6XPdTfYQFQjgAgoT DU4egfwaIgn3Ne8rl0YbvThgrniz4ksAZMPlyi7p+NWM3lkP3upvVQ+kPflZepvitC74 6o/WztHlfdkTo6sSmJKfjq+RjZjr8G6fYficBJo/kpOkAHJVE882Wk3W4NK67jQOn+pk v94g8niIUhoPIXhZ9dAcCksmnVRFAQ8o+o1vUjAhuRp2ktHKXl/itrovPBy7iv4BsN1r A3Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176684; x=1755781484; 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=zUATJGpL2aZmNHvgdIJrCiimV4Ex+T+dDBuXOQXlrRM=; b=vK7m42xzsXp7APJwp2wtDFkHwyysmjXTkLWpMgrDiec+ZVcejvIlM9Toenw6+KDyAU LZsa56qJoXfQOOYjxluDmfZEJZcbtNOdEErP2TSuX5VdR42HCZtn2u0E8lZdOOhLhc+N aWUYfCm5UyafsM1uFnUjA6jWtE1TWwZfmXhXoIF+HrW/hdXUzkO4+2lv3eY+Jx+f0+IW jQq/NmnnPOsTbbgBSbR/lIf1bfnQCOPHLe0O7jmusFusfburAKYfMauSddn7r1t4mENq 5M237NXT5nRhe4uG2vKf5jJw2VkIz21nOBtNw56SXjZSEmzlSHQzmoYZDX63RgT1JGG8 ZJ/A== X-Gm-Message-State: AOJu0Yz80746fxdgzI97RdhLECBYXCLbcnC4DinLIKLHS8gVv/jkNIaA VciUjxa8fRNHB32eO3azTr0PJ25YqrSh4cjGoXSQ/3fjbg424Ta8NR6tS8EihjwjNVpVNR8FN70 TVLHctTc= X-Gm-Gg: ASbGncu4dQFtH2KxUwzFhLlPqofxAPstR8Jau+kriaVMa3UHi4wGzAp9M6HJWIBDS77 zWKtpXJkdINPaWk+L/GoA47YjeQTTIA5jaaKIm5TF6SxiSaFfC8pQ1fKHeW7M7IY6nZ81WFUlrx lWineBxTCqgi6ybQ4Q0LiWmyB/v7aKKmST2AYyKp1vWZ+vq5pS4PTa2MVfcKfnDIMDEYuF6X+uS LOnBtic9Hn780nQLCr92SLFwHIhSJvJgAM4ELdAeQ5BPdRYzot3WG4gTo/ERANohIHJlCuyWKn+ oEua9B5N8rJOTy7OP7jakL60trWFw9jtnZJWyuiS5mP0YuozUPkQU8R0MtuP19I3HMQX0AQ78yK hzJ/I1kk+8YXC46higsa0T5j8v2pF3OL1mjTzk90sOuHEREI= X-Google-Smtp-Source: AGHT+IFV3CkynLpXycITZt6NVyg51oEddwnNqu2toXxNeMuBwWdA0u6guxJHRV/xtjr/9f+zeag0Ug== X-Received: by 2002:a05:6a00:7095:b0:76b:caa5:9a32 with SMTP id d2e1a72fcca58-76e2fb315b1mr4497765b3a.11.1755176683611; Thu, 14 Aug 2025 06:04:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 67/85] target/arm: Add gcs record for BLR Date: Thu, 14 Aug 2025 22:57:34 +1000 Message-ID: <20250814125752.164107-68-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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, T_SPF_TEMPERROR=0.01 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: 1755177169314124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 957ec232a8..62cc565229 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1782,15 +1782,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 Sun Dec 14 20:30:54 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=1755177224; cv=none; d=zohomail.com; s=zohoarc; b=AoI2oML+l2ke57crTc6Oq+UYbPNb311ydnVai0/lpRmEuKaVI6nskKyW2a9IKW19i0y1aEmSWe2QR402yeL6ZP+WRPBAkSlgwmzetlyG5aeg8omXtd20YYhmoCD/fIxGIFinG0hb9/7vMYaqEs2G824CuRKFx2Rq+8xQhLPj3UY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177224; 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=59Vc71z+OG5Nme1jDykZuPFaHV8e81GjVPog9V1N6Wc=; b=LLGfe0oH7GJ6uXtLUBOjqX2w1Flv+OTcMhF2FLaj1jFOAjY0+WRW5Ga7IuJHg232TGvGDLXVqg2qrGiZccC17+2pnw/mKwK+440uAmoPfAFc8ItrfwEuiUjq3di2CbJB8xalAkB9/+T++yJVWRloWPuF9GDqUD036E6iiRaA+Dk= 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 1755177224096505.5095394798732; Thu, 14 Aug 2025 06:13:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeY-0004Ek-Ex; Thu, 14 Aug 2025 09:06: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 1umXdb-00036b-SH for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:03 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdS-0005JV-Qv for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:04:58 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-76e2e8bb2e5so1141682b3a.1 for ; Thu, 14 Aug 2025 06:04:49 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176686; x=1755781486; 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=59Vc71z+OG5Nme1jDykZuPFaHV8e81GjVPog9V1N6Wc=; b=IbEF4zQ2oyZaH1rHPnknARG8Exk0b8h3PL+WFYKgRzNPebyvrHFVcFjnN4RDl7uikO /Tqx0Rd/dgguRvt31TzEUp8aZcmmYx6jFxRzrmqga3E8pP97RC6b2g0n3FwnDnYWtnLc mkbES6D//jMMi50os3M44ShtoEWGY7c0NpLM+5rCKHC15bXf47gR3GL/YUatSV2VE3Xb r9gRDmd0AffdLQhR3Yq4ICRADWx9FeFtB18K+j5wWKk6d3nZWsuJJT+Yl1cHowmOD2Sl b/kAumaVGtKrYEYfkXobRFPUvVMYowU5Kp19T5FMW+5DdCnqzioQQFCKIelz6ot3qpmx Xq3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176686; x=1755781486; 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=59Vc71z+OG5Nme1jDykZuPFaHV8e81GjVPog9V1N6Wc=; b=fiEcJhIc8KRiQVynJ7Voh3tssPK3qXQdh7OeEehEv4v5Tw60Hyl5FWkGGNOBzqFNnE q2SuLtZpEVGQbz6TzlCTGOkfRAcZgMYOEwfzOj+4pharUG7MTX30/NISVRP6X9zFM+TL t4nKaTOVUEly9zCSV2iuQCWdDgIf3I+mzmai3jTIG+atEEALEwwFZx3IJ8k2qoYqO87E N8ILYs6lsQ8pJreIZUyUzVx3VsgMzOEdGa0enLqvLLGpsgAdwynL3y7mwM68rUAEaFGE 8UqHE9yh5ZQ01s1/nxfGQoUENDsohQQS/ioqX4qVzyFfFjtJTRfkpEVTOQiCNSG2PXH4 GYIA== X-Gm-Message-State: AOJu0YyxIZv2Q39f/Jhoqc7vFKhRCvDy/aOBtV3+aaYKKl8bviMZrvUD D9GcyLDAjE+blIeui4DPkHJb9wTF60K0lCCc4VPK4qMLznc7A0NdRBlgdXSxiPl9UfZxQ7E4wix Wq7FGqFk= X-Gm-Gg: ASbGncstmmwl0LJ6qtvJuTSSTL8g+he4mIQC1QGbBynth6rDUHz0kUzfn9TmAR5PrKH bGNx8IWrf/7601OQ9Ddc5T0WR0s3zkn1e/PwaTtVPpINzHUI8pxNSmATCzQiPy030tbTpPqnEr1 pH3pLuWKxHDe3e0cQTL46dDQQtxxnf5hRAKkTkH8Ue++I40sj39L5A5gn0/HmwPw/MmS+yT+1F8 Vu/pN5cd7fkAQuLkEpKgkXzoFc6HLPt7T6ySjWfgCpzhjP+SnLJNafXWJU3LPEdmAMRkUbcrYZD Nq5cfzzTk56gVFwtvHXOTjTrasPs6H9NbFIC538HzcV2yzAfUN98sAvdhyEEvwmFW/4Mvrwg+V5 AdKhaZDahT6LM/G8+L42XBp79eZBDbreGMzTu8s0qx4dzt5o= X-Google-Smtp-Source: AGHT+IGp+FSadv6GDyINa3dqUz8Rs7SnfusM8+9mAxsoENsax8IJT7xkA+1CWe6ZxnViVlmMkk7uPw== X-Received: by 2002:a05:6a20:7d8b:b0:233:f0c6:a8a4 with SMTP id adf61e73a8af0-240bd28673dmr5282846637.31.1755176686518; Thu, 14 Aug 2025 06:04:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 68/85] target/arm: Add gcs record for BLR with PAuth Date: Thu, 14 Aug 2025 22:57:35 +1000 Message-ID: <20250814125752.164107-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: 1755177225651124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 62cc565229..3a25a24047 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1842,20 +1842,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; @@ -1892,19 +1892,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 Sun Dec 14 20:30:54 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=1755176961; cv=none; d=zohomail.com; s=zohoarc; b=NfB2ajhut2TG6FzUmy4pEPWkxNLdJ3aNYwBGQ0524fz6FTbwBJRxwK4vofCWRIcVOG5Bl3HDAoxMh3V1SXWjcA8nJKya4n1d0ayw5JtvSAtAlVArYdhELebJ3BTGwLpB9zNpPkCLf7hCgqqtzKlFISg9G4nxzXbKPdl9rTTtSos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755176961; 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=NwFLvMHNhzDIJrx94b1vQDvIr7KcBJBJKmVw4Y9DgL4=; b=hPLW8lqs7oNHTE9l8GYHKziluB7TqAJztqWFPDKkLgNRW3/i7J7uHfJ33vVAbiMZMjeRGg7LYcxkEUkAs629f1rTJEA2gsBq4lSETg3tWbS1u5owVq8OPrzDqo3Zu+Ug6rG0D1w211OeG92hps1qf/UJx34dT2emS6+Yhv9O5ls= 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 1755176961725291.94590473741266; Thu, 14 Aug 2025 06:09:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXef-0004PD-65; Thu, 14 Aug 2025 09:06: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 1umXdh-0003B7-Ik for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:08 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdV-0005Ki-M0 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:05 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-76e2e8bb2e5so1141723b3a.1 for ; Thu, 14 Aug 2025 06:04:52 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176690; x=1755781490; 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=NwFLvMHNhzDIJrx94b1vQDvIr7KcBJBJKmVw4Y9DgL4=; b=ZaQlrTwiWsw4lTVsidZQYkrhOCqqdp1RPcxsya2CF5XjcN5nqA2WqpPoLPSUfXNvDl qNj88DDkCBwet46oOSAwOrRmCGFNMKoIWuY7iGc58rRjY4a3JHk/a3eYtF0x9mDsceRl TSIiz1WL21GIPl9s31ZUxXXLm8vmARKg1Egq+DbXAurBZUnrMU3B00/jCkmCojjfSnmI NPP8ZXSTJXqHo1Fg4er3MFyDJyUlhcf+vLj1zTEIeKtHa8hImJeR53FPr0xZ8vpoHn4d mGm+DCmQbAYDHjxzyuHWWvq1J3UqMnzHjzT8b9mYQVoQkNbSUTW3CV2BSKjNv6zan2jM d7YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176690; x=1755781490; 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=NwFLvMHNhzDIJrx94b1vQDvIr7KcBJBJKmVw4Y9DgL4=; b=AMu/OSVQHg2zhREWyfkxExE2g9tpx90F5U4uaFi01ipGgZSSusZlXQBcul7Uipn86T lchMkP3C8HWnKXGN+8CZmjWYZrJBxIHbLqy1s3zXJeeWIqbKwicbhG7mjZazoZIlqsbL EWJh+iAjdYfJW9Ta3LEGNKPTWdUgyODUnb23duB/d3fCzKmmM6Xpc6wvy6CQQbihcHbi CANn0oLupHicUGMAWmsrHvaFyThZh1Fmq/sFNzyoIsebYihWyuVdN13Dx0nwOlmIu1R6 i2PkXf+3aDKcCke31UUOB2f/25A1T24vqbqaYEfpG/wf8xFQJT8G4LBMeGG/WveE7++D fklQ== X-Gm-Message-State: AOJu0Yw6rBKFJSB3+J1ghvfSRPgs8DxI/0PwwpIBlyccgTc3KtUsA7Or 0z2GInGbJhRy1XEq9FAgLidSydMh/7d/CtBDUnBruWqeyxXZ/Q2vOTQgjg7ZSVLkx2hx05ybyPt pS2twzFU= X-Gm-Gg: ASbGncusXl70rAu09YdyTRxXCVk5OWu/FtR3NiqEGiBUObFEwmv0e5uWSf4TfFIybUt M4orliRBxrCl9QiwGu38byVmUvsmYCRGhmJ9V2KtOUXafH9POA42HZHr3Rsu5X1EdqvD5+zz5G1 RAZ4u6Mrc0ykIMOHUtn42pSU0OQOyhaAmnvzGcGxnn9hzHQWK3uA+lCqz/oG2S/kLkNnVhvRWgI IJcJh3pAdTPaIp4dypqdXs0nZZSX+M8ePjHvIqtW2fCfw+oTCZZ8d+Y5F05OW0PL4+AaCMILkQl EcbCKqnxV0P2jlUkn0UPGl0y+CRn15AMYNb9yjqOpSextb9ZU6DazQeRBS9KcbraO2YFdrDEDl/ q03+CjdLkGmudeEoNblpO2qAhNVWpGCJTQ4B96iCz0xhNMf0= X-Google-Smtp-Source: AGHT+IEMsaeUKqahWSMRkwpgjAW8BjqwbshIW41fTvHIvwye7pg2NrNtpcrS2rsMAnmA38qdrJUzeA== X-Received: by 2002:a05:6a00:3992:b0:76b:ee57:9897 with SMTP id d2e1a72fcca58-76e2fd144aemr5014622b3a.14.1755176689688; Thu, 14 Aug 2025 06:04:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 69/85] target/arm: Load gcs record for RET Date: Thu, 14 Aug 2025 22:57:36 +1000 Message-ID: <20250814125752.164107-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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: 1755176964546124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- target/arm/tcg/translate-a64.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 3a25a24047..e4a298d61d 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -444,6 +444,27 @@ static void gen_add_gcs_record(DisasContext *s, TCGv_i= 64 value) tcg_gen_mov_i64(gcspr, addr); } =20 +static void gen_load_check_gcs_record(DisasContext *s, TCGv_i64 target, + GCSInstructionType it, int rt) +{ + TCGv_i64 gcspr =3D cpu_gcspr[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 rec_va =3D tcg_temp_new_i64(); + + tcg_gen_qemu_ld_i64(rec_va, clean_data_tbi(s, gcspr), 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(gcspr, gcspr, 8); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value; @@ -1798,7 +1819,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 Sun Dec 14 20:30:54 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=1755177882; cv=none; d=zohomail.com; s=zohoarc; b=S3q17qcMnjnQ28LNQxmSSKH2ea2jas8TB7Dg1j7QQDnkZyFTwa5DyQGlhztFUGVTsM8GfRJim6ib+Sb4Dzmv6WG0pA/y7m75klrjkwb9Ca7ITdux7PdK4D/ePijSgXcnR1pn3TcKj34zhSEwwpAJzuLxX2p4bFCNv/bFCyz2iA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177882; 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=219p0B6WHxgpAXzKUyAECcJImn3r2+0sic49ayh7Cg0=; b=ih5IO0udxixf+E6pg4LVaqhx//JuSFweI2x31lYz7UwkAk9AHv1VXR95h4DuL+5pHnQ7H5Ozkms+HUlkPaGhVyWyHG6RWOwWAIPJeq+p/h2RGdTzS7TOQyIU7tfHtOv+eBe7xeCS8uL/N73hJUvSljraOoFgm8/tmaHsF+HZUag= 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 175517788237846.72953995323223; Thu, 14 Aug 2025 06:24:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeL-00040I-AQ; Thu, 14 Aug 2025 09:05: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 1umXdm-0003Eo-3T for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:10 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdZ-0005Lm-Qi for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:09 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-76e2e88c6a6so865329b3a.1 for ; Thu, 14 Aug 2025 06:04:54 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176693; x=1755781493; 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=219p0B6WHxgpAXzKUyAECcJImn3r2+0sic49ayh7Cg0=; b=i9p7wBRM1+NmWgHFCBEHwuLIHbDF5+QXBtl+UrQc6wkS3kt11Xdgcc3th/DJlB8IpL PngzD0659KHjDthUNdf4OmkLwA/a/CuQuiZd7Ct4s9OjDzWG42+d9uX5cSb+YAEiXux/ gV2szy/ghFTJugr0KCgTxtn0wImlWKjyu/4ODmT28fDryMcrZ6r1fz2XsD2jHXt+ysIP TIuOMnBCzPWiQetLuhEfBDSITpFApGtvHCCCSRXTcv1f+d7AmjUT09lNC/zuRWdh+h+F dHkA0vc7XgtdcjKu2PCZIooG/CJY827dEPa47pB9wSiPPxYccnVRS02lVClXPF+LZGOe 2MYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176693; x=1755781493; 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=219p0B6WHxgpAXzKUyAECcJImn3r2+0sic49ayh7Cg0=; b=MZGCxyIWLestpiv5vDu729bENzf2w/DIAMEoo3HY2Ne3WqN5XDH0t9TzHX6I/zcyOZ /z4mxPBOl4Pv3m0ZjWvU7SsKxvaDshxkx/Q34bBeKiPw5LvU+OVxbZTEsduKnDQxYMhw Mf9yLmBxi5QEVTSZiC/jgubN7aFDXswuUeHz80nj4cB3mRCL3rFNVGOW4AXPun7iS5/h obR1boaq7Wh67H1U5QDPn4AaO94h+p1FPfiSCE1+WptgLJZtm5UkLnPwaL0gdHYafF9R gAIcxoCIvwV26ZGw7QcO5Ae5jVnVUqtqEsQUhjoXZo/k9ETwkqA6Cr1qeQ1p2t/Zn/yL PCoA== X-Gm-Message-State: AOJu0YwnEv5JP8FJCtsIyj8CTOo7jCYtvosHc7VwTfeoQyMx8fI/YG5Y xbWf+5a7A21YTtFeuXoZ680nCkbx5fNiwKEFfyflZb9r03ccA4FgwrSLUwjsrHy/hpcDcUEozt+ MzFKh4T8= X-Gm-Gg: ASbGncuKKjJizLXLnN7D57Zybust2szKTZ3ysdNQuuP4eylptRnEynCQFZiS9pLd8lK e4DsZUiWu+rehJuCnn6V40oHyKM3z06LpjdHvp9DjULi7stoN2eciqFlzC+KZ5SvN261J/YJksf ALSmbOVKLUVmy8XZxkSt/vxy1aMJzB5l96yembYhvXsapiJeJLpb4y/fnJjoWepjQwNMxMd0PF3 nuee9meaaeiiAYNP68G037DCtEET0BqbPYSFZnIA15X9U1o/8SBZViXWJRNWCgtZukdpbMqY2/K eZpopfAaMyb2Y0Q+zkpzzHL+kiMQvEtSaBARVVAoZUukXmrWnOPliSY+Fr/t9hiXxpUS7enRcZ3 kZpYzQH3MOU4B9HEIa/JBAWexPu/4Bg/hnXFrFxxYp1phtT2nOxJKjBOALw== X-Google-Smtp-Source: AGHT+IEfUT04vfTlRAQMmKNWsT43ee2rkhiFL6I8T+q12t3xL+2eqCnDFr7TmUfSsi3z5bICFbkvTw== X-Received: by 2002:a05:6a00:8c2:b0:76b:ed13:40f5 with SMTP id d2e1a72fcca58-76e2fd91a8amr4531119b3a.18.1755176692912; Thu, 14 Aug 2025 06:04:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 70/85] target/arm: Load gcs record for RET with PAuth Date: Thu, 14 Aug 2025 22:57:37 +1000 Message-ID: <20250814125752.164107-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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, 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: 1755177884422124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 e4a298d61d..ddcfff9041 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1898,7 +1898,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 Sun Dec 14 20:30:54 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=1755177146; cv=none; d=zohomail.com; s=zohoarc; b=Ry3/eSraxV9hJvQcL1u9SyBlDv+aqxiMSANt4diwQwAk7DwXIbD9s7ssVUv2TcUfrmP7IeyfWsveY9pP0k6mmlhGPiVr9aliCY8g7fGshQsjk7nKZtY4gSswBiA7JaGzRHvshoHJwl02GPammlcJMsKG48d1pS/0qPM3w3DMG34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177146; 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=m6MyjGmstG0f9MCMTmAADJQskUDNEaZHn8EXWKtjZMd/vmVH6Tb2R5gpXiUpfCRmHEvSnBgtI49lsFmkmEHoO7OewWyf3v3edOUdl5iCkr4qAoycBtiyrwoPMdfECSJVmapCsb02LDvyGQjob6lJIQ5oH/+udapfmGRxHEKYxgc= 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 1755177146934392.58872830917653; Thu, 14 Aug 2025 06:12:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXeh-0004Td-Ju; Thu, 14 Aug 2025 09:06:08 -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 1umXdk-0003DF-ET for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:09 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdd-0005MT-J5 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:08 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-76e2ea6ccb7so688793b3a.2 for ; Thu, 14 Aug 2025 06:04:58 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176696; x=1755781496; 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=TfULhRTxuvo6icmsc/AVGew7D5BIbEaNyg7xLApfu97A4fxfDdsDqto42kaivmq3Fo sFGiJZTt5mPtyWpNj0ftpCJj39l5tHktvIN+p0N5N3wejjAEysE+geAQAcRjRRLYw0HI iXOZqr72VClHeGcaEi6NBGvGGOhzHYCM2WI3qIEp7zhA9TGt4q+GsRfTyDC+1kVkVc0K mreTlCTsZr4ZMtJlge4ld/SkHBIUTaCUdPwq1+SatmJCMU/4uNy+U2g5MWBUY5UYD55s VIO1l6bqWtaRE5qLQRr8SYDj7jkJqoG/g/GHSguw2k/ZYbstaQpp0uw/7MzcHF1u06D3 FZwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176696; x=1755781496; 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=STiWQuMlu4E5TvzCufP992dFzRRNqIjqWLubIGv77j5gHqeefP1W3DQEH2WWz5zdLC UbB7kNA+bpQYrSShkzvswq/rjWQKiWHAXC13JfKrbefSt6sUd3jr+ZKHHjhuatz9MXzH WkhuiulbWp3vCCUDSAa8Wgi4fdbl4UPmwS3g255AhvMi0Uoindih7ZBXjnAVXtAfjjDM 0kVCM+VwAA4wKp1kKaV+Ra8WzG8PtemtAxNt8JAuScqHmXOh17D3QU6Ozj4ozrGeFuU5 nTDa7SfevhsQcbZEmN2x4UJLMMYd2GRZJpz1ytgalnty0/7Hoo2ifEKHFONr/3JXWq+X wO1g== X-Gm-Message-State: AOJu0Yy1+QsoEIkK7/D+WMaRz39Hii6TahtzbQwTL6cOrlLn0J6UC2P4 gXWs6UXQKwtwBHnkgqV1RgEZ9PjzViBRbxs17s2GTDEocqIEWqM9Cgpokwlp4VExE3xgy+bFm8E QqC0vuWE= X-Gm-Gg: ASbGncv+prstJqrxv/Rx/WDgKQzeZK5nCRxgEj9UNiMuvWYR7W5DBBp0lpfHYIRqAZZ CcjKwNHdRMkFcKk+ClQkukMuYzAYMPpaoUuYySzGnA6m6MqmPJTPhOmagm5uw0xDB4ST7TSzTIe zRNr3vpqSdQN7+sKixlNvuXP72WmKuvPXzb/JrRCK6cphUyxXocoqDOZvKGS5Xmlq0NcOtRFYZ0 rHzihh2DKozaDIVRtIgY8s0tj2+rCekh37qHCk48H5ALb6VgB7r04ibJBJ3jqvU131fj8cjS0bc DPSohl84sZ11VKm1s0A19YHws5mgcaKqy0hvjZwzYfm/Asc26rUDFUHaPJJXs6eOHmEl33iL1jd Gq3Ls6Qu05xEHTfXyRRAcPQTLwwXYQYw5ufVqlCuAKIosl7M= X-Google-Smtp-Source: AGHT+IHXu7kVwvsiHCESWKp89UykVuKTFb0m49VMRflGl73F2VVq7uyMikzGvuzQi85isQ13z/hovA== X-Received: by 2002:a05:6a00:398b:b0:76b:e805:30e4 with SMTP id d2e1a72fcca58-76e3200f33dmr4540446b3a.24.1755176695933; Thu, 14 Aug 2025 06:04:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 71/85] target/arm: Copy EXLOCKEn to EXLOCK on exception to the same EL Date: Thu, 14 Aug 2025 22:57:38 +1000 Message-ID: <20250814125752.164107-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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: 1755177148912124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177436; cv=none; d=zohomail.com; s=zohoarc; b=GGpdk0SEwdocKY0SAmP/uOTlb8jX9FwJjqq30IZbpkTXSARnKuyFzNGb1kTtAqYOn8VKi08Gn1jYM7ThrUgSR0dEqvuDoFT09BteE/2g6KkRZrshn8qmRleNsDDBME0dDnqR+sv6Vhpaao5R4lOnvUd9bJcraNXCaNEJ6K2Sz1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177436; 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=OilbtfAdUmi5H/jZNnhFz9zzL3NbmIdtVMPBi9Egpj/uy/8PdJcSULEVdZpTJHJvm7JsnZ7BI8n9s5bYsqChaV5MZcR5lp0htXLtlOAFlty2o4ptIwqzPwop9+Uuc3umj6rz2RxuqR377ZJxD7F0jol0PxyXo2xNmzlhKrZl73A= 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 1755177436419375.1243047257967; Thu, 14 Aug 2025 06:17:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXek-0004V1-2W; Thu, 14 Aug 2025 09:06: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 1umXds-0003LD-AU for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:17 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdf-0005NO-QV for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:16 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-76e2e8bb2e5so1141811b3a.1 for ; Thu, 14 Aug 2025 06:05:01 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176699; x=1755781499; 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=ZhubJs+/BwZY0lumJQn1nYBtM6oFZcZw1e21YQxrqPynYS3xH+lF7arO5BrxUi0Exc pok/qVjqrc5q57UrQE4Ye0lRtM0D806uPuZNC2isd3t+kFFZE38utXgd7M2GP8AyeFYd twSLzlW78rJ7LqLqJywsRCYfZ5txIRB4OE15oW+uICyp7RvlezWh0rk7ct4yTrQiheFY wIg0q2UEHlzldck6H/eQFzSh7Y7VCiiDuW03HWEdsJG6WCCW2VufvimFTnFcUNhBJWsg 78Az97GpdYh5vQCVefeboaSzom/v3jp6AJeDMIgW/+8GVKhgYins1/0DCButtlniidJL gtfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176699; x=1755781499; 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=byVgX+fSi46eyklVMOydu5Plovh97vo4qn3v5jx4avlnrui4foYwvIqH+cOiGnVpGX zKlUwH1UQ8GAOMfzTBBiPqAFZXTLo2KnHhHWTRp1wBy/lxIdnvOkWABlgzU7mVdBi/NT qQD9ta+pyv0QmHwS7J1T3aGMAGwLdC/G6QUaaxA/zkGMMOSIsn7gGXWVg/Cwgwx7Ne5d pJgbnmp1jAMyUv4Z5TaY9smG+tBjiOzI8TXUosaDD9U8xEUUAnKwACav8b1DC46VhLl1 aMPRVZsl3H4uLs43xgze61iq6IqZFYSlz7/NdaVwvfBkl6e0jG+raoUHfG2AJap87z4M LMfA== X-Gm-Message-State: AOJu0YwYLH3Jr4tEvAAhWmpMNPD5c7ofU7cF0n4sWm4+hoSrpJ0ZKqQA uYpQdMBEELxEN70UR2DdYjraS5aUR/rnOOLDA2NkbXhXLw9nTuoZ+SYVY6FnpfgMSC+3zd3+6ok S9Q8Ep6k= X-Gm-Gg: ASbGncvhkYv0LOjyeNqXXPinp7Xrku9KFwKbNzpv6h32GsROEXoDf4/qTTaOKZhPYwD cO/IR24Y7NODSe9GYNjbOTheXpX+cryAk2atquGlpwEVpZeXW99guSStZvGMb+KoVCYKotuMmvO m3Lrz/tsc66A3kLu3NVsLUl9x944VelkQWEQFjrmdSqY3NDuGD/3nrIEC/TPopX/8aumX+FGjkc JMGXGU+Y9+RvzFdUD/XdqBdbGX/Bb3tmoPqwOF/CqDU+rNJVVRCs9TPybw90bqP4eZosRuQe0Yg JTQJGBeaRDQOKNoE4S/AXdskizFUDA99mw0KoFDjU3hjMCoLpnLHq/iFvdxsl0vF0nApVxUMzI5 pfJq6O+ryf969745OjeHnJxYHsXx0iSvMe1Cnzgu3Ytend5I= X-Google-Smtp-Source: AGHT+IFYy6VeKxegeUXeSlAob6/MtLuOQ3HsrHHD3yLrNCg8ojehEmagSqWqjoHYpFGC42rI/oGmkA== X-Received: by 2002:a05:6a20:728e:b0:240:c3d:2449 with SMTP id adf61e73a8af0-240bd2b465emr4986051637.42.1755176699035; Thu, 14 Aug 2025 06:04:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 72/85] target/arm: Implement EXLOCK check during exception return Date: Thu, 14 Aug 2025 22:57:39 +1000 Message-ID: <20250814125752.164107-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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: 1755177437987124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177764; cv=none; d=zohomail.com; s=zohoarc; b=nSgpCGLOKRhQWsuUccZUWBQcN66ehjXKHKdoLDJvJI8HgDicm2CK6pdF3V/VYA38T8Ix+d2lXADhlLBBjKBdP87cVVAfCwkCssYdHfw7mErQxFU6ceFlSjFNXUiN6V+GkA+CNp53J2KN3VhOfi5lOe2n8jTdTvkwoW9toNlfeCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177764; 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=ZZW7JUEdpnR7cmNPIMiCl6kHICiiK8jPqrgmKqDDlCeWbyremt2p4hScneK48d0p81oWi7nn/usNULUmdagLV7gAZImhypBOB7N/xCZJygf1QGv3X1TmsZSzOJCh8YJ8efUMvdvxMD0C/pAimW0zjp05vMiqplnAkNkXAfBPdDY= 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 1755177764739243.3371817190539; Thu, 14 Aug 2025 06:22:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXen-0004Y9-Cn; Thu, 14 Aug 2025 09:06: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 1umXdu-0003MM-Kc for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:20 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdl-0005WS-3W for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:18 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-76e2ea94c7dso1333814b3a.2 for ; Thu, 14 Aug 2025 06:05:07 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176702; x=1755781502; 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=XGFf3B2ld4uo57k7Y6eHIZg9zR9q7YuIzF+TwzZ+kL14f0VFXgFKyD112sJ25f9I+C Fc2WYov+FbHOm8S3cZYsSf5bfynbhnm+NwSaHgqPJJpdZ5d4XUyoYtk1r9ZS0vYs5DTr R6YfAfNvn82UKodIs85Hl8W6NSnMhF/DZ9wx1W3D+o+6AgyZ0Um9Os3ySMbzH+iSXqpx M75daqiErGqTvWVpq0J1n4V4+m0E9E4i/UIfVpip8MPFr6fNKtnZmxBujuDO1AKB3vDE H0w6gDo+vubiytQ8Bzv/I136RWVedWc57EAahEEh1v1Qtb2e5XjkzRDQjWmiOptIGYEF PCPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176702; x=1755781502; 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=tSApT4Y7aSAq96KSkmITNz6kYSgZF1tCj+Iysgou9PtpnU8twMAXwubpvBg0S18pVj +u8dpPRsTTJt7P5RdWIlgbPw8DscgYrW06JkkC7O4VkJTkSao/yhLWxyfdyT6CtVVvpO QtB8XVpYnSEAWrPIksUAN569KolJw1aqY1PqYnf82hIVYmRffV/X6fTZJxFbBKbQeAwx QTBkER0uWTa4VkKnsfZKzajXhuWWWaSIXLTVfvYQvbjzZ1Y9fli2G/DcoTW5HDQ/IcIG 5ymiAB664nLe3/iqKnZX745woaJFEfgjVnhiejVJzriSJaJiE908LRlo5jvLLVYI+TDE dRfA== X-Gm-Message-State: AOJu0Yynr4h80lwnXcxDX1/8HUG54bfBTXFfbQARXtKch0UuawZmc+x2 6i8RS5UQ3X6jlOiOwKt3nT+fCqmdHhhNmmqXgPIuFMDUycGy+X0c9mc4D/hHjGbc4ubdO8AgOo4 Ab6buMrM= X-Gm-Gg: ASbGnctxO7j1LBaIkNBwGi1l7wyzvnS6qgC1/CV7fSermBJG+niU31v5q/YeKGR9kN2 R1NJr7j1JgrImDDj/rjVHfIs9ZYQmG7/eHmaJzKXCnb9w67PFcGS1kj6eTW20B6c/hUAUk84f5I c6EjoQlbLQZjHy/2guza47TWWf5AIopoHWW95bVJlqNXoTbkvCjlutxATJ0+nXMvQzguRWlmOxa UEyBtSJgbFkgBonancJUrpjrQAIVpeTJHvPbhIp+p8jGe4Zb6GkhEBUGcPUv0sos84FqRe9d7oD WrWciUPF5FFbsAWh/iMALjaCHa7yBSY71sl5QYSIYbdnR4ynLJpc/js103X+4T/t/AXzaj0xKh+ bzsAPVb3WPHkIeK0k5jiutrkPTs99YQJixUr64lMlb/mOARk= X-Google-Smtp-Source: AGHT+IH/yhMZGJainqAx6hHcFZvlcDOdk2i/f3M6T3xLNUelT7aLU9oeggaV/hW28XdEfr90dG/Y+Q== X-Received: by 2002:a05:6a00:1995:b0:76b:e144:1d91 with SMTP id d2e1a72fcca58-76e2fd72ca2mr4558954b3a.16.1755176702220; Thu, 14 Aug 2025 06:05:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 73/85] target/arm: Enable FEAT_GCS with -cpu max Date: Thu, 14 Aug 2025 22:57:40 +1000 Message-ID: <20250814125752.164107-74-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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: 1755177766305116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177227; cv=none; d=zohomail.com; s=zohoarc; b=ZtnQkMy5GsQAeLIiZi3J9DQ4ouulCM98cDoLf8tePIzzeAg9gTtXCsIujTCnJSJ8YBxIkIvFKGc185nA+hNwo5FRWmYP5bqRpkS7F02KNZm9Sya/uQVgitI+ALrAm+fAak93eEpXVxFrnFiXhtB4CgkJMv04LPBstzYt58F6m9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177227; 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=SXMtCI3sMhrzB8D3bpZF7rNr3X+EYEWI1IfN4MfEIkrVqWH2FRTZ9ECbYU9KXHXvXWH5wPZUQ6MbBi//bMPP/9bJyBfa9xmlDohwmmPY85gfyipz0XTEYaBecs+PTiENnxhPBlyGqdFWpwRcCgQvqdf1vmfuzKPSPvYCETLDKrM= 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 1755177227866471.83206516624557; Thu, 14 Aug 2025 06:13:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXek-0004V3-7L; Thu, 14 Aug 2025 09:06: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 1umXdy-0003QN-OA for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:24 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdm-0005ZY-00 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:22 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-76e34c4ce54so468485b3a.0 for ; Thu, 14 Aug 2025 06:05:07 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176706; x=1755781506; 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=fKNciRcHYNuGPnX2FUaI1U/TZ82Hh4yYMRQ+S5QQfUHOkKvspvCqnj1UfPluexFNDi JPToCg7SWiQvEJoRMRmBpCa5+UrV+ZslweVFuEtL6sKQqUGPjEUPO56REr0zIXQHR2PE X/klhK0MsSlCJ4ihRXatvKRaGWSbXIouoyAy4Lp0nAkaEsMqttST+sPjC8ZKDO6ICIkj lNvWYXGqDQGh1CgINeW6deM8937+2XDOO2LnuqZcy9bHNHnXMI209vKighOdzdOGwaKP mrIOgktHiyS3z9aoVkFaBCacJ7HEOAqj+sw6tolwnEMj7SSmhAirLDMJvNfNx6aUT0FM OcYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176706; x=1755781506; 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=MMAAJnH1g7D4CRr3931hxqM3fgGbYzrtDe4ciFRcKVpShxptA71gW1gtBUFtyeo1a4 SiLzCrkbAckZ0XA9GHsGALcB2Rj6IGNExI8zDv2MHXyUtsykDg+njgzFwRJ7uz2/Wz41 3p+s8H0/APYnrEEnD4Wp29C4D61vT7n5O617JBcxw6trjQo3uNk1MjNp7jMd9sWb517W VspMubTudcjorupz3g120XSubZIqZ5U7ORyq8uyYp5bFvnxo+57CQsJ4xWR8BrqWdINh egOI5R3F8I/DmyyeYlUiid9MMAn/Hnj9BbgK2eArmyFS6jtTfmbQl7mHZjJW1FGLL2iX I09Q== X-Gm-Message-State: AOJu0YxvAQ39B/GcGgIf/zN+u85DDDBOUEyoZLJO4yr3cIZx9Luu+SRe yEClpGo16okkSc+YTzO6uhwMECjy7GVh1btQahHr1/NfbIkDd/s04YnyE0gnCOREbIq7rQ3JTcg epXXUA4I= X-Gm-Gg: ASbGncuPs1w6xbFxozEDqPmAlv8vDEeNP1GJzuniFxpWWYxwEEgosnn142rTHoUiM9W bTSd/Phg7+Ao8A5Y6OTd/+3orYmkM1MA5Lr+MKctKSfeUh0w/gDgxZwqHaXjKGCpu7tujg+PNOo 9IJ+j/lsFUwhCtBsDjzvtAaaYoVsXd6wdKW3PquqYoBZ+9oWIeIC9f4VRGgz2ucRcYojnyx6mPQ ML+RG7N6kgYLZjp8/80RkjTGtRba9jLF0kTG0MwR/AtVjK92Xhp+6W2uzo6p87JKZ9pc+XNVwTB yyNjdn/VZD6C6aAhXvNQNG4aCU44IdKdEJOiylGU4dClyjqa6s5QEJqe2J5pc+hGPvdu+P17wu4 XAXmZ4IUUqlwgTQ7LMj1StrfPtdCNKKgiNqEEo8Hk6mcRoLQ= X-Google-Smtp-Source: AGHT+IGUzJhZb+srcyOhlpR9O+SnFPnKVKso9Y9tMrX2a8W5NPgaMZKm6+7aVvD8ZgLqjU9Ge3BQ2w== X-Received: by 2002:a05:6a00:2e16:b0:736:5969:2b6f with SMTP id d2e1a72fcca58-76e326f4f0bmr3626162b3a.6.1755176705228; Thu, 14 Aug 2025 06:05:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 74/85] linux-user/aarch64: Implement prctls for GCS Date: Thu, 14 Aug 2025 22:57:41 +1000 Message-ID: <20250814125752.164107-75-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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: 1755177229852124100 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177945; cv=none; d=zohomail.com; s=zohoarc; b=LQrsvi5R/RLDSS4lX0vDRAzQ3aNiKifK03SbsdHGIQEwQI7jWuimy0Rao50hVwdAdxLOPVsZ/y7qAnXHOpOsHqt+QK0BPWiba7UWUTFtelvcrH25ljim2/FBWz+vdiZCQ/3z99OhT4J4Jd47amKnuaGQaVUxvd/5jlu0EVcBJqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177945; 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=EUakLBVNPibLiKw/UfQnOjeQuVJdCJkUd+wrF8LLEvPIpcU6aG00HZ1tKGviJxf3aNDIJjBimfhwD2cAhe0fe/3JSNbr7zzT/ZwNXTaOFvP7e/npT982cxymnAqGA6Q7ZHV5p//rPr2aLZR9QqF7u7Befxlz7fnVwmLm36WrffY= 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 175517794578191.05717146362508; Thu, 14 Aug 2025 06:25:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXem-0004XV-4A; Thu, 14 Aug 2025 09:06:12 -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 1umXe0-0003RS-8e for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:24 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdm-0005aW-TS for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:23 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-76e2ea887f6so719159b3a.2 for ; Thu, 14 Aug 2025 06:05:10 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176709; x=1755781509; 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=QrWjLqGKssKjyHuHMs+aasxkpAEzCqUOY397aWNnLD7GCUSgJKRjzd/OdBQBe43stk vKa9YT5Tlv6F8vS+As24YV8H5d9gN5tGe60D9/ngK6i8HF5HO+IfADksT7+g0uC0+Ji4 aWXGA4YKt/QqZNZSgMqMHT6xCy7kCwv5VoLJm/vOG34nonygUqUxUEisBFUCjgqOmhDU 503P1ZbZgb2jNqMRoefacvgezRW6dFPLmv2+WeDLqoOzMuefOGJQ+Wbz9/BhCfyO4ksO /PhZRzs070vInyNDC7qmzDAN6H+jXGkmADxXq6/CVSfbXoSlAKHKG9wEhIVca5UxYEWP w0cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176709; x=1755781509; 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=cA62Bsc4ZkfBcUmpxoI3Pug9hMrBggxptdsAXn3XUMh7XZxLqGKXq5s1Xr+UAOH1F0 nrpSd/V5HfBc10rqY/tJVTZKXn8Z2Ms0sIcYRMqbopAHmGVwhY6cg4lBpGdnSPl06wG1 CDpRoVVgkkzTxgy9N0fRFbs8BjZSr+YvS8ReLmkPFv78C4RKvQv5A4J83u73jZEGyQSh ys154wQDhGqO1VFFPvdMQdcUI//XIqTESftla0JHeBfbK7deOn8qqN/8D8jl6dt8bY3+ THgr2RESdqvW/Pwyxbl8vUiOGbizSFy1xDS+n9JLVkhw0rjSPwhI1+BFWNNqQ0ohjgir SAnA== X-Gm-Message-State: AOJu0YyqClH4vES1g1kqjCsVY0otE4jh9eyQ8tgv1JfGWI5Zhh4j2xEA kyAxgLDOCA37T5JrMQ+b6I8kDQsUCYAADpqdXhjUKTHf2SKpSb5ze/7mHcQ65r5zOqr6UpzgX8K o3qdWUFc= X-Gm-Gg: ASbGnctc0l0a45pdTlIAwrWraATHFvFZ6pxBjN/GgkZcn8/VHsOyuybLjU7UWAuruFO 6f83/4irfudrwEUu8Q5j2wMweK+ZlIIPfE6qpEsu9pV5qQLrlODR0bbMVdCn/k8jGccjzOmx/K8 2BLUyQs/geo6aVyQ5UhpWDl3bA9vyCd3Mf0Ia4PtZR7Tuo1j0M+RHM+35jfRSH5N0tGyluG23c1 dPrP19wVdsXxMtJbIENz6ffhQgrz8frDc3zs73jbFqYCojD3I59GpdqqZesGZ8FrwWoQ9exIoBp oP5lHeK37YFCKfjb3JGWWf1IAWF2G+5tYeNvvZ5/YNMdgQuckGQqERsYKeQKlOHq+BdFlrOi6eb qEQtwQllC0P5ukPuzSmLLziKbhvuKuWdudBBJa0Z3Ksiegig= X-Google-Smtp-Source: AGHT+IGpWmGFa/TWxWsDhF7kHJ2I5r7JNiuOH56iHK8+K3kpJYcGceT5x2yhXsfaxDjC3aNXXdLyMA== X-Received: by 2002:a05:6a00:244d:b0:76b:6288:e2e7 with SMTP id d2e1a72fcca58-76e2fd8dd88mr4424527b3a.20.1755176708438; Thu, 14 Aug 2025 06:05:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 75/85] linux-user/aarch64: Allocate new gcs stack on clone Date: Thu, 14 Aug 2025 22:57:42 +1000 Message-ID: <20250814125752.164107-76-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: 1755177946999116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177426; cv=none; d=zohomail.com; s=zohoarc; b=LGmOPDI3Yk7bJsHJ5bZRiyIgcHWsgD3xVqrK9aSMy6eLe2fI5h7tVXPEziA7UWoBybc2P+srfGJfsHeZPgJGjjkQBi0pkmdxyDqSYRH/YtvAwJ6hs7CbpVyykLnypJ4BijqVYcPCf7No0Ebl3IrVeoN5c4O4/g0l4WvylxpFcmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177426; 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=LTA8iIBvI1ihz5XpPlfCVpck0Naw5erWTcI5nmtXTZ0hmLay/n1rMCzcoKRJPlKckBARmGZ/V09fOzgfIBtyjpROWMindSDs/jUHeJJn0xC0kfsKdC9I4RxaqLlf7EMDzOSAgRUhfz508EsWkHc414RHU4RlkxLe8KVvx8Yx+A0= 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 1755177426913768.1848277917571; Thu, 14 Aug 2025 06:17:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXet-0004nS-IU; Thu, 14 Aug 2025 09:06: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 1umXe4-0003Vp-Dt for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:29 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdq-0005bK-SV for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:27 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-76e2e89bebaso698248b3a.1 for ; Thu, 14 Aug 2025 06:05:12 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176712; x=1755781512; 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=xf89rY2RdSFQ4itg5aju4P6bh8iTqLFUL61PBoDij4U4gw7UxVUBAzQv9Q9We2uGeC POnrl0RLD0nrRcFRlLTss+oAttu47MGWRmkii4SuqG5nmtX4VFaVjtKEvNevucuQgaHM edUrnz7Cd/Ob+8Mxo1X01Rkd7GM7ewUV/OIKrESWUBu1WCIxdaDYp3MUb1roZhLyqWnp CbBmbLDBAranYnCilnZFp+OobJkAapvTfBmHRStI///V9fHSErxQOKjSBrLNwhzX4Yew GPU3hcflavru6MB+r1gb7ivP9X8wGL92IZ+xb3JnmnOmnZ1bJV7zNwFCms3clc4ktcNQ tWyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176712; x=1755781512; 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=vwHUvkrgirf/jDiTEqcOxsRYU62ZRioqnyHTRL0fhmHh4Wvm1BidDoEc7WoQVMsdCd d7hjNmSBNMlzkQTMX4fZHXhZCufGC5xsSYOXEIx0HuVMjS1UkxILOKcXp66srPenWIRQ mp0uPPMveAX7czvUaBCQ8NLRi75EJYtqaGsInlN/Gguq39mhFaouF8cfRo1PnuO+fmve 2ru73fV0EfQjflnEzh4Iuv48uw7wiWFnLRUYUkjhbtgwVE6OZsPK70U0/cww3DrPbcrU oBJV5ZI1f+88Pb1syHlNR/G2AFWQwJCZrTr8XuthVp55Atn4cWJjaBoc0NrQzBAyi8o7 lJ/A== X-Gm-Message-State: AOJu0YxAZ5WpIMD13X4NiNrtNzhDJlT/fF20EJsOtCNrD/54SwdQBVee RRmh7u+cdhiHHsVbY3LAepxHb1m7OO16L3kILhYjamu1i9MUnwHFNVeV+hVNfqwvGyAxZ6oUPH8 NMJKBIXA= X-Gm-Gg: ASbGncvot90tM+6KPfc3wK5BZeEcmvXKr3gTwrGa2JfNZ2NVNcol91Gl7h2oqSoGgza ReQId8iYM5abMmcLydSPJ5NGoD0Yun0St+1FxHo7NmUBVUbbF4Dl1ly4PUOHAokJ4trBR1+HCyw jEm+Esmljf88bHvfQLOf3xUm1b1CRcnFLx+YCdRUrALcdtJeESKQCwcGPg87y5faYMSkJQtLtZ4 0upo/DKdV+nCnpOnzXDOlcOUKl3+4BBBXZp3u8UsAv2KXD7tBT+GUdFUeYmrCrTLNIWOxQ7izTO az9FuHpDR/vXbV536OFKyGEbHj7KGwpe50C5QmhZNbxlQuOX4/x+yiLuIS4i2bQDu3X4khrRj9T 5Yi0z8bEk/po76pVAbRhB1dGBh9MyshXcH74wWJJQery8C2g= X-Google-Smtp-Source: AGHT+IFz1rg3YKil1wGP212tKnjrHGzwXOCKqk0XWfiExwIIMX+0YzDe0O905cvhAAUGDJI+6bgPgg== X-Received: by 2002:a05:6a00:2311:b0:76b:ef44:1fa6 with SMTP id d2e1a72fcca58-76e31eb9cb8mr4346246b3a.4.1755176711484; Thu, 14 Aug 2025 06:05:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 76/85] linux-user/aarch64: Release gcs stack on thread exit Date: Thu, 14 Aug 2025 22:57:43 +1000 Message-ID: <20250814125752.164107-77-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: 1755177427871124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177444; cv=none; d=zohomail.com; s=zohoarc; b=gnhVy+Yjdxav5J1u+zR2LliTJagEzC0PIKZ3GGJBkTnqI0Po4/d1iV/mt9hfXtHyK+8Duz5J1dFLUiCxXnDvHuVTho0X8PnjLXYOyASGXG9CmPdEOMS5YSrRrBil9e2ZeLmgtje7EJHR49x+OEHFQpS1AVIZmOMcZ4F22IlK5OM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177444; 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=DBYS2mqukXmSuyeBEriXoe2yPoz8PJ/oKebq4ub7EQRYlgsceYrgg1SmWSXmCDDiBC9pxEeX+JjV/OeB6qtaWU2o6zaRxRbMRTY+P5FYNqgIiqc1v1Uhd6QWrXOqyRJIghVOEtceBrGJMew6qqU+oVYVRFQd9nqzOQZJi8s3b2I= 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 1755177444590356.31948381168183; Thu, 14 Aug 2025 06:17:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXel-0004XC-Vq; Thu, 14 Aug 2025 09:06:12 -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 1umXeA-0003YW-8n for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:34 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdw-0005c1-Ca for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:32 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-76e2e89bebaso698284b3a.1 for ; Thu, 14 Aug 2025 06:05:16 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176715; x=1755781515; 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=MXB4OkMT1f22OiEtP+X4ik1vyxe8SWDx9zPFpdmWbsu2lNl1cxOM1XsrRmYQ0mlE0i Go5kHHmu3WyLklJcSBxnqFAdjfe/VW4uZ5PZMT0zby1tAYu1X7vPTnTmHy20NSR9CQGR dIe0X4JcW2WWnVnOp8Mr/B16AyNEiqu2jdheNpvELfNb7AyRxHDxMQ1FRpeB3FBEr4zM Ei54y4Jh2Boxdt6R3nnyHF0Vfd9ANfZivedQjczjUUXNPdjAFmKJ/4hpFxBks0N/rXP+ HGITiaLgpIqSWeQ6WSJ9xMKL1rj0MXlQ6Bae5mVvYyrVcDXfkZWuEA368yePr4D7Kn8E 8Kmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176715; x=1755781515; 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=dkZH5EcsrYbXgTEOBfGk2+BSW279U1uVbZbePETsw3BNp055jq5BcMz1R1cpA5m49L wzdiWtmkJffP3McfOHIWO3ExMYf25sIJBVW7vCSczl5uXlMP7t6tYRKMRRzog/CH3WRC /pnaAD45HKSTkGh8NZnY6KBYOU55JKqABuR7nep6lUFLzV3+dslD+6qlb9FH/ZUzTHGK uFH/X3eD60WsNOGTTWvuEOmgc6cO56SNaIkYfIdgdcqqMsoudI4fgfPUAmAxSkDnDrW/ +WWtHgkM+nnHdurSOaBrp/0TSFLb5DLajPsd3vQgQtSySHqm4b69/xTOyK9SzPbBWj+l YbUQ== X-Gm-Message-State: AOJu0YyEzyFvrtkjMrJJHMkBs/fFk7O3qKwehlYHV97INYsbxPzH1aJU AFafqiQXD1SqHV8OnmN7LVoBx3MSwoHPNLCx2d+UCLYvqzlnnIT/7dmyXL6LaEFyxRpiRv+tcrB eWrFFgXA= X-Gm-Gg: ASbGncsHEF0ARzAE4DneCqYh8pM/PX7gi/KGAaa/7NthwLYc32CnY0xijpqYMlGTI1e 3btfMgn1ptChyOhXIYvNduHR1lsl6CXk9g/sZl/v8ES0NMyiaKMZng3W27I7v6gkpg4D58z6vvX 5jgsVZ/M3Hpg07jzp/oZvWGbPNueNITMPtYeMpb/wyaarrYEMgqfWAAonBssiU4lZkU3W8Op76/ DSBU5p8QZpXGUqch3NGTUFixErHZrHbw6UgQC/64ZhzGg6DvSoEv9+L1D6y3cfcpVRFoSaMtkPZ 6GWN9lXwjzs6PzKuuIArIKd48lz9FrdmeClr/26wr/hKfqImZFvsgccxfsgC6gX8mWzfJIq2Vef R6w0ZIBjJ1u0ef37do84A3p2Pnd4MxiIdpdaRtEOAzV76ki8= X-Google-Smtp-Source: AGHT+IFfO9vl4AwAbosB3xXp1RewKyiDguAhLwyKrcGPiQ51KSA0BbQ1pNvVS49hhtDh9IXpitPncg== X-Received: by 2002:a05:6a20:3949:b0:240:356:f033 with SMTP id adf61e73a8af0-240bcfc8202mr4423678637.16.1755176714753; Thu, 14 Aug 2025 06:05:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 77/85] linux-user/aarch64: Implement map_shadow_stack syscall Date: Thu, 14 Aug 2025 22:57:44 +1000 Message-ID: <20250814125752.164107-78-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: 1755177445675116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177135; cv=none; d=zohomail.com; s=zohoarc; b=gyleOSDe8t9heCnMOVjCHzGu65Q/Q1UI8R+jgVChQDqsH2jf4DeK+iS8ifFkFhwlZJK+oXEgTRUxMwFuMKnNhtvIZXNIBV5bc/e3iKWjBcVudOdzzGixRS3uo74hoDYzZl690NX4pWcekDEmm1DJWLY+zqcLesNbgugOel/HwxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177135; 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=Nh6LQorP0ipNXf7oShg/R5QFehlex8xTlDZUa/RVg6cCDDCMW6GCWfvtjk9xoSsjfSo+8/+NJYHPMuViViwtm24BuoiHkDI/LBajZfKgaTbBj4bNsxiyLuIuOYdCxMOHSLvfjx1u1Zgub+I09Rfwpe7cjzUKpKPFo1bxOXFux50= 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 1755177135233906.2228203825924; Thu, 14 Aug 2025 06:12:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXel-0004Ws-4z; Thu, 14 Aug 2025 09:06: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 1umXeA-0003Yg-9O for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:34 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXdv-0005cZ-UP for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:33 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-76e2e614b83so720798b3a.0 for ; Thu, 14 Aug 2025 06:05:19 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176718; x=1755781518; 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=emdcfISw+ZyZWZ+mIrPdgDHF1qM2bwpq8q8V3lR3cby+WI1DXyT/L5M5LT3KMSjofR 82puxP4gVWW1PLJS3DujIMAR2+DVKUMSzh1MAPY6UitKUidxqnZ70y4tHB5nsVqNx1M4 Ts4aV/kjnA4lLoQbLsiYec3LNSg2W33KmVWY/lysAgGNF9y9ivQQaguvszkZXXaZYdkT aNZoMjDB9yCDE+Bt+7G5JJEsv+svIkR6DPh1kmg06cUnZ+fDMp1ckdu4c8OkoCZ5BPZf vGd/3apxJIEIg6xSy0peVpBEIFTMXqb0toywM81GHCpDvj8Vdqrk7MCZLETImB8O22Uu ZALQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176718; x=1755781518; 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=dhOJ2rVBQIs3Tcaf3IO3ySWp2qOf0ARUdI/JRcHnk0PTV4p2UYEZ9MAKLa9e4Xj0FE FUtLjGt8FPpnxxNYm+4mwIxX4nMYCk/7PX4DAygQ1T3se13H2xCVcSVWipVLNNrON1ve 7JHkeAZ1Zxm69W9BFaVu+IdOTNwLvYY4C2aiMcjYV0rP7kGndwIUv8ByVRoqXZbnDvfb 9/a/jOmuaWNXbSJv3mBQYyXDqEBOUh8U/ugdkq2GRrHTf1iQP7Mc5EjLEF9AGsH9LYKJ SUHpi8V9Pm4ObdQY6rtk4WE5SMXSYuZQ3wp9weGarF0tls9x62BOZEpFS8fMjs1Rw1CL pKZA== X-Gm-Message-State: AOJu0YzEnB/ZVtRonV/e5IEzji+nQcDI90vaYR1lcjG/EOlZVJ1a3nrV lxZSO0XV1HqfH4HHMli0qkBn0UxGdVuS5oH9kfZbmjH/Vb/aC9oExKBs7q8yJHShJZUUdWzxbjP JJ+bBbxE= X-Gm-Gg: ASbGncusJcSHxMQZpl5XZZoC/pBoFgUAC0ko87o0Kyxsnas7Ck7wc64gQQUU/LZswbv leg/7bQDbJUbP8gdcj3n08HN0I7/kUAKB6rxKFv6NOuLWu7OCBc/jCOOnz8FiFYnRKUOim7yDzS dxxNa4WWywP6wqhwHPPJW/0AQbksmKo0jtKWapfObkj6JqM7wh7h6i+ckowpHBONh63vlK4R9An ELledBkDvcbxBSWtYtfNe6An11PUBLToKvRWe1Rw66e4lpanaKPSp5DKduXRIQfvw+vzY7g0ASo gPBbrwTB5DbuI005Y/z1s3l+TSi66di9Cn5xdj4AF/YVmMiBbXXOf/yT2jUyBecnfnFV2St1NBu Mvn7swDyS/zsbqA6Zep/pMIhawjVm/lnLDowPxgcMY2O5k8L5cGaOcdnsHQ== X-Google-Smtp-Source: AGHT+IFJO4feDKk0LaggKzdPc3UD+mX3IYfxkI84XpcnCfxFsBphVVMP61Cmxa4qIqRC9lPaqCe59Q== X-Received: by 2002:a05:6a20:4324:b0:240:265f:4eca with SMTP id adf61e73a8af0-240bd325a85mr4140446637.36.1755176717833; Thu, 14 Aug 2025 06:05:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 78/85] target/arm: Enable GCSPR_EL0 for read in user-mode Date: Thu, 14 Aug 2025 22:57:45 +1000 Message-ID: <20250814125752.164107-79-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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: 1755177135943116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177789; cv=none; d=zohomail.com; s=zohoarc; b=AEGoy2ubdHAyGKUlVoOwdxE7+MgZZ4MFffFsiFkuQHyip42PpXmjJDci3Ydv65RBTOOp7JlOeh01T2maGamNnQmL0OuH9FvsLmTRhncRzMLL79PDjl739+a0dPKB5huyxMRbcoDjR2f3vjkt9Pe+qZGtob+cdtxxG7rz4IzwtAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177789; 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=weyLI8Pwby6Pmklm5JI4NiuesSFjCf6M/0WIe/lgfK8=; b=GLTLkKUMsj+laiprrqh4yUdQvapkWp53nEO3ArmJ+n546iT2JtcEf2T/x4ilXodWn1JxsOjuudHdiRLHM/S9qzfHOE84zpIwS6+T9BpjePSgD0TpcRdDa8YGtGVG61cjOMSHJcG+9VRBMOex/TFKa61Ydy1u9WmS3uNbx2F8TiU= 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 17551777898712.918665659913245; Thu, 14 Aug 2025 06:23:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXen-0004YE-GY; Thu, 14 Aug 2025 09:06: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 1umXeK-0003zv-QH for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:44 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXe0-0005dY-Ue for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:05:44 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-76e2eb6d07bso919848b3a.3 for ; Thu, 14 Aug 2025 06:05:23 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bcce6f6fesm34480631b3a.26.2025.08.14.06.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176721; x=1755781521; 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=weyLI8Pwby6Pmklm5JI4NiuesSFjCf6M/0WIe/lgfK8=; b=Wdw4P+MYA8/9s5MtfbuS8MnTHDewYUxZy6IxjFEPLtVLpPGxWUpiEo9/9SupFjpWsZ +YGdE8+L8Jo55xe5XrYInSbJMD/m+WIpRZ6RbgIBgUE4pAANczNjx0tATu2vE/ZIm3Oj u9yMMq0Va9woDw4v5OriBkuO/vi53X7xrOoAS6GqbinRn1NTSwqhyrAj6HChKf8ND2hN FTjyrtCNiMoiR/lo1b8UXGlNonD3RJI17KgNVXcAuE/Nq/IRNwuSoJnHr2KdYfQB1dlE RSgHblDpw/rbpk2tPKSsFAESYsNjFH+OwcJbetHOkwXljfyDWERSpWCSuAQsDjSBM9d9 7iDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176721; x=1755781521; 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=weyLI8Pwby6Pmklm5JI4NiuesSFjCf6M/0WIe/lgfK8=; b=XumQnG1xwXWvTfiECeQRkZbLfYOUUAxmKtc0fygtG454EC78YwARwU1+JUgsA1f5bG MJs2N7QIIOaL5nN5ZE7sv8JFWWFVeflYXTcmZ+nUNy35w+2tli/ZRGHL7xK/ugSFNrWT AUZxydCE779LrDfSZmAf6pIA/hG59LpqMQMDjqP7IxuPJmzSnQ7YCVj1nrzeMajYOEWK UOsC5gipLl2BhlNrqOhOKLAXRVNO+Bfiv5m0vNtXbtBMEE2oc+231pHDnzuTxOaRNKpi 8hs28lISN686XVwJRB2AwW0QWtN3zSaK2HFjbr3Jrl5pdZQSy0jopeFLB79wtOSX+IT8 aLWw== X-Gm-Message-State: AOJu0YxZ9ZxC2qtbcJFfE0Yoy8Zh6x+58yv5kMIqEBD64+C+C0495jdK YvSly3n1rG0mz8F2NY6EwVRjE57YoTZizIH+CK+mc9aK9eAgnng4OHavxD8wejR5VlpE15O9Tma 7Vyhq8Us= X-Gm-Gg: ASbGncsNgnW/D7ZNJDTb+KDJOT0RK0Q2ivdkLpBAHFJxp4eKtLYceNRduflVbtvbTQO EaeVdkwC6EQ+UGYXOs+AQ9aQlbqsvvU4BU3Vkx5Hc/xbqt7yb+G+TlUbMQovdV2Y+LbZqhS7sDJ 8LTWktTDb3vAxj2IGOntq7YeuQkXBl+wvtHs3i9E4HWPqtjd+4gohqt8fhIQ+++mWbOOHSr1bQQ BlI4Rq4rEjM+kVC+p42CpV3P/S1NgLcAjzVqQbLogCiZom2CJBuTbyqVgqxig4R/RsPonDhyzUx YUE9V9/0GB22oZ8kBLBXWANFpN2toPpEWBR+len/IAFWBb8YYPKQzrfqec4bR/7iMpYK2GNHcUW kv3wSw5S3RjEyPJt+7+gFiCFpHTLVW5QF5AdwXBdmNfPOggLQ9YJIghfG2w== X-Google-Smtp-Source: AGHT+IFQGzlyyD2ip3r/5qhf3oOvDbAe338WXf7KKQBDABXnHFR6gOVYV0jiwmtEaD6ERJ11X58p8w== X-Received: by 2002:a05:6a21:6d8e:b0:240:358f:3918 with SMTP id adf61e73a8af0-240bd371837mr4806608637.40.1755176720867; Thu, 14 Aug 2025 06:05:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 79/85] linux-user/aarch64: Inject SIGSEGV for GCS faults Date: Thu, 14 Aug 2025 22:57:46 +1000 Message-ID: <20250814125752.164107-80-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 1755177791431116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 da89dbb095..080aaf3369 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 Sun Dec 14 20:30:54 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=1755177962; cv=none; d=zohomail.com; s=zohoarc; b=acdWabYa9DyVrH4ZnhQ9/fi1D05DVyHpqXlXALnjbIysqUaafvrRPV+A/NzvFYLwjbk5BBc3AK+/iQ9Bcouf+zVDs1qGq8JCx2HVjH8XlnZgns+EmFN+sDC6uAjVYQg/pfKN0PNmxad4UXhKFNCL1OQL+qbiHhUuF9ISonFBgLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177962; 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=jUo2eLEQH3tvadRbtyXeqZmXKqgrSzHJmdQtpKn9Hto=; b=jnBlAmpaDdtk9hv04WdtTDO5WRzvB1sGivjp3IcxFynHv3gIuy0MjkEzb7W8UKLddJqAZQurWrNOiFViPrAUPPtMACUHxon5V2OLyZVd+SIiq0bcph3Oa1vhFWNyu6QuDGSiGYt8vAOcUIpNHg+UHbyb1iq6QHVwc2g46W+9vuw= 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 1755177962488830.469375059614; Thu, 14 Aug 2025 06:26:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXhX-0001VX-J5; Thu, 14 Aug 2025 09:09:04 -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 1umXhO-0000uI-GB for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:54 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXh2-0005wk-1y for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:48 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b471746a879so529415a12.2 for ; Thu, 14 Aug 2025 06:08:29 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24304c2943asm64438335ad.30.2025.08.14.06.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176908; x=1755781708; 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=jUo2eLEQH3tvadRbtyXeqZmXKqgrSzHJmdQtpKn9Hto=; b=okzpQ51DVigKOc4ziC3CNGM9piXqF46OdJUtubB3PoZsCxEtDU40Q/s9AjdRrcK9nf 7ZWfogGgpsPVBg4GMmBa6PMdyX5Se38TZFv+iiIeOIfvQ8kHj0+jeaWT2SMVGigXYvHN DvHF0O0D5W3PsW8HaXe5x9KEqG81Fvm6bpuTaDL5TT/xmVyyykm0u/bT53Hz7OKWo0vi o9j3GhcogepoEaiWsRflrjL5fhmwPZMRi5SyyccbzhGadIyZi8WWJk4pEwtpJmMpy9+G pDQQAjg4hmp/F2ASp+oCrOZs6fidRzUmCHKmPbxtyBgym54UoB+DpNAJbknsmS6Gd2HS zP4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176908; x=1755781708; 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=jUo2eLEQH3tvadRbtyXeqZmXKqgrSzHJmdQtpKn9Hto=; b=Pqu7ms3oRDIVDVfRfxweJ6Lprliz9n1X1+3ecsNCLs4RrnrxJpvVS3ym9jn6xb0hpK jkI2wQ5RqQ4YeZdAkNi8oTeJPgwYF2TFCgDuA1RkQi9ONq6g+idO0GcQopSmDVHJ4C/k dKV5gFMJVB4KMghvjQcYk43Ju4H2T7/JtVf2WoZ/rAa2eXEeospLclKJ/FSpSsdPedMY mG9VpLzSntpZNLaKD1qDNk8pp4nC5KMdx+a7mhYYT3U5Z9W9VsX4rvRYeE2Zs1hk5AwX uI8YjEKHPIzaxiwpaok0mBAI3UR030UhcAn3PeSEZWS5fGouoGKhmgR7LtgzOFztvjaH sPyg== X-Gm-Message-State: AOJu0YziwSQR2BAxjgI9iIWlUOEsMoqjeGAwL13qdecJ/Ds8LTDqrWh0 d0EiiYzIqjSEcBIVlNjhzckZ/NCVkuxSkkI2AYWAn9ECvm1a1+lct7iog5OcI5xzD5icNbxCoi+ qXptg9aw= X-Gm-Gg: ASbGnctlm0vZ2yM1/Cj4dtIg1yX3HTWzJIDXau4SYUSInAmhDF3Yh9UNkI5L8akPBN2 s23CPCzOE35BIqMj24iTYYmSi3Ay9OlD1JqRGagYyhWl0x3OLPcX1HTRCWhgdxo8FJOKwNWd0Sy jevN7iyisZzj2cmcqq+uo33RwRGA3J+giYV7JCaaZHo83hYMkqu9hpgJ6rl28ZQbjIgk0CfcZxn OCWYz2HeRue7BFoLQPM68fYk9WVWr54MJ1hrHiSgJCoJ3MrGu1XuX7Y8RkFJa9LxA+lJOLNWaus NebTlC6qzATI6DvvAVTusMD1BnUDhZfr/1DPCR8GJTuXZqkRLUOUW75gmflsRUZgjj4KjjRpFzW LOVK9QaeZM4vR6VT6eSa2uxnt/3U4MKpPf7QIOMCVfhwzYqQ= X-Google-Smtp-Source: AGHT+IECbLuwUgIIWFCgXwT+SsT18GsKwbOiG4OlTB20ATuhLzFybHx2MfINYOfNqlzG98q+tS2wXQ== X-Received: by 2002:a17:903:2b0f:b0:234:8ec1:4af6 with SMTP id d9443c01a7336-244586d5141mr46731925ad.45.1755176908010; Thu, 14 Aug 2025 06:08:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 80/85] linux-user/aarch64: Generate GCS signal records Date: Thu, 14 Aug 2025 22:57:47 +1000 Message-ID: <20250814125752.164107-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1755177963461116600 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 Tested-by: Thiago Jung Bauermann --- linux-user/aarch64/signal.c | 138 ++++++++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 6 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index ef97be3ac7..f7edfa249e 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,64 @@ 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); + + /* + * The kernel pushes the value through the hw register: + * write_sysreg_s(gcspr, SYS_GCSPR_EL0) in restore_gcs_context, + * then read_sysreg_s(SYS_GCSPR_EL0) in gcs_restore_signal. + * Since the bottom 3 bits are RES0, this can (CONSTRAINED UNPREDICTAB= LE) + * force align the value. Mirror the choice from gcspr_write(). + */ + gcspr &=3D ~7; + + 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 +609,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 +682,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 +721,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 +744,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 +817,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 +836,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 +900,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 +913,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 +942,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 Sun Dec 14 20:30:54 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=1755177364; cv=none; d=zohomail.com; s=zohoarc; b=Y5OPjyq90hx/HxhCBOlkYLditSCEOQRUsAmkCuy2s2YSPmk06cRXRA8lHA2BkVwIf+jBuDeTMoUFGw6/E+z7M5jmxCiacghCv3U3IbWq+p9+TYu3UWNe0njfviVE0Z1t30FuR1rVZhV0EQpGD22cIGOPg0JJhjViv6I5DWK5twM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177364; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/Xz5ywrXRvUgKRNtpJyxz8fg1SwzzhmCjpXpAJaxAoA=; b=ai+EsSNbIYdmmKnCvS0OAQfzFpyPjO2KZ0TxOXW0HJIjTVerHFxU45b4nN3tNGRXyhaV7C7F4nqV0Hv8HgqODmOf58YzFjHXZrSKgXODi/mjoWkmXJkw+xaQj+U1e/bJ9ug/lomBtx1KJJSAHbGDG2+RDxh7iN0v10cdSYTlQEQ= 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 1755177364913610.0853907145826; Thu, 14 Aug 2025 06:16:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXhS-00014u-CH; Thu, 14 Aug 2025 09:09: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 1umXhD-0000jx-Gx for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:45 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXh6-0005x7-Mj for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:43 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-b4717563599so693923a12.3 for ; Thu, 14 Aug 2025 06:08:33 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24304c2943asm64438335ad.30.2025.08.14.06.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176912; x=1755781712; 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=/Xz5ywrXRvUgKRNtpJyxz8fg1SwzzhmCjpXpAJaxAoA=; b=LJ32U4ureI3Wb33fNOmeFtzovz99Q/CUhH6St/XgkUOdhhXCBgeuZk/fxzYE6ewUtv c/SB/HvIWLQnPf5eLzNmTQNc+DjUnbo4A9jz3+RLkhb3RzPHFFiuTwYLAjmZId279wsy cOBjrdvMo1CdI2JkQGBpkiSWVMPBizftCbCfhQLa4xDznV2O67HXah9xwvJEiL+vCNR4 qhV4m/Zc39frMcN/Fd3zyXDcv6mlssGd0mMKRV8KX7lut+FyrssyT+4W8eByU8NsmZIl lj9rDxpXQhDPdEeSOw9kXEVlAPkde5UnexnGhKRax+sbuLod0KvJYz5E3x/3UEytSpYU B53g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176912; x=1755781712; 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=/Xz5ywrXRvUgKRNtpJyxz8fg1SwzzhmCjpXpAJaxAoA=; b=deEOKOo11vh+238uf6dD4d/APQ9RODe2ypLgNqohD7GQvoOJEXhSwCuGNp3Vww90fr UVnkj3V5JuoKpEexC+X7lmmaBzMWpv1pV6yw0BVePoWmpT+cR8UCE9N8R9ve3ASnM9oE V/VqB7W+h22LWiAXPX5/TfKqT5IFEPLSUHjfHdKEThey6Z62H+zcQQW/9uIjIlpt0jMs 25hcoGa8A0x5paf01QnNjNAmxMUtIAuxlOX6MX3YhF0VLWkIiWCsBQLbfeZEvvo2oFlq w77Twzij4a1zMRmqiZMEbXZX5yByHhWtDv41VT1giyhSBu7015yLm7gol3zwud4rZNBW sHVA== X-Gm-Message-State: AOJu0YxFFTEncEDgNs4Nu/b1sk4n4JHigSOmfqNqr0QzKti0WTzInoDF +l5YAPHmtHzl5rb81HKwZnnEcpedGSsxZ0F3v0qEZHkYNJiy8wiakJHm0uETezyZb5Q4fYg94Iu Zv3rkS+Q= X-Gm-Gg: ASbGnct8Dk5rdQBXMTV1X63+RnV4l+r28d5j4vXnEX6TvgssVf3NGK06RdgfsAJ1XtV ba7q0JnY6hOhWyqr3d88FVkJoASZlqnojkAOAFO+VYPZx6E2bZWWPHLuzoeQROhrkIRK/hHeR5r AcaVsuGmIy5HnNE9SC7hyAYoeZto4educ1QdF71n7Kr4lhB6OgR40l4n2Ie3uk7AcS03NkXhmwn hvt7EQ5CeuqktX4Bpe7Z0K/lbYyaCXMAVjsFO1c4T3HUZhQqD8M/aaKX8eoTvoS2yuGmXXZl4lB 6YzYFO7uBhPuvPrqys0NSyhACztLnKMFb7ZQnQccDXAM6lRkjgkrdkruKAfTTGCP3G0XlEtRWkE ERMcKqKiusrykDnN7xCeGVtZoPSM1Lcv0iAZUcyvA9BugxGQ= X-Google-Smtp-Source: AGHT+IH8wCgRgx1Gxdk7EVHy9Jg2RPrVCUOg3vltmvLYl/U/TpbZyCpBsGuNGBEXDGi1bMcyO7flzA== X-Received: by 2002:a17:903:228a:b0:242:9bbc:c775 with SMTP id d9443c01a7336-2445871c7d3mr43166585ad.56.1755176911664; Thu, 14 Aug 2025 06:08:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 81/85] linux-user: Change exported get_elf_hwcap to abi_ulong Date: Thu, 14 Aug 2025 22:57:48 +1000 Message-ID: <20250814125752.164107-82-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: 1755177366839116600 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: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177789; cv=none; d=zohomail.com; s=zohoarc; b=JZSFWIx2Iov9vF0pU8YhuEpWjOl0ux6dHL2wjQr7TchtVf6vixFgXOCwy4LmfaEnaRC6boEV5KmzSzLFjMLQjb6M5C9Hjg7XxVrNmV/exprvnmcglySVITMmaP239xnE9Mry+CdYNJwOkEATnZvijKguLzy+pbtSIx3aBZxSGBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177789; 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=OYSo8WnSxJfhZlKcbvDufSyzxkENH5DiXrwy/up3nvuFZ4lRLRfr+PRT2AvcGpYHqkhGwfi3Fc068SjzN0fg4ALrXZtmXSFGsS9ydsPgNXNaQkAW/arSo+kU9bCofOHxk0Hzqr7k/hIbNow5745mHa5xvGI+K8NLe3D+4J9ViaY= 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 1755177789240419.5408927119896; Thu, 14 Aug 2025 06:23:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXhO-0000tw-LF; Thu, 14 Aug 2025 09:08: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 1umXhF-0000l8-F4 for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:46 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXhB-0005xO-FT for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:45 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-244580591b0so6082835ad.1 for ; Thu, 14 Aug 2025 06:08:36 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24304c2943asm64438335ad.30.2025.08.14.06.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176914; x=1755781714; 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=NTTT/aZnd7i0YwAaOmJbwE7As6j8BXQIgcJJDezrZp26ZhoT0wIuflMzmfitnf8ZEU 1zPXeWByQ0V3vD3ydZil4DTuDkL6VbFqHkU2zyMWguSuYYLcQYQ/pzXScpz1PMU53S81 wnwhw4bKDbtQvrfJt3n0Nh8pvrSpWN0JYyd4FbwUKH2gLdO/RRXd7Uaf5gwPh1LWUgPB Kq9I3BLDbxiskT4/icM7PaS6K5KKs1+/GMI2481yAY/yWNZKR5XhaPqyp7DYE4Ay0/8o Y61O0SmK+dqjCeX6u+wG2z5JqfJotv98kEq10L3QE2/3BK75DpnOzlAAeVHKLRT0OtwS iDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176914; x=1755781714; 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=GmP/q/E2RC8P49dxoo/crCsDH/4aCLFlj1W55YMCCnlQUhEPIazPP0yZ0+JUVlLvMG LdiEyCLGkjzBMLn0ThJrbmUkMNZEAuPMB5xf3GcTfbajkZ/BuDsSU1V8cQiBOaAbhlfx wQRi7WZfu58Y4p+lVetxWZVTgwkiWdxoyIT3QfN3I5ooAM5ZkD7Oj+mmgO9I26nwt1XL P7lmuRkJ1jqX2bCn40QnYJ1d5VO4QOAD+uX57LereOJJxU0tQCLXgoDOYJ8vDLoUAmiO 2xLMvkOc/11/FuXpDZEHznb9YxeYXurUkwfhW3QehlI47ZlPMIwTArq754Jn/Dhm6TuD 82wA== X-Gm-Message-State: AOJu0YxTwheGIM4Y5PYNxEwTbAixk+p6+MtyTV2H4CdgQtG5dJzgG9w9 gJH2LapsrqL8ranpQNif87djW+6ifF2n3++4iHcDOrzxDYjivO55WqdjLAoyulXVrbVwavkMw+H b18wNqkM= X-Gm-Gg: ASbGncvekYobIn6SYQ3tea7kwUijhKh7Aa2nXXdwzxKoG8n4AkG7JbLFYoy6Vhjn2Nh 8cUOn90UbYPEF1ZObcpi0tYNRy84RrrJWiVIpIV7zPfJdagIT/ZJaLmzoEihFBhvRExI34bVynH gohhZ/JAy2W7Rj+me7s/frRX7GFbiu1uwtqKR+pZhUcD/NT84gOVtYqh2MA6OXJKvmaPVBUeX2A +uPT0hlkqZ3SguM4HTnI0hzhu4PHPXl/NzoNRLmcGwflEsj5PoF0YnjWxsef0QgNobAelx2wdYA UKsda4urNMEJDOFe3ZKqHnW2bRjhHoeKxTta8AiAzrJhlbvF3ZbNp5JARZ9xCVpnREjQmlMEnx4 QbarnDq2+l6m8dxDiHZyjKYUwvMj+FG2iVQwP2G51CgGY0CI= X-Google-Smtp-Source: AGHT+IHCYUly2xq/OiPBQ3pX2EGmQuu77FfAvzsezay08YhbrR/4DnKVfu4eiWMoh5O8fJ/8uRmUxQ== X-Received: by 2002:a17:903:22c4:b0:234:986c:66bf with SMTP id d9443c01a7336-244584c2da5mr43248005ad.11.1755176914428; Thu, 14 Aug 2025 06:08:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 82/85] linux-user/aarch64: Enable GCS in HWCAP Date: Thu, 14 Aug 2025 22:57:49 +1000 Message-ID: <20250814125752.164107-83-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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: 1755177791478124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177916; cv=none; d=zohomail.com; s=zohoarc; b=XHMPM4DoPffp0Q3yEJe0M3gmaOcJRJQsvvJCCNtPAVrvD0kUjr+rVc5I+cuQFtTeorH5afdPg9tVM3qb+A4pLGPp2jPHXT513Fj1thut9qEaxCEfGMjYHwI039G9ZILdYA4jj5Cg0Y+s6xFD/WXdi0NDJQ9NTbfQFMKvYCu6nbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177916; 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=d+6tNh0pO6QeYA2wXY+r6ZbfQfvYDhX/5ZHVnf4L3jd9P9wNnx8HdPyYdsR9IaB58uNw5vPSMwpoNyFLr8xWVBzfqMud2DB8+nxgeKa79NhyxPKA6KurmlvSO+eKaXmVB5fv+EdlezxSGfK0wS/cfysGfPWF4EEp2IhatSxVCrc= 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 1755177916532844.0075654711459; Thu, 14 Aug 2025 06:25:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXhi-0001rW-Qt; Thu, 14 Aug 2025 09:09: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 1umXhQ-00013Q-0u for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:56 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXhB-0005xn-IH for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:55 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2445811e19dso7481605ad.1 for ; Thu, 14 Aug 2025 06:08:39 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24304c2943asm64438335ad.30.2025.08.14.06.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176917; x=1755781717; 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=v9HftAT7k3q1G8PR+IfoL0zVLM8Jpw1kjW6Xom3lwhEFLQXmw5hIunw588iZwzs2IU exxMp6v4Z7yRLm94W8vEXxxRY0URkT7qGnSdEEqHmaxLHmAzEC9dDTJXCvKR3107jvUe 50WPkvgimlOfs0C6L6ROySv/1fY4TIsCBAyAecE4J2Bncz/EleVoOcPmfDponWMwQyjn 5NpVFWHT3/JLjn6Ui8iW2XAMO6WhesgUSHQUxqhb0I3+MQ2KLraVeg5MMgUnNPOCB8AT jXkJ1EYNYmJ73EAC5nLT37YeXI6/X1xx7xLs2D86RkjPzanpUgeg9CEniLm8TEEYXoVI AFjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176917; x=1755781717; 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=RIUwTn+o9oN6Iv1T8BUxWSw7K+rZxW7/Et86sZbD/5qIUV2eQs63c8n6QCN09n59iJ PiyRVITlkh7rr9Ij1CNYz4jHbpLaNHZ0+YH5tBRVegicAqShxkihJ5o3townMyx+79bG xDYApXZC+EakcvSYtFPer0j0SZy26zkZhgVsKU4QkGEWANeIRE4N+W0EG+OKXnPYvuO2 0Ap/dh/bDXVynqA9HQafKKdrO9Seqdrp3zy6uSJPsil6fZEHp2BQLnLZ6jJPTS1P3V0f ycc9Ei1fk1I6HCVOletXICqYFmMIHYOlr455LWkofR37LScl7q4/EhVZyZz6EsR7Wrku HJeQ== X-Gm-Message-State: AOJu0Ywvjb7KhreVWM3vp5qJGmyPVZF93d0CvGpEFs+bviU/GSlH7LOc iFWkCNoFPSY73Sus6M7cvyfn95mXHRjQVFp/whdho1MX+mojspG68ghX5eCkBCaQ6yBt2B7OfEi 43r2Wl4Y= X-Gm-Gg: ASbGncvfeHubWXZdIVG2M8YCCvuUp7+hdYe5o0AttG7JT504mFVS7eqCfrouqVYy76s gcR4r+BgiA2h12mfmyvnwEs3OrMDEMH6RTa9z7HmOdxyTWBGN/XeQ+JWyuUI5+xTkVGwyVZwm7X 9lFzNB2fERNoc547/HLtp8dfTRlDlDNGekvf6OshPDLWCsZzef7okfg02sNOQ2hMx3RhHxJ/Tw1 JEimLuYoBX6bJ8+gTuE845UlUxfTrFQi9dZfy4thBf7HBb3SQfwa7x/0HWRhYIUnajBKL3Einak yfniTEqKlq6WEBewrciUHwyPY+XBuViBGyvKDfmwpx3VbVWSRPA8jt3l7EfAnaSIAH6U93DJ79Q ZiyqfxPYIGmB7YxfHzo9owH2hiti5CY/LKO28Asz+eKA1g0k= X-Google-Smtp-Source: AGHT+IH8941VP1uXJa8jY6Ah37eo+jnrj+VojjCO4TWc4GEFEY/n1VI2va7JGvGfcN5krkBIkPU9CQ== X-Received: by 2002:a17:903:1984:b0:240:7725:18de with SMTP id d9443c01a7336-2445867ee51mr46813895ad.37.1755176917333; Thu, 14 Aug 2025 06:08:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 83/85] tests/tcg/aarch64: Add gcsstr Date: Thu, 14 Aug 2025 22:57:50 +1000 Message-ID: <20250814125752.164107-84-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: 1755177918720116600 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 Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177152; cv=none; d=zohomail.com; s=zohoarc; b=Cj/lElncUNVZ8NmloKwxZSbAo6LCSpiGzA6jP1m2b3XjUfo0xEuqYyqd6z8CgaoW/ekzJX3aM1izPTLGQamIpfsiM9PzkWSSHmw3Cd2CGuqpr2pyhejq/sKaBBkqvrxMoXc5h5QgnR8JOuf6mg+dcaksVnL8NQZiBOu4hqMYjnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177152; 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=G+solE271lhZjw1963CvFo/par9AZWccrqUeKn1mfkVXymtfns9NsrccXal9tuURB1PlpnX1IwKIz3AUqskTElWOxlNtgZupZpZT0IYlKLowU4XB61jY5ih7HYUeudMR2dDwy9EGLT2unWwnb3Jov+MpBTe/Vg6gYf8MUWPwUmU= 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 1755177152488692.925601324529; Thu, 14 Aug 2025 06:12:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXhY-0001Nb-S6; Thu, 14 Aug 2025 09:09: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 1umXhO-0000uE-DS for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:54 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXhC-0005yA-Cw for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:49 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2445818eb6eso6464095ad.2 for ; Thu, 14 Aug 2025 06:08:41 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24304c2943asm64438335ad.30.2025.08.14.06.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176920; x=1755781720; 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=DyQvJ0HZe1/BIDPY+w66ShdVbberqsodrCbffej9jlwhrs86bRkM/cCt/ZRf2TgMRp SabyI9CPMgRwA6OXsSqYL1Lk4+imeiT31rqN7gyaXUKWvDzaQDz7gJSmi59Uptz0gLrj tDTu41lSXdKxCGhS8kSQuGc/AvGWJcXvOOKvcb1S010VCHUunfeCBd/3S4NFajj+8cry bRKbLqBnTCdfggPmTVlVOaIWP8ZhBUEOWUZezehlzFNJBV7d7QRyxRToBsJna9Z/XjFQ LVRp14p+ah+iB+rAq4U+w1qY/IJQ5NHkqPmPz425fCNDZ8wJKF2PeyGjcWJ0t1YUBY8l XhvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176920; x=1755781720; 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=IbTcWb7Vv4LM2eACqWhKha2/T7QIB15Pl12lSKhObIa+bkdWx+c2yKCbeMDd8r5Dm1 2G3lY4QHVhNojDlO7tOhwP1rzlrVJDOroy40Ha0rKoUJ15hRfEKUweoyRyklIGeHtIIw luiMsLYTRJLRw/O8jGoUuY3a1f7al2DgSm9pb6lTo21hiUf9QEKWXyFq+njAjkA0VphJ O22fBAzAuR+EMvzjv9xtnnhiE9rNWTErKxHK0GzAj+aNMCGkR1lBaopQRVCtAwnuhNnZ oukH1UkLbVzgmVLnS404hUVjn+bcfGpvZRzZ9r70h5NmgAwfnmeIqLSMJjEFb7N4zZJR 1RXA== X-Gm-Message-State: AOJu0Yy9w6XEd62YmyRHTH2QAwbe1pz0kCiZGsfSsxQGa3PXQDJ5qL0p /cAekEEvysPW+1PHtncN1cW/ZHterfrkRDvMwTxFilqCt/okeDCmI8MJpt24EjMFKZfhVNyAl3s cbvX92V4= X-Gm-Gg: ASbGncuitu5Ymgou6Zb9yUJb3t9F8jRyQ2ThMYMmU0Bi2maZT1K9eWdckgBF0jgmMbw KkRj+O/AMlO8q3fuxWpue/bz/Ex0CXPEe5CXYqGuDqLCFXTReTl3/XHXj8/T8LnuU7gWnl03Zgh 5yTdUqeySeK0g0jyrPgwhXZpEvtcngI2PU5n7Arr9DILQC7n6zf303m2+l0LsLjmqWS9L7bXmXD uW+OoHuPCHDVMiYKFd7zQBlJk9ub5ttFiSjmD28IV0tkJW3u4QxGHke4oI2BDxZMoUlVuRIf5Hc dq4zYGsojzW2k478O/OdW2j3Pk45ZlSiE+XXgnfxWwqJ6HX82m1mPzgiyNRoPqJP6K56yh0vuUt 3xX5uFBtyPTxNP2uMLToAZYPxJdv8RCZQ+U00Prjnd1+fQG4= X-Google-Smtp-Source: AGHT+IHPMQ37RESdZkKcbeLTTR+tYZ2/ePRnBdXQSbqyT5zDTKWX9Fg406xDSVLsDgHldxHoMPx3YA== X-Received: by 2002:a17:903:2c8:b0:243:7cf:9bca with SMTP id d9443c01a7336-244586ed222mr38606435ad.55.1755176920293; Thu, 14 Aug 2025 06:08:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 84/85] tests/tcg/aarch64: Add gcspushm Date: Thu, 14 Aug 2025 22:57:51 +1000 Message-ID: <20250814125752.164107-85-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: 1755177154138116600 Content-Type: text/plain; charset="utf-8" Validate successful and trapped executions of GCSPUSHM, GCSPOPM. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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 Sun Dec 14 20:30:54 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=1755177811; cv=none; d=zohomail.com; s=zohoarc; b=O2QshUUFL8Ekn/YWdhBNbbzI6kxwOgBC7H44mWcfHP001XinWW+u4kwV1edQGKuIP6jJXsPKH64+fPKVzngEE3SffLBRNViOLNiyb+qAFGuhYvYfur7l76lgNCZtICKBAcW77F+emkDJHskrzivArMyRDwBT6Cb5w8PGDi8J8cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755177811; 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=EC6ybjMWJcllqyt0+XGuMXasZW9Vqjsf3N3C1p9iM8Jo2xC60OIDvUBwwoyojwoSNZ4eV9t5d1O3ION4skQ5YSb+UbmOBuO1hQgCfuOiFVMz2i7JsWdkoE7TyeC0aecawAwbEh5/xu/MimXUBMAw0nmXdejuFc89Zti57c/4Tdk= 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 1755177811853246.358021589156; Thu, 14 Aug 2025 06:23:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umXi0-0002NX-3C; Thu, 14 Aug 2025 09:09: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 1umXhT-0001KE-BG for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:09:02 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1umXhO-0005yn-9R for qemu-devel@nongnu.org; Thu, 14 Aug 2025 09:08:59 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b47174beb13so576439a12.2 for ; Thu, 14 Aug 2025 06:08:46 -0700 (PDT) Received: from localhost.localdomain ([206.83.105.236]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24304c2943asm64438335ad.30.2025.08.14.06.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 06:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755176923; x=1755781723; 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=y0ycavbTbeHBg24zlS/TfS1/itLrBDtb5K8r8Y9PPei7DNSi4yhu4aEClep5wRlOFF IwmiJdftAhTsZ1ST36YKnrwzqmG9ckQVTb1/jjugS+weN2ILyWppIvsSR0gMxlZ34Azv Qu6nzhWGK1oSaJ0WmR2Dgq3h+B9JKA6Yu92ESulzvncP3cMRMtRANkwEEshHm33aN12E MOwWkjfpNQStrv9mm9CkSNs4t9XijFPXIkEZXGe3ggdjMvjtMqzDf+TkMQI4+8Y2kqD3 pIns4yeZWO6FSPVsnvuCs7fuzzoOfxwQchwlm6gkNMJbSVW9fjn9/3FlkmMVyzk6iSeC cq2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755176923; x=1755781723; 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=FBBQW8wfjMSgBnX1ejdQm4BkcU74V+Sy/MkrZkfOyzQt8ue8mGDOWoAVnOAZE6+l7O FV0Oc+knxbEi3lquozX1KXkWv/Q1UWUTd23I0doW6rS6mhhorydfWNY/KwLKh9LKTzUY LGU2LAftIJEz8j36gBs2QBapkrI+cBrqtuJ7jojNrcZBQfJLyro5W8BfPjGvnn2Qgppy +r+J++g+jEBAIC3xEwOYBAzzufuTM3v/7f3zsf3jGb/7iO4NDuAIDp9cIb9FbfJg962d bE5Pj3dcr+KwF2gzXqVoHOa1ggFzB1DvOVR8/0IugVZ+DtWPCSrmTLmgeU8g5GkCg4hj JBFA== X-Gm-Message-State: AOJu0Yx/OT8rdGCQiLAJWgrwOKPXuj7uhINiOIy+eQlBYP8Qqyha0Gv4 3FiQ4HrIoVAIE8aZkSGUrPqVvYazKefPBLqgpIhZcRVu/w3lPlyuf4bZLv21TrFSppjiQ0fXCZ8 wNCpDZu0= X-Gm-Gg: ASbGncsrVNiaSjxKhg9EwvKrSdtZlo2h/R1FmcGAwvXOxI0iDRMUzSCfQR0TSg4kGXH fJHTPzy7X8zp/xP5O90RExfrxX4YKcA97ntETVr+S6OPQ4hqRhEmbOk9s6XE+/owIHUa4ZrR/wd tgR7NlDAOleWVsGfOZ0PqOjkrn92aQJhIZ8jNV6hhzUM49SScFRs5sRP/wL6nxPwctJr60CocSq 9YKci8DgwvCjnNXYg8luaWYPbzzOVWw8KS1x4fKfERXjxLrNZQsMzMq5qPunelmL6RgsvCHRCFb q+a75C5Xe/IvBG/znx6+0low1wsWY4PUlt1/medT8ns2hAdMrTeHnY1loCZaIuepNo34rBsJM/z dIblYMtpK/uIrt1MKU83MuqqtLrlGR+RYmlQTKpJhN/+gdoQ= X-Google-Smtp-Source: AGHT+IG/dkbB6uvMypOJlf2Fesz59oY3wr5wGmYP0fPlPty09Gplf1zoGQfiwLuUwQe3Z84A+u++UQ== X-Received: by 2002:a17:903:2285:b0:240:cd3e:d860 with SMTP id d9443c01a7336-24458b5546bmr39662555ad.41.1755176923376; Thu, 14 Aug 2025 06:08:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 85/85] tests/tcg/aarch64: Add gcsss Date: Thu, 14 Aug 2025 22:57:52 +1000 Message-ID: <20250814125752.164107-86-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814125752.164107-1-richard.henderson@linaro.org> References: <20250814125752.164107-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::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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, 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: 1755177813794124100 Content-Type: text/plain; charset="utf-8" Validate stack switching and recursion depth. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Tested-by: Thiago Jung Bauermann --- 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