From nobody Sun Dec 14 02:14:14 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=1753603461; cv=none; d=zohomail.com; s=zohoarc; b=NqEpfjZsiO5EiZtsg3NXiZYBR8OvOGhhSOG633DmXr9yFHOBeF/sgGhvvCoIRuFez0m5pNM05PFOdvZUOV8d/681mzeDyQc/5vkhRTrlguivXhTvD9OcccuCQBjOq0CxEPLo4gr6hfYUcS2phos6yEeErwNlXGI/XChX+26Ia+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603461; 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=usHSMIsiz9y48acSDTuSuakYJz8ebYKYrU7jsQN2xLc=; b=fm0HT90ifvGJdPNNgxWWbnHsxCQ0yFCiWuJ41pEXDrPwo5g4cEN0yTmOSmrAW04eNJH6xC5zNlMvI5DaCF1j+e4fw9aMcwEhmlL1QIDtnUeQ8YYL7CqubPQP/VR+0fM85bBzD6J5njDd3jW1Pkt+Pv2QeqJjPZuFzX+Q3WJi7Pk= 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 17536034618481005.1780162484415; Sun, 27 Jul 2025 01:04:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLb-0004pt-45; Sun, 27 Jul 2025 04:03:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwLX-0004aQ-A4 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:03 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLV-0003zw-Lh for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:03 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-23636167b30so31230575ad.1 for ; Sun, 27 Jul 2025 01:03:01 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603380; x=1754208180; 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=usHSMIsiz9y48acSDTuSuakYJz8ebYKYrU7jsQN2xLc=; b=b0DlaMGaQYnBjS6gKu44Zc6gHeA2KZROiOupr8qGHqHR5OJ9lQaZDngQd8GS6S2jyB hhpHUWqQaiOEj9RKctpoDekLLaMrzpmPl8aEiwCLh2lIhYTqXPximfzin1C7opJC1U58 YlefQQXFrsmVxAQh6nYZN3x39vXq5pCz3bNofvO+U8MYG6cWlrsKU0fA/zbA0pBCZCiH zkvh+7CrVvhZjLGHQOV71YqbEXewm26Tiy4+e3h9SMyRgVyZ0HehPufjA7BJyDALrMSg WHGD/PNThUejimBn9mm65kauP/ub4+yhreuNHsoRLQFGRl3AKgrRYqwIUloA3541dus4 WODA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603380; x=1754208180; 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=usHSMIsiz9y48acSDTuSuakYJz8ebYKYrU7jsQN2xLc=; b=LdK9506B0Do1K4rAcjGfmWHvgYYOYlwAvrRrEl4gTLpOv+rYKuE0EOSlfXbg/DzonN DU2ppKZ5MX3k7mQ4tZHvye2z3VIXzXx8J30UxLDpqoZISLUMXDx5owR2fTOthiX/lt6N t7CfId4TVIdaHBrevYmqw3ZH08vttOYArrPA74Du/lDKcNjf+PzxFzqhQsrzWcoKvlm0 GvNdiCtG9M/XbbMrOMyNzgP71FBqrQaPjVQdQt14vj70h/3tiTg8Q72aBtf/yTABYO3e NFDE7xfgRCR+Udtuf986TT2C7fKt/zY9/4ZuMHyD7x/xVBwOE90mvSSQnGRsujCcSt+k d3Zw== X-Gm-Message-State: AOJu0YwZCcD5NCom+4k7ZRBgp//zZxRIvH5WTQ/emxISv0gujCePLPed W5CRpcQrtdt3Ms/MNWzYmsldqO3r33s402VJ4MXIeWLiT9eQjY5k/zDh0BWJDDKjrcbPRWWCcc7 2VD4R X-Gm-Gg: ASbGnct2Wn8n5L6Jf2XITzUdZM4XMBcEH75lyhAn+wdBd4DCF/CpMYtSlPrHWvuEP8b 460Ouyjr/C4F3QkTU+tJslhZ16L6FdSnnMspXiFHoqmFzE0BXHT/uDruoXWic3ltCRNzf1x+HjI so0ctdd5cuVsRUUhdzeNeeERNQakV3XKb61JJyc+yRodbrZH8nglyVIwqda1xqeNpX+M76Ll7cn GJfTxO8a24DBjXfFhYN4LtCohXwR2yumm90iRm1KTuco+++D6gVVjlY2VHlS253qg9IHylQ8Y1O 4fd0dfxxUvkqhCyPnTg1DiNsy8wlkHOle3COJGGqxrqXIPE83MYig6r2WM5aXPIymrUgb6KdgdM YiJ9BahELCj8o4Hs5x+eEH0+ofxb2uqISltf6qs5AC94o8XQhhEvIY5i/mdzYMM2bSc2fV7P1Os Ck3P9VEN7n3FI4xQA4QmgY X-Google-Smtp-Source: AGHT+IFJzDtcQ+pettaj7X1WjMGuF+CataC0LXZ3wWyG3zpvbK0AJMBtTAFmX9i2NgegI8Y49mFnWA== X-Received: by 2002:a17:902:e891:b0:237:d25b:8f07 with SMTP id d9443c01a7336-23fb30f3711mr115297705ad.44.1753603379095; Sun, 27 Jul 2025 01:02:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 01/82] target/arm: Add prot_check parameter to pmsav8_mpu_lookup Date: Sat, 26 Jul 2025 22:01:33 -1000 Message-ID: <20250727080254.83840-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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: 1753603462386116600 Content-Type: text/plain; charset="utf-8" Separate the access_type from the protection check. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753604184; cv=none; d=zohomail.com; s=zohoarc; b=HJKG0uqYGAJOxwEvhniSaOt0hs3IcOuWh/KojJ2WpDZpT3ihzwPvPEMMBUeefjC/Tyf8XSUGOjylBpBNF4wxJ0xh4Z1SiNEwkFEiFiRzOM6GeLJFjmOTUY1U+/NoIdmYjAkA8nyXRRvXzzCxmNPSLdyv3EnEGofriEbXLZa8vpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604184; 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=ytRuA3L88Bv4lWdDsxQUFk0uzi+wgTB6xmr4FnWYbaQ=; b=EgqOELIUeYNTCUqOtKu+dH23BriW0GJ5JEPHwgJtuIknrMeTERJrMQootcvkXDg7Tj1TR129skbLKg1wJoDsacdCfyl6lRwgR1RHtKFYg6qPYVYfcRzo4Xegpxjh+0RTq0WQifJohlcO6u4ghG8/zjKxE4vbXUgOn/IES9XmZnU= 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 1753604184048550.1576549175757; Sun, 27 Jul 2025 01:16:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLd-00052n-AG; Sun, 27 Jul 2025 04:03: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 1ufwLY-0004lw-Kj for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:04 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLV-000400-RO for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:04 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-23ffdea3575so2210755ad.2 for ; Sun, 27 Jul 2025 01:03:01 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603380; x=1754208180; 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=ytRuA3L88Bv4lWdDsxQUFk0uzi+wgTB6xmr4FnWYbaQ=; b=OhEs7GVykrmOYpvV55+GxpJwA5B7sjGkV+CffwL5+mujhPoWtmVD1zh37Ft8nseq47 l3a/T68mfECoABDHlDbhl1er5+X/+t0mh3s8G1iUSP007rUR2aoeWa25Xtm+HfJb1j+/ yS3ix+u/w5gDG0m3MRO8ba2HnSR6gGwugx/uTn+cgXJknvSiN4XGFVaYKv13kDpWqfS7 DO30CF142bDGd2P++Pbctss2qXb84CpeKFLzPzLHE5MhvPJFtA5plY92Ed3/lxx4QjoA xtt7Pd9Crd/dEU/2T3ecvSQrlvAo7/Jy3Ca4uREJ0zWQwyaCIsoTNJ4Ra+gsN8T6scVc LAGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603380; x=1754208180; 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=ytRuA3L88Bv4lWdDsxQUFk0uzi+wgTB6xmr4FnWYbaQ=; b=iJda7J4IJV/Tsrcp3pV0ZoYZwZ6fFJ1hi9KIZKoZhEVCj0l+WTSHQJJYMBskR/+gsz B9FKCbKZwSSkK+Iob5OInHbJLcZXD6jI0Blat6lJBWNXxpy03QRXYVUmlLlRYt7FIeV3 M/riz/QEcwRU26mufJT0yhxCs7W3JhCPrq8cEuZTYUP5ccQLaVCrDobaaJilXrF2nWr9 N2RWKhNx/d5kwKsCPTOb50nMRGB/LTlovfccnXNAUGjnsyi10rW2ywWvcMZMw4MCfCVz cq05ttTJb/2JMyuLjBRanqnOGc9Gy4BonTVA7PlTNUIGIJL/gUO3Apkw8IlMfY/0vRGa oKcA== X-Gm-Message-State: AOJu0YwtzpOObF6Em0Y1Wnw3XJ3mrEmBBZFV3dcUkycr5lnTBI9GTTGK FMN+Yfe6EFUNPg8rQmtJJyitfrpaAZBPageF7i2h0SuilttufscozesSL03bOlHLQ075lbdeHF5 fiL5t X-Gm-Gg: ASbGncvPVma6ajFiyjAS8dxC2aIgZUvOK77b6nCiTMHX5iMDY/JAlh2UZcGwFBjZyMu fNJBDG5wgedZjuTxe7yCvKkqpJSmK0K0GWQuknDz3JqTq75XgBozrSi+UC66OeO9xkLZ6VZDgYQ EuRK44WzvJIEZvLNK1Iahu9/708QKoPEGfKVfCFJR67VtsXoziJ7scvm4a7kb7CUdKbrgUdthrW 3I7X/wBFphpK/PYLoT4I9IHMlBmPPrc0xVLNlX9RjMf/Ct2V9ZFJY7qSTgAAYrGHS3NpHdXvdlX /+a82IjmoAXxgJZa7SvvZzPoLcQK91xecChrU4CN5ETayBbXnAbtw+s8WwgLCQzwGZxcPq6/Ukd DjKKJnag2vAxzAyJdEyy1sFdVRHNKmVl8FFmrCwc/vxlPEKBetCoFc9Wnhd0HL5H+9DoCzfQhCF QAHk3ag7dGrA== X-Google-Smtp-Source: AGHT+IHlk4NM/IkaSqqZei2Yo4X6NV4bCNrnxKGNP/UHAifw/peVYY7O86RQzHj16pbaqmKL+7ulIw== X-Received: by 2002:a17:902:da48:b0:237:ec18:ead7 with SMTP id d9443c01a7336-23fb31252c5mr138196085ad.24.1753603380329; Sun, 27 Jul 2025 01:03:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 02/82] target/arm: Add in_prot_check to S1Translate Date: Sat, 26 Jul 2025 22:01:34 -1000 Message-ID: <20250727080254.83840-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: 1753604185795116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603556; cv=none; d=zohomail.com; s=zohoarc; b=NlsZnFbUQKQHl3xZUC6nUUWtKWfcCOa0d80jV8p6qdC1tLdPJ5JAzW6F7PA8vR6m85HozxA7dCG+l83TBmEUfxMkqkVAiZU57lMP2ux1TEQuXcVQrD/5+wFtyHxdNQwr+QZrGaf+d96jNMXKw3SLKoKj4Me3zLlO7zkawpg3Wyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603556; 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=KbpMjeNAOgpQVH9iBoeuKkwL+dC1QrhKT8NKphlDlP4=; b=a/Gi8yHsQZQWHg7TGz7UxTL8+IaqlstgZkMtUnZrHU6MFC6N/CZ2V0Bpa44J5wlzuwHbJwi41I5WncYMXu9KR5KMkQq+m5JUfYhMwphJnCbDn5XOgKrPK6J8qsvGMOnmS8UX/kIedRV7sK23/gnlHEyomw7g3yTZ+PbTIYVCA4Y= 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 1753603556433164.74255170825336; Sun, 27 Jul 2025 01:05:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLv-0005Np-NI; Sun, 27 Jul 2025 04:03:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwLY-0004mM-MC for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:04 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLW-00040m-Ts for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:04 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2363616a1a6so27448365ad.3 for ; Sun, 27 Jul 2025 01:03:02 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603381; x=1754208181; 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=KbpMjeNAOgpQVH9iBoeuKkwL+dC1QrhKT8NKphlDlP4=; b=GJJmfbdxILLlEF2zVNIvKamnfckpXwwB4shyKFpDertlV7rst3835X/mZzDWNjUbRA fDvd0ZMGY1ePlaRIxLRg/8JfvusDVRBH+aZBaosAvoEz1KcQM9/pSIwZm2yxC1bwtOcR 6gBEceKK+vxUtYvnBfeFdxyatYJDeZMKVVcyx3R+eRxFjd5F2qFrcuUGBJsIt6sqrdxY 6wv97MEWwsSamFOTkjKw+D9/FRP7vWSFgXXLuEIvlkwg7TSzKFPTH4tk7fd07zTXHcG4 D2zrOoGPZ1Ne9SXHlh9xHw5Va4J/lWzHWza1ufYIm0dYLmsGFbw943sct80kdK5sp/D4 9Otg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603381; x=1754208181; 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=KbpMjeNAOgpQVH9iBoeuKkwL+dC1QrhKT8NKphlDlP4=; b=DtDTfM58563IhgZrgKmLMxG3Fb8tqsx1w+pus52Ksyh8HUo2bfBRmN2xsoiTxuP5+s 9nZ2jJAMU7/65H+4U9G6h6LdWpi5xpx/y9X6MtpG54Tfp9BTTSLSlhNszSLZK1I73KUa l+atIOAXJ9LF9AS+3Sbd25JASswdULDNmiHMER2jWSDBY0ntrwXsvVcA9OHygQ3aENla LUuvFRPBSRyYPubXQhlpwlnTN05OTQkg0WysmgVXHlgqAGOWxL/dHvkYQcbMQ0TYRVVB 0tozKh4Y7IbRSJvCxEkZtWkUyJf4EYNPW4kiaHwasZlEoI6CM/wF/MirMHRP0F6dpvZ2 wsig== X-Gm-Message-State: AOJu0YxHJvXWwebJjT76StBZmNRhCI0SKwMuK8nR+bFgbyGmfIkB2AfR aWLObfgpFpSLJGwz+p9zTq1g0rdJCtjzh9YnRERWou/8UPJUpyARbzvE5la/nZMIGAzIWqZUkF2 BhR0N X-Gm-Gg: ASbGncs2Yr7W64osa30OK22yImEOOeRMXv90cF0oEnMuhir1/35OiS8tPNc/CGjRCgY oxscaqbnxWr/wOWEhGcK3pvlWeTRx3pS28F9ZcRBWee3c3rg+IwNgJ+B+QYezG2DgS17V8/tbif HPfsmSx2Ist5WJ0FUBqHh5Z0vONzeOyydYiMvcA/y6i6KQB3Co2khTjpaeM4FHjk5RtlinsEehU 8QytqLDDp+BDX2VPA83XpeOgNRuGTP01mS82uslya6POkhMpag7XUTtKZ/g/KY82xrOGxy0DZzz KmsWTfsked777jaeq9xCf2M77fN37oI4ef74beP21kelZKqw+aBnAlfjPCHptT6WZMTVyzqQVJN 4frARJPeA9y9AwoL9eWL6QzR0KRA0pTA707n7peARlcGDwjIxdcCP9MKS2agkPReRexkmsRja0q /PlYhHh2Lkdw== X-Google-Smtp-Source: AGHT+IHy12h5qkeycTEEJLcoisd4bZvo7IHvdtEy7VEqPK40yZPem+FDlhXPWwrKV/krk2O51UMOZA== X-Received: by 2002:a17:902:d503:b0:234:d679:72f7 with SMTP id d9443c01a7336-23fb30998c2mr111630205ad.23.1753603381522; Sun, 27 Jul 2025 01:03:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 03/82] target/arm: Skip permission check from arm_cpu_get_phys_page_attrs_debug Date: Sat, 26 Jul 2025 22:01:35 -1000 Message-ID: <20250727080254.83840-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1753603557039116600 Content-Type: text/plain; charset="utf-8" Do not require read permission when translating addresses for debugging purposes. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753604036; cv=none; d=zohomail.com; s=zohoarc; b=KY41BiF0tzcBaUnlZxafr4JPTlqST9t2SbZrV7wbragfmkKftXmrIZBj/WEOhc92HnR0mI7dxEmtmi7on2/7kwUpBsHeCcwSm8PTGbNafN/5SSnFe69zxhU8asHks4sCoUfOIz1NygsFaLlV7OVhrhDqV6vRdXpB3mVKWCPkFb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604036; 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=NBl8wbDOpfkOgn+Qj5iZnDh6LWcdNiRislLxlLvgUus=; b=ctzeB18hOlMiQEVhp9havAHe0oFcRFF1q0ZqA8ie8AIhbq+mdcgIQgTISx7x76hcz9hoyAh34gSqIYlcPEPwvHrgNAoUUt6BBscd62EvtjVkSXw2M6aYM5WYMFdUGwPWoEN2KgFxJEMT+ixIU57XatY11liOe1a4DlBeJlGjLPo= 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 1753604036214577.6947751637206; Sun, 27 Jul 2025 01:13:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLd-000542-Ah; Sun, 27 Jul 2025 04:03: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 1ufwLa-0004qC-A3 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:06 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLY-00041F-5w for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:05 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-24003ed822cso1914845ad.1 for ; Sun, 27 Jul 2025 01:03:03 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603383; x=1754208183; 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=NBl8wbDOpfkOgn+Qj5iZnDh6LWcdNiRislLxlLvgUus=; b=Qq87pOknrhZrJ9Wk07bAqagbbwEBi9ZBt/G2JVThL6wOrnqvCUWdf4WtGu0zjUa0qY c7d7i0C0cGe3XeVTS8J3rUbC3Q5Z8Hgp4MdIXEfthmIHOyM/Zu/Pcds5j+I/9zuJU7Og hR2K8RTtVV94SGho6UJeyr5X4bfM8fo1khM9FKWPcua+xOuAo0Xy8sA7EQ+Yy6Op+8Pi +BTmsk2AdJ23LQqGBOYrwugICwdAZba8Es0mkfbVIO6C+fiOc4C0uCIO/b2U7T0aBM2X /veav2i3uZcYR8frXHRtNGx6TWwvhJY4RVPX9qM8N4vuQ5ZBR0QEpNIdcmomvzggG8wZ xkVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603383; x=1754208183; 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=NBl8wbDOpfkOgn+Qj5iZnDh6LWcdNiRislLxlLvgUus=; b=FkOUz6qby9hWGqoZjDIyHho/9Tx5avkgltXZnbWF7xXJZ9KJrgN3zcvMGhZ9teOEqo ehM6kJUYEvadT0hDbHur+awHACYnq2vb+W1GyYvmkv08XY67mKqu62/iaWWthNHPf9fG 8F9d350yTBRxQsk7QCdFE3UTNurWS3L96XFY3DMMtVhs/Sl2Rdjz/jAB943fcupse6KD swRYyxcF+ZD3eVcanWgC7BLBnyJKJi/jLQIeSXWZV8bCQf0p+L8qCr6S4nsDk5qo+Uv7 +9EaXF8F14yGzlKGpuZBpy3bP2fT5uBJUM0Sk3bPfLjNSWOH2mBGVHAo/fqsRnmGK0gu Jo8Q== X-Gm-Message-State: AOJu0YyAa1vABOvQ+Mzo74z9U6LfYlYyAc2POaLNPH3jpzWYNtFk/IaB PDZv0V41ICpmSa5xBviepyXghTdeY4/Hj3bOlukamWosJXQOxitigo55l7AwXt+ctd1l6lDf7Sw /9H2G X-Gm-Gg: ASbGncubewoRZQhj6lgxMP+fAPr5Yec9giaA2QsFLiNVY0pbLT8OgZw08VE4EsxREMe p/svTWIL2FJfodU3WfW7zSp+bHqLtnwVoGAvcaFGZnbbWGqSg2IJ6MPBmXP7nvrGKsnSKraW0Xe hpnE+EB0TRiOxzo99sbJ+ZsUGnmB8ysaW2y/8GwsbWFwUVDN6M3oZzbSGtrVFqPSZtpOufV4tBF Sf1GV9xNL1I9OUakcRn+kjrft9b5Pz1qz2ZMyUJqDEbmce22zXggXN4GeKIXpV8uq60iqUUXuFB NDCaC/F+Ni6uLkRPIdrI5bxxYjBY4llXlfO5P/iMJsRj4azgM37CTU8b+b+yoBELkciyqcsQQsw iSZSQcB50burtWqsHQWf7tI1S96815NWmxbDWNEGuGCjlYnh5Dg882RsCkYyqP3e1NNbkXYcLiW nEe7dgAUfTYA== X-Google-Smtp-Source: AGHT+IEgJ6ZyBs2S1E41d1MudyquAGu/lrvMtcFIScCW1Hdi9hk3xoB5Tnt6lm7KgyG4jYDxEvg9/A== X-Received: by 2002:a17:902:c7ca:b0:23f:f96f:9dbe with SMTP id d9443c01a7336-23ff96f9fecmr27379525ad.24.1753603382640; Sun, 27 Jul 2025 01:03:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 04/82] target/arm: Introduce get_phys_addr_for_at Date: Sat, 26 Jul 2025 22:01:36 -1000 Message-ID: <20250727080254.83840-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: 1753604038583116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603500; cv=none; d=zohomail.com; s=zohoarc; b=Ib3rkdYmdOnjGZsGmFUtYazFSy10tSDDU8DOFBjV0bx1yJnNYlAeZk/coKthPRjjnwixnvWTqI1OjC+pASTq8E3n/r8SL8x+XKI9KE3q+noi3BK2hgI8swcYR7DY5OClCwv72w1V/XxIpBTCjmaKObZkaYYJmnoZgME24xkWd54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603500; 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=pCFS6cqTwlg3fFOqku117fnhPK1D7OaRJaQ+ElcEeuA=; b=H/PNrKxKOQvASHdGktFZJ3ca+EP75BNdmsG+6zbEfN5zaTI+lzw/c5Cvssv/0KYtHlt2uRlHFAsWyy5FLzN/HlQQZQxM26jeInWKmHwlglnvgb2uTnRrc2WBN3zrf56LTMlwrF3SD7zVHtGcuZkQxOxrge9D0wS2jPD14lrVV9c= 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 1753603500990619.1442141111684; Sun, 27 Jul 2025 01:05:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLo-0005Eo-9O; Sun, 27 Jul 2025 04:03: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 1ufwLb-0004tE-Ke for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:07 -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 1ufwLa-00041Y-21 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:07 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2349f096605so41184795ad.3 for ; Sun, 27 Jul 2025 01:03:04 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603384; x=1754208184; 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=pCFS6cqTwlg3fFOqku117fnhPK1D7OaRJaQ+ElcEeuA=; b=ZEhiUVZoKtL1akne3G4OzYuxsapMBxGn6vdVtlBCoZL6wWh2pqk6nMe+Z7KvMHkX9j 4ysKpND87+D7d/wo4rkDJ0v2gK1X9m1f4JqO0sVL8mvICyQ9dEvOCFrAuLoavh/69whg 2rH2uOQrnYKQXLxF0DmeM5FhAB596aUxXSsar5gNDE/6eaazTYQLyUdgbKCCkjeeks3L g4sbQxfvwMXj9JqcQbvQySoFZB5KsUAxafD97RRbyt6nfOPo2w6g+iHNp+GF2iRTvhhZ cZK0bW+A+bkRCXRggXx6y3jiiMxnp5GvBzve6baqY8MRNKtfwT5WujZFgPhtoO3WYi5+ +uOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603384; x=1754208184; 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=pCFS6cqTwlg3fFOqku117fnhPK1D7OaRJaQ+ElcEeuA=; b=pE8HGooiaqeCCP0aVOrD6Am1OMr4J3cMiS1PF5M2xvGtpReLIJi3L4rWn1vhi99XLI iqmli4S3Z4Jz0q0SQo9obaWGLYiDfQdGYjBR9eWLznI2pbb848aGCT9U2xM9qUtA4Wsz zt3iSdn3DpsN3dj3cuL6GmWpiNjxm6U5u2q4a+ckLEprMQSGfUdiIyb43zclsHCd2wbH ii+YhUgrC77IKTLCvEH5zju8XliD5V52covgcbcWmCbM/Su4KxFSQDpYw7xWuyiMBCpa i4Qs9Gq2+u1eCqja6wbdbr0P7IO2wHt6OktQeU9h0mSUCx4/N19Euk3kgc7/CeIBNyLP hyWg== X-Gm-Message-State: AOJu0YzL4kia+pjGE415g9VcdQpAvfHQN/l7piGWJERuHF21DqJKKhrd OdBOpNaqjfClDLQQE3+xPoOLq2gXoJ3q7+4grdq0EHAUMjsJ+dTW3VhVptGMIGODwOCr2jJxt2J YiWoW X-Gm-Gg: ASbGncvcWSQ1vrASeptbkcfSFa1ztJV0X/8Fh/a1V1Mc5K/VJp88v8hy4QupcxHdrdv +3EcAlqD97VuQiNNmXlMuxEQi241r99yH6PtbdWbezQp80g44rvYzAXxXSn35UME0gjfpaWo3DW SManUXLD91fIBNh9We6S1qYq971DyNPuB51UwQvoErNz2XZwSE0fkYlcDui+rnAlNgOc6yLVIpo P5sCT03N4XaXPbCQraEeLDwjsCvgXziDxV4wzeDTW/IcHX5OOrmsJBC7W4/oRSnm4hEUbca5YbA s/xxZvQAoAVtuUTzrhiDiriA80JAnX92PjYmjth1ST+Vmcox40cCJwp0ThxfD1VkOoi9jhHfdEQ 5bKjJC6Wr3rljakCNgR+JOD2rHj8UTDuYJBDD+KPbwYvcdOb1pjYy/EnKRb0KEas6HNoDCFtqRL lIkBbhUP7h2GUP55shLIIAqUvgdMoXEDQ= X-Google-Smtp-Source: AGHT+IE15DlIHJfYVYyb0xNhUbYGyOzdfFbS408/FXwVkk2N9tdMCZZroYOusQdeLTgIkLfBzQKYBA== X-Received: by 2002:a17:902:ef07:b0:235:cb94:1399 with SMTP id d9443c01a7336-23fb309bfe3mr107940975ad.6.1753603383803; Sun, 27 Jul 2025 01:03:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 05/82] target/arm: Skip AF and DB updates for AccessType_AT Date: Sat, 26 Jul 2025 22:01:37 -1000 Message-ID: <20250727080254.83840-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603502538116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603475; cv=none; d=zohomail.com; s=zohoarc; b=EIZX+UE+dY3edgSB25RTIVw1mssuoEYzQMSpTiEcIuVkOejdQnEgRgGZU3vQe7mSOhNgOVLYHn4+7qogU+SGREpJctMqQ1q9DCfP976PAGV9Lunu+nhlZNcB360IOCsWj4TAtP8qRvEXkHfcFE9q48N3ICeYVMo8THpb41vLDKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603475; 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=Vhk3SKdWV5kBlg0P0w9+ddrIGjowa1smEMmdzbTEdqI=; b=bEpY7znJNyalqcWLqe20drhWbVJO0WTDYTLvOSl7zs57TqOEX6gRTMQgimtdglg5068i340iBAnUoHf1537zGQykXzkhhsh6t5Ch/K2T/ocrteqfWeS+YqbJ4Tev3Pand49nj9wUoW0UP/Zi6k42xLPGpHcAdP0ybKhDm1wg7q8= 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 1753603475667585.3742783397394; Sun, 27 Jul 2025 01:04:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLv-0005O6-Nx; Sun, 27 Jul 2025 04:03:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwLc-00053l-TV for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:09 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLa-000425-Cc for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:08 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-23fd04416f3so5932055ad.0 for ; Sun, 27 Jul 2025 01:03:06 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603385; x=1754208185; 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=Vhk3SKdWV5kBlg0P0w9+ddrIGjowa1smEMmdzbTEdqI=; b=ZyelX6RMi+Z7k6s/pzMI4m0XO/5ez/WSiHBhhqVb/XmdHgFoLyPtBwKGhHEqzZaCL4 QWCAqokm9aVyoCc4YKPIl8UNTxjjDkE58U/mVMZayg5gGSMH0ECqys+q6krUaEmlxbcE 2Db6FHb+UV0HLVsZZe5ratpL6JtFHxWRDtQbbErCd6LgBuoa8eNMyv+nfOHzaYZktb43 RA8hsIz8wZtiIu7ImoiScevtIKIjbnp/3YJoKy0WD+O2BS74Na+p+t26SSaHLwIrOGU4 Bihc6OkGUDyfDDGDW6p+PnixSE8Nur/iNRfgag8VoLaQt7a4JU0gJzrP9sAoDJ+INA+c srVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603385; x=1754208185; 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=Vhk3SKdWV5kBlg0P0w9+ddrIGjowa1smEMmdzbTEdqI=; b=IsYhXdhKEaRlMElc6zn+XicIH7/13LdFfEEwNc4cl7Zo4l94iGE8bPh/x20aJ1nvrN sdHe6lQMDaQ74oDzMYOCOTGHpSqA2pUE5k3kxoGACJu9ik2E/XOIHpiA8mRNl1T/EzPA rElITuD4Dc61EtoXlbvkhwHRs0QjwpC/W1rYMtByewDQQswYrBKlv4Jv+86SqQ6t4CoI +s1Tvv2n1vgUtsTvhvHimdHBWo6qlV0BPiJucFO+77QMnH7MoQhnkNBGhRLJzS+5Y9hL snZt8TVuW108ySKBFS1MEsbNI6Cq6vNXL938w8whx+kKOs0s7Leums5iSCOW8xjldkvX y+Gg== X-Gm-Message-State: AOJu0YxVDoY6iKCIedveqZ6NxYDIOMNk1I3fZtpvszOw69D6pUYrRByh PUS+TjnLrfhYww7pDb5dbt15WSJgLL8l2g7vLNyZT98Z9897Vxah5+wMHMpf2LAhJ7KAK9lyU6Y L7CpY X-Gm-Gg: ASbGncuwtImdEdP67Ms7XjQnsihO/RaaAepq9ydQQTfXc3wjsG7o3SHdMnmE9lhJYJI FafmZUHifkCj5nNeGORw3aSQgYaBA3f/z1I4rcuoyGuK28OhtmkW74ieM5DXNnezqCpDQX+/PXb 50MAr5HIbwTyCrqdTHvsJaLqUFUA2Wf2S2umFd70qS60JFOzTWhq3jK6gjnt7CnEAdDfezQQr/w t2c4QGVysGEUP9ke8CBxFwuPtQ1GELbz3HUrHeXEAfm9eXmVvIhoDXdjjscLNqytibOvbcNeZ+c FkMbyMNHjmN5POCw2y6hZ+RZ1tTJyO9oMp+OToy1D/sZMEiRu5ZzQ7pjRiq70rmk2wL+zg12gWw JWTTvVzUZ0PnfcoOcrBgRI5k5aSxuBS1hDckrKpr+RVm0kYjMYhKGIDoalk+32NP3KBq+3+e6j4 8z9T65Ie5Npg== X-Google-Smtp-Source: AGHT+IEW/dI9vmkRP6/O8G4nox8m73DPhhLJw/wlK7STLwx8XdBXNfPiJNtEGDDSSXawLdQxFStjuw== X-Received: by 2002:a17:902:d486:b0:232:59b:5923 with SMTP id d9443c01a7336-23fb2bc7d33mr125700505ad.23.1753603385066; Sun, 27 Jul 2025 01:03:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 06/82] target/arm: Add prot_check parameter to do_ats_write Date: Sat, 26 Jul 2025 22:01:38 -1000 Message-ID: <20250727080254.83840-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1753603476363116600 Content-Type: text/plain; charset="utf-8" Separate protection check from access type, in preparation for skipping the protection check altogether. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603557; cv=none; d=zohomail.com; s=zohoarc; b=fIwGB+2vkum4qMNFet3CYQEpDY0c3NQMMhnolqJoz9btpDO3wunnaSiW3AtT1Q3zXayY1jalTAzJ1iG7brF/KJYXYT5iLyG/C8EVpclJStS3Oe3TBw2Y3K00P9D+rJVjTU+mL3KPzEAFcsZV8kJrrszamb+9vvaXGHD3tCOO974= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603557; 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=8MiZSYeSsFc7E9O+r65QuNCOOnlvBtRW+4SiNaYQadU=; b=RIehyM24nHYfeLBSa/nApPjLn8YnKEH1yRRmjy0uM9glugN0fMVL2/zDDqkTCZsWmk9Ft/yW6O9RKNn9D5nG0lZAa8MV8z8bT8ccoRr8PS30siObEOsSBQaGibkOlMrAKqijpCFdCJe4GX0PE2DvVd7DoGnhv4gom63LEnc/wYo= 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 1753603557944765.7342810202447; Sun, 27 Jul 2025 01:05:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwLx-0005qs-Vi; Sun, 27 Jul 2025 04:03: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 1ufwLd-00055j-Ei for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:09 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLb-00042S-Q0 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:09 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-23fe2be6061so4506045ad.0 for ; Sun, 27 Jul 2025 01:03:07 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603386; x=1754208186; 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=8MiZSYeSsFc7E9O+r65QuNCOOnlvBtRW+4SiNaYQadU=; b=KQyA2TAoBD8n/hNGoC6cBU5dK10t9HKHqr1eTE6oJ5xowbhEKp+5F0xtdAIJGI+23E smRUbbJWdKUJeokSepfQ6Zews+mkmURrj6bUEEkFHm3h9pCiFRPvpG+JXNZRHGn2SgUo SVHVuijMItOtm7T94jxqrat6PfOVJkfBbNKmXMEmWhrRkDlr+R+tPN89Zb6SbT6qbEtv Z+86k71Wqnt4T7MJ7u6oYo9xfQSovgPipbixC+eNxmMcSKWVtFv6nYsSKG5WCEeD9xde HDddAU+RM5G4e0raAZVoAxE5fycKEAO57H6Sg7QaertSrh22Lxjs/zT0L5kKzQ4UJ3e+ pKkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603386; x=1754208186; 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=8MiZSYeSsFc7E9O+r65QuNCOOnlvBtRW+4SiNaYQadU=; b=RSBn1mPQQvMfo87RujGbtpgaiVGdEL2ytPyiRG+bm8+hqI97DXLAfLKMtcCmWXvv97 3RYYLseC1wJQQeaDVZKmcodJHfEMW1sOMtfiFRNsJX0dRQKxEgehPwdrad09vacgM3GL c45If0ZgeFLFmYYslHPRmBjKVE/OCf/Xg8VktUjhKADMErIIzA5zA02wGCCrhmOqAT9y fZwT+Zpw5QM2kn49oYP6186ro0cVb6UyNI4WFzR+1mkUAxO6t62DPA3mtx0ASeHFItX0 ti9HLjIYpMEhRFmuS2tspbYs3v6MLVUOzkT3P13YtntmAmCYVqZpTeUPz8tnWPhAYVNN zJeA== X-Gm-Message-State: AOJu0Yw7ptYTWqt9J3XaSEuE9/6zbJYfZnXZBWsrdvY7s3yeJGjvvepf CXQ+6nZ9cH8k4RTubVJY0cw264OqB+rbICiUvSOF5RvlB0W7tn68bFW65lnKUioW91y1JiQD9Pq JeKQ0 X-Gm-Gg: ASbGncsj5fMa9GjQXvv+9yg2YDRdKUUzb6VCslL8MKE9nvRB0UaWeumKXlqKXx0JyHa LYv39pbr9iThyD7JKFn55OEy1C/v+aIE6A7E+z+7y4/P4aLTQlp1UGL9FovYou4tzlMFxWwN4g7 rMQbfGNNqMDcVIl3+DtaSysJIR/ll7Sitgri2evce67GU8einZ+DlO6mPwHkGO+4pn/iG5EwOQq UHg+P7U3N4DmKYv/Y0s3utv4Mey5IO9wNPaWYA00A0bt9lQ8pFhk83/0fbLyIpU/oiAvuYPUW5I C0in9olBIRvKawmP+fq4d/hh4wV7o+3uI8tnQBqHBh2Yhkx1vziXPy5/lJtSAjpa3EgFB3ierZk 1Quna1XPT3vArKcu0xEBP/E1/uTjfQotJOxxbBm4kTIkDplRTeAKyZt5DkXaJvaXzoKthvBwIQK wyS3U8+Iw7n94KnvhFP8V8 X-Google-Smtp-Source: AGHT+IGCBfsvDo+Ox/F9r1qUIPnELctXG8FwQaMQtr8h36eOuqUep7Cl1gVafQGxVyTltvkhmMQgAg== X-Received: by 2002:a17:902:cccd:b0:23f:75d1:3691 with SMTP id d9443c01a7336-23fb2b5c028mr105140895ad.15.1753603386224; Sun, 27 Jul 2025 01:03:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 07/82] target/arm: Fill in HFG[RWI]TR_EL2 bits for Arm v9.5 Date: Sat, 26 Jul 2025 22:01:39 -1000 Message-ID: <20250727080254.83840-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1753603559049116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603922; cv=none; d=zohomail.com; s=zohoarc; b=ZHx9Iv52S0+EfVOu8n65NgSxT9ViSsPqwAoj9a8TGEw2N9LF2CAnInKr70oWl+LcgQuanrPbBfvSbxsiHXGD5Rvt5N4Lw1Jn+UNJaRnX12uhKSikgY09Ej4ZMS/Jf+zRUACwAIKoaT11peFOwFNpu3Mtj4sHlilH1zHSV+CLUck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603922; 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=8A2p50fg2lrocPlTL2vHTdYXWv0sBXWf3nT/JIz8EKA=; b=blVDdrCQLj7K3L6Qy1Lvyc/lzRHuvUPjoLJhTRrXQdKN0DWFlLSG87JHb5/62/TlhZp8eE6EWEmeeyShq7xSj+HFTGS6QzqHL37V3pMPSd6HvCufttTmXseaM1qVo7LsMphynVvhIV+nmmziLCQ5hRVD/mAeNIBNkZrTcL2+vvc= 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 1753603922903350.07976576707495; Sun, 27 Jul 2025 01:12:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwM3-0006IO-Dj; Sun, 27 Jul 2025 04: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 1ufwLe-0005AI-8Z for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:11 -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 1ufwLc-00042s-Re for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:10 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-23fe2be6061so4506145ad.0 for ; Sun, 27 Jul 2025 01:03:08 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603387; x=1754208187; 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=8A2p50fg2lrocPlTL2vHTdYXWv0sBXWf3nT/JIz8EKA=; b=C87E6EkqCknoLZoMSb/v9s4gIXy2tX1480zD183lDNVHer1rg/H9/LVMCdrVw/TVHw scavmGM+Ha/pLPZ4T0SicJxIxkD2RF+lETqCjAC97cBmBh34CTttRkYQ7dsCqi08eeTq L/gICFChno/HPXgBmDfK/15QidlYlctb6/OHfQD5aMAcz9QzyMm5HIH2MtZ/Av3yGnsH tldHlgYqExOwQrQ/u2QQ+C0R96dS3vR5dyE6aQyRE+aDnII2kfYdCXvXB2qa1IPGco7w dq+JmfThMV6fnIr4HooHzz+GFwcDzE/8TzT2bx/s/Vtqat48N6U28KgZnKo3rk2KEG2a z0xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603387; x=1754208187; 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=8A2p50fg2lrocPlTL2vHTdYXWv0sBXWf3nT/JIz8EKA=; b=tAollbOBZOo9wceJqlok2dFdWACz+nRCXUpV03UkmHmYEY5ugtJUlK1lvY3ytEZ/6i 7RDfjsJQJfV3yibriZF+dhYLfgDGAtGPCjJ+n7GcQ8rn5ahUrhjd7Gu/qiOWDTq7TlOY kKdwOoQd8BjYRu9yg/gxM3naVPXv1/ynV08uMwcU2Y6mIZ7wjy3ndJDyw2SHX8lHvY6E OUfaauFjXsiLUxF0qmZD/LnHaKkGU9nb7KPtRr9PRYel/vSQQQ3dW6JJyomiGmXpZpgn yFLM5sGAjcbuWBSWnoQ08Co5NYav95JDiE0pp9qF2OBkLj94b8W37YZ/2RLCE01wzEpv 7qKw== X-Gm-Message-State: AOJu0YwPHP907R1H6eUYyi6EhI14dJ1/I6haVXPTSRzH2aAlTPvB/S7M myhLT3gISj2wkYl8k6zqx7nheVzFktkudBf5Qf6MYZo0bJaU9DSo7jWgrYyTP/e3C58N3ntiSIA VgTPz X-Gm-Gg: ASbGncvBDbpMiPQ4/yCEIkEmbnl8X5iT+2N+dwI68lCzdGMd4AFHYVVetgvhIPRjldv pkMYLdeamSf4Y3df+QnW63Cnac0cvTm8Fn5fJvztPJdKTcNfxNfqK4pfizNbKLdi5dLw6N3HZ7a 6J/1vD3T1oD+2S3JeLby80iB6HbXKHkUnJGoH2I19bPVh5Nrs8a9QLX8zkOlG+TvQvk15Xu4EQX 7T4i5opxlxmZaj3aR0QfpRioaANBB5J+jQcfpjma59TzmGhuc8rJ7ZycEZtdeUI4LYIgkaqjEug oq8XqtjVthlqR6mWYr/eHg4eou5mopwON0l10cJeHYKpOFMhN/WrLw0JE0FJjO827MZ/hP2zU7L BeITJdi4gUIbeFWUlUuV5J2by7vywZtMaaIbjB8qIPbSOuuBYno6RsXz3ba2Ty4MZnlzsyda6JH uis6/bEOYXmSEHoYFuB0sA X-Google-Smtp-Source: AGHT+IHf3wJsHXONbsv6Uf4y5Yowp0JbTdoHUBtuq5S5db/3aMTJ1/U4pGseHJ2GiebRIvyL4dEnZQ== X-Received: by 2002:a17:902:dacc:b0:231:fd73:f8e5 with SMTP id d9443c01a7336-23fb2cc0818mr114605865ad.24.1753603387243; Sun, 27 Jul 2025 01:03:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 08/82] target/arm: Remove outdated comment for ZCR_EL12 Date: Sat, 26 Jul 2025 22:01:40 -1000 Message-ID: <20250727080254.83840-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753603923650116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603481; cv=none; d=zohomail.com; s=zohoarc; b=C4uCc+rLReZBpXbYRTLUsMLqdvaNYuhFth8QlqCY9kJqBAjcLlVk+t+lsS34M9BRxgSS/p/AHBAK588H22rmQTk4CyeCEsoliUNkbr7vKSe9jJpZp1BbhDHeu4SqKk0i0o/I2xtS7rzBkQqDA47J1fmvIYm5mlw8Xdmi45qmDr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603481; 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=d2EtIwYhWBdunEnHZqFFjPpeIhDqDk+A7MtfcXFRuII=; b=GXb5LjgTXCAOJqBY4CH1UFA2ti8bi9t/PDeMJZ9oplid6174kUF2Yotqii7ISn06Ug9eppYePfmAi1rOzUoNeP+483NY+2+pbillPALcTpLewF8tZM0IZd2l7NiD6WKfFe2N/RyMigQcX7SmymeyevrZY8/wo2TEcSriHFPIGhw= 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 1753603481428989.2572135795642; Sun, 27 Jul 2025 01:04:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwM0-00068e-QE; Sun, 27 Jul 2025 04:03: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 1ufwLf-0005Ac-Iw for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:13 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLd-00043G-Ql for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:11 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-235e1d710d8so45887365ad.1 for ; Sun, 27 Jul 2025 01:03:09 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603388; x=1754208188; 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=d2EtIwYhWBdunEnHZqFFjPpeIhDqDk+A7MtfcXFRuII=; b=YJkYm+N/uMDX+3rtKutoU5HARhpFkPJ2GCgbjS6bf+8IskxN9sew9wz7GE57iJGf06 gYbzTsxmRWYed027Z+X9xSSXBNruGmg9rr0hj711pYEQvtiYczSno/bD8SD4TDwt7+Lt r6jMOSThsbkCxwrpA8J7fQJvV0Au8Y/b6Tg6k40cxGmoClYF5uSFi0KAbaAEVx3uZXHq AFhqHPi8wt9URFzY7OjjRDE6g7m45iErojmiJF4l0ChWL2teE3MKWFqWBLTQY2r7VU/2 Dd68cAKMfJytbKKs48SRPIjYHdpRlMuxqqLR66PHdPTlYooy1sOOsZmjtC8EVTVR5gjp DOhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603388; x=1754208188; 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=d2EtIwYhWBdunEnHZqFFjPpeIhDqDk+A7MtfcXFRuII=; b=NbDay3QAeRKsyljMrHyfilMZJhHBt2f9IdHSiEsAqePW55t8fUCEvlqnol8cnJoyRG h+ePmv/ibZcnoQkLsrTgo+L/nBp5f3iZImpJ2s4mxOTCLgxLisRpsmIHbMKT1ifQdFD+ K9qXqmAHS4G5nI4oQbXg+6rt+EdLK8w5DZdFUjYEvK4AkD1u/NJMY0wUApMH3zaHgnwI 2a/s+SBydAhguTaF+cgJv0W2sfvJj3ltHE3DBimOETC/iNls8InrpoNafxgvZJRESS3Q oAYXVvI6eWLIMpoyFPwK+2r11oQneaaebwlQhPL9AmBeDb0pUCsWCC4DUGaIxUMNCHun btYA== X-Gm-Message-State: AOJu0YyZ2FyI1Y7zuJ9tJlwC+uePaVuIzAJcda/+d8IBj+aCHp4NsluS zF/LZxSXZ+CRhE+k2QkPqvZ0DeHHfSYMvJ/hOYSnQpSTcmiyD1leSv+m2VhMnfr7CWm+jCbPjm5 FihRB X-Gm-Gg: ASbGncuQWStNOTsyNnpVd7Mm9B1k6BAoAQDgSDD9n1SEWiB7FwV5hZxdW5L4cW60vgU Qz74ykxcO4Fdx5b3T4v5LizUwxhFeaDK/MPEZwDZYPS3TZfUAS7yZH5UlulYoTQ1ysCqUX0fli9 t1Gw2ow29DAZrZvvSvCcJUBhc+c50nR62oX+8crObfHA3TYgIUSK8ir5/xU8pcQ4A5wXe2RYwo2 QHk8tzlsBIG/GH3T0mHEzRHYEeRFBhz1t++h2QVDYTZVZBVImyRTBaCMbRhwyq3/dBBm2Yo0TJQ PPuG2/0l5i++hbr9E6tcA3DUx3fosTIQLFOnlsuk23B5FPonH5RE+PnLMeQG8QrkmD/k1ptFFCX 3qTRS4Gvi/pX/4vxMu8c40IpvbKN/xG/Se9rU2gqJDWafUH7eU5El5p/MwaA165eUfF821pdZ8Y Ni7Qca+Z0U6w== X-Google-Smtp-Source: AGHT+IFju1qSSPpmBJkIphAJ8pz0PGLVnKMnDrfHIHaeuL3Xg8w8myeMSf20CntHltCPh75kPEoXSA== X-Received: by 2002:a17:903:3508:b0:23e:277b:b921 with SMTP id d9443c01a7336-23fb3179e0dmr108943045ad.42.1753603388479; Sun, 27 Jul 2025 01:03:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 09/82] target/arm: Implement FEAT_ATS1A Date: Sat, 26 Jul 2025 22:01:41 -1000 Message-ID: <20250727080254.83840-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: 1753603482453116600 Content-Type: text/plain; charset="utf-8" Implement FEAT_ATS1A and enable for -cpu max. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603461; cv=none; d=zohomail.com; s=zohoarc; b=BoBIKE3VPU2KRZ8+x/Sj2IcvzA9B1YCH4a9OJJIpT7Ax+dMJZtYm+pr+wQwBelqMtD2bHG4ZQnqOq53hb4y1jLPMR06+d2FrNXL+9MaiXGXOfKXY49Gm5qhViQ1sHExGZnmDoYQowqqEqMQigFlauE8c16pyETEeaafGDQaj3W4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603461; 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=QMGC5A24KwjwokxNjbljMwweFFMcRjy7ppuyvfWNL3w=; b=PADQEj4C//0Ub2iHLOZ1jvnnfUe8UlHSSj2xoj8XUVbsHL/LGg36wZ+jW2B1zr86dksba3T+uWEZ79ZWchzi5GBLEOD5wACZJ59X4+xe8u2t8d9duElGoiKWSJR0OsMa20Rv/3utXxhk42S1Ga8fujYrKLfEMX2ZIJgQPm0dB6Y= 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 1753603461937432.8723658334279; Sun, 27 Jul 2025 01:04:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMI-0006ew-RT; Sun, 27 Jul 2025 04:03: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 1ufwLg-0005At-BC for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:13 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLe-00043j-RD for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:12 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2401b855635so325905ad.2 for ; Sun, 27 Jul 2025 01:03:10 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603389; x=1754208189; 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=QMGC5A24KwjwokxNjbljMwweFFMcRjy7ppuyvfWNL3w=; b=TBe6yjk3WYPmjO8whI/gxXWh0DJ/pZDhycJK9T9o/9lkgayLPhWhfcRW4RJQx8M8JC Qp+6jUbl5cfxdicYnrL/6SQIlqTLtwPLn0al1reH0C5I2SxJASaOcpRyj8RNIkNw43a8 7vKoqxMKhAVytIZSiYRCGoPk4UdnVVcVxOUz8TtIJqddxL6M8ZcNiSWu8FlR5CxiK4xU rUaQXUQr7Tv1GkoFVS270fyUtxTXXjLpWA0lRxCDczs+kdr195MV+hy3hsGHeLb5qDKU 9grormeD/ZVSvonVHv0ZiYOZZ5J04x+/WoDZf8rndHwR3N51eMKWOqN4asNnGc7g6DdH 4XHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603389; x=1754208189; 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=QMGC5A24KwjwokxNjbljMwweFFMcRjy7ppuyvfWNL3w=; b=uwUIZCzXzwC52LqiwP36tNb2sKafiOQ7Yv2ytX2geLUsk44L3FwsTrZQ7Dx8f8lpRt 9LOMfsLncUSVLdCCMaZGCOILyadbD1zJPvz4mLQ+18P4jFay0QlmmyYPmETBuc5d3vyc 3Z2W8i6VL+88Psg9JhZV/A7orzqK/Qo/Xrex+yPs5xsEdZC3B6K2rJQMk8oLoY7nqA2F ani49IdSWeihGvhP3wt2F53qs9HEA7+3YFu/QwOwvy/BBWQInSpfxEIFV4/X+OGTfMLz H/EUmXwuf6zVZ2kCWb+NEOxjyx2uoFuU+7G/zXK1EFSJvT30lnhgCMXzKqvENlm3JF4B W+tg== X-Gm-Message-State: AOJu0Yxqv80bLxg0RI8YqckciyB9gswb7ZPzLvy8TGXIVEe4suelsgMr stn3PQpnFt9jbi6kBytsWVgYXQv5UziEEpQzGsVo6j4S6k/BJrGRJpGxo3SG7ZI1hJRUi7IApCI s3KW0 X-Gm-Gg: ASbGnctAhTP03z6fki7DUM15UNqVjzRzIH6xAsxqtpSdjQ/rA0WYpP4HLSbxKrwE0aW dZifnGaJ2Xkl75DsJNEzmpKi8MIiKZdem9VlZn7Wi1ZRinI3FSUbDA9vXWaqtGDSxEKyhWxUo25 8wDZECHhC/0j7tqLeHuXCtDPWQZD9jrieEYtIvFAwK0svHrUCF9d0Ufjiki/5l5W6ApzK9HlrC1 xdCRWwiz6F10jY9yi4sQsbkevcUp1zKk9NdMa+Izq+E9IKo4WpH7CR4M8aEPBwAhALjRlgE/OIv C+FYgFzgwm6pXD7i9u5iM5lI6hHsX6eOAe8KI5B8KddKeBlRT6AYolOFI1wmvVPSzuKRlK6Rf/u 726B+alSeOqaQYE2X0s3DS9HjwG8ZHrKaN8rFsmMvh4dmnMnvjk+6uxzIevsV3LqkIOx6JYs6Al 3cSLIERrZXsZxmLdYOvN2vmeKOcJ6ZXCY= X-Google-Smtp-Source: AGHT+IH4jY+b1OjVLIoKFK5y/UUEhv9wVPF6RDRt1TAW/dGh7V9q9DWQx2aS1sTd7KOMhNu+pw/zlA== X-Received: by 2002:a17:902:daca:b0:236:15b7:62f6 with SMTP id d9443c01a7336-23fb30aaff0mr110769455ad.34.1753603389562; Sun, 27 Jul 2025 01:03:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 10/82] target/arm: Add isar feature test for FEAT_S1PIE, FEAT_S2PIE Date: Sat, 26 Jul 2025 22:01:42 -1000 Message-ID: <20250727080254.83840-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: 1753603464195116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603633; cv=none; d=zohomail.com; s=zohoarc; b=RVDBeZGfnluKf+pU4cQRw20qXYk0KlEqZCzHNlZet2eY77CbEbM5rTPXhoFo1jTIeE3DkocAo/Jig2QWALxh32GNCsUpfcXfXWw5Mff3ZX7/O41vb0YwnDyLGjcwwteZMQUfRT2VhnWVHWPJB8Hn1dP71zC2X+/cg2kNGRcu+8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603633; 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=3cpS/rQKc/KiLSv/x9q7oUeyX2cxzb+6hLrCr5m20LI=; b=Vj7+WFyeT2DPaQonFuQaBqhuwiFRxEGCuczw6fJNCGSsW3RCEiNPJeLYT+UJEr2aDphjWF4nQP+Xmug6KBoyNgAgwLZmrqRiwDWN2zMEGFGH8OEJ0oNsbU1Iqg+w/U2OS+0KCVb4K1xn9bwSW58p1CCkNAI+2UygP5gzAGAmtYg= 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 1753603633139599.9561988755326; Sun, 27 Jul 2025 01:07:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMM-0007Iu-Vb; Sun, 27 Jul 2025 04:03: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 1ufwLh-0005Bv-NZ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:15 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLg-00043z-46 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:13 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-234b9dfb842so30465085ad.1 for ; Sun, 27 Jul 2025 01:03:11 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603391; x=1754208191; 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=3cpS/rQKc/KiLSv/x9q7oUeyX2cxzb+6hLrCr5m20LI=; b=LaLk2N9r5WGVELKQflY0REHxc6IW7RCttUU8yeOjxFYYY3/Ca7CRpKS23mIV+p53Dh /QIBRBz6fSpmz4VPErtwJOaNkgBd16sH1YKlBTJ3s7/lZIZkIljL50N479km4NiMVCvs Pjur+M4BfUVz6zC82aA7sToxT33Fgc4BFl9GdFJeJ5jFPiU5nGKfXmT8GIssVPy1P3Nc o8RBpQkLZEDUlH7UQmBgeY8kpIeAgFNQmo3/shxlLOiOKnfFOKU+nUOEALwv6m5htt+2 GDhLnVJ+0J03mLTNHg2rNQOAOEECZQS9X/ls/mD94+CzSvmtLQgSKDWwZ8VEIwWH10ka tRsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603391; x=1754208191; 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=3cpS/rQKc/KiLSv/x9q7oUeyX2cxzb+6hLrCr5m20LI=; b=FWCXLrVQ1zO8CNp3rc1vDT+k76DXOKzq6O/sijObFYuc3dI7h5jKwgfwSoYugiucGy xO68Rt3BUK9bFNafiVB9/VxyUdVIPZgf8FLG5xr3ZhFiQZ1L6yh6Fdr4effFQyNKov9Z on4xODq/L/dBG+ZRPISBFPLJ0HDYviym5RxnJZH5hjVYf05gcwlPo/HblFCsiAyqcBVc kTGGvdiq/f75zQE7ciyATDLzKWhUrhHbrDkDCXUNCDt8ve8sQh7DznkON0khRWafFB6S 9SRPpeXLf+p4l3H3gJwqWUHDsYOmoFInXLLqLlEVdrv4YaLwLsHY2ysMjZoOSHxQL3nD i8Vw== X-Gm-Message-State: AOJu0Yxw0oMrivbCC/RQ/eRyQnK6jpMxSx2Z5xcqDxNx+pxoaoXB6IxN Y4pkpSEeZxc7jFrtZRCNdWhspE/AxDOBgGcrC5Cg9KygEB9ZX0+O6cebXZoTbTj/0/8qa43U3o7 ryrE6 X-Gm-Gg: ASbGncvZMpVw/8pGRtmhzPDN/ku0M3KGjsE37whLIHIOyNn1Wf0e97HTgUDAb7Hetw8 3LZMsRhyoCCm0QB2m5yQCU9ReHeo8TdPKgSV/20WEwjZcrviU6Ztmkw9a85mhbwyMiEw1Jxk+zx YXKsWrxPZ26Wr+Ts2CAxdy2chTGaeXVF/AkrPn9zdGY259RChM55s5xJmtwCuaB5Ag360ocxlwu atn93uMGsdw6galMB8qG09JA0O2MquRgMCU3WZI69RJQYYTYiYgHtdcRY6zFzZt+6n4TNL75kPn PBo+5Y7mDwOW9vZgr5UXP39/crL37jxRwTLSjQJcLt0CLBG+YKJsm9QpFqfjBemRyqeESAJb/5e HNnL/eVN59aX96gbmk2WRJUabOKsQ2dRviKV45WfJHIxjNzwAgg9xKULjXXr+JukicguKLgFi7d fReYceoixJGQ== X-Google-Smtp-Source: AGHT+IH+7Wbhl7q+tsyTaGSVUjkVhSeWJO75Vu4sJUBoMTEl3Jthz3XcGKZ/bxpWAZjkB5bDSo1JvQ== X-Received: by 2002:a17:903:fa3:b0:235:f298:cbbd with SMTP id d9443c01a7336-23fb30ac008mr133704455ad.21.1753603390804; Sun, 27 Jul 2025 01:03:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 11/82] target/arm: Enable TCR2_ELx.PIE Date: Sat, 26 Jul 2025 22:01:43 -1000 Message-ID: <20250727080254.83840-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: 1753603633853116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603610; cv=none; d=zohomail.com; s=zohoarc; b=TEm8mvI8VLAFGVT/QcijSZfIWCKErMVZsTjarQNV0YDMDW0JP818QNv4ktTmfSGLcPHsLwl868WKN859Wzg46hhp9N/qSfsn/9wZHOsoHaTCC7mGVbz3f4xKiV2jXnJ9yY6e7FWMmJ7qyIgfuTgQQX031283ISLMKxc8EEoL0hE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603610; 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=pF/ThpFrnIItzYR+Sq9qVM5WxgnvRAKRM6CwORqEOQA=; b=SMqYq3a8xQKMQQKRwpQRvRac7I82AOaoad5IlcHYzO1ywSuFeXtKSRcsMvjuvbH3ITFOu3F4LdXiS08K3HvUIFJi3+AZOtSfNvBQwAEeHAGc2Ta5a3JZ3Izkp9XwOQXa1M+UcLYALWKUnQvLcNW8NflY+qf9r/d0ujxkXDxGiVY= 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 1753603610885306.17946004337296; Sun, 27 Jul 2025 01:06:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMJ-0006i3-5W; Sun, 27 Jul 2025 04:03: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 1ufwLj-0005Cn-CQ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:16 -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 1ufwLh-00044L-Ae for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:14 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2352400344aso30513445ad.2 for ; Sun, 27 Jul 2025 01:03:12 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603392; x=1754208192; 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=pF/ThpFrnIItzYR+Sq9qVM5WxgnvRAKRM6CwORqEOQA=; b=M0kDEVvPxXvt4a0keWNbIftCPlfqCpR4Em6fQuHZw6Uqq1dz8wrbdDr7z3iY5tcFx0 h8Z1bQsdz0B+xBbrUe/EbdWWmcJTciUnVC6OyU7bVvoFtT//cIHJfbBIrrEx5v1NXVcV pcywfAE2zcayVbUPF5GzFki+a4wzNddGLfjXumx98Ck0uSYW4TAJS9/pr2YwwEMZh0pp gf6aZI9/C/lGHQonzIUp2SNZkwgQqIEfb/0C8tF5uPAI3Y89jF2kDwjO2gx9aaFhauEm vEQ+pyaVVIkT0IL8mI1ZzdsXcANw3pkrftGhM6FCZjkAoMFsA5W1rbuICizAVDMDyvjV 0JOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603392; x=1754208192; 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=pF/ThpFrnIItzYR+Sq9qVM5WxgnvRAKRM6CwORqEOQA=; b=OV5uU2/KyyKsYeiKEiOp7tMLCaxzem3sLteo2+oIoyVef0ThU8J0UYoqXT+KqgKFk3 g7mDUOorzYH8FMcK9EDu6TfP69CL6P1/SaXNV/xtIhkGv6kMCxfjWrFauw02Senjk6Mv R05CFxwk3V5laD08ok1DYnq0MqGj9n+oRFTFGry/JK80rogRLztonzBMMp/4RyYoEUdk fD9vhye13ySDqKst5MA7fqQ3qBysyC6jkKbgtO/9/RzcSAPhAiKxBcq4A1IKP5vZHAX7 MDuGvGhl4OJSrk1HaAzQpVyTRRl6arfzsDtplB9hqNUIw7cnVtlQm9xq8oi0fTUuDkP/ dO3A== X-Gm-Message-State: AOJu0Yx8IM0S2VRRsjpEdzOZfm3KHbpRv0Jwa8g+L00B1wzkZiHgTYs0 eesfNifbwyy94qi52n5dCkGhR8gLUA5ZjsNA+v1hk9uUy1WspnXdLpPcFDGTsOUqCZOrLiz/kFq HZWHb X-Gm-Gg: ASbGncuwdCy0QLcEAnnOPszu6+Ux7g4n+UoQ8EoCNoUXlWmHJ7BYUMl2aGUCthtbcKC b7scluZXrbk19hE9I4rxBI2BzE5+Dt6ksvSiKtNx25qsV4VRmWOLQVM7RScgL+XbHcekb89ne0i X9CXgtOXfmyUGPZATiyguHIM99ahXfbnxzYJvWxrJmtdqvof57b6Rfk2kz4yf75hwaOm0dc+kaj JBePSEYAqFSwafBXjPDOytbsuhm0rHujTicY2ckCO/9KeytOsFVDrRNyW3/fkybQJby07nqlQNf yeZa+sw06VREj7C1FCB7SIrARe3xb2cw30jyLa257GJNGWrtzn0JVJ11WXYUJ8cUHZwLh3V9+Or GUuUbO7lEZCS2QiHuWkqV2u4/IL0VR6TiC7GC0PuJspgt/Ap2kRnBzgb44wdh0XZgbLUHQQTfA2 /6Xvik2o0ABQ== X-Google-Smtp-Source: AGHT+IHerc4fpQBiVHhOvRGLZ/QNXdo8UghPX7cp0n0LgwzI5wvqYvi8NLc+KhNtZqB3XT4nhnOADA== X-Received: by 2002:a17:902:ebca:b0:235:ea0d:ae23 with SMTP id d9443c01a7336-23fb304f9b5mr103774405ad.6.1753603392012; Sun, 27 Jul 2025 01:03:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 12/82] target/arm: Implement PIR_ELx, PIRE0_ELx, S2PIR_EL2 registers Date: Sat, 26 Jul 2025 22:01:44 -1000 Message-ID: <20250727080254.83840-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753603611422116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603675; cv=none; d=zohomail.com; s=zohoarc; b=HNhKNjnGjqP1V97wcSftOjBCexFGkpuf/oqttWUjrT8wyHwj4wFUGqsilWLZzjZ9J7NjdNjwRn6pJ4eM177kMNfb8K/beIsYX+HHvZfGAdl+5PKBcVHCycjgZtSbTAu3sbdr4ZDT7oWs5cPzNtLtibVFonJ05w5PXU2MTlBjmbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603675; 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=q7LCKs76Nw+Cer/cpAQHFjJNOdRtPOAbp6iYLe+f3EQ=; b=YhWTfhzSJuMIGpS4/5OcX4Pkn4oPMNEajtzyMBLsFYypFeSjXE5W5qdkWj8UBRKQ8anH7zmTtc7JJ4pVLugwJDoqR9Q7gyKQ8/+ND65Gio52rsSK38YErLctEsyldypcDtWoNfQUaP9OApBsry2XCggZKNgmw5aYz11tmnCFdMk= 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 1753603675827196.9081905659441; Sun, 27 Jul 2025 01:07:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMT-0008Kn-Gt; Sun, 27 Jul 2025 04:04:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwLk-0005Cr-Ly for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:16 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLi-00044q-OM for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:16 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2401248e4aaso1288305ad.0 for ; Sun, 27 Jul 2025 01:03:14 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603393; x=1754208193; 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=q7LCKs76Nw+Cer/cpAQHFjJNOdRtPOAbp6iYLe+f3EQ=; b=O0AutxExnGgBeFsJ8I22bRDZyqo/ZnEaJuqLQVXM1rvfHesTzY0piMzWkGhEQO0CRr PzWV/N2jP43KmApTWtAcWoI7H9LxinsiRfj3eImOiC7LOwXg+LVaWIXBGmjnw/7v8cfI kRi7+zDZtP5u3jWyTvxFpaNIkj20WZZ0c8WohYzUC3JaX5zNulQxaXrjLcleUVxdG/kF CD+p2DbvnB/pa4tc7kzgjetEs3Ewb1TnKgmW73gOdq3yfHTcvPW4j8OE6RJ1Siw9Bc1p G7jz54frOXkYCmI8lhuKcIONsBy3AOs4qbOnQFw1v0WzyuflwzUS4GLNg9Kdnxqh3qO9 1DaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603393; x=1754208193; 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=q7LCKs76Nw+Cer/cpAQHFjJNOdRtPOAbp6iYLe+f3EQ=; b=r678ddcu4guv8334j6K1mqrjO9ZWI/HSod4aOTEqha1Clfs8sEjl25Z95SdmyxmheD RZLt+m0efrZpsNVGcTjdFSjtoLXmRtmKgxO8QhmrWOgkZsr/Bj/UsPeOIYV3jN1g0NlI q9qk4v+AgrLYG8J2kQGB1nlb+1zhmt60ypwYi6NXv5HnGdzOMpONGCnDBP83CTBlydqK ylqffeGZzW+b6mOg163lWrOOnwoULkRjL7x6WVpjwAf/zmDBVG30+uLjupI7zpdh9+LW yIi4ZYn6oKA2c+RGGv5T2hVUKnnRel4CNSLVWD1Jh4Bs81bHsr4aOL0dDJ1FufGLD+7p QP4w== X-Gm-Message-State: AOJu0YxODjHrhpRZw94wRzf9WYDbnsbDjbnQj4FvmC3gbQ630njV6Ugz re1NyzzXVmFU0lg3I7JYuHELw9Uc67Ht00P55IiQxwDKkoljUhQk31vbk1FKpXIm3kuz4GxNLlt /eKtn X-Gm-Gg: ASbGnctZzvTfPcxuAt1NDcUoVFJiDONM25WJ8pHyyYgcFPu8Bd+SahfY3I9j0/vRWEl 01b4hQKMgxxfzIYTWwvXV7/WNaYPwR+WwHPwnr6YOndxKdTPbH3G0+evYdo40mqPEUfcQXwtyUv Lov970J8BAwQ3ssUzKDPktEbenhIVjRKipjReJffVDqWg9GcuMj2Q3wlsTFsNR3/rrGhdu7xS75 BLpTr7V9WBo5Ar8CrtJr08wxM+U/wKzHMGcVx+khXfm4s3fTe0huP2hBfn09D8+Hms6IzHZIZ3u PHKCyopRxtEiPXACj+/G6V8mRV5nALjiy59hyU+0tGg+MTD3JxzBVkpAV7BanWo/K5epSggLCIC NiOBd6ZUcc8gyniZ+WGuTu1u1Zzo+ak9OJDTrv8z5WidblcmVhY23KY51pwpU/vFSK3WuSlW6ir WPVY+2ONY4Ag== X-Google-Smtp-Source: AGHT+IGYLJ2isOG6ZUT0awpKMmjRMNeUMEglbx/RJ2Y/VkBoBpUaZfJnVma0NJIUrgXyC7EvAfxesA== X-Received: by 2002:a17:902:ebcd:b0:240:1f25:d443 with SMTP id d9443c01a7336-2401f25d6e2mr1082595ad.30.1753603393160; Sun, 27 Jul 2025 01:03:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 13/82] target/arm: Force HPD for stage2 translations Date: Sat, 26 Jul 2025 22:01:45 -1000 Message-ID: <20250727080254.83840-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: 1753603678022116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753604356; cv=none; d=zohomail.com; s=zohoarc; b=W/JS4olCqxtCm78Fhn2/MNcFHfD7BDpabepQo1f35F3kJvIaPJXwEN4cpttgCOimQVpcWjmpiufGOpCIxt/kO3avjPGAF/bwRrOZZRvfUftBbSanZG93mWDUYCAAh3Ma/mBKMyK1Fnn88EJ34LbXsBW7imWXh2B4+/k85wFT6sE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604356; 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=x1wBSdpzr7dO5TzmGChoFiy9bL+r/HGBv+nchEC/hvA=; b=ZclIZEM3Vr6ttqFIDFRlsT3Br9RLHq+h9LaEAC4ArUbCsfk5l9t/qAzhftnxJXamm+RJyA2KpzpTZGTgOxSOBidqnkrxcFv6Ni/CL/ydYXFtwh/bLna3ZNe7NABsot91O6nIwI2On7gfHOOiFzgkOwe6flfCOhptEeFO3ZFKUCY= 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 1753604356007309.64682498167963; Sun, 27 Jul 2025 01:19:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwNj-0003uk-Li; Sun, 27 Jul 2025 04: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 1ufwLl-0005Ff-RG for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:20 -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 1ufwLj-000452-HD for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:17 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-234c5b57557so28979175ad.3 for ; Sun, 27 Jul 2025 01:03:15 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603394; x=1754208194; 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=x1wBSdpzr7dO5TzmGChoFiy9bL+r/HGBv+nchEC/hvA=; b=SM3JxG+ygp768HSWCLw3St1X81q/90xBgxeHU8D/ENIB33Tq9KuYFok1I7IQHt15Sf 49GbGxyHiXdfbXWi0EI15pG3KhnF8FNX7VCWUlOCZt9a7of+T1Y3lrG4id3vkpRY4Npi VU13D8XsT8FAl8CrFfpZNrs0l4CXHEvPtz3n0ZX55I4jcjNOssUpc+xXUl8a1mrj8h+6 hs2x46whHAegm41LvUgiz/9sonI+jkWXK21Q8Zqk9I90bPn0p7J9Z4iNPXuyZR3lu4PH DXT2zIZ6UYZKrB4nZghW+ijpvCwTnPN7abuvg9JyCHmKUC+9wUBk3ZU/Q0+R9l3c1D3Y +8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603394; x=1754208194; 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=x1wBSdpzr7dO5TzmGChoFiy9bL+r/HGBv+nchEC/hvA=; b=jcwR7qJOItZfwejwnneGyfCDZ9hpOwxfH9Ui2h7WOhcxPPtirOWIIYsw8wWWlGf0M9 KrwriiJmZ+y4V+FILIthF/qirQKWqS6BDrAfieGEn1bBlnNYfiyFFBU20Ja1cADVvxY0 RGLPC1KnLCG2zEGIfkdC3IwwgWdRkAGEIXHyhzOXZOGfC9VI3Pnq+Gd3fHaThnwtJLg0 HheAmhtK/lDm7oKzyMS45TY0uWhdZQ4Fqqsm4jhg7Dl/vuUGKQsQdGl5gWjTNh2/FgyO xEUlZg7iaHutWI0Q6crtiskw8n2SlwxGzPxECn7rjMprcfgwL2iMG4Dh8FWPfwhPGCQa s9ag== X-Gm-Message-State: AOJu0YzDtucD6lFk/4ZkXAEWVygBBpytujrRKbM43NIql8v5S0t6CveM gotFGQm6pnTVBj+MmMPxEXNvyu+p32Ckd/61sCAWbu7WlIWFrs+hstdwJjTPlgkqSe/VAxamE00 fbQdX X-Gm-Gg: ASbGncs3R5HH+CRwvYWvm3qX8Au2UAo8Zw6JSHeLlRCrI8lhnS6iv1qIg+uVW0I14Xe 5mJvcLuhmC1AA92qNHnMP/qEOduJlFgzQuAtU31GyFAvdE1lLQq7s16O64uc18D5UhESYsIu8dM iX3G1h4o6AhIvB3NfY7MgEzMk1nOVbs+q7w6AClzBeRi/WTCtmEvgMau9vQhRGdm1qVBt+4H/0d n0u0d1mJuxwHLy/ojpIeufw02ldCXO/yBv46u5pOlBZVhMw53LyR9eVYyi0LhJpowHBGP/bQN+k PAv54GYUddxJ2orJF3GdCr207QTnB29VmWqIUCxS17dQpVMSKbclqT8fGDyMJAjAy35GJ/NDCFF 3G2bNMSL5kzhzvd3U56X3BAAvKFPuvHMsVqt5ljdGaVY1bq5eXmQhWItHiwfYAW58+QXN+hqm/B Krae0jZJelIw== X-Google-Smtp-Source: AGHT+IGrJgro1MHVvAGPsm3lCGhD0+0mdcX7boiHCLcajNdaBNT4flTXjmo0GufvABkmlIkQJR9Eew== X-Received: by 2002:a17:902:e887:b0:234:bfcb:5bfa with SMTP id d9443c01a7336-23fb302a71amr110099605ad.15.1753603394134; Sun, 27 Jul 2025 01:03:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 14/82] target/arm: Cache NV1 early in get_phys_addr_lpae Date: Sat, 26 Jul 2025 22:01:46 -1000 Message-ID: <20250727080254.83840-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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, 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: 1753604356862116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:14 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=1753603607; cv=none; d=zohomail.com; s=zohoarc; b=mVh6uvrLxXQQC9yVk+0XFNLoLtw7he+1JEqgUfn0AEQxYdlLY4sajipXjOGU42ZQf4Dpud1ofCDAHw/XC9Ht6HNMf6AP9WRlYICAHxB6aCVBy9XNc3+0v42q/YMWQc13ZEiLFbMBzkRsgnre4U+U+vFjjTpkNUTZvp24nrnO3M0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603607; 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=iLtDIjPQLDZompmk/Ugn11Kk3KXRHr/yrDqwQ7AVJX4=; b=AeaCuwjFPzC0HB75jYOjsO2zPNwKfYF3RWUzlYR/sUyY5Euk77WN/ADxlMVFEWSAeZHfWtXJbazlgDaEJ/uyw9Gs34iAAW22bNpG8r0fBpetJjdkydKECLBqW4BN8zAo0VLW0SfN7KEf57YeWNxdpkCPYSYa+XuOWuYip/8oiKA= 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 1753603607565278.4144150538915; Sun, 27 Jul 2025 01:06:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwNM-00030e-DL; Sun, 27 Jul 2025 04:04: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 1ufwLn-0005G8-0Y for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:20 -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 1ufwLk-00045P-HY for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:18 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-24003ed822cso1915325ad.1 for ; Sun, 27 Jul 2025 01:03:16 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603395; x=1754208195; 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=iLtDIjPQLDZompmk/Ugn11Kk3KXRHr/yrDqwQ7AVJX4=; b=L8SLf3uQ1WIN7VqZQsI5YDrp7VK/Xuv8GZfk7ceC8amLA3aSqEFq0ODj2N9MPkvXcQ fJrkMmEMmjOXrIg0qSy1ToGrwqiWIa1XyBwTwiRENzHSXUUS6tVBztJWkiLx+iMKFFpx DBFZfAUZAoanjszrooZ++1pJt0CRyPnuD6igbK46DAv1SQQO2wWISn2AwCSS5Phenn8f Y8ofivuWLUsv9F2a/0YoN413GtnVIMsaSBjz7Kx4EqdEIaRi1fesvRn1tVx6px/nyW+o cRkMqbwhGNo7COFIQbeXXZiQNsmzB4N1CmRFsHnAtEQ75Mq4mxwHbq30Tlzk31W0DtcA j1Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603395; x=1754208195; 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=iLtDIjPQLDZompmk/Ugn11Kk3KXRHr/yrDqwQ7AVJX4=; b=Gaf5e2luBxOUN8BATJtPwHXr5y4dTmJG+SALNrERSWSEeOp4QV3+FVxMvb4+OXZpW3 9o8CE/Dmw2n0gBITRO5aNS8OWPxM9FjDgNr1rqBHFw7vt7JjaxKZRgUcM6tfzHh/9cjM iJX//G5ngnwgJtcOkl12K9Nxt3xyJoghgbWfmdpYvEeydwNQpuwJM4B3TuqqDwy1K1HM G4UON4pFUSLthb9JxyT+uSVegOb2psqZVxFR64GfIhGN/xdom+UWdMsXlrHTb2vJicaj SWi8zrZYDHPZZwS+oHdmnhHABWaxdgN3JMvpvSnDOrodKV+VZsfXCMV4nPm+kwXp0dCk AXbw== X-Gm-Message-State: AOJu0Yw30ip2oU3TazqbVEHOLw1DG977ZLaQ57jwclft4OgkaMiRqCPB e+XOe+WKDyHugK7fX7TEaDQaIuqSWe+CRkjvT9VNKetRmob9R5IWMJNm6RyoMm/0IPaLliedWmz 764mr X-Gm-Gg: ASbGncunyyNdjx8jhvJfKt3kFb+iXZG/DmmQp+Tnh8WwgCg5XYQUSFUsYW1MOAIb4Co G7eWLurKxbitrrRCWnNUZvyys/ay2Ho32GHdusXfpClLy/Qg1IhaxQJ4MWdhk/uhyXOrW4lsZ8u ti3ac6ecW7EUcHXzBEX1xoad+bXPSLLfrMz8TQX+RL7CpUPf8NogArGZjqP1WPy45+19J/OuOd+ tgsAE8B4gScIXsNKs8KVbQfuyVhxgX48Bdon96VGPM7tjlDJmzE6oWWOPnxckqWxJPSR0tXmEVM ZXLKtndOmuyJHEwcRk9vQv2kbJmeJ/mU5dVNcchpAdoaRRfC3jNZd5MwlPJCexokZj5XqZ1EGe2 DEV7+KV1b/tNkL9wOg2iawE/+c5Uhu+Sdkp0uOiEvBEfO/bo9cOr1mNnUBH2lC4mydnYRY0lK7e h8fMfm3/+Onw== X-Google-Smtp-Source: AGHT+IHUzhaK5+Wrx07Y+uyJBuZ19no1gmSavZADSHHojq2Mt4rkaYYvgDW63hOSLFOJVvW2zFfhjA== X-Received: by 2002:a17:902:c94f:b0:23f:f6e0:b3c7 with SMTP id d9443c01a7336-23ff6e0b6a4mr40035955ad.45.1753603395214; Sun, 27 Jul 2025 01:03:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 15/82] target/arm: Populate PIE in aa64_va_parameters Date: Sat, 26 Jul 2025 22:01:47 -1000 Message-ID: <20250727080254.83840-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603609401116600 Content-Type: text/plain; charset="utf-8" Select the PIE bit for the translation regime. With PIE, the PTE layout changes, forcing HPD. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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..ecce93fb97 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 02:14:14 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=1753603694; cv=none; d=zohomail.com; s=zohoarc; b=KEvXnIn2uaolOWjEy8D7jLgo63QFkGlolLVgFMwnmEVcJ7mX71RJX/FuNkGy6OWo9inuo+kiv5m8ITH7pU68taiKZFhPutyO4iSSeqQGYxpGiLm3Ne16Of0/aiFIiQ8lmuQ2kRC+wdeMHywj4Wozf0K0tUVritfhEl/SvioS4S8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603694; 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=Q+P8IeblzykTcTyKAeGF2rS4Q++m8Pm2ndyatxyUnIY=; b=Ded27Z7N3MuIZ5hUh/UVTq4wW1ex4wi2sncuPIeNuC0sB8IGCpLni0HN6743GaG82MfpNhYD3b1/kxtEwSZSg9V7GhJRgiP+iCo8xHDFDJgetUbxnhI3rmA0t9laPzxfy52ujlLW6ifwH6oOu5mseOpAARpQnpz87HijMxy9Vy8= 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 1753603694448761.2494685251723; Sun, 27 Jul 2025 01:08:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMT-0008QQ-Ua; Sun, 27 Jul 2025 04:04: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 1ufwLp-0005Hw-5j for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:22 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLm-00045l-P7 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:20 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-23fd3fe0d81so8009825ad.3 for ; Sun, 27 Jul 2025 01:03:17 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603396; x=1754208196; 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=Q+P8IeblzykTcTyKAeGF2rS4Q++m8Pm2ndyatxyUnIY=; b=zL7eOaDG7y/8L44+BUyRhTV5geAtEh1JapJ9xhq+Q6+SIgehkdr2VPeI+Y6lSSd+OU U5UEYvrGsY21w02niEpqxqjyWxRIRehqbupnIRa0x+ZRd5ahLyvhKMBJiKJkKxq9TvPE pcvqJKWsIpLCUykyvqZ255+bgxHhy1/qvxIKiAELL8MNnWRXL7n92NoO3/k0jNGqhwCv DKrjUJNGvTw3OAKZEgRENzzCaF6WFewgOoX6IlQnkJ1vYOGO1oG7Z5etgYzAZkgj3j0M Et+lmGz9JL1Z/FfZd/rvbgeZLgFQXk7q6pGpqIRNQb9teQv+BGzEN0jyo/uXacybRCfw TvOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603396; x=1754208196; 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=Q+P8IeblzykTcTyKAeGF2rS4Q++m8Pm2ndyatxyUnIY=; b=MIaBBvddxlaiu/SBpVz/LHIG88H/Sf8M1yTA4KWxP7MUwEk9vAGFmWMznhX1T8aYfH REENClr6UtJK7CBtBpdry1LA7PiovHKQ1uBu+RK0tp0DgyDITvfkh1FW/A5ozT1bXynL eGkRiQEXk5leUtWGHSoUAcFqqIC1Avp60TVnSWHsSHx2hbFeVm67Ra/VGC7ifmCP5tSH bVY6r7C9Jzvt1d6/w5qrnkvTuMsTw1kbaVfAJIxi4+vnnbsLUUDV33X5rvtsMIPLItEL TIXJHAVtK6XINUezBK0aKmeywQ8SoBxNtOMTFRrxBKnu8qOlnha9JAs8nM2QsiuRLkOh B+Bg== X-Gm-Message-State: AOJu0Yx/rkE6eMd9qBBkCDIMnOsxcYF8Xz6JTgt7kROYys3p6oz7w+P8 6tED4Ll1oldB+LoIFYvjkhCAr8MAYqfV8vir2bSvtEWDLinQ0KnoCKW8Zw4xqfzn/+FRozNAC/E ELlRJ X-Gm-Gg: ASbGncvI7UhxWQRZXYvET72QXkG+P7PCqfzB/A8ICdTRie/9lpS9F8JQ6rNWtgbtDRO nI/azez+RBP9c6y3iSzPNEFqtCbeoeHC5F7bOnVt5AxYBhMXY1+yAWAtlv4qZgfpBCT+s9RkJ9i bXTJr2/Pc2CrlaLhqVR1sZAec/Kd+iYxSQNk92gRnaX23XElru+HYL+oDHuYMD3E35k65JxLGMD czjQWm6JACDkW1nCaymIAStUFJpdsK4cx/d1ImV35APWVZr68jub+2n5V+q42dswtFJ20D1fNNF 80ajRkQz0qrB5NxbED6IakSuncVCenBa0iK6GLEULPn0H8yKIhtHMfWIAf8iGTppnPJJpkLkAUR 0L7/G3o8/QQAXRkFhywdKbxp0KNUCs9LW29Bu5zqHvAGWfYCJSSvWTtrfmpLBO61++eVlbQtr36 buP0UYxoBAZ/Owfp4XlHgU X-Google-Smtp-Source: AGHT+IEr/Nl6iSrZjjYMfkNwomO0BknCbLoegJBNlI4U54V7K0Qb66VKxiNIyoK0zrwUOJFOHLNpOg== X-Received: by 2002:a17:903:1b05:b0:234:b743:c7a4 with SMTP id d9443c01a7336-23fb30e42a3mr127714365ad.38.1753603396378; Sun, 27 Jul 2025 01:03:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 16/82] target/arm: Implement get_S1prot_indirect Date: Sat, 26 Jul 2025 22:01:48 -1000 Message-ID: <20250727080254.83840-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1753603696230116600 Content-Type: text/plain; charset="utf-8" This approximately corresponds to AArch64.S1IndirectBasePermissions and the tail of AArch64.S1ComputePermissions which applies WXN. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604390; cv=none; d=zohomail.com; s=zohoarc; b=LS13r2Qheu4NtaHvU3sKrgHTjKGi8XsHqSoYt0y+bjf1gHe41A+l0RGHJG+P2trFkNhgmE4NOaBn1O+x2rGI522tvauItwzmAOfbnLDJFi8hyL3Msvih1647QegPXeWm190gUNaOJGAW7M3kB8eKwEuM5BSk7wQ2SH/yGC8rZu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604390; 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=9jF/EGg3UDomg1t1Cn2r4mChtBaH+ZfabK+9IehzGgQ=; b=kFE8N6TWtoRtxtdypP5LMWdlDl44IKl8IIi2Ti9nlWIvUzilmnIDu58t2A6hXo3XE1ASQCU1lPv3lJ8uIGZNCqI03TdOqgtQYUXlOGnBgxuGo09MKG1heejHMMR92RENiNuNQRmtD+iF3RZFyNYU/yxZqvjrtdiivdzjWn2xmyk= 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 1753604390166596.4577252383025; Sun, 27 Jul 2025 01:19:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMX-0000WT-1u; Sun, 27 Jul 2025 04:04: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 1ufwLo-0005HE-VF for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:22 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLm-00046D-Pv for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:20 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-23602481460so35104845ad.0 for ; Sun, 27 Jul 2025 01:03:18 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603397; x=1754208197; 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=9jF/EGg3UDomg1t1Cn2r4mChtBaH+ZfabK+9IehzGgQ=; b=kLYESnI63pLmb/s3Mt5XA//xthtk7DUoRunHST3Cj5TS8RKELSoEWR3Ca6xH2OBTZF yfBawSUCawfjnl84trQwYQSVRjO+bbw76MfskTm8t69GqQVPwmCpWoURjnIt/9bfkKWF 4jtS1Tp7tHfAZ1nbvQezqeGZcFQKHwBiz04o84M/y8tz2S3+wHWZb3DKR+UargFlrpxT PnkwJD+ZuInIzQlCWzsol0wlaxLeJHQXr9WoGnTAMu7io4Ma/MuJxWKMVneUox6JUE87 9lim2i86TagA3hS0cGKWWTPrKPAYNWj4EHGgCXSSB9jBxWhbBAIaHHH3oSIz7Yaq00+M TU5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603397; x=1754208197; 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=9jF/EGg3UDomg1t1Cn2r4mChtBaH+ZfabK+9IehzGgQ=; b=pzgF7DCiVqyiGDLD3enxMj9j4jrMtWqdQqTc1W6z0BQXj8upJ0j1vdgYm4DhAEucVk t/oN4gJj57hymrY6IJ6lRmM3r60/ShYyuJrzalUNjKeQCMTOl/Dy20VCf/aOYt4K60/F xt+VtcvnlL9wFmqp+cv+J+DZfBpxmhpd3Wq/GXzBhpmm9vPAcpt1p+l+9yN17i1yRPYR j0dZJntqFojSez7oU0Ef+lkiPshYA03OSnpMFhrfi4pDdrlMH2l7pLNZZeq2npfm3JoW U5xpazF/GUKbHToBvN4+5YREwHienzQfQRzUVIv4ysbB4KkmkZ2zOuGi8M8Xv4bQdygm wuhQ== X-Gm-Message-State: AOJu0YzIclIRxY2joAPzOxeEaWqz6elvigAN8ybj/ok2DfncBtR8UmEo ZhXmTo2svXUDl3nU0wLZ61NfkGWoXyggBfn6CTBQmdGU4knY+d7a7MDm7xQvGtTNinwfAivPmYM DUbJW X-Gm-Gg: ASbGncvDuIIGi0AyIUcwQcYt703D4Q3WLh5vggKwYZ9ViiV0Pd1cmK/4T7+pbS4RMKe pcqOAClkD61M2qBJ/ZkDi/2D6JwtH+5H68qRuqa3NNeBEyrqde4SIuYFU7geCkW7h7RCtQzSbuf rHc6eGXMhcjT9wWAuW/tXAHBhOwZDlQ32IPbVeX7pPalkNyhDxj70VVaFA1Z8AAAHI1CsX+xFnq Aww4jRtYstiG6wF4CnozomT1Rc3zuW9qISGAIoWLO/ROypuM1nydFiDI/Svoygu/lEF35RAwQt1 cT+MVfVOMv3xATz5WR+Uae2Lg+W3Xo+s3HVwKhYVGh8m6zSLDrnhwPFaoM6A0ZooP/WVuK8Rgw/ BZQf2bpWIxnf16L6GVy/3C/ObnRx3lY6ilmmoaVM9S7nmmciNdpC1umsn118L995JX9G/kB/Xhm naNz65yhf4GQ== X-Google-Smtp-Source: AGHT+IGQ7kH1etKbzOy6oSWGmQG3I7DrwIgM96ODRoqLcUs8QSX22/2YpG4m8g/zyRXiJMTmdDT/oQ== X-Received: by 2002:a17:902:da48:b0:23f:b245:531d with SMTP id d9443c01a7336-23fb3080817mr109082015ad.15.1753603397489; Sun, 27 Jul 2025 01:03:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 17/82] target/arm: Implement get_S2prot_indirect Date: Sat, 26 Jul 2025 22:01:49 -1000 Message-ID: <20250727080254.83840-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1753604391254116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603610; cv=none; d=zohomail.com; s=zohoarc; b=X64ARy3Q8YPAHaEIFiljUv4Su9vJv2GaLKUS4WIJp0OAhTaWgPQP0RRbJL9tmWTzUdtvFs05pbZORCKufDYkkdLUMarlZ+GEr6fxcALkPkhO6Q4WMoWsu48sFF4VwgchMaSSTIs35orkdk3Hk2FqhHd/reGPvD8tCYk0krc7tp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603610; 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=DL9CLJOUFdaWACxBCMgH+zFAs5kXtrfa05dzoIG9m4s=; b=k7cU++JivFQR1u4gEYoAlYkhKC3T1j4F5U9IAFDnkH019ft/DtX275X9QUht4G2EmeYxGW/1Ppwxkuv6y3XmhUYrK/qRSCHhV0hrlAjNueayun8Hl/Uaksr5NJfl8mkWFda8y3Qb1aAGhFch/0eMFDvBRQR8XXP0++Z2v8tGJgo= 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 1753603609876428.3316023380138; Sun, 27 Jul 2025 01:06:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMR-0007ze-Dq; Sun, 27 Jul 2025 04:03: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 1ufwLq-0005I2-B6 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:22 -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 1ufwLo-00046U-2w for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:22 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2349f096605so41185705ad.3 for ; Sun, 27 Jul 2025 01:03:19 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603399; x=1754208199; 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=DL9CLJOUFdaWACxBCMgH+zFAs5kXtrfa05dzoIG9m4s=; b=scZJR1jpTVyexWRgNKBVnGOWnBmHvcw6ee7+N2Joj/aZsz4NStydfsdur3LOcuz8Sn DqV7aHqsB8RplC7l4vHD00+sWYJjgKEVcFBdw7nmkFbMe9Hhy86HAsc8PefzmitKDsMF KgQM0alUzfmMRQpYFhoEMkEev0D7diVP6++ZS/yBY85wjmcJ5IxQjEFnjFMQ/mZK8w4F EgGRDAGTDuaz99TavqY0oypbdC927+mk060YHvBo+LsP3piVQY1uJ2xaaZNSh2vgu5Rz coBU5Hw0U/dIA2J5D0A1q67I9Ok0IZ1s7G9/m3oRbc8luDX6niEqLWSlVCHfQauFzxF8 yIlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603399; x=1754208199; 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=DL9CLJOUFdaWACxBCMgH+zFAs5kXtrfa05dzoIG9m4s=; b=eWUSMQGXmae+r6ZbFUxuBa0iPrak7lgkKr1+zRkJJUIFT0bo5gWJXywx87sGVyYJks 4GpnCJp7rsBv50OEyhwB1MtGlGKygac3LO3ehEDsOIzyZwwyz4lEv5zeMBV1jVPPfAS1 e0arxIntutskCirzQWl0segFRcZwGwsitetgSLMiQQC652ycYSl7X/K6lW8xUVOEBNb0 9LgBcrQyjnU9F7/8Qgcwe7N0HOwo8LDdpBP1J+rGolVnVfYrB1vPSfGinqKkgTq8gsFj JRCSGOk2tGn76RTB7eBdjCBXeurVQ6ODvTg45mldA9mlEcxAvPNATtfD0jBJV6S+VgEp V90g== X-Gm-Message-State: AOJu0YwxqU1+P+Oh+VHtT+7ei1EichXCA4WADoeAGIEvPHxwxLbEgvAo 19PleJVcMx/OWGsUcO3FY6axpsJ7+EA6Sk9cihfrJve+Xfm/G2wnXA8SWB9Y/PHflBFz8Ar8/p0 rPt/o X-Gm-Gg: ASbGncvzmKdpK2Gs4+eaNWF30vFp6LYN9YBwkjAOBFCvp5PlB0Ygl+X0DknZ0nE+AHN pv55yRimQy9FnWYd3H11PNC6EwNSArgDyBG3gU5ZGmNvvt1CVz1dtQ5JEX9hxN0lMUgGvpn/Qmy OMOL85I9aGkWX5mMbuiLhBEOBar3tM+b2Z7GN7TqFg8lHvWZgMTwU4+niLSNISr4Wmg/5k9nJOl Z/77J4lVdUIGHMuYDdqDuqTgyU6pQPxS544NsSUyst6goDkuAOeQpmRJbA4k5XxebRnSGuavkkp xoSMi8JfqfTFvdmsxXxS6LjHQgO16ySdNh3ftLkg8rQk7amYQKKpUaE65zRHil4SLxdyMimVT7H IxQm1QWH62auU4pZ6xz/fFSd811m138D0y+ApJysxXp67x98VELFrvPCNyZGLqW51o6g3MaOx7d UeA5ha0cHF+A== X-Google-Smtp-Source: AGHT+IE+lQz/NXMBFH8NUBwLwA4+Enx3kN9Mz4zJESXm652yImrSPGkku3jZKzomWsXStNwwdqxZrg== X-Received: by 2002:a17:902:cf03:b0:235:e942:cb9d with SMTP id d9443c01a7336-23fb30cb4bdmr131589495ad.17.1753603398778; Sun, 27 Jul 2025 01:03:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 18/82] target/arm: Do not migrate env->exception Date: Sat, 26 Jul 2025 22:01:50 -1000 Message-ID: <20250727080254.83840-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603611452116600 Content-Type: text/plain; charset="utf-8" These are not architectural state, only placeholders between identifying the exception and delivering it. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604075; cv=none; d=zohomail.com; s=zohoarc; b=RE6u7WBSWrQb92uv4MvCJ5QBYodXBDN1XHyaA3U2c5kR+R/jZPrKLM5ZT7J9GjY8PBg9sYb33N8ZN81uB5Q+xp3PREZoIEiPHOxpmtL3bY33szT3jAiTUiiZ1YjaaXdIffHL+IGcjoM5GL6HDKKH/hvAXxSgk70KXwKr1OUjInc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604075; 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=g/H+VBjLr5/lNaQTqOOTzzKgeKFHDBsmPau28iTb4mI=; b=kmfDG/E2mxsWoO9lpKb5HF1xxsjxqsf7NGZGIFklGwSTAsuK2Z+Zpg4Sh2/x8fLE6koiGy4DHTAigvWkjfboSxt0uW4v5OSGPmRFZ4Y1L6u752tL+4rX1I/EsmDBXgYazzby6wNbmqnlPICNqlL/buA1+zG8blD1DAEhzIAx+to= 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 1753604075273108.55315077219507; Sun, 27 Jul 2025 01:14:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMX-0000XL-3M; Sun, 27 Jul 2025 04:04: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 1ufwLq-0005Je-PH for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:26 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLp-00046e-3q for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:22 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-23dea2e01e4so45471695ad.1 for ; Sun, 27 Jul 2025 01:03:20 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603400; x=1754208200; 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=g/H+VBjLr5/lNaQTqOOTzzKgeKFHDBsmPau28iTb4mI=; b=gihswkdc1yG5zWDmxfP3qPRO3JMzQCb77ovU0Vja85xvReliclYePA/yW1SwEn3UXF 5kay344Otb+igmvZfU1kxKLPL/84iTfZ173TVN8cx1PIq42sfdluzxRTNcUFkeeMudgy ot8vD9dTgIeinoIn6QbnVLFcdMPyswbhqJQVWjyseIq5E6jaje2op+4+rae1I2OGaaB9 sJE8bQrBSHq9h5GCbLgXaO9lkiDPp1JWhJDc/uCto1sKWMhtAjrsfhHSYd5J1+hrl2+j DAAy/ZS9ktt/0GW6EnHxt16kGdtrFEPkARo67xEmcxicYCKb0ywI8S1PA0wvnf8UtrHU zFIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603400; x=1754208200; 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=g/H+VBjLr5/lNaQTqOOTzzKgeKFHDBsmPau28iTb4mI=; b=I6vS805Lpm+d9mpbySGe+4hLo0u/0GwkPVEWXwgn64hjlmrgp0gRAE9i6TqYcj11BS bJxkvdKHKN6q+1ZXH7Jea5Y2X1hcUUPACmhg0amvDQkPcz9ktQ4EYKmDAeDNnwuY5EDM dkxjWMkYLcCwV1rPwqR+KFCYa2LZLTkKoLJCwwTnTxFLTkvqijkm5F2k5EknS8nZF476 daA+ILDpkgHiKbOQLXVx/IVehCqBxnhMr09mdfD0vftPBLsJUIuuRaS3nn+xYocs5qhq Vso0mAfoRYcIjgm8ePtSZVHfazW5a5jjBZBCIV7xlbCtytnHs3mSRQemRzU0mrjxCq/v yMFg== X-Gm-Message-State: AOJu0Yz8Uf7ncT7nCVdPoL74j+oU1aq45x1jmmfZ4HPyWv93dDu/GzZ2 vBxsqbC9TSLaQo96T9etFog/upwgmdSuixB5f8R+FNS0seiDfIvUNm5fpPWQQk3cVg1V2CHFIKK W9qah X-Gm-Gg: ASbGncv8XmlRxmV8aw0jwySHAb+p0rLkYAca076UJj9YJJAPGhOMO21z1Dlp4BREe1G DBpirc9Ls9dUVKOZ6yyAhK2+JLv9IJ3RWKqJdJq0tLCM/+J7w/3raH9UtUkB4RM5mQHvofay6Z/ IWz15r+PUB8QTuCzCML+1082e0zr21oAry3pMvTed1edFrkW2cdRyl8A4uJKNzGTnLik/y7Laqy lovg88REvRKrlKDvQlgyG7Hstk1L8c1h+XlhWbMhU0FGUUa2oufGGW/EY0KviVaSTZmRd1DZAUD YCAQ5Ri2Za3JTM8bbF6yyX7P8dNhfrTgJPmV0iGfwy5pIWPBpY/+HLgYwydrhUvwSymYC9OF+hR EJM6xU2XW51rqKPyVJjqMgRknRRrKLmYLmY/zV6i59DDuG+yQ/NBzLMaFJdv2FmztvRfoLOHCIg n3qHLLo0VZnQ== X-Google-Smtp-Source: AGHT+IFWl3mYtL4BVjPxu7XrjmhNtAST6JwW8VgxkFgsUafWT5AcS3A379PaQEj7JzojeSE0JE6NBw== X-Received: by 2002:a17:902:cf12:b0:235:ecf2:393 with SMTP id d9443c01a7336-23fb313a940mr108350245ad.53.1753603399873; Sun, 27 Jul 2025 01:03:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 19/82] target/arm: Expand CPUARMState.exception.syndrome to 64 bits Date: Sat, 26 Jul 2025 22:01:51 -1000 Message-ID: <20250727080254.83840-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: 1753604076850116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 ecce93fb97..154bda3cd4 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 02:14:15 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=1753603939; cv=none; d=zohomail.com; s=zohoarc; b=RSisXvr2ViQbIUsBGsaF9ddGQ+Y7fnsWMWfTd9kvyX++yL/RMkG87ZAaOA7ZBF0xiDv2KOsx0qu4IH76v7ItU0E9CcTZdvHCKG/gUtQBi9rwvV5hjHDq5sVRMZH4n1slaxp0Jwbd7Okfuble0XhDBP073D66eP8PHttf5+bWbac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603939; 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=ZV74/jk180skCcP64aNSwWKDejXWoEgBfJ7ZrJzLYQs=; b=jJrvW+HaLMGU0ZpfEvllRSA58SXK/2fmzTGnfvKIELszOhdurBRfLxXWZTrKpaW0eOBZR+AfykChs1Cpuvfo8KQvp1ufnvymH2F5uxnJKBTm6NyXLkH6s61b5e66xc1OETgY6wPepvwYwObVU8nFJ5iLN7tNga/iJnNx8DKA1J0= 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 1753603939649746.7846391764066; Sun, 27 Jul 2025 01:12:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMU-0000Bo-VA; Sun, 27 Jul 2025 04:04: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 1ufwLs-0005Jq-Bk for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:26 -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 1ufwLq-000477-8S for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:23 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-24014cd385bso1420415ad.0 for ; Sun, 27 Jul 2025 01:03:21 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603401; x=1754208201; 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=ZV74/jk180skCcP64aNSwWKDejXWoEgBfJ7ZrJzLYQs=; b=zJuxPc42cZv3cXbeL1tcPTFk3NX1ZSSOYVijbLmH3ng8OICHYJnZ6QgbyKu2sl6EmN MxPaIIGYE37ooY/ZaLXi8sQPnFMCJjx8T/LHErPedBs/uOkxrL9VDBYs/s6sAd3MtDRY F5TbdrihPYPYT9+/fh81zDbseTijHttLt07ElfeCTOSXOOb2AFHX4qfwELhE1ks8xySx tuebPW8qLlytAe13bdaLaYCRK8MYZW80UJzA07zTHZ+h4FSpv4qdE9dEh1WQCsBddyoN Y2ANllhmqX5XCk8S9s8XTFe5oPTYBC2dzlLP7xizwapCHhizhnFy0/Otuy0+Ey4rW/VG x+6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603401; x=1754208201; 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=ZV74/jk180skCcP64aNSwWKDejXWoEgBfJ7ZrJzLYQs=; b=YTKS0BohmkJJrS4jmkhnzrB/0tnPThmDv4/8iKA8NEuIyq473oSvhuyL4L65dx3/rR 4zHRdaEwmlJeaFY8sWSOwNKvqRhMluvrtgQl+FXnotRxNjH43n0CY2omS0kQCuMUeKRI C3uJInaiM5cYYZOeZOLrou4rX1hdD6Plm6I7rIIiHPGgVuOmQWVGC4fOSTtHGuuxmTWC +l7QBKkxgRNbqY2M1X6zfl4+3SuqkE1VYW1f6SZPd5YP+4QcLBCjuoA6FGe1qQLy58Nv kOJb6rl2irl29JvZL2mZXTL1OkmHDaFBMcLRrYw4kYT88gN8ystn7m/miyYtChR+7b8M TG2g== X-Gm-Message-State: AOJu0Yz88sq53NAkl0gAldIWyEJ6DL3Cn5jqBSD9gaFG5fptwYCF9hXe AUjqcyikd09lTYV/USzAJ6CbYAijrOE7dq0zMGNmcDSw46W9oGlb79oFTIhme1a9BPwXPaLpTwc Iu0qA X-Gm-Gg: ASbGncvLNKlSglfGvQ7w3EJnAuGXAGzxtA9S2bOiYCB4XaC5tn1DKxMmCpLR1B1ADTg 8Er0J3YdvIlIOfdspS8DXhk1R/JIP5h5cw7wWwuJUWM8CzboHEf59Ei38kqqDQ9Na6/zQ4djDtx ckxJTjGgslLS+kD5ZL6Em5qLuCho5NydNT5NYms/eQwIMQhIIeEAJ4apy0ScZQbkdO2Yl7MtQvg 0tV4e907oz4XO2Myngx92lxPZDx3GXHFpWq4N/2VBHJZnCfUL3mdKlj2h27N9u0OKTan0bt2ekf YZy0+7S8Rb4EMs0K3SHFgFZ8gDAvtgOXCAALA/2m7YqU42RxaobNfsADlNBFyp258RC7OHBC6e/ NonTj1CglAUkpq7GAajuILCu9ilEdIl7V03ILBeaAJ50eEu/FfCEnmiu/+o/KrvXNWk4kspiiTz My5I6nn6HunxqzRNtHOip8 X-Google-Smtp-Source: AGHT+IF8szVz0tmnKhIlULobTD/BqkVWwZSRDel+zMsmDzGILYrcF7VbnskPCmgMAIsQawLb5hTLrA== X-Received: by 2002:a17:902:ef07:b0:235:cb94:1399 with SMTP id d9443c01a7336-23fb309bfe3mr107953615ad.6.1753603400931; Sun, 27 Jul 2025 01:03:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 20/82] target/arm: Expand syndrome parameter to raise_exception* Date: Sat, 26 Jul 2025 22:01:52 -1000 Message-ID: <20250727080254.83840-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603941969116600 Content-Type: text/plain; charset="utf-8" Prepare for raising exceptions with 64-bit syndromes. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603616; cv=none; d=zohomail.com; s=zohoarc; b=joUsLoezK4Xsb+709qrtCgF0JMqqNUQtZE4XQlr6UHxyYtCEDmq3s75Eu12Km75yF0pTpO3w07hNyKPmUpOEfXF8kVa2Xz2hkJ02YHxLfdnMZTk5O/F8qY4HdNx4hTt76cVPZp6Uc6CSoF6f/7jZEULqeN8E7lRANr5DapCWte4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603616; 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=LYZh6fiTUe+0EQpcXU4sHMxQ8Ins9Igi8YtaAq4VDew=; b=Ao3G1c5/FsDk30pmLTHSW8rRvSfYUcPM3cNJQtOqjyqm5vZEppg8DnhgXnaPw+YkVEQYOE12EPcls/aE1ji2VVThKWs4hRSYtIN3msNmsisLRqcH30jXr8/FdmMNcjxTxhvrYpuEyGFGcTsTq9Dtn7MYdTW5kvGCTPWCsRchFiM= 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 1753603616302997.2466381063331; Sun, 27 Jul 2025 01:06:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMa-0000yQ-3W; Sun, 27 Jul 2025 04:04: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 1ufwLt-0005LO-Qo for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:26 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLs-00047g-4V for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:25 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2363616a1a6so27449275ad.3 for ; Sun, 27 Jul 2025 01:03:23 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603402; x=1754208202; 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=LYZh6fiTUe+0EQpcXU4sHMxQ8Ins9Igi8YtaAq4VDew=; b=NvIHBjhG7FbRW/zEcIJpE1GOnwUk50TOt8cyWb+pRCNP/ZfbrhkAhUUkUSzs4JTdaO PE68a3fbxyI+e1V7iu3BhY8PF0YPc6A2d9NIXK8LFd7+hEcB4nJHXZe1jujGEGHicYDA xnqFP3757r8aSBzvbY/OSLyfvxLfw8kGmX9veuRwVRqdQef6O4IWRNE4gRJG04pt3Jri SClhmh17GltR1yua7sD69bSboziJhuEky9MZ9XnZACTq+uOTVYfJMCKAMIO3WR53s6Vg eYb8dEVD3WRK8WKDRWX1rN1n3D2c/4pkfXmdnvHvLYpCMhBGuVu7x6a6nCZE4oA4MyLz OsfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603402; x=1754208202; 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=LYZh6fiTUe+0EQpcXU4sHMxQ8Ins9Igi8YtaAq4VDew=; b=fjyWQtQKShy5h51+wnKM3L2sjTZCpFryhC3C3E0vF7kt55fkqcbV3EJugSdY0Dalux Nv/t/wYMOMlpMVQD/ifBxc7tCLBvz5ABw0YIcMkwwKE53VVnhULIg495Tr5oegcabezB oqmUGy93ux2squwr5DfAA9H7Uw4Rj2S/NT4vaWPBhAHXtPfAo5688lMNPpvWnykjV8n5 7zfvbtTaDvUOGkpmzgYYzyKAmxmzwfEZHwvPy4ijYjimUjzqlsN0ZvsOMyRGus07tjCj W4lN14DZJbZPbZnylLf+yzYc0zK4Zxl/xUG8lmAT0QVNz8Gc7g3qrY59YIYX7xv500z6 CjoA== X-Gm-Message-State: AOJu0YxrXW+qP+9yZOMnTKqrqfELa5p6EBA1MKhhl8d5WentoYgxytlG eGMy1EIS5PAIlysaXtcP46vfn4OvYBrWmUWD9QAANOyJSpN0Mdzvizj2x2yzzekGNv7caNDqHgg vibAg X-Gm-Gg: ASbGnctZSM4fBxfgg8p/nr61jkBSEe1y5PIDtRhxK+etwUac6zvjZZozp6gWrXLVg5l JYY9QXh/h+mvpmccC3l3YhHcZiH9Yi90vfytTt8R2Bo0nlwWY/ZzDKFUk3/LozfRZG9/S+r4kgc aAlubI8DsisvceuE1X+kMgbMWc9FEgPa9lDDuiReJezFE/J6qHp9q5IbgMh4v2CpFeBGUh8vUVL 9K+3oc0fcw3wejkaR4rnEQk2ZV6CW9E5Rc7WI8jTPthwnyRRbkCKaui1e5qOP6TZzYVWuWcGmvj USAJkpPaJvIw5PEGnnigP6lMxqoo+S4oJrRwjanC95iHOZxxHvGBs+uzanVLCDMGBJDoEKZr+LW FafyJHwdLTvQoLDeJ6ofxNP45Vfy/4T8SNVlD9mDPWUWEVdiqzTnow90yqQOFBGDJ39+6URwYMk kEGHrqgtxbDw== X-Google-Smtp-Source: AGHT+IH1eeAT8s6Oqma5zyC8EDC3TH1shCkQQPCskWKrxdp5WvgGWV1a7lYDQKl1J7lCQGcB9dT2sA== X-Received: by 2002:a17:902:d4d2:b0:240:11cd:8502 with SMTP id d9443c01a7336-24011cd8924mr7638015ad.13.1753603401960; Sun, 27 Jul 2025 01:03:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 21/82] target/arm: Implement dirtybit check for PIE Date: Sat, 26 Jul 2025 22:01:53 -1000 Message-ID: <20250727080254.83840-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1753603617551116600 Content-Type: text/plain; charset="utf-8" Both S1PIE and S2PIE have a bit to make software tracking of dirty pages easier. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603621; cv=none; d=zohomail.com; s=zohoarc; b=I7MdBMUQUdUFAiErtbXHIwyVR0FbYxlcSHDWZ06dwX/x1W5UGloYAWuIQwkXO8CySeQIG2jht8y8pGFBi40woGdWhUZ8hwzwWedVh6yde0AivS7UtaNr15nPEo2aS5IOwBWI6dHmNbbn/WjZhELNJoJ2jw/GealuZsjtFpRlUvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603621; 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=GWd/xEZNpqzr2re+HDg734KFb7ylW92QKYvsSGI2wwk=; b=gmb2bMw1KueqCKK9hVQrmHmG/jlx6k+sg/Im8NNPQE/xBiAzm3IKW2wtL1XEOWETSaN6S3xF7JAz7rbtmuo2WHeFDtLu2e6dyAWz7OeXUuhiGu6Iz0I61MJkyU1lJdcR0nI4oVRpD/6seABCLhidecv3CaO8ifIyD0emHGjKVkA= 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 1753603621425363.29903080471604; Sun, 27 Jul 2025 01:07:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwNM-00030d-9a; Sun, 27 Jul 2025 04:04: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 1ufwLv-0005Mw-1F for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:27 -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 1ufwLs-00047x-Ji for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:26 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2401b855980so363305ad.1 for ; Sun, 27 Jul 2025 01:03:24 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603403; x=1754208203; 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=GWd/xEZNpqzr2re+HDg734KFb7ylW92QKYvsSGI2wwk=; b=Vc9XfNiBXq8lWOxPf1Rbv4fo/Zb4odYDFaP5gVkp8btIGD4AUa//Ksm5+XsBttHMgb mDCaUTs/xSj+MDqUFbZ3tSFV3hGgxqhn5olg+o+ZIi5+WprM9QojWl3mrT+BN5iQ6NxC ouHYcFUgYbipy76gjT/Hjz4T3zwbZs2wTrUfZjl25HRf/lB+gy76ACYuFPoMfZfzAjws aAsh95fR2tfKwIGRkkLitpRl9s5MOduG4ANiyW2+iNrPn54cJZ+pD7jaFNSyN2dCsfWW 9nWRP1OpDvHE2pOSW2zoMdufRA57sjT5D4mlgsNA2f1uns86PbOPLhaK23tS8NcH5IxB lcJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603403; x=1754208203; 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=GWd/xEZNpqzr2re+HDg734KFb7ylW92QKYvsSGI2wwk=; b=jhhyx4LZ0zXwo5riP02CWQho/Ql7lMG9QWoNDA2PQw99huHveBvgVYEtr9wSjtnHoA Q55NJeUhB4Cq+C11av4mqzlu9bGzwangm7Xm0cP5ME+pTySjxW5Y9ts/lfex8GL4P/lu MXGGUJEKHiMC3oyaQcSD0+hNul7+5gOfejnCK6FGgRpLbeeZuJd5QpVGnfCUk5PptMjI qvVDNHrtNKUa8K/id2HFenvaODePkKIt1I5dNu4TxCXB8Nh31PQCQ80n0NTYg8EKqBEa fuviiAT/YtJrhhAI5KCCPiYUZgBST+vpQK/3guZjbFyf2DKbjhwSL0EorEojBW6vj3A8 2cbw== X-Gm-Message-State: AOJu0YyfHUiUi+D/8atKmlRQOhqF9FghTESG6A7coYD8tPKlq31/w7VS 1eICCGCQXxg3WBkVRFlF9a5PWoNTyqfSXVqZptGNShUSTh8GOijzf5Ldhja8sjOfTzjxmsO9Gyp bnRcC X-Gm-Gg: ASbGncuItk2LJ1Mm/gp4fGUM5mJBebCTi8OpYEASCGaJeS3CATVUnuWdSvLNqgZs79m +AubiOji8lYrtl02b+w8PpvbZ/VZzw9ZomtWPlArsYP9LLE+RQMFsNR172t2aVpaSSixPCIN2Z8 rham1u4wwR/UHPcVATZGsucVW/L5VJoCWRxif+vxcJc5PqngeFFx9ZKxPlPre84z7XEiyKTIVfY NlTcPUk9QRq3XIVa+7jA93slWjHs4itYUVDbJCroHtow1N7Fqfci4z4f/AUujS2zdnfKg7790oS wpVeKOEQe/6xCwBTG5RQO+HcIN5fd2imPQmyIrAo6B0EhvQQ/5CfML4eVGgGehMQ0mGCo9hwKm5 OMBv0hzY47ZE2UJQGBJWQeV7faQi/a75O8IoA8aNzuRZ8YhjqHNiQcEIwWnkffmX+M6rVCmptPE DuW98wV8acig== X-Google-Smtp-Source: AGHT+IHMb9WxuEK4kLQoowwafwOlbljK3CdNXO79VAWgTyQ4N0R5HuZ3l/GXTTinzvtc9iDNJj8qrQ== X-Received: by 2002:a17:902:e78e:b0:234:9375:e07c with SMTP id d9443c01a7336-23fb3171f12mr110025845ad.46.1753603403394; Sun, 27 Jul 2025 01:03:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 22/82] target/arm: Enable FEAT_S1PIE and FEAT_S2PIE on -cpu max Date: Sat, 26 Jul 2025 22:01:54 -1000 Message-ID: <20250727080254.83840-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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, 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: 1753603623582116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604469; cv=none; d=zohomail.com; s=zohoarc; b=I4YeQF2IqUcVdtru0uS9nS84MPEeqiIUSI7SPmMwYWmzhVCZjNkcsfhZ90rlWA99zNUT+1qXNq9VIAxkY0FdEsEXhiWgNJUrxgwC2kcmWg63/u9YgcFuAv+PI8nnkRvzW5jd02xRoNlvCUarHy5tXtowhFf6lMqwU8gKyhoJ0bU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604469; 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=uSHTZd/mS6B0hzuFKxsgTmFE8MtB74l1Qk2MWt1HjCI=; b=DF2MszfoGDF0yvkzRJmsEgLYfka7ni14R1TVXZFn7QA1yXIMHaSQ2d4tjuHIYmcC9ojYzkmqOVHOMFpd4gwI+/xx0AynQUwML+Al80vccbo6n3fmThzj4s0PuPm2VIy8infKjq96zB5DzJPPlQ1lSxW8wa4oxqpZD0q4NUQEyJI= 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 1753604469781987.7401340958578; Sun, 27 Jul 2025 01:21:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMc-0001QZ-JE; Sun, 27 Jul 2025 04:04: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 1ufwLv-0005QJ-Ry for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:27 -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 1ufwLt-00048G-P0 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:27 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2363616a1a6so27449395ad.3 for ; Sun, 27 Jul 2025 01:03:25 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603404; x=1754208204; 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=uSHTZd/mS6B0hzuFKxsgTmFE8MtB74l1Qk2MWt1HjCI=; b=TQC1PEs4BgGcHKDnEdL8AdeRSN0SMu66OyIKMQz7M+WjHkOgytOcwzRe1Jik4JDxcs 1Ua/w4tg8K1cM7tk4AUWvlMhpBFrHWQb3mU1zYrw9v+V06DTTpdBJqanFqH3wG0b+F+u GtRAVxAx4haWP+KyWEHUulfqPBjgRcyCB6ihj8f/Ig2TbNPr631dftl/NE0zet+XV1Sq 31D16QQvqIfwiqkAHq+/ppqqazBTDYblYgL9cBbEJOzDVdU2vTURSssLhZ4Tr4DuUkRj p4pMYlogEeffwkiefRpJzvlQINugPI7CKpZ0YoyuKyTM95FPCVRC8BARcTAT3UY/cQro uT0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603404; x=1754208204; 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=uSHTZd/mS6B0hzuFKxsgTmFE8MtB74l1Qk2MWt1HjCI=; b=Bn8eRHrizacTCYiKCqsncC8OSrARHzymu7AV+vEhuUUxbGpWvNWqwk79baOnLHHS/H 2vhZJBN2DzvOYk7f1HJ/MZatXcg8vfEwG8QSosvyStE5kYS3YQBtJuAuriGTNq5fsQKq hrPiRuh6NDL5MJulFzgIgeYAlIaGVDkcB+TxrBDweS4CY08GU/HznQLFlCRBKa3uehPT frAJ+V85xP7sSLVSc9OXaKwf2DFWInVds2kqvt303eS82rJdKsP6rOA75dmkqcER5XaW gsj6RYNhhWvuXwZ+NdZU80HWL4PLcm9KRrZsVfRdoj/w28/BCaBZipmhlFyDLDNEBCY5 qtvA== X-Gm-Message-State: AOJu0YxFW0GZAjIvGR0anZ0T3FEFb7tnOusEWeDqIWb+N5ZGQ4m6OUuU WJLLQK7m0TtBweW+1iIFo71rJgfyewencvtZ1QCM5LQCw7JpKHetVYdNT8zm5RaJ9YzH8WnnlK9 1qiiK X-Gm-Gg: ASbGncvc3pZhPCRRGflnujohv1UKwm0zXBbWl28dd8Tu63uH1VcKeVu89wEFyqf3MH3 1OXrFJ6DBxlPnt/bpuo/CgGI+XBz0bI4jPs/Lt8fGGw+soy5RHUM4lwIPk5XNRNkf4AYsOCa691 dcx9kv90ffDT8KDoJU/5JBIu41hRowypCqwbbM2EEubhbjXXcx2kNjLZg2apR5IoEwU8AxKSwyq +IXRvHYy3H+ADegRKmP8MYsE+PLT3k+Z8cywbtOlH64fJaQE5/9ipGlYVaDPw39/fsDmH0eeA6V Vgz/3Y+6/ZGIB+Q4yvop6YFvCRPypINRGUn8Kv+M4AoeFxJUmhXndzJaVLVeaCixgY1Kp3vmyzV izdrUbeC8YZkgiJMGRkwyt77MuGBTBMU1vjPVM3x2DfUEL527JOne5KfXkZBSaonYQGRFPKlLZ6 pyQbGppuxd3w== X-Google-Smtp-Source: AGHT+IHN97kUZiEzFaxmUgJNO0ePdUfUyl4d79Ib+Zn3CO8PG86mbgcPVe33WYe5I6K4LNAkKfFC8g== X-Received: by 2002:a17:902:d4d2:b0:240:11cd:8502 with SMTP id d9443c01a7336-24011cd8924mr7639755ad.13.1753603404436; Sun, 27 Jul 2025 01:03:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 23/82] include/hw/core/cpu: Introduce MMUIdxMap Date: Sat, 26 Jul 2025 22:01:55 -1000 Message-ID: <20250727080254.83840-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604471865116600 Content-Type: text/plain; charset="utf-8" Use a typedef instead of uint16_t directly when describing sets of mmu indexes. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604469; cv=none; d=zohomail.com; s=zohoarc; b=K2UZODPJZbkFU2FGcAa1cDQSTCsZpJc+s9toKDqS351vYAs345p6nPmaXS3/oXM00fbLJd3NidTRGzedMttGtnRto/FfSeHSzpftWuad2Wptkvoks31rmO/+ndH8hYQLtmtJvoJm5KQpld2p9yb17sfbdBI3Usp9WVbstshNnYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604469; 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=jlJ6FDp1q2NQgZlTviuGz87rhz20dNXg1agPJ/fUdpY=; b=XyqmNzPJPqfwK1Q3iJW/Of7cGHYSLRcHFWKrPFSy+e8/qAtyUrxt483fdK8+eUhwdKacaja4R6Padr7096nCfNjB0V2YGmWwtgiCBDXqcupMUSQSZNSiem6UyRRiibdssBFD4faDS8O8ugbO6trgVjHnlCfJ5eMXFo1dfpAULm4= 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 1753604469492281.64632289261533; Sun, 27 Jul 2025 01:21:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMZ-0000xu-Vb; Sun, 27 Jul 2025 04:04: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 1ufwLx-0005fK-4Y for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03: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 1ufwLv-00048d-3p for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:28 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b391ca6146eso3084847a12.3 for ; Sun, 27 Jul 2025 01:03:26 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603406; x=1754208206; 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=jlJ6FDp1q2NQgZlTviuGz87rhz20dNXg1agPJ/fUdpY=; b=lj/uK+J9yJUhcrvtcr46OcwAIm4K63erUNWGUN5FWl9Jtxi/AVp+JEik/OvuiAOBGC WURn2/EkVor6nS2xKUoccvYhwqse+JiaEifMyMQqgrCzbmKmN0dBNv9lJMDN0Gi2K95I RlINsOw9Otxh6DMNSBCi1BjUxDfcb0cIay+yu/PvS516OM1JWguRvLXOD2wa2OfYnqK7 XJpiH0+fp16YQWXr1QYtgHeRYEtMpte7/RDtLX3U4F8/fr4YI7A7eOsa5mcFza0LBWii 5bO4tuNAE4WfKigsd4pVFgrZP1MFqE7ZXV9vAxRtISykmtyla1Usk2d6czfhjsr+JI3e Zk3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603406; x=1754208206; 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=jlJ6FDp1q2NQgZlTviuGz87rhz20dNXg1agPJ/fUdpY=; b=QEEU5yWPTZrpoUx6sBin3OC8IE2gSdLh/1N5TYvFV4/EqC39SmUKV7Dg6/JF6kyW9T wjjd7d6AeZILDZoDU1y+l9e6J5f10kJK0w2nCBfVtsGtUmvNVwYqXWRwyhSNB06N3gzm ZaNd52VhyZk1e9K4d7aGs6NK8whvcJrtnlHDxmaVHmujco/gjGb/8wQTphp9QRAZ4rM8 dQcSF/GUC4GtapXsiyuwB9YanjCswDBVPFT8wrCq4xj6Mp6WRuJ/qEaSyfNxtN0Swh4i tSFyaiTTE9ZCL7Axe84/UdJW6yc8KL/P0z9PJkhEWG3X4xoUvZK6fn8YXyiLbcDfGTiK gcRA== X-Gm-Message-State: AOJu0YzyTe/KdoImWb4L9jgh/7DUqnrQiwvftBgglNdyY1JdfqshjJlp o8GRvIpsQNRpOJylX9EoK1pO0zy6cExf54UdU6mJhmuMS/h1v/bX/fAX9OmQekkL/AjEjycv4+Z gHqMM X-Gm-Gg: ASbGncsyHUd3j1ca0qWHx3uTfN6Cxm5BJx7RiTy6okGePmZ2oyp80w5WnI0LGvtj29E xv/XaUUiW0/GYA89fW9wIVbEbqcMNfnBMZDHyyGlqMwVucrL2spnIVd4iAF3NSlr+DBwJ1rz81t TjCDhz4DzOBWSz5dcF+KDJQXYhq7FnrufIeeE4GOGxVSYjOK4imMMqMZRCKY6CerB+abEOAurEE 3wBBt1dxNUGXV0AYOerXNy3Jl8s/JVMHf0UgRDWCQFtYXfse8rA5+KeV7t1/BLXXvb+5Qb9p96l 2KZH7gCZWOnD+9Knu7nA5xBi7IBqujSwADcDEgn7uIb3cj04xhwMDqNNKkF9h5cuMGoe8+guO5N qaLbUNR5M6TUfo0Gy9AY16sdLJZTSyhKccpqbHYxlt3iY7Ywor+YWAxedcCUfMW5jLSqsvqS5FG ijuD+8eYT3DQ== X-Google-Smtp-Source: AGHT+IFwnlPl9ex85Y1qAQIlHahJ5Um2Cb1c1wxF89A5WEIwgxzqx4+rwrcpDIfiHpSVHCTt4AfPIg== X-Received: by 2002:a17:903:3c26:b0:237:f76f:ce34 with SMTP id d9443c01a7336-23fb3082c1bmr120976475ad.15.1753603405649; Sun, 27 Jul 2025 01:03:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 24/82] include/hw/core/cpu: Introduce cpu_tlb_fast Date: Sat, 26 Jul 2025 22:01:56 -1000 Message-ID: <20250727080254.83840-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604471573116600 Content-Type: text/plain; charset="utf-8" Encapsulate access to cpu->neg.tlb.f[] in a function. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/hw/core/cpu.h | 7 +++++++ accel/tcg/cputlb.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 8 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); --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753603907; cv=none; d=zohomail.com; s=zohoarc; b=FO+J0kS7gCupE3CcG6Jvuzv/VelAdZdmBSv6Z9m82rG+5dEG01kLySA0814I9rhjLMC2hrFHetG/bkGLBARWZEP/LYZ7LCG9WwDBnjDv4Kcn327pdH5/+vqh5KbvR69nqtOYfjJyfbxbnUiuaW1/E3je0dppLMP13hxbNqmC9Tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603907; 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=6Lmoqg22csYQ2DFF2//zFesjPFppxznMHPDSWw6zVyE=; b=PilBF0IUq5/uzYUffCy46LpPo8dZsarZqhmYTkKvvwmACaHiVGKIstOvwprEHRX2mxDEKF5ZGNLSUlJFedGRaMcf5sAez0h7XaKBqjjt34Q8qDd+5sjtG5x+TUZ0nn0bOIymQr2MBA8yGiR7xONaVuia/bOq8AJHbaCRYNjaWG4= 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 17536039078671014.8098921152241; Sun, 27 Jul 2025 01:11:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMe-0001Za-BR; Sun, 27 Jul 2025 04:04: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 1ufwLx-0005pv-Oq for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:29 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLw-000497-2b for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:29 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-23ffdea3575so2211865ad.2 for ; Sun, 27 Jul 2025 01:03:27 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603407; x=1754208207; 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=6Lmoqg22csYQ2DFF2//zFesjPFppxznMHPDSWw6zVyE=; b=NNYt6gFzmDaVWv/n0u2egiGs1nnemCD7e1260T51ikjdR99RvdK1QhoHrIRqhOiu3Y TLn6drCZ701WW/hjroofzW0U60pp0HImU5OLBIabltc8652Z+zGrQlLSqDriEXNEUalt JSFc+mz3VOpuevOXy92BjBB7hk8mTETat+zx+PkSgYZco+XLTZIQxNn7IZFIKSFwZ8WF y3pJoy1e54g2MIqqKVymjZ8/kspmfC2NyyyjIy0Knv6c4N0GFA6cpVg1sAaIk/8C5cRT lHODeKNhWQhzI2h0X9jLijVr5Zy/bJcZwVCFMG+Y0xLlNXRYM2TNSwNfvi5J9TKM/SiE H6Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603407; x=1754208207; 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=6Lmoqg22csYQ2DFF2//zFesjPFppxznMHPDSWw6zVyE=; b=bicNTG5FFGnYfq4JS354vujOPm+731u3LsyW7/fEqTLo0HcpXvAxNWYddx0HEUAmAd PyhGm4oaHd8CMC6PbcIqcS8vwODbqa3HWetCVuYKMtIRVCRlJnRvDvy08jqJCmRspSdi khE4Neo9tu1ugJHdFL4iTK9AjZgLJhMKdM6e/y8E7rN2E4llciOjPCcIAtqNMwWm+Xsq p3MsWmtXT7148u7aDbVNlW+ZWm/SFB7dfpEfMhO8bP7mRFYKnxiioZdt5CnHNnAvgWad MwjFUt/aCUxlrWhQ96bUg9qB/DsYnPyYDZNn9aVzUpokqKKF6A3IdpFeUHFzAZbn7C+n eBuw== X-Gm-Message-State: AOJu0Yyqkfi+aUiyMRAXszDkGgZicf0ht4LKcY9DXXXaFQf7VUPq7rNL RZWQcXnWcdEJOha/yxpYaG81YGbUuPdJAkE4UCQDjM1of2BU8rERVs+jWVaaSgVSHZIwmB+MqMG /VVIt X-Gm-Gg: ASbGncvIiAlKKs1psAEWF6K6APRUpsvxXAN1DU/rsYhOycvSCCGPC7Wr/aqNgE6hiA8 m3+kHpRYrUHUPbkgxQrxYEUSbQQS1Is1L8/Uq/6QqPnXzASEuCvM6Wr4uTCCEjq+jxVvcmS0G/h xkpy74uPJxAZb9jAaqsNwnZceTMMiCgWfBkvsr22Cv+idbkPK+jfvfk/fU1PHXERKoDZj4Ss9tW 0UcTOOfqrz38dn+D7/rO1lWCWBiXlb1qkSgJ8uy/Og7HvistOlisjvlorcj5OrEdrKlgd2nzbMU j+rkmcnQ2L6XJUKxmAZETCuYaHinLtsejcV6sn2bA2tteD/D67eytiiZR9dRa9CsR/qiXQ74FMX e1SlVmi8g/Wf6Xek9NSswxI3JeMNkGfLm+f6e4CUfk0c4IIGhcc+Kx42xxIP8l7EDvnUss2zuLV /AtvYszzElrg== X-Google-Smtp-Source: AGHT+IEQPP1SILRmrPIfyCrWl9l2RoJ8pQ4La73nEkl3hpCZCtnjXihtfwdGY+gzUg8Q1Alc+HiPxQ== X-Received: by 2002:a17:902:fc4b:b0:23e:1a6e:171e with SMTP id d9443c01a7336-23fb3184928mr116965895ad.51.1753603406771; Sun, 27 Jul 2025 01:03:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 25/82] include/hw/core/cpu: Invert the indexing into CPUTLBDescFast Date: Sat, 26 Jul 2025 22:01:57 -1000 Message-ID: <20250727080254.83840-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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: 1753603909588116600 Content-Type: text/plain; charset="utf-8" This array is within CPUNegativeOffsetState, which means the last element of the array has an offset from env with the smallest magnitude. This can be encoded into fewer bits when generating TCG fast path memory references. When we changed the NB_MMU_MODES to be a global constant, rather than a per-target value, we pessimized the code generated for targets which use only a few mmu indexes. By inverting the array index, we counteract that. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/hw/core/cpu.h | 6 +++++- tcg/tcg.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index bd835b07d5..85b1ab4022 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -596,7 +596,11 @@ static inline CPUArchState *cpu_env(CPUState *cpu) #ifdef CONFIG_TCG static inline CPUTLBDescFast *cpu_tlb_fast(CPUState *cpu, int mmu_idx) { - return &cpu->neg.tlb.f[mmu_idx]; + /* + * Invert the index order of the CPUTLBDescFast array so that lower + * mmu_idx have negative offsets from env with smaller absolute values. + */ + return &cpu->neg.tlb.f[NB_MMU_MODES - 1 - mmu_idx]; } #endif =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index afac55a203..615675d185 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]) - + /* Invert the index order -- see cpu_tlb_fast. */ + return (offsetof(CPUNegativeOffsetState, tlb.f[NB_MMU_MODES - 1 - whic= h]) - sizeof(CPUNegativeOffsetState)); } =20 --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753603697; cv=none; d=zohomail.com; s=zohoarc; b=E0AAEWZJ0A8FOxktFoA3dh6/b2kTxNMP3UcREoLas0l2PTNzHHNh7WLDE5vsNuWgQ9Kx0MTG6KjO7U+zXRV8INV6Soy59zl2A0wJBPEB1EHgJlynY6ioDXQoIYYY7IURJFC187mwsssRKyHiIjEJFjPhHc3TIt2oCNctq5U+c9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603697; 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=5U5uKtt0dYMHATom5laLyD9UNdX3pU9hAWzf847+404=; b=aS2KRyJ22Ie1mRXrdMoyiC1ZCSutJPHedhsonyiHOTq3rqVc1erXEjZIR3Cj58RLtOyYhEDIovGyi+YA+iaQtEn1EF9qZcf6VLqRhUsz7Q06ryMsEohbsSOcHRGjqfEW35nq1x/30/yqkPW/D2MubGelg0oQkkzz4J3WCkl2Z84= 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 1753603697672893.3571430690218; Sun, 27 Jul 2025 01:08:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwOM-0005qo-O2; Sun, 27 Jul 2025 04:05: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 1ufwLy-0005vJ-NV for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:30 -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 1ufwLx-00049Q-5U for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:30 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2352400344aso30514255ad.2 for ; Sun, 27 Jul 2025 01:03:28 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603408; x=1754208208; 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=5U5uKtt0dYMHATom5laLyD9UNdX3pU9hAWzf847+404=; b=P3ys4EJDvFnUmRWC1BuFJ061dOlzMO8jA3ida+AsAlqNPPiJpwMbGmVVLePnss2Fv8 UprMS8wzq/IGoZ5ObwUFQPnLsFWken0GhIMqFGtBXfQf52vwFRNhXr4sXDpxi4MJSg5V pM+LJGpHQzRjMV0bSKzzpFzVzsGCJ4eqD3zlegsWjCXmec2Mnj0mi7ZrkuPyoTXu++Dy 6pwx/NCAgseLfRBxO7Gb0JQsUyEhbx5DZh7HaGYdAv21lU/svdjEYNMeAbEbwh7gbAyF 2/7IVVyfH87Xd3AC8RH3xSWBIQmHhetgX0goSLjR36Qq/zjtd0XO2Ydkkxu3+WWSjHO9 oDUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603408; x=1754208208; 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=5U5uKtt0dYMHATom5laLyD9UNdX3pU9hAWzf847+404=; b=uU8GU0xPQj9uQBBIlgsKWpZya7iN+8Cn4cktVMNVHeBb4Eo9BbkCL69N14sXaA7Kp+ 821P3lglkTlfBdfNGLFu1BMOCSd1gapLddPztXFkbkvJjV86OTeV5aRDIFER26XnpPHT JRwvsytE0zesKDVty0qhm6BccMjZ3MeDKZzZwF994Ab6KOeZ8eKH9Vr+C28OW7lYwJIM AfeIczMXMiw6yeUx6tTWjAo+5AAX2OuymFDWhxQ/DApLNAOcJFoQ+xeVUKxP62QNoN+8 DphTMT1Pay1w8EV45o2Kkcr35roO/j+IqLk6elqcc2j7vjelfwUB5qSMWm8AL5+bPaV2 qVfw== X-Gm-Message-State: AOJu0Yz3jjO7xR8wJpbThrBDwaJII67IZ50Ug2RIenU4IUdQLMIKG7gF UHx/r58iOU3dhus+x9MgJ0NyogV0H+dxaWRDPGA7U5MW/GNtbWhRK9//xocta9jZwcDfQJ9vhJL 9MtL3 X-Gm-Gg: ASbGncsCeI9yhDB/zypt0I+UVVES8jbsmCpLVZMWtl6hwm0hPumPjb96kcxKpeTyKL+ NBjd8TdjphGg8tH7te+925rwP/yc2cLuMHX03vMbNnAo28ZeTnhJHqmnGAEwkUfsW4cxEP+vxDy T1MHs60zj/Y5PNTRGMr/JyrGeDMbnYhEEx5jkZa4x2ikvtuUqkgS/VAHfdmkszYIu8dDMzI6tnX dSpOHv7pokE+OYlGoFEGycxkFUcmvlxWB5KAu1Z6FK9W435Z47V3er2994ytcKBPdX7tJNdBAGE AyIEMVI8L2JJyrJsmwUe9Kk5zXlN1R1p3Blaj8/5m+g4nX824qnGXg39y4dhWKN8E30RGAsYohk VGsuQHJ/j9cC6NsRCAIuw/AB4Wav70VBVgjfYzPDwRXwnn/vLxctbLadQhZjRIheS/VDiuiTYkE AnAxYt5D+3ag== X-Google-Smtp-Source: AGHT+IFmwitUmt0qFVTKUsXi7RNSAUSqNuGzvb0P2H6j++ds2E/N1WCiJb9mUPHQDo8IpYV5d/t7Uw== X-Received: by 2002:a17:903:1c2:b0:234:a139:1210 with SMTP id d9443c01a7336-23fb31bdf48mr120549785ad.53.1753603407889; Sun, 27 Jul 2025 01:03:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 26/82] target/hppa: Adjust mmu indexes to begin with 0 Date: Sat, 26 Jul 2025 22:01:58 -1000 Message-ID: <20250727080254.83840-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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, 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: 1753603698030116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603612; cv=none; d=zohomail.com; s=zohoarc; b=EJfvd3rRQwkAHFGoLwcb6B5DH7maeK5tf1rY/UCioMx7o07EES4/n3TttbGna0b/Ha5Z7IygULn4rWN8z7IxnYD2IxnJTXELd0AKNMN38vI8veLwxxC7tzQx54PhTiju4hxGBaJYqqRDUTCx+HfIru8NojVrTB8M3xGqE096QT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603612; 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=aOJZIZJj/tIs5sXQuR3l8mzb1hhaa8gRwgUU6Thg5os=; b=oIWP2RcIZ52YeG6g9LJGrfBo3BrLTDZ+ATpJwglhR9B4JVHaAirBP7lqNRHreu3qDKAoXvi0o3b+B9n9axr2VFWTfEZceiK+0ODeqOcRduut5LRt5p02zWnuCDnd5d/PfHTj0FTOGw5j20OMiTl/oiT5WUVqY/VqXRIMLGYHO5k= 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 1753603612693578.0116217759956; Sun, 27 Jul 2025 01:06:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwOk-0006zq-CZ; Sun, 27 Jul 2025 04:06: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 1ufwM0-0006AT-6b for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:32 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLy-00049y-IR for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:31 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-23fd3fe0d81so8010535ad.3 for ; Sun, 27 Jul 2025 01:03:30 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603409; x=1754208209; 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=aOJZIZJj/tIs5sXQuR3l8mzb1hhaa8gRwgUU6Thg5os=; b=ngAtlPtsJncqr06iep+oPXpQHy7aKiXvkQ+7gqQqUXhIYA1GP65VoM64zJozqMtkba 7FRBPzeL6nIvrxtum47SwdYTn/GELQ9gdcZd7fHo4LE3lABak/rgGdUfbdbkKkBL1s9B KzOzP/cnfaRE8leH/Cn98HIz7nGpSi24S874J3W6l4SNXZoL4EJ/Br/2PdzwnaBsXpI9 MnSKbPqtVHn7dkQYlHfflsHTO+x65UfW8536X0rEheFlto/SwYXNozK01fd/yrUXqOYV WTcsKyOG7ZTnfK1qJRqiXvFuVPvqOx3Oad2jmwt3Ar1WTlTgfFeFCYYpjd4OZt6+7fsn svPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603409; x=1754208209; 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=aOJZIZJj/tIs5sXQuR3l8mzb1hhaa8gRwgUU6Thg5os=; b=Qu3ADAHmQdaiRtf+0Pngfuuimj47mBmJT0Pl4jtxVro/HoK2enfI/ry5JfFhR/9gRM O0G/K4WU46RsrNtqRPwSgkmq+hIN1NygYL5ru+DtIpcSV7vqBmLtfSpjVXk5kBztUZ07 DjFmcBmj/FKG7/lt+xnhNOIi1THL/T1acLIl2IDMmzcL6g3x5GIWA60mOGy8oxO3omwF S6/3cRhgZ69KJglfp7TbkagtYyb6o8lBaCUCv9tLvoP/N4FbZ6MqDoS6KTFyyzmm5Hyr R8nAhgQaJqqEOdk3TTlBeeQcLuPRGD1nJd9d7IOLU/Db/EiPNNI3hoPApcMhMGypMCRq G5Uw== X-Gm-Message-State: AOJu0Yzt9lwRTaaJn4Sof9404KTKSkzTHRWeFAxYs6NQa4IMlk0eJI8W Wqk4CR3lfldGKhew8ECX4Oyo4OzV6pAIOmesjcQxDCUHZNtFmbr6prDfoNdl8Yws3HZCB/J3dbV eZRnM X-Gm-Gg: ASbGnctFOJcKXbKJ7Eb3MpT+NqTo5vuL5TT78ckW2pUibcffMx891sqNOGnQ2qfokU3 WlqdbMJ88FUbp7KLIUypChCtBy3ly76PTeRw8xsJOKsYw0k16UDrnhIdeizeiyBLTVnsi7asRma f92kSVdGJI0eofm6WpePpB1f8XuiacglsRjOljQY/txBQ/jvJEs0brYLzNaD0XdtSr1YTF1QK6a hf74GqCoC8RrXufVMLYvfbukJLgvnrPIjOFzqLzLBPIY/mHO4A4ltithEX4/ifmcSkR+uutLIDV OFMmwqMkIDoBhPrbJr67HrTjiWMUsIQaero8LQl5GTG06VnPZbXuOIbrVh+CmQqwRx0SypzySuW +Fxyk1ujge+7J86XRhE4W3emobcWOoQaJRli0uz8Yt4rzT7aUxWAT0r3Ij6wXrKOabJ+7omGspd 8JyBjve95EkA== X-Google-Smtp-Source: AGHT+IE38hch7fbzFLmFmhk0gVXu4FVu04ds4WO/+HboMxMk6/MfAwsZjKFErX691bsc8n/IpFVfGw== X-Received: by 2002:a17:903:2ac3:b0:235:15f3:ef16 with SMTP id d9443c01a7336-23fb2ffc4a3mr110180555ad.13.1753603409284; Sun, 27 Jul 2025 01:03:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 27/82] include/exec/memopidx: Adjust for 32 mmu indexes Date: Sat, 26 Jul 2025 22:01:59 -1000 Message-ID: <20250727080254.83840-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: 1753603613669116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603937; cv=none; d=zohomail.com; s=zohoarc; b=ArZjJi8Q1j0ePnMBWWS+2GP0n26rlEZuPgtopjYjkduViiur5F2VhJGFwb5D1lx+Qr1chwq1UZA5YZ7h1PNGrfiFuuxCNVZVJtr+4K8+FYvg2CZRggA0H6V93hALVX3YQybJ42AHY5iWnzGjzOIRgHqv7SiITV8D6cR8EoYBvEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603937; 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=TMPqhlIvVePcBqPr/zfm9nD1xzcakWTsu9w+PFYmzes=; b=SH8D8uUYswfjrKCfk2QWlt+013ZPtog+cv6HUaj8ePMpXuxV4PMQ10/AA9bUsPa0ojvHKP8Egjo3uzSJp8qJeyjxJzcmP8L2Z94nVv4SFSJ8HSgJ+6Slj2V/I733HiXjdcyI6zqKc13ZElFfZwWXkjq6JH8iOWVbbuOVSMllPDU= 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 1753603937272604.8449575018076; Sun, 27 Jul 2025 01:12:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwP3-0007ZY-J5; Sun, 27 Jul 2025 04:06: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 1ufwM1-0006JO-Ed for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:35 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwLz-0004AP-PW for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:33 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-23dea2e01e4so45472345ad.1 for ; Sun, 27 Jul 2025 01:03:31 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603410; x=1754208210; 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=TMPqhlIvVePcBqPr/zfm9nD1xzcakWTsu9w+PFYmzes=; b=gm4/dkNneI8Kprt38MaFBzB0bzpa0i5B366pQqhav+FMI7T1eT1R0hxyhpXe9xQGdW sEx/wYM8YKnMdu/JAEE3B39JhSwkHKY4BuTli9Ujca2W++EQmq41vaTR8yv/4DE/U01U Xr4TMEYPGLwmueNoTYS2FjeT2iiAbbsKV+HLtwktNAZ5vP3j6eTeOKVx8axQXbBvYzcM 4ATUff53WDyTM+Hx1JNP3Y89Wjh++G4HVTaJuYOtzuJsSTpRV6Hz134Smsmfdk+XrOsJ G0+ZRLDoMXPKCSSyopeyWlM/nPPQ0c4pDbm4Pk3zcSDHbv9+WNeYzDr8Aox3P58duzil a+KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603410; x=1754208210; 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=TMPqhlIvVePcBqPr/zfm9nD1xzcakWTsu9w+PFYmzes=; b=HTbPKIuVpvbpdiUzc3gFhRzgKf4bh/JqJZslCx0gY8bX+LyEQAe9plZcodSZu/9Duv AR1w5Bqxcj4JFZqMx+GCVbb/1/qg2VL40Ur81ByFCogOMSsu8JG01V7C1R8HI2GXcTga My5xlOuhlC/CAWYcIOqUnS6maMz1mRrCcv5qlj+0B75GF5i4SI2wypEl8z7QisgodGR6 JZ+SQcG57LTknQ/QIucBji5F4EuOXS+7bZjIwNBazVtytFdh4ibK8cblxMNORC2UJyUI Afb1EulkiEVFz0rradRRolXFfgdNw6r9+Ie/voLBZyhxlbLmQd3x9VzWxsJcP+1oUvkN vpGA== X-Gm-Message-State: AOJu0Yxp+OP66JO/K1XDR0UEUgBLWTWUHir+T1jN677lRor2eb7zX9o0 tVfrPJlkCKidd8/ZlzvIHmDo7YgNxv7p+MPRGSB04vtx/W7GKgXP1CryUgSGHnIMruVQhfUruVp mGHHw X-Gm-Gg: ASbGncvC0lpgvJqIHJlexnRP0yUuJjISB8GtdPcp49FRMVxIZ38UqxdINgcSw0KKmFD 4Bcn0/RCLC6h2vJK8IUA6JXm9Me8pAqupUv6CJtpl9q2sHI0KKSVWGT1LuWPE16FgDIox2v5gR5 3FU4pZH5le6tuxicUgDuo2XvuZhQXdoM8US/K4mvOdebIRnIQ6SuDyyC83NOsqWGn3bdwf8BLRw O5XRwRQHY2sQfybPqoXdLLY8czM42AQZHVcbDwITuQ2dYMG3v6DGWZLXRAgCqjkQqW/l6AQ7/eV 2y0wetfgvlSPtaT+cV/DgWad4teO9r/ESAPEMMfgTvGq0LlTg7Kjit3d4TlS/u5GFpgH4aUyBYA y1BXNyvqerZRXd6ChBhR8MMaOld0LDbqzPrnPh4oYpNgGsIKvakblPTzfHVmO57J/qjsegNdPVs coTudYMTBEtw== X-Google-Smtp-Source: AGHT+IEj3kNZcHnsQJUHZjOnzE4zvkn1AY6MPkHP+bxMldIPOTC9x6UwjNYtBvSg/cfDcMNZndzfow== X-Received: by 2002:a17:902:ce0c:b0:234:a779:47cd with SMTP id d9443c01a7336-23fb2fffa92mr116055315ad.15.1753603410479; Sun, 27 Jul 2025 01:03:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 28/82] include/hw/core/cpu: Widen MMUIdxMap Date: Sat, 26 Jul 2025 22:02:00 -1000 Message-ID: <20250727080254.83840-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: 1753603937702116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 85b1ab4022..a95559c538 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 02:14:15 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=1753603749; cv=none; d=zohomail.com; s=zohoarc; b=V28DMhP0tWUKZcr84l9YXNKGoirO1yBaeupNeSZplt83XVohBAqaZIGHGb8NgNumIO8ZKvOSyFX4HXTAQpImOJljW2IlPPxSWUC0l3yn4yyI+qkJBQbycUEhEYSJNYbBvj+MoZE6ev3CIkPJri3cBE7vIv2Bpkyh/iUB203FUZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603749; 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=WMSUmdSDMbwqKWFfFGyySffyaMLsl4UrF41r34r1pTI=; b=dyjBXC3ZJmamxgph1aM968HWkPvKXzyYS+tA1+jqK/tFwh0PmBR6n0TWUIvwmi+VKbaBr/ZHbNEKLmAdHdMwmKBkth9pTYorGiG6P7fhrS3OERW+VQj+xqaiHesJEFgC0Hh/fc9j9LIcgoQHPJDXTEM/bOsWxXv9w9Xo72YEAWU= 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 1753603749842221.03523309857565; Sun, 27 Jul 2025 01:09:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwMv-0001wa-Rz; Sun, 27 Jul 2025 04:04: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 1ufwM4-0006Nt-0G for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:40 -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 1ufwM1-0004Ao-8d for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:35 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-b1fd59851baso2508554a12.0 for ; Sun, 27 Jul 2025 01:03:32 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603412; x=1754208212; 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=WMSUmdSDMbwqKWFfFGyySffyaMLsl4UrF41r34r1pTI=; b=l5FrjLVIq93ggN7SCpM79k3c3rNB1dtLNZG+MNEDQE+kPQzP1EqgTH6n0p12CV2ILt mRvDyThOUrJtaEnzO1J2izH7IClZrRYAOWuM/1ld0SVJOrFNkh3qoxhx6EsAGIejOvcN SxEh6JAueU9Q/NMU060cmBKcR4x96ZXoq6/oxhDY1eYYQ4UCQ8bTOKOUZ9IA3aOCYTv9 6lBlwX2Qws0fMjGoyuqdXOech0RcEos0zkZWl5gMo7l8JYk1b2fXX3k2o27FW8UMw+Gf uneawmPNhiuz5XlfR8X6jGcrSLfUkVxIW93Ogy+QTELQXKEoUEnJMCNWS6kt4+D90st3 32og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603412; x=1754208212; 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=WMSUmdSDMbwqKWFfFGyySffyaMLsl4UrF41r34r1pTI=; b=V1F2DQI6ukNEnwjgxGT+2IuFC/iURurNjliZcHD67mFu3a1o+Z0425KHaia6y5VC6a GQcbyr5+URehmbAh1ZuM9WeL5K4yZ1C/ywLNHMg811ij5P6RU5GvkL6xF+lsilNvQLfV mubhG+lNoLjcDZvgawivyK2FCu2sSx7LnLCCLeSXZ/wkZ1YrCarbrYA0S+jQjAiYRTEk 1oxv96/f1tAqqdQNg4CaGzA9Hzwnfvm4X8yZJXuM9zD+GqWNyq1GZt6VUNZXbpC1YdJk RfBvrOGgJoXfvsvrJePcvrQExQXto0nYuuQUyS6JeOFQmOnq5WoqnprKT+FmQbfqjtjG gItg== X-Gm-Message-State: AOJu0Yy+BzL3e5nUUDslaHcdIhvCDQku6frvFA9oW4FbHv26tURIS8bf 8rXGLVtPj+xbVbHG64HNVx8OXm7AJP4zwGm679TGHc1pZS3a3tjOvOf22XHGR6Tyft6Upsa2KMi 9CUON X-Gm-Gg: ASbGncu737mOZX+7/1iBrdi2dR1dlrh/6jCs9BB1nDklJCHnawYELNU30YwfTNcnsl9 fJ4CTParlp+iu+6cOGFCeu8lIQhPSAj1gdocOW2NOZTrk0FPSaZP5J/kSs7bM+hvxqJH76d+PAj FRY2EG8IvMomIwg+BfWyWRbUW9iieRUTvOB6VIk20FkHX3SMFerCtnUquDerzEI0ALunRS/HFLv 4ZEAALlfNdMH29VVauj8luYgifEOg85fc1cNm7y3Wu3MZ+AFsKZaqnTjOt9C5xa0L52txzwLJmR NQP3MaGEXzPDUxFYs0/q25XLIelnCaRMG8ytxa8q/4NyWCzv+xFQiTqWeMQdyZefbVXDxv+1Uvo tjA6M36JkgjKS9bCF6TMOy8rPW5JMDMr+Ug4tXUfZ0MhY4xmSWm4pYg3uwxbDkS+wLo4ZejIYLn Qy1rx+jL8Fkg== X-Google-Smtp-Source: AGHT+IECoX91jxqsfYZedMTR8Inyri3OvEQAzc47FZh6EFgoVJXFnk//G3VRJ7o5i6nkdmvdpgMvmg== X-Received: by 2002:a17:903:283:b0:215:8d49:e2a7 with SMTP id d9443c01a7336-23fb3132269mr117947905ad.50.1753603411690; Sun, 27 Jul 2025 01:03:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 29/82] target/arm: Split out mmuidx.h from cpu.h Date: Sat, 26 Jul 2025 22:02:01 -1000 Message-ID: <20250727080254.83840-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753603750604116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604184; cv=none; d=zohomail.com; s=zohoarc; b=fUAsv59km52lxNZ8nWrgEcobdTOsgfOT7VLuiiLEl5fmC8OfycKdlrVX7HcrjVQr3U+DLCP5LJaGxPpVA/qbQ4oWD1h3CBm68I+rHFvjLXB9DZkwm0iUYUk9E4ModdBU1d7JfcfohAJjTee4ncYgcWODWblr/nGECOBV4+DfGyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604184; 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=M7NeX1QToJsoLekcDUKBPtv0jG80+JImaIT9zuG4ofk=; b=cODsuxXhaKGmEL2C1PD6ClO5qFqxE9N4FKPNwEAbSiB8lKbIa309Fqq199qv0IoVV7pO7AGeh+FB991GeLaezPex04XZkI1JFtloQWt+eb1/a0IYnbj6lvyTgwsBxp+4wnWqZf3+KpQM9vkZIBV9bxoOAQ5W5copI4g65yF/r4Y= 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 1753604184049462.78341824790937; Sun, 27 Jul 2025 01:16:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwP9-00082d-A3; Sun, 27 Jul 2025 04:06:47 -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 1ufwM5-0006O2-FY for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:40 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwM2-0004B9-Em for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:37 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b3bdab4bf19so2937929a12.2 for ; Sun, 27 Jul 2025 01:03:33 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603413; x=1754208213; 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=M7NeX1QToJsoLekcDUKBPtv0jG80+JImaIT9zuG4ofk=; b=cyTC33CK2X+jBNLIFXmXeMZqyu6T6q44t+mb22sbzkuHiL9x/e1xszSMFvDaI8Cx/1 kaq3exvSwHpkZr2PHsYwi1HNQNKKWxRKGt5TCYDCZcqI+5+3vMLo2ua2MxQGscGNnArr JnodSJdIYwpEdYutZ2jjhmReoQnRK10DOqxI50AOJZ5aAvtmo/kycW8Z1MQgBqnqu206 rH7yyPKki59exbhJFDpV/NW7kLi0AvW7nca2ZSVJ1/OUsxtMW1pTlcR72G+UBHJhUV0R faMQB4eIAFrcEueDxSMhHhRkUTw42EadPGH+4kFc/p/1nTw2NET5rySglWAQwFxrOubd +XUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603413; x=1754208213; 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=M7NeX1QToJsoLekcDUKBPtv0jG80+JImaIT9zuG4ofk=; b=LSk+sTPxL9Ku/qVH9pUNc5hHAwEbwxpCkqkdYZwuEr2LmnGeN5s6rZJzKO3Ro8YmUb MlQraCzytcimgxK9uF+MlBuUaD78q8EhM959RKC52pd4q9Oabl65LtikA2TBCrdXxzLW Dw5XKtybypdznJNZkZYyDwYghQOfuRys+nGj+BUguSnniIV3k4KVfdxZ8OaJyd7s8Prr 3DyUzu0lrkiSTwBz5xmO/eS0TANFfqvEkVsGvPkNZlsPyX9RezjseIkWnYB9p0EoPPV8 p81dbguxAxaf8kP9j3alBiQdLZaZWsVeRZVbacPs4691mrTRc+VMIuOUBwhG2mmRY3YV bejQ== X-Gm-Message-State: AOJu0YzTy+fuEm7vEP1isoTfMH8+cebx8h0X//Xfop66A5CUOCIgUSJi I+fKywuUjifJ/SK0VKWvg4PAniuImImY+30Toom3ygwczN7aFaNXeJV6MfM6UP8hgV6EbPF/mL6 NAfe/ X-Gm-Gg: ASbGnctd0mJe72bze/BmfPO0pUPvjx+N8CpDgWw1l9fxaqIwU30DARIiWIw7sacvJ6y B64dk09gLaSGqllxiDaJEbRSNpwMsk2zldyffjhpMpQLmEWGfxvv98iaX9OzYOiIPvtoXNUOwVy 0AkR7TunbbZLVQTwU6C321pzaA/VACQcRp50rCH6l48NxJtEub9Evj3P1rcvCh7q6xZMIZYw2kc SOAJlsMkwrZKljthwmQ2KsSeUQu6T3y64T0bj2f5HOD5pAdZ+f7FNBRyAuFabScMu0fp0/0MQPG HfWVQqcb/D//MLfspR/7Ok+Ce6vxBuTeKt0iPcBZsdHOw/OBHPzP0/LVTdj4ZBJW/J7bFOjwZf9 TO1WzVOTGikXBRyiedjNpHvObw5y7Xl4LTcpefO9EzqKcKrlybFoX0Ubolrdpdhl/3/XBLKgKdl advRMisQA0d+ndFeXtFUsZ X-Google-Smtp-Source: AGHT+IGlcKzfKAiQrqsWsTl2NS9J+91egh6o7Js+rMydJxytkz5g6cSoBduFp+udUm6onUOgvZdgZQ== X-Received: by 2002:a17:903:22cf:b0:23f:f707:f97e with SMTP id d9443c01a7336-23ff707feaemr36925425ad.17.1753603412820; Sun, 27 Jul 2025 01:03:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 30/82] target/arm: Convert arm_mmu_idx_to_el from switch to table Date: Sat, 26 Jul 2025 22:02:02 -1000 Message-ID: <20250727080254.83840-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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: 1753604185695116600 Content-Type: text/plain; charset="utf-8" In an effort to keep all ARMMMUIdx data in one place, begin construction of an info table describing all of the properties of the mmu_idx. Begin with the access EL. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/internals.h | 3 +-- target/arm/mmuidx-internal.h | 27 ++++++++++++++++++++++++ target/arm/helper.c | 27 ------------------------ target/arm/mmuidx.c | 41 ++++++++++++++++++++++++++++++++++++ target/arm/meson.build | 7 +++++- 5 files changed, 75 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..35d41495cd --- /dev/null +++ b/target/arm/mmuidx-internal.h @@ -0,0 +1,27 @@ +/* + * 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]; + +/* Return the exception level associated with this mmu index. */ +static inline int arm_mmu_idx_to_el(ARMMMUIdx idx) +{ + tcg_debug_assert((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 154bda3cd4..a97838a04e 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 02:14:15 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=1753604548; cv=none; d=zohomail.com; s=zohoarc; b=Iv5SKImzTT+imZ1c8dJvF3kl36U32q6JSJxOpAIRoRZ215CGGDEaa6v3BcwLUmJhjqL3IzVr/7C+e22BKOa6wF5wLg0+TTc0Q6CCRERQFX4HUm8L/UV1VxlxvP7z/vQYH5ImbzRzBaNukGss/qpjJz5CZREtaOwpnLT9JzrR2bw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604548; 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=hMdapYeTXQMq/7/SV5QO5q/aUbpfOJUhhXVEaV+Zq1w=; b=Z5tBQSO+TLr9GY2/+Y0ONlSliIicg3QmYqpeMb1uqVq1HVxQsjBiax70KNnCHPxfwXmgoDmLbNEU+T1eAFSDozO/q4yy/rn+CpfwdaSDKvgylY6uNCkrPH2GEw+BiTiJfy+J6OtTmAGbuiO8tzt5ktrcZuzasXVwSgBb5gFLksA= 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 175360454896935.98976354226534; Sun, 27 Jul 2025 01:22:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwNV-0003NZ-FJ; Sun, 27 Jul 2025 04:05: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 1ufwM7-0006OH-A3 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:40 -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 1ufwM4-0004BO-Gg for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:38 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-23f8d27eeeaso33828105ad.2 for ; Sun, 27 Jul 2025 01:03:35 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603414; x=1754208214; 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=hMdapYeTXQMq/7/SV5QO5q/aUbpfOJUhhXVEaV+Zq1w=; b=vtkuZR0k47aGWS1z9qXGXVUvuy6i/GII9LNaPJyBsrp/nR2u43oDwj87cROApm3obt 5C+xwkH9oEcJeLDxuNx/n+GeBMJMm4l83GDeaBHBvg2cdObEZTW/x7+nAb8s+qblnpxH WQcfbFqMe3gWZeguwUe8zHBchJ7JdeMwU80oiqKSt/kRtNBEw4KzmSXJbZJVRv/aLvpb teg4hhCp86nMJpFoRQ9UAGq6qOS42VTuYjp/P9mqf3npPaxm2QUZrXoTsGavyliEMbG3 uZiwJX7ViJPKuRwEuNTEE5lscFReU4xp9QPwBI/UdpFrLZZz6lebNDrPoNRBzjurjfPL KCSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603414; x=1754208214; 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=hMdapYeTXQMq/7/SV5QO5q/aUbpfOJUhhXVEaV+Zq1w=; b=OFyIuZGZV2im+78pEJmp/1alFmj6k/4qFA5D1ZC5N1tZg7sG2HuDJutHYGCxf2+ARS +22lIW4ZLutj/dbgRV68Y3bR9popcdtneCXZD5OFpQT/EDn9uKFMYF6wppsPe08UJlZk 3DUN06bTELnY2CCG9E7zokfpcarT68WsUO67fZv2bM/depZNO5+GrlBwyOTccasMFUNg /teTa/sEv99SnCvkDTh08KPFmB/m7cfEclbik+tvJL5V6GM74yHAtntr8l/NRSMqKC5z dDsa2wwDSnpyWo3t4aSaKGvvnrP4Lwp4XXS3mOr24NdM25jYzupygWUOx46DAIC2dTaA RJjg== X-Gm-Message-State: AOJu0YzwDd3/YXaVyinS4DDeVK9FZWKD178iTPTha69VDhaCV/Isr6M2 wrds5rKQ3dzJxwc/VP9PAwDrodJxDz5oSxPVPFjIyA+eZapHSU080k8FL6qdOadlKcpyRxX2N5Q l7e/F X-Gm-Gg: ASbGncvHXjz5En4MpvEcZmg7yeDbGS89mvscOCD5qomLzd5/uV0f7TOP5aK5oE9hoo9 vN4ne87T+uZuPqe2jMi76u6lOqJ9/AgiVKGCvuYNZ41okOqmxSAft/3M4FsAyx4xWyofNaNTGws sbroqNSK+m5dMII8dbKJNrNqYpsJ/6qses13/KbPI1FnqynrLyiv7o6CNGboNYHYKCBk0E8GBQi N5ooiCWvTcjPgVWr9Wf7+3mDvAEPtkqrsWtjOFO5Ww3Ee9YzrVktaeiKtc2ATygSC7G0y3WthXe vifGgHp3ng1/plojN2A6zzYYJKHJjbUBMwp/B0joBVubEwKMD/EhbX/TUYMvczYxCtjz1zGhi4f OOKjXvreK+4uNtAnpb1zo25kB9NENP4ZU3e95Zvg610/4g/oq/EsuySAwl566QbhPCapHqwlBVV hlmAp0GGeSEq9ueBG06MDt X-Google-Smtp-Source: AGHT+IHzNivkBwhQ7sQ+jc8vSxfmi6LFD/Ei5V0Dd0x7j9NM9lWywS68xPS+AzhRNdsT0efEP6Wd1Q== X-Received: by 2002:a17:902:d4cd:b0:23f:e2df:a13f with SMTP id d9443c01a7336-23fe2dfa232mr58530565ad.29.1753603414481; Sun, 27 Jul 2025 01:03:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 31/82] target/arm: Remove unused env argument from regime_el Date: Sat, 26 Jul 2025 22:02:03 -1000 Message-ID: <20250727080254.83840-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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, 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: 1753604550288116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 a97838a04e..461572f918 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 02:14:15 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=1753603627; cv=none; d=zohomail.com; s=zohoarc; b=l6IDS74DPNmsJoUxyM9OaJ0mjHU6wB8+5961ehgC7VcDXaxV5T67XmrOrNecBjKW6KGVDlVvO4S0vBfFv/3B95s1nXtGMmb1sY2CesukhnGJBRysKzyHzMb9TFk3Z1oBtp9nT38yQlJsn2dlmClXftnc45MmDjvExmwOxrYXt6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603627; 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=TDl4qI49SpWW8VIqpAekGv5IcctWpYAVkinX7OmWaPs=; b=LNxLC/YKEd1Ubt5zljxR+p+c/Cm1gSm4PGwJDPPNmi1Av8ZFonASUuVYGoNhHqdSEUbeApVMDaTZJqULdSZhAWr1ETeFyoswJaujmxwNJx98kh8NXsdka7NRJ5AH9lwWKfe6kOh/r9oJmN+HlglYMdOP9VsmS0HS6qH4rDf80jY= 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 1753603627334779.7860297142312; Sun, 27 Jul 2025 01:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwNx-0004T1-VG; Sun, 27 Jul 2025 04: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 1ufwM7-0006OG-9s for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:40 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwM4-0004Bj-Ru for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:38 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-234f17910d8so29660265ad.3 for ; Sun, 27 Jul 2025 01:03:36 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603415; x=1754208215; 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=TDl4qI49SpWW8VIqpAekGv5IcctWpYAVkinX7OmWaPs=; b=ZpRA7VjWwdeAaSsroG/7OzTHGfcs69V7c8HQdz+HvZZZUkXXwvOYzlTaFJFAaQj61o sF8Fa9/SkwkmtP3n9uT6apSqemhoksrjHq7Vt6DaVef9pYbUfK6rVUul/kBIMvHoVowa 1e9jX+skXq6edjj2dCLGDB85gMUgWHFopmQlMk+dxfgfKL/LWRZ7XFp3879sKH8O9OAf hxM1ZINtU+Uk10py98bTgwpaLwWI0HtqAg7mBivA5a0OG+/vF1AS49kbGllT9rlC4vQR iRLgOGZyPUc+pDr9bXnN+ezSAkMtf844yyTRZ3qp5KeZvzlc0XgOXt7YrHg4Mq8h55hk HXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603415; x=1754208215; 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=TDl4qI49SpWW8VIqpAekGv5IcctWpYAVkinX7OmWaPs=; b=VZVXUSdwBwrmutqDWevjmPmXsxJbuu/XFI1zeyLxQXCoGbq2YNSzyf+Zo3HTG95+Ez dotVoFjPJ8Nn7D0CnmSLMXpM1yap0tontX1LFzYCGhofolyEZlgf3u7Om9sHNaacfORV BI7anFq+heDk8LztxbYhAQntw9DJWwTpITvd0OeqrIn42KOSApkK0hfJId6/sv8az1mi oRI7ue/ZypIA047DIEwWztMYV5EsBjlR3VM45o8dqwNViTaCnmLNiS48L4/1m/AFUAfF r6OECn3moI2nbHc/bTBBG9jQBVOJEsNb2zy2/BuPSqIWusxtp5mgiWfZSSBMRkQaDl/A iIgA== X-Gm-Message-State: AOJu0YwBGyJ2hCJQ/4mNFMwU2+jJy/KYOUOZmHU/BSIr8kZR80Y/LE0r oyNrk4iPssziRDEJlCwOezV4kx0gUEm5rpyu+l9j/Nl3nXXtYCvq0kYi5AXzLNxF18/aowvA8mk pOWMz X-Gm-Gg: ASbGncukrRY+V6fS6yE99S5H9W+XZQXiHfpaN+mEAdkR4zkYUNXs95+FseshfwE+EJY diUG/aZGNssjBKGXJAtcVbzJ1xu8VvZeCs23jRuhoCiRLpOaJNNp8aOLP+4Aoq+Zc/dlxrYDrcE T6nKpxOAriz4O/Xn23SvVHIVUUfbCdTKkh0Frm14qG/Qr/XH/vjMbhPo2tAZTw5ADqmDddXf9Sl vCz6sTpMFg0NGdNNCWw0lAUnbkzq0O3na5/G9Q4ROJg7Od9RK0gERVnmCAffnTM+yBSiKlOXSaA /e7udwBWZn9AnLDkvxAMV1xP7wk9wXpj+DDQeSNi6xQ+c8M9CefBKi2x8TbIUMg2EaPI3IyM4I8 pziz+qrkG4ZG4Isbn2JtP+ShOtMq4oRRMeYzlwNqrzSxQHY3D8ziNAgD5fM9EJSxZnifDpfFgBk wwhs2L7arQKQ== X-Google-Smtp-Source: AGHT+IEq9Sso7I8W7nFVKNYO4frvKDHjD3yDWtrK3/CJA6b/4nRE+hD6AdliFPD5BDnezu3zrn2h9g== X-Received: by 2002:a17:903:2346:b0:240:2145:e526 with SMTP id d9443c01a7336-2402145e8d5mr428105ad.6.1753603415594; Sun, 27 Jul 2025 01:03:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 32/82] target/arm: Convert regime_el from switch to table Date: Sat, 26 Jul 2025 22:02:04 -1000 Message-ID: <20250727080254.83840-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: 1753603629592116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 35d41495cd..1a4770401b 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 @@ -24,4 +26,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753603651; cv=none; d=zohomail.com; s=zohoarc; b=Zfe/B3iFLWZemtTMAJgGsDVg5xl/CQiaR+GYdE6PNDJw/qe6d/vd/4dnn3oeOW5eEb1yGexa4ichRRnCP1XOEVHD3P5EOzC8QWYPce8dIPRWCEoaUH2shqS1HFVj3e+hJsh8gjfHqzx/9SJ50qHm442Sr+Pcv9ZZidNjPMWb3M4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603651; 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=eEH28c0nOz2sg6VGDpoRkYxKKUtdldOAh0qxcYe2kKI=; b=RL8ZyQjGGwj5IUlHY2nWxFIqpC3qe3tCKGRE/DfQGSo4pL1BqCAftpD41hGzJdfhKdT2VcgGEJ0mkEWNUW5IpWr4A4JUPOY9aqazJaTTrfQzYEopgSior74xugdgJZLfMR30kQwU3uqU8hxVgkw/Msb9wlwLisDTPwHLii/ByqI= 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 175360365120177.85556814858637; Sun, 27 Jul 2025 01:07:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwOG-00051z-7r; Sun, 27 Jul 2025 04:05:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwMB-0006ZN-5i for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:44 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwM7-0004C2-2x for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:41 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-23ffa7b3b30so3141865ad.1 for ; Sun, 27 Jul 2025 01:03:37 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603417; x=1754208217; 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=eEH28c0nOz2sg6VGDpoRkYxKKUtdldOAh0qxcYe2kKI=; b=SbfAR38DiPlSV7SNbRt1ingsSWfShHikeht48rafiWGmkIBgEuL6Yd22BKYgq/cOx8 bs8J2TAr7rbTA6xwKlbMdXvC/F8vF2ftEObGAQ2n8Tgl0Yve0LkFQNyv5rLerFQHeQjP uetOzL3k1hBwfSxW/kinKyvb4Jy84U+mTRTw/CAM+fqwiTdwxnCu4bP/DEh6vQCa50Y6 4JfySFCxhSN9AHXwrbdlTtrIlJIfmIyfMW7S/591kZLLx+5WRrZC7I0IJWYWaeSBTuBd 35k59OcOrNHCUXvdnh3nOpKPqrwYY+e4SKnsmoPDGXOWwOjvi37ifjylGd0ORHfztfbe Bsug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603417; x=1754208217; 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=eEH28c0nOz2sg6VGDpoRkYxKKUtdldOAh0qxcYe2kKI=; b=SQuow6+dE9yKVDOOmCXVgEr71Rekr5fw906RxP38whodYheYV27ANu+D0gHD5BfIoQ iVCSDF/tDYk2tkg+BD3JpTPYMOCz8Z13WOGVvKAiQWjzrIox+DYkcvahmde2w5qLNE/8 rS0XRdqv/PfyaDKqEAEQS8K7KY+TwXBY6QIBME2V+W704x9UJNSiZlFek2JaPhY02H56 WOoMP0ZSG6SS4uWPSAX12u5CVPSas2+PUkJExLR1ImCJ4DKVZd7vPSoY/yakOL23T00U WgcPCQAMxlzR2sWqhjsoWLcN14eUsXZz/sCt6IMUvZO9ETqOmkOIdbBv5bJy0ccvZgCC e10w== X-Gm-Message-State: AOJu0YzAVbkKUlJgJESBbd/JqqUKadMCFxnGjMoOQ8GuhSBjjmxVh7F2 pkYyvd6sSGlZhOb9VLqsVaMjJ1h/TZoXZFI84RWRxXMWJquy5swhvgdwV9lM6A5kgB9l/1XXGWe nIXyf X-Gm-Gg: ASbGnct5MQ4qeVEikGGQRdOP5FyuDY35YLv/aR0F6b8LPB82mkEDGANIvDKIuHfpAFO 32Tmik7x5PrtHH6H9ykpNQkyhS6w6fKpavmz7SOCa0pGm9/Hy/JvKoi15xRfx6vqXgJAPnJs0HY TwzbBU1wh7oU3JcxxATPxZZ1Y5mLIqgXTrp7wF379JlxnAzlirGgXN5m1KHl7L7eKg3U5fbeUAK iPmW6LzJVlkqlh9QEoJZRwM3b6Ckg35Oyr4vjQX0Mp2WD+GnXSDnrfvFtn1KMpiKM4NxvPcudIf Ki3StcHayVZeKRmsApy6d8yqtWiKLzgyPvx8DCTR6pHNFNyuN9U79BbMFXxZ6kxkaTmxbcX83mX 4/e2KizMq0nNnZPgZbMeSzF8dyIab7HpeBnxmHJ9JLhKtooxOtdd3XCNsyyOGPyxtClzWjMBiOW U8Kp5IsQiNwPz79d/my9hu X-Google-Smtp-Source: AGHT+IHWDTap+O0qoUFA2BjGu7zbECg6lodgNHKPTJoDBav6hcH3QMu67IUmIrhMmOY7l7a8fEwumw== X-Received: by 2002:a17:902:ccc4:b0:23d:dd04:28d4 with SMTP id d9443c01a7336-23fb3165099mr122608635ad.43.1753603416914; Sun, 27 Jul 2025 01:03:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 33/82] target/arm: Convert regime_has_2_ranges from switch to table Date: Sat, 26 Jul 2025 22:02:05 -1000 Message-ID: <20250727080254.83840-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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: 1753603652122116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 1a4770401b..76d50a0645 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 @@ -37,4 +38,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753604292; cv=none; d=zohomail.com; s=zohoarc; b=gj65Wyx5ajS4wYgkLSMMpA26wR8R6upA9S0/b1pZv4xd+zzL8BYRH+2ImFJDjR5uZlOwcpcVBBxiPimcjP1ymUyPk7sELFgzUrvCPs6MBftrnR0oEqby1ryOuBsVFVGuZBe2QYWv0UEY+Vhee2XdLZoNcxYSoXCzIO3/B3cIPrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604292; 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=FHjiVrtyGk+joVx6C/qMYRoqGTR+w3gl7nkjiPlPhGo=; b=XvGPN/8gzJcSsaQdGJoeQnx9FezwSMQyOwLyX1vWDLdi6Olxlss5PX/O22mpclGtCyohm+W9fqg/EJplAHdcLsR/tdCA7qgnHnMZ7tiFyhrmmv+PxCtRediB3a7XWIpM9AKWW16ZQ/f+RmI/xjW5Ij43DuleLdY6aD8+aVB7Hzs= 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 1753604292070165.05075191405354; Sun, 27 Jul 2025 01:18:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwOL-0005l7-NE; Sun, 27 Jul 2025 04:05: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 1ufwMB-0006ZM-5h for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:44 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwM7-0004CD-SJ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:42 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-234b9dfb842so30466645ad.1 for ; Sun, 27 Jul 2025 01:03:38 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603418; x=1754208218; 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=FHjiVrtyGk+joVx6C/qMYRoqGTR+w3gl7nkjiPlPhGo=; b=GAT9jsDjYUxjhlNzx+Deqs++GNAD83dRqqFmwusSI7fn2ITpQZJZdgyrObifhumJmy 1pHaCIjIEeN6bTmZzuMBorMHOyYMHD+JuXEEjnqhCYzxc++GZcoTxmGf/3gg8NM1Sd2R DodqFIgiNR7+y4bwoYPnr4DD71LaO+mXO2RfcBDiq5VamNxRmmOutcYV3eAWcpUDxDUG qFoOIhi6SLC8BcEcZfW0acsCabgwK0OiPVJvP/RtOPd07JFgQ2wP9cdiLB3b059hpLtp yIUaamzaBjabvZ1ctzDtu01CdcdttDldg0xGTSe1ndhscnhe6k/kyqpPUDQM8SO4t1YE 17tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603418; x=1754208218; 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=FHjiVrtyGk+joVx6C/qMYRoqGTR+w3gl7nkjiPlPhGo=; b=kJu8mmWV+PTwmfVQPuca5m6Outvbq/enJLTy32UVOahZbyy5DmxLWpEUxpCMNBMZEN 6NYTBHY6cbHPHq8YPfE3V8X7lD5IbVT17AWR/NrfCLt1xMH/Kb3TG/djluPR3VjgVqh5 SfkKI106E1HwfnZ3otfLwGKJVYZfOwsiOGK2jl/LXEtbbCwYR4M8mpwo4tLTLTGSJSvB ABPHnbOxlLhHyMbpOvMmTs5tz8GDAvoud0gOzwrCWXGYVEeNuuv7EtXZRfIDbBUiNj+F fvn3nxsgC5WDOp3DZgts0ZkLl0/tm2ULgH2vRh0lTa6KF9wd8bEwyeWIh1VE0Tqx3QAR efaQ== X-Gm-Message-State: AOJu0YzpM1tSNRKn2AS/v2g+tTqRyj5URba9Zq9a+LrXarwvVru3iNro 48J7nidoKPBOiJYLe1xfUgt4zrvNx8Hf0lvjLrPTZeANvYaLW/pXgHgeVoJqZCzdJQetVAoyDdH BzQ7W X-Gm-Gg: ASbGnctRXq3rKvuATHjRUNgrmq4MDW1Yta+zeGfogafeUeTVH1mB3IdMThek9mS+Wzk OzMHP4A9MgWTx6pNfrprOHn+G6CKMT8ly6kXiwCe7YR3d3LnEsJ1aKZW/G9RHvzYr97WZ8A8G3K +4W7ZriNEFES3zgj/eV+I8ITF0oRtn5w0dX00IWfCOyCJ86arnEjrpp/UI/e+nlytfuUGWAIYTT otgMvLdimpXcgfi0bfhb6DqufbEVA8BfqYb1Epmk58lXI1z3CCj51itfPYW9voVT8hdZOuDvbxN 73Xc/KxrBv4HS2UJxLXkY8R71m30W9WPqw3nWapaK6fOSCXsu9/njsmKkH1r4wicf89zQiu7pVP AjIhcUuCfHOvtFwUjxijtCbmkW8F4clo/P8LUniuXX44CptB0a07huH2U6UHPCL3pAnMbhbh/nE KMSrRYdCX1qA== X-Google-Smtp-Source: AGHT+IFI+VMdb3I1r+njjq4NDcntqyF/lQV/iglQN6oRXq7iB633oxpAICLiZKLNe4xChMKhr8X8QA== X-Received: by 2002:a17:903:986:b0:240:9cf:99a8 with SMTP id d9443c01a7336-24009cf9b76mr13579885ad.11.1753603417996; Sun, 27 Jul 2025 01:03:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 34/82] target/arm: Remove unused env argument from regime_is_pan Date: Sat, 26 Jul 2025 22:02:06 -1000 Message-ID: <20250727080254.83840-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: 1753604292523116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603764; cv=none; d=zohomail.com; s=zohoarc; b=M1ZznRe0fLsoTCdUW/MYK5C6sXN1FXxhB2UmviRuT7XKzsguH/PP6M9J2RKwcVtGboRUUdG51d+T8JW2iWDlY7WhdITxJZSKX1LlKTJ+o8zmwS3b6V8SgCwONdPpWxfuhhOhlJgcRK64h7q0kj0tCez/adyqxaZyz3ZViWTUFxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603764; 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=UAevgaEqYGutVd9d9I1Jx9uVLEhSMtUVuYJhw8Fcb1c=; b=iqRG4Bwd17zCydkkdM8ZzDkWUqOZq778Hvls4ea91AwX2qG+RefXDk0l0GL4m2jHZ3zykj7me23AePUEkCB3Du5QfD4a6rFza6uC1VLG7RCcX4cEenmLsFMSue2EwQo9qES+Wp3V7+kD+oWw5KjbslS/s592eufGfhT1+ZKWTtk= 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 1753603764653811.2430183145419; Sun, 27 Jul 2025 01:09:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPS-00025K-NF; Sun, 27 Jul 2025 04:07: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 1ufwMD-0006bW-IT for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:46 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwM9-0004Ch-1A for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:45 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-23fe9a5e5e8so4652565ad.0 for ; Sun, 27 Jul 2025 01:03:40 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603419; x=1754208219; 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=UAevgaEqYGutVd9d9I1Jx9uVLEhSMtUVuYJhw8Fcb1c=; b=bEgFrI7Osf18Affss+uDwGOB3O5FxtgnA2C7oBA2kdQs/Fl00MsXXq2NExrC9ZtB7c mQjrUDFQ/rz0YqPqnE0CKxgQg4v8mHHGghOzFvKb4ZAurQi6fq9mQpqzlM8zlPpfmVFB Gkj1rzDCCrr76ae5hbi7/+6cZn5bEB0RKD3OXVM0arGQ2CrqsaUfJNxG3O6scRu1VYNf hALtdxYS008EJmND+eFlDFbK1eUYXnLfcJ1G1nBUX6hjO4zpCml5yBx1JIbwUuhDA4pk BNTyd1rWoxAsAd6lsgZMkf1fq/TkePgHjAYQiSstFRqPG3D9CPkz9kQ4E2sO9SCsusCx tA0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603419; x=1754208219; 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=UAevgaEqYGutVd9d9I1Jx9uVLEhSMtUVuYJhw8Fcb1c=; b=nNCrXTpUuDkFfH+JQaOdm3hKT2J2plRVnczwfcv0gAq6o4UvzV656+qta8DRZiAC/k avju908lUTODYQnSGnyjSA0RhLmISW2BTcykS636+a8Qma/oNsgYpvtkEwcWmmQIGPsW EWY3uKqC5rgG1lr+ERnZXPPTbiUxm2VOaHjSEANRUNbwSMnikiqUYD6oWIp2glTGOOIJ Y0R+cnRpgfSZXkFBBiLw2x79khU5+L5dhPDZVH0kj0jX0hu3KEjJd8AiOrUIbSZComjN gGRP2WjhJPiDjCBEAqVbTXHO7Znz/Jx55TyoP9NCu8ymhVEad9jea47a5IJU3+RUxurK c/mQ== X-Gm-Message-State: AOJu0YwNdHhK92QDCJYIJuynaYHzg5KMKrwYHVr5ZNG/PR1moyeCkpSb ZtQEajrt91q7akSarArfC5ToMsZNdMmLLH2Dmtqa+tpvKSYbTkIeG8PlgvU3rTpqnuFyHpGjBpP lpG9l X-Gm-Gg: ASbGncugXWvNQ6YOuOl3h31Ax0iZmNXiqlcK2W/r5Wv8lDUdfmateW6xFSASoECyTDH FmiAwaWk1SMh/nCY4Qi9j8FJ05qQTIEtwiSwmDx//jRZUqs6Q/VwjGw8PjQQNH58c0/qhz0Tu4c Gy1LgI9Kf0EX6RzKbZpKmdTWtOABRc0PufzqrftJNOouV0GzWAEf839QMZozp2x0TNfSAE7Igfi 8T/ssdNQPF/BP4bK9p2T26bVm2bUBTECdj4b6dsVJwvgTd494jAvQukCLjmA6aifU8ebu1rU7qb CnrI80pNw794VbVg//gnSzU67nllZ/WMk3m8WZE4knweBsAapsmcuTqgWEYZAIGzncf3NlalUMj VHgxdvqNvlG8AwshxmjMwkEjiA0BX0K8fPXWpW6l/dIrpQmBrUf9QZ9yjQYj7mpqox6Avf28M6q 51fDR+uSITMg== X-Google-Smtp-Source: AGHT+IEShDbtBWYBNqFv+9GZ9xODSXVgaWwiIc7rjSws22nHHtyIKuNPl8+W9RLwGFJkgNH6c9KLzw== X-Received: by 2002:a17:902:ecd0:b0:234:9cdd:ffd5 with SMTP id d9443c01a7336-23fb3125d55mr114390825ad.25.1753603419179; Sun, 27 Jul 2025 01:03:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 35/82] target/arm: Convert regime_is_pan from switch to table Date: Sat, 26 Jul 2025 22:02:07 -1000 Message-ID: <20250727080254.83840-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1753603766497116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 76d50a0645..5a7259a557 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 @@ -54,4 +55,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753604390; cv=none; d=zohomail.com; s=zohoarc; b=LpyU9R6RTcX05vF/uM1y5oDCo6aJNnug3UG6yfNdeVKDBOQdeIcqrNoLJByj16THbY2Wlf8dksRRLfY2ihh785dDk95UgKDrFbM9syCXSzSL340Sggls1aFLM3Jc+xHJQVTRDw7nwTMxG7IGH9slF5j1HXsTdwzu4KhNbBGy46E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604390; 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=P+7R5cwd/2Q0LtBzEZr6GfHkwiI/pvqCBPx4b4tvS3Y=; b=iJwl6LfN+FSZHKR9XEkApTzz1JqB1LL5B8SVu1eoKMC7aVnkgCAdovzW9ruCtvuRWbwJTXhSUtJq1Qu/eDCnzxezTIis8QvEklzhvnDB1Jj021E095srrEDEe9vhMywtSuFgGuvKkFFkQKL0XB6IQkqBvH3cRIT6J6E66V8wJMI= 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 175360439033714.653534547728327; Sun, 27 Jul 2025 01:19:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwOb-0006Lk-UJ; Sun, 27 Jul 2025 04:06: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 1ufwMD-0006ba-SH for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:46 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwMA-0004Cs-UG for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:45 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-23fd3fe0d81so8011025ad.3 for ; Sun, 27 Jul 2025 01:03:41 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603420; x=1754208220; 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=P+7R5cwd/2Q0LtBzEZr6GfHkwiI/pvqCBPx4b4tvS3Y=; b=qL+cgDgfrEgXBe9b2rrTHJvImdZY6FL1TdCLhAU53F9Wfql31pDNhUsmt607tdUXoe 7R4GlQYB7YCgqS5M1ijKR5LxhL103udOjpifDUZ8iO0zDEpG0hR1zMCVgCEvsZXNmtTO 6pdYXRGYBXajtAycdu0+ohx9SDKQZ4A3FogvSNyW4TXRFetpqPQpCtY9j2dkUlBWANu6 kgjKvNqpHQEXQAZSbymGYEIsu3XBAgJby0bBTeJCFA26LcgYStEKzZyditTfBBlSPEpu Y6I0nUQyFp2vRvx9j7fp28F0cChLnqVyj45SXIldtciDK1pUF75sPB5GhT36mXlASQBW 020w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603420; x=1754208220; 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=P+7R5cwd/2Q0LtBzEZr6GfHkwiI/pvqCBPx4b4tvS3Y=; b=w2HkFZhYVF71LYj8aGbYKORJbyTJtMIOiw72j3nQvLLvHuLf94ZYQiTE+sdsoQYWVy aDOIE13vMECM49s0ux1aP/RApOZe+HeQDEZNcD0hQusrEnFBGKpDoDvoxJ2l/wXut3bp rwboqexrwpkHzROh9G1JEMTmycP5VTmkWPINGL2G7ABVzpBt1bHx74Iak1R6QWb4mQAv wOKnjzyTa/JY1lCsn6vbkdYWeWYdAqyeP/YdCr7nYMzlnER8QXBdJb231nnDZaZG2rUq 5IrFDb/UlQE6uz3JdNrHLJRw75j/uZSy/po2zd2Hq4iurLOtUE6DlZfYU1yxaiU1sc1R 1O0w== X-Gm-Message-State: AOJu0YxweDSJ+lHjD7bytHuhLxxyly9L3dc4NXKzpUTD8YKw7rBPx29y 0vuPjiNtRKw/yKTgFZyaikAw1DcgewnSHXF8PBzaaX50zOVTU0Uz4k7L8Cg1ZPBFP8qL5oq826g dynGg X-Gm-Gg: ASbGncszTcTwbX5UWmtKJemakSyGK02bsXhwv6yiRRhiBXp7l9qCBbX5YFJiNIpsS5L EqzXoHVYInKM8uWbqOxq453oPmzQoyt9VcONtAic3xMDpok73SHtbqE3fx9cFgzTV+3axSQXnIC vOH12I9WxEdasLsYdayxovDYc/5ECdtS23PF96s1Y46RsD31P7wefVNHoSmqLZuAUF3aLD69COJ TGDynnHDGiAoflDl7a3TRn58SxxT+J0HgQ7SzPDbyXZlKXCrI91kByVjzeNMGWcKN0KlIujz3Bh wO4If4giWu6xXa9AI12V5i0mMbbN7cy4sXkSOowaA8ZTbIo7dtFhZZ6fe2NUWsPtFETAbuFg5JP Y0LCGGoJQse/j9xVcQC50BvZJsnnTrQL0hPdBorthTSEDc9Ug+WNJCtqzK5Kec/EX/BzZEDsq/p lnbGQmpS2igaxo1gly2UKC X-Google-Smtp-Source: AGHT+IEIqi++EfqOOvPwadQDVtDVG7jKssc5axOHTnXU/WixWBhIwLPSffx3B5gKVFBVM1KCqd7YIw== X-Received: by 2002:a17:902:f549:b0:237:e3a0:9d63 with SMTP id d9443c01a7336-23fb30e8635mr124077765ad.43.1753603420282; Sun, 27 Jul 2025 01:03:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 36/82] target/arm: Remove unused env argument from regime_is_user Date: Sat, 26 Jul 2025 22:02:08 -1000 Message-ID: <20250727080254.83840-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1753604391133116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 461572f918..d82f2b1131 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 02:14:15 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=1753603989; cv=none; d=zohomail.com; s=zohoarc; b=JqOUawZihLSgKRV6n2V/7va678L2HX06YAVeqRauD7SRpBfYbxIc6weaUIudFa8IXs+8vPn+SjKyxB9UjK6HQHD9XBPJzca2LYiOOS6LeRaOy9W4EVhACZ8/oO5GbPNc0VmBtaIno6/kFcfyk4jubE35exlo1msF6azSyyiZ2j4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603989; 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=YV6leE4fgOKq8LWFBEf7PmSadRs+8Mz0dVJVLCLswgQ=; b=U+wohVpW+M9ABI7lQP6iyFUBH4Axh6HRmbBWPAsfWqEg7Y6jGDyCysWPWyrQNuLCbOyI7h1AwpA0rDqRiXFIKZA7Bu//P3GO2ImRp99G7d+CV2OIVXymLpyB4ff71SS2aTKICY3yM3qocTQFH+nIJYQH7votIACMWJIwVqv/xlw= 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 175360398914837.01659123382217; Sun, 27 Jul 2025 01:13:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPY-0002Tq-Hg; Sun, 27 Jul 2025 04:07: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 1ufwMD-0006bd-US for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:46 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwMA-0004D7-Us for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:45 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-23fd3fe0d81so8011105ad.3 for ; Sun, 27 Jul 2025 01:03:42 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603421; x=1754208221; 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=YV6leE4fgOKq8LWFBEf7PmSadRs+8Mz0dVJVLCLswgQ=; b=iGwuU1mUCEK+dSv19rrLCnNXcl+oDLMQHgGNed1iwD+mxLVeRSEUBqZDe4CH9bBv84 6V+QcNFBHPrq66I8Er532d2uPZ8tL9QaOzJBrgBN7LS6oQHmFYFMO9ayDcqQeLAw465T I4SjQtUnxGUpkewcBwRVvmVOwkEQSlo7pCst31IPZlEXSQu79xzmFeDqk934+MigWbSl e2ap+r9Ttkbi7oEuwjlu/nXmNBIdZYquW/R4w4L4lWyx1TH7yQSN2DHt36UCzfirfjNi jqkPmbQj+SlCDokBGnLf7/nLaweWsX5RIjMFb7bHA6FQR0FN12KT/YQCuUBDm06q937F EDCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603421; x=1754208221; 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=YV6leE4fgOKq8LWFBEf7PmSadRs+8Mz0dVJVLCLswgQ=; b=S+mD1EbLTyPsuv4D9ncmRdCQq7iA3tfqoeezO+W6bpiOQuO4FNsNns4Ff/l1CmAF24 ax1W1vSYqsOIduEGNnxrxlfcRkrmGfISaz1eKWURYWW6fSP+N1XKuYe6osMoMFCal5BI 9AQZ6WuVc2MB+NSd5WLweydMdxAoEt1pDP9TJi8YPzwp3N+yGDFufuPUfBu9PSofczBH 0zGXihXITY8AOIk3bdxahwwSbZwYLkxOLABUXVRgh2p0xA/++oUxWs5IZnyaJ+I86Ge3 7J4y0KeWYNKM2JA7wpVTNdNi+mau8SJXFe0c3/1svVSUHsmg304/L4cJLuUoO9oot0T8 86Pg== X-Gm-Message-State: AOJu0YzG2NRP8p6pnxIY2CyehMxO5rsL2k7oyMjA05vJTk25lBkCyw8b cI4r7+FnoOqmMpIPHQjY4pS3T/dj07eVqZRFtZJbahctrd/J4SwXKHPr0BAQkrISQUagV8Y/bic wI2Do X-Gm-Gg: ASbGncuFfQDA/WnMGV5gyFL6qTnV5po99Ub0G7No+jR+boXWqKHWOAHMJOfkCnLNENb 3LjrFSSmf/1YJVy2RKxWRbbqrF5BFmPyLXxTLSiaCZwxUEFw9hqIXHLJOdTrvhR6R2uK+YVS3w1 ZteU+Rca4rktyJxsq+KZy7WbuSki2XSRmU+VWVEcXV0ku64zaArhn3k18hAoxkimtbQvuDZKpz3 w/3Q2lTGajfHLM6WwXlDAAqmuK10wpgL6yfNCcvwOOnz5DDkxZIrXFr/aygGdw0WUGUkkPO5OrJ EnO9vjJb/nf4m/o0lEy+K/b6F0Nu6ZNtqoBK4m36/oi9OdEksiC5H13bw7qxMATMUK/06aCNUjT +6WLLdWMqiuDOydbropF0cZe5YcZlhOCZDo3V5J0xkpXMLXQPkWwCgoMmSyLF7+GuD97BWbnPqV 6IitD7T4hYnw== X-Google-Smtp-Source: AGHT+IEHRISwR3dMbs8ZHoA+Q5EJ/5dJ4grfCKxnBfPlukxzoLno1A4Ku6l5AUE3W/+Hz2Mv+dcvGA== X-Received: by 2002:a17:902:d585:b0:23f:b0f5:b73c with SMTP id d9443c01a7336-23fb30e81c9mr115784245ad.44.1753603421595; Sun, 27 Jul 2025 01:03:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 37/82] target/arm: Convert regime_is_user from switch to table Date: Sat, 26 Jul 2025 22:02:09 -1000 Message-ID: <20250727080254.83840-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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: 1753603990198116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 5a7259a557..ef1f94a23f 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 @@ -62,4 +63,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753603604; cv=none; d=zohomail.com; s=zohoarc; b=Nh68ayHVU3DgsTyiRd2h9lJq+HctdI6h3IAKgalS3ZAAbeL1vALaqzWlQWHy93l8wUoRhfgkLQZt3OeafD6VZFRtvNI38XvkM8FiYcBP4qLFhs7lOOV0oYSlQBG7UOqiFmhtpZ5BtPawJjdaVGoTS8FDdA0Q8+an+ObuMZ/uolg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603604; 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=3GsGizLEr2I76K1s0Xg3imO0jd0fS5orGZDEDwiddEA=; b=KRy6FBG/4hLRD1ADMYPOEV49xHTZB5bWgxzqUiiw2KoG0TFhPvbapfvEsVRVsGsTQ+r+ULYE4ytFmwRWEkIVhU/MDT0RRS0z3+PlAXvIdRBHuYxtWwgxxRKuYWwnTbO7Ks8XDZ3DjC8Hb+gYovR1WS8wZlZA9GQUbShN/vX42i8= 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 1753603604123743.6362146192794; Sun, 27 Jul 2025 01:06:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwN5-0002ED-Ke; Sun, 27 Jul 2025 04:04:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwMG-0006ec-As for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:50 -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 1ufwMC-0004DY-KJ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:46 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b31d489a76dso3532624a12.1 for ; Sun, 27 Jul 2025 01:03:43 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603423; x=1754208223; 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=3GsGizLEr2I76K1s0Xg3imO0jd0fS5orGZDEDwiddEA=; b=aJ6dXF73h5kWJpI8e9mCXgd6zQ1zyjILuE7IM6VTJKl2UOf45Fu0tq1Q3wmtoTjA4t 6HInetx2PNeFyTlGZGP9rFUBJcUQ+J7gKP4bU3QrEhXdXg/AZYnq3NK0hKcp5C7u4Zk3 XwjCUzWhzA3rexspsQ1fjf/5Y0eaUtmkJlkSLeJSNFxqSf31m8blBUXsfHmOMngGWMkZ CmccYCOeXGuM1bE7piX1TF96mXHPLUU3hzgUR/JaeloHYLdWkFdKfV4JPkohwEbwjgda y4O3vIINWOcA4EXsdDe41N7Kui86xONtRkY0dFmB4pWxFjvhLxqELc2eG0gRRIYQIHN6 4u4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603423; x=1754208223; 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=3GsGizLEr2I76K1s0Xg3imO0jd0fS5orGZDEDwiddEA=; b=iURft0p6pkfwB7ADvwI+yMq+kxfFauNpi5/ACO6OFTjRN/zo+geiZ2/Qf1cgP5e54J 2pbOzrqZ0c4P9E47A++7qQcQTliGSPQmlw2KKaV7dEU9DyfJvj4+np2/DbX/COIL6lmt 6iYbv89A+HS6f5uouMhoJ/Vw4F3txbmcDZzjlzDrKDqN+lDsLqaISgJRJGRm6WOti/lW EsYmLNHd0M/l07HLsHmmLzh8WvVsr88926uOjEXxYQw9DCz/hbj94D1ideLVUKBC14tm k3RDXkOFLoemVeiFusco9VCcnV5UYNai7SSDDFb6jUmA8N4FZN0otLXKunCmCecp+IQd xfvw== X-Gm-Message-State: AOJu0YwEcF51Ri/eEBoKjsv+MptE0QGKOcYrde7dfSBtXwZza7HiFm21 cRIEcsuu1VltZZR0pNHS/tleafWFL3baGDH2nqH5Bvf4nUQEMJoz1FdcGEW9zYWundDcOxe1J94 nzXo0 X-Gm-Gg: ASbGncvcWdO6mlmdtvO2YtUoNdJ9KpOwrV3/ezvQicFGbVpB4XwFKvg2RLFMm3DUh5r AZBSZ0GcWKO3JIgtvdWxqDrxrauW4h0XxDwBU8fKkIJhk7073saDoxOK2Z/7qZbDDoVRdtXnBMT rmuG4Km7yqgny1ba+4Tl+7hOoWzQb3GNfyrQT08onclNibwRrjZsQaDMFFaXlMxAW9sYhDopuWY PIr/Ch4YVlzLIDbA8/n40me5CKVrJXYMsac5lxxvlZRo5Qjd0O0cZJ4szRxS416/Iw/hKlygZlf TCKTh162xXpMAVSzCeLGJHP00PSErW2FrqexymYoeaf1uLFwFF+8oTa+3xOvpo4D184wWrzaVyq NijgBVNAli/4oTDrjfuMm29hFx4e673gbFGwlQKlrV2vuzfC5PrSQBfMWXFWYhYt0g88iCxr4FM bLk3dSbYlK0AWDT2vOzUMl X-Google-Smtp-Source: AGHT+IF0EhjvtisVRivYc7IzAxDX6eDs4ZLdAu7RV/YlY7swbnFkhYhixjnykvACGjgQhutoOUqTvg== X-Received: by 2002:a17:902:f68f:b0:23f:afc3:83d4 with SMTP id d9443c01a7336-23fb3086eb3mr138186625ad.21.1753603422658; Sun, 27 Jul 2025 01:03:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 38/82] target/arm: Convert arm_mmu_idx_is_stage1_of_2 from switch to table Date: Sat, 26 Jul 2025 22:02:10 -1000 Message-ID: <20250727080254.83840-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603605577116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 ef1f94a23f..f297eefe2b 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 @@ -74,4 +75,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753603648; cv=none; d=zohomail.com; s=zohoarc; b=cE1yg2uLaKnnFQ9VjqYJoworXMM3uOBUa8OYG9qG5W+cdw+Zty0oP1rrqRhMMy0CONgTuWlLn9zoyd+lLRspUUvb0N0+M30yxrJN03tS9irfb95D6RMBFYnmlD/gyxcjkAqqhfdu4yFaCvUp7XOxcmf/MZWHbBL3ZUyXibhiFw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603648; 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=q3yL151P+dSoqNJcReBE7377GzJXEssI8OgEgpoGNy0=; b=Q6+aEl6L0zhED4VVxjzLh985D/JBnE5EF04ydyBFfBoXGpbxZ5QKbj7TtqizQ9zJEJ7sn2HEDq8l17idopxvrqrG5tT94EsDVMAMRefkG4kGpTrU5yjv5baRVwzeuqPt38yw6FNRIK18/Zwq9vuqjz5xvhclOIOOaPuKan1CJV0= 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 1753603648738395.63665017133644; Sun, 27 Jul 2025 01:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwOx-0007Bv-TZ; Sun, 27 Jul 2025 04:06: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 1ufwMG-0006ea-AX for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:48 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwMD-0004Dt-58 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:03:46 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2401b855635so328235ad.2 for ; Sun, 27 Jul 2025 01:03:44 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fbe333efesm30016415ad.65.2025.07.27.01.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603424; x=1754208224; 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=q3yL151P+dSoqNJcReBE7377GzJXEssI8OgEgpoGNy0=; b=IAdKt8tZR/E8YkdfcWJuiUgSDNuQEjXclW+F5sxWro5BKX5EpoS0Kr+jH1xZnLwa7u gZ4NjhlAOwmvqvkEOwsXSKx7XIyuWPqzCvjn2Tw2Rm+OuBwzykO9slbV39wVw9+t6OVo DX/HpvVwWnSb3VbbMcltkaTceCXtOIxsTJqWT5igEQZPHp1c/xLTb68y8hltOKAVr2Lu BJXtje8exvnLkw+KT3yzcbIKwNjt0vPV/i5ySX2J7/KUPX7Cbk9VkJzjr+7KR6DEZ0rW xAwVCty4DUFN75PiAOt/R2IX8aP+Kopj0qOEHskKVkgJeo3sCZs2VfxazKQI+5IoDYBO UuYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603424; x=1754208224; 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=q3yL151P+dSoqNJcReBE7377GzJXEssI8OgEgpoGNy0=; b=mRMTF9FxurQCIG6BUb0mRKciNsGxJtvcXDxVD9NOPwr9gdNc49e10Qkczqn4MKLuUB B1Hm/dIdd7uuvHi+kCgXLaA+tX3tH9gWmNEmfqrsaKfIcz40WEsoi/ZprWZVSdkV+Xad d5bkQtKfJsRCfbsqmdqzN4B0AxT9Du1zk7pQztmrS0eVNeoUdmD9cDQbaIPWo7Py3viY xcYXO+JY2c+n+XhGOovkaNG2HF2XPd946u6rXKOwiRqENo/qZIJ3YrP0EXCBTk3K8sKH lZWEeEpzYteZbdmfY2PSO5t3AXdfsT6USfBSAXs5P6RLvV3w4rrysqaHWg+AFXEHWOwO HM5Q== X-Gm-Message-State: AOJu0Yz1hr/n9x4dNf5tuVvsTlW0KPGkcbLAh44Va/t4jBXy/UioapNp 5ky57w6PZ4L+MPoEdwARlqPReBfBdipP/TmJQs0Yqr4Hog6YPPYsLVoHuLOWZ0KgRfp/kwylsIC G/15u X-Gm-Gg: ASbGncsCAfZoUhNDcNjDST8VfKH9GTli0b56MedLgWZIMqXKVYILQIvws14eOLqfcu5 p+eBDpt/mrjIqEUaawPXJdR2jn0ScAG5NVrJYjW8ZaIid/TiC0ztieC9MutaHl0NB3daLGv7+D0 KmgyMaOAP/t+tNRfIdyfV/qgtHTO74g6iR+QUaVb47aXjqwkbsx8APJt4Y5C7dEKZEcA/LgsJhs Bd/bcl/wyviQEhKMrLV7HDMN6anWGVWhNPayYCd9DIY0a7Nthu7i5hc5Zit7MKES9ZILRIsg9vR nI++9z9JnzLbx3i1v8WOeI1JS+8+KiYB6aoqsDCrFvDttll+recU0D/Iic75TDkSeNCLv/nqllX CoP85lechnayzLXNXamrX7hfUWGZ0U+29x4rcXelcsC7j9lNovgfVM8XdQloo3UWHrzHa5k57gA J35knd4jd2Ew== X-Google-Smtp-Source: AGHT+IFWtjbccSO+FpQWJvZahLzrOTog6H488t6so/U6K9lhBW7Q6W5Q2mk3I2W9iNLuNscMxUCRMQ== X-Received: by 2002:a17:902:c94a:b0:234:bc4e:4eb8 with SMTP id d9443c01a7336-23fb3120755mr107039585ad.46.1753603423856; Sun, 27 Jul 2025 01:03:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 39/82] target/arm: Convert regime_is_stage2 to table Date: Sat, 26 Jul 2025 22:02:11 -1000 Message-ID: <20250727080254.83840-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: 1753603649810116600 Content-Type: text/plain; charset="utf-8" This wasn't using a switch, but two comparisons. Convert it to arm_mmuidx_table for consistency. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 f297eefe2b..ecf43d7709 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 @@ -82,4 +83,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753604123; cv=none; d=zohomail.com; s=zohoarc; b=aM3PpaP2dsvFNhyJ+yp+6souHwza4JVl/Wi6M1JqBMCcWieKntnUsKgJ+juYFBSDpw3vj/1SsHPMpnq1oECD1HEqwslKm7V6v7p1dZphCl/b4uzdF65QGzkx8KraGF4YL8HjCcHiS6enGgd8erymttBfgUIEeB+zMhl1thqrbQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604123; 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=nnwnImOB6woYN1+lz6pL+O2PSlPM++BKcvLqNL+O1hY=; b=llxbrh+BiqVfykFP8ooHGpKZ0b6EoZD6TWYyI5S1kUQHSk2Sb+ieWQJMIXQuXZaMratTVw6bDA+6H91G0Wu0yEaV+phUKlfasq5GIaKL3Ty2BQZh1TfDppzFAMN8s2QTM52KSIOcYzeQaTkUr6o0oCLFBgimCgBhIgkcJAEP5MQ= 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 1753604123336519.8529859228602; Sun, 27 Jul 2025 01:15:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPH-0000hi-Ra; Sun, 27 Jul 2025 04:06: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 1ufwPD-0000A3-1t for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:51 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPA-0004h7-6n for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:50 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-237311f5a54so28273865ad.2 for ; Sun, 27 Jul 2025 01:06:47 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603606; x=1754208406; 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=nnwnImOB6woYN1+lz6pL+O2PSlPM++BKcvLqNL+O1hY=; b=qkGsa+cdPDQrV3d7Hh+5TdHvo3ChjVdiEQNzIRgzdQsy6mPmX7x+OnLcg2ECfVLp+Y k5axsuss9x3YMEiitVsUYzEe6IRXs576KRclE43FDRVWPsgKQGGbSY4UHI7EPUQapi3O cb96tKK7c7eb73Zu0rag1mCBvhP5kYoftOyXYxlw9ioXggrCivQBZeTXACAnZbMYosib G9oZSAkfUyua3RjRI4TnIfqFNLRCtnwziHFpIgGCYw4EaWBbCoLV8thk7bSzz/Y++xs4 a7MyXl8/kOj0vYX4c4AXTImKIAuIsQqx45HMlYNOONqCOCcjebXM9X1upVlDPrh8gGlL hZ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603606; x=1754208406; 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=nnwnImOB6woYN1+lz6pL+O2PSlPM++BKcvLqNL+O1hY=; b=o0/Q1vyAyeYWbdV5IBc+EGS58AtoGFy3nC7jGaFQ5plawBXTz5UTsLBcwaScR69z+j AcgmOj266Jry/ZrhNibpCE5SwUdo0QVT/Mf2XQOai3VVVIl+YSg63323WFFtCXNm8wRX Hv6bE18/s6C2uObOlZbwZ0Rb2XCEuF+bjr6xDdHEbXfH3j2dkWErqOlzkRxCsfqJbfgX 4a1ZVG+hInoN8jNIAEOgWgxAV+XnZMEbvuDoCybAbWDXKcYTLakg16AyPKYziPDpVedw msCYk6tkxBMicY82C9W4gQKuQK5aAUFf9pMQWsSRZ6BzuSZtDo68bbS4Y38QrbzyTOdH pJWw== X-Gm-Message-State: AOJu0Yy//WbUgGcRejrcejyL1xubPHeHRojI3a6dNaiVcX6Bgjp2ZLH+ XKu6XvbfdV/CjYqXEdTmDLJhqlBQ17+AkYm43kLjqqrBBrEVa/8A+TJGYveYh2yOscsD9wrQGNX HqnW/ X-Gm-Gg: ASbGnctwqg/lTtGat5WBw1WI7Ev/IJxJ6btUnFX1hvSKgiIUMMGYbPix39q/nebqCW+ 2fx3urtlYHvAPkyq/UqAViomj1tARVHavSxI/URluuPj4zV9SztuDGEf++TKhSFtHXgX7CS/ter Jbb3178JxU4YXgiwGR+pHZ/esv6za3f2sHHh2LjB/ZRzK7bnoKSNBzGTWZ4OCJpj/6RW+uB5dPb NQRHv8Yw2E1ztlwMTd8yM70ghzC8orkhPHJ/NkyW9UM7JV8qizxtS+4PlPemKnf3T12CSKycEvr XDGDRMt8Qx63zJiyiKlWbg08+P9bPUOte6ddU/AKH4RvTk4V4nQgKKHhrGF7kPrslfaW4BZlxjy iwRNL7y8ShjsS3HjyfaJYReAacPlE5MdjxMorZn9YDhWAHtxrFI4V23wzV1ehaJ0C2LQEQEhExT kRh3Thulpm3A== X-Google-Smtp-Source: AGHT+IHMMAMWkZkO7BlUsbigYnBK1AytNLIPb0aFUg6vBOez/H4dEVebiphwEO0U5gZm9neEeJtJhg== X-Received: by 2002:a17:902:fc4e:b0:234:c8ec:51b5 with SMTP id d9443c01a7336-23fb31dace2mr98830235ad.53.1753603606402; Sun, 27 Jul 2025 01:06:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 40/82] target/arm: Introduce mmu indexes for GCS Date: Sat, 26 Jul 2025 22:02:12 -1000 Message-ID: <20250727080254.83840-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1753604125189116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 a95559c538..bca13bf38d 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 ecf43d7709..f5de104460 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 @@ -90,4 +91,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 d82f2b1131..7ba802f2d6 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 02:14:15 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=1753604291; cv=none; d=zohomail.com; s=zohoarc; b=IqavH1pmNczEa8Zpi/rypxXMzd81Y+PTP1EBahibwL2r++dkbUfRSqBLvgj8uy1CNGdj90OUeREufP/9IiV08KefeOgoCPFP6KgdxC/EYkiSlYWLb8NIUGWAKZ7/pEpPbTvhEHTlOsMB8+SdqsMAEdpDW0SuQ1/DzvZPX1uBzYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604291; 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=zYW5TuePB67HwCH6P3Jbzlj0fkBjQRv8GZKruDniEmg=; b=Jm31g9QDN+d+G8ZgNcj4xep8rnNlNqbVWEg5j9e2RjykuS/BvtUwp7LGeDUCPTM8A7oXwDJa/OkhlqZYEJa+pYZJ11XEq5Phoiaj807D/YM0+8Z7AENcK6EK98y0h9LEfsIdfQ2J/RtSms+i2heVqQRVkf5okkfTyKRtTBMhLtU= 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 1753604291547317.90398068764046; Sun, 27 Jul 2025 01:18:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPP-0001iJ-4R; Sun, 27 Jul 2025 04:07: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 1ufwPE-0000Pd-KG for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:53 -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 1ufwPB-0004hG-0o for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:52 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-24014cd385bso1440745ad.0 for ; Sun, 27 Jul 2025 01:06:48 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603608; x=1754208408; 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=zYW5TuePB67HwCH6P3Jbzlj0fkBjQRv8GZKruDniEmg=; b=XJZYYnYDwgdBbmzHDaVlEQ83DqyDRkdQjh+/b1aSYmLhi8BP78GL0P7bwKfO33lbuH y4lJIM1IGpr3jUgt8PbOYy75kav+/Z24pmO7CYfI3rqwakbmTXrKPovmueg8hVHEBzhP rI78bkgeGpmGNobILgn2H9lcy1wfF0ryQ4NBJJqYrqCT2w30bQqEcAcnFKwOat/R4Oib UsCWDcsdKfsDFPnbtlxTZyTOgMXRfA3vJONkrWfyfXMfZzykrOkOcQKaxtm4RiXDLHEH roz5bNkiuUSiV/7Y59BVDU0c2g4P3yzt+eiNgQh2N91VD66NQfzjIY7nDdJcnaAaFTNd P1Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603608; x=1754208408; 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=zYW5TuePB67HwCH6P3Jbzlj0fkBjQRv8GZKruDniEmg=; b=KnbWDJNwrYbkyKeN910CbkQpjTDu8r5wDaQ3ogsp/Cgo2x9BZ4Wek3en8W1XjjBfBb bITPokMfvZ1sTgKB8Oqt1i415u00w+OoZi7wyvP3YGrnUDmNN3xLx4G7LBRNiEasFNjg IiFs0IIzSG9tGQ1a496Q/Q/uP4TCDtdH7w3EabtaW5gs/rwBXwRwHcqa68bjXKn+hnT/ hOnt17Jl9oYYf+UFVgeGzLRA2dZrDbYMrkmjhCuEcuVfvo6OdNq9I0cM0zgCSxQi5SbT J9W4avCTvbNuEh1a06O/hmazZM+SMAYfOn0LRaauuZcaDeXPUQ37lUHJYcjK2YridAvc rVjg== X-Gm-Message-State: AOJu0YyK7BNvemjcUPSJTCeJYLpDFbeu/g/eL8LGDecxD4H7/t5tvyhV gtqAvqO5qob+NHSu9I7RwXYyBVUHJUkXpLd4Cm7+JeaQ0r6n19NBza7HBvpjx3qgEhHgahiHHPl q4PsW X-Gm-Gg: ASbGncvyyhpN5FrCjtKBsOC+s8+2AnB+++/Gu7Xih5S9zQwsuBTYIMwPg73QwKN0/PU C7RQwNtIKf6PF0GQHOIJDGaOiX4SAiR+xwbrBPCkZYOp6mSgrekvqIXGTriK1aTRP7fw5q2Tvx9 8l1Xo6Alb9aAsmyV8mvdWG53231dlgjG8FliWxcGy2fCcW1EcrWlf/X/SuV0LPeg9EvPDeMTamn ppkeZi8X7BaC1JDBZxKitPi/orXUxaGHP9A9z9T5m6uClZOtrQb3ytYNXvHbk25BN6G5HLzJoJK NQY/hLUjFgnu+UvDcnuGpou9z+i5OMH/EDwSfYGry6VVMet+7nZMlH3i+vRUyzy1HHOovZXwlbN FcQ2JCW1HVgOr81/FQHK7MgRo/48gtvnVPO93LDoCyunz7sYOGivzx3JO2KWvSq925orSfWRDr+ vuaXeSoyt31g== X-Google-Smtp-Source: AGHT+IGoDxCFC88FETiXCByupKPdD/lhYvGofdkVrYFEl3fGqOgDMBaJ3odNx7vVG8ceJT8FYsftjQ== X-Received: by 2002:a17:903:1c2:b0:23d:dd63:2cd9 with SMTP id d9443c01a7336-23fb31d3328mr132316615ad.46.1753603607588; Sun, 27 Jul 2025 01:06:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 41/82] target/arm: Introduce regime_to_gcs Date: Sat, 26 Jul 2025 22:02:13 -1000 Message-ID: <20250727080254.83840-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604292468116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 f5de104460..b6954cbf40 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 @@ -98,4 +99,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((unsigned)idx < ARRAY_SIZE(arm_mmuidx_table)); + 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 02:14:15 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=1753603907; cv=none; d=zohomail.com; s=zohoarc; b=kFY699c9+EHKMd8OwSw6Fs4BYWUbAJhht1tQBikVVmB+AK2gUM+3GZgAZ6Ym7fm5bvdbbhDDMzace7fJ0rRb8cKTpGSqpWi9XQXadzMCyLVNnmh+bgkybVAKgZeG+qwTa9JaoYG5gKolKXhq002Q+b09UkVjfzUy1toppAup+Ag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603907; 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=Z9Mg6ErdWdTHwLMXbslXCxCUWg4H1dPmwKDtcENgOd0=; b=nipspfOS3B0XTulW1p/5E1YlNGXtQmpTuFysMwixCpHNk3n++2haUXoOWnqv99fbe5SRYMc1JFjtqN9RLDMXyFkmfd+7tylOvnsX5f0FmwG/CZw108zLYHDZUzi3O54431b7GSUC+FJvZc9y9VzJEluzS7yRZ1FBdfvU5kPuYEQ= 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 1753603907422501.0032336775539; Sun, 27 Jul 2025 01:11:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPY-0002T4-7Q; Sun, 27 Jul 2025 04:07: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 1ufwPE-0000Pe-LK for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:53 -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 1ufwPC-0004hS-2e for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:52 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-236377f00a1so30196225ad.3 for ; Sun, 27 Jul 2025 01:06:49 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603609; x=1754208409; 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=Z9Mg6ErdWdTHwLMXbslXCxCUWg4H1dPmwKDtcENgOd0=; b=Euhaa4ztM3bztRpBGFnOGvS3y5vht3IePEPIfMA+14D6tcamLP6dyGQd9jXi3Xn5xM lyUwb0S+MXDNLugT1SlecpIcqKN9qohCKr7oiNsS0b9y7vD+pA3T1F4fMohAUPF0wbYA t9dob8Hv52P9EgQcWGObJbL2R2YEKtztFipVWqk2JbxB/y9NTQSFHUGmRPIU1jp5tOX0 2AKp482e8bO8OUF4a3wP8b8lT3Gpmlz+NkWNZjgyX5Ymm3H1d5U5XQtb2maIoTmcPJhG c3aB6nkDRpDkJWLvAlfLBYoWvvO9O1u4HiZblfocEWtFji6I55ZOt7XdrBpPy8zekdFS aHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603609; x=1754208409; 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=Z9Mg6ErdWdTHwLMXbslXCxCUWg4H1dPmwKDtcENgOd0=; b=KvvFE/mo8Miv896BMwoD05bD3NZhYa7xe55thR8YLipMeiMCb8dPRU3bLvQFzm9xJ/ mxuQyIcGV+bYInZfAa3lLh07nPBk9gA+lxNkR7nOl8nw4eVC0o5g6JLu4SZPkOpPQT1G Yi1ZplrGuz9jlfrXLPmVRFEUh8peK2qvnvc8GHCozpEzE8+BfFPixP6r4NmBlWBkI41z bt1LPtayTMupJHELt+I5DgroR6JcXNyxvneWXu661XQEPvqWRuDqAKcAMOIG/qg99dMj vZQUmkhyrKMfcZo9ypmo0S7TVuq7WIdXmE03sgOKraYvwE8BCqmG49FaeFUSkPWb3946 vetw== X-Gm-Message-State: AOJu0Yzcd+CWpVgKDSZXMK1d2IWW/OmGO0y1R1dbpB1NTyX6YpHeV+db DDo9yRo+F/Nn45RfoHN+L8W9z34QADKOuzLqONPjO/IN+ptr/1gBQo5C6NFkEuUmeiso9Ir8azS seKMw X-Gm-Gg: ASbGncujuiYTSwYJl/BhNpNql2NAmy5LIKE8/d5ry4P0ZGkdrZJnO5M8DO0sJn/B+CA 3q7f6z1//JKuX0Z+vuJbZ3/7OQQsUyY21ik8PSqTNSITkNFIc3Ck7MbNbkvDlfGiT1kuJmv4jvl oKaIkODItbnYC0PECPFxu/3j0J2jrv8bBvQyqK7jZSDS+0lRHfjjM0U0YeW2dPvTGX5JeY98eT6 BaJDuOMcktgaf/PyNDy2Eoe9pVcgWK1I0gXWDogu2NNWB5lgKQ7YW8dAcj4D2odh8sw+SUb/Etr wJSEVFwJYc7u7Ou1nzVUr6qvdjXAjRRxU38BJUCdberfFzKvzPRA+RJ9TMglpN9pTGEnnLB+HU5 XviHjbik3KbESaFra0YfoFMFmqYXWXUndn4JzvclBqbmEN6ObZ9r7YiMdleUeeotsMdqm8bJK2h GtunWxXn8lEQ== X-Google-Smtp-Source: AGHT+IGsxest7+gb1/FyQmtoZFg4V0fwMcuLCzviNMseBbxSRmqj+IzNHrhJZLN7tGq3VYb69mVJ1w== X-Received: by 2002:a17:902:ce8e:b0:23f:6fa4:1567 with SMTP id d9443c01a7336-23fb2fefd31mr102730265ad.8.1753603608781; Sun, 27 Jul 2025 01:06:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 42/82] target/arm: Support page protections for GCS mmu indexes Date: Sat, 26 Jul 2025 22:02:14 -1000 Message-ID: <20250727080254.83840-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603909581116600 Content-Type: text/plain; charset="utf-8" Take read and write from the s1perms.gcs bit computed by the Arm pseudocode. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604290; cv=none; d=zohomail.com; s=zohoarc; b=GStO9q9A6VLfArPRzNNpgsnAPbK9byNW4ZuT9dVpkBCVn7fZRnyqTakU3bLp8dp+Iotrm6UVM4iVzD+YVwFmcJncRqgz9WxH5roXSzvy3MUPVOmp441wvjz7pa5zxm/R9N2fQXeCT/ll1fu4OsFh3X0IeWSRHRUYDq5Ne6Dutj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604290; 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=+NPgwsTSCva71w86Z5YnXEZFZNtXQypOh1AcbEhfj9s=; b=dvTBg01qmGh+mNJsYpd976zhrFtcajCY3gnuqes0XTvhMDnaqV7yqF7OwSdRo5VF7ZSqYuUJl67BZFBlcK1aSMhdQBmztpkCWNmcGk+5I589F+s5GVTpzq5DwVmTImrocGGRRPtf4jEeGI41SXqZbHm/RVDDZrRrTEdNmCsVsgA= 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 1753604290072629.9941666024005; Sun, 27 Jul 2025 01:18:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPh-0003Ey-0k; Sun, 27 Jul 2025 04:07: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 1ufwPF-0000X5-DR for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:53 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPD-0004hc-CK for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-23ffa7b3b30so3151675ad.1 for ; Sun, 27 Jul 2025 01:06:50 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603610; x=1754208410; 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=+NPgwsTSCva71w86Z5YnXEZFZNtXQypOh1AcbEhfj9s=; b=ug68Ad4mVlmKi9kWsIl4V2VEPXDvgb0YpkW0+GnBJ1yB6WCx05B3KvOaM40cvkae1Q 7dXQDX7SENUNgzSMZ8ahj/QAytmSquTZ/i0uSObMKjbUlGxh8ubUfjWtyzG5dpr1W0ZG TTxy2GDAatwK+xUgO1yJHWaiMhDCbuxORCEGxfr4fHdNidw4iRJRS5G5FsrepmAvPNSR FVEs6j3kiM4B9HI7HQSfTPIb7zQPKnEDcykU2/SB/h0R/AgZA0tSkm1nKdGlUmDglZx2 gTeMNd2dJNELkvhTKF/8d8DspACYTH3AWBQRjh8oHu83moata3ZR/lTOsaGco1GixZoW q6VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603610; x=1754208410; 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=+NPgwsTSCva71w86Z5YnXEZFZNtXQypOh1AcbEhfj9s=; b=WnNNIl0dCH4St4umqIZ+WqzUFB3YdsA0HGNZz0RtYa/mjmw8e3rRWAZolY856XkLfh sjcQfEdL8aEZzOrlEaaAkUNbC/3Ok27Mqzt1yPE+eXOssykhhVy5ZzXpREscwlNtbKeC M7LvBzXPUZpWp52nyY7K9bI5SsHBVRK+K/1ow3cBaUhT3ZPR7fb60dp8o/Ld69bnvrhT prMJ0wHDOPpQixGeL4LSX00oFoZdQO37Ep6J6GogIjV79mrWXeb+Uyvng6KSNf0s/vqr mgS9NQd31pCJbMhTWu2+2D72iQ3iDtRmPTZyluMvk77AzMuLb7rTjAEqEOTVa10GYNl5 +ytg== X-Gm-Message-State: AOJu0Yyl2UbI4ykX2Oz1dbHfrM1xaD6uSLZ3tWD2eYbyMTX8jZVZnKo8 ASssKKCzV/P5kuZ2O5nRZuGXxxczcD1cKLnhov1ip4vQTQYa3uqkkOy4saDqVMn6GlVD7DNBIi8 rXVeW X-Gm-Gg: ASbGncvpgUshl8xy37jMiIU5JTr8t9xJ61qCpKaNVUqccGpOAlXaJkKNAmUDNCK9rAf fbfbE1jhZBy2zcG07aOQPERV/Ylxvyy7pDCC134wQLneG6TMNkPQ/HpKTi84W6PPnw6lFd9DLmJ r6p7L0nEHVkexX9Pz4MGAOwnfRhLrdhUvZkH11kWsWbDtjBpCjjOESARU0/SJTdPHPncRvWhzqS 9EylIBC3NqUmDM8gqdjGTYL2YiIEW7k19kN+HlT96XCwCf/8pdH9Chl+vvAEO85oWGoa2jysiRV YSMhzAMEMbfckt5A5OChwZfqOk3Lh90nVyCc38zUSugOTTvGLcOFk76DfkLkjSZ37gutWBmRKfw SfhxjEjXHRJnC415aWEXDjrOOAtPpgbiQG1PGhuRKotdDSypDVDNZ2wCAkw3QrIGjSokwy1a5u7 U6dKgDp+zXSg== X-Google-Smtp-Source: AGHT+IH2L8R/p7KXz2bqy+DWrzlFTVJp4BuheM0T+jF8uWaVXvL+N7x6wWZACMISCsUdrIgSJgrk7w== X-Received: by 2002:a17:902:c602:b0:240:84b:a11a with SMTP id d9443c01a7336-240084ba2ddmr14898605ad.17.1753603609941; Sun, 27 Jul 2025 01:06:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 43/82] target/arm: Implement gcs bit for data abort Date: Sat, 26 Jul 2025 22:02:15 -1000 Message-ID: <20250727080254.83840-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: 1753604290484116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/internals.h | 1 + target/arm/ptw.c | 1 + target/arm/tcg/tlb_helper.c | 1 + 3 files changed, 3 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 805f4a1876..7a42f8be0b 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -756,6 +756,7 @@ struct ARMMMUFaultInfo { bool s1ns; bool ea; bool dirtybit; /* FEAT_S1PIE, FEAT_S2PIE */ + bool gcs; }; =20 /** diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 3c84f0f024..ce9626b627 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2393,6 +2393,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, fi->stage2 =3D regime_is_stage2(mmu_idx); } fi->s1ns =3D fault_s1ns(ptw->in_space, mmu_idx); + fi->gcs =3D regime_is_gcs(mmu_idx); return true; } =20 diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index ae2acd6727..37c7651799 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -78,6 +78,7 @@ static inline uint64_t merge_syn_data_abort(uint32_t temp= late_syn, =20 /* Form ISS2 at the top of the syndrome. */ syn |=3D (uint64_t)fi->dirtybit << 37; + syn |=3D (uint64_t)fi->gcs << 40; =20 return syn; } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604010; cv=none; d=zohomail.com; s=zohoarc; b=MDcddOxNkZGj5oamEo00383ZAdmyGTgFufuzMVkVknJ6BZLafW2nP741xYTIiDVZrpADqSuxjSiA0RtogHWqw8S+XHu4Ji0gbAO7Spk8GzAse150tFmBVztAkW4zqwslqvMNSAzNaQJTUEVjCbMWB5nzRXCw+VLIhVJtuvbrlTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604010; 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=mToJBu/VemOEmZefCjIO+GVG3ZJTtC6Z443TOamRSW8=; b=cFjXPnN3i/SGbcUpH8J8AejS5LDT40TEJkgpBAOWsu+3+DYvYGuHv0ZOvSCXPI5p2OcNJM6EZwiZr/NZEF0GwqN5VQj2BcWTqKivYveZVw6JDBa18z5msdk2qLboPJJhodNRSLOWAV3Ch49CIArbJuueE+ccGMIjUvebWr1uVUk= 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 1753604010852596.9042311058115; Sun, 27 Jul 2025 01:13:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPU-0002Cz-DE; Sun, 27 Jul 2025 04:07: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 1ufwPH-0000or-Bv for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:55 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPE-0004hz-RK for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:55 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-24014cd385bso1441065ad.0 for ; Sun, 27 Jul 2025 01:06:52 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603611; x=1754208411; 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=mToJBu/VemOEmZefCjIO+GVG3ZJTtC6Z443TOamRSW8=; b=adqhoAOZTA+CsUK7vc5RNE26fUqBUc+LYiNfzv4UA6ZC7S7YgSaRD2SF/5IyuVKq8M 1TwZA6VkcBFsss16fijDfNKQTdSVD08v0VYjE7zmoMjyMroYhhHiD7hiNe/G3VC0L41L zuhgqZPxO4lTmq5Q659yhBxEn2x/slqdzRdzFptJcQiF3gmjbzK/ErFJsz+46yTYYZ0t X4xokPbEoKMLjY6Y7xr9Uq6EeWuEWT19bPTtKlluq31ABsnqvixpgCpblpDZpPYqrkvf JZBM7HRSH3ZcRNf+DUcsevZlkf9W/9rLebXfz7z3nE8M203NFKT7gmVk4Z2w+H1NZKA2 EeEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603611; x=1754208411; 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=mToJBu/VemOEmZefCjIO+GVG3ZJTtC6Z443TOamRSW8=; b=ic1l7aJ3yRh20E8zD606pkTqG/uew8JnED5gz5f/ekkBXFY4v2AK3iV/0hs2n7XIyL NJn4fyClcDsdG2bs2qsZcwLmF0MCYsL3do2/rlpPmmpd8sFpFZSUxn6OSYjOJGvrJI0z /UER5Nro+iDN/2NHCZQ9h6QqhJejlZaS1pCf0Zbd6anuf5hDMRgVsCPIhboTBjeRdzwj 3QezG5aNrnJw2uQc7vBzscjge4jUXgXYakXC2sDppxUyQ1SfOvMo5JJZkfpg6rI/iC3+ Hz4nhPVCjatUpyVFgjIKgwkGRV9SqLlZXqXBlvrQEwOmi235xKTjiEysq/MlOXo8r2vR x5ug== X-Gm-Message-State: AOJu0YzDWFbt9aCzNdQqzYCJ93QrU14DbPiMdAiiBBohSa9Ub430mtZN vT3kM3f8zprZQVpM4CigvJhvjoJkUP9gmQ1tBcFaYT6fwrUm/cLKwMGtCeFKm1ZYLX6jThxT4fX qs3Er X-Gm-Gg: ASbGncszeV6hEAURw9g6n3yYwqfv+zvcunuHvg2OLbmlLxGXpp6YUAcZ4EqUO9myWvS 5OF/UsUyu+Lok3aKdQILBoMFHmGPvOkraM5NI7D229n4jLq7Q444o412afvALdBKqzPsHWC3f31 LF71Wi16LOcuq+7pvwYlOwNW/XFjMziNAVKIu3uBYiMmA7PZiSGZNAROya6RGmbuwWQI4STYz2O 0iEe0xQUsvIdwCICW62uePxejC0ty82P6+XdZmah2+LCbQhiWJaH8eVEbZuiqFVzT/94AAaklqp GZwc9lVI6UzgGj2ni3KwjhsXf9P15Q4P/Ird2fL0uJI7/cc6qyQDr/QKKZYupfK5vK99CubhKdS Lyq54ZMhWZgmRWbKTPj48bTmKJc0alg/2RyuYor2mTQQEHxwUpvAMg2Ipg+EyLcetuBYffhcxW2 drj6bbGoDXvQ== X-Google-Smtp-Source: AGHT+IEUJaOXL1ZJTibUTZ0Ja7PxjIjlFVfY2y5pdng+8Z8WFGFX6XmoaGgigM6xGeBEkS3TL+j50w== X-Received: by 2002:a17:902:fc46:b0:23d:f499:79fd with SMTP id d9443c01a7336-23fb31c1b0bmr99615095ad.40.1753603611092; Sun, 27 Jul 2025 01:06:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 44/82] target/arm: Add GCS cpregs Date: Sat, 26 Jul 2025 22:02:16 -1000 Message-ID: <20250727080254.83840-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: 1753604012235116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 2 + target/arm/cpu-features.h | 5 +++ target/arm/cpu.h | 12 ++++++ target/arm/internals.h | 3 ++ target/arm/cpregs-gcs.c | 79 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 3 ++ target/arm/helper.c | 10 +++++ target/arm/meson.build | 2 + 8 files changed, 116 insertions(+) create mode 100644 target/arm/cpregs-gcs.c diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 9efe9238c1..bc6adf5956 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -774,6 +774,8 @@ typedef enum FGTBit { DO_BIT(HFGRTR, VBAR_EL1), DO_BIT(HFGRTR, ICC_IGRPENN_EL1), DO_BIT(HFGRTR, ERRIDR_EL1), + DO_REV_BIT(HFGRTR, NGCS_EL0), + DO_REV_BIT(HFGRTR, NGCS_EL1), DO_REV_BIT(HFGRTR, NSMPRI_EL1), DO_REV_BIT(HFGRTR, NTPIDR2_EL0), DO_REV_BIT(HFGRTR, NPIRE0_EL1), diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 83875c06bb..e3754df786 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -719,6 +719,11 @@ static inline bool isar_feature_aa64_nmi(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64PFR1, NMI) !=3D 0; } =20 +static inline bool isar_feature_aa64_gcs(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64PFR1, GCS) !=3D 0; +} + static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) { return FIELD_SEX64_IDREG(id, ID_AA64MMFR0, TGRAN4) >=3D 1; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index da42bd4466..1da73196f0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -591,6 +591,9 @@ typedef struct CPUArchState { uint64_t mecid_rl_a_el3; uint64_t vmecid_p_el2; uint64_t vmecid_a_el2; + + uint64_t gcscr_el[4]; /* GCSCRE0_EL1, GCSCR_EL[123] */ + uint64_t gcspr_el[4]; /* GCSPR_EL[0123] */ } cp15; =20 struct { @@ -1735,6 +1738,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_ENAS0 (1ULL << 36) #define SCR_ADEN (1ULL << 37) #define SCR_HXEN (1ULL << 38) +#define SCR_GCSEN (1ULL << 39) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) #define SCR_TCR2EN (1ULL << 43) @@ -1744,6 +1748,14 @@ static inline void xpsr_write(CPUARMState *env, uint= 32_t val, uint32_t mask) #define SCR_MECEN (1ULL << 49) #define SCR_NSE (1ULL << 62) =20 +/* GCSCR_ELx fields */ +#define GCSCR_PCRSEL (1ULL << 0) +#define GCSCR_RVCHKEN (1ULL << 5) +#define GCSCR_EXLOCKEN (1ULL << 6) +#define GCSCR_PUSHMEN (1ULL << 8) +#define GCSCR_STREN (1ULL << 9) +#define GCSCRE0_NTR (1ULL << 10) + /* Return the current FPSCR value. */ uint32_t vfp_get_fpscr(CPUARMState *env); void vfp_set_fpscr(CPUARMState *env, uint32_t val); diff --git a/target/arm/internals.h b/target/arm/internals.h index 7a42f8be0b..350b8bc678 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -253,6 +253,7 @@ FIELD(VTCR, SL2, 33, 1) #define HCRX_MSCEN (1ULL << 11) #define HCRX_TCR2EN (1ULL << 14) #define HCRX_SCTLR2EN (1ULL << 15) +#define HCRX_GCSEN (1ULL << 22) =20 #define HPFAR_NS (1ULL << 63) =20 @@ -1778,6 +1779,8 @@ void define_tlb_insn_regs(ARMCPU *cpu); void define_at_insn_regs(ARMCPU *cpu); /* Add the cpreg definitions for PM cpregs */ void define_pm_cpregs(ARMCPU *cpu); +/* Add the cpreg definitions for GCS cpregs */ +void define_gcs_cpregs(ARMCPU *cpu); =20 /* Effective value of MDCR_EL2 */ static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env) diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c new file mode 100644 index 0000000000..9c06100d2b --- /dev/null +++ b/target/arm/cpregs-gcs.c @@ -0,0 +1,79 @@ +/* + * QEMU ARM CP Register GCS regiters and instructions + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/timer.h" +#include "exec/icount.h" +#include "hw/irq.h" +#include "cpu.h" +#include "cpu-features.h" +#include "cpregs.h" +#include "internals.h" + + +static CPAccessResult access_gcs(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) < 3 + && arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.scr_el3 & SCR_GCSEN)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static CPAccessResult access_gcs_el0(CPUARMState *env, const ARMCPRegInfo = *ri, + bool isread) +{ + if (arm_current_el(env) =3D=3D 0 && !(env->cp15.gcscr_el[0] & GCSCRE0_= NTR)) { + return CP_ACCESS_TRAP_EL1; + } + return access_gcs(env, ri, isread); +} + +static const ARMCPRegInfo gcs_reginfo[] =3D { + { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, + .access =3D PL1_RW, .accessfn =3D access_gcs, .fgt =3D FGT_NGCS_EL0, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[0]) }, + { .name =3D "GCSCR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 0, + .access =3D PL1_RW, .accessfn =3D access_gcs, .fgt =3D FGT_NGCS_EL1, + .nv2_redirect_offset =3D 0x8d0 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[1]) }, + { .name =3D "GCSCR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 5, .opc2 =3D 0, + .access =3D PL2_RW, .accessfn =3D access_gcs, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[2]) }, + { .name =3D "GCSCR_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 5, .opc2 =3D 0, + .access =3D PL3_RW, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcscr_el[3]) }, + + { .name =3D "GCSPR_EL0", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 3, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL0_R | PL1_W, .accessfn =3D access_gcs_el0, .fgt =3D FG= T_NGCS_EL0, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[0]) }, + { .name =3D "GCSPR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL1_RW, .accessfn =3D access_gcs, .fgt =3D FGT_NGCS_EL1, + .nv2_redirect_offset =3D 0x8c0 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[1]) }, + { .name =3D "GCSPR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL2_RW, .accessfn =3D access_gcs, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[2]) }, + { .name =3D "GCSPR_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, + .access =3D PL3_RW, + .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[2]) }, +}; + +void define_gcs_cpregs(ARMCPU *cpu) +{ + if (cpu_isar_feature(aa64_gcs, cpu)) { + define_arm_cp_regs(cpu, gcs_reginfo); + } +} diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b472992b4a..d9318c5325 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -644,6 +644,9 @@ void arm_emulate_firmware_reset(CPUState *cpustate, int= target_el) if (cpu_isar_feature(aa64_fgt, cpu)) { env->cp15.scr_el3 |=3D SCR_FGTEN; } + if (cpu_isar_feature(aa64_gcs, cpu)) { + env->cp15.scr_el3 |=3D SCR_GCSEN; + } if (cpu_isar_feature(aa64_tcr2, cpu)) { env->cp15.scr_el3 |=3D SCR_TCR2EN; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 7ba802f2d6..f006ecabf3 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 02:14:15 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=1753603734; cv=none; d=zohomail.com; s=zohoarc; b=ilUwCwlvPL/fzMVsv8wl5EALQj/cLfshhle5gVVPFNiAfQIEj6SWMt8tUKFF/cosl+mgIyQWwl68uTf4Ho6POU3lTp+I5+/kWBiwyhxt5z3/TBJzvjhCXsX6ryy2aAGbq94bQaklLkTW9Hc1rwE6zE6XIjgRQrbYbUP/c2CU3mE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603734; 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=n5KGw0rszlxfQOasp4Y8/ClM9+NCtEfoSabGbZCzMS4=; b=SuplSSTWY3VzHHmaaq0H1zz+f+InZmlen1JelmUMn3y4DqtpkVtaC7ne9oJsxNG42FgyJU3EIhbeP2iQQfmo+kL1LBGtCQxMJLA0xBptsxmAoNMcuyDsEIfNH8wgxzFfCvrKE0oqvzVYwvAEM0WgLIOkFmNkW2EfEb/WM4XcrlQ= 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 1753603734466342.0950817798904; Sun, 27 Jul 2025 01:08:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQD-0004dZ-KY; Sun, 27 Jul 2025 04:07: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 1ufwPI-0000sa-1x for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:56 -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 1ufwPF-0004iX-PV for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:55 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-237311f5a54so28275045ad.2 for ; Sun, 27 Jul 2025 01:06:53 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603612; x=1754208412; 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=n5KGw0rszlxfQOasp4Y8/ClM9+NCtEfoSabGbZCzMS4=; b=ktygabfN0hBV3mo5IC6pJIqD9oWdZrL3hZD6GvCddn2/9af12cFTxeZFWt9aWrj81/ oG1Y6IVM47T4qoLUqQ2eFv87QfrjExjoAl9n2FKiSUBMCpB4Uf2fZ9KY2RfDkj1SPaAc o9ZgcIkGzS7Cn6ncupkG5DFI6LdvtQSm3tYMc6bhiI8pgGqibr4oPfhxTmBItbOHS4nq 2oVuisTadsEQY9lGOOcszbnSYdkmMGDbv1/sk5SDVzeQBSMJlvtHfqZ+T2YCMx58tUGn CkuGRiOCJYjE7TshanQR/pIRNfoHZ58iU9k3SPxpqlfY7/+aI9jcus1MdgtQ3ySajDIA VTcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603612; x=1754208412; 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=n5KGw0rszlxfQOasp4Y8/ClM9+NCtEfoSabGbZCzMS4=; b=tes+UJ4RfBAcwB3Jdhv4owoP1u30tbAD/9LMsjSL9PAn5Y6ip8RYgKclDFWMygdOG5 NDtdcnxo8oBiNmQLj53ksFFag3fAAdVtmC9aGTbw91t3I52eFgRgbEuXDAo2RNQ/Bxbd 5rgFrUiMxsgXGCsMpApnPOo3/HRFGL/SNjMzy5I0DnvpbDiRPLsmz0jNIJA1nIkBUc+4 1h2zhtyHWV7jp8//5KbRlmDiR/8HT7vnWSizjkyRTQNeolf+WKLl+4h1dL9/xfKvlu5o +1LT9k/hx5ljrdz5GRcYZfriMO9+VNqvrtrHhhm8Ywth+RF36FJ7C3leVZoopSlaA0Wp hRjg== X-Gm-Message-State: AOJu0Yx48/8TqU67MinT2YZWuzO/exIg6fpQVtUlTU+VTN0/njS2L7GL ZM3h567yvprXxPykTeF6x36vKiof81RYcCZb+3TOxjnSwfhlMePgx3PQCuPqIVwXnUhRHQwWeFf 0JOpx X-Gm-Gg: ASbGncs0bgNRNbNclKjsgrKdCQKqBks3p1LGmIuzb+3LUQ0uNN4sxQjbluUm6OSy7WR WCcHQgOBbDu/sQ2kfPFSGNnW8AuE6Z8oLH7P+jfey2z0NsFzhLzy/iIEiytNSg+flU/2p6sMvTO J4EkM0TIy/5iIlfjZCJNwuZhITsMbVSwlbYf5IQaeD1n8+pWHmDgwsaHNRBduK7VPr/i/ZCIYrd Jylrgez2vG/fTrHhwdOP3yOJT3auailO0Y+Qx2ids13fcYVdFIfyS+/aH9GvEYVT8V5QTP4W8o3 JUxcjyJbE3NT1Gb76OlSayuz/Nc286suBKq9NQ2/aQzg/mn8/Yc6Jm0+u43y1AwsY0PX86M2x0U V/1r+HCROlbpRmlvrcAGzDMd4MVF6zrhcvjKPJdIoXfcR4xG6d2JxtlTLeuBxr46VGtaV7Hdkhd QuHtJsK3RV6g== X-Google-Smtp-Source: AGHT+IH8McHdk+grdCjzVKen7FGqyuLTHeSkNtc79Qcv8+YVmp5fw0PC4BlSP+B5QC7uza4W+F/scw== X-Received: by 2002:a17:902:f605:b0:23f:c945:6067 with SMTP id d9443c01a7336-23fc94568c5mr65886905ad.41.1753603612210; Sun, 27 Jul 2025 01:06:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 45/82] target/arm: Add GCS enable and trap levels to DisasContext Date: Sat, 26 Jul 2025 22:02:17 -1000 Message-ID: <20250727080254.83840-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603736349116600 Content-Type: text/plain; charset="utf-8" Pipe GCSEnabled, GCSReturnValueCheckEnabled, and CheckGCSSTREnabled through hflags to the translator. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604556; cv=none; d=zohomail.com; s=zohoarc; b=QjOM/CIBTnf6KOd6UTQCHeND+T6yBBhQp7vOLuEsDY+y8YIzghGLQYhV5vhI7rF3yk4ou0AYLnTxKcIaVNnmLPmXJLZOqh7U+sHJlv7TzkFntgZLTBhsGBA6kX5xRiGVuJj3ycSBBbjxGXF27GI7ce0p1rH3aFPyX8L3AKOGtJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604556; 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=++Cy69LINFZDrXdrTLqtc7wtmB6LxpThVdWCRFE8Wj0=; b=LUbd4PjW7g5PZjVIGdCGED4KXK4qaGWf7NCZaKttxUvvxtxz91bVC2QFVT4KJ4ZjylDHIjZYhAkW7JXZz2BOwhfxBU2bH21gutAfzaz7bQlhxV6eXpFkstmXoUo5ZlThQ40kxODqfrOA1sXef68DMyb/d2h+9wKVlWXrm6/4Fx8= 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 1753604556445865.5004390063009; Sun, 27 Jul 2025 01:22:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQO-0005LZ-13; Sun, 27 Jul 2025 04:08: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 1ufwPI-0000yf-Sr for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:57 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPG-0004it-S0 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:56 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-23dc5bcf49eso46938105ad.2 for ; Sun, 27 Jul 2025 01:06:54 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603613; x=1754208413; 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=++Cy69LINFZDrXdrTLqtc7wtmB6LxpThVdWCRFE8Wj0=; b=HZjf8yH04XHIprUoWm2eHUSbVHSyWZEsyEfmQri/eyKhvG+QYgctKQaT/1EpDohbAr Y/TmlrQ9ro25aYy+xmXSIoZH0KVUY3a2yuVrkb7TR5GvLl1LZsdGBG7FpG/b0+JzS6Z1 27RQsk/l+npvG5pAJgApKkoAUIoU4Ut2k9C95CtvhrdncTraFAg4uzFJ7yEFEoLKKeWR 62KQP2fmeo8SpN8aUYie//RiOOSepWvCSElO8BOmXFPb6U/t3hNEsWTQnquX1h97ra3H NaVZGKrBD99jFdZTtNpyCkVSseC+Ir7vUXmMa8fb03exv9oMKMg0hmEaJ8U+MsDlIP7L MlKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603613; x=1754208413; 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=++Cy69LINFZDrXdrTLqtc7wtmB6LxpThVdWCRFE8Wj0=; b=FVqIcraiJguTFclIeswIk+aGslWAu/pug7xWKuURQU+AQRkGAsWie2/ClG2yV3a1BX 5UI5dP4SZNULCPNSQRXyc1QfGHTClxtlKJiM0HfOjVHI7LOlaa+VbxJP9dojKXjTNYG8 NH+RDR4pwD1gI0CXw3cadOx83vB95wf59dgX9yjc/f6kzxB9DRiIjkfL4Eh6DgNKABwp t47rBmyNtxFZALcBRnurHaaX3DH2MLpTLaWu+vJLT6ruGXLRvIOU4sHLo3xtM99Af1Vt EmR2Zw7f9V86/CvHZu0SfrS8cMFhDAatpXDEsAXSlu0ElSaZryxiexhQWQ24Yq3ARrlT n/zQ== X-Gm-Message-State: AOJu0YyL1QMXMTZlOtjrMrzqBfTtjzjO1AGa6wRjJoOO1yInCqy8kwtz a+cG2LtF3YvZ1htcZGDQIsxzYWd6+qxxSgFnXYI1E7Dt8K7SFcPv9nK6Yx3gIOkWDpRBQXtLfVL MkVd0 X-Gm-Gg: ASbGnctIiTMM7nf4fFGaoiyGKzUI7dzSHB168eWDYnonN6fquqh56edT+w56IbhBRw4 Ovhslikzpw60dbFWE8Lu3DfBtevdmb20YU+J+i5MMmV0rJLmqKiSXAR0U/x/rXd08XZbMjFeSwH 8qriVR34fb5xC2qcaaMItRUa70MttJ2ZdXu2nQZNEkfPevr9PZ5Qnsa6rSoxzfo8ZcVYOVtLqFT UEZ23k5itZWRqvImKaK8t8NJddiFV76scxEcB6YenA4PH9L1kOMFMwKf55slRJQ8RQ9jV0k2DkX YyZZx4aRh3H/bk/4dGwlE7Goebgp7yswHuPo6yaUYf/Wjl43OVvsC2/2gg8QCMytFYpnWZk8PI6 pQH2Dxh1gA9d7IYQeBaTSBRkFGbotnAw9nA1fJ6hTm+781mixM+WTM/sn49DmcLNyuDtAu97lrZ HbsC2lYz32hg== X-Google-Smtp-Source: AGHT+IHOUX/HL/pMvbV6Y1ALjFzm1L/dAQ3ppwp7NGAFiIn0x2lHOWBsR9QoqSka7Zymiw9EuHTslw== X-Received: by 2002:a17:903:3c26:b0:237:f76f:ce34 with SMTP id d9443c01a7336-23fb3082c1bmr121104465ad.15.1753603613488; Sun, 27 Jul 2025 01:06:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 46/82] target/arm: Implement FEAT_CHK Date: Sat, 26 Jul 2025 22:02:18 -1000 Message-ID: <20250727080254.83840-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1753604558356116600 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. Signed-off-by: Richard Henderson Reviewed-by: Gustavo Romero Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604366; cv=none; d=zohomail.com; s=zohoarc; b=gPyVb4Q5btxpx9/JHb/p1rmuEg3gIowU3CjhWFDhsecgwQmLxBYp1cMgKEbXo1HX0Km9KuieGT6gw+/b0fejm9hx1EgZyxPYAK5j4geyCt+chbz05gvraczWQxP8QJCh5pJEhZzGNQvbLv7blE6QL7MnLUd3+eiGssmM1/ND5/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604366; 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=sxBCi6sSWmDnM4iJ4ormMiI3d1NPG8eHi+yGWtcyMy8=; b=TVkqSZovwlieC9gGk2S52rweG7e5+rmorf2eZ2/Xut3Ij9e2nEuapl2CqKWKl6p6tjiHMLwyjvrOYg8CblcDOY07/ZxZAzMuCNQbUx0gBBuUuzm0W4wrxyT2ZrMZA8bnNbNgdmfV1Eqwor5kQE1Eeqo36kGQpKuzLGvMykJ6iWs= 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 175360436614943.543251235313164; Sun, 27 Jul 2025 01:19:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQT-00064e-Uc; Sun, 27 Jul 2025 04:08: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 1ufwPK-0001HJ-RI for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:59 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPI-0004jH-6c for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:58 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2400f746440so1203245ad.2 for ; Sun, 27 Jul 2025 01:06:55 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603615; x=1754208415; 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=sxBCi6sSWmDnM4iJ4ormMiI3d1NPG8eHi+yGWtcyMy8=; b=TfrPpl1JwGA+1W55c6Q3Qay7ZmAGRiOxwbbrSqhCxvFCXKk4YR94LPuHrsOcemr6j1 dsSVgCF32Lj/+nkEtyWLvSaTKI8JNFYoxjUwCFwCSe4u9iEUV2jZhDco/42YridlR2n4 IAqvBdwzhwYePU1DarMLgkr3XONs9C/Zy94HqUGp/KYCe0dAxwaNN18UNMArqQ7U41zC w+Ew2RriXyJxrv01TSNM2zflyzTb6iN5PUnrRmiABWrxC4fq2iXGcBkRxbVrcpLSo7DA VAoTSlvwyarWh8gcwQVimsZawEjZ4jBvNHun168rn4p1/5E2XVqW7xNCg71dF/9poqu+ 6p6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603615; x=1754208415; 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=sxBCi6sSWmDnM4iJ4ormMiI3d1NPG8eHi+yGWtcyMy8=; b=WneviyKgR7awA6CirxG8YyA718Gj0X9cYhm3YpUCQDHAfoVftX1+iFu3TCOlUFkGUQ MWR8XBHRZeAz5QOr5hOIVvu91R1vH4UoM8x76lhYrzwLPjZf8IG6EWKcpFjOv4qOIAS+ 4NF0nlZkAQBVLk4eWfYrGukf7JdSiE4DXLOn8ZykDtOhCFMZkRFmvxY/rtjFmb2iRhNX Yj52FBySk/hi2dpatAOc/nOZMKSDQRKbdBIf+FmZ+o2XHOOqcLcm/eoe3FiZAUf/UFUT AUxB2YTmc4PUdQcM3DB9lo1/nmMpRbj/kOM7bhbOg8Fay19t5WyCoEs/oWjUuYNFEoBU My8A== X-Gm-Message-State: AOJu0YwihHuO91OrnFD82awMKsXTYl7Q+mNWePR0D+zZaLyJ602HheWx SZjYfdTNVTHxz9yrC+Cc9+p2YFq6A+AA9TiBrMtZIsvz5PAR7BJ3/Q+/SlJDx60xTG1W9luti7B cq+Zu X-Gm-Gg: ASbGncsYehDAUlBTCeytVfjxmUnrJKRmc6T4XqH/NXWOl1gnFopr0gcsYJH8IjM9n2O ETTcKuHPdNSQeOBoIDY5GOKAkc8rdrRm8B//evE303NtK6uPbPk70RStPjTIh/QNkDyF88ynR6R 3eU6qU+60NCwLGjR2K3FFaA18yJTQqAVGU5KOsEJ3yp56ZKOmpKHimk971zEKJnRotUJEzc+B6N OTwOL0ebfq8qQ/Iy1Hh8aZS4h/992ifArjWRsD56l0L1eMG8xRorBCNiFfcOUWGqTJXHCfAMkjF TXRe4q/l2LSN+egUsaRyUxO+PVCxfknyNd1ZUVQeUMjf9MkKkiPyx9LieiiC87+RV8+wfRgBF3i yv4ov3HB5nUFc5CIMgjeaS321Rsy9EyXGii9e7dmJEF/tLeHUxF4TnnAiDA2koeUs3/yXT4VMNF IORiUfM4To8bthWYdi3Sru X-Google-Smtp-Source: AGHT+IHHJXTt10nz7F3w65yOPRkbceLMtVqmREy5ERgr/fyCAtvA772otsplnIfyqy0BXYS0riKUDg== X-Received: by 2002:a17:903:1b05:b0:234:b743:c7a4 with SMTP id d9443c01a7336-23fb30e42a3mr127813815ad.38.1753603614630; Sun, 27 Jul 2025 01:06:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 47/82] target/arm: Expand pstate to 64 bits Date: Sat, 26 Jul 2025 22:02:19 -1000 Message-ID: <20250727080254.83840-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1753604367129116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpu.h | 8 +++--- target/arm/tcg/translate.h | 20 ++++++------- target/arm/cpu.c | 6 ++-- target/arm/gdbstub64.c | 1 + target/arm/helper.c | 11 ++++---- target/arm/machine.c | 56 +++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper-a64.c | 2 +- 7 files changed, 81 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 98360b70b8..7769c4ae3c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -268,7 +268,7 @@ typedef struct CPUArchState { uint64_t xregs[32]; uint64_t pc; /* PSTATE isn't an architectural register for ARMv8. However, it is - * convenient for us to assemble the underlying state into a 32 bit fo= rmat + * convenient for us to assemble the underlying state into a 64 bit fo= rmat * identical to the architectural format used for the SPSR. (This is a= lso * what the Linux kernel's 'pstate' field in signal handlers and KVM's * 'pstate' register are.) Of the PSTATE bits: @@ -280,7 +280,7 @@ typedef struct CPUArchState { * SM and ZA are kept in env->svcr * all other bits are stored in their correct places in env->pstate */ - uint32_t pstate; + uint64_t pstate; bool aarch64; /* True if CPU is in aarch64 state; inverse of PSTATE.nR= W */ bool thumb; /* True if CPU is in thumb mode; cpsr[5] */ =20 @@ -1556,7 +1556,7 @@ static inline unsigned int aarch64_pstate_mode(unsign= ed int el, bool handler) * interprocessing, so we don't attempt to sync with the cpsr state used by * the 32 bit decoder. */ -static inline uint32_t pstate_read(CPUARMState *env) +static inline uint64_t pstate_read(CPUARMState *env) { int ZF; =20 @@ -1566,7 +1566,7 @@ static inline uint32_t pstate_read(CPUARMState *env) | env->pstate | env->daif | (env->btype << 10); } =20 -static inline void pstate_write(CPUARMState *env, uint32_t val) +static inline void pstate_write(CPUARMState *env, uint64_t val) { env->ZF =3D (~val) & PSTATE_Z; env->NF =3D val; diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 3e63dad2b6..1479f5bf74 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -378,27 +378,27 @@ static inline TCGv_i32 get_ahp_flag(void) } =20 /* Set bits within PSTATE. */ -static inline void set_pstate_bits(uint32_t bits) +static inline void set_pstate_bits(uint64_t bits) { - TCGv_i32 p =3D tcg_temp_new_i32(); + TCGv_i64 p =3D tcg_temp_new_i64(); =20 tcg_debug_assert(!(bits & CACHED_PSTATE_BITS)); =20 - tcg_gen_ld_i32(p, tcg_env, offsetof(CPUARMState, pstate)); - tcg_gen_ori_i32(p, p, bits); - tcg_gen_st_i32(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_ld_i64(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_ori_i64(p, p, bits); + tcg_gen_st_i64(p, tcg_env, offsetof(CPUARMState, pstate)); } =20 /* Clear bits within PSTATE. */ -static inline void clear_pstate_bits(uint32_t bits) +static inline void clear_pstate_bits(uint64_t bits) { - TCGv_i32 p =3D tcg_temp_new_i32(); + TCGv_i64 p =3D tcg_temp_new_i64(); =20 tcg_debug_assert(!(bits & CACHED_PSTATE_BITS)); =20 - tcg_gen_ld_i32(p, tcg_env, offsetof(CPUARMState, pstate)); - tcg_gen_andi_i32(p, p, ~bits); - tcg_gen_st_i32(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_ld_i64(p, tcg_env, offsetof(CPUARMState, pstate)); + tcg_gen_andi_i64(p, p, ~bits); + tcg_gen_st_i64(p, tcg_env, offsetof(CPUARMState, pstate)); } =20 /* If the singlestep state is Active-not-pending, advance to Active-pendin= g. */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d9318c5325..ec63297165 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1208,7 +1208,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; - uint32_t psr =3D pstate_read(env); + uint64_t psr =3D pstate_read(env); int i, j; int el =3D arm_current_el(env); uint64_t hcr =3D arm_hcr_el2_eff(env); @@ -1230,7 +1230,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) } else { ns_status =3D ""; } - qemu_fprintf(f, "PSTATE=3D%08x %c%c%c%c %sEL%d%c", + qemu_fprintf(f, "PSTATE=3D%016" PRIx64 " %c%c%c%c %sEL%d%c", psr, psr & PSTATE_N ? 'N' : '-', psr & PSTATE_Z ? 'Z' : '-', @@ -1247,7 +1247,7 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) (FIELD_EX64(env->svcr, SVCR, SM) ? 'S' : '-')); } if (cpu_isar_feature(aa64_bti, cpu)) { - qemu_fprintf(f, " BTYPE=3D%d", (psr & PSTATE_BTYPE) >> 10); + qemu_fprintf(f, " BTYPE=3D%d", (int)(psr & PSTATE_BTYPE) >> 10); } qemu_fprintf(f, "%s%s%s", (hcr & HCR_NV) ? " NV" : "", diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 64ee9b3b56..3cef47281a 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -47,6 +47,7 @@ int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArra= y *mem_buf, int n) case 32: return gdb_get_reg64(mem_buf, env->pc); case 33: + /* pstate is now a 64-bit value; can we simply adjust the xml? */ return gdb_get_reg32(mem_buf, pstate_read(env)); } /* Unknown register. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index f006ecabf3..e404ba0f71 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 02:14:15 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=1753603810; cv=none; d=zohomail.com; s=zohoarc; b=Uq2piOxBfWBLN33zx1cXSao4qK4DwgOVVHMm+sYmqEEX1/9R7rERqAWtfvMpvRZMfSvF0rZDyo/rOVErkpkwmtQcqIlPrMyIkgof+V/uvJlZFnefYcKICRrIhuY+4q0ZrWf2XCCFdkLUtnCjC5MlESxyRs2YZJoxMPPJ7V02yEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603810; 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=aph0ZkYCjiTweukUbhlaS2yrRTHeOV9Z1zDO+YdfHoU=; b=Aht+8t/8QS1MK5HEJz8Eg31LeyXHkQBBgSKxNrWrJ1p0H6c3SVhH6oCDpdUHI2TXxoIIrXOuVt73MDPiAKH67dQy+ITbkHpFRZbiKc5IigNXfBxkAu9rgRFseLwF/xpRlcbssT24eYD1AIE++3hwq0Cj3K33vlKjPQzooXngndw= 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 1753603809984210.96420175461913; Sun, 27 Jul 2025 01: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 1ufwPp-0004DX-5o; Sun, 27 Jul 2025 04:07: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 1ufwPL-0001Nv-Hb for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:59 -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 1ufwPJ-0004je-Jt for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:06:59 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-313bb9b2f5bso3156519a91.3 for ; Sun, 27 Jul 2025 01:06:57 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603616; x=1754208416; 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=aph0ZkYCjiTweukUbhlaS2yrRTHeOV9Z1zDO+YdfHoU=; b=BFCO8noJ4CwkJvMxwu/GP0B4Lmym+xhCe08Ak0NfH0j9pz8Dsk2qTyYuylvzqvMwtj Ed2i0XHdldpN3v1HQdH2Fgm/pEVs3y4Lyn4ofOAyUntsYouYWPTY7yElHZakfY0UlMsO zAegL0PWcTbwz8caiIdAwwvGPS3deVGfV0ZE8tPf6BVkB/xtBMBllDoB+6NetgHIKVoK koOD3iVpGc1+9wSdYYREPAr+Bhh/jIQC1gBcUNipuNTeztCXqld9JeQ22A44kLfzfaRe kXtqCvR2Jt++al4jilkgyAA7tCcky1t6USVD2AO3ssOQ6yOPaHXYFPkwsYCg8iGlS/iU GSjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603616; x=1754208416; 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=aph0ZkYCjiTweukUbhlaS2yrRTHeOV9Z1zDO+YdfHoU=; b=Ujd4xrucQcKg6NROP04iBWAYywWwzxqS44DmXIEgHcStmNLTYiyiWkeVd9q4t7HQpw QXL2/0ubTjfnfPdSSXFWJQWEOn6W6xkcRfujd8iXUyxYLBxcEaHTx4ZfoLyioPfPk0Td zMCkodBYPeR1prZqLUW4IAFC4F/nQncyeq8R1+8GKYDuozJKsFungjA7IGr+kKYQxIe/ zPAsZcp5qcpm3toOmBwR7miFdTgyuKuXA2G00KPCdnTy17S9T4wPCxS+sbRgdZ8kkJFk gBJlYmsiRtZxR9ICMazPih6BX6Yj5i6E4z4+ToFZqpNNk1GV4glpC9WXC+fcvp/gIxvy XPfQ== X-Gm-Message-State: AOJu0YzpqIqD1DnMKm7cxSKqQ8qPZdDTKWQfL6ZT83cpdNd4Yy7+BzGu E7Pz69NyOCYwAmmE1wz5J98Qp9DXf2oPpvZMmd0KsjhdOTsOzg0YtlHYXRbPT6+KV84BMavhNqo tmC0i X-Gm-Gg: ASbGncs+ZeS/CIRV8w9opPYHNl+Og7QuqcsxNDRoZwhH3jflIXPukMs1PQfIKjtv22J pxxCcVpdmS7ZrCLVh2ovZASgJVxJxC0zHCXoXIsNSuNnmNv72XInzcSgp/v0v1F4f2sfCk5nYB8 3BeCp140qMFCxgxAhlvtvsruxJGkAeliv7LJnP/QqbV/TjcSDGKYauApHQzbK/0uepfh4gW8PH9 njMI4g4g2XxGDgJh3ve00ek7qwu4lctf90g8MLhDgqzpfo1SGTy0UXg3vSG0cQGl7o3InNTIruF JCvk0jEGM0yk7AbtjlVsTnUWRKSf8sNsjrVvSiOmcikR47TA0U838ZgBPgO0rT1xYhH2zuiiQPZ 2C6aJYthIh3qGsjauPzDLNGPHlUV0TmvWP4Py92N9y/uRtJnKTTwyplE3+JdQPAFPvTMg21W2pa iJdWsnABjm3Q== X-Google-Smtp-Source: AGHT+IF4jJzoNuOyW8ulnmLiKYz/LJK+i9Ip9ny6z5DTY/riG2Jv1c1+UFMaXIyIhtjobnSOAgEyTg== X-Received: by 2002:a17:90a:c888:b0:311:9c1f:8516 with SMTP id 98e67ed59e1d1-31e77879820mr10750158a91.15.1753603615935; Sun, 27 Jul 2025 01:06:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 48/82] target/arm: Add syndrome data for EC_GCS Date: Sat, 26 Jul 2025 22:02:20 -1000 Message-ID: <20250727080254.83840-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603810979116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604343; cv=none; d=zohomail.com; s=zohoarc; b=FC3lEFdP7sIsavMsVAynJRm8hDIxUN5PAilg4EO9FC+6xkwaBnbyhY38aRkZuIW9DfRUeXYG87F0PdMkzR2byY1tFT7u+jLKMWo/d3wswgro3qM81YMQucGwUjbSVmJtyIRaidfv4ynorPhG9vfBhOLL+rLdEA+PUQXMAYcko6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604343; 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=oAmWUG1RCHR1wBPHXNwosNOvy6qQDPfTqzqzFrLqHas=; b=h47UG0a2t5FDMz4587EXFLckOEl1mGT+ScHLwJmYcJeR4C4QOAFvQuvMo/DQZujNU5C2JAKvrSix39kXhf/sqWKUGSOPRE3pk4DIJYVLVG4sSEfR5eltmJhXjIey2C03mKODkNS/QDc1Ou3VAc5zbgpZGP0wpLTO18I47hF9UIQ= 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 1753604343988416.66582181540844; Sun, 27 Jul 2025 01:19:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQM-00057r-5f; Sun, 27 Jul 2025 04:08: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 1ufwPM-0001Yi-Uo for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:01 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPK-0004k2-Hx for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:00 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-234bfe37cccso28438025ad.0 for ; Sun, 27 Jul 2025 01:06:58 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603617; x=1754208417; 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=oAmWUG1RCHR1wBPHXNwosNOvy6qQDPfTqzqzFrLqHas=; b=WN9QlvB6idXj/5YWH8S02Uqc5ZNatnL7wQR+tvw0ntnQAQ5FIezgZqNqp+umu12xL/ WB8cWHMuj6sXAA/tlQicyXyasYOSAn4427FvUAB99xqckDdo/qpC8pYplkU2G0PxZmbx DMCE3+HomfPZTaVw+fmKkQK0YcaWVnGAHFf5tBLnvw0fC06m4rHqhCjtdNXj68tVu+eV 4gcwMrRfsasuG7a0kdmhb7CljWziIIlIy3X0iDyfZoWbcKfrdQxgAY7Ar6QMN1zjZ1tb Ps9X5qRnYNAe98Pgc15W0/5XDsqRmqROccYpU03o2MGmHqr1zQercxBZ5KOK6TAxm+RJ BFLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603617; x=1754208417; 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=oAmWUG1RCHR1wBPHXNwosNOvy6qQDPfTqzqzFrLqHas=; b=qJXLCczoAooTgZKD8faEjY5L0eYV2q+x4boDeNej3v01QoJO2FnfITgGicG8fSnt26 pmqbRKxoJLbRbPraYQm1dKI6y9haCwp+hUDLPXNcVA210wrtIOLQo9HaR+58Ce/ekRO6 d/0pSn3Bs+HbGgypoKV0kAvNKljNSRwbeGmTMjj4nnrlAdHQPBTCLFz7bpXg05CX9eNj cKRP6IRv6MDJASIN0EjJ37rQvT9WGn4oH7feDfZKl1YmgzHgFo62+xthEJM1RyopW/XU O2cyB+Ik8hGDTrXB8fsrO5qQ1X6rIilpZKXv6Z14YojV7BBbIV6SHuMq4S4LOJ2CX5Ql 7b1Q== X-Gm-Message-State: AOJu0YyxoKiJknvk9Y3Mrqm1qzgOEpg2RhVDut6L4OmoJnjcWgA1Z426 CWIzdTXPxBhpLtvy7XR0igQ8MTVKfQ7NEkg2kUl+WM38F5qK49owoX+MPSseT4M/TXQBc3CVHEi TUBRP X-Gm-Gg: ASbGncsRP8nnMvrY3+QneeSBerpXRUhlatKzhonegmWcI85XdYHOYMVPGDRkWnWLqeB LLUtsMbsR/OzKJh8hQaYz+oq5d+Mi7ikHlm/15gZ3ymRrwzWNNQqi+QjnYx++wUAsWDylpXj/BQ B0BiZvNhwASHJs1PYO6dLIqPvE7+UnxChHs3ugnpY4YtEVWs3pmbg0eFK2tgVxnpF1klVIzqDQ0 8cMsTFxs0Pt/tgXgPca4q2fUtVt9Mejkkhyh6SGLQFT5Prtv1wTjJKWsSL/p/XrMEieXoPArrr0 la25lqgUxKmzLhzM1yuHC5WnlZuort+AOPoyUiomeSvqVpvC2aY3wxzXo99IxYboh0UCA7lcW0P zOsR+Gh9ij2HTmJLJI+a3lza3hywsJv6N25GcArz6PS5lHdpTbbiS9xrfWaX4sqyh3DXr7Ie9/z uALzrK0tFNjg== X-Google-Smtp-Source: AGHT+IHuNkOu00Nar9cfOXak0qgpjdu+yHE8bl8psmZx7AJj/VK3tYntnqLLutsJ2jLBpdNsNmPNDA== X-Received: by 2002:a17:902:f612:b0:240:e9d:6c43 with SMTP id d9443c01a7336-2400e9d6f7emr12389695ad.51.1753603617060; Sun, 27 Jul 2025 01:06:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 49/82] target/arm: Implement EXLOCKException for ELR_ELx and SPSR_ELx Date: Sat, 26 Jul 2025 22:02:21 -1000 Message-ID: <20250727080254.83840-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: 1753604344961116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 e404ba0f71..2514a03c0e 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 02:14:15 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=1753603817; cv=none; d=zohomail.com; s=zohoarc; b=Z+F/gy7SsGuWSY/43FvYZdevwoKSj++KtDdO9Wz5xXizIhwyqV5yxuCcg4AU+llY9PXzLwA1jCtbRz3a8Gzzi37I8Pc9TxesDYN1ZrVbdZmosLmfrnqQi4VkehxMhYTaH2+OmLrbCWurOBkNAdpucVmXQdhM4pmc3YvwdOdLzU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603817; 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=+JapRuQj/rYjZd7QW4g+JSnFIid1K0Vna/nY4R0gHLQ=; b=OzTN8hmyYFJrFqodwA63OWmT+T+7lY0/0iKEIBO92kD7Ss+7ukPJqclPLtHss5LK7M7KheSBvivEawPSj3/r9kkmZFEKFg3GAeNhMM0yFnzAMdJ+DTXXG3kc54bLYo8mgQKNyWZ8v0H8EseslZxV0VcIwcPgbtAcZeP/0AKs5N4= 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 1753603817612163.88763172425286; Sun, 27 Jul 2025 01:10:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQS-0005o0-1D; Sun, 27 Jul 2025 04:08: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 1ufwPN-0001gP-Ta for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:02 -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 1ufwPL-0004kM-Ku for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:01 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-23aeac7d77aso31848865ad.3 for ; Sun, 27 Jul 2025 01:06:59 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603618; x=1754208418; 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=+JapRuQj/rYjZd7QW4g+JSnFIid1K0Vna/nY4R0gHLQ=; b=oSEpP2m9QeyR3C/LWCGjZjnAHy7pSFcrlaJ+yAIBNDLa8/Fy6RozqNtrq1KVVsmC+y 90tTjoO7l+9g/TsqofyuxgjSM0i9j/OMJB28ayc0EWvtR71sCHmwrS+nP6GilSVC6+xH AKGxeU12I0/LbrSDK51Zbr2lZwBd8ndzQ29BFCwhuLfttdLIdg0SjiOAAMicoozhGcIY CVhe4c2FS07+uyG653knXCnsCVlLK70cp+PK+vR7vhSe8Zhn8e7aOcUMdqVvcFHcN8zY 09MGTluF5kA1dlvp1cyRXCOz1Z7VVASP+r/luUzXcjQPh6NSvKoh52kyDKs4HCgdXJ5s mHJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603618; x=1754208418; 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=+JapRuQj/rYjZd7QW4g+JSnFIid1K0Vna/nY4R0gHLQ=; b=aqLAneNYWmMWMewD+1XNGCW2RUWuNJ3KVO0uAKvO/TEhMPgJe6WcF717/6rkUyOuIp OyCSoFEqoXz3QVfVcxBMs7nWhkedWEvyjMZusn7R4vCPmlt5mA9IyHzavXOkAwnDW0Nb eWuF/OfKT3diVLUKUB/lIFQjaUSjrg208TrJU7tca/+p6tfiOCSLtIpIXuFWJvmnwIWO dmdboZWftjKfx5PEBYhePS8VUensIwixSiRev/6k+z93xYcjk8hyP3CwBatj2gvOu6W3 k0UA/cMl/2+hJzBVJrzCZNF6/uIULMwOyLSFgqYl6iYwQAjp46TyU0bMmlUabvRT3Muw 1A0w== X-Gm-Message-State: AOJu0Yyk/M7qLJhKECi4jBhrl6+pG4E98Xar6W6eLSl3LZ5adIB5ailX vpFDL4XxTk0b/ZWH3pPJbm4BbFddrTBfBTSoxytQRgni7thexamQoZnHcwkmKTD8lxcWCmpqEVm 9b+tB X-Gm-Gg: ASbGncvR8hDUxF0zYZnOTCMwSzAwl4B70jho1scrIg87umW9zhftDPbHEDPfFobRZLw dt/RtPLZ9nlSdw2ovvzHFrCx+1MTxEyhBfwfWC5kQiMGwY/W7QLOBnrR6/02CjqSuH41IE/Cra7 Pl4KHz+RNJWCGIjZLVzVsVv+1zhEXjztrVz05Wh7KQ3xJbcjMwYnNWohXG7OHijaShmtSylZzZI 2xUDP7jHwOe9LCqvXFRlxVh8epFY4wzXxiYn8miDd6f/M/uF+7D2NUzXeKuRDofM6lrXJNhjWgK kJW15gsINf9gNWboEKgCuDHComfmwN4ir/g1f+ZJfdxHgLTKPc4PXTLnE2/rwVe7ErKeNWpU9Mr 6BP2ptSwjI+Ug/rfOy66/QWUcdsuK1ODiRpGF/x3AE6Aq+o+77LwxrkCf84GD/3/W+v9I2Gw5T6 fp8qdl9RQjdA== X-Google-Smtp-Source: AGHT+IG0uzV56S+Q3O8b+sX45ycBAFUkQ8fuad9Y6UGFaJ2Q+JT3p1XWOZCznNjuH7Cj9oTmYkn8AA== X-Received: by 2002:a17:903:22cf:b0:23f:f707:f97e with SMTP id d9443c01a7336-23ff707feaemr37050175ad.17.1753603618312; Sun, 27 Jul 2025 01:06:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 50/82] target/arm: Split {arm,core}_user_mem_index Date: Sat, 26 Jul 2025 22:02:22 -1000 Message-ID: <20250727080254.83840-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603819077116600 Content-Type: text/plain; charset="utf-8" Separate current to unpriv and arm to core mmu conversions into two separate functions. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604258; cv=none; d=zohomail.com; s=zohoarc; b=aFJT5kbO+cZ3N6Oip/eC+X42JAIvIeQvhQ7EK6kfCOvHFQsfuqv0hDQSx8cVbEJFGma3ONdTCzBOd7IgYcULAjIsmElPgil8rd5QQZJJusQV6JY2MTasyVCuIibZ1ZGWshFfzHPFDcj8pV+leqM8U0Tr+EJnbwlYsSZn+n5HHj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604258; 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=AhhZA/6ifKL4l4jO2ipFN7HTrNIURT3W9UEWXRBt4U8=; b=Fa/+wMc6hDqxteDMOsMc2VdLuf1jSw8JW9vhf33EzjajIXfeVUb/RSRzfXOw4DDJhhgSHa9+CH8YklprrjK9PIxo61ckElGAiqlCqoP5dSGsBXH1CuDIMUi0eM/EHm4xfTUzb1XYF28r0edIK6+50txMjzsTI6RH/Plg6iwMs3c= 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 1753604258988467.20784288038215; Sun, 27 Jul 2025 01:17:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPm-0003wa-LU; Sun, 27 Jul 2025 04:07:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwPO-0001ov-UQ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:03 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPM-0004ki-TT for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:02 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2350b1b9129so23722765ad.0 for ; Sun, 27 Jul 2025 01:07:00 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603619; x=1754208419; 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=AhhZA/6ifKL4l4jO2ipFN7HTrNIURT3W9UEWXRBt4U8=; b=rYMRsGyWEpPMC4XMooCswj/1+kIt7klBQYVBamYDf9FzpN9jyneWoxvd8/cLuHaiPo NSKJORIeEz41EuTWNunTpWYXxfAmdCD5gXTkCCClhUOPG2MvkUi3RN5GH1qqmP1iEVM7 V2zHJ1WXkwPoOHQ8QnZXhCaGaNuuwFzVQ27LoLwWG1LfWBhfasbK1hIG+U0EqxZphth0 V3M/lcux1qIbEkOVTlRprEDBDx7efajnJ4onH5OruKsFQKXrd0f33sFsTB2I9j/4C9tA Pt+Mtu7Q/IroIGtfGFc8e411f4Y76Llk1mQM7Do/sshSniutzU/ASN4kLPFwiLuPgr8D 57ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603619; x=1754208419; 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=AhhZA/6ifKL4l4jO2ipFN7HTrNIURT3W9UEWXRBt4U8=; b=eSgHfkV2bt4py+/3eMtHRxpRHscEX3fdZ64XZ+wlwRThwPUMmn86o0zsSaT2H0RwcO kICbABjzH850ImU78QATdi7zpAQcBWLwYzCs09u/dF5vKw+qmG2k97ie/UbEVuzqQlyV 4XYDJPZsa4rsHch69oQ7gmmgalc5cPtVyCeujzQBV7X8z4dOUalqL4sKvL7EJmYFaBdV zsu/KMgqx0VcmKN4DHCljmqury57cxGjA553UX5WV/RTtg21ThfRjpWaZjskfF19W0kq zOcibyGJ3NlWl61sw9XT56FuGEnpSX3X9i7aBA4tPvImVnVM16dgnbExTSE6gnImU/Jn aoaA== X-Gm-Message-State: AOJu0YxQZDW04rAKJyn0vCUfH6KU6n/gB5pMHyMjjf47OJ6TvpqMyFIN TqZ1gYnItfxDaZEJSiWGtTv3XYVBRSmvEsElvtPOO5Y9h8XgnCg2s3+WIc06ix62AeXLZAIa7Ty g2ZsC X-Gm-Gg: ASbGncsKJHeKnP9u/06G7LBKQK4fvHS+jmAzL7c+IOkRwk49ce1g0EyqQhL5Wrbuu/X q5KeS6SbrvyZcYbOyPO8XJzr//GyHrDWq2iGg4AuFiMtlD60bZHQpQdptGH+YEBLE3XGlXX+ikq uFHO5vHVEZp4vmCldKTTx2o6hPmnXvtm/A8y2q5QN3aEfpEvtRok2wIeLzhx9F0E4XrTCfNy03X jDhp1P42WhCPapi47d0FbTx9uD3GHaDRfw8GOWwzBlPJi3iQZlcoMdkv7doFFH2c7YnjlTWE03Q NfDrq6yXzxaaJeB6qRexGHJasXLaoSLMP+JDVMoT8ZTqmoVvCu/FSYET+PJy95rX7NPqktYM73r XhN/NN0qexADN8kXwMvmysdw5PZnuUDZaL6MRy1QKzbbxfr6PKl11fHB7m6gr29LBkzCqnHBhSa BuYPTICr96XA== X-Google-Smtp-Source: AGHT+IHfTSQ9wxp+4X1iKjflsCFlCHe/KKq9Gu7Meweg8oD37rB/f0IOs+R+RL1AYj4sJfR08BwFGA== X-Received: by 2002:a17:903:198d:b0:237:cadf:9aac with SMTP id d9443c01a7336-23fb30b2b1emr140422835ad.29.1753603619447; Sun, 27 Jul 2025 01:06:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 51/82] target/arm: Introduce delay_exception{_el} Date: Sat, 26 Jul 2025 22:02:23 -1000 Message-ID: <20250727080254.83840-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1753604260388116600 Content-Type: text/plain; charset="utf-8" Add infrastructure to raise an exception out of line. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604005; cv=none; d=zohomail.com; s=zohoarc; b=HaVi09IZOGfYj8OSmLPc17NIeM0UpntPlvRh1K94lrF1wOvF/8goSCxWRgw0nQ8BYyLcSqeSq+pkMtqs9t+Fl1Sko7fVbhWKChSJ/9JNQHYCz4Yz0W84Le7pVdh5qv8sz2iAMoBaArkPFzTc+TFjs1J/gdHqN3VGj/ddv0Ox2G4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604005; 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=Q1E53pgb9AZCt1kwtrkxIgkEwDfx9OIXorUzM2iqJtM=; b=EBWe40RDQwPr3BQHUPE30zEhp112izDU77YGyqKzsGwgFIEy63lJab6206qzObSkPJGC+z5fV499vQ7XPhZ1ZhshFcz1zu2Mp/TZHRlxmUOy0zBOy3EXuon8A5Dgq6/enhFSv88ICz1kit7swIYh4ipT0qQYbRvKOlvCCVBKkGA= 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 1753604005472580.8550729146458; Sun, 27 Jul 2025 01:13:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwR7-0007r9-3w; Sun, 27 Jul 2025 04:08: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 1ufwPP-0001tN-Mr for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:03 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPO-0004l5-01 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:03 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2352400344aso30525605ad.2 for ; Sun, 27 Jul 2025 01:07:01 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603620; x=1754208420; 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=Q1E53pgb9AZCt1kwtrkxIgkEwDfx9OIXorUzM2iqJtM=; b=E/98XfKCaXFIsjKP8+pKO1L9CAD3bMFnrLS/lsC19x4/brGyUy8gf2s3NZ3GlElr9o i++KbsVrPpH0oz+q7eYx3vz7lZjKqzdjyPBy06rrINFnHIKQ9wpeB89qhwE2yZKhqEXy RKvzAywW0Zj9QivLj+9X4gbQzptrrgmPi0B+roc6GQC+rDwlVuEmXfaauTTmDBdFTP+I u7VM8CtZDndvWxAQ2TMJiZKz+v0qwPux0gqkbphudvyBfyBq9ZrgTqJF/lSJ+/CO8cuw 5iv7XyXhphtd6xKgXKPijSLit2JAilfFrLBG+JHRJy1hkM8EhvNPGW/biqp7FyLiaYa/ KI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603620; x=1754208420; 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=Q1E53pgb9AZCt1kwtrkxIgkEwDfx9OIXorUzM2iqJtM=; b=M9zg7aMkBkbghrfcM/BsOFFhCBtGLwpGxPUTYtnTHrkBp4fHafeGjGItiZOcJbamD4 xxAJWOSd+Dtl4sZ6014CEfMLjZBFBmCywUpEqRGKbbo0JM8H87J8MXkujJDuun/27VKw oAIUp3IPKjiglj8g4SP7x+KBCxqH5cgJo9tYUq1gHlSV3D6ivlZEzGQtLduUhyqAMbEa l8GYZyGLC2FgOP40tDnZr58QSisLf6zhPFH3xKtRLL8q0y5+GSKipOphyMbSrNbvodte tcEHfHRq0UpbHP0MyMcuyABDfQpnoGQfEGUqiAt8srst9+nQcd9rXyKqGRHtz7mMoQDJ NHTA== X-Gm-Message-State: AOJu0Yz3+qtLPOukl9/WKdSJwqm+4Y7WI77khLHh2JcmtBYdcVOswKMN qa7Jjh/kZjIjS3NWT/nzhVAJSLsxEBe5TAu/e/1JIb8JsRT3gGxrSklIBm9EwvL3PP/KitDA45f peSz4 X-Gm-Gg: ASbGncvBpCX8zkl4tEgKTcH4Q9EoQZESmtKfhIYTwrSwaAF7gAErxwSmpXfXkGQgyhL YzhYpNWBMDn8OcoE9TKiQrfNcEkYK8yKCd+szJj87cdETCmMfOtRYJd8RQ2JDaVZz4UAWSzhXdd 19VruDzjjzVAO5sgcY9I+ic/inWBZR1cRWy2aHB3mKy2A+zMUgM41O3J3LRlQKVGMpVU2RWma1c Oy0ouT7DL+YF6Pu7sMKEwMOXVA9Zld7zVAk8DDSKsf9vYQKQybBmXEnIA4bbYvPO+8112ShQkek LIozQh6R/Wt3kkAYzcI5Xuet/77DWOVB2IBHFUyEm9HbiEGs+fG4gRrbyVVG/EgZvAODKKUXGK3 C5t63/ECPQQ0KVBjQiQ5HWcN4LnANYYLNVAjQtiVLWaaKpufs6F2Iu/Q3fVAXlqWMZEGFeebiQE gyp5adxVJUnw== X-Google-Smtp-Source: AGHT+IFzSx/oJgTSX6vJxIjvcD7JVwHH/1H5rkzdVhtJCT3r/tyrv7Z0BrQHle7g2OPRwrc/5IaI1w== X-Received: by 2002:a17:903:22c3:b0:234:a033:b711 with SMTP id d9443c01a7336-23fb31af6b8mr120133285ad.50.1753603620562; Sun, 27 Jul 2025 01:07:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 52/82] target/arm: Emit HSTR trap exception out of line Date: Sat, 26 Jul 2025 22:02:24 -1000 Message-ID: <20250727080254.83840-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1753604006336116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604151; cv=none; d=zohomail.com; s=zohoarc; b=WVdiBdke7d7nBexNtpZRl7oWzTV2+ZZrULRO7Ssy9bAchF88ZuLukX1W4ypOgX21EXC8RkBkpzMrMwqyYTmul2RrrYDLyclTPuDCVO73HRX5/fTY0n0X2qrAYhw9QGKsxuF2mhTBdFikpIX/4xcC+eUfGZUN5CVLzdStxlVwWw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604151; 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=s7c+QA7GWNE6I5/69pcOioZrB3w1TEGpVruYf14/lg8=; b=fEvKXF0GqpACY1p5ssaFtv893slfDjzrZtcLtPYMSaKe+mZzlmV2iT2pbkqR/Ocv7gpUJ28nGAttL8Gx5AQnZ33DsjmoyUMpcmHT+AOrxMmF4Z3MjItY8vV9EQFLBOXD4BVC7LDfKGmeKhdSZELuo1nyR0JRiQNSGsw7O8SX2f4= 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 1753604151594457.0001903721129; Sun, 27 Jul 2025 01:15:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwR4-0007lp-Md; Sun, 27 Jul 2025 04:08:47 -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 1ufwPQ-00020x-OC for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:05 -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 1ufwPP-0004lP-0X for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:04 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-24003ed822cso1924285ad.1 for ; Sun, 27 Jul 2025 01:07:02 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603622; x=1754208422; 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=s7c+QA7GWNE6I5/69pcOioZrB3w1TEGpVruYf14/lg8=; b=rpPY6Yo1ZwLqGGSu7uNiGnBvy0tswb3kHhGw9z6u5DqIDt2TSPNhPrCOgN4gMKtmc1 cBxlO/foOqhyEwON0feOP79GUvuA9GMqn+auWx0voiCRXRUu/g+yjF8py6vm1xbL7CtD 3CF8uaMX7bj/JicMNoggDAiOEhqImt06+Z8raePWOd69JM8LZYT2pe1QYjzxM/QbzdkK Oi6FCirJiaQzmZsVqrKEgEFIbC3FaCVEOCjkEdeeWjPyjMkR5IVGlF6lsn9wBzGGiz8A AlmWpKAedwGhv+c77i6aWhOKgM+A1VC8voVZAhh/KnXDVA2Mn92fz1+255/JPNotXwgI mHSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603622; x=1754208422; 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=s7c+QA7GWNE6I5/69pcOioZrB3w1TEGpVruYf14/lg8=; b=XpDhsYXvyfsJy+R8sv5joa72tLLV8AaN5jMBfMUChxz7a0jMbmSB/jmnSE+C7DVkrJ WwBszjQ0F8BHysB9p7y76qo8zgDBIwnAJNtVDlHYQNxzqCXTkuz5nBvUTuIcQ6MDcG7S OPfpCVOJ4RENuomOorh7oXKfg1nqaSGOT9/x12I8VqvfmxovZIdUUQzlF0Rj8pkyf1jq e5h0/xnhEr/LyaS3yQXjgqmtK9JmCm7thLzdNkXhWWfK8q1zULsFIAWDNDSWFpzCrqzy 53RBEThOT29avxa6ePoKhSvgtIoQ1qVgFP6fyKffIUxOqrLrBfxbeMNp8XAxZg9EeZfo mNPQ== X-Gm-Message-State: AOJu0YwBwupen4260gcOt1YPbBDZnDpHuVg7tnb4RDN28dI+trWSWI6D F4HaMGvgK3sU4Ljj5yqH5snIOlCNuLSG+KG2kNXiNJdf7Q+tCIsdezr+yKfl4sAnDq/Z4Gd2RpG +Sj1y X-Gm-Gg: ASbGncsvClUmdIH6yTOWV9FW+FbEzAaWMp3f/HsQfojtuc6sTAXfuyT96C/IQBNxbcM JUQRvPNjJTLlzFotaLJ9h73k7OdyFBbtC6iN6HMy07Yg1DLTCFK2363SOa6WcwDeqPJYTMMz/eY 8Gql7B3H5uUL7X/HtYZogHP3MXJNIsnjanU4t/eM3Qo5F4ebnb1ivMmnH1NEegWuiLuyrg8WQtb 8VogXItYbukdy0QaIa4U0SLPj7c6UMwGjYa8aGi9tUXZrpSYl3NynLjZlSylxoEjCvd+24Z97Ab dxcVtI13uVc+TY6Wlt1tO7c7nnIlN8hg1x8J2bLkQZGdu4jynIl80c64YYs5g9JKci7qwALHa7r Ef/STWq6DoLOeXKyZr7n0rfNpacjdT9B5A4cUdS/Duj92juWGt3SO3m2bLKkggzKuhTNnx8d7Yo VE9oGGl9TSSg== X-Google-Smtp-Source: AGHT+IEwyg9SGUhFgm30Es4mhpzpXYNuR+cmqe81WbPYpzx6AKQ8J1wJRZTvJjqL5jgrBSb0J7ZlCw== X-Received: by 2002:a17:902:ebcd:b0:240:1f25:d455 with SMTP id d9443c01a7336-2401f25d734mr1628395ad.50.1753603621694; Sun, 27 Jul 2025 01:07:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 53/82] target/arm: Emit v7m LTPSIZE exception out of line Date: Sat, 26 Jul 2025 22:02:25 -1000 Message-ID: <20250727080254.83840-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753604153331116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603907; cv=none; d=zohomail.com; s=zohoarc; b=cSw67aFTce1moS+m3tut1vy8I19AfVKrHzV9YehLcuCiIKTZXDcbXpYkZLzTyqrS+Pg+n819lDcb+mTfwMwNDJLSKr3JGUQSNROzm+C38ClTziwo6YamqZ+CP3BCxKQNI30N8POj82THnusGdbRI5D1Zs2fvQYwbvRdWFHoU7vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603907; 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=OjXGBVIh+Z1kVRR+6/ZuQ93tHMy2PrqXnE27+av6Y7g=; b=VZo+1o/ExPR2KC4owGnSDFEv/D42PRH3jhXpSIlk8rtAnVMiNJCNevAQtBVlTqzBAGphbbYFBGGyuJYE0Xf7kKAeCLAKLy7gTEaI6Mt4rFTbKcMht9ZVaVjIW5ZQ4ZZ1vniblUD15001skFmKipdrsL7yW8LfPnY5SQG+LvRxG4= 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 1753603907691249.84473000525418; Sun, 27 Jul 2025 01:11:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRB-0008Gh-Ri; Sun, 27 Jul 2025 04: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 1ufwPS-00027D-6u for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:06 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPQ-0004ls-ER for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:05 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-24003ed822cso1924355ad.1 for ; Sun, 27 Jul 2025 01:07:04 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603623; x=1754208423; 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=OjXGBVIh+Z1kVRR+6/ZuQ93tHMy2PrqXnE27+av6Y7g=; b=fUezS4p+l+LcUkiedC6FWkUofNSblAjN65ozVNNeo4X/eFTA5PEpe35RKA20CVHwgR zbntgiogIk7wnnln1bJlmKe6tRmwDCA9yf2KsnGEEtX6XqvUyxesqiJTzYth0DRcJFHb p85RJOPeRx8V5cOw0IGGj109FSB3u/d2QOofmD/ImP0RCsgeVZM8MWnAaHHeat2Ufj48 CYAcvUEqVpBX+RXcQSu55JO4dlu4xINHq+MnADrgQU14Z+0ueSEJrv0gUTnVZ1vzo2+e 2sr9aZ12yqH3jb8mKhILT1boT6AW74OqTDKHtEdCkUXgtP16jSIE4ngSeSj5rdyVfQl+ rRJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603623; x=1754208423; 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=OjXGBVIh+Z1kVRR+6/ZuQ93tHMy2PrqXnE27+av6Y7g=; b=dNBUUlAL0HPQrNjDKyN+sB7/zQJcsmviO2sahM/eMZnOUlPHM43sTmeIZRjg9EVYnF 5mw9R9q2pSHKSupVcfFYNtCiqJVK5JqlJRkiiQN2w+nOkdZV2JUOmw9LtZRxcCmleEzv 4Fpenl/HCvwThhRvF+BmqaBAxuc28fu+ll+DJjLMrc4NRovwBzgQjK4R7TeeSnA6DdfF I44FuAjH0VbqadFqmkD8y9QTh/arvUiwn3oeWgEgNut7ZpZWz/e7PhCajXgi/JoDqXFz 7QGO+dNN32BsHZR30CinGTsaMieGhkpT332G8MAYpsNiffFhVa+DVOa3zVNiF/rZ+Wk9 Faew== X-Gm-Message-State: AOJu0Yzh2dFb7rl3qwIrtJRQMHTs9Xz/i4P5xcGpenoxVD40WSv+UqD9 xTbMVCiaPzei+fukIIBzRTa6sIx8EPi7g4inohh6ERxq9wiqh3p1LIrcgnTm8N27Ab+lI7CbFaS xFXJn X-Gm-Gg: ASbGncvWkm4KShzFtdANtIgZ83HKgvtgmuVkeZr6LyeeWKe9hKAIjkUddsrTUOnZiVf k/uwdUx6HG8S7s4OJ7+VNJBYxVD5rfBrHPNKAUWxs0G27lFdIUy03an7ZLHhvcs+MMbg6hX3lER 4QfSWxYGLKdUy+e8MaEjOk9B2O3e0MFUx80kbNNF+OdYDVHewW0/WaxaPksmabVBvX7D9bkgnHB Q/I8C2axTAdHQZqiFemz23Re9cbDKqYVt5zwl265nMWl+dOXonlQwiLjlmyQvV+ogDE9FBC3GQl VoTXjgCgbTrDQqaS6YFipi8WmTMdfDhXmXGv/bGi0HtXnyZvhNcjIaD71e0nac1c/Gae4aPuijr ykOYdptJJrAC/rvxkYDIM4QQG6zajllLMtGVXkWnJXa+0qltg7Mi+jOyaTG4XPr3+/L/AgL9ntn ltaLF2BB8srw== X-Google-Smtp-Source: AGHT+IHPJgPJ+uKXNU+iImif1vtJlXfInIpCWA3nGVpJZlBWQYFBP82U19KOGEuYdfZv3d87CxeCNg== X-Received: by 2002:a17:903:2094:b0:23f:d0d0:69b7 with SMTP id d9443c01a7336-23fd0d06b84mr39260535ad.36.1753603623048; Sun, 27 Jul 2025 01:07:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 54/82] target/arm: Implement GCSSTR, GCSSTTR Date: Sat, 26 Jul 2025 22:02:26 -1000 Message-ID: <20250727080254.83840-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: 1753603909637116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604271; cv=none; d=zohomail.com; s=zohoarc; b=TpJYUMnTePEYpxBNjALaVvcUcSx9VGKEgPFweSlnp4djNL+g8wRZzIr8eYc0Ph8a1ECA3OtiNncQi8h12qvYabEB8LvVoVgZN+SAo80s4zKdXbapBPOjSSL2gy7oHj5cuM8ZtEK9MzNCFju1xq8a24WqK9zMAdCcafDAVnISoW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604271; 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=FTtFiV0an9RhLFd9ouBN3Y+ST0hrHevuMmYKg7N5y/k=; b=eHb3qoyclJI7XULOu6jQG0AECU0lCRZpOKJhj+oJksbXJS57TU3mHBMNAHGOHwJ7Bq6jFw6XC+soTPCPlkiBh5JRTjsLZb6ruRBtEqo1cOlDVNMeEYYDWYHaK7XahrOfIImhnQT0bkAqj+767y0esSPlh0Gt9l0ZbLI1H4aKdxg= 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 1753604271866805.7351671314655; Sun, 27 Jul 2025 01:17:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRM-0001Xp-Cr; Sun, 27 Jul 2025 04: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 1ufwPT-0002He-Pb for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:08 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPR-0004mE-GS for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:07 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2400f746440so1203835ad.2 for ; Sun, 27 Jul 2025 01:07:05 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603624; x=1754208424; 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=FTtFiV0an9RhLFd9ouBN3Y+ST0hrHevuMmYKg7N5y/k=; b=EyOggIoiXbM3OrEa6s7UDiRFLefGumhfPweuO/h2zW0oj3WGi3RllEjHhcw2gPinDs +UbQz5V+Kq5O4g3pmrNhoAi4fLBqRUlH8M7JjtB4mukocD0refusi6zAvXiqWsT1rNGh y6DqqeyULTSCiHMfxzwhO/6K78kz/TKnE1I/6bTpyOPxl4f2eTEolymffxBJN9Lhgjpd //0pP98MZ94nKE3JDq4WLNZ8PQxk6Hf6S6GjwUlyr/MwMnr0dScfni8rLZAFL3oSNoON gv13fULJ+FOZRxuXBnejwqjNHtqA5e6/3up5M+qGxOfSbRA81QfnftRZx/4KPDIiq0DZ Yr8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603624; x=1754208424; 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=FTtFiV0an9RhLFd9ouBN3Y+ST0hrHevuMmYKg7N5y/k=; b=tCdQw+o1SFyNe2Wc2MPfNzsadzWUJuG5rJSwr25nhufVC6OqG+F/cvG9NHByQMluGj qFqQIMG39sONC1MIf6HxN0qktXuTahcy4Xqfo/85cHYfYPWuZ32vTJcLDB5/oxws6f1X ABeYUW9xWqpia4n2zlyzVi4eMCdZ8yRqN0gMT1pRxQ9DEQuzU1fQ+aBqedig0fd8QPMx K9sGxuhqi3bOGi2PF4+XaVyi0q/JK9AbR/IPh3E8YLrqEqJHbPRYbW1H5lQlJbB1hXC/ KOIRhT5AmQDU5t+pvGlIr6PNRI8uVerxBYVN/sMDrNQEIO2HBT0Hq8cTBwFuBDKfynjc xysQ== X-Gm-Message-State: AOJu0YxriEp57XewqylFFNuj41vr8T9/JBnqRpsWJXZPJ/HR2ubx0dwA OfYJtZsjrCtRg9Nt/skKCzlQ+NpIkDtsSQCAr1OHai1gSXckXLPqhDBd/Teg7PztdIkbXK/b3M3 WS1Kg X-Gm-Gg: ASbGncsLQP5z1R2cGWEWc4waIdPWfixvuoli9YlHKGL4tfTtvwEY74wiwRXwXs5zr2N 3rrqx0S6262slJsAgG0mTQ2DFTaD+JmhnJrMHJkS1WT7p7IRFrjg4rMS9beO5t7b03KfTHcOe8D w1R9i9yJQzKWG6oBanVKuXwt16lzCPQk4GR7NFCypzd+Ocs+Mw86vN/5mRZp845X3NEJK2SDkNB XNNrHEuLi646oiWJ+4meue8pSwZAefXtqIIKHLDbnXlxReuWTkPyM2TB4Bqze1orTxLre9yqLpo xQSyL1JSh59qhMk81xJm48w5KwX5PbqjgSN6yB0yg6sqkCxKtbWWkmBLL3iPCZXr9oOiFKN3qXm riWyJtwIUkKz4dim3sxfmgjNG06oHUqasDESh+8obYf0z4F9ijDndWguWPak6yZPVB7QbKLbIGc tJ1vLFrltLeIKOfVN5vR8x X-Google-Smtp-Source: AGHT+IE6vX4jo34NmC7DNBiNa7fLgG0kAJ8oMwYLk+ZYdX+g5pw5YJKKxaizdXQ1juFMo+pt4JPpVw== X-Received: by 2002:a17:903:1b05:b0:234:b743:c7a4 with SMTP id d9443c01a7336-23fb30e42a3mr127818165ad.38.1753603624225; Sun, 27 Jul 2025 01:07:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 55/82] target/arm: Implement GCSB Date: Sat, 26 Jul 2025 22:02:27 -1000 Message-ID: <20250727080254.83840-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: 1753604272456116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604351; cv=none; d=zohomail.com; s=zohoarc; b=dN33kdDqCkq20etMsFgTfoUSklYPc0c+BeTAK1nqUpjhct4Ros3DwSOiidwMjlh1UTEY4I1AJUoqWFr2IxpWwWbLEcmKquKXmSGgI4mwLg2B5Mqp5k/JLtxh2QZLbCuvGZ7qWWwxLtMDTJZfR3g71E9AFkQ/gQ3kr8/RpPQEjNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604351; 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=VDuc8fKh0LQOOl8DOh+JTBa/BAss0l82OPl5+x7xYC4=; b=KzWm8Bm4b+2pYB4ECDY/hIqv0G0LPOEiehu/TUBJSXUBpQ+qva0w5uXKAToy2OcoQyiXyI4dmFTzvFTFVWjdEDVxgFyPhPgq7uGTD2Ct4Pjm0zj5P6OnnPynizZg0QtG4CbpX7MGb4Pb1Fqtnd/ESphaMaNAVreQeNPiryzRXq0= 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 1753604351050367.43700535279754; Sun, 27 Jul 2025 01:19:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwPf-000352-Ij; Sun, 27 Jul 2025 04:07: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 1ufwPU-0002MC-Ud for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:09 -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 1ufwPS-0004mW-Si for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:08 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-234f17910d8so29669185ad.3 for ; Sun, 27 Jul 2025 01:07:06 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603625; x=1754208425; 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=VDuc8fKh0LQOOl8DOh+JTBa/BAss0l82OPl5+x7xYC4=; b=eBTZKv+sqZzM5a31PQdKmDDLn0G6NPiY7BU1G/0LExkVG/8x9ZJvinrzoXZm3/GzUL row/gqHzc+BJqwxRQgn4kW6NKmhjq9DP4/txf2VwHpMow0j92GgiR5BPUPFBDqmiR8Vk ujnsoBoJbsmebsLrFrPM9ZobPVhPip3QE8Jj1VuyJYDmVSXVnzNSIOHdx/iyuF7HnUx4 4R8YK2cgfAeRvYPolgxHTWGJ+R57B0OXq8u86co3LnCLn3PfrhabytC3IHn35+9vIHHS M+u+oRRQlhiP/hE+tFM5LKxxZU7a4l/fkHnydcralQzDmuybqrBkubf6phxIczXRYRdo MUBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603625; x=1754208425; 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=VDuc8fKh0LQOOl8DOh+JTBa/BAss0l82OPl5+x7xYC4=; b=BznEi1VK1uRAW2Ru1TINCLSG+Vz6cveqhBm8pG6ZfDh7N00JF9i3oeIS0s9pTr778e hatVaoSeitCcoKb2DwBClf+MemRrCdop6OcqQKy4EJU1ftwHKaKGeSIp6ox/+8rRxGaK Nbs0bDhsu8Hpx/mwrZ+yLWgLJ3wCIkyDOH96Np7uuaFZaaYZ404k/qryEXxBlRJhpUjq iV8rT8k8PkeCzRveS8MQMWlFHBBS65+G2YeMplVkEOEEJXAF8GZruLiY/yFZSr4Wpwag pEl4PCDWTqYMqrCMQkCXRUBciIjomeRZmz3Rh6tB31/ovlAfFEt6pWmteFPJPnjOdRf3 lrwQ== X-Gm-Message-State: AOJu0YzQlX8kkqzHi3jhsc62Vnpjjpe/ubVyGeAtfUH862DAIVbSf9Bw IMjzs03MVKnt6e/QyTTwtaiuYZJGm+Wo6rwQ87VLoNe8iXOy1q1n/qo2g1OhVvBgOmZtUiBT78c lRLJ+ X-Gm-Gg: ASbGncuY245TvEPbrDiiinF/s/8qPSObhV3ljoQGDs8xlbrGCq+lJeobniq+zYwBd/1 f8V3OPkwHNFlUTPIhP7RMP1EWvh0uK8Bls+gKmW4hz+EMbah87RcDHZMKCZUEtGccEygwOPlk5N UliB8wMLdwdqMCTy6GGESgquvKI7XFL8IXtzweRQTeBXAjqUIe1zv0rmFBdaXcBfkR2ALznc/IT ryXLfEte2DTn1PsjYhZ32CThvfUdFTDI6+LkHsInYvD4abQe8It6v4tRfoXve2zH3DFFL1t+DrF 3GWIcTYAEIodC18fZPbf2TKWrvJz08SCTDC5R0vGcgius46GL2/3ooNFZIWVwbv9z7WdyTx21T8 gBe+0BwaGxYoi487LGMMNgqg24pJFSbHn/aA7DEyj4oFlL203UnqYzPXZaRxPJbbEMQmNeXQ+zJ puQHVr5WBwQw== X-Google-Smtp-Source: AGHT+IHEPehRsnkC9wrTMnTMmS/DiL/1EuKCOkIQH2VwEJ/Ybz9CBNEVkvqnwkHJ+0c3j2o9nLMQIQ== X-Received: by 2002:a17:902:f688:b0:240:483:dc39 with SMTP id d9443c01a7336-2400483f97fmr21316945ad.47.1753603625438; Sun, 27 Jul 2025 01:07:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 56/82] target/arm: Implement GCSPUSHM Date: Sat, 26 Jul 2025 22:02:28 -1000 Message-ID: <20250727080254.83840-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753604352936116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 3 +++ target/arm/cpregs-gcs.c | 16 ++++++++++++++++ target/arm/tcg/translate-a64.c | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 15894332b2..93358e6123 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -46,6 +46,8 @@ enum { ARM_CP_DC_ZVA =3D 0x0005, ARM_CP_DC_GVA =3D 0x0006, ARM_CP_DC_GZVA =3D 0x0007, + /* Special: gcs instructions */ + ARM_CP_GCSPUSHM =3D 0x0008, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, @@ -861,6 +863,7 @@ typedef enum FGTBit { DO_BIT(HFGITR, DVPRCTX), DO_BIT(HFGITR, CPPRCTX), DO_BIT(HFGITR, DCCVAC), + DO_REV_BIT(HFGITR, NGCSPUSHM_EL1), DO_BIT(HFGITR, ATS1E1A), } FGTBit; =20 diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 9c06100d2b..38987372c9 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -33,6 +33,17 @@ static CPAccessResult access_gcs_el0(CPUARMState *env, c= onst ARMCPRegInfo *ri, return access_gcs(env, ri, isread); } =20 +static CPAccessResult access_gcspushm(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + int el =3D arm_current_el(env); + + if (!(env->cp15.gcscr_el[el] & GCSCR_PUSHMEN)) { + return CP_ACCESS_TRAP_BIT | (el ? el : 1); + } + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, @@ -69,6 +80,11 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 3, .opc1 =3D 6, .crn =3D 2, .crm =3D 5, .opc2 =3D 1, .access =3D PL3_RW, .fieldoffset =3D offsetof(CPUARMState, cp15.gcspr_el[2]) }, + + { .name =3D "GCSPUSHM", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 0, + .access =3D PL0_W, .accessfn =3D access_gcspushm, + .fgt =3D FGT_NGCSPUSHM_EL1, .type =3D ARM_CP_GCSPUSHM }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 45ff7bb0b2..a5810be2f7 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -420,6 +420,19 @@ static MemOp check_ordered_align(DisasContext *s, int = rn, int imm, return finalize_memop(s, mop); } =20 +static void gen_add_gcs_record(DisasContext *s, TCGv_i64 value) +{ + TCGv_i64 addr =3D tcg_temp_new_i64(); + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(value, clean_data_tbi(s, addr), mmuidx, mop); + tcg_gen_st_i64(addr, tcg_env, sp_off); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value; @@ -2765,6 +2778,11 @@ static void handle_sys(DisasContext *s, bool isread, } } return; + case ARM_CP_GCSPUSHM: + if (s->gcs_en) { + gen_add_gcs_record(s, cpu_reg(s, rt)); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753603905; cv=none; d=zohomail.com; s=zohoarc; b=ddJUtSoFtqjHIp7F/BsK//pHhgvwkoCMFOziezCza7qKFAQyr89H3nZ04/p/47njRSYiFjazWw4mFri8Bf4UtJZ3qhfHsZKVy15/GCTSruSSNOBbzeUaOTYg0z5zrIzrZWPGCp7vsGlH4l9IezSSWIGTQ2B3UmRuL1lx8L0KW00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603905; 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=MVylRwCjX6yYGQroRwywsqeSdVr352gntV1nVCoF2rc=; b=Bl9erpdyL5Wcrsbd9kVf1+3z411jougvHLNEnSDHjtgOmulnh5X2/EQzuwgEudwmoaEYfwbo+xDfAJpNji4yEmOV5vrDhYwrgsaYvIEiOPFuu/Oc3eai3oCGKOQ9jDco0gM7uV76JRH75Qlyy3cXeacomNLgX6zuplG/caL/kMA= 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 1753603905633471.51669122181283; Sun, 27 Jul 2025 01:11:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQS-0005v6-B9; Sun, 27 Jul 2025 04:08: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 1ufwPW-0002RB-9U for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:10 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPU-0004my-7U for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:09 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-24003ed822cso1924435ad.1 for ; Sun, 27 Jul 2025 01:07:07 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603626; x=1754208426; 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=MVylRwCjX6yYGQroRwywsqeSdVr352gntV1nVCoF2rc=; b=ZWvZnFUGzRbB/uxmhFekJEKU0QUNp/VwkbpFop4Fza86bZMm1oCoZ/nG+1Lpi9Yqia 6aXDED4Dy3BTyy/Q/lL1dLCF34gG12qRtxzduhCZ/GCT20wMUqKRgYMv+jVROZEqcgor /r86MFnR8JtwHb9cWcwvJUXrBDEp3J/UOwnTcObKnruHdo5VlTxFmiQsZ6cNjXBP5bcr k4wCFCANwSsfx0i95M55Yjak7WtoXDt/HZexNPOA+za6bCxOVfdl5OlmzPAov7wDjD3e MCkPqtrLs5rDUwDBIssGvBBeMEvo2hlXqlf8n0GXBzRKj6Et2E2YOC1jQ5xLFnYYl3Zp rHhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603626; x=1754208426; 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=MVylRwCjX6yYGQroRwywsqeSdVr352gntV1nVCoF2rc=; b=snFU0CpgZhWwJRKr5bHpbTDbWiqmJHrJe50rqjzbMLCkSsCW7bF0cFoa0cg1hlrZLF DrzmJu1G4kObVGzRKh46ruvp5rFD2060V2VsVptXzP42KyCZta8LB+17GifJxXcWLdte DX5MXUYcC1w9kfNv+kXT42iOJsd/0TbSAJ4JAlclnao6J37n89XjpTUEqsAN5BvCTs71 MrGxC7DYyLxqgc5ZIfD6vl0hiPVOoiM9ZImyepAAM6Ju1/wJjA4jrptxNN38xRLvczIh 3RwH7diaGCG7F+adtXxFyhnqXV4HLUf7hyB45au+lois/KOS0dhRdMC0+oDN1j8+1bFR 6Lmg== X-Gm-Message-State: AOJu0Yw49AmCO9ONP0TFm4IiDAX5uJ+JlaB9qgDjDUlrKTj/h8obn5MO Hkl5Axw3001aYsorli2ycqMDTKGnMV0eCB6Ek3FQqZOnqqDxsON9hcNS29L38UgyXITkGWpfAQV Cpuj0 X-Gm-Gg: ASbGncstL99uOuDYpIzIIOs+MeTQLMsxeFVx/TZRz7lpFdS4tRREtIpzHtzC8e2pWvh fNimVAAg+Ljq5ffxTUdIjyzSJzOvnFlxPc/YIFHJ3R5hH0UWve970SheRI6Amyab6UPDFaLRrop CnwbWCdDyUEVk3l/ROgqHoukKG/jTyOSFIJpdMLSV0SLRO4LVW2lM/QAkQfQZCxRg7VbnKaE7i1 a5xQzhxq1BJvrzVqdPl9sXlgBLpm7p1r75NwozExd9y9w/fX6Kvm6Hv6tnptb5t7kytT22VfUH4 auGbuQuRZmT4YYd5d3Y5y2tkixQoQP2xc/od7tOGb8M89uXavk7HMLarnydaaikdPd0hnVXhBKW NhYPJ9gfx90LZ1cwcOpt5bACtmqT/xVckUwU0sOuqaG2fgqyXkvJZtr/eVVkPunPQ3/7CR4uVJG iJqpjVGI0XPRYOahCpv1q+ X-Google-Smtp-Source: AGHT+IFfMqbiYXQ8ocaJp0HDlsiUS8Udv/KquBlBVdj5jLlSf7y9wSFmP89e7hHrFNGsn+kT1XZipQ== X-Received: by 2002:a17:902:e948:b0:23f:b09f:52c7 with SMTP id d9443c01a7336-23fb3043a03mr130054195ad.23.1753603626590; Sun, 27 Jul 2025 01:07:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 57/82] target/arm: Implement GCSPOPM Date: Sat, 26 Jul 2025 22:02:29 -1000 Message-ID: <20250727080254.83840-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: 1753603907646116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 93358e6123..9b19520346 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -48,6 +48,7 @@ enum { ARM_CP_DC_GZVA =3D 0x0007, /* Special: gcs instructions */ ARM_CP_GCSPUSHM =3D 0x0008, + ARM_CP_GCSPOPM =3D 0x0009, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 38987372c9..74a1697840 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -85,6 +85,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 0, .access =3D PL0_W, .accessfn =3D access_gcspushm, .fgt =3D FGT_NGCSPUSHM_EL1, .type =3D ARM_CP_GCSPUSHM }, + { .name =3D "GCSPOPM", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 1, + .access =3D PL0_R, .type =3D ARM_CP_GCSPOPM }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a5810be2f7..0279111cd2 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2502,6 +2502,27 @@ static void gen_sysreg_undef(DisasContext *s, bool i= sread, gen_exception_insn(s, 0, EXCP_UDEF, syndrome); } =20 +static void gen_gcspopm(DisasContext *s, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 value =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSPOPM, r= t)); + + /* The value at top-of-stack must have low 2 bits clear. */ + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(value, clean_data_tbi(s, addr), mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_TSTNE, value, 3, fail_label); + + /* Complete the pop and return the value. */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); + tcg_gen_mov_i64(cpu_reg(s, rt), value); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2783,6 +2804,12 @@ static void handle_sys(DisasContext *s, bool isread, gen_add_gcs_record(s, cpu_reg(s, rt)); } return; + case ARM_CP_GCSPOPM: + /* Note that X[rt] is unchanged if !GCSEnabled. */ + if (s->gcs_en) { + gen_gcspopm(s, rt); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604045; cv=none; d=zohomail.com; s=zohoarc; b=Ec2VaS6+kN8xhTCovJKto71GW8TLdU0cHcww1R3pDvx4t2EybqPOzPnh8doTnV0c9mv2wbiHPPDPKz+Cvbgfk599sWBySpCfvFFaZzOSuVPW3imoUAvP/raR1K71dSUJH7yHuM13xxADOY8X6YC2uG1ULQIzBGen6EjgFmiIZaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604045; 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=v8CYypw7eiczgAtGXhyBt3X1CyDsVK1kkaaTP5EVuds=; b=nHjvGUBSxiCBbF8XEHgxGi2l0iUqCZVglToFDY1W3ZvDEnLI/z5wMSJzdjk5NMiF9NZiMHQ00T9OOKuLzpuX89su7YjR3LItYpXxM4YKSIi20asvGVzuoVVxHQn7WWBUhq3M0B9BnDNEFGoLsgPfF1N8u5JzVFNIqOULpysMYas= 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 1753604045582780.1540804868824; Sun, 27 Jul 2025 01:14:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRI-0000lH-7r; Sun, 27 Jul 2025 04:09: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 1ufwPX-0002T2-07 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:11 -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 1ufwPV-0004nL-5X for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:10 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-b1fd59851baso2509384a12.0 for ; Sun, 27 Jul 2025 01:07:08 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603628; x=1754208428; 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=v8CYypw7eiczgAtGXhyBt3X1CyDsVK1kkaaTP5EVuds=; b=L4CsunAhnY5F4/geUR7Y2jg6VPG5LhaFRqikDTV8cAran1/H/0KSTwDT2kjzuD2VpJ iDL9R22m0G6k2T9jm0U136sULC1kT/0b2N9cfqFhay4s7xyYV05rBz3sVfHEYPRN2tM6 SSOAGZyoH44c/wfbTd/2xfonmGwHY7uVoFEqo5EVqYGyPRh/wlPog2FO1vlPZ7MhUbaD F4Zw1om+ETxVqD1AJXtXOghfSucOYGA+iC0LJyIuj8xZSYyB8IzeMmAm8uOWkr3O4B1V Itwi60fjLy5OURfpb2UdG6FXoSoZNAviZBUwk6zqMU+J9FtEv7Jb2Yk/yJBeKElyvrMK FNBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603628; x=1754208428; 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=v8CYypw7eiczgAtGXhyBt3X1CyDsVK1kkaaTP5EVuds=; b=Hk2z2XlIN+u7UNF0jU6XE+hmtYfatSaX7WEh4gVy14xbO60w0zrp1MWJ9JVM390MKv BH6n/ut8SxuHtVzNY8OhNAEspH71TyjFRUob4/kheOsJIUspwp1r7OreCWxtd8t4EWML aP5T1SeZ8oA7v52koU8ObJypvHXRDdZMbhkQBDs0chBic6DjH8ivqoNXopWnRDedJWpn BPtWfJotY0pDqwyPVnuNQ9ZpIKkyEu6LPoc7+kF11gwvfZvLp7xN11CM9MXAtHfy4055 odqn/WzBNeXqoF8Ezr0QwpDWbGy8nVGl7uDFnTzeviJPRgt4O9KXtUF2yTlvXXGTf2xv QhpA== X-Gm-Message-State: AOJu0YyjgHnCtbr1J+VdyvjKAyAa2SYYoPkGQVbVJCkNZySyQnE+13S0 MjMcTF88EaVcXwFcnbWoL0Pb6qEaTaRhit4U1awhbVG1OqRIvtm8QcPrDzBFNZY9N8c3wGubCbS Y4mM0 X-Gm-Gg: ASbGncu9rYCbJ/VUTVF9SDCPgzrfy7PhlAsH0f7hfe4UfwBhJJKNFW176oZoE/w7lJO f9sp1JTKrFmmdxU6fcAYP/dgHq1Lqye4YfHy4PgirdRDETckDqFXvkGw/8lJlOzf4j6uB7+S3ll bNnFzaCeehsdO8NP6iStYuRdhxiASr7EQv4V4svW+YBcUKQyRTxuOkfbkF9lNA4V9Q5Oe2qQxBN yvZtx2042CkrvxbJWS9skY20fLGj9yfwhKebu42anrAVm4SnYcMD9QuMwLYV2yEa/e6BObOUy90 YXim4U03iJLh/y3Nn9gpWbbbU9UqTB0n+K9PrUU+lckkykojJ+feEEGKAQqRoOdjdO8k6AxgpAT 4Z/9rdDfCNRZqlXxNW7FU+hHtZ7a/aztdygzAk2YqQfa4iB4jSucg4ZPrrUcBm0A3Ce60NlZIfn eUGitkKEiE7g== X-Google-Smtp-Source: AGHT+IGc59+vQi1lvZpKyf1EWjzoQe6ZgMTT/sd5AqG8Qnf4JYRezUtcttHjuRL1Dzzy7ArdCvH2oQ== X-Received: by 2002:a17:903:2b0b:b0:240:11be:4dd3 with SMTP id d9443c01a7336-24011be5835mr8172905ad.3.1753603627817; Sun, 27 Jul 2025 01:07:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 58/82] target/arm: Implement GCSPUSHX Date: Sat, 26 Jul 2025 22:02:30 -1000 Message-ID: <20250727080254.83840-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753604046603116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 2 ++ target/arm/cpregs-gcs.c | 17 +++++++++++++++ target/arm/tcg/translate-a64.c | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 9b19520346..3d76afd20b 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -49,6 +49,7 @@ enum { /* Special: gcs instructions */ ARM_CP_GCSPUSHM =3D 0x0008, ARM_CP_GCSPOPM =3D 0x0009, + ARM_CP_GCSPUSHX =3D 0x000a, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, @@ -865,6 +866,7 @@ typedef enum FGTBit { DO_BIT(HFGITR, CPPRCTX), DO_BIT(HFGITR, DCCVAC), DO_REV_BIT(HFGITR, NGCSPUSHM_EL1), + DO_REV_BIT(HFGITR, NGCSEPP), DO_BIT(HFGITR, ATS1E1A), } FGTBit; =20 diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 74a1697840..6f25543426 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -44,6 +44,19 @@ static CPAccessResult access_gcspushm(CPUARMState *env, = const ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +static CPAccessResult access_gcspushx(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + /* Trap if lock taken, and enabled. */ + if (!(env->pstate & PSTATE_EXLOCK)) { + int el =3D arm_current_el(env); + if (env->cp15.gcscr_el[el] & GCSCR_EXLOCKEN) { + return CP_ACCESS_EXLOCK; + } + } + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, @@ -88,6 +101,10 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSPOPM", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 1, .access =3D PL0_R, .type =3D ARM_CP_GCSPOPM }, + { .name =3D "GCSPUSHX", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, + .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, + .type =3D ARM_CP_GCSPUSHX }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 0279111cd2..732d65f54e 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2523,6 +2523,38 @@ static void gen_gcspopm(DisasContext *s, int rt) tcg_gen_mov_i64(cpu_reg(s, rt), value); } =20 +static void gen_gcspushx(DisasContext *s) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int spsr_idx =3D aarch64_banked_spsr_index(s->current_el); + int spsr_off =3D offsetof(CPUARMState, banked_spsr[spsr_idx]); + int elr_off =3D offsetof(CPUARMState, elr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + + tcg_gen_ld_i64(addr, tcg_env, sp_off); + + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(cpu_reg(s, 30), addr, mmuidx, mop); + + tcg_gen_ld_i64(tmp, tcg_env, spsr_off); + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(tmp, addr, mmuidx, mop); + + tcg_gen_ld_i64(tmp, tcg_env, elr_off); + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(tmp, addr, mmuidx, mop); + + tcg_gen_addi_i64(addr, addr, -8); + tcg_gen_qemu_st_i64(tcg_constant_i64(0b1001), addr, mmuidx, mop); + + tcg_gen_st_i64(addr, tcg_env, sp_off); + + clear_pstate_bits(PSTATE_EXLOCK); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2810,6 +2842,14 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspopm(s, rt); } return; + case ARM_CP_GCSPUSHX: + /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ + if (rt !=3D 31) { + unallocated_encoding(s); + } else if (s->gcs_en) { + gen_gcspushx(s); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604516; cv=none; d=zohomail.com; s=zohoarc; b=KO2m78xMZdpR2LTp9xpBEoZ33oz4ZzJxncwb/T97D3d0s2DQJNZufi1yfhbcipN9hLing6diUWalVcVtvWz7iAKJjLtHI0OC/wQ1drkEG8fttrPjiZG2lVNE4A5d9QE/tf09QyWBF1f5PsESTWb98IJuVBx8UmWt2O34EZrg53M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604516; 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=TwK1FVcwYdH/CTb2jXjKNg3tUOpLN2LCnFxikA/29X8=; b=c/nK8yO5O+fUGiJvpr+GoLGGDbjjY5mMZw7MDDNL10EGoKZ+P3X2+8Vo3QUs+aq5wecFkNEX7LR2Vfecy//YN01bvgtNCMxwV715BA2mbdbwAfi/SKGPT4eUYC2pag8wdtGvQ02na8U+qAtpGptKIlzV0+ezVE3aXqZNxdIQlv0= 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 1753604516933383.3165051098607; Sun, 27 Jul 2025 01:21:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRK-0001GC-P8; Sun, 27 Jul 2025 04: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 1ufwPY-0002ah-BB for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:12 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPW-0004ni-9p for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:12 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-b31c84b8052so3968082a12.1 for ; Sun, 27 Jul 2025 01:07:09 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603629; x=1754208429; 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=TwK1FVcwYdH/CTb2jXjKNg3tUOpLN2LCnFxikA/29X8=; b=E1Y/hRM73oGdumchGai2uIk2k5OHbWdPv8wI+Ru0ACbRWrI3v819FkJKUM5Pe0kid/ F/QLZzSImHRbnSOUQg6kmWnSMIHaUprVso+IzpkrW2ew6XEKj75P+Y8cqbFDjI4eJB9V j0RhP3fvHegdWfcKtJs2G1B0Y4LNrdevoDfPFtGblJyDpfM8rft80uOuBZTFX4vDdiXl NfW+0BLuevpnnHyewrnzE1F82DPfQIMxxfB7PS/4Mz7UM4pgeeQC+cLeBLvKazU/SS9v hanvjCwCjRKSqElgm7qvEMRrBKSyBTb6TVQysg1EfOpcYZIdNLv1emTXktM1KGdVWJ8F Mg+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603629; x=1754208429; 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=TwK1FVcwYdH/CTb2jXjKNg3tUOpLN2LCnFxikA/29X8=; b=TAxIJ1Mhagcl151k6ux32PpZLnbHUDXQGmUJGQiDd57mKWf83VTZbBgcKgx5bcZT8r whdjXuZXaMXAmruFnAXf4eEtnyVuBTMFVGyAy3g7HK3z9LtTix4+MK1Ugs/HNbxePFvT 7a47DmOJWg16jor9VkA2ojRJ2N/zzwur/+EQWsXV1tfHuadz2+kIYAST2kRH6mxbmRYN Fj1LzmWszhVKhozW/CXkwz9GqxMfJCU4URw3erEoniJhW8o1XPCCWbXJuLDgwzLLiBMN xvFWQeZZlzmiGfNoDBZdqa6d0xq+BL1KmCpTGfM5JOLuOLB+OP7wjRBMqNrijJ/OFoSl 1T6A== X-Gm-Message-State: AOJu0YwKykABd04GDekEQ3YfgmGyknTcvj1cPevOfd/fRNpzFeF/e272 HwETBOGGa/bDorkco7YS9iPKOBSUKv9EzAp0JfOPbVffbL8PvrpRCFeqXZqmhV1NuT6pIVC2eB/ AbrMY X-Gm-Gg: ASbGncufQ4M5yGgaYRnT2i8eFEiMUmzf0NMvMaTeG0A6Wx+r3F3mhyuAAAUjqDjzbmP q5dJ2m1tXD06ZJ8/+OO4acTNwk3S4qZL2VjsTL0K+RgAx1HlFB4+dJ1F88LyDhh64D2FWJrTLoa qHaRMFh5PG/DoFWTt9StT5rkUTcWd5WqwwKneeKpJAOr4VFIcBHQZa/w2VyHVCTz2GVQka9UMoR qOiwwEd5cGiG6ihodqc0HzkGMRjR97NNguff+aayBfi6ggkUbhr4VFY+PzOVLcuX4DTRbM6sMJQ AD5B0QL4h5+Ts5PCX/0IrdZaBPnT8k0PazTA5GEoKIk2vwqtf2y3FfJnUcCh0yDSflh2oHZTVLx NhW1+a2h3QIS0bZ6wZysMNH0Gl1r+veACFkXcMuOeA2NcmJDwTJ6GPNS3WjdS7r9qEUx3qsjvcp /QFdNVOjsaAw== X-Google-Smtp-Source: AGHT+IGgJf4iX7TGZ0pdNeyA6L4moN6D8vKdRfTaaddgbdhHaTax3qRrU2mE0QDFcJ0OVX4CrOK6VA== X-Received: by 2002:a17:903:2312:b0:23d:dd63:2cce with SMTP id d9443c01a7336-23fb317b00dmr96704455ad.40.1753603628859; Sun, 27 Jul 2025 01:07:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 59/82] target/arm: Implement GCSPOPX Date: Sat, 26 Jul 2025 22:02:31 -1000 Message-ID: <20250727080254.83840-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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: 1753604518308116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 3d76afd20b..084ea00e51 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -50,6 +50,7 @@ enum { ARM_CP_GCSPUSHM =3D 0x0008, ARM_CP_GCSPOPM =3D 0x0009, ARM_CP_GCSPUSHX =3D 0x000a, + ARM_CP_GCSPOPX =3D 0x000b, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 6f25543426..2bdd41c796 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -105,6 +105,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, .type =3D ARM_CP_GCSPUSHX }, + { .name =3D "GCSPOPX", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 6, + .access =3D PL1_W, .type =3D ARM_CP_GCSPOPX }, }; =20 void define_gcs_cpregs(ARMCPU *cpu) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 732d65f54e..773ed3044d 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2555,6 +2555,35 @@ static void gen_gcspushx(DisasContext *s) clear_pstate_bits(PSTATE_EXLOCK); } =20 +static void gen_gcspopx(DisasContext *s) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSPOPX, 3= 1)); + + /* The value at top-of-stack must be an exception token. */ + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0b1001, fail_label); + + /* + * The other three values in the exception return record + * are ignored, but are loaded anyway to raise faults. + */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp, addr, mmuidx, mop); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2850,6 +2879,14 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspushx(s); } return; + case ARM_CP_GCSPOPX: + /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ + if (rt !=3D 31) { + unallocated_encoding(s); + } else if (s->gcs_en) { + gen_gcspopx(s); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604474; cv=none; d=zohomail.com; s=zohoarc; b=KjZ84btyhVxd9xmtYbparE15hLu43MBqk92jxOB3zrvoOc6R0DtMlTQ9rAeDYIbLes0136SByyFTpnYKq03+Rza1fyHYVcRvK4EPeH6uAU/CthF8bNmJK7hQEOCcEaMjU9kqiLnOeJXx050XQ85OXXE46i1yGcf2dt3YqlzZJR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604474; 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=ZAD+04FqwSKw8DLKNS0UP167F5/dokMNRY9qi0ztYmk=; b=LgPDeT3bbvfvxG/MSiNknrZchV6ku0UD49lNE+9K0roCL03Y3hhaQm5qlC7baVqfZMmiS1APGlTgAXaQ+bNImD7m6H8HRfLi6rtt5DxVZlH7gOWiTbnYZCKZBplP+hh+7WRBEVOxcLHfxYuLpAV6cNWN9Xojt06i/0/FMqcxicE= 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 1753604474728480.5987350780921; Sun, 27 Jul 2025 01:21:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRX-00037F-5k; Sun, 27 Jul 2025 04:09: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 1ufwPZ-0002gR-9c for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:15 -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 1ufwPX-0004oF-9l for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:13 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2400f746440so1204215ad.2 for ; Sun, 27 Jul 2025 01:07:10 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603630; x=1754208430; 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=ZAD+04FqwSKw8DLKNS0UP167F5/dokMNRY9qi0ztYmk=; b=zZHzihO/ttgj20/+f5jSBFQwspvFgMtNBettLdEMsuGfB+MMYj2ZMDfV7JhZEsqCqK sBDVlt/AFMEW4aMYNv/Mg505KlwhuYU7jtRudDWPCds/gZW86hUVWQuZ6rlOD104Htry ZzKqEryRIW5W1YrI7bKNQz1JK0afCcXKF2z3Z5ekUdIdG89+CgxOeyWMGJ3CkfQ6MmNp Zms5rzfslgmkr4UkyeNUBEmfs8Smy1ZA0temM9Is6Tzb0nVjNe//bp4vs8pUawxioolR 3PwhV4rL14/+PKWx3kZcfyBj16kyT70qVwhMtNCuGtMJPdyU8VmKiAAy8oxPg99Yrphc R4AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603630; x=1754208430; 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=ZAD+04FqwSKw8DLKNS0UP167F5/dokMNRY9qi0ztYmk=; b=dCZP4nVa4xKatLwgbrayYVy8wnbjutbFjeUbg3ox6RnAt+5+tn+mmNClb4cge45CUh Z9u4YcBQn/VSGGTNMR5yyBZxKgE1mJHU1LopH2sPTcan5+SAAiauV9Tu2cSEoLRgsFvs Jb56mcf6SlHRtJJR3gf3+GjHH+cptDhHzyijmlPxFi8Q4itJzVWF0W66oK20cM0+89kH v7s7LT+YIWd7nO00yMo8HkdIcysmd7bggb8S7V1jUn5EqkgbYd6aATbIPXGCfuSSO+o5 zk5oR7p92ADyL27twQM51SNo/657BshgQ0wMhs5vZ5emJqUz1CVa4YL3yTsRHUlHT5E4 Yu5g== X-Gm-Message-State: AOJu0Yw9/W0nhhd6sU5vUeyl8XpXzHwK3evkFs6bxpHZ1u9l7IeuYI5j WejUl2iT2PKPwzdWDkHqBWGrZaI9nyZcgfaDPBhfxj3W6PzBsYx7v2zHE2WPWIM7kjJPoQveUD4 VhABp X-Gm-Gg: ASbGncvE2z+ykOKPL/xBMFIKgwcP1hoUIlC+C8QSWg/zUjhvvkEYgICiV2QXnOu9IkW SSkS0WgyAVMLx1fwtp+pDrMsE4O3JtqCHNK+0OH9uBFNnleFn6xSooeDt4eNhmNwGAjR9Uka5xE 8rU6GPcuCKxt9pDWwkQx4n/wLdSirDmLjlkwAx3lpvTkgTsY02bSPubmskkKzyUNSCG6GDT4FqM JTCuirQkO7ocUxRiWXMOcHBSE936IzeGhPEd1HjZucNByVLKoa6mDZ4ZLeO/PLCn104Z3nEutPB pOvYTxAQ87H1jliKzCNufkOKMELfFhIgV1dezHv6z2ZhbTZZB7fR33HQ/tr7EFleOvrFTJ9Aos1 VI9FHnCxgajha7AWPzNPWmkvoaY5D1/i6rPilBEBe2+272TE0+ypYQmid0ozqMspS61+xWSy0Ja ZnkaUXjm+M/Q== X-Google-Smtp-Source: AGHT+IGRGVkSQcbbDZejA4BH7Qq5Pd+P3cDd1yiNrCv4EzHOiV0dfvrfmb856jYel1ryf48cjsmTcA== X-Received: by 2002:a17:902:f114:b0:23f:df69:af50 with SMTP id d9443c01a7336-23fdf69b14bmr34451645ad.34.1753603629908; Sun, 27 Jul 2025 01:07:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 60/82] target/arm: Implement GCSPOPCX Date: Sat, 26 Jul 2025 22:02:32 -1000 Message-ID: <20250727080254.83840-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604475729116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 17 ++++++++++ target/arm/tcg/translate-a64.c | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 084ea00e51..392a0a264f 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -51,6 +51,7 @@ enum { ARM_CP_GCSPOPM =3D 0x0009, ARM_CP_GCSPUSHX =3D 0x000a, ARM_CP_GCSPOPX =3D 0x000b, + ARM_CP_GCSPOPCX =3D 0x000c, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index 2bdd41c796..ab53a4314f 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -57,6 +57,19 @@ static CPAccessResult access_gcspushx(CPUARMState *env, = const ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +static CPAccessResult access_gcspopcx(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + /* Trap if lock not taken, and enabled. */ + if (env->pstate & PSTATE_EXLOCK) { + int el =3D arm_current_el(env); + if (env->cp15.gcscr_el[el] & GCSCR_EXLOCKEN) { + return CP_ACCESS_EXLOCK; + } + } + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSCRE0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 2, .crm =3D 5, .opc2 =3D 2, @@ -105,6 +118,10 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, .type =3D ARM_CP_GCSPUSHX }, + { .name =3D "GCSPOPCX", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 5, + .access =3D PL1_W, .accessfn =3D access_gcspopcx, .fgt =3D FGT_NGCSE= PP, + .type =3D ARM_CP_GCSPOPCX }, { .name =3D "GCSPOPX", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 6, .access =3D PL1_W, .type =3D ARM_CP_GCSPOPX }, diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 773ed3044d..af91b7f95f 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2555,6 +2555,56 @@ static void gen_gcspushx(DisasContext *s) clear_pstate_bits(PSTATE_EXLOCK); } =20 +static void gen_gcspopcx(DisasContext *s) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int spsr_idx =3D aarch64_banked_spsr_index(s->current_el); + int spsr_off =3D offsetof(CPUARMState, banked_spsr[spsr_idx]); + int elr_off =3D offsetof(CPUARMState, elr_el[s->current_el]); + int gcscr_off =3D offsetof(CPUARMState, cp15.gcscr_el[s->current_el]); + int pstate_off =3D offsetof(CPUARMState, pstate); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 tmp1 =3D tcg_temp_new_i64(); + TCGv_i64 tmp2 =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSPOPCX, = 31)); + + /* The value at top-of-stack must be an exception token. */ + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp1, 0b1001, fail_label); + + /* Validate in turn, ELR ... */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_ld_i64(tmp2, tcg_env, elr_off); + tcg_gen_brcond_i64(TCG_COND_NE, tmp1, tmp2, fail_label); + + /* ... SPSR ... */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_ld_i64(tmp2, tcg_env, spsr_off); + tcg_gen_brcond_i64(TCG_COND_NE, tmp1, tmp2, fail_label); + + /* ... and LR. */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_qemu_ld_i64(tmp1, addr, mmuidx, mop); + tcg_gen_brcond_i64(TCG_COND_NE, tmp1, cpu_reg(s, 30), fail_label); + + /* Writeback stack pointer after pop. */ + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); + + /* PSTATE.EXLOCK =3D GetCurrentEXLOCKEN(). */ + tcg_gen_ld_i64(tmp1, tcg_env, gcscr_off); + tcg_gen_ld_i64(tmp2, tcg_env, pstate_off); + tcg_gen_shri_i64(tmp1, tmp1, ctz64(GCSCR_EXLOCKEN)); + tcg_gen_deposit_i64(tmp2, tmp2, tmp1, ctz64(PSTATE_EXLOCK), 1); + tcg_gen_st_i64(tmp2, tcg_env, pstate_off); +} + static void gen_gcspopx(DisasContext *s) { int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); @@ -2879,6 +2929,14 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspushx(s); } return; + case ARM_CP_GCSPOPCX: + /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ + if (rt !=3D 31) { + unallocated_encoding(s); + } else if (s->gcs_en) { + gen_gcspopcx(s); + } + return; case ARM_CP_GCSPOPX: /* Choose the CONSTRAINED UNPREDICTABLE for UNDEF. */ if (rt !=3D 31) { --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753603761; cv=none; d=zohomail.com; s=zohoarc; b=IUArdc46KCt1TFDL4pvp4DzWWZiAqdgm9QkpVpOhc9Qfkl7+pvnqqg+hqgyO5h3D/Lce/obblgz+UE+AKNmK2ikbDprAMXZmXGPT69z66Bx10/9tZ/sKc532GEKjnlNq00HX8xxsEzVHAmvfWWcRAleZP09UGGb5PyIreyQ2y8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603761; 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=1IXOiXj1C1ZetYUAJn76SJu5i4qqFoVN2qqJt7z2Klg=; b=CPVakbcDaUE4D8fM9pfeyEyUJmqrM9ifCnF6N8M0n+QTJ9FeewujUBc55AM/U0lsc144TGE7W7Ta2Hoj3Dp5rfZWrPUlHzxis9Gt4IVHT9SXo+1OxREfNXoR2v4tu1G6OvG5bIqnlMny51kxtlci+zV5+lfFO3AyjzyPeQBQRiA= 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 17536037616831002.2164927312148; Sun, 27 Jul 2025 01: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 1ufwRW-00031R-MY; Sun, 27 Jul 2025 04:09:14 -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 1ufwPa-0002j1-DQ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:15 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPY-0004of-JL for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:14 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-23636167afeso29870725ad.3 for ; Sun, 27 Jul 2025 01:07:12 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603631; x=1754208431; 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=1IXOiXj1C1ZetYUAJn76SJu5i4qqFoVN2qqJt7z2Klg=; b=BqfKWI1pKEMvpsARuvEY8QWhVROAAl9orvFfRn40cOh935v+0wEf8rZ93veo7A1yrQ vPCVm9qY+XFI/vH4wLA5uFbKkO6uiS3bygpX6iD5OE3aVrS92INbm9ruLAFjdxQ0yzMa G1Sa5rWiqAt/oBK4hvnCFnsrwoHtKGdseAjhgpJJJpVzCbvQqwUDTfwl8Yo2/7cta5xg EqA6Cqx5lu0Rltjm/NZ0KaX5qn2Jb4uw33lHg0XFa2oLq3mprr4PcYcTmH8tu6smVmvZ rhkr1SdwJdi6TJKE1/o3x8weSCxfe+EPhCq2RptdtGrenC6sqH4IOGFy4KcwDloRMNLQ l++g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603631; x=1754208431; 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=1IXOiXj1C1ZetYUAJn76SJu5i4qqFoVN2qqJt7z2Klg=; b=QDuVSlLZFDucP/yXnDru+FjP3vsQWoZuPkKjqWyu5EkTMNdyY9hwZk0HJUhHKPdFwH wJGepf7478XB3Y5HeQNdVpjpwB0TRNh4cdo3bsOuKQC8Ewrn9MAbyn4wtd6omKqt0/Ql 4eKoG/dsZJ2pxFUoaKIY+2lpzaVII0QRrsuQEXV41UqpgXot9WKLNzaFmH7ppclHmD5o j+TUPEmbw4ak4GlBWWibn5R8nIdgIkuPs8HAnMZaq6QG4m2VZiT7INu3QjVN9S1X0DLZ TpItoIaA1imbasx1k4iprv7xG8EFKimbpNjOxU3RQF9ToRmNBbNHY9PC/g38xhdo32nq YihQ== X-Gm-Message-State: AOJu0YzKKoOahJcojKLlKdYqu/iwJ424Lt/77Y9jieXUfTmSwno5VqLW 58ZhpsQKpLFPEnf+sCEUUyWKNw8gQ2/MUxd7lgxGULu5L6jS2RF9e4Ox0lSl1ciJDF9zTZplYx8 VLpSy X-Gm-Gg: ASbGncvTy/gNSNvTtHwBFsTsrvzjWZq/CAeJX84pzp1sEx9WM/oiefr0uD56ERVUAkr jv3lM8ZSIADKj+Tjxn6R2lUWARakaGMB+dEJSmkna8Xqye+FiXYWMg77iNbs7gtnDU5jTqWSTt1 TTCV384HRCCcCbgzXsvw3gEPRUrUTZJoRWQL5Vf8uTyf4AIVYhPbVSysUDEntxKaem0AdbgG9KS /nxul+xzZx/eM2rxWvxKR9I/FQ29QCMl7vw6J2+2TXGgpXfMtniEKRgAeRsKhk6v+JDZpTuKeG1 CrSsPqEQxeakHxFGUnexkDt2KcupBjlgGnJYGSdJS0uOQTv1kxOQ72++Sr14zOOLyTiyZ7i0lgJ jpe8MaqcMnjzIuQu9RynRInpues3cPzdk3HVh9yPf45+uTbaLcJesPwJ4VgyVGW8Ssy8jZYcDAJ pd5uGBBlV2Vw== X-Google-Smtp-Source: AGHT+IHjBkuqtuiOLcMSppkeQ2Zf4hV3hjaQ82NkUs+E4Dc3jfIUVk7HlFBsz/i+AYABL1BqbJndOw== X-Received: by 2002:a17:902:ea02:b0:234:9375:e081 with SMTP id d9443c01a7336-23fb319041emr108186605ad.42.1753603631121; Sun, 27 Jul 2025 01:07:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 61/82] target/arm: Implement GCSSS1 Date: Sat, 26 Jul 2025 22:02:33 -1000 Message-ID: <20250727080254.83840-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1753603762897116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 392a0a264f..ee8b870e17 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -52,6 +52,7 @@ enum { ARM_CP_GCSPUSHX =3D 0x000a, ARM_CP_GCSPOPX =3D 0x000b, ARM_CP_GCSPOPCX =3D 0x000c, + ARM_CP_GCSSS1 =3D 0x000d, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index ab53a4314f..bdafc60786 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -114,6 +114,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSPOPM", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 1, .access =3D PL0_R, .type =3D ARM_CP_GCSPOPM }, + { .name =3D "GCSSS1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 2, + .access =3D PL0_W, .type =3D ARM_CP_GCSSS1 }, { .name =3D "GCSPUSHX", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index af91b7f95f..e4c7801740 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2634,6 +2634,33 @@ static void gen_gcspopx(DisasContext *s) tcg_gen_st_i64(addr, tcg_env, sp_off); } =20 +static void gen_gcsss1(DisasContext *s, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 inptr =3D cpu_reg(s, rt); + TCGv_i64 cmp =3D tcg_temp_new_i64(); + TCGv_i64 new =3D tcg_temp_new_i64(); + TCGv_i64 old =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSSS1, rt= )); + + /* Compute the valid cap entry that the new stack must have. */ + tcg_gen_ld_i64(new, tcg_env, sp_off); + tcg_gen_deposit_i64(cmp, inptr, tcg_constant_i64(1), 0, 12); + /* Compute the in-progress cap entry for the old stack. */ + tcg_gen_deposit_i64(new, new, tcg_constant_i64(5), 0, 3); + + /* Swap the valid cap the with the in-progress cap. */ + tcg_gen_atomic_cmpxchg_i64(old, inptr, cmp, new, mmuidx, mop); + tcg_gen_brcond_i64(TCG_COND_NE, old, cmp, fail_label); + + /* The new stack had a valid cap: change gcspr. */ + tcg_gen_andi_i64(new, inptr, ~7); + tcg_gen_st_i64(new, tcg_env, sp_off); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2945,6 +2972,11 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcspopx(s); } return; + case ARM_CP_GCSSS1: + if (s->gcs_en) { + gen_gcsss1(s, rt); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604269; cv=none; d=zohomail.com; s=zohoarc; b=b6YQBt86P+QrYj13yywKqT3zlx5mwlx0LHtYz9X9U6I2ghqdM2eVSSKoCFMlwnDkuRqH9zvsPd2j2YW5E4s5lRkFqxQT31vF52Fgah3lAeRxLtIU5l19ioNfQ1+5yaELf6lhKIWX04uO16+Whdd8h4MX4xRaGVAy9LzItaG5yeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604269; 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=Fqv3pWf5B2ybNy5pOAou28ZjicdcKv72gJ4k0GwAojQ=; b=FQJQaBR9vOUFyn9MPq2JOqGB3L9CsVK5Qom4k5RHR6GsmjfLvp3ec3+g1nWtp9vz/YDj7JDEHvotk3gPklnjI4gARyNBj508bbqI4fitt+eN2Ky71Quol2OGkES6xK0lJDZEOSOWu8uKaIoy9dJ7EoqtCaQdBnqQWSYr0IG9OcA= 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 1753604269632201.51023874167106; Sun, 27 Jul 2025 01:17:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRT-0002am-NM; Sun, 27 Jul 2025 04:09: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 1ufwPb-0002o7-S0 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:16 -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 1ufwPZ-0004p7-Vj for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:15 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-23602481460so35115025ad.0 for ; Sun, 27 Jul 2025 01:07:13 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603632; x=1754208432; 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=Fqv3pWf5B2ybNy5pOAou28ZjicdcKv72gJ4k0GwAojQ=; b=GNv/PXQvipuJI2xk1SOX/4qKwAwoVX0gzjmqgVgIDmwX2X0yK561PHu+GU+JWGrtx/ kCCYT12sSNfNEtK/GuH5m4KhrEXfaW8Yyk1L6Q4mhSehR6peNhts3oKirspO+0aZqt9+ 3q/wtLvNcPv7XFcC49Z1InYpJA8qjs06mgOkZl9tZ0knnpNKPGDiQA0gpUuOAmFg/HQU zzxMpH1TXg+57H1Zjx4BOFoKLBuDstM8dH0RQvLAFlcTLmzNsdxixUrMPgH6xJJajl+O yUd9uOxyUNHrl0/NNEY5X3x99Zi3Vo77csqoAyli8U9A0YYDvHirFurk2PBjdxlrLCj6 Ui1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603632; x=1754208432; 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=Fqv3pWf5B2ybNy5pOAou28ZjicdcKv72gJ4k0GwAojQ=; b=KLyo864Oz5lz4ufPnlQq6ChQNsiaNysvhot2aoGfTu1M5ZU0ZXH0QYNqc3FI29Z1tO BsIDOxA6VmY2Un9S+z0I6uKcNriRppr/G45QDB1gFCn+7fDIWY2t/ug5gbto9RrO7un9 i9fip8hEpXX7RyRgWDhmcK5Oe47d6A514S84XMW9FblAIJ5I5/kf05G/5l3/4sUbh8+j apofNJtRkzSOqZ1lPqzTtvPu/0RCkLQlqEwj2sqBWpHiZv93R/z5+QQNrmHm7807pXVy 7JOZ6jAs9DnFmk5u5ts+FN5q07ZBfFp+M1vRnGiQTIs1v/wcl5+HEmCJwqzJiOzYmBUI 0SpA== X-Gm-Message-State: AOJu0YwyR3FZ16KIFHKxwrG5zvEIBdrTcGw8XitxGQhpSiSKjp2wuB8D 4BCGO7bvIFZVr1jQHq/vbhRXE9xnJ9XSwJPZWeookk5s58GtjsQciD5w5LvWyHRaaKhY/utTs1c blWAI X-Gm-Gg: ASbGncupj3aMz+GcSXzy5mC/3P8L44Z5gWSTiJd0Qk3eL2Un4tRTR88Afy0G/cpEyuz DbsxcGMihlfkHFYev/KHFg4voADPIeRiwLcddU/xe36vGWfWYHDIAXs/AC1+qd+a1c/TD6D6HwX 13+BlTP8lfFrvavaehWFZmCwkBM3oI9KEFpZsHcFpB2fXq8B1w+uWFw/0H+sTNePS3fSzOdJPlM N/AO7kaASE2s+jPZfVyRRDXanDOcrcYHTTLl8Akk3rU4UmDmqcEZNZcvx4vClAyPEGzLZ935SHT zugr4vtLeB/1u169gZalm875ylSl7TCe5Qg+odaiyVQ6cfppWYnd25vMc/5krBFIAhe6vZ447c8 huUY7mPlrk6o6P1PVt/59qDynlzQdQmFzuW+oRgojSthlpEEzUy/m16TWegSlk+m7rZEOVawNrr vosHKilbrPcj/eFcAXTz7F X-Google-Smtp-Source: AGHT+IGZfWJqk8AIXcF4AAZauRlBqMgvZCim7iN7AkrYT9Bdb38lkE+ZvqumawIN4MOcc6nOaAR8UA== X-Received: by 2002:a17:902:dacc:b0:224:1af1:87f4 with SMTP id d9443c01a7336-23fb30854f6mr115890565ad.22.1753603632439; Sun, 27 Jul 2025 01:07:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 62/82] target/arm: Implement GCSSS2 Date: Sat, 26 Jul 2025 22:02:34 -1000 Message-ID: <20250727080254.83840-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604270406116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpregs.h | 1 + target/arm/cpregs-gcs.c | 3 +++ target/arm/tcg/translate-a64.c | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index ee8b870e17..1ee0bfd132 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -53,6 +53,7 @@ enum { ARM_CP_GCSPOPX =3D 0x000b, ARM_CP_GCSPOPCX =3D 0x000c, ARM_CP_GCSSS1 =3D 0x000d, + ARM_CP_GCSSS2 =3D 0x000e, =20 /* Flag: reads produce resetvalue; writes ignored. */ ARM_CP_CONST =3D 1 << 4, diff --git a/target/arm/cpregs-gcs.c b/target/arm/cpregs-gcs.c index bdafc60786..558e223838 100644 --- a/target/arm/cpregs-gcs.c +++ b/target/arm/cpregs-gcs.c @@ -117,6 +117,9 @@ static const ARMCPRegInfo gcs_reginfo[] =3D { { .name =3D "GCSSS1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 2, .access =3D PL0_W, .type =3D ARM_CP_GCSSS1 }, + { .name =3D "GCSSS2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 7, .opc2 =3D 3, + .access =3D PL0_R, .type =3D ARM_CP_GCSSS2 }, { .name =3D "GCSPUSHX", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 7, .crm =3D 7, .opc2 =3D 4, .access =3D PL1_W, .accessfn =3D access_gcspushx, .fgt =3D FGT_NGCSE= PP, diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index e4c7801740..88fe5ac4ef 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2661,6 +2661,38 @@ static void gen_gcsss1(DisasContext *s, int rt) tcg_gen_st_i64(new, tcg_env, sp_off); } =20 +static void gen_gcsss2(DisasContext *s, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 inptr =3D tcg_temp_new_i64(); + TCGv_i64 outptr =3D tcg_temp_new_i64(); + TCGv_i64 tmp =3D tcg_temp_new_i64(); + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(GCS_IT_GCSSS2, rt= )); + + /* Validate that the new stack has an in-progress cap. */ + tcg_gen_ld_i64(inptr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(outptr, inptr, mmuidx, mop); + tcg_gen_andi_i64(tmp, outptr, 7); + tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 5, fail_label); + + /* Push a valid cap to the old stack. */ + tcg_gen_andi_i64(outptr, outptr, ~7); + tcg_gen_addi_i64(outptr, outptr, -8); + tcg_gen_deposit_i64(tmp, outptr, tcg_constant_i64(1), 0, 12); + tcg_gen_qemu_st_i64(tmp, outptr, mmuidx, mop); + + /* Pop the in-progress cap from the new stack. */ + tcg_gen_addi_i64(inptr, inptr, 8); + tcg_gen_st_i64(inptr, tcg_env, sp_off); + tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); + + /* Return a pointer to the old stack cap. */ + tcg_gen_mov_i64(cpu_reg(s, rt), outptr); +} + /* MRS - move from system register * MSR (register) - move to system register * SYS @@ -2977,6 +3009,11 @@ static void handle_sys(DisasContext *s, bool isread, gen_gcsss1(s, rt); } return; + case ARM_CP_GCSSS2: + if (s->gcs_en) { + gen_gcsss2(s, rt); + } + return; default: g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753603973; cv=none; d=zohomail.com; s=zohoarc; b=ECxsN5bC7Fv8YgvxVouP24Jon9cbu07eQ5+puiVBr51GyUrGd/TbXiFJZO+wi113fbp1xOCzQLcVBr2uHaCsxESwHHEV2ZfjPzZ+xEJds9dibWOzQfdHPWrDJIYmX2Ix/RNSLyvG88tI+cBvtpo2C65Jl5zMcWsydigzSLCXbcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603973; 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=arVF9tN72BhPKd2O49ekxCQ+4ux1mZKYZhH3GMQy8Vw=; b=ZP+l9Wnd87KPyQ4EYw2+Wn6muNyOSu/wQWPo1ImDqvzumNE7HSOj8GNFEi6kx82UxhVGUJOkt0sJO/thusOpLWq5Ru7KZmg3djJOsm+BrHqMHcfPHwEOwIzIR377RSLZcS7m9XHECS1pjQJ5sJt/E8efIE7NUm3PP0JOjrUmOoo= 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 1753603973501590.3069484909432; Sun, 27 Jul 2025 01:12:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRe-00049C-RZ; Sun, 27 Jul 2025 04:09: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 1ufwPc-0002tk-Hd for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:16 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPa-0004pU-RW for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:16 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2350b1b9129so23723175ad.0 for ; Sun, 27 Jul 2025 01:07:14 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603633; x=1754208433; 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=arVF9tN72BhPKd2O49ekxCQ+4ux1mZKYZhH3GMQy8Vw=; b=XoRI0inAFbVcu+4iHCptVU+UyQ7kaFjCeimZ7v8xC9g84nHv+OzT3NB4X3OglUwmd1 266T0oIaKs2ahdf04jQuY1kaYIpwM2s/EuSn7dI28XHQYWHvhaUKqqN98l63qyVqjUbL VNmBTXT3oxgfLR+qgFArxjAiFJXPFpiHFRxioXYwecEMlLuJzAOnrTdUdxDWvqNidxam FvBcTMUmgW30SdiOYi/V0hMVrOnRwgfHNeyUo24rj2wHu/1PcN52llcSCaaB4d8Fv+zY Y2azzYPBW6uBeo40LdB60vO8fX2n/OrwLUOBF6jW+9J0XOuTHsvRYG7THK7SLqzSuXBE sfcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603633; x=1754208433; 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=arVF9tN72BhPKd2O49ekxCQ+4ux1mZKYZhH3GMQy8Vw=; b=p4IQmNLpTZnEy4TcGBDn9pxIUFH7dT7fBYmQ5+5YaoT2EVyE8Cjxt6B4o3jelbCJPa jSMV8DglIjU1uRS8i2yfG8mIUi/oTsh3I8UGXXSSyPx6laePezGD8uureuuNCJ870SFr 3s0LhaRPWU+5JtSREIXvbvUNNa8JjUmZfX9qbWxFwVCPtRhiR8B0DpEw2iEYS22Bsx2L 3vDaWZWBE3Vz2XKfi7fVN+POa0APkbsI4GaJCoJIp9QSD95LVZCVy61I0IXNgtyYRKRL ApVkFgDldhOiQhBkXrIuWqN8AL4QoWNfyuS8WwaeOWM/fU7OrJOpSVWrqXCt17NtKqh1 U1OA== X-Gm-Message-State: AOJu0YyYhKXvdP2v6PpYIFeZTCdyXmRbWhuTBsGuxTcsdJT5WpuXTx8U 35hLxkWJdln8t2k754FPPMS2WjVSDldRcG4p3B32462rA+kydh5MJYkrc57DDshSX2nw4dRGClD /r5cw X-Gm-Gg: ASbGncs/jRS3vbV19vTvTd4UpVwbqiFIRxM2LdFKal4WBjQFIU/REdg5w/o6g3wiY6j 08rYcLpqEK5knVOUg9cjJLLoUPAD7WBIO+PZJc7Wu2VfWN68yxhqF2ymlKWxjHz1CjdOQ/RR9Vv Iy2YAcUxupIPX2owwOYtCP8qO8njTKnAAlyQsPt7s2RBTJhoKZw+2ww64xcyGp4Sknqz7ZLgNWW Jp9biJd2IlCgnlLv+bCxw0lLW5biNg01Mu6EHr2r/DnPXPCp+iRg1MjK9S62X49UuhzaLBV1/mB CZtQ7090ui2j3LyimaPIoHdAJAHYvtb55NVcNSCrmYtrRXXjBqpbB33YME7Hqbd7U4KY1Fg8BSK wW973LiT4ajB2jVB8pf3nf9UVxkqycFjocJ5MHN7VaTbtrbYkg7NuWAt099WlDp5EZOWxA0HXEP IKbvP3hjD3aw== X-Google-Smtp-Source: AGHT+IF3kFx4OSDvA+Bf8eqDWdtPyShqYUixsaFKMSMMPKtJ8UDYCVeKAuX5YbZC6UMtR1f6SiWtCQ== X-Received: by 2002:a17:903:41d1:b0:240:2145:e51d with SMTP id d9443c01a7336-2402145e8c6mr588745ad.31.1753603633593; Sun, 27 Jul 2025 01:07:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 63/82] target/arm: Add gcs record for BL Date: Sat, 26 Jul 2025 22:02:35 -1000 Message-ID: <20250727080254.83840-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: 1753603973959116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/tcg/translate-a64.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 88fe5ac4ef..6fd3032613 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1667,7 +1667,14 @@ static bool trans_B(DisasContext *s, arg_i *a) =20 static bool trans_BL(DisasContext *s, arg_i *a) { - gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); + TCGv_i64 link =3D tcg_temp_new_i64(); + + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); + } + tcg_gen_mov_i64(cpu_reg(s, 30), link); + reset_btype(s); gen_goto_tb(s, 0, a->imm); return true; --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604346; cv=none; d=zohomail.com; s=zohoarc; b=dAXFSIM3oBwJwCtJb/g3ffvHozaXCulMxOo6CShlwv8wB4wxmjQz+KR8eVB+CD8+hXhQnQYB2nomu+/EAlcXl3/hdqamF3xmHDVF/HogHKrgiwKgfvjHa0dFcILXIGhMbhscfLRAPTkU+3rCLs3bbdPCGD8QwUjrxGXIR+zVR0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604346; 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=gIx4SJW5J1RoTFpdEMgpD6LEdku6UeK6pLsBjwXWXNo=; b=TgdpTDBCqsLXvxKcSyQDbgz1ERW7wbNo+A8g1PwJuz4xNW5EupNxWl+9rWPRGSe7kesFwZZgh8FgH9L3XuCpEJaQEIC0GaBiUw2GUl8QcbQTuUd8pIL4FPF2W0OAVeMxcKzWtVrLCtShl1ge/JUv2UAq0TQFJ56KjmMHRCJdpXQ= 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 1753604345856578.4902160448895; Sun, 27 Jul 2025 01:19:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRi-0004fG-Ry; Sun, 27 Jul 2025 04:09:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwPf-00039h-2u for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:19 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPd-0004q9-3K for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:18 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-237311f5a54so28276225ad.2 for ; Sun, 27 Jul 2025 01:07:16 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603635; x=1754208435; 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=gIx4SJW5J1RoTFpdEMgpD6LEdku6UeK6pLsBjwXWXNo=; b=YduySLf9ZW9JR5lD0IxivZS+Ep/17O3Yj3Ip1WG+De0+zjTZyZZaVveENBLs5tRd0Q cGyPoMAoHLd5e89SrTa/Pio3veDMhbHnGp8SYBe6yMwfkOpfQtIfKRK0gTSJlH9eo3Hr +cv54nUQhI2q77Gg+VLgOL5ZsAMkT2RQ5oKVmIc+dfmP5bb0g2Pkk5GMJ/M85/DscRWd N4/R5VwwBaoknRgmKWPxn0zZ+5O38khQ3R/3Q1gmOnvUEjATHHAg7OZrUe4lc87xHpcL lQkM88gHfzFowjDTDF+IMoDS6I/keF8+O7Aa9PbDx+J4WD5N2xsjKpK2t0mbGjboCaEX mORg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603635; x=1754208435; 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=gIx4SJW5J1RoTFpdEMgpD6LEdku6UeK6pLsBjwXWXNo=; b=bars68lJGuU0XkuklLfe09Xx3TL9bGuoMfuqZo571T4Fu8kkYP9eMUjo8DJX4VuSLR k/+NKHyW2EKLdbBJNmdNh+Eudd+qM3oPZFxef6GH2vKFMet0GljgWA+3m8lwlcW9jwS5 L/Or2MOdAKIUBAVx60U8jp4pEs47bPrJegw30f4AXL3omR2MfHhdCaVnxbzTf+zkiPOq C587rWSzaNGlwhyjdBuR9Ab9lDA7XWQn6mBSf4CwNMeX1sRhWWW575lobUN1FwNnoQPs fc1xSjKm2fu/7WoshjUcfNieI6UY5JXoM98z0g8hM9zGuNTsYkRUQWrX+qcXBjtK/CsF cjsw== X-Gm-Message-State: AOJu0Yy8W6E3+CO4GQEn70yyB1Hmsz24qp0jJ+fPpAaHzJ0m29eGVCIw ktyZzay1pbvLzPunkYOqHlkDNxD0DLPzxzn6hpwePWLhCTr50vk2PlsPtMIEfwR4C29M6rewU9m nLvDb X-Gm-Gg: ASbGnctlE9KJ3wCQy8k2i3LRZFbWjjJC4nWNF59yQvdoB7uBP1dR7XVoIcIM8Dr0cso k56IQERUDvfGXL929OIfnx/Chlcv/oixQYJO7dwMuxpmHYhl9UWpvZcBYZGEvjtNOiTNcVcnBVq s4NEVodHJ2OLkWEwlEY0IuBTNPDJJIQziHUIgDI+WAll9juiQIqNtpqfM1bFTzcv5BroDm2wcqk yaoYHADUeUSCjEWn8agXrSfUZJPvb+6wX64MwTRk4BW1+nMQKogfSXcq/6VCM8nuT8rJdmVg+z9 G+oEmc6Jz9AkAw3Tc5SsEdBjf3AoVJoVfzC4FWBoNesxogERgwlzTTbsb7I/A4qRhYp/KAevuVL PHmowTCeugL3ytkRhzvijJjQXdISpixlaKulCF8QYnJA+GIOzznFc/eIqdZ+FCJAq+IGi+mqYJu J4BTqGqsXi8w== X-Google-Smtp-Source: AGHT+IGzoSI76uclgP4CqGdNrsMo8Qo/wReLVP3GIu8OH5J9u3/hOjlkb8ZnmvGfvdE6Lsz0FOA/1Q== X-Received: by 2002:a17:902:dacd:b0:234:a734:4ab1 with SMTP id d9443c01a7336-23fb307cde0mr126460925ad.3.1753603634680; Sun, 27 Jul 2025 01:07:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 64/82] target/arm: Add gcs record for BLR Date: Sat, 26 Jul 2025 22:02:36 -1000 Message-ID: <20250727080254.83840-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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: 1753604346805116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/tcg/translate-a64.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 6fd3032613..4c3cc3d943 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1771,15 +1771,15 @@ static bool trans_BR(DisasContext *s, arg_r *a) =20 static bool trans_BLR(DisasContext *s, arg_r *a) { - TCGv_i64 dst =3D cpu_reg(s, a->rn); - TCGv_i64 lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; + TCGv_i64 link =3D tcg_temp_new_i64(); + + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); - gen_a64_set_pc(s, dst); + gen_a64_set_pc(s, cpu_reg(s, a->rn)); + tcg_gen_mov_i64(cpu_reg(s, 30), link); + set_btype_for_blr(s); s->base.is_jmp =3D DISAS_JUMP; return true; --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604470; cv=none; d=zohomail.com; s=zohoarc; b=AHyN7PvsuxnVSk1keIEz5pcsUmyYvlIwD1TfxHuDZq6Y5UFVbtMGaoEw+hubQLzlyIlgbn2CjaXfpAyJd1cfJVzuUaKvgFgWf0c2hbVw+/qAUf1ajQLD940R+M6I9s8s8WQcoX6S0WHPBvz8qmvJvnpgE3TAZGjopPa2eNhy0As= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604470; 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=7TXE+y1w22n/yh7OLtHbJKv3G2qNUuDgGnZZzftavGg=; b=OE9pfXdqm5CppLknuO53T+tHUZmIujA8gClf6Hlp8/aXI9yU7DN7DDV3NcpDgfgcuL/2OhyzOtlf6YY+K13DK1AR6Us6QW9DkWvTyfoZ7ifOvATg46KUBxJyKN+eTWQjrqimJCeWcjOJgZsqOzcVl481DkTaqs44JnLQvFU7ZOQ= 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 1753604470900272.822375566094; Sun, 27 Jul 2025 01:21:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwQN-0005Il-Eh; Sun, 27 Jul 2025 04:08: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 1ufwPg-0003ET-2D for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:20 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPd-0004qD-4Q for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:19 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-23f8df98e41so30602655ad.0 for ; Sun, 27 Jul 2025 01:07:16 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603636; x=1754208436; 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=7TXE+y1w22n/yh7OLtHbJKv3G2qNUuDgGnZZzftavGg=; b=ovIlMz0lFiyBmvs73NTtlOng3R2mT3E+pk/aqSIWGvPXKNWwW1gjvy841dzeXhHmOi 1UPdqLVNtZZi7YqDFJSTFm7tl/rany1vnFCfjKckUfUF4Cyw8An91CMA8A2hgscIAPEP 83fcz3X4W4G6EGKmI+03djaPl0QiApAVmkcGetwh8+8vsv198LVdjDddJXtxGGUIYTGG c+Wb6SWNKAeIyl+55F62AcfKXiTivhbBCDpI6lkyh9vFF+L9DH8sJGjaAfnsBhOn7yqd 22LSPDZsgBrZCZk2bEObf0RxIS/ROppHFUwpfpOtT7UhwQGEX0oxOm/I13/06uDtq3Jt X84A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603636; x=1754208436; 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=7TXE+y1w22n/yh7OLtHbJKv3G2qNUuDgGnZZzftavGg=; b=JffmjhnApKhG7aiNacXF4Ggi6j5JR64BdD7/6bxKjIGv0YKx08sejJ/Ftr7P4ZjxUM qFnYflBtJnT4d6ycvyA73LNU/lTmNXN0zBPPMMaUEz0fOCb2Uo3hGPWJy0jV1fzVfRQE K7gKSaY6v7jOXIhPR4muWzq6CAHiqPZ/vtVbkegnE4EYDTDpLLfi5IVkt8dSqyn1iiXA EYpBvYv4GEKhf1/jUIYGCrYoOVOycXNvvBO1w3tNnBa3lgB0SXAe0zyBGrjFAAQo3+eb CjiepG6dqkS1zNODQqzSdoxvGbW2pljDECoYd0g2Jc10CM1/K7VPW5fYmwx6Zu44O1ol znzQ== X-Gm-Message-State: AOJu0YxeknF4ZO7f9jq+WyXXGZAXPpCfPgaU8hzO94DUwg6dsLZsYzpP YMzet/M1Bw8+cMjyOKPnSKglhmgynLkM5HkXKjreR261qHvCmASOuIWwizaBlCu5XsjavKvk0J2 qr59G X-Gm-Gg: ASbGnct1DPkzSfRAO7AC+25D0w0gUUdaB3P9YKx6VjXubZhi9tXLBPMXWeNBpqoB06n YVj6RbkeQyKyAWIcPmjfaWVgCYi2YsNarhgz88RH1NqpuyqYR7i8XZ9DTg82kHEH84QlOK2K13G +ZJG69VgMWpjp9gjzAdjAs3vOAaB24HHqaTXfAqTxUhl+ytKLb+GnDQHzLGd/uHprUMOrxnBcSM lvBzOUA7XGGGHsJpef7EgIcbf7y5bJmWefkQzNkTRgG/cLvVZ/fz/at7nE60LSPj95uJIIhQmy/ B4gi1UW7rPpTE4m/am9tT2xfipG0nqiRXJJqVRTpgh3Sxzb828vBL/Wa2GgGmbdlnv8wx1JxJC+ 7fgOwNKI29bRd68TEZLfTNc98vri5Ns9UGSaGqu3gUfHmmGZSXr5NBAx3AK4E7ktIPxCU90Q2IC 4F1N5HgRcJVA== X-Google-Smtp-Source: AGHT+IG3jzsa0TkAhyaIVt1nPobzgt1cxaK0VlCFf9jdct5cTr6wNOOaSykvTNwinGs5nqyMhyepLw== X-Received: by 2002:a17:903:1a2b:b0:235:ea29:28da with SMTP id d9443c01a7336-23fb302247emr129933255ad.17.1753603635826; Sun, 27 Jul 2025 01:07:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 65/82] target/arm: Add gcs record for BLR with PAuth Date: Sat, 26 Jul 2025 22:02:37 -1000 Message-ID: <20250727080254.83840-66-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1753604471629116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/tcg/translate-a64.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 4c3cc3d943..a945fd3b33 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1831,20 +1831,20 @@ static bool trans_BRAZ(DisasContext *s, arg_braz *a) =20 static bool trans_BLRAZ(DisasContext *s, arg_braz *a) { - TCGv_i64 dst, lr; + TCGv_i64 dst, link; =20 if (!dc_isar_feature(aa64_pauth, s)) { return false; } - dst =3D auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), = !a->m); - lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; + + link =3D tcg_temp_new_i64(); + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); + tcg_gen_mov_i64(cpu_reg(s, 30), link); + gen_a64_set_pc(s, dst); set_btype_for_blr(s); s->base.is_jmp =3D DISAS_JUMP; @@ -1881,19 +1881,20 @@ static bool trans_BRA(DisasContext *s, arg_bra *a) =20 static bool trans_BLRA(DisasContext *s, arg_bra *a) { - TCGv_i64 dst, lr; + TCGv_i64 dst, link; =20 if (!dc_isar_feature(aa64_pauth, s)) { return false; } dst =3D auth_branch_target(s, cpu_reg(s, a->rn), cpu_reg_sp(s, a->rm),= !a->m); - lr =3D cpu_reg(s, 30); - if (dst =3D=3D lr) { - TCGv_i64 tmp =3D tcg_temp_new_i64(); - tcg_gen_mov_i64(tmp, dst); - dst =3D tmp; + + link =3D tcg_temp_new_i64(); + gen_pc_plus_diff(s, link, 4); + if (s->gcs_en) { + gen_add_gcs_record(s, link); } - gen_pc_plus_diff(s, lr, curr_insn_len(s)); + tcg_gen_mov_i64(cpu_reg(s, 30), link); + gen_a64_set_pc(s, dst); set_btype_for_blr(s); s->base.is_jmp =3D DISAS_JUMP; --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753603894; cv=none; d=zohomail.com; s=zohoarc; b=SvKMjP6srzrbWbWU4cIzkKx722N/ZH27c8Fg0oXjLsA04et/m4JBph+0oEIWFGeqQov33YSwq9g+3coTsuPvgIkayljlmhORoT4ahttp8L2vqlS77mwrSovLLqKsre7vApxRyQU2NWHPsrOCCnOZXHytV3MJx/FZ89PkR2O+Upc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603894; 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=RPGoJwnTczFq0hUhh1/WUbQmW5Q+b6Pxb6X8smLgfxY=; b=HgwaLdr0m94PO/PY7ocewB0VqilpFjFNezKstpZaPuVRUPcE4Mhky28SQGQh3nMoVrShAfinbSMr0LAAbItMwaDqdt8yNKFrcO2DRrKoVz8eFb8Nil5pJzRC/2CE4mJKkpU/PK9t5VawF8ssJgcJsDjz0Fw5h7G78SNAqd3M+MI= 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 1753603894090519.9196190399962; Sun, 27 Jul 2025 01:11:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwSE-00061Z-Sx; Sun, 27 Jul 2025 04:10: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 1ufwPg-0003G3-FI for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:20 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPe-0004qg-9O for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:20 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2352400344aso30526395ad.2 for ; Sun, 27 Jul 2025 01:07:17 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603637; x=1754208437; 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=RPGoJwnTczFq0hUhh1/WUbQmW5Q+b6Pxb6X8smLgfxY=; b=U3rhdrPCLMbBLMWVo8dqfGUYl4Y51srOqTZ6cyln0Es5AYrSDqaxbAzVzmGdqLlhxP JHVp9L1XtmjN9IcSqbSOsffxpPUBFZu+TK+OUvhxSNoBDGH9X4H8PB3zZq7utIxURS68 /kV1UpbWKLL6i2mAx2NYMxpgri4A+c8uTZxfZmHfzjL7SehRb8CZo+I4UwP58HMxC4vu mlbdsenEC5axepsaZMhbwY6Z7CZc3ouRIpy4ApANcZCG2fvRdDmjaNrqvgLD2f8BgahF B3scs5p2S+D99hY/udBdeJim8hhAjldHx/meOh0P0EncDCkIPCkZFrKrQTcDVLzpJTRA nAgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603637; x=1754208437; 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=RPGoJwnTczFq0hUhh1/WUbQmW5Q+b6Pxb6X8smLgfxY=; b=rI1DmA90I1r97WOJPKrfMlUeoh4Nu7rcVgIg1Y8VjuRnNoDDE6PUTgH4J/JecgMwSG NSSOwmOd9QnT+qyDT1uBnGST/mWGXbGiNA+bw9x3WiOU510CGBx0ix4bLZPppOJzduLS wuPHhlbdeIGTsbTavHateoet129cKcBhO3ZV+AA+vhZaeHv3OxwQsQHuiJly7qGDwdIj rs9H4QXQjFLUbdK9L88pETO15kpBQpYAx4poZpQLbcZu4OikMhCO86hvkBZASsrOwZy0 Mo9TJLWxdR2GwtvqmcTmoIwwFbRZLQsSc3HeAKh5mqEKyJSJDWL8kHnt300bZ4chzlEw Z1lA== X-Gm-Message-State: AOJu0YyQ51ClVXB+rj5zD4vOdvqc4fgH8aVfVpB47ysikDoNzDroXeGg Ce1fMVTuHE1YKvop3fZUNx2bRTyvsRNiaXPpndw7g033BFRrlHdXzE0E74vo3n1YlZGJCKTYHG4 fviI5 X-Gm-Gg: ASbGnct9RmpQTrVMQl2NO7xk2uOMcNTlid5vwI4c0J42+Rh8tB1AiZUGImosimHswwF +K4dwe+twnoV1gOC0hBjA4wg27C9MMGi3mwnt9/xeYcaQ2GlXezC7JoZsfig0BvTsB+7NTwiSEP G3EDYCBavQkma/pLC2ds2QuR7k1UXD6nngEI7JN1OXLhiXNir58cv/oX4ZP9uGul4TfboayHmsa BEx5olOHrg1S3vu4XT3h1q54QVvRa7rR1W780uVULAnDg7zVG7ELHV8xL+MqSNdA5sGflLztO0l 3+6PqTBAWPP+cYOtnglYnjSA+iX5bFgbAE1339psLDJX9YZiKhZNSqqa0/0ON3IaF9ZvFFbgj3+ 1cdsAGRvkxK6zyUMvqYqjO+5yXG+qCD1Adq3XyXckd0Nw6aPSlAymllAyw/qV3cO3SRkjuwVG6f /hsur0PXlVRtmMYwPL+zUK X-Google-Smtp-Source: AGHT+IEIRxYBJ603W4TXnAniQq+VBI0GlTfV2fO9AdN3n0NroZYOkJSO6Z4zjh9Q726DB8SpdfMkAQ== X-Received: by 2002:a17:902:ccc4:b0:238:d19:864b with SMTP id d9443c01a7336-23fb3165b37mr111857895ad.41.1753603636952; Sun, 27 Jul 2025 01:07:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 66/82] target/arm: Load gcs record for RET Date: Sat, 26 Jul 2025 22:02:38 -1000 Message-ID: <20250727080254.83840-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1753603895561116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/tcg/translate-a64.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index a945fd3b33..49e17548c1 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -433,6 +433,30 @@ static void gen_add_gcs_record(DisasContext *s, TCGv_i= 64 value) tcg_gen_st_i64(addr, tcg_env, sp_off); } =20 +static void gen_load_check_gcs_record(DisasContext *s, TCGv_i64 target, + GCSInstructionType it, int rt) +{ + int sp_off =3D offsetof(CPUARMState, cp15.gcspr_el[s->current_el]); + int mmuidx =3D core_gcs_mem_index(s->mmu_idx); + MemOp mop =3D finalize_memop(s, MO_64 | MO_ALIGN); + TCGv_i64 addr =3D tcg_temp_new_i64(); + TCGv_i64 rec_va =3D tcg_temp_new_i64(); + + tcg_gen_ld_i64(addr, tcg_env, sp_off); + tcg_gen_qemu_ld_i64(rec_va, clean_data_tbi(s, addr), mmuidx, mop); + + if (s->gcs_rvcen) { + TCGLabel *fail_label =3D + delay_exception(s, EXCP_UDEF, syn_gcs_data_check(it, rt)); + + tcg_gen_brcond_i64(TCG_COND_NE, rec_va, target, fail_label); + } + + gen_a64_set_pc(s, rec_va); + tcg_gen_addi_i64(addr, addr, 8); + tcg_gen_st_i64(addr, tcg_env, sp_off); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value; @@ -1787,7 +1811,13 @@ static bool trans_BLR(DisasContext *s, arg_r *a) =20 static bool trans_RET(DisasContext *s, arg_r *a) { - gen_a64_set_pc(s, cpu_reg(s, a->rn)); + TCGv_i64 target =3D cpu_reg(s, a->rn); + + if (s->gcs_en) { + gen_load_check_gcs_record(s, target, GCS_IT_RET_nPauth, a->rn); + } else { + gen_a64_set_pc(s, target); + } s->base.is_jmp =3D DISAS_JUMP; return true; } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604108; cv=none; d=zohomail.com; s=zohoarc; b=eDuNQQl8aXOpPjhtXfl8Pj68NlLUfXulA4gjg9Luig02t5yN+APd+JNx2PT6hNwx+Ao4yscD31WWLuldTXfkXvtuMA3mGFSSgfBAj8v1mR9UrsfiCqrUJWA7Gj7l3unpGeQaHHJ+5xbaQUKiaiJUSCYYA3EheiILAtr+8RVdMOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604108; 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=RB9M/NYV6NC+RrE1c3AzJNzEIqzbZfbB8TlpGuA3ub0=; b=Amgk27VDXDsRLJEkxEQsLhZuJuznCQICo0RIK1WCK5ePMpKqMTTjwfegN372Nhk3ytfCmrI1jCpiHLTr2X3x6pYJ6JxtZLD9UoVKsLp4CVnlebA5DD41kxJrsQzryW9qHORXP3OU1k8u+9Mm9OCnOeKAogqosoIp5e29QxKvyro= 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 1753604108424875.2520848642407; Sun, 27 Jul 2025 01:15:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwR9-0007ug-30; Sun, 27 Jul 2025 04:08: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 1ufwPh-0003Me-1p for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:21 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPf-0004qr-BB for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:20 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-235e1d710d8so45907395ad.1 for ; Sun, 27 Jul 2025 01:07:18 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603638; x=1754208438; 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=RB9M/NYV6NC+RrE1c3AzJNzEIqzbZfbB8TlpGuA3ub0=; b=vQPImJToE0n8d5rEcHPO8+C1TFG2JW1qGOUJnFlpMGiiqoc0ZadBEUALTpnLobC8SN 7wXMKNkyiWKqiFuODrYC/rlnMwq9xeSt0ynqye5EBlkr5kdmxSvzGywB5XgDe/dwo7NR LR/j7O34hUzuYcQ1VgD19dO37EW5tFS555gOgFSs85qz8LYwFSf2kmH65EgOC181oIVB CSRUdU+v70onFEpAZBzZrFiQhU58IPZ0qLcSqn+SPhefdpEl8vLqjY/NWls6VLWx8zDf ws32DB3mu+hsXdf2CprVgPGxSM+tLS8rxNxddFoamkiEIi1hva50c1wideQLq3y9xvtl rDVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603638; x=1754208438; 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=RB9M/NYV6NC+RrE1c3AzJNzEIqzbZfbB8TlpGuA3ub0=; b=S9ud3XGGxe+6WCXwkogr5JwoL+8R0IP9YCQV7W0iObZ6izRVH96ebjHWRUGp078YD1 8US0LP3Sjyar+hMsUupszsDawHrLJzrQNtqm+zIQfFlnwS3KOhhdVY2IZCcp381VAniW 2bB1bAFjFqUibbf3BCoNBNLhJErFz+QhJJYUi4SNec5enCR4dZoh0umX+AIybiR1xp+y 7LUwfuZZ4mNy4/bztCq03mTSub5gJTfE5FQZsXBXVw+TNo0GQ2kDnxdCgvHj6U4zyStw Bq0WFQIB2RhjlXyazZmcXqxOjVmtj6Ul1ZQ4PoOmARRPze+dHNLiERsxUhhB/y9vNO8Q VsAw== X-Gm-Message-State: AOJu0YxAzjMCcIOU3m0BjqrG/AsLc1HcuBBTA9eZ/PQc1axRX/xdUGFf sQWRU4xWhU1i3xGxXHjgaMdf20yLnS0rjOCHMr1edNcZRQcS9UaH4GpYO9wYA19ViMxeA8kuTA3 jxf64 X-Gm-Gg: ASbGncsINaz0Dc3dv+/+aDAOSUWc10v7SrJEm8PZAPor1hVrZj5oIMEe3cErkmP4qzx h+dzQLOo4dfDbjNulUsetkVewFKhzpB92lSUxw8SjbOJoP1IgwJIzN8XQZ8A+isvN/20Si6ftnr MKSXd20+NxPdFgLVoqyM216cUmAusMCR5EgDNZu5fVBzzMw5ts1InZlqjE8f48fPjXXPoe5bRtY IxbHB9gCntwZ6fXRWhMHbyj85KwUNaiIa3sNDbrjM0wGUYi0K07VHYaXbYm7L1Lff8iBebA7LFl nKJ/4lkrOAm3UggrejDionDtiSISFzQeP6yk0CLd+jG010RCS0cD2/t1vrAgzRgaQYApIJkn2aL 7Pf+2Ct9kD0eYCWLKDzT7poADEWm7ID6Kkb0Ah9kl4Tm5Iio0lcvCX8YYz1jAZcZrnIGRGWX490 SVe9L7vw46hw== X-Google-Smtp-Source: AGHT+IH5ZWHbmImMIHnHrPTrcRkEHEAN0dapUsFJvYyxKo/AcbUmGg978OW/x/pgvhMlcn11rQahrQ== X-Received: by 2002:a17:903:2b10:b0:234:f1ac:c036 with SMTP id d9443c01a7336-23fb31c4de1mr129390315ad.50.1753603638014; Sun, 27 Jul 2025 01:07:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 67/82] target/arm: Load gcs record for RET with PAuth Date: Sat, 26 Jul 2025 22:02:39 -1000 Message-ID: <20250727080254.83840-68-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: 1753604108966116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/tcg/translate-a64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 49e17548c1..23186850f8 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1890,7 +1890,12 @@ static bool trans_RETA(DisasContext *s, arg_reta *a) } =20 dst =3D auth_branch_target(s, cpu_reg(s, 30), cpu_X[31], !a->m); - gen_a64_set_pc(s, dst); + if (s->gcs_en) { + GCSInstructionType it =3D a->m ? GCS_IT_RET_PauthB : GCS_IT_RET_Pa= uthA; + gen_load_check_gcs_record(s, dst, it, 30); + } else { + gen_a64_set_pc(s, dst); + } s->base.is_jmp =3D DISAS_JUMP; return true; } --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604363; cv=none; d=zohomail.com; s=zohoarc; b=k3REB4oISDadrTAsvfL+kt9jWCLyr7dy/oNru288iZ/9k4LwEYBYfGitHh8aQ4vnfnMS14RTvlhBPUX/fhMtsVP1N5f3DkhEfmU/AvtrFULp/tMw8ZrliFtaeuJpTfFUDkaV8qqbnzGwcVLQxnvxiETJvUVuSuW0RVQxZs72Irg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604363; 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=rpfne0/mZ4p8IHBae8X7Y2QjbioW2/Mtp7IWsAwdNTY=; b=K5Ux2wehTXDUiE3fOX9y47fTNXITGhYZr+Y4hGb7ZoxQNMkIjoi1b4Igrd+bdwZD7VRqucIBRZtd4sF8gDt3iw1q6tBYBAEqM9+3vNiM0YlVbW4QrqpHMaa2QmZ8zeQrniKjR7im/mOfQd/kCcTvUa+ZXgH4oN3zSHabrUCglZE= 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 1753604363546754.5045741191132; Sun, 27 Jul 2025 01:19:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRi-0004gc-Nv; Sun, 27 Jul 2025 04:09:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwPi-0003bG-4c for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:23 -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 1ufwPg-0004rG-FD for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:21 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-24003ed822cso1924815ad.1 for ; Sun, 27 Jul 2025 01:07:20 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603639; x=1754208439; 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=rpfne0/mZ4p8IHBae8X7Y2QjbioW2/Mtp7IWsAwdNTY=; b=VoKk40uISNZitzhzJoLShp/1IGfYp9P1NSXG2/asm1j560/GSHTnqrOwRYGG3FXLUF V0UwaZELncfZFQ00X4dDfbjyI1L29k0m0QUjb+178FJh2s/Qr/TeMdtFHYeXnUd6MQnS nilJidzCO3rLpNQM/+9SEkOYf/AVd5S/hd9VayQWkTBfaXhtXS4bWOrT6KCLYmcbxYAf Ds1sPFP1TkCFuD/x/hdQ0VB0Jmu0U3OO5bGJ+/WpMIRoIlhlWxK1RIjqM7cXxGRZpG0L 9mpL+IYr6qNTy1MGp/G2tTqiPOUfeqraNsZfd6JK0w+hpOBPReph1Zr9+3wtDi3jCnzX B2DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603639; x=1754208439; 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=rpfne0/mZ4p8IHBae8X7Y2QjbioW2/Mtp7IWsAwdNTY=; b=vva5vLX9FndO5uzwpgT5bDbCmv8CeMBkCDGWOR/01scspXc9lMWsBYrQQyLKGE9Liv mW/b8HYL8BXh5/TGf7idF1pr4SesZsN0RVPB1kBSt3vVVIYb5YuGGkXWC3lDvRKrnyOQ HL4qfjZ6UVbcnAlWDe+9ZWgaZUV1exC8Ynf1LCSZQNCBF9eNWjkwoxIw6fI7tx6/i6yx NU8bWVoBiKkZsYjcH1eBdOA0KOlDcnQADnlqV5FbPCBifshkfFY/ldvuOaBAjWwRH269 C7wKx41gExtcWDk4X854hUTULc0hn9kH2XR3t98lzzGPAovD5qEELtA9cYy3ZmUkwQcw XMzg== X-Gm-Message-State: AOJu0YzkXJhgMEQKzk8cVvIrwX34PFZScmcOcWv3s2xRdKMCQ/ZKGI4X /Kbha5JqHWVT31rjcFESO5aaR9v4lpum4gICRzV7waXVoQZcXgjY61+Mb+e11xUgtSpRrmVEAop RbKGW X-Gm-Gg: ASbGncsnAGQ1cac7obSx2IFr97e9lkSL9VQy3ia4be6u1WHPcBIuR4BMjRTmxw3W+eG ZlW/QF4WNSx/g2a/wUCqSZRgK7iYBmcvSF8+Lq/7chxPmpHBZ4JH238550RV6yYqsZEGrdDijqz r5R6tdw0FCsjl5rEPwCiIyD+VlWeYaoa1g0eWqh45Nj1RuISOrh838N81q47tH5G+Oliv5mUrTl hNlWFegzrRws8Q/KJSSGxOgcYoXG8+LDU6OslWpHjigN9d0uXQkYalwArBP7RZv7uVAQT4ZlrfC ZL45+f9GLU2VGQNgatDLMVX4b3aU/XaevwR6ncBE/tdPDUjXQwmAH434mEWLrUYlb0d/Wvfxseg 14j2SExRqbQ2+VsO7QM35SJS+5b7lqSAQiXMp5OY/0YU+TXHHkxL0lvyd8Im5XiHwhvwegxot1s LtE3QgSMn4TQ== X-Google-Smtp-Source: AGHT+IG56sQfgqz33anShEeaMUmb3hh55vlGCIqobz69R8Xdox0GURjgL5UdJ029qX9g7AxqfaS+LQ== X-Received: by 2002:a17:903:2346:b0:240:2145:e526 with SMTP id d9443c01a7336-2402145e8d5mr540885ad.6.1753603639052; Sun, 27 Jul 2025 01:07:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 68/82] target/arm: Copy EXLOCKEn to EXLOCK on exception to the same EL Date: Sat, 26 Jul 2025 22:02:40 -1000 Message-ID: <20250727080254.83840-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753604364920116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 2514a03c0e..23e54684c4 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 02:14:15 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=1753604108; cv=none; d=zohomail.com; s=zohoarc; b=TXpjmigcPFWsDZLsUHd1TSnLGjKQ214Z8Nv/FTjRq+rgqv1ebL6U4hHRX72w3BAlpIqavMybX/2kFdciFlVxeyQXlYXb70kAT1kWimHELstaoGqym+CSriZvm7Ae9SgfFukIHnyEsi0AgZ9STSc3CA3Gt3AnxgnLWkZqe/ylfYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604108; 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=3aRYtrkrc/9kZo8KuhActa/u/OWLIUyr4LApQE/Ub6k=; b=UGNff2oCOFc8CGWcyio52N89YXhwRNFh9l3QVKV9rpQFlkfEE7nDfc4k18Hdg43BuB42V6fOGf0c7h/+IWxKdGZZd9jBpagv4psp/nFE4qmgw5ebBPYo8vkDTuVOonTPtqpu7H9mHrN1CmfR+QYttS74zEAxYRlVqOh5P20Qi7E= 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 1753604108334620.2873304892782; Sun, 27 Jul 2025 01:15:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRz-0005X2-Qk; Sun, 27 Jul 2025 04:09: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 1ufwPj-0003g0-6u for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:23 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPh-0004rn-EA for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:22 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-23602481460so35115405ad.0 for ; Sun, 27 Jul 2025 01:07:20 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603640; x=1754208440; 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=3aRYtrkrc/9kZo8KuhActa/u/OWLIUyr4LApQE/Ub6k=; b=tTSUMHAl/7n/nH2wIloQhShbcZqDasJIFXLLJdgUJib8Y+TSrSJGRbEYvw6iSc+xfF niTxMWBkoqCZqKl3MdOgO2BSJUGowBxqXF7ARGZ1NOzq27O1fR3d7h+27jSKBt8bvxux YYGsZJpiB4HSMVj1ktnILZrgY+j4JYM60pFNYXiZntmgUD97azgA0vO1a9ENnlbnbQw8 gOQE3OHHRmi/g+2Xbcqj7w9uoXMuKaAmDXfUZjr8pu6zQyPpQ2iuraLrt5iG3pi8yeSs 2tP8i/BOSWEeHvIxfDyly9HXnSy7SGmMhOifATPuhcplPtNsB8gCBNK13Iza40Q2VOWo faBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603640; x=1754208440; 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=3aRYtrkrc/9kZo8KuhActa/u/OWLIUyr4LApQE/Ub6k=; b=dZhWxQsQ7NhblL+Epft0kyWFyug5XtHUMs1vmiRvvB5tmwP6Rd23KYUGM+UmOLPa/X Z/jumzjBtkMaQqfsUROgvta3qM268PBu2ZD8MSgeHAd5QKPtZIHB3rJPohad5lGdhxaq daC1ed9CaOX86IHXCxq2qy5W9iVqgN9AziHbBMTGDYfY6lQ+SCaFWYnYadDUK0pq/iGu BD6VGsT/zMq3DD2O3BEfeZKjr/e+1s0sTOkfB2n4L+oew4PzIUQiW+I5WPCBaoYdkucX eOk3jApX1lLkDw6iPUObXSzoBGomSSq1fS/qR8Wgpof91ht7/I9M5ihXYFHz/nAQGuxz CJPA== X-Gm-Message-State: AOJu0YwWXX7QWGBTwwfkM5+qAkzcWdbl7iZ/1ZUiwt55UoJTT/71k14V Y8O3ovCPZoTz0dJYd0l+O4flkP/HJCZBQCoYRx2jvfluhkD2SJ3WfFtTcKJjSh03+Ue3ro52hS2 h/SRX X-Gm-Gg: ASbGncuLoODA3H7OQRrS7C6mDTO3WRfWR8QkhPudIkf+EmOVdRmYB3/0PWzocm1JtN/ Dk0gdJDzAKAawjjiadgkvV5vDGgK9c2VNyASHYuwupH40jdgU5I7YqBiTBD3l8U1BJbuJ+Dh9S6 2PGsLAEeV7+1VzX4bZnNuJTwWqmKr8B/DirlDKigK9HcuO2bSUOVOtZXhzMz2z6tS1HWVjfsbUZ /gp6gdoCIs+RefB1cT934UY/olU2GavUm+CO4ribMxTsv0cfa3NYbX35cS0nShp0Wm8reiRh/T5 /4r4AZ+eMnRqM7p23J3wmt/8XmtVFdptnH2c2QPIpqV/9ELSQ+VbCy5jCa1Gghl8T+M16vgFIhY +EBVdWEzECgLSzSq6Y/zP83NpZ/FO0rCiZ9Otyee9zsv2y+mppZWcTGyZyKgVHeaZLZZ0JlLTNj F1gffDYC5wbg== X-Google-Smtp-Source: AGHT+IEeP+A39mBZ6PlXL8UX44ZOiw0oYRQFS/jwuY/iWxLsPsXXx4nHwqubE7GS+C2auFS9DgJPlA== X-Received: by 2002:a17:902:f607:b0:240:9f9:46a0 with SMTP id d9443c01a7336-24009f948aamr17984795ad.38.1753603640071; Sun, 27 Jul 2025 01:07:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 69/82] target/arm: Implement EXLOCK check during exception return Date: Sat, 26 Jul 2025 22:02:41 -1000 Message-ID: <20250727080254.83840-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: 1753604108972116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603973; cv=none; d=zohomail.com; s=zohoarc; b=lxDQR1YwJrM7Q3n+loDNk7XB8JwCRsz562BmQv36mv9mGEz0LCADq6C06wuQV52rjfAlXR7KIjC2F4Y8ywzYq1EC2A3QrJ9jMSbV3mKk4Fq91Y3iRmFKxJKYGNLWHwYYshtqhKvbtemX5WinP4laDjXEi2uXQFrUHmJUOY+TTkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603973; 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=SDylAKOmltNGyLx2E37xE3a+pc0ueuM8z50fDJMoOME=; b=W1ZHRt6mrdJe1Lc3TvpK4bkZ+85W1gjBWplVraTze38nsfSShZ0FEzPJS62mQdG+iDJ5ndA6/ESK53nnq3hpkevB/maLsC1/plZD+BAQllOn3t1VOqEBbaxOFYz9RK7fJPgwAvr1lNnqFH5J8IN4jV0r7uPfRlXY4qc84qa1/RU= 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 175360397358253.50979316265182; Sun, 27 Jul 2025 01:12:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwSH-00067l-FL; Sun, 27 Jul 2025 04:10:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwPk-0003o6-KA for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:24 -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 1ufwPi-0004sJ-Qt for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:24 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-23c8f179e1bso39877395ad.1 for ; Sun, 27 Jul 2025 01:07:22 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603641; x=1754208441; 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=SDylAKOmltNGyLx2E37xE3a+pc0ueuM8z50fDJMoOME=; b=XM65+nOcE2uHXZ2YH/JN3giI5/9zZvvLPqigF0PO/ZBv39oVXVhfQ0TBrpqufUYHGb BgxRfuT1hySZmwoK/nMZe6sw1XHPYtWRn9wqaYKSlG/G6KBBXLSVOlNxt2ZamT56zUlZ Tw0Dzr+VLSYXs0jxNW5CW3rZkHcHXZdIj3/aeXgMsDuwVODZCrfXTCHweAKR97dU+/NW 6ilYMiRBl13JVKqEG+3L83S245RjMWUNsLP5KvfTVEBg2JNqLTZ3w1b73Qi/DUIy1opU Bu7ehQ2yyzVwJY43fEKfuc9ptpVtMFcT2BG64uMysIdt2oSEGj99vP64SM+tdNNTE6wl BdaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603641; x=1754208441; 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=SDylAKOmltNGyLx2E37xE3a+pc0ueuM8z50fDJMoOME=; b=SM2fuv3vQDSXgkJGsqmghRfS27PoeT1NPlb/HiUZBzQcc80SZNCJ1jXVc/l5ZS2EIY y8hOwvwTihIdedj3lBJP/izLpwNpeVW+3NOU9mkb58pVcG0wCgbZ4FZ/snIq37ClvNfz PwtHD6XJhbVp7A1YmwEdwsQhgSvyfTYvZVwC3mwyhLrQZAx9urmAKnAD+3GSV4Nyv2AS h5xqA8gPKDenoUstYqi8KNi4xMhXKowdQjpO0uWyHUSNYzCzB3wrXajCwHyTJfFp3ero T8WQFYbHpDzT2RLhlS658SLSRPMqP6sxqYm0jJFidEgXIuY/aVWcgMxCj2DfzP5Z8/BU zVIQ== X-Gm-Message-State: AOJu0YzNa5E8mLA2HZH38p4SqFZDVMvAEp4me7nKLF9dYxSfkHlpw2Eu VYWQCWE8306VTl0KCtuRTO4ZYq/+WDc1AEGp42gz6PHz8NeHMTEd4VYNFhJwqWIbRpbsh1pZxBD 1f2QQ X-Gm-Gg: ASbGnctrly6FjDI846/MDTCcBW0yTpGiDrdXca52hXCdryS1JLAVrTYzbSvTumBqtgB exLj/PgbMasHiUgpTIriDISrVp0vjcbTHJkrUKxGGkj74G2KRz0U02/Jxm4co6WLDTLdipRjchl j+3dFparA4qGYf1f9caC627Tz3Hcm5zvUMAoKJP9MT3GIXjdpkmJULJcfTK+TiuWuxcjRLMoUTb IYMQzEVt+C8fsCZfYaOSEEuP7YjJFwEBr/kfqnrmPs4a45t4w3cfLMijuIRVaRlzorOUbC7O3Pb EGVYXXIM8tzXLjtZ4n8eGt1q5mduBSE4sI+5usthj+Rp/9NqH0Vt2RHT9llfBzwwRUulcgaewh+ 8r4RDhCzUXsq/E9XFiwK4NglxjAAKimGdmQT0dGIVriYQWOCGbbmw0oZzjVohWnRvpUl8W/9lIJ r7sJ62bSwkng== X-Google-Smtp-Source: AGHT+IFR4QduveMs1gQmtG9cAKimd6lBjoMXSGruNmr8p5HBIBpWWCixESy6Hd0da+mAMQa3UGhSig== X-Received: by 2002:a17:902:c7cd:b0:23f:e869:9a25 with SMTP id d9443c01a7336-23fe8699c24mr27485075ad.44.1753603641234; Sun, 27 Jul 2025 01:07:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 70/82] target/arm: Enable FEAT_GCS with -cpu max Date: Sat, 26 Jul 2025 22:02:42 -1000 Message-ID: <20250727080254.83840-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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, 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: 1753603973993116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604537; cv=none; d=zohomail.com; s=zohoarc; b=YMYBfNd8pZ0WOtPDc1d4AvM6aMFX13BwxeRM5itWRLf/ccorTYs5T4Q7zwcbmG4YjvhIzgY9QrX3fDhX9RSBMZEqp0iAf3JEoiDaeAUo9TYzVnjEB2bSTvzjHaGzCbez1Cvsaq2PM8j9JUdKQkOTwApiLkR/jLa/ETlqSqdpfTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604537; 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=Ydcyb65K2tz+QaP0rQj5OctHcXPpiWXEP1hQZYLCpDo=; b=FnmxWTm8PDYpPl/zeUWYACy3f+PqaN69bcDBJW220iyEafgGwBS7ckC0iiJyT1/JJQFrCQIz4DJ+HiS8hKkqpsEnNgq1b1H8RBc74/oxo0SfHD0e+Ywo2sWlaBgbjfPP1wivio/Fh21tkHed4tAddR/ZOv1qkUZ75ngiYY8i8RQ= 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 1753604537099716.9995916273306; Sun, 27 Jul 2025 01:22:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwSO-0006on-1O; Sun, 27 Jul 2025 04:10: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 1ufwPm-00040u-J2 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:27 -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 1ufwPj-0004su-T7 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:26 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-234f17910d8so29669805ad.3 for ; Sun, 27 Jul 2025 01:07:23 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603642; x=1754208442; 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=Ydcyb65K2tz+QaP0rQj5OctHcXPpiWXEP1hQZYLCpDo=; b=vn5PFtM55QBczc0v4xXKu2BpdsrmpT3R0I07d/XUngZjthSyeLs4uTtTMHeYyzfI+P aGGRULBAXvlUBAOVHY5gau6frAFBttyEZI/ez+XvxzbndPjGju9R1/qvvuZqYJFLZieA FMh9MA4P3R6Np/6R60IYqlfWH0MWlJAME5kOsU9Vt5mPDUlyIr4jHHC4yKftB3Cy57XE 6sCNhoDqUyd7XVHWWJbg9PPLrayn35dSvaTKr5hAjQ3yUgThLqRD8vDJPSFJsbCTrkk4 EpGQqqJmR+Ekms6KWm4HrqX2lYSQWKtFZTExf9m9lxeh+1dP7pypO+E7EjNv9L0YWpPZ /x0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603642; x=1754208442; 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=Ydcyb65K2tz+QaP0rQj5OctHcXPpiWXEP1hQZYLCpDo=; b=es0zTc9lxgPWuXvQ7Y6yaZrsFlk0kYaoJXL1DV2D7HT4dv/T58QQVJpN2FiDPd4DKr AszZ9vKuBpkYtJDgmVcl6MyXlWzYQ1+IBE8olUaHBKP4avWllRm0KFmeyWJwpeUD+/fU SxMb8tY+uGOT0+PQZbmgDDViUr6Qa0HTKYaD2gTlKQv4jr+T3kAsu6fzEhcO6NeW4oVx EyudnzfNsV09p+UGT/8fOaV0HZ0dG7TTiqWMrXRSntZlOzz6Z9tEvbtJ76oB88BX+mbW VZu0LgGmj6Adh9Fsk7VhVqGFwnbcYauZ101AUYrbtqURJOJgtwNwgAyy1k1j9/WKczsj qX1A== X-Gm-Message-State: AOJu0YwcEbVQHw4hFE4SJVpsJOgFPsevEYaNcVBNIRdBOS4MBT1xp3n0 nffDkAlX4LlmCvoxJd5nTX3TFFz0bXD81x4EQQ98XDQPbMZ2e8SMwhQYPsR0neDm1E0uzQ6URzT JiGcA X-Gm-Gg: ASbGnctOVMGrCyDfL30JHBGYkb992qzxh55CzRdIBXCFkt8jvNuChF0/eW12WiOF8r9 gXMpqWv3hf7UQ6zA0SUTQzuESG3L425MnkqWCRtpwb8OPyPdmTqPDPXMGGIrJB/QEjL4RrOxtUS 5pGrsDd8fUr5PLJIhD8wfcJr8B0tT5lvX3ctqG9zq6abkHCzLNLR1i6KUgSvXtx5ermqj/DwlTN JUIGNniV5TCna5Dd/L/rexbJp5SlQJugQL+EnrwBr4zs3DURxU0hWhle0HmdFmn2E6JM2DCqL39 hgdmKy57KHS4ytyLQO7GBTV8/lYRoyntRoATN6Qt73i+4Ii6ukXV0+UVkKrsmCcjQXHbU0cCzVU DaNXBGSd/MU8Xn3+atPKwsBycLAibuTOdrgYsYXpkf66juOhf3M0SYfMrI4DwHBifZpB8n7dzUr 0mXP7bbwd3KfcjVyMbMLUq X-Google-Smtp-Source: AGHT+IHs5QMggS6SeDC+mWT8vPr6oPS5XWJaC2nalXW2MmpZY3Up5CyXrZMRr6ubzjRVReEoUoPHwg== X-Received: by 2002:a17:903:2346:b0:240:2145:e527 with SMTP id d9443c01a7336-2402145e8f6mr551625ad.25.1753603642359; Sun, 27 Jul 2025 01:07:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 71/82] linux-user/aarch64: Implement prctls for GCS Date: Sat, 26 Jul 2025 22:02:43 -1000 Message-ID: <20250727080254.83840-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604538375116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604207; cv=none; d=zohomail.com; s=zohoarc; b=SJzpYz4IHarjVagBli/LejtoqnlYrE1aiqk7Q3kxbjSDv9ugT2vDaP4H9faLboCnkge7xDygCD7ejY2/XMp1LzZE0na5J7caUemKbkys+tFlNR1vW+qTOKcDbzo6ZhLHLQuF8bM1q/eJ4wf4Q6dxoEHedX3aojYSI3VfP5LEnf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604207; 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=5D3UspdEe2Gt+MgZasHPlZJNZ0zbIXOmWsb4P6ImjX8=; b=JIVh0q97XXbJfnnJXpwH5eWUutum2u488BUvj+1ecKNz4LhY83Kqdphek47UDzAEPX6aUsoD1lj/gPvj6fvl5zUkCG8AcrvIYIJaS+jxBpkmnVncTff6X1aGttcdqJTy7YwCGryR8hwPPpVUc3XRkterIAvU43EhB+WQRMpnB1w= 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 1753604207613779.6729304094001; Sun, 27 Jul 2025 01:16:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwST-0007KM-Io; Sun, 27 Jul 2025 04:10: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 1ufwPo-0004Cm-6A for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:28 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPl-0004tL-2p for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:27 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2401248e4aaso1304005ad.0 for ; Sun, 27 Jul 2025 01:07:24 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603644; x=1754208444; 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=5D3UspdEe2Gt+MgZasHPlZJNZ0zbIXOmWsb4P6ImjX8=; b=K/Nj4KIwLSoysZurfKhYhSa49tVgYRYlPYPhzzIeMvnvBBRyvnprB0pItd/Lhxr5gb yg0aRKbKmNhGqU5p5L2CWeB49FEJl6gBbtFAM9yXgjZVLvzii7prZhmpepVHQtmW1UuU jzgCTDSiAiLyulH0tiwMjIiOPGAfsulwezYUNpp+xhX8ACsPF0f0JN8VDr2kqkjWt+y3 zJt1jo+TuUBhqarWXOCjtMBMVbq4Rd2iKFFibh9EwRYHgIpSsoxHf7MMbiWrJhx7fFXD yjw1JO804pyu+h4OqNeyCGdcl9Lm0B2d1h5opzTeQq1UxujsIeULmyMHbkT/gFJ59Ld6 LPQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603644; x=1754208444; 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=5D3UspdEe2Gt+MgZasHPlZJNZ0zbIXOmWsb4P6ImjX8=; b=scjZwaQkM/BWWb1Bhro5l21FVY6Bx+z5KxB1frPVMTQVKAcefMlReismojK2avRx0i TWfHXiI8eUsE3aOEWEkUqwH5L9aIVx6iwAcX/QePD9poSrEpCcTQbas6HkpkZCuMwmkL nHFlZB3/kQFETOsbCTV1N2gsmGgjOYe54DCk2igoUeW+PmcBKK9aGlkVH8rSpGyNSsVq HTo0CC76YB65VIKRJvk98sBTlTpFNMPVWJchu5FpzEK+TuqZzPpu27dv5CCecdZRJCum XiJGW+ixSfJKpUBCZCynVUx3w4t6ZNTsktQM5ImqhEmqisZ90v0xOSz6h77DxPIoyFup NBNw== X-Gm-Message-State: AOJu0Yz9/x7au/RE7O1/2XtFWRAOvPCmBNI9ImafLlMBbxeQ7u5UjMso gBWJp36tksZKg+7KRu/0/N1thNA/gmc0G4VfZlmqfN9VqXtwqqlGBKBYpEyMTMaF+ozNBwnmzRm tFqrU X-Gm-Gg: ASbGncsrLMGg1w1VN5BdG7I7TJTLDz0y/VPLKCZc4baeZt1+S8H7F4KQgYF36zd0u9C kw9QV0k+qusuP5kqpiBb0pLfQxH6uyq4fg5s3QwLFrN9NqQPZhjCuZo76ZmF9/5F9j+YqzgrBGw D7+4UzxQdGvBHBpmhkf67w9z6cAqkRne4lC/Hcr+bmG4haibnbpf86W8DXhBkXyLU+nKB4KYnmG S38EPOEZH27fmbi4gYcAkVFnYnQNXjmuaexJSiTrqdw/AN37vrsASJosphdH111a0HWZMMVPGpT pG+m1BRkumWwMk/tMhD3c3GcclIavxBw3xpMn6DInee5TakuQFU4l5+zspo+RdInLdMHZUX6wjK BmF8pRMgb5Gp9ZaPWAWq7tJnfUglCCCEWm+NwWrxnk0IPBMdDYqjjZJB8NtZgcCGn4C4aQTbaoj lHRGQVYV+wQrl8yUoD4Rcd X-Google-Smtp-Source: AGHT+IGyTDU/O5hjh3VufwX2Pxw3M9WK5I9tTZbR5Wv9jWSYX+7gy2Xl8Rqzgu3eutA5ttt1urcAiw== X-Received: by 2002:a17:903:2b10:b0:234:f1ac:c036 with SMTP id d9443c01a7336-23fb31c4de1mr129393425ad.50.1753603643705; Sun, 27 Jul 2025 01:07:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 72/82] linux-user/aarch64: Allocate new gcs stack on clone Date: Sat, 26 Jul 2025 22:02:44 -1000 Message-ID: <20250727080254.83840-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: 1753604207931116600 Content-Type: text/plain; charset="utf-8" Allocate the new stack early, so that error reporting need not clean up other objects. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604228; cv=none; d=zohomail.com; s=zohoarc; b=JDxfhQ7ZsLqZ47DQ3Lc5uUIv+k8D1vHMvNzTB/PpOunKzbfynpR+ty9aV7uissN0pv7n4ztV5KavfTZoDx5Jxm7zsyk9zuoOhv1HdKmwTSWs5VOshQs9qt+e0aYkdlzkDFRPPEETqtQKeZ/MOaW0uMKofJyahXHA0GJSNvWlxgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604228; 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=Otu/B52oeMdohHSlUgQzyMXI9VRbf/jGWvdVoLWz+3s=; b=G1IFFBQbs6qB0bdIP+s2jynLmFTxmXbkkIIaVAj2wRCnc1761wjkygbpyfMp/2+j7B7sM2o++W+hPM0hF72Xnd6SNRjMrQrC7SEFn8FnL8gXjvgJVqoBtsPTwbwbTkirPAF5zXH2DtDHgOscen021f59xtFtais4/Zff7nSRqRM= 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 1753604228269419.7577942662614; Sun, 27 Jul 2025 01:17:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRH-0000i6-OT; Sun, 27 Jul 2025 04:09: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 1ufwPo-0004Cz-6s for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:28 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPm-0004tn-77 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:27 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-23fd3fe0d81so8023045ad.3 for ; Sun, 27 Jul 2025 01:07:25 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603645; x=1754208445; 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=Otu/B52oeMdohHSlUgQzyMXI9VRbf/jGWvdVoLWz+3s=; b=wa0VKLp18YH5V1h7pRg/XPdQVct045zRW1fvVkq3VPixbm33hMjCtpz6i78wB/z8oK q/Qib7vSaeeo0Kpoz94GA+0s4+7/nM3UqvJ6b335vz36o/GnTuSImya3ICknNV27RIXh /BS6KEbYJ6qXSs5vAg6NTdfGGxwTyrQEcke8gJFTR9YhEKMQlv2mtVPqoWAp7rnzM0Ve 6bOcvWcWkIpVFYUUQmVQ8G7DBt93hKTGDDbKbutPHcXnU5dbJ7CbBy0049zJkf7Nh3/b zh7ykH4gwWWvYWRGsAIZ4fhBryx2FU9sNgFYjGiw1RgqYiq/KFL5YZDJaJc4outWL9fq +r/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603645; x=1754208445; 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=Otu/B52oeMdohHSlUgQzyMXI9VRbf/jGWvdVoLWz+3s=; b=p2FhXFlRY5uD0nmXx4InnQD6pke8VOeWtNy2KJfGLTX3j7PeK9k6Lg3QFKZOiuV8LW x0r9Fjbm4X9CL3kBmDbpTi5jbdD/0JfMI7HJ4qBUJ/rYA3MwbjPdxQXvo0b3C2sVaM7r blqjMqAqUFnnwxql3cQJKIkmDLrUQTWrzZNqFwAaZkPULRcQP1yzeIakUlyhPDt4PbTO qMvPshzQwsHp5q/XcLJyYfLA8G3dwJaQVCWO6aTCcbBWnoZGa1lnfr/jQCtP3VAM8qnQ vQAVURwqi9kYzym+BtEIfzl6ydTns9DAFRq34AWkesrELC2CgoD6slMDyGwpmGX/Lxql /Wpw== X-Gm-Message-State: AOJu0Yw8Nwz9Lsmp/nIUZMAl7q3WF2x5vjH3CEITsd8qcj9g/0XNcPWT hyYT39P9IithMoIjM9GlxtX2C1nMxrLNWTE6CykO0OW72y0iWwlVnAQ5ty87pHULiJthY8JXqCn gOoOt X-Gm-Gg: ASbGncs5xxF604dC5LHi3JqzQEN26SGG5rl+iCyvOicT8P3UEpNZaVSlD7dj/fgdNcW 4jl8HWAeBfo61uRrkPAVxmmfKAWus1oJYCLTcK9YD3SW8Xlu5pEetc9PQMjoPL3bRpfYyQ9nEdv ZS/eEaAzDEu5xuDvKLm1OWjBXLlzIIk3UB3fmVqvby63O3rBkIFwg9gUWbasOzuiTONtstHaA3a zLWXFGhR09zawRrHUvs/pG7hNW1pxNlC4zzJpHpkYFjdd1+5Yrr+uQ0kaz01WiVza69PPBjo4K1 hxALUix7bzyi807yj/TaewIMbKKlKH7K0BOfWcdoylV0NA+kfYV1HoBrF9KWBQdzgj+Uy+pGzbT UZvBF7CyFetUecEZQsk22aEsc2GBbqP75aVyjpqNuelnZ9qGl51QPFxkB/IwzYmuafwUrffec/q SIu7/b2Z3FDw== X-Google-Smtp-Source: AGHT+IF/2CuoTlt3zc+4OmMG7XjZorqIJbfrqSCR/o4C4/g4W5AvTbwgr/zO7OK4T3Sk22I00tzSXw== X-Received: by 2002:a17:903:230c:b0:240:96a:b81d with SMTP id d9443c01a7336-240096abbc8mr17680565ad.5.1753603644780; Sun, 27 Jul 2025 01:07:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 73/82] linux-user/aarch64: Release gcs stack on thread exit Date: Sat, 26 Jul 2025 22:02:45 -1000 Message-ID: <20250727080254.83840-74-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: 1753604232144116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604389; cv=none; d=zohomail.com; s=zohoarc; b=PZH6PtTA4aMz6onNcNM4x1bXkX6exar7/wRK0Nu0pXo7+jCx2o89molR3BrFZBArztYSZ10XuPTZ4Hd+ImAzWLn8MJluEKv7cQxG2NZOFOyXpD0Ekd3A+FYLtwbaWVYkfJsnvMV3aJWMIyBpLLjdQ5VLhsgmOuDtVemYx9OOEa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604389; 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=i1XaTPiEo+FTtf/Cktl+jdbCdlFK1FMOPPILBOSb6P0=; b=Jswi3p3xCGUIVYVMMr8hbDey9y8vIP0QomQFqmlIvblP/4ChZDXn0PQqGQnyLXNxXyHcgHo/ExAAJOUw3RXzxMVpYi1oRRH73SiZaXCCStPun7rP+z8yAg6JQatRcC69hDKGqijtggf7hktIKBjvJcrt6a5w7EN1MXVBPQz7Hkg= 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 1753604389321232.80916734574305; Sun, 27 Jul 2025 01:19:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwSm-0007zW-50; Sun, 27 Jul 2025 04:10: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 1ufwPq-0004R5-GG for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:33 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPn-0004uH-9d for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:30 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-236470b2dceso29632255ad.0 for ; Sun, 27 Jul 2025 01:07:26 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603646; x=1754208446; 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=i1XaTPiEo+FTtf/Cktl+jdbCdlFK1FMOPPILBOSb6P0=; b=ORh6DisLjiAx2zW6SdEJExcqZ5Lh4TSj/n+atRZEy9gPF1BTi8LUYKVUZBUZl0GmVA kDnswrvX/65TCyT5k3y9m9piDR6ARWRzn69V6MIl5oqbsSvQ9qetrQMQDZmvuRbR7HY1 iODyepVcgBUUgJckCsAoSuOE0LW1n6Q4Jj2edohhiJUNeY23/cN6zBLhoO6by4r0o0bm dqy4kL+zExw9OHt9X1Lay7PguzG9/wcKraDOm8FMn9+fZnkAfH6MGUSehcKKhEcDqh1c O5P8gGhypMtOb6McQQOtDbf1Vi9MSZzn9pP825i2XH49VyoIJdQ3JQSlFuLooF6xNUZI 6eGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603646; x=1754208446; 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=i1XaTPiEo+FTtf/Cktl+jdbCdlFK1FMOPPILBOSb6P0=; b=p8nQYsd1uVcWAvgp9lKiSQY/OdL7sivKBOBSp22xRj9HYGvNJIpYfdXYDATONbK4jd xqOuKrsW6yoXorbWGtpHd+S3qV6mRIenKFOfcDhBt5DXEakGrvwqc0h7QNdo0UjXkyDm S1/lonnsTdDNbLghj7qiD9f0yj9PtxpLBPem7ajjkWGibzMOpHn6Z/jbtifhTCHR5E2l ET0KYOV2UqWpODRxrTa+nZxU4vQrVEDMhz3aPe2m8sEoP/tUnk8g8DVk+1e3Fzmc0v33 iNqa0QYFkCunKUd67Zm/qdM5kOGWbPwxbenox0LVJKO3ecjLao+MrZudGaGSGJF8x1Iq HT8g== X-Gm-Message-State: AOJu0Yx7mh5V+DPGkrdYdWIPicdCOVOjrAzOiCCiBG1xdpGN95tjLZw6 dgW84SDn9+Uco56nWH/4aF2pNPQU5ZfSSuF9nm2yIop7TcTe5KygEM7QQ2gdnDvuQxcnM6qZg2F uwFwU X-Gm-Gg: ASbGncsaOIPaw7HGuxxsUwINYKZjad/mWQEb5cUdrVeTaGZ9K4bRbIGfyoi6B70HNQT E2BKSdUjb4KODkqDZd17L3X9ORbcA1aqaAJtNC4bq81x41G/StQyRLdizbjqH4n90/jAcf9hDL2 1QzmSsRXjuDP7JihoN08GfBJKtDTfOYXFVvkq4KP4h3JaVvY23LlXftUmI+wASEAgAtYtq1l59g xLZTP1UuBmUyHiUbtWmfn2+6YHZuMSuxv2HECkZQC26W4doYoW6NAYsk/6B9FiFf04Em8RRZN7z ISumeORCgF6OUC79y8likNSzN423lgPR35pY/qVswHZQx0R/EDy22RojPdUAoYpCKYn4TGBx6K6 MCYzHhU1eO1Q3KEchI7gXuvwl6DzY133ZsisUjxm/QiGOJaqvdsHonApZklyiF1LfrRRqFb/Naj GGC7sHGvyI7g== X-Google-Smtp-Source: AGHT+IEkvi39PvKm1sNYDnna/cpO78Zsm8uiyQFmothKzox3JMiUh91wKtiGEbNTGZJZnTvaDAmwHA== X-Received: by 2002:a17:902:fc84:b0:23f:e51b:2189 with SMTP id d9443c01a7336-23fe51b27dcmr49777135ad.17.1753603645855; Sun, 27 Jul 2025 01:07:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 74/82] linux-user/aarch64: Implement map_shadow_stack syscall Date: Sat, 26 Jul 2025 22:02:46 -1000 Message-ID: <20250727080254.83840-75-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1753604391099116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604102; cv=none; d=zohomail.com; s=zohoarc; b=BuaGoperBV3x23d6q190vDZvXN3bd3VlWTPJvbfvcs+tdo0M9d0n0Df3h7fnULmkWNKmJsUPyIk6z7TtyBam8mLEntQtJO0IwnQn7H5j8s+OeqzyV9KLO//24u5VzHkZ52P6Zdwa2Gw7ym1/WFoYv96H6NW57AhdnSs3OEaovAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604102; 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=WR7r+Hh17fQ0ME4q6Jovo/isLIn3L83iyAvcPtqKwiQ=; b=FHdcVOffO/NELH1z+UF47vz3ePmSNjZAQeTtpEIf/DJN0xCX4PPDnyrI45qb5rvmLTdQxv2t97ezMGg37OsNx5c17Tq0W1qo14fa968c8edkGUNEfRtArceF62m+bT1ZfmZ6jT4bsF/lT+2UEBZsE/6oiOC2IBKOaC9DLUduq6c= 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 1753604102980629.2601344063615; Sun, 27 Jul 2025 01:15:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRs-0005IL-Te; Sun, 27 Jul 2025 04:09:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwPq-0004SN-KS for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:33 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPo-0004ue-Fx for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:30 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-23c8f179e1bso39877755ad.1 for ; Sun, 27 Jul 2025 01:07:27 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603647; x=1754208447; 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=WR7r+Hh17fQ0ME4q6Jovo/isLIn3L83iyAvcPtqKwiQ=; b=UTCbTJMOr6KISlFIU4i4RWufSMuLgT7hR7VyotV0lSV1ygvAokyAWKOv678JdUfpPl 5qU/tuXGjIfyXkqwQmje7gyf3DhAo/ylwKipf+zTdRv78ASMZmvASHO7uVppVlmBd/rQ z1bNPvy50n5rdA9x87taXmkpWjkM7pgcu/kDrRVM7B3oz0ihzrhNAFk/jL8nw61vnAxi ksFaE/65wr9iYFHFEgtRP2fDHPhQbc7OdetIuhQlhXgCVF/KGDv0TB1vS0MH1vs/9jPh kGSQdGsB8Wfb9Wj+Kgt9NVA+8Ec0DbJ5p7+DSWcRFD2mdL1vgBYwFVmwIjhYPglcEIFm VfSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603647; x=1754208447; 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=WR7r+Hh17fQ0ME4q6Jovo/isLIn3L83iyAvcPtqKwiQ=; b=dslLL2I/w1iULjeOIZNW9JhyjGq3Ex+924i9wYTxVBpK/WWegDG+PJWlDI46S2Y075 xxZNiHfQce5q9ZlZa63BLRMZ1uc8mbSGqW833D4Qh7Jcpgau9OHqZQ28ytn5IwQZQPbq qX/eZ3xE4mz1so6+xXOf8717jI8SAMaP2JkE7CXBFKAw7uR+IFz5fMt4xcbAfDoArb6d MSHH5kmzDH3mRZd2tlfvasnwWtnjbQbOqn9CoMUWGwQwgFSc/XU2szSmC46t8OqNbFqP zmWRjBtSLGMpL+eEOc8BwEcTHcFz7PU335bE35wTybAjMrecIDvsb1+ZMl/vN7iEhkC4 riPw== X-Gm-Message-State: AOJu0YyKA3NabTqB0Run2iKuKOQNoWUSWkyzi35e9Lz3Ew4V2sKLIw3q Ff+TC+TFzxqWNdgXCsCHbiZsOEyP2RliMOSKCTpRfPYaddBOPb3WTMk6ve2k2NKEduDIiepm+VV V9z9M X-Gm-Gg: ASbGncskcj4jsoB7B7UsC2pruYgP0o+jdNxJ8dEVk6v+2cBROf5/6CSzSXkvr9krke7 BhAxXdaTt5HzttTAshTTw1+ZD2am41DMIOF3moBCzyLTSygpRGVpojifDc87zhIADiG32/2+9js MoBUwxaZqrtIBVDK3NuE+cjW9oM1cXoNFF1FCZK2f0QssmySDTfA6O1mwdtFLLIIF25q/7J8UwY Wae69ZRSU9/+JkoWVIYIbjyke7Ljk9ENjPJzoA3u2ahaYhK9DhYOujyiNba+PpX6GMInlETqp2G hW0xFT5TRMDlWCiJSyq3i/vfAhXxd7xzjnW67FpCWyTqIX8CwOWy8vZJA0YY2bIfCbr0HTFDw8M I7LrBBQSlDMRkLDlfVoUZPTi5wz4FDfG1kAhS8y/a5c2eomi/qLblA67e8G6AQ5Pt1ZMqztdVsw ZJDgIznidt9w== X-Google-Smtp-Source: AGHT+IH72wYXaufke0LU8TNswAbPJxGaBVoBKpbQ5s40qTUYYqEXcaFdM9cXKUSB3NrSFVmh/0HLkQ== X-Received: by 2002:a17:903:f87:b0:237:e818:30f2 with SMTP id d9443c01a7336-23fb31e4605mr129353225ad.50.1753603646977; Sun, 27 Jul 2025 01:07:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 75/82] target/arm: Enable GCSPR_EL0 for read in user-mode Date: Sat, 26 Jul 2025 22:02:47 -1000 Message-ID: <20250727080254.83840-76-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: 1753604104926116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604030; cv=none; d=zohomail.com; s=zohoarc; b=I/wSd6xErPSQYnkWugOXkCfwK3sVzPIe6LlLrWlQ+J+KZrv2QO8K9qCZ/3oh8twzxi5tT+rrR+mSqEtBNkAc3LumDsIS+qyLK2sSJJKhz+JndLhdNKRKiLtJmdrBMCysuk50JfTX6Uk6QyX8aUBX5I3AMJixd0IQY0xLZ0q1v+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604030; 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=ttkkqJwyeBJ9IX9rZE+f+UWiZ+lSEPmZ2iQQAJpTW94=; b=EXWDujxlqSk+wR+pqJ3s/9jq5VoEaLVZ/bNmdJl6ld3GCbg5l0CqWtBAoGtfR46aq8ls5gFuQDqdUmkKo6+9VxBvZc37jO5V4BNCcfJPFC1ESZd/+tiG0JJpHG3SESZHLKoBpfKjo67cgFfXSihnNbTkrjj7eQY/zIAA12nHYXQ= 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 1753604030118676.7802455189752; Sun, 27 Jul 2025 01: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 1ufwSP-0006us-WB; Sun, 27 Jul 2025 04:10: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 1ufwPs-0004Zr-Nl for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:35 -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 1ufwPp-0004v7-La for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:31 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-23aeac7d77aso31849945ad.3 for ; Sun, 27 Jul 2025 01:07:29 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603648; x=1754208448; 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=ttkkqJwyeBJ9IX9rZE+f+UWiZ+lSEPmZ2iQQAJpTW94=; b=D6TQ9pkblBJm2KKWsiKyEEB3GjafG6+6t1zDw3XtRqUpiGBJtYnRsgepGY2RMbkut+ RPtA08HrHnl2Vanxn5LSq0Jrb1nCBYZHFYvjYujkuqm6he+7yyPnP9YubB/804u+Qgsd 1kWZRIsLdh0fixhKryTIGL6fsQ/TryXl+++zYYOBUnxvSxykDoOc6vfpNyFVPx2Hv8Xx jOCh/2mSuhjMaqvIBQSNrvhUvTVFBEFpVLUSPcUfg8HWa2kwddC72ve0BOTCohu0HoWE QYKO5O5T4bn6DyP7b7WECvOXF1Knaz7gOMBbk6QYuxX1+6X+ze2bjwcuB4wuNF4YMfRU Y/vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603648; x=1754208448; 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=ttkkqJwyeBJ9IX9rZE+f+UWiZ+lSEPmZ2iQQAJpTW94=; b=K92WYCwcDZl1EaP6QKYM/5gc4kmAHq4uLJiWJXh/zgje/iYBG5LLY1fJhNpJrS9QIA yNrYL7yiYqjygTu3bepFrBxMpfWXQZUI2kzfVN5iaGp5fP7xjFkKcPqMklbGJK6Kxg0b AwWD5pfYGcpJeUt60eEvZ1thY1yKd4LHeuJhCKWKPrzOHSO+FtbJBcb4BRlE416Oa1Ht Znb5k3iBRNpg6AvyZuJ2B9aSO5pPYiALzjJd7zZFPruvxxYyk3h60mA2L9Py5ZOVR1wr +K0AYNT4whyG7CECX7WxL2Wr5O6KimWBTr4auRsMCI3daRgyu+ZrBxKdagDdsg8NE+Qe QQ2Q== X-Gm-Message-State: AOJu0YxbZpln5iEXLAa6eOlpaiUc4AJE8tVmhKeSSlQed5H3ZMdrH0gA TKk9MV0CPzsA/y6BZcRVjlq5rPNdKH4QVLrD5/UY8rVNViwugXy25uAONXs2lgQTY/TPuEK9uUr 3/yS2 X-Gm-Gg: ASbGncvPoJFDwigN2ZlcC0C8oZTLqLNdUD3WJjxhDXwxSTDOcdyBK/x9IJ1QgwzN5c4 sa+a3MUlfYEZWeA6bLImAFhlmflcPjYiy7Z70sLmWQkXCozThZ6nP2DCloJNHxQ0j89DZ0evLCz VKVyEHb0KYoTjwbU0PbugbWHICwHVfNuNme/Qyp3on4zd9sptmFEu6HaUopBnjXHgj1tKCHp3xb KLWSJAJ+3dDbQvOqLkWcMRjN8OtFj/aAVVZkC6A9/OF49KVDfnsPZ4d6pQv+/KzDEfj9Fgy8J38 fRVpgxS2Lhg+0pS+UxeG8LK0DHFmmuuj+OnJeox8uvICuVPikGt8d93iJwvGnDlLW9pCxq2ifem 5yrYjiuXw1vtbO5XBxiR+LS6TIgw51191JaFjBeYnO7BROX+M5ldLU+wKVLBShOn4NgOxObZJEn 5XuHEgpuuzVg== X-Google-Smtp-Source: AGHT+IHY+Ei+C0Le24QEZiwIk+aLUKXjm5k1X3rMgGPUrNCzC/ftqq/o7bTOisG8Z+n8sTet5krJLw== X-Received: by 2002:a17:903:22cf:b0:23f:f707:f97e with SMTP id d9443c01a7336-23ff707feaemr37067355ad.17.1753603648050; Sun, 27 Jul 2025 01:07:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 76/82] linux-user/aarch64: Inject SIGSEGV for GCS faults Date: Sat, 26 Jul 2025 22:02:48 -1000 Message-ID: <20250727080254.83840-77-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604032538116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/aarch64/target_signal.h | 1 + linux-user/aarch64/cpu_loop.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target= _signal.h index 6f66a50bfd..e509ac1032 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -7,6 +7,7 @@ =20 #define TARGET_SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */ #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ +#define TARGET_SEGV_CPERR 10 /* Control protection fault */ =20 #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 7e9788abfb..00ff51c883 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -89,6 +89,11 @@ static void signal_for_exception(CPUARMState *env, vaddr= addr) si_code =3D TARGET_ILL_ILLOPN; break; =20 + case EC_GCS: + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_CPERR; + break; + case EC_MOP: /* * FIXME: The kernel fixes up wrong-option exceptions. --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604030; cv=none; d=zohomail.com; s=zohoarc; b=IFiTyDV7TG6XDrcNYfeiWuFfEat6VlOB2+Z+SAi4RtRqeY+AenEBHLlZ5TlPcV0QDUnxQZ+3GhX5DEt95okwN/WcHSdzVtwZjJShUYO/4MxFgpctwH2vojpW1vtRstsBvFxLsANAg5phoj4Zg61z5b66Pns+FF5mDiDZ9N8nIks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604030; 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=DBUjlCO9H4FPTqA2fyTKtcpdcDG9njKI6sQ/H70sjVQ=; b=QTN8cCeNvMe9ui3+8tGTl3Apf/cwpjw+D4N562dGU/2Pofnmj4a+0FylWHe1TWeDy4FrhDfonv1nuFWi8rRrlDTqGyEY+YlBxXk7n4vUHap/Nq/E9Z7IKYIhZFCjMb7jOFU4NlgjzrllHEGS8daulZyenZoU1aw7tXnoAN8y17E= 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 1753604030138228.6709438185934; Sun, 27 Jul 2025 01: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 1ufwSx-0000Ag-S2; Sun, 27 Jul 2025 04:10: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 1ufwPw-0004ka-3H for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:41 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPs-0004va-Gl for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:35 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-235e1d710d8so45908175ad.1 for ; Sun, 27 Jul 2025 01:07:30 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603649; x=1754208449; 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=DBUjlCO9H4FPTqA2fyTKtcpdcDG9njKI6sQ/H70sjVQ=; b=DzzWVK4KmRtlr7y2lRST69L4MHqI+FlYqlmN+kBA98rH8Q/yU2or7sP/b6jmZKNej/ XkutOdGVJKBbCNpMk5j+faNp5YuRg5cNXc5eKNDU0scB1tubnfCBvub+6dSEfimc6KNu vJvHFsJ8rJmNyyLjpBOhveJyMXcv47Y/q/2EQdwAWSrfQB4Gjzt/5uxwcXWVQGPq+9wY Sg7wuGoasq34Ol+mClbx62USkL+EiU2/lfRb0+BReiMDn4vj67UjD14TUc7VX3+pGTHu DcuKjDe9s/d2tWTopBBU3x8vXH0SDQ9lq5+aazXbqJS4WPrY9TtzQE+mchK7faqIoe5S IBKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603649; x=1754208449; 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=DBUjlCO9H4FPTqA2fyTKtcpdcDG9njKI6sQ/H70sjVQ=; b=nbfASIOZp58cyjl/5hK1tFgZ6V2IiLDHcMkCBStoXIt7nS+m8IfipC5jxRZG8mGYmU EtMqchFgLAQAaMAiGqdLrU8FXdMDiYvKqKMRrnyXazPsKTv37gRkx2gblw3pddGuL1Pi WhFdip2315m61nLQF240Qf1hM4GbzXZZ8EUZSiFIc6ID0qCkeqZNFUGsF+yvc72ANJHa 07AwwmgyjQVR16r9wGo++avOpbGlS9NUNcAKy8gcewMJMvVzezGR6X/SAwNpAfB10t5y VmP4a3V8QJFVtMeG8MU8dtAygbr7mwpGerSYnzTs+yTUrR8m9NIms9r3PuQ9lezi2XUW uBPw== X-Gm-Message-State: AOJu0YwbgKQM9/74GTbMxbTc3XtU7Fq22Cl1ZkxLFg2AkeZCSC0t/f+s 6xmdYPUhq7eYWrmVX2LZTJuA2d38Hy1asbF8RcatAHhVPn2kygN+hfI1moaGPv/N324VWQB4huM aB/8s X-Gm-Gg: ASbGncu1w9zICW+oaJENRCdX6yZSVOQ+hCayVou9EkGdXUgS5YDPU8fDC8sOQU+/Iw5 4i3I6FRxpVEBsLcqee6Xt4yEuMMHYLkBTibV5GgIhHuNUWIm38dWHPWVyAuquVUANC+fJx1EqUg VZDbAR2z2+gWRPzoYTZtHoMiSRnQ65+7vIyN2luAy7IXqn4e5MV5gMM3US2THjyDg4yJp77c5eL icqp2fCI4aTYaVGXH9aMFn3dTYSJ36fs3s2KSGY6LUesvt2aJOknRP9/gT6ACWrz7aJkVxFbAPL Nm+aW8eBpdzAg+OldJZQoJkiXAZeSpzsHwkHaO6OMRqMmWK9E1x6LmCA1lOCpVWyAC70AOZOS9v QJ0OYgolsObllkjXwUNjX/VAbuC1iQBdARyvldfayrzL7PsunFBzTbm4EoPoVLL7Z1zZf4DLykk 8iDu9IYmEbkI0E7f8IBcgL X-Google-Smtp-Source: AGHT+IHCT/knaTbD7w1ht2i4slWOAIc84kwTvU2ekNP3KDmpxHWeNbHZO8g2X/k8Lf3PBHm8GvaRtw== X-Received: by 2002:a17:902:dac5:b0:240:aba:fe3b with SMTP id d9443c01a7336-2400abb2552mr11834875ad.16.1753603649119; Sun, 27 Jul 2025 01:07:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 77/82] linux-user/aarch64: Generate GCS signal records Date: Sat, 26 Jul 2025 22:02:49 -1000 Message-ID: <20250727080254.83840-78-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: 1753604030565116600 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/aarch64/signal.c | 129 ++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 6 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index ef97be3ac7..a1957a330c 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -22,6 +22,7 @@ #include "signal-common.h" #include "linux-user/trace.h" #include "target/arm/cpu-features.h" +#include "gcs-internal.h" =20 struct target_sigcontext { uint64_t fault_address; @@ -152,6 +153,16 @@ struct target_zt_context { QEMU_BUILD_BUG_ON(TARGET_ZT_SIG_REG_BYTES !=3D \ sizeof_field(CPUARMState, za_state.zt0)); =20 +#define TARGET_GCS_MAGIC 0x47435300 +#define GCS_SIGNAL_CAP(X) ((X) & TARGET_PAGE_MASK) + +struct target_gcs_context { + struct target_aarch64_ctx head; + uint64_t gcspr; + uint64_t features_enabled; + uint64_t reserved; +}; + struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; @@ -322,6 +333,35 @@ static void target_setup_zt_record(struct target_zt_co= ntext *zt, } } =20 +static bool target_setup_gcs_record(struct target_gcs_context *ctx, + CPUARMState *env, uint64_t return_addr) +{ + uint64_t mode =3D gcs_get_el0_mode(env); + uint64_t gcspr =3D env->cp15.gcspr_el[0]; + + if (mode & PR_SHADOW_STACK_ENABLE) { + /* Push a cap for the signal frame. */ + gcspr -=3D 8; + if (put_user_u64(GCS_SIGNAL_CAP(gcspr), gcspr)) { + return false; + } + + /* Push a gcs entry for the trampoline. */ + if (put_user_u64(return_addr, gcspr - 8)) { + return false; + } + env->cp15.gcspr_el[0] =3D gcspr - 8; + } + + __put_user(TARGET_GCS_MAGIC, &ctx->head.magic); + __put_user(sizeof(*ctx), &ctx->head.size); + __put_user(gcspr, &ctx->gcspr); + __put_user(mode, &ctx->features_enabled); + __put_user(0, &ctx->reserved); + + return true; +} + static void target_restore_general_frame(CPUARMState *env, struct target_rt_sigframe *sf) { @@ -502,6 +542,55 @@ static bool target_restore_zt_record(CPUARMState *env, return true; } =20 +static bool target_restore_gcs_record(CPUARMState *env, + struct target_gcs_context *ctx, + bool *rebuild_hflags) +{ + TaskState *ts =3D get_task_state(env_cpu(env)); + uint64_t cur_mode =3D gcs_get_el0_mode(env); + uint64_t new_mode, gcspr; + + __get_user(new_mode, &ctx->features_enabled); + __get_user(gcspr, &ctx->gcspr); + + if (new_mode & ~(PR_SHADOW_STACK_ENABLE | + PR_SHADOW_STACK_WRITE | + PR_SHADOW_STACK_PUSH)) { + return false; + } + if ((new_mode ^ cur_mode) & ts->gcs_el0_locked) { + return false; + } + if (new_mode & ~cur_mode & PR_SHADOW_STACK_ENABLE) { + return false; + } + + if (new_mode & PR_SHADOW_STACK_ENABLE) { + uint64_t cap; + + /* Pop and clear the signal cap. */ + if (get_user_u64(cap, gcspr)) { + return false; + } + if (cap !=3D GCS_SIGNAL_CAP(gcspr)) { + return false; + } + if (put_user_u64(0, gcspr)) { + return false; + } + gcspr +=3D 8; + } else { + new_mode =3D 0; + } + + env->cp15.gcspr_el[0] =3D gcspr; + if (new_mode !=3D cur_mode) { + *rebuild_hflags =3D true; + gcs_set_el0_mode(env, new_mode); + } + return true; +} + static int target_restore_sigframe(CPUARMState *env, struct target_rt_sigframe *sf) { @@ -511,8 +600,10 @@ static int target_restore_sigframe(CPUARMState *env, struct target_za_context *za =3D NULL; struct target_tpidr2_context *tpidr2 =3D NULL; struct target_zt_context *zt =3D NULL; + struct target_gcs_context *gcs =3D NULL; uint64_t extra_datap =3D 0; bool used_extra =3D false; + bool rebuild_hflags =3D false; int sve_size =3D 0; int za_size =3D 0; int zt_size =3D 0; @@ -582,6 +673,15 @@ static int target_restore_sigframe(CPUARMState *env, zt_size =3D size; break; =20 + case TARGET_GCS_MAGIC: + if (gcs + || size !=3D sizeof(struct target_gcs_context) + || !cpu_isar_feature(aa64_gcs, env_archcpu(env))) { + goto err; + } + gcs =3D (struct target_gcs_context *)ctx; + break; + case TARGET_EXTRA_MAGIC: if (extra || size !=3D sizeof(struct target_extra_context)) { goto err; @@ -612,6 +712,10 @@ static int target_restore_sigframe(CPUARMState *env, goto err; } =20 + if (gcs && !target_restore_gcs_record(env, gcs, &rebuild_hflags)) { + goto err; + } + /* SVE data, if present, overwrites FPSIMD data. */ if (sve && !target_restore_sve_record(env, sve, sve_size, &svcr)) { goto err; @@ -631,6 +735,9 @@ static int target_restore_sigframe(CPUARMState *env, } if (env->svcr !=3D svcr) { env->svcr =3D svcr; + rebuild_hflags =3D true; + } + if (rebuild_hflags) { arm_rebuild_hflags(env); } unlock_user(extra, extra_datap, 0); @@ -701,7 +808,7 @@ static void target_setup_frame(int usig, struct target_= sigaction *ka, uc.tuc_mcontext.__reserved), }; int fpsimd_ofs, fr_ofs, sve_ofs =3D 0, za_ofs =3D 0, tpidr2_ofs =3D 0; - int zt_ofs =3D 0, esr_ofs =3D 0; + int zt_ofs =3D 0, esr_ofs =3D 0, gcs_ofs =3D 0; int sve_size =3D 0, za_size =3D 0, tpidr2_size =3D 0, zt_size =3D 0; struct target_rt_sigframe *frame; struct target_rt_frame_record *fr; @@ -720,6 +827,11 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, &layout); } =20 + if (env->cp15.gcspr_el[0]) { + gcs_ofs =3D alloc_sigframe_space(sizeof(struct target_gcs_context), + &layout); + } + /* SVE state needs saving only if it exists. */ if (cpu_isar_feature(aa64_sve, env_archcpu(env)) || cpu_isar_feature(aa64_sme, env_archcpu(env))) { @@ -779,6 +891,12 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, goto give_sigsegv; } =20 + if (ka->sa_flags & TARGET_SA_RESTORER) { + return_addr =3D ka->sa_restorer; + } else { + return_addr =3D default_rt_sigreturn; + } + target_setup_general_frame(frame, env, set); target_setup_fpsimd_record((void *)frame + fpsimd_ofs, env); if (esr_ofs) { @@ -786,6 +904,10 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, /* Leave ESR_EL1 clear while it's not relevant. */ env->cp15.esr_el[1] =3D 0; } + if (gcs_ofs && + !target_setup_gcs_record((void *)frame + gcs_ofs, env, return_addr= )) { + goto give_sigsegv; + } target_setup_end_record((void *)frame + layout.std_end_ofs); if (layout.extra_ofs) { target_setup_extra_record((void *)frame + layout.extra_ofs, @@ -811,11 +933,6 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, __put_user(env->xregs[29], &fr->fp); __put_user(env->xregs[30], &fr->lr); =20 - if (ka->sa_flags & TARGET_SA_RESTORER) { - return_addr =3D ka->sa_restorer; - } else { - return_addr =3D default_rt_sigreturn; - } env->xregs[0] =3D usig; env->xregs[29] =3D frame_addr + fr_ofs; env->xregs[30] =3D return_addr; --=20 2.43.0 From nobody Sun Dec 14 02:14:15 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=1753604516; cv=none; d=zohomail.com; s=zohoarc; b=i4v8GpNJQSzs9CPPVT1jfbjEtWW99VwyWyxLfV18FkK0lfCx8aU8V6dn4B/1fOwgtvkRp/EpZmC5FXJNFTmzGfuF9jb+PdW1mwHctRBwAO7hhdvZa62jWRHG6QVhUEAl+OvMRjxxMLKkk0zgbFwqGlSC1mc8b7uVTYftMY2ICTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604516; 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=9biC4m5Z/jWTlu3yNFuyIx6JyDKTGnmYvdUOQcfLcyY=; b=jQuRT/7majjRCcxip8ntiuVp+lXmjfb0+0T9xUntTM/nB6kp+aSu8lhVHpyD1eOG0GUDKY8HmL69WKWU7BUL9BAmhkVnR18hBJLcOR82xIMnQZnx2ql8z72zI6Gk31lvJGcU4cldsnbrNkfP2aPpUq2Rei6qC9HrVwJ6OfmkSiY= 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 1753604516903199.43966725371286; Sun, 27 Jul 2025 01:21:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwRP-00023b-3b; Sun, 27 Jul 2025 04:09:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwPv-0004hD-Ov for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:39 -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 1ufwPs-0004w3-H8 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:34 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-23602481460so35115925ad.0 for ; Sun, 27 Jul 2025 01:07:31 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603650; x=1754208450; 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=9biC4m5Z/jWTlu3yNFuyIx6JyDKTGnmYvdUOQcfLcyY=; b=UE691dt/eomuwxuLQ1b8lIyKMSH/7w1CZJVZR+0ypovHeqReSlkra5elUzhwi+lTMX X94c8LzY4TwiBtjLLUBINQzZjuYRxBQE4+iNZJd48aK+CeWvjfm7IdHj3M0o3owY16V3 svj2lOzQwE8BWEtke7YJJjkOZhexi/ew5DkxhY62hZ3XKPiNNB+80HwB/A/0wR/I55B/ 7U9jGmUrhrCqaVZY+ie2/wNZ/K6rmg4WBOy8WcelRehE1hUMPUxTsbQd01AtMESyrXhY KuNIV7OO8yLwxl2P9bfEss61obBjXNdoxBvtEJ1QJudzg36cO056LbADwZY4YTLUBrSD OzmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603650; x=1754208450; 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=9biC4m5Z/jWTlu3yNFuyIx6JyDKTGnmYvdUOQcfLcyY=; b=C2+/2IgJgKt9VHxFx9mLMUPyPK35CfQEpZbkixnE+8cBUpxNa2ZE1snNZBKQnHU0M0 x9y17mg1VkIcvpPg4vYAKk3FB/hiUHoyoFpnq3Q2wU8LdjRFrgjPKjncSrxGrVo/8mkt CAe2r8Rqxm85Ki9/NUoJRTlHmvKt7togqXAtqOxvPm2Au7S0yJrgkkI946P4jTT8boB7 viHzNbMrQbvBxZM8mO30Y7L7KSbdb03bwNou2gqHefXo8L1gnRO4vHYrtE0u6Kmz5SNl yUA7reCLRDmk40sUHJ1ped+6aaXWKLLLwQuUcW47hPcTNZxGqV+2bXrmazUr1U2qHmyv +a/A== X-Gm-Message-State: AOJu0YwM+p79A/owgErDGo1ELlZxfZWfsaklij9ngAAI/xqSvkK9YlCk MYXA9jLD6ugQZ9Lx3idLT8O7gj6AL+4feZmM+38E8iqTZEzvhRz2wNx54HdfHl6g/xSCOW82keH vvf8C X-Gm-Gg: ASbGncuFCB9F2P4zR7L+MnrhO+3/bzOT6TubUIXV+TM+C8Gf081UkTuK5ii5hnG04vz WTIT/2DTTEqP5oFpxHSMJjjdS0O5bfYU017MMfNhwYIgSlpYrmbS2vCIls8pjeXhnYbMPHSretb wMEWZAk/t194sQAnf3Uq8c6YYlTGgEWsWQwJs2F4jKlhp33dIQOfasOm5FPqBQzp9QfZF3JkNeg XW/1nISIMY3+O3IcgepQsjKG4ka+8dKAp/fZBbSOei1RM2angv4xS8nt7BsHrrdltR/GoEc5fxz ddb8tPBLxvaiqIlNUZJwIgGj+OF7fIgXY1VqN7JnaDdWZQtPLYCmb7DZW506C2zynBGQwqZ2i0P CyT8pWypPih22tq+MnrMkuXOUE5Ubm/EnMG6/PUlm+S+yQADQPF1naZXoniZ9BASKAtYSlDrmsr RNdgKZSnWay9xlReYAFwPK X-Google-Smtp-Source: AGHT+IEg9NX2MMOvAdB+/kV0mFV+vFeeiO2FB68ptY+7GX9OsqPm8d7rxf23vuBeIp+S+FdsVOF+hQ== X-Received: by 2002:a17:903:2f87:b0:234:8ef1:aa7b with SMTP id d9443c01a7336-23fb3085301mr105934895ad.20.1753603650251; Sun, 27 Jul 2025 01:07:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 78/82] linux-user: Change exported get_elf_hwcap to abi_ulong Date: Sat, 26 Jul 2025 22:02:50 -1000 Message-ID: <20250727080254.83840-79-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753604518247116600 Content-Type: text/plain; charset="utf-8" AArch64 is about to add the first 64-bit hwcap bit, so we have to expand the return type. Since the only user assigns this to a abi_ulong, match that type. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753604148; cv=none; d=zohomail.com; s=zohoarc; b=AwUM/7Na9QC3ISZddqeuLkNIVlnAL220gQoZWj3ggOa0wZ3oNTiC00DOh1XFuw8bvmUII1DS8zap4NCgkljJJa4kTcyFlOa8xna1yzW/6JpWwxaYInIyy0paV1UDdcPy4j/hBCJmhU2dZe/pNc6MkkFKLAhRuUccX+JIh2pQwpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604148; 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=ehuTGpwHUKV7uIhBwvsB0XfGLWumhP/9m5f41YJi2Jo=; b=bUutVNFg6Ztk+qdsy81/uxUN6aY3UOSwxtwxlRbP/2jPoCya/7dYmCxwwvYwHtwmX0Voxk6q1Jn7QK+5YVZigwI8lEzPMpIYTQ1DdX7dFzlpn2oBdAhKNzOclOcbHeQPVaUMytpm2ZyE2KBuvtJVfE0sU03yNFTBTcq8cOpm/is= 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 1753604148266618.9134699642192; Sun, 27 Jul 2025 01:15:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwSV-0007TQ-8C; Sun, 27 Jul 2025 04:10: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 1ufwPv-0004hR-Ow for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:39 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufwPs-0004wO-QK for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:07:35 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-23fd3fe0d81so8023315ad.3 for ; Sun, 27 Jul 2025 01:07:32 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24011d5bcbesm3908065ad.10.2025.07.27.01.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603651; x=1754208451; 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=ehuTGpwHUKV7uIhBwvsB0XfGLWumhP/9m5f41YJi2Jo=; b=yMui89P46t3mgSC5+JXtvdSztlrmmNWsu2bHma1BhZ08rvpkR3GJVM4/5J3YPZjLor +YmRJ7CwUs7smRob24T28tuUIRlJBHjVK6klLexwTj1eRka0AWq2z66QT4RIqKtVpN1G jdudUPYwfLeSrv5dopuewb0N0UVUMThxryU5cjLgbZl1AOpycstiWPBWf24ILMHUWI2l tWrFhJ2NAPxJkyWv4w5x9rchNjiajERbNDQTxWxdJH2pBTVsVNZOmcWs5pEzX3YId9jr SslR4XUVM8HrUKqufMHm5MQb/RH+4/xfVeios+Zx8et44oH9LgItoI0s7IGMSC0lPyn7 7Y5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603651; x=1754208451; 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=ehuTGpwHUKV7uIhBwvsB0XfGLWumhP/9m5f41YJi2Jo=; b=mYeufBx8yil1YnxgeHEmLE5Z2Yzn2TH2aYtqu2jG5oCWBRgLnKdtMp/X/MgVQFLbcM IhiITrNxqbzmhBjab24JEsIku7jrVg+GSNQQPwjEp9qWt4/+JdmFkfYNOJdnQVylcsib ypHslG7RAH8ClXAMeRacOPJ0eqS6HEcczMRecjFDxqU3seONjORmifdg4wN5ShaQncay w0iWa5LYpM7VgBTfySNMPwBfNe9cRcw2TsEUuU1TwYFEk9zXZHXnvcyWyTuxHGYfjaak tYJe3/pkbvtWLBl9Bs8RzO5G3veCkYUa9O3N67zfqdfTbiiPCEj9aKVlCXFRl6H66cjV mTyw== X-Gm-Message-State: AOJu0YxgA4HddeiFakZrJf38rXKXosN19PESt0u2SxRmnUdI9M6vP77q B3TUHMGjtJuTb4d+UJq1YY0hv6+qe6dP/vp7b6X/caMtlpirGreZq4I5fWeChULW941IULy/jJc 6Zlc+ X-Gm-Gg: ASbGncv5rWxnoptIFSvdcfZXPPH3iPrPCgvcmQm2ux5fH+ncpnbZl1/SkGwDmFwT4Bb wSWpAUP7gr6pMlX5qFx0UNb+iP4KcKYZT+uYjesk6g5R8tVHx8CSXLI1dcZ8dMML2DZe+/cPrmb axE1i0DzZZMZr5pFkw7jjYw6MIv26s7Mub8wJhXIxQ/FNFfL4k4PCSpmltb6wOSUP+3L/RonxX2 FdpCF9cbeUkD0/CqNUcbJzn8kT0QYzGOp3P6udls2RfSTnRUc0EMVNjUKwoI9cy15a63Y3QgwOD OtTu+GdzIrJmzEPW0BW+1E7qM2LAtF9vTQWsmZiwq9uK7QVr2StmIMGP7l8MTzEgnal7R+1N3lR rmRs676xmJGxwAZUj9O3l2mZrbjFW0yZKvjXZSIVUPr5f+fV+hGQK7BXq4CgFsGhbJu+GckVMG1 r0OsV6mP5MhRolU57daf7m1OgIEQsQa48= X-Google-Smtp-Source: AGHT+IHDa3fA8mr/5q33HHHGjx0ZbAYUddd8uKH/TBEuM6O6B6H3HWJr8yzRpCDBpJWSSVbRZmlbVw== X-Received: by 2002:a17:903:1111:b0:234:d7b2:2ac3 with SMTP id d9443c01a7336-23fb3029b76mr102260535ad.20.1753603651316; Sun, 27 Jul 2025 01:07:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 79/82] linux-user/aarch64: Enable GCS in HWCAP Date: Sat, 26 Jul 2025 22:02:51 -1000 Message-ID: <20250727080254.83840-80-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1753604149349116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603990; cv=none; d=zohomail.com; s=zohoarc; b=a+F4IG6RwdBL8A0Uxou/BE0SYO3oYcYCCrlRvvK/H41g6VKunsUmDWFbk7GzH6fa+uVI0eUc+EA/45QllaBVAcCZZXU4E4TFyy4hMB7op06UWh33ozNYYXmOgT5oJk0N2k/5KpxOc2lqoeyaLSvkHylH4lcCPNhEOxRAo1GKwds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603990; 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=2BmpRZBaWh5no0akyUOZ9r4Fxe0S4GM46R9zVbkzAxU=; b=kmvxGs1d4yJhF9gR0Pi8WQNlY3MejfB8XCvy0LlteQtPetYKXaLbNP99+M8GpS/QFC698UlZbpYwr3gHcwjz+Wydc88LuERVd6+X84rurk2oPqUQ7nGB70Avr1VfkmKfYN1fvUoc/HQFvUcWxy/5qQmr28xrp36VBLoSEoy/uJY= 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 1753603990915373.99748205773756; Sun, 27 Jul 2025 01:13:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwTz-0001kX-59; Sun, 27 Jul 2025 04:11:47 -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 1ufwSu-0000BV-Q0 for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:10:41 -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 1ufwSq-0005Qz-PK for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:10:39 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-75ce8f8a3a1so1997653b3a.3 for ; Sun, 27 Jul 2025 01:10:34 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76408c0271csm3085491b3a.49.2025.07.27.01.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603834; x=1754208634; 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=2BmpRZBaWh5no0akyUOZ9r4Fxe0S4GM46R9zVbkzAxU=; b=gFWt12CQzc1OWDxDsIr0cyId/38D9g8g3orHaGHXH/vuB3STstqflfll0xC3HalktX L3Qir0QSPxqIun4wkER7oOx16/ZRrhUQGn/njyeQE8mZ7o5305m7a4XYR4xzZJvxxPeo RAa0SCclNwncQeuBvkc/tJX9tPZ3QMOM8DSWZEtGSMqtDSx5/BeXkK5ocsKTjPlSHkMM mNhlnxXTmc63d8hhylOkLImb1+6rLbCncoltLSTTfp861fWpae/p9FUASZz2MODvj0HU GSee7ZalrOu01xtbINOc2I6EqC0Yci43+fCMme52c5hCx9vL486GIcKPERkIjBTYiXC7 bWxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603834; x=1754208634; 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=2BmpRZBaWh5no0akyUOZ9r4Fxe0S4GM46R9zVbkzAxU=; b=h57+SytihfhKUqdFhlGoe0X2LuCLgQZxu+ocoeEH/U//1NIEUIKuar+6AIKAsyTK2+ pdXo3nmYzI1swu5FQC4rA2vsJ3rQsR3fl4q87ZoKxPFOo4dbFu2GbXPUK0/hLF7OmiwT CP+s/0vmdbNIsQXwoz7twJsekHvDNBeo1MVqSszKQOC6nPE3jRfyrYtCb1jsVzzvBVXW dWROGwGa6KqWp6VGy5RM1g2rX8OLew4zmSEufsUDD3VWOXnUNhkUAzoVd/SAZ9Gw9AW5 u+fITzCY5CGdjoQK9xRF0apXcy/7Pk6yiLw6oCMaMzjBsMhKYqIz7klCRjCyuni0/irQ aGhQ== X-Gm-Message-State: AOJu0Yx4eP2G3li21WiSjIHR7Rb1Qf9Ob47tGYX93807ARM7b1ivGg5a RdESm2HAigfaUr6PDpb7r8DiapRX6nkpuGUeawAuiPXKBMJCUqb+m4j+tr3iYOldhCG2gCoE6Ir A/4Lm X-Gm-Gg: ASbGncsJNYH6zFTlfFOZshKHL4Aj0Nm4eSyn1stsu5cqHn8XpwODudFWkonme/3Kk7V A+fdRNZDenJ2/5n/XbgVjStSsoSrgyIMm9T/Ks841w4cX/k/I1SoSz5y33UHaTo942F2X8lon8U d0/4pBKFGC7dsQzA3ZYwdxyptY+/xzOfi6jSs1+4OO9VB1xzr6thBK6lg3p9j+f2kAlpxv/Nkfk 2LEHMeQd/F3emyXxHHVrJKKfYqSKTafTJsYiaKOAKXI845CXoCUExx1mR2a30sTl73ffk3deiD5 G/a8HxRhBEr25v4RtPhQ88RhdkpL3aeXZAPbp30V2K6B4xSwdTtvCPUs2rBcBluCDx107W6h2vJ P0Hd3UHJ2QJNKuuEkh07rGCg4OFsl98CaFZfD7eHRfb/ALjnmYZR779YJxC1GHZo5i62AhOOQa4 50gomZp1cePw== X-Google-Smtp-Source: AGHT+IED5/K/3pO98rUvykzieWT76IGk2lsmulFAD0opY1CGyfjPmahkMCkAIuNDBW2l/+wV9hkoqw== X-Received: by 2002:a05:6a00:18a2:b0:736:8c0f:7758 with SMTP id d2e1a72fcca58-76336a42c17mr9417550b3a.10.1753603833757; Sun, 27 Jul 2025 01:10:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 80/82] tests/tcg/aarch64: Add gcsstr Date: Sat, 26 Jul 2025 22:02:52 -1000 Message-ID: <20250727080254.83840-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753603992505116600 Content-Type: text/plain; charset="utf-8" Add some infrastructure for testing gcs in userspace. Validate successful and trapped executions of GCSSTR. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 02:14:15 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=1753603943; cv=none; d=zohomail.com; s=zohoarc; b=Y7J0AN8qAAodFEcjsmS32yqA7HQLNKbZNj1pYFA/6De30hVrguUyOQzj/y9yDS1pL+dAIDaizohmLcg2ORereREVMvAuSxjQwc6jUaqUc5lCezbHnM8JU7c1foWJoxgmRzG3Jghblmv3+eWpmv6jegAQ6gmNC1c89t71obEqCIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753603943; 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=mAfnYZFojtklCwJRxymdFpeNN7gNQpULrXmCsUVIRjI=; b=m34DkjecE+xBuj8ytTEeAiOrrVygd8+wNqS/n+wNIoinHGBNfq6CMqF2UN9qbqr7/FfloN6Y993G/1vTwhnUMedockoSNacfepJER/KQ7WkLMEfCg+mgKGm+r/r95FGYS8cIl5gEuEQYLrOrTeQxQhuQehpXkS4wC3udQVIgltc= 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 1753603943192872.4953592669897; Sun, 27 Jul 2025 01:12:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwUG-0003is-U0; Sun, 27 Jul 2025 04:12: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 1ufwSu-0000C9-SQ for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:10:41 -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 1ufwSq-0005R7-PW for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:10:40 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-74af4af04fdso3302764b3a.1 for ; Sun, 27 Jul 2025 01:10:35 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76408c0271csm3085491b3a.49.2025.07.27.01.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603835; x=1754208635; 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=mAfnYZFojtklCwJRxymdFpeNN7gNQpULrXmCsUVIRjI=; b=w3tlnSnCioUiLKwALz9I5PlL8rT0RgExpLGitYUDQQAsRh+K7pECDT7sccDXKFPyf2 cRjlJIeFZ6mF81P8MHduIoSvPSxnMK2FQOgmxHVxlwbjUfuzaKSHI6yVBTkBp9XwkeoP EK/xRhe0nl231p3yPo1H8FUTNvdB1MRVgjrtuSj2KVJfzwM8ehVwPX3vwmWa6h34/OFu MVXv3bV6cvWWVHEtOTyrTYdjkIhXYFbGgcjfSRim5BGPwkHbIXkC4kgsZg9vsLKnwz8K eNMWZj/kGaVq6YjP4WOSG0B+x34P5ykCa6BV/ShO0YR0u6L/sXuwIrM4W2jCbM+/YQia Z/Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603835; x=1754208635; 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=mAfnYZFojtklCwJRxymdFpeNN7gNQpULrXmCsUVIRjI=; b=NTm2EMqTvp0x8LHCEP+Y6O3JC/fITX/xjCrpFfzv/X4o5DqKUz8BYTX7+nqfKpVrLl EXk55p4N2ePnJvvM+z2Yv8UX6lIEntciZ4zIPR2d6NVwvZxaUV+yP07Ph5fZNp+vVeJ+ MbblctjHoGWqq5G2OKdqRjszsRmstmJhLyhvwYkWUcbQB+B7cdsfrdamiUJlJOmBrJlC qIimulq47WMkUOUMEAxxIHOh/4fsL6cUIUNI4Nhoh71mIFHQ5x5ko+mJ7wUvNO3a1h0R NwQXE1bt6A62eiJF/IYRnsbInQZvstJgZ4ltGeU0YcNfYVcfmcvxBP81t44mh3CQZtBP tfBQ== X-Gm-Message-State: AOJu0YyCKQOBIK9Vu97hUWWkWcpvEsXmKI6o7WB7WVFlbbFPZq+8PhpS Cyzrx68I6TbLx38rtr6xOBH2jgmYHiKbBtAJvcszNV2eRT14QY6LefyGI3wwAomIBtP/J2t8tzY 3rPBM X-Gm-Gg: ASbGnctc1df0idvXoEuJit/Infj2OXlyh6yMlfIcBbxPBHWIcWmhQW1MFH9ogzrGpdF snR2jzo98MFrSiOIx0czD+MQmumozvlN1igZqquATtfTbX0hRbgYxL+Gg0ud8Yt6JWQvI54WBAZ IRC8NpBRgcUnowm4XaIxH0W1qNb9CS5EpMpE9c/0KKN7aqcrLdpVgbZGMB9mG4y09BmQgQq+pHG SLDEg0wcDpAvcY/3L7xP4yqzIPnRZzyqGqnVqN+zCOokAxPwkqBCFmidsXIS8mOkj6ZGpP84Bjy wI9BGNH9BwN8KpCHoCO/7dbDWEfSaPg73KhfZQ86avCYB+QU9+DPPbctXCIrtAlHoyBHEwDYPmm DQ+l7NE698ojuaa9NMNmaKJv6W6AEx6z5r6OaKIxvbu5W7ZQiIg337+vMN7ba383eoKGbr7q4fx 01RPigEzj/Gg== X-Google-Smtp-Source: AGHT+IGEDv1rKx+ii9+DsUIH0u3zZgy2AbMLB5Sk/qBDzZpLvN5BKGULoBO4iBDaWkaloNky4Q1Tmw== X-Received: by 2002:a05:6a20:914c:b0:21f:53e4:1919 with SMTP id adf61e73a8af0-23d6df7ea1dmr12511667637.3.1753603834878; Sun, 27 Jul 2025 01:10:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 81/82] tests/tcg/aarch64: Add gcspushm Date: Sat, 26 Jul 2025 22:02:53 -1000 Message-ID: <20250727080254.83840-82-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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=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: 1753603943886116600 Content-Type: text/plain; charset="utf-8" Validate successful and trapped executions of GCSPUSHM, GCSPOPM. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tests/tcg/aarch64/gcspushm.c | 77 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- 2 files changed, 78 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..0c7cc09065 --- /dev/null +++ b/tests/tcg/aarch64/gcspushm.c @@ -0,0 +1,77 @@ +/* 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 volatile uint64_t test_pc; + +static void test_sigsegv(int sig, siginfo_t *info, void *vuc) +{ + ucontext_t *uc =3D vuc; + + assert(uc->uc_mcontext.pc =3D=3D test_pc); + 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; + + assert(uc->uc_mcontext.pc =3D=3D test_pc); + 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 tmp, old, new; + + 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)); + assert(old =3D=3D new); + + sa.sa_sigaction =3D test_sigsegv; + if (sigaction(SIGSEGV, &sa, NULL) < 0) { + perror("sigaction"); + exit(1); + } + + /* Invalid value -- SIGSEGV via EC_GCS */ + asm volatile("adr %[tmp], 0f\n\t" + "str %[tmp], %[test]\n\t" + GCSPUSHM "\n" + "0:" GCSPOPM + : [tmp] "=3D&r" (tmp), + [test] "=3Dm" (test_pc), + [pop] "=3Dr" (new) + : [push] "r" (1)); + + enable_gcs(0); + + 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("adr %[tmp], 0f\n\t" + "str %[tmp], %[test]\n" + "0:\t" GCSPUSHM + : [tmp] "=3D&r" (tmp), + [test] "=3Dm" (test_pc) + : [push] "r" (1)); + + 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 02:14:15 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=1753604274; cv=none; d=zohomail.com; s=zohoarc; b=fvuqUC68mXwRuksnYF2aX8BzjcR4q9t7vmYdqyr6OF+btCKWjUjUX53aIQgFjruK5PLczexC8IdMrQsWZxSQUPDZaoEAqSijVwpB/2C2NXGoC2mGOOdnN8CG68J+l8KEYhdYRYEuGwVLYfVeUWQUsIOkckOzALwuG+O8ZT6BXpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753604274; 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=UMsWiUAscqE67euLD5nK2idOuvJcvFXzap5kwHEFlqU=; b=irJ23/tI/g9IuxM6+RLGoWL8xCVQyrmnY6CC8c3PR26IBeiOMzlUzlE5KFpIMeuns6+PRKpjRzuF5Xtlx+HJfjTbr4tEgzwfRuBbYnSdxnxUNJnBdnNaG6Soul804Wrorx1fIUPiQ2pmawgFlcwWcLAvlFkavTW2OX6U3icrnUU= 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 1753604273959927.1935468807718; Sun, 27 Jul 2025 01:17:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufwUD-00033G-6t; Sun, 27 Jul 2025 04:12:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufwSu-0000Cb-Ta for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:10:41 -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 1ufwSs-0005RI-2w for qemu-devel@nongnu.org; Sun, 27 Jul 2025 04:10:40 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-b3be5c0eb99so2982856a12.1 for ; Sun, 27 Jul 2025 01:10:37 -0700 (PDT) Received: from localhost.localdomain (syn-098-150-199-049.res.spectrum.com. [98.150.199.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76408c0271csm3085491b3a.49.2025.07.27.01.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 01:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753603836; x=1754208636; 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=UMsWiUAscqE67euLD5nK2idOuvJcvFXzap5kwHEFlqU=; b=gcc1hXSRbytpgeNBMdPzowqlBbYE1wN+Bx7/sac9wNlo1OxaUGX1f7B1OSO+hJNoUP QwG/ssaZq+RdIfYLwQTNXnFAfqizf9yJAZhs53IA/o6O6Gz736sI9v03ThqkSfJLn/KH l7rHRbpIVLpsZ3ortf/ulnN5ruRqIrXe5mk10Kppgx8Ag9nqmnO40J2Zg4mDH0osQHsr mW2l6lCo3BKUha4LV2+lOojwtxlTpbcZRB1t44KkLh7TKghl8SWSZcfMn+29en0cYw8K k+tWU/q/NTH6/G0RmaCYeTtQdrBi7WYEe0f43on3GmqE5QMiv1+9djj07uPraQCprWOC VhhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753603836; x=1754208636; 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=UMsWiUAscqE67euLD5nK2idOuvJcvFXzap5kwHEFlqU=; b=wP83huBtq4bHYvFHA8pXH4Ohh1bgIeGM68umqb+E3UgQ5W918jj72Fl/cd/njYq2Wo GW5IBf1C8zdCmX76nD9N3cI58qvVl/jnZSpHD8zadUIwYcFW31bqraCTuix2mwRZsV3v AjpLfh6bRaomQQmIB0VFL4rzmN4WNHaGItG4lXk7MGQ5ECrkkV4O7EMl6c8VAnZkKNZc P5tVUWfxEVWAGPllD16JqFlKTrFyCggxan2qlaRJiP4IyDQm46tcSsWznlLcr/33SUcA wmbnV62J6fwQBLWxk+3gzzP2ZkggY8AeOyxl2ULDHPn09VQPOFF9YyC2Hyg6o+24RK3y xdIA== X-Gm-Message-State: AOJu0YwzH2tDe3hZEz89SJ7D6f7XOUaGP2Ckj3rMZ2kWcUb3nbZhqAaN e4wPT0ntMnsigFRva5sVc+fqBt1irjvEZ2p35JGUEQmBW91x+Rcy8R8jph1I6CPztHLT5S0HXTf Cfa7M X-Gm-Gg: ASbGncvZ+GJLdlSGbGxY+O6mBZvu246TmltGRZ3QUA9sYYdu/fok7Xqpge8QQ+CXQcW 9/1VqghL4TXVqQwJML8TbFA7ZVMiLkIIkOSKdUH+WN9KR+UVFtlJ5+O7fx9IhBZt1u2I1dMYI1i TxjSc2NzrN+GIt6YmD5Vbv0G82tNDfhs3edrNYtslPgo03ANUqCEfyyOCsM34ylXoydcS/Y9uIk LdfUAv+lVWkrEPCcVZyg4F/bgRaO3514HBxF6okZKbD9OWe/wqeexjgCFdN2U8hPekTyN6hhNIE 9Jl/RoPu72W8z3CpG1wH+vLR4J2qEDFvh+E8sxkx1UvvbUmW0vofz25DctNEBw1zj4F3Rb7yPDs nY+1sdiDbcFYACUm4abozfHi3xu8kfHiJS3oSvphlfCWqDv230Y3nL8GHwL+B6wxCRpSqHz5oQg lsvcPSR9vZDw== X-Google-Smtp-Source: AGHT+IG6AZ1qJKcy+gdYGTYkFJTh1MTpuko1sMXaVVJn5VbtN+ITUpnR5Qr9Xd+jmDVvII519Haeeg== X-Received: by 2002:a05:6a20:3ca1:b0:21f:5aa1:3102 with SMTP id adf61e73a8af0-23d70189e0emr12212839637.37.1753603835960; Sun, 27 Jul 2025 01:10:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 82/82] tests/tcg/aarch64: Add gcsss Date: Sat, 26 Jul 2025 22:02:54 -1000 Message-ID: <20250727080254.83840-83-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250727080254.83840-1-richard.henderson@linaro.org> References: <20250727080254.83840-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: 1753604274455116600 Content-Type: text/plain; charset="utf-8" Validate stack switching and recursion depth. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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