From nobody Sat May 11 08:32:22 2024 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=1666592832; cv=none; d=zohomail.com; s=zohoarc; b=BzCD9wCAjAH5n6V+qxRu7hsPvZz+ldq2jRc65jlsm1mWtkEZKjjz5tkEz/XqPDhIT01ubmBno77D4wRRVzVupK+WLao9ku7i6u40pnUnxh4k0kGn9hSx5QnVkOIGgRSfW+V9ETP+XDeImv+jPN6X1bF+xXbmkyeCnZhOYx80o9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666592832; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dRBUuDv4xO4FSH5BCO5y+i5Lk2hVQIRJPv1ndVT7mQw=; b=jaAgm9sxFTA6K1n+JrPejWmBfSDxrp8Ug906cnrd5h8DIi5GI1mv8aWswt5SIgjAf7mQMDk8/KlpOQrSVwmEcn1gmZTLFnWxgqpXMTZMvrB13VTsIZiTrRMCZcblAniTlnJW6N4l1BCWpPueg++v5AkfhLHa8FqR+Y5oIN7GrZs= 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 1666592832606245.3374445641989; Sun, 23 Oct 2022 23:27:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omprf-0006VW-9R; Mon, 24 Oct 2022 01:19: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 1omprb-0006S9-FX for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:04 -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 1omprZ-0002Ic-LV for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:03 -0400 Received: by mail-pl1-x632.google.com with SMTP id jo13so3977889plb.13 for ; Sun, 23 Oct 2022 22:19:01 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=dRBUuDv4xO4FSH5BCO5y+i5Lk2hVQIRJPv1ndVT7mQw=; b=lIfskUFuwd74y9mbyGyHFZpm1q3VWFHOfhC1cpd4hArkgXfbGbmQrVzPZe+5HM0WKz o7dxp/AlWoODR5DgSxjeCffz5VAQ/yIdLq4WrWYEf/1i/9qcwBvQQGJY79LGy6epz5/S dwugOjQB9aQBWmAlSwPuK6nnA0hDO651Oh00/kcBxRcTknHydTgJIjIDtywcqOdBqCcu QcS1qDUdhmXfrrv9a+j4zIUMOYNYOHZhBQRklLdw3F9/uLiLTzX8QyyOI+IhO3K2SK7q 2rffRDsP47Hny1SHrCslMFx+TSAiHCHdTGSx9U+/3JYj2zp0aiLITR4lwa6Wb8nlCymc tW7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=dRBUuDv4xO4FSH5BCO5y+i5Lk2hVQIRJPv1ndVT7mQw=; b=W/TOOUnMqlFy9Pim/P7DA2VIphw8vRgUPmbTSbf8+Azkrjo1cfdtkxxJ+mv/Bf1kqj bXZ31D+U6Y4M3c3bPRAHdiTpY64tFKLkPsnzEqw+SYuXkG4Iuhh+bC0f8ln1LKxB9GSI t8YM2T8eNDBFxtMbpuU9mUaLoa5v/sLIpSfs2IQHJ4cpO8gI9O/xrggnClKPKlIde4Ts 4fEkPEplQ+MUMFSxgu53qz+c0RKV+Y52aBNEd0sltDnqCai1nEo6Y2txDLI3giZ7xGL5 mZ8suVwvLWGEgwavgIeRANnm8SkVe2yuI9PH7Ib2kZeoz+qZUa/umyzJUk8uD9i7jYHr kCJg== X-Gm-Message-State: ACrzQf2j4XsHNKVovD7j0S0u9sTMoV2mhoMYNh1UAd46oFU5Uc+V0Clm GFHpcr5HyXZTwrRBI60EyrBV1X0iaO7M7EwW X-Google-Smtp-Source: AMsMyM7v62G1m/XdrJ2uStaGY5VMXNtIV1NwLiF27IEsM2BucKwUXJCUwDuiR+x0BMC6Ggexr+Z5tg== X-Received: by 2002:a17:902:e952:b0:17c:2eee:c0ce with SMTP id b18-20020a170902e95200b0017c2eeec0cemr31633689pll.145.1666588740221; Sun, 23 Oct 2022 22:19:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 01/14] target/arm: Introduce regime_is_stage2 Date: Mon, 24 Oct 2022 15:18:38 +1000 Message-Id: <20221024051851.3074715-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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=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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666592833565100001 Reduce the amount of typing required for this check. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/internals.h | 5 +++++ target/arm/helper.c | 14 +++++--------- target/arm/ptw.c | 14 ++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index c3c3920ded..2b6889073d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -673,6 +673,11 @@ static inline bool regime_is_pan(CPUARMState *env, ARM= MMUIdx mmu_idx) } } =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 exception level which controls this address translation regi= me */ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/helper.c b/target/arm/helper.c index c672903f43..cbfaabbc09 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10352,7 +10352,7 @@ int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx m= mu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 37, 2); - } else if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx= _Stage2_S) { + } else if (regime_is_stage2(mmu_idx)) { return 0; /* VTCR_EL2 */ } else { /* Replicate the single TBI bit so we always have 2 bits. */ @@ -10364,7 +10364,7 @@ int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx = mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 51, 2); - } else if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx= _Stage2_S) { + } else if (regime_is_stage2(mmu_idx)) { return 0; /* VTCR_EL2 */ } else { /* Replicate the single TBID bit so we always have 2 bits. */ @@ -10474,7 +10474,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, int select, tsz, tbi, max_tsz, min_tsz, ps, sh; ARMGranuleSize gran; ARMCPU *cpu =3D env_archcpu(env); - bool stage2 =3D mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMM= MUIdx_Stage2_S; + bool stage2 =3D regime_is_stage2(mmu_idx); =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -10532,22 +10532,18 @@ ARMVAParameters aa64_va_parameters(CPUARMState *e= nv, uint64_t va, } ds =3D false; } else if (ds) { - switch (mmu_idx) { - case ARMMMUIdx_Stage2: - case ARMMMUIdx_Stage2_S: + if (regime_is_stage2(mmu_idx)) { if (gran =3D=3D Gran16K) { ds =3D cpu_isar_feature(aa64_tgran16_2_lpa2, cpu); } else { ds =3D cpu_isar_feature(aa64_tgran4_2_lpa2, cpu); } - break; - default: + } else { if (gran =3D=3D Gran16K) { ds =3D cpu_isar_feature(aa64_tgran16_lpa2, cpu); } else { ds =3D cpu_isar_feature(aa64_tgran4_lpa2, cpu); } - break; } if (ds) { min_tsz =3D 12; diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6c5ed56a10..004375e02b 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -842,8 +842,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_i= dx, bool is_aa64, bool have_wxn; int wxn =3D 0; =20 - assert(mmu_idx !=3D ARMMMUIdx_Stage2); - assert(mmu_idx !=3D ARMMMUIdx_Stage2_S); + assert(!regime_is_stage2(mmu_idx)); =20 user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); if (is_user) { @@ -1171,7 +1170,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, goto do_fault; } =20 - if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2_S) { + if (!regime_is_stage2(mmu_idx)) { /* * The starting level depends on the virtual address size (which c= an * be up to 48 bits) and the translation granule size. It indicates @@ -1342,7 +1341,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, attrs =3D extract64(descriptor, 2, 10) | (extract64(descriptor, 52, 12) << 10); =20 - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_St= age2_S) { + if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fiel= ds */ break; } @@ -1374,7 +1373,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 ap =3D extract32(attrs, 4, 2); =20 - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + if (regime_is_stage2(mmu_idx)) { ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; xn =3D extract32(attrs, 11, 2); result->f.prot =3D get_S2prot(env, ap, xn, s1_is_el0); @@ -1404,7 +1403,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.guarded =3D guarded; } =20 - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format =3D true; result->cacheattrs.attrs =3D extract32(attrs, 0, 4); } else { @@ -1435,8 +1434,7 @@ do_fault: fi->type =3D fault_type; fi->level =3D level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 =3D fi->s1ptw || (mmu_idx =3D=3D ARMMMUIdx_Stage2 || - mmu_idx =3D=3D ARMMMUIdx_Stage2_S); + fi->stage2 =3D fi->s1ptw || regime_is_stage2(mmu_idx); fi->s1ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; return true; } --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666593283; cv=none; d=zohomail.com; s=zohoarc; b=lRf1AlSdEkHzkdzL46T+iRyqaUieMoKHe1RKBtXmqFS0Pt5cVdWCRAfVHr5soti0vqDVHiyewntV8BQXgqeZQtD0IRUu/8B5gxDhCx2q2EijNL05C6G2mx7lCw/t4NQuZOYzl/cEibS2JsFjxE3tndhq2r5FmXy9PHPwMl1rzmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666593283; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TugH2ukoL/GP7ZN02ws3Cq0+tk08ipGAjprVUPkbIZQ=; b=eE5anT4JszEYkccMPkXpqiT4VQoKCKku8eqM62Ztb0WalEf8eNkwBEVxYFl/QoO19U6RXyK6pTEYtMZKDG/B9MCtwlyO+7QXINSqFbCSUReQPcV6EJD7ZAfFnLnhYNZoHIspzmF7g+yEShGBeOxiTmi+sAzc/W2S/URx2LPlHMg= 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 1666593283241372.5943241068147; Sun, 23 Oct 2022 23:34:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompsZ-00071a-DW; Mon, 24 Oct 2022 01:20: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 1omprq-0006ap-4L for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -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 1omprc-0002Jk-Hs for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:16 -0400 Received: by mail-pg1-x533.google.com with SMTP id r18so7791041pgr.12 for ; Sun, 23 Oct 2022 22:19:04 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=TugH2ukoL/GP7ZN02ws3Cq0+tk08ipGAjprVUPkbIZQ=; b=lrW4Kubth2Hwb9Z0wiJ0K6rEYWrzBKu9qhcst5WTDbdD33E+HlfDfZOguU1cIvdWuB LDyFC6d2jvP1sU9rZOG8c5XOBjN/qVuO6e+rGavg17mHND8Zo1tkip7LX+WivJe8oVpU p2U92sig1iMncxHTQ4sqfB50AJh6yAY+/DQW7kFL1QFf+RB9fOTcBRzjMvIyvksfK6L2 6CY4cKM7Qj9okPo/0+fsM+ZJCe/ulB6bTPgKxxmHB40NK2ubW/sN+El3ViSdPP02BIEG +cR8/dJpiB4IK1VJagPMCsc5/ckGPjLqKm36QglJaQDxvjzeMpDBMeH/d836yeu+yiJF Ub/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=TugH2ukoL/GP7ZN02ws3Cq0+tk08ipGAjprVUPkbIZQ=; b=1YSdQShnaECWsN44upIIRCS/jdGlJlTrIW/+ECZ+jjc2ykh25tGyOjN1B8e5gGJLxp f7aUmtDPpo6h36Qmo30m1Oe4A+EAttKd+Oq1zdBwdE4nUP6ZrnQqfAi0Prj/FxMt+HoB H0SnIP8iatE42gUw9GuYpasqhz6aKobmj0TOtbcdq6+oKZ3EQ5HN8Ib/bKq1cKvXn8RS IzX7myv5ZzQWT1Xy7UBokUe2eYWn7hmZ6O2OLzrAa6LpjB+eFgOrKAb0aht3b47nK3A3 kho8iU7HTSdEpMRZ/ZvIALb4PqUUFVWqjyDuXqj5ee17ZJ6SI2Y1Tb9shb6o20vkqmKT BRYA== X-Gm-Message-State: ACrzQf0LIExL/jeVHrIqlnTioO7oGvjcdAaPnNGiyvIV+IEJTgQT46Xs hx8/uRT68ihXHR8IhyFP6IyYamQoVwOfacYV X-Google-Smtp-Source: AMsMyM6hdYB2evnzD+qK8QBYQ1x1O2D5dQbz3JPclZX4UrKd0Ju3TIuXMcqIC6u+Vwu+F7g32gNlMQ== X-Received: by 2002:a63:f07:0:b0:440:5c6e:5833 with SMTP id e7-20020a630f07000000b004405c6e5833mr27534717pgl.375.1666588742664; Sun, 23 Oct 2022 22:19:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v6 02/14] target/arm: Add ptw_idx to S1Translate Date: Mon, 24 Oct 2022 15:18:39 +1000 Message-Id: <20221024051851.3074715-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666593284039100001 Content-Type: text/plain; charset="utf-8" Hoist the computation of the mmu_idx for the ptw up to get_phys_addr_with_struct and get_phys_addr_twostage. This removes the duplicate check for stage2 disabled from the middle of the walk, performing it only once. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- target/arm/ptw.c | 71 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 004375e02b..161b7922e3 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -17,6 +17,7 @@ =20 typedef struct S1Translate { ARMMMUIdx in_mmu_idx; + ARMMMUIdx in_ptw_idx; bool in_secure; bool in_debug; bool out_secure; @@ -233,33 +234,24 @@ static bool S1_ptw_translate(CPUARMState *env, S1Tran= slate *ptw, { bool is_secure =3D ptw->in_secure; ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - ARMMMUIdx s2_mmu_idx =3D is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_St= age2; - bool s2_phys =3D false; + ARMMMUIdx s2_mmu_idx =3D ptw->in_ptw_idx; uint8_t pte_attrs; bool pte_secure; =20 - if (!arm_mmu_idx_is_stage1_of_2(mmu_idx) - || regime_translation_disabled(env, s2_mmu_idx, is_secure)) { - s2_mmu_idx =3D is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; - s2_phys =3D true; - } - if (unlikely(ptw->in_debug)) { /* * From gdbstub, do not use softmmu so that we don't modify the * state of the cpu at all, including softmmu tlb contents. */ - if (s2_phys) { - ptw->out_phys =3D addr; - pte_attrs =3D 0; - pte_secure =3D is_secure; - } else { + if (regime_is_stage2(s2_mmu_idx)) { S1Translate s2ptw =3D { .in_mmu_idx =3D s2_mmu_idx, + .in_ptw_idx =3D is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_P= hys_NS, .in_secure =3D is_secure, .in_debug =3D true, }; GetPhysAddrResult s2 =3D { }; + if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, false, &s2, fi)) { goto fail; @@ -267,6 +259,11 @@ static bool S1_ptw_translate(CPUARMState *env, S1Trans= late *ptw, ptw->out_phys =3D s2.f.phys_addr; pte_attrs =3D s2.cacheattrs.attrs; pte_secure =3D s2.f.attrs.secure; + } else { + /* Regime is physical. */ + ptw->out_phys =3D addr; + pte_attrs =3D 0; + pte_secure =3D is_secure; } ptw->out_host =3D NULL; } else { @@ -287,7 +284,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, pte_secure =3D full->attrs.secure; } =20 - if (!s2_phys) { + if (regime_is_stage2(s2_mmu_idx)) { uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); =20 if ((hcr & HCR_PTW) && S2_attrs_are_device(hcr, pte_attrs)) { @@ -1282,7 +1279,18 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, descaddr |=3D (address >> (stride * (4 - level))) & indexmask; descaddr &=3D ~7ULL; nstable =3D extract32(tableattrs, 4, 1); - ptw->in_secure =3D !nstable; + if (!nstable) { + /* + * Stage2_S -> Stage2 or Phys_S -> Phys_NS + * Assert that the non-secure idx are even, and relative order. + */ + QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) !=3D 0); + QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) !=3D 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 !=3D ARMMMUIdx_Phys_S); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 !=3D ARMMMUIdx_Stage2_S= ); + ptw->in_ptw_idx &=3D ~1; + ptw->in_secure =3D false; + } descriptor =3D arm_ldq_ptw(env, ptw, descaddr, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; @@ -2468,6 +2476,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, =20 is_el0 =3D ptw->in_mmu_idx =3D=3D ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx =3D s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Sta= ge2; + ptw->in_ptw_idx =3D s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_= NS; ptw->in_secure =3D s2walk_secure; =20 /* @@ -2527,10 +2536,32 @@ static bool get_phys_addr_with_struct(CPUARMState *= env, S1Translate *ptw, ARMMMUFaultInfo *fi) { ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - ARMMMUIdx s1_mmu_idx =3D stage_1_mmu_idx(mmu_idx); bool is_secure =3D ptw->in_secure; + ARMMMUIdx s1_mmu_idx; =20 - if (mmu_idx !=3D s1_mmu_idx) { + switch (mmu_idx) { + case ARMMMUIdx_Phys_S: + case ARMMMUIdx_Phys_NS: + /* Checking Phys early avoids special casing later vs regime_el. */ + return get_phys_addr_disabled(env, address, access_type, mmu_idx, + is_secure, result, fi); + + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: + /* First stage lookup uses second stage for ptw. */ + ptw->in_ptw_idx =3D is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Sta= ge2; + break; + + case ARMMMUIdx_E10_0: + s1_mmu_idx =3D ARMMMUIdx_Stage1_E0; + goto do_twostage; + case ARMMMUIdx_E10_1: + s1_mmu_idx =3D ARMMMUIdx_Stage1_E1; + goto do_twostage; + case ARMMMUIdx_E10_1_PAN: + s1_mmu_idx =3D ARMMMUIdx_Stage1_E1_PAN; + do_twostage: /* * Call ourselves recursively to do the stage 1 and then stage 2 * translations if mmu_idx is a two-stage regime, and EL2 present. @@ -2541,6 +2572,12 @@ static bool get_phys_addr_with_struct(CPUARMState *e= nv, S1Translate *ptw, return get_phys_addr_twostage(env, ptw, address, access_type, result, fi); } + /* fall through */ + + default: + /* Single stage and second stage uses physical for ptw. */ + ptw->in_ptw_idx =3D is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_= NS; + break; } =20 /* --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666591657; cv=none; d=zohomail.com; s=zohoarc; b=KpxJqfUF5++eRHlQkldBPMgZk+O6ivTFVkV8+8q6gUkTS2GTmDfWNykjiYmNjOm4yB7hcQtjGU6zFXYP+s0Gh2YWfkKWXfrq/87hyQqMU+VCXUwVtxyoiaUJukOyeWxjUryFPGU4I8wWBV46kcCnypw7HhVVpr8e+TCkChAMkPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666591657; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xwpoipf+qBrSAl33zLnSt6wN4K7EGIfNiIUVkyXEfCo=; b=kWXDOw+ZlL3rAU7BrjLB0I3wn9aTgLrT4IQ1kngCt4Ab7Tv1dUbD7B9bIY9twnug0QQMrd0/UCqyXhI0HNOjlgcKdgYqnB/eAUFjtVZH+d3c9Yqikf+SQGUs8AdNf9hZmNhsxfbkL8Og+ph7HwCx04UQE3wO3Kbb0fZfFpVkj60= 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 1666591657792312.115395713849; Sun, 23 Oct 2022 23:07:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompss-0007WM-Ew; Mon, 24 Oct 2022 01:20:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ompri-0006ZH-VW for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omprf-0002K8-65 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:10 -0400 Received: by mail-pf1-x42b.google.com with SMTP id f140so8141056pfa.1 for ; Sun, 23 Oct 2022 22:19:06 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=xwpoipf+qBrSAl33zLnSt6wN4K7EGIfNiIUVkyXEfCo=; b=dbfi46uB/7gS8ippsDDPhZaM5XIwv8C8/d1kVqkcpxlsE+qzNODqsqFISf9M8dQd+s gasowfX0iZwEFaTpDb6QaV1bK9WYXptzqRX7PCmLll9kAF2nDqf/0olhEO7JW532l7zj jOFEA0oLX8vkFj8kXvMRzKTTPDqylXx8zEUsLFZGR9tXFt+Zn0L4MTQ2yKiohXvsxjP9 BiEMs1t251nMEoDnbK5xD6MNyeNYSHvFsHabW/vTx56qPSOsdTZiZ0rEydj9B+r806Bs vFu8Ic879Phb6qQDxcpVjj8cKyP1JJXuJwvbS04oihKB1lpfB+Kl/Ezg9aVHntz2+I8/ jyEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=xwpoipf+qBrSAl33zLnSt6wN4K7EGIfNiIUVkyXEfCo=; b=FRP1xh2bVHcIz89sS4uSxEa6mOuUmh8F5zeOtq5Det9Jz1e7tzvrDDJOH5h+tFhvn0 XpjjQpj64GHWdD7j/K45OZ33oraiUJ5AinzTTFrhRdyEs0Epuj00iiJWsZs1nOaka68y sW73x9uMRlm+yxVidT1rfmrv4u7lU/t7fSRo6U69WFbuk08DPBVpmjhuLJ4NiXLTqZxu 84oWQTCgn+/QJEluVY+yWa1wfgg9Qdhxe16qE5ovIn3RbAbt1wyICOOfXym2STW42fO+ NaIXGu+XVg53P9jXmcKZE/kh9zHAekPg65UBb4N6tHEzFJxONXRdFrt2vTnELtUsPcqJ fH8Q== X-Gm-Message-State: ACrzQf3ozytqROTkUpMyWLYOAOrBF8w7kUzw7U2t83CeWwIyZAmdppWp JQ7A+4ds/x8X1dXC98/AuVTJCa9lbRFoRMgg X-Google-Smtp-Source: AMsMyM5w213LcCW57+hEqO3c62ln6wJFPWfeGgGYCiqN05Lp5CTlYmvCKmASV3yOahlaQbxsWely9w== X-Received: by 2002:a63:54b:0:b0:464:8e6:11e7 with SMTP id 72-20020a63054b000000b0046408e611e7mr27325447pgf.212.1666588745685; Sun, 23 Oct 2022 22:19:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 03/14] target/arm: Add isar predicates for FEAT_HAFDBS Date: Mon, 24 Oct 2022 15:18:40 +1000 Message-Id: <20221024051851.3074715-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666591658483100001 Content-Type: text/plain; charset="utf-8" The MMFR1 field may indicate support for hardware update of access flag alone, or access flag and dirty bit. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 64fc03214c..0eeb4abe53 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -4139,6 +4139,16 @@ static inline bool isar_feature_aa64_lva(const ARMIS= ARegisters *id) return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) !=3D 0; } =20 +static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) !=3D 0; +} + +static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >=3D 2; +} + static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) !=3D 0; --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666593634; cv=none; d=zohomail.com; s=zohoarc; b=IQfp8nP6hpnQL7PTE/9cQoa7hBz2puJ4HLNZo9zjKF/iF7wxa6SZVpiQI0t4IoaLZrw/XzXt9p/aNisRbQ+55JkNdMMIDzqG0sA/8ZkLNzb6x4JyZNvhl/2ItAu4LHhwkjaQ/yYlzGSikiqGQkIiR0KrwHR2vmc2arvs4ZqJpfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666593634; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ALv+diZzer09a5GMXMjosNYk9lCWFpNzZXXMnFTG3Zg=; b=RAmh2thXP1KJuVNunzyAp4Sagwri9sRvwoo4ogPQid5DiD8qFDvVPpIR0dJQugCaWIVtBrKA6UUWW3lK12Qboa4iD9atWcK+4yegiWZZrn3DazAB4r6b00rg6UJhcEOJrPOJunspQpqEa9Z5yfK2Ee3yfK/DtpT41VBDFPQ/ZdU= 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 1666593634542476.62211960668765; Sun, 23 Oct 2022 23:40:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompsm-0007NQ-2Y; Mon, 24 Oct 2022 01:20: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 1omprk-0006ZM-0b for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ompri-0002Kr-4Q for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:11 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 20so7829908pgc.5 for ; Sun, 23 Oct 2022 22:19:09 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=ALv+diZzer09a5GMXMjosNYk9lCWFpNzZXXMnFTG3Zg=; b=Z2KHSzBAkg2Xf11Snoc26pJ3BxAl+a9asBngWvnZ4nfKXr85BySTz7+awp+hZUV4H4 Ps7VmOF0gzlKaovvEpxhxgpfiHnR+YebjygBpgaAvya8dtM+CGQXZV+gWqsVkzi/soem 7jRYNyZaHPmXYOK+EN001GlKqwDcVzBGuEIgN4dNVbF3p7d1CZWkaz+gUHDdPQJCaugU 3CL/dmQfwVxNAeWY4xQx0PVbWZ4ruZcQhoIHlRHkA1fcX2xBqxt9zhWpJIAJJ5kTIS/3 R5adtZg0+UsshaABgNBMkqL0HZOvxjXuMJYTmk6Nx8hoR1sxYyhViGnkdHjN5z6mJ1Om I6Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ALv+diZzer09a5GMXMjosNYk9lCWFpNzZXXMnFTG3Zg=; b=TN98HtCTQiKI956bqsTmr/nz67R6xBas5lZUWQElZqen8RNOnpE5pkkj1i4eGssiPE i6C6XIixdz1xDUVZ5NTHDJZtCUU8+OSjruTEnQkWXYkDESqguttJgqK/Ubl/kq72WCbu sj/WBxD6sQo9aCdM5XmlK+9dzoeom53r6Ncdk1ne/tIHDwnvdRBFdcxrGcg+C0nnELjc V5ktrEJKNHwISbT6UBXe8pZ+yfeldLX52N9KufIw6k2t2fBa+eStd+LuaDTx4R8+u7id xK7LjAzm+Cp2QyMnpQvb3PktFrYs9vFgJ7kfkswZp7kpuZ7JNWZxPsChO306rS1YydLe BDcA== X-Gm-Message-State: ACrzQf1lan3wwOqKq4NwKWfsxLJ1PYD81UWiZWrGrcJL9YBt5vrKW5uA 8GhhrICfoMSSPcV0l1x2qTxAKg5CUENLYcha X-Google-Smtp-Source: AMsMyM6LXmN6OclQ4zEEErtQhstcoGRZjyi/BT0s6LouQ6w121FzM6DeA18RcFP03R2jhuwmBjjzEg== X-Received: by 2002:a63:b545:0:b0:43c:2ad9:b00 with SMTP id u5-20020a63b545000000b0043c2ad90b00mr26701098pgo.535.1666588748701; Sun, 23 Oct 2022 22:19:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 04/14] target/arm: Extract HA and HD in aa64_va_parameters Date: Mon, 24 Oct 2022 15:18:41 +1000 Message-Id: <20221024051851.3074715-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666593635530100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- target/arm/internals.h | 2 ++ target/arm/helper.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 2b6889073d..16d7989604 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1046,6 +1046,8 @@ typedef struct ARMVAParameters { bool hpd : 1; bool tsz_oob : 1; /* tsz has been clamped to legal range */ bool ds : 1; + bool ha : 1; + bool hd : 1; ARMGranuleSize gran : 2; } ARMVAParameters; =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index cbfaabbc09..6c7a8beed6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10470,7 +10470,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, ARMMMUIdx mmu_idx, bool data) { uint64_t tcr =3D regime_tcr(env, mmu_idx); - bool epd, hpd, tsz_oob, ds; + bool epd, hpd, tsz_oob, ds, ha, hd; int select, tsz, tbi, max_tsz, min_tsz, ps, sh; ARMGranuleSize gran; ARMCPU *cpu =3D env_archcpu(env); @@ -10489,6 +10489,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, epd =3D false; sh =3D extract32(tcr, 12, 2); ps =3D extract32(tcr, 16, 3); + ha =3D extract32(tcr, 21, 1) && cpu_isar_feature(aa64_hafs, cpu); + hd =3D extract32(tcr, 22, 1) && cpu_isar_feature(aa64_hdbs, cpu); ds =3D extract64(tcr, 32, 1); } else { /* @@ -10510,6 +10512,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, hpd =3D extract64(tcr, 42, 1); } ps =3D extract64(tcr, 32, 3); + ha =3D extract64(tcr, 39, 1) && cpu_isar_feature(aa64_hafs, cpu); + hd =3D extract64(tcr, 40, 1) && cpu_isar_feature(aa64_hdbs, cpu); ds =3D extract64(tcr, 59, 1); } =20 @@ -10577,6 +10581,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, .hpd =3D hpd, .tsz_oob =3D tsz_oob, .ds =3D ds, + .ha =3D ha, + .hd =3D ha && hd, .gran =3D gran, }; } --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666593150; cv=none; d=zohomail.com; s=zohoarc; b=WV0Z4McyVhLJubCkcclgwrCpTMb6gCZaJD2nrqg6RKAGwaoPCb2vaPrJMQsoXo5LNFm5Tag1KuNi9rr6dHDj3JC7QGMN5THO3+ey6DmLGe3MwlsrqH1BxmHAkdVQdX9Qag4bzQKVEe/jJaklo09z51zFdDK/Cv648SMd/hRxS5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666593150; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=TLlHtwRgdacquVuudXFbFZNQQZR2EhkDRRWKclpXGlTcwWV+CsgnTrqfzu+rHLgdZRzqtwJJ4i/LmZVTvurNEoIJXLGlU6GKYzuMHJzyiA6PgjuInUFkgzZ79NzVnFMEy+n25tAQ06q/NVcD2XzWpD3cKSMHCQJb2WELKFd+zNQ= 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 1666593150014622.4987606182475; Sun, 23 Oct 2022 23:32:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompsn-0007Pc-9F; Mon, 24 Oct 2022 01:20:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ompro-0006aj-R3 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omprl-0002La-8V for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:14 -0400 Received: by mail-pj1-x1035.google.com with SMTP id m2so3321783pjr.3 for ; Sun, 23 Oct 2022 22:19:12 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=IfYYdXX5BP6H2RKB06MWo2FGklxdm07IL/N5UXRPwLBGTAEP0hqm7919yy3GVGqKjd uaD75kv6DQqxgbZf5VyT0kdfFeTX2Cw4eOAkIIg9ITJdmArWCGyKJcTqEsH6R69cslJy oruTjvQQqUYgs0jrjaXKqb5smIVyxVJwENHfbH8Q7sUgbu2CgUGIXLJbA4gErK1KHQH8 tcxw6VuFgGhQuYc69C//SKX4J9c/07HSugvm/2EVoVAZmRfEQTOAjKPBYWlWnyNrEKw3 AYPSnVcrBCBI1F03zgDwWtz7ZqBnlmB0lzLFLnRN4GPSuYZ86Q5tcAqu9b6HFA06VtdS yIeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=Q9u/CTbpsuyt+vL/yIxrL5pNR478Gk+hKHZIa5AENgq+5hU80mnwf7hSfVzlMs51K3 dSNmPqnC2cbCUUVsCEmrGpOEq4xED6GZ10V0OiBbcYelPZrGYuoDwdZ2awOU6PsVJTmB h4Ku79CS8PsTX/4sN2yuGfYhqSSwWqQUViLPw1KEmIxn1L98Oezw0BZTVV1vw+mGEqb7 rTVAfmSSmapAuliIF88+ocsBWJeXcP9NUhtZUe5JRVlfY13OMzxYL0xtiJoSohMfJnD7 NcXp6cW1qoWS0vUE8l3m+JEORZmRKfcDZNqQvqPsDVabCzK7gDv+VHZEX1PGTtNuW7p4 kojg== X-Gm-Message-State: ACrzQf2YmDessKD80gzXToAZLF6BxAhK/h8u92m6heqaTXllFB1Nq+Zc cpGBj2Gj3NKb+PELry/rWOMl5da62cwddWOB X-Google-Smtp-Source: AMsMyM7pvFvFpRNMM5cnT2xW2vSFpIYMp9+eKhf6DDzFizDr2DkJwjDGQrk5fx8S3ombY4NeG3gXEw== X-Received: by 2002:a17:903:283:b0:186:8a20:c1b6 with SMTP id j3-20020a170903028300b001868a20c1b6mr10784768plr.119.1666588751667; Sun, 23 Oct 2022 22:19:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 05/14] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw Date: Mon, 24 Oct 2022 15:18:42 +1000 Message-Id: <20221024051851.3074715-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666593151077100001 Content-Type: text/plain; charset="utf-8" Separate S1 translation from the actual lookup. Will enable lpae hardware updates. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 161b7922e3..36524b35ef 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -319,18 +319,12 @@ static bool S1_ptw_translate(CPUARMState *env, S1Tran= slate *ptw, } =20 /* All loads done in the course of a page table walk go through here. */ -static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, hwaddr add= r, +static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); uint32_t data; =20 - if (!S1_ptw_translate(env, ptw, addr, fi)) { - /* Failure. */ - assert(fi->s1ptw); - return 0; - } - if (likely(ptw->out_host)) { /* Page tables are in RAM, and we have the host address. */ if (ptw->out_be) { @@ -358,18 +352,12 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Trans= late *ptw, hwaddr addr, return data; } =20 -static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, hwaddr add= r, +static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); uint64_t data; =20 - if (!S1_ptw_translate(env, ptw, addr, fi)) { - /* Failure. */ - assert(fi->s1ptw); - return 0; - } - if (likely(ptw->out_host)) { /* Page tables are in RAM, and we have the host address. */ if (ptw->out_be) { @@ -526,7 +514,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Trans= late *ptw, fi->type =3D ARMFault_Translation; goto do_fault; } - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -564,7 +555,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Trans= late *ptw, /* Fine pagetable. */ table =3D (desc & 0xfffff000) | ((address >> 8) & 0xffc); } - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -649,7 +643,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Trans= late *ptw, fi->type =3D ARMFault_Translation; goto do_fault; } - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -702,7 +699,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Trans= late *ptw, ns =3D extract32(desc, 3, 1); /* Lookup l2 entry. */ table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -1291,7 +1291,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, ptw->in_ptw_idx &=3D ~1; ptw->in_secure =3D false; } - descriptor =3D arm_ldq_ptw(env, ptw, descaddr, fi); + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor =3D arm_ldq_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666592449; cv=none; d=zohomail.com; s=zohoarc; b=J5yB0qhGbykgVF+EjcBymraB11B1gpmNz7JMcc+EwuyNDoVgSPNEFa5RGOxW1y5gbAIppj7sMfC0IulJ24iJwEMsfXDXxSw46n/jeCZgpVJXqo75cT9azwcaWcIHxnKf1nBz/O3rFRzUDZUudlBElUHD4KQvghAkKJ5W/PyhuzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666592449; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GPM9sD1J7LDvJDVQg9T/5F8YfP6ZpygL4aiMX7D6XJM=; b=jibBrk7S29MTnwfExfrhejFqUCNRN07SxSKmxrShb8VxEM7NdXAJA17Uk2yyOXNamyRkd5u1fqTvePtPsFrm30gWDqw6d+NveY67Oy1322E2Q0uHg8m1UljQvImIWkBwgakdZutC4QNIvSebiszgQQlpH+PUvJMvxnnU5tnaZ2U= 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 1666592449890984.1429881739082; Sun, 23 Oct 2022 23:20:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompsl-0007Hf-5K; Mon, 24 Oct 2022 01:20: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 1omprq-0006ao-3p for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ompro-0002Lx-J8 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:17 -0400 Received: by mail-pj1-x1030.google.com with SMTP id s22-20020a17090a075600b002130d2ad62aso1427550pje.2 for ; Sun, 23 Oct 2022 22:19:15 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=GPM9sD1J7LDvJDVQg9T/5F8YfP6ZpygL4aiMX7D6XJM=; b=Gc+bfP7hYkUTJ+yugL1DD4jgWGnArJcfNgDWIyBKeRJYwe7nJHPumH5qiawiX7vXQo IG+lACOkU8vEFz5ec/mVIRTTeWE6cugAMrokbkm3QZr0nxr/VfavawXmSZZtSmd6BOJV gXD8prEZxBob2u/Ad7P9XDSs8cohdlnq3KrgLS8oZdEw2LfU+odkLCeNX4rmqcT+hSA6 eK1GJb2DftzMUaK1N0QyYynkqDwSL04CWXmH/M3VoxZqOO+YRO6EgxtK8hZZAhwYklf5 2UnD4uFVI9XGxJim/WWvth8fM7QiX1mnb1dW9p8fXYL0SzUiFtB3HmWWZWg4akI/ydUQ cawQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GPM9sD1J7LDvJDVQg9T/5F8YfP6ZpygL4aiMX7D6XJM=; b=Nk9C8XUbi1nzQCmm8YtP1TE6cX4bnCXpNqdMvgbitKmbijaJBT1nKRSHHLuXEA86LC K8n7F3xCLxw/nML2Bmm86xO+wMYH+ueSkphCNn+KF6wTRO1RXhjxwJ/k6xFYu3eiTd3f Oom+h0n1BfK8rI7cpQkZPe5wU5d0AeFouyNkBqxJfxcKLoVQbEOPZum6qw2fOom4nhgb fu1PzQw+f+ZqNLd74UyK8lPRNtIlz6jVeuoITkYbsdC8J+pTZ1D31Zb0oJYF5RHZQwga X2kaVaV5+Zgto+pj4VKd/E1Jlowf/0Nk2Yv6mJAzW0HiD6BTZnURXe/FyPtJuvF6ZlJQ GTpw== X-Gm-Message-State: ACrzQf2FNFH9sqyNqDk4JZ/QBt3x3a+FU1Z2QyOOpXd3UdJwzuSLA9sO 2jITVuTSK0BfETBV9w0YNiTwU+BkJiCKCjjs X-Google-Smtp-Source: AMsMyM5XftKtrUz9t3jc2z0Nv5oGhP3rIvEU5lA9H+//lE72IrvcwTpWMflwLxkUM9iRhv4d8PphEg== X-Received: by 2002:a17:90a:29e4:b0:20a:f9d5:c10e with SMTP id h91-20020a17090a29e400b0020af9d5c10emr73461562pjd.132.1666588754644; Sun, 23 Oct 2022 22:19:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 06/14] target/arm: Add ARMFault_UnsuppAtomicUpdate Date: Mon, 24 Oct 2022 15:18:43 +1000 Message-Id: <20221024051851.3074715-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666592451165100001 Content-Type: text/plain; charset="utf-8" This fault type is to be used with FEAT_HAFDBS when the guest enables hw updates, but places the tables in memory where atomic updates are unsupported. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- target/arm/internals.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 16d7989604..a5ef5f6054 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -338,6 +338,7 @@ typedef enum ARMFaultType { ARMFault_AsyncExternal, ARMFault_Debug, ARMFault_TLBConflict, + ARMFault_UnsuppAtomicUpdate, ARMFault_Lockdown, ARMFault_Exclusive, ARMFault_ICacheMaint, @@ -524,6 +525,9 @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *= fi) case ARMFault_TLBConflict: fsc =3D 0x30; break; + case ARMFault_UnsuppAtomicUpdate: + fsc =3D 0x31; + break; case ARMFault_Lockdown: fsc =3D 0x34; break; --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666593564; cv=none; d=zohomail.com; s=zohoarc; b=JF1Ro2+7uhsRXZcj8esW+vakDo9u8vU1szAguXWZZKVP/mtAPpqcK/lN+kr5Nm+n+yLdX/rOdynoaLYNLjt6KoDgINVhom+cz6bQavA5BWlnh6k2lZvcsQJE9i863jt32rgsFFi8DDi9PRERSD8lgRmYvmKMRj7INuA2fyQLMEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666593564; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/GiKSj2DI/fM8k5gjQPIZReGKnYnqJ3VPV7yF0e0HWE=; b=NKMn/DLCXOmSR7xUDwiSeAagLTOIA+B0/2JfqMYbVLbvN3MbvpPZN54ygj721QdZqsJoyRBq8pbkVi4oO3g9epwA7xddl2GxjjNJopb/BFnzfAY+bZDCDMT1hm521rVicpJo4ZfzwTakxez4JXtjm7US2D0lnDoNtjIwKDWj7Lw= 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 166659356427291.60257324042288; Sun, 23 Oct 2022 23:39:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompsq-0007Ts-Jr; Mon, 24 Oct 2022 01:20: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 1omprt-0006cG-FM for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:21 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omprq-0002NY-QM for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -0400 Received: by mail-pf1-x430.google.com with SMTP id g16so2677445pfr.12 for ; Sun, 23 Oct 2022 22:19:18 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=/GiKSj2DI/fM8k5gjQPIZReGKnYnqJ3VPV7yF0e0HWE=; b=QYO+VEO8fbfNr2JY9OFpe90J6FHqGZOGl65keY3OMjec7Kobfrj9EJx3+MVvU42wmt zPsX+fL9OELfTIuFyzptmt8Mlrvyt4KPfMHOMKZ308SIxh6Q82k3wWkpq8G1Qf5CNzSR 3m4M81RESX9fbc9+vb0zoIt0QZs4pGeqylHDrQ3WDHawHNaiWo7rklKJ59a23u4boxhU oEvjFzdIWXh2zSixkHVsBFY2R9KJS/159ODxhHjg31FULWDPSrfE9Vdx75Z56rvunT90 2GfPx3g2ApA8NDj/IcdGspTgckgXsRmzLVILKQWrsUL3ob2s6ncoz0W8JruZ2IvyI4Nz 00SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/GiKSj2DI/fM8k5gjQPIZReGKnYnqJ3VPV7yF0e0HWE=; b=UaYhuNRQs10aok2dMY7Xs5bkRzeaSaF0eFa1xHQN93KS8qbM+WGfbJxge2DjGqSY78 FEWa/1EHEwDiBsNyzj51HVhxWq6IV3861XjZVHu5ahf2uLFSHurbrds5D31pHpzXlBfp AxHEPti29gJw7triXTgadCVBEwzoxLzpf0F91cjPR2LIklDdUAT6IER2pdxNvfZSWf/p e2pVv1/VrHD2i0ph+byORSKUwnRHBKicQOXd30ScpdeuV2UQ9XgnNShqKVKtoXmPzvxe qKR5rd/F0MoQCkCP9/pO3io2Qcv/UpNwFKWavK4HlfT+6NeZe9zNEHQ4bS21FoAImamA UW+A== X-Gm-Message-State: ACrzQf2OE55/FNGbfGz4Cc7dt8HgvSpOrqZa1/oR1s8xPMyhe1vAJpC6 X3oPwKh7ZTCvZFLh5KnQAlNHF5N738FZZ/wP X-Google-Smtp-Source: AMsMyM6kWo1UyB0ULwuDzAocZgnKYgfnmBwPsZBxAv/EsVlTWysc7HUivsBu4O7InMJfjKL5+UAP2A== X-Received: by 2002:a63:3fce:0:b0:45a:2bab:6002 with SMTP id m197-20020a633fce000000b0045a2bab6002mr27214309pga.454.1666588757369; Sun, 23 Oct 2022 22:19:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 07/14] target/arm: Remove loop from get_phys_addr_lpae Date: Mon, 24 Oct 2022 15:18:44 +1000 Message-Id: <20221024051851.3074715-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666593565313100003 Content-Type: text/plain; charset="utf-8" The unconditional loop was used both to iterate over levels and to control parsing of attributes. Use an explicit goto in both cases. While this appears less clean for iterating over levels, we will need to jump back into the middle of this loop for atomic updates, which is even uglier. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 192 +++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 36524b35ef..615471699e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1080,6 +1080,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); bool guarded =3D false; + uint64_t descriptor; + bool nstable; =20 /* TODO: This code does not support shareability levels. */ if (aarch64) { @@ -1272,106 +1274,104 @@ static bool get_phys_addr_lpae(CPUARMState *env, = S1Translate *ptw, * bits at each step. */ tableattrs =3D is_secure ? 0 : (1 << 4); - for (;;) { - uint64_t descriptor; - bool nstable; - - descaddr |=3D (address >> (stride * (4 - level))) & indexmask; - descaddr &=3D ~7ULL; - nstable =3D extract32(tableattrs, 4, 1); - if (!nstable) { - /* - * Stage2_S -> Stage2 or Phys_S -> Phys_NS - * Assert that the non-secure idx are even, and relative order. - */ - QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) !=3D 0); - QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) !=3D 0); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 !=3D ARMMMUIdx_Phys_S); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 !=3D ARMMMUIdx_Stage2_S= ); - ptw->in_ptw_idx &=3D ~1; - ptw->in_secure =3D false; - } - if (!S1_ptw_translate(env, ptw, descaddr, fi)) { - goto do_fault; - } - descriptor =3D arm_ldq_ptw(env, ptw, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - - if (!(descriptor & 1) || - (!(descriptor & 2) && (level =3D=3D 3))) { - /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; - } - - descaddr =3D descriptor & descaddrmask; =20 + next_level: + descaddr |=3D (address >> (stride * (4 - level))) & indexmask; + descaddr &=3D ~7ULL; + nstable =3D extract32(tableattrs, 4, 1); + if (!nstable) { /* - * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] - * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of - * descaddr are in [9:8]. Otherwise, if descaddr is out of range, - * raise AddressSizeFault. + * Stage2_S -> Stage2 or Phys_S -> Phys_NS + * Assert that the non-secure idx are even, and relative order. */ - if (outputsize > 48) { - if (param.ds) { - descaddr |=3D extract64(descriptor, 8, 2) << 50; - } else { - descaddr |=3D extract64(descriptor, 12, 4) << 48; - } - } else if (descaddr >> outputsize) { - fault_type =3D ARMFault_AddressSize; - goto do_fault; - } - - if ((descriptor & 2) && (level < 3)) { - /* - * Table entry. The top five bits are attributes which may - * propagate down through lower levels of the table (and - * which are all arranged so that 0 means "no effect", so - * we can gather them up by ORing in the bits at each level). - */ - tableattrs |=3D extract64(descriptor, 59, 5); - level++; - indexmask =3D indexmask_grainsize; - continue; - } - /* - * Block entry at level 1 or 2, or page entry at level 3. - * These are basically the same thing, although the number - * of bits we pull in from the vaddr varies. Note that although - * descaddrmask masks enough of the low bits of the descriptor - * to give a correct page or table address, the address field - * in a block descriptor is smaller; so we need to explicitly - * clear the lower bits here before ORing in the low vaddr bits. - */ - page_size =3D (1ULL << ((stride * (4 - level)) + 3)); - descaddr &=3D ~(hwaddr)(page_size - 1); - descaddr |=3D (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs =3D extract64(descriptor, 2, 10) - | (extract64(descriptor, 52, 12) << 10); - - if (regime_is_stage2(mmu_idx)) { - /* Stage 2 table descriptors do not include any attribute fiel= ds */ - break; - } - /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 3; /* NS */ - guarded =3D extract64(descriptor, 50, 1); /* GP */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - break; - } - attrs |=3D extract32(tableattrs, 0, 2) << 11; /* 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 ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> = AP[1] */ - attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> A= P[2] */ - break; + QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) !=3D 0); + QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) !=3D 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 !=3D ARMMMUIdx_Phys_S); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 !=3D ARMMMUIdx_Stage2_S); + ptw->in_ptw_idx &=3D ~1; + ptw->in_secure =3D false; } + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor =3D arm_ldq_ptw(env, ptw, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + + if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { + /* Invalid, or the Reserved level 3 encoding */ + goto do_fault; + } + + descaddr =3D descriptor & descaddrmask; + + /* + * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] + * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of + * descaddr are in [9:8]. Otherwise, if descaddr is out of range, + * raise AddressSizeFault. + */ + if (outputsize > 48) { + if (param.ds) { + descaddr |=3D extract64(descriptor, 8, 2) << 50; + } else { + descaddr |=3D extract64(descriptor, 12, 4) << 48; + } + } else if (descaddr >> outputsize) { + fault_type =3D ARMFault_AddressSize; + goto do_fault; + } + + if ((descriptor & 2) && (level < 3)) { + /* + * Table entry. The top five bits are attributes which may + * propagate down through lower levels of the table (and + * which are all arranged so that 0 means "no effect", so + * we can gather them up by ORing in the bits at each level). + */ + tableattrs |=3D extract64(descriptor, 59, 5); + level++; + indexmask =3D indexmask_grainsize; + goto next_level; + } + + /* + * Block entry at level 1 or 2, or page entry at level 3. + * These are basically the same thing, although the number + * of bits we pull in from the vaddr varies. Note that although + * descaddrmask masks enough of the low bits of the descriptor + * to give a correct page or table address, the address field + * in a block descriptor is smaller; so we need to explicitly + * clear the lower bits here before ORing in the low vaddr bits. + */ + page_size =3D (1ULL << ((stride * (4 - level)) + 3)); + descaddr &=3D ~(hwaddr)(page_size - 1); + descaddr |=3D (address & (page_size - 1)); + /* Extract attributes from the descriptor */ + attrs =3D extract64(descriptor, 2, 10) + | (extract64(descriptor, 52, 12) << 10); + + if (regime_is_stage2(mmu_idx)) { + /* Stage 2 table descriptors do not include any attribute fields */ + goto skip_attrs; + } + /* Merge in attributes from table descriptors */ + attrs |=3D nstable << 3; /* NS */ + guarded =3D extract64(descriptor, 50, 1); /* GP */ + if (param.hpd) { + /* HPD disables all the table attributes except NSTable. */ + goto skip_attrs; + } + attrs |=3D extract32(tableattrs, 0, 2) << 11; /* 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 ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> AP[1= ] */ + attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> AP[2]= */ + skip_attrs: + /* * Here descaddr is the final physical address, and attributes * are all in attrs. --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666592258; cv=none; d=zohomail.com; s=zohoarc; b=XIHX9egxBd5JRsDZbM8PhwPbJSg/So4JJqrbH/41Px83Dp4zYE1STElGDerctTThcSK+4c2AzhKLLfCYEcd85//9zVeAYYfY3vAG25L9VMX92vNb/Y3Y4fSg6swl6ga6jl6+UgWwPGLPq97GbFMprAcKeboF4joepSuZI07FDIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666592258; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sdisIrMnl1TYgX+y3Jca2Lvj3mz6slgwmrdpC7jGGrw=; b=dppW6knPHNk4aYMm6Vmy/M2UhYsajYY+/Us8Ldi1mue737OOfF6re0yaBdxOhkctNySLXMjyhfqR6r9MMUvU0yBdn0TPKpa7pXmqZSwNKAeU72+Vud8GQEXydKGA58+IqXFQ09ecOjS8q0I+mg0gXYFRp+842U4LWfgfw8HKfXg= 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 1666592258787170.85322700096071; Sun, 23 Oct 2022 23: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 1omptE-000846-21; Mon, 24 Oct 2022 01:20: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 1omprw-0006fC-Jk for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:26 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ompru-0002OR-G9 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:24 -0400 Received: by mail-pj1-x1032.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso2948829pjg.5 for ; Sun, 23 Oct 2022 22:19:22 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=sdisIrMnl1TYgX+y3Jca2Lvj3mz6slgwmrdpC7jGGrw=; b=og12VUipEK1VY49HsgdcCA8e760wa1EattPTpkBogRteWDTlOIF45jSPqVT9Vy9wt8 dXFaaKD1DN4/4b8QTxh8jsnx2KUsC7epVNBkE/hmDFVBmflO0qk7x0hC8A8NadIFTqeX WBd1LqdcswlNz+Wx8Neqs+NMFuvUZjj1pIJ2x+/8i9K9300RxfxWam0UZbAbkPFZNRyH CUJyONjkyGUBcDM/Uh4AjAnJHl9O7IIx82X+5UeZfPBLgPMBB5gryvr2Rz9iWgLPykPW MCpZAZYX1UrPJ+i4xRVOhwQoZ7ibxubynoap2r1sfruslhvzK9PqiGsuqYtkI3PUX+4A Xbpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=sdisIrMnl1TYgX+y3Jca2Lvj3mz6slgwmrdpC7jGGrw=; b=BDFaFT4Maq6wAS2HpvBKxDQ6w3B1UUiuJ4Oud1vF3LCZvmfB7zarQ56GzcWs/RzfXS 0jDtjVx/od9LH8BUB8WBUu1a4ZR8nExhbeldgN415AkU23N8qQnyCLnSNvZ4otcbdKl/ 0YJhZOhw1s5dpBH2Rx2z3gYFkKXF3xs0YebtJwyebWX3+Y4X5oycTtWpvJWAKGB67p7Z VU8KjJn7hcqtqQz+O6AKSF+Wx6VOIkVa+IaA8sMI6flCv0ofbGMWmmLrmJ/c9LbPId9j PaNXjPUa9ZfzKnKOjlc/8lmRSpkdPxnEvAOwVJBiEvRBMM1RCr+fUQXPej4Cy8i0mmrC TKDg== X-Gm-Message-State: ACrzQf0RxecfwkKEkLaWvKMRclElC0KwDnpTdBHOxF/M2HZE2IrWBq1H /Y7EGamwyq/WINkNcMNoKSxOuC5SA52VIdIJ X-Google-Smtp-Source: AMsMyM7ILcxOCL/EICGbYfz98KtMwHOrcupsyTvXhfCsT2TKJ0Hz/MkPrH3sNPOaJLpPqyh16Vtdvw== X-Received: by 2002:a17:90b:4c48:b0:20d:5c55:b8a8 with SMTP id np8-20020a17090b4c4800b0020d5c55b8a8mr37161938pjb.207.1666588760266; Sun, 23 Oct 2022 22:19:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 08/14] target/arm: Fix fault reporting in get_phys_addr_lpae Date: Mon, 24 Oct 2022 15:18:45 +1000 Message-Id: <20221024051851.3074715-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666592260561100001 Content-Type: text/plain; charset="utf-8" Always overriding fi->type was incorrect, as we would not properly propagate the fault type from S1_ptw_translate, or arm_ldq_ptw. Simplify things by providing a new label for a translation fault. For other faults, store into fi directly. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- target/arm/ptw.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 615471699e..cd16b42c96 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1063,8 +1063,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, ARMCPU *cpu =3D env_archcpu(env); ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; bool is_secure =3D ptw->in_secure; - /* Read an LPAE long-descriptor translation table. */ - ARMFaultType fault_type =3D ARMFault_Translation; uint32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1101,8 +1099,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * so our choice is to always raise the fault. */ if (param.tsz_oob) { - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } =20 addrsize =3D 64 - 8 * param.tbi; @@ -1139,8 +1136,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, addrsize - inputsize); if (-top_bits !=3D param.select) { /* The gap between the two regions is a Translation fault */ - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } } =20 @@ -1166,7 +1162,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * Translation table walk disabled =3D> Translation fault on TLB m= iss * Note: This is always 0 on 64-bit EL2 and EL3. */ - goto do_fault; + goto do_translation_fault; } =20 if (!regime_is_stage2(mmu_idx)) { @@ -1197,8 +1193,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (param.ds && stride =3D=3D 9 && sl2) { if (sl0 !=3D 0) { level =3D 0; - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } startlevel =3D -1; } else if (!aarch64 || stride =3D=3D 9) { @@ -1217,8 +1212,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, inputsize, stride, outputsize); if (!ok) { - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } level =3D startlevel; } @@ -1240,7 +1234,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, descaddr |=3D extract64(ttbr, 2, 4) << 48; } else if (descaddr >> outputsize) { level =3D 0; - fault_type =3D ARMFault_AddressSize; + fi->type =3D ARMFault_AddressSize; goto do_fault; } =20 @@ -1301,7 +1295,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; + goto do_translation_fault; } =20 descaddr =3D descriptor & descaddrmask; @@ -1319,7 +1313,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, descaddr |=3D extract64(descriptor, 12, 4) << 48; } } else if (descaddr >> outputsize) { - fault_type =3D ARMFault_AddressSize; + fi->type =3D ARMFault_AddressSize; goto do_fault; } =20 @@ -1376,9 +1370,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * Here descaddr is the final physical address, and attributes * are all in attrs. */ - fault_type =3D ARMFault_AccessFlag; if ((attrs & (1 << 8)) =3D=3D 0) { /* Access flag */ + fi->type =3D ARMFault_AccessFlag; goto do_fault; } =20 @@ -1395,8 +1389,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, p= xn); } =20 - fault_type =3D ARMFault_Permission; if (!(result->f.prot & (1 << access_type))) { + fi->type =3D ARMFault_Permission; goto do_fault; } =20 @@ -1441,8 +1435,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.lg_page_size =3D ctz64(page_size); return false; =20 -do_fault: - fi->type =3D fault_type; + do_translation_fault: + fi->type =3D ARMFault_Translation; + do_fault: fi->level =3D level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ fi->stage2 =3D fi->s1ptw || regime_is_stage2(mmu_idx); --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666589089; cv=none; d=zohomail.com; s=zohoarc; b=bt0oCUA2QaZcKt1Bnnam5ja7dvJw5H/AowT6iuFRSFtv1lYJm9oq0p8aT8c8h8Z4VnvRaBJk0fRn2PYhcxw9MGG3uaDM+HP7KftKUjpdvioXjIxBwWj7LM/kTvGplFrQ4q/PT8ZpNmEtdZqLQ2I4Ha6oPUbNH69Om1ymlvIhI2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666589089; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5O6PpkAZ96UkPrcZ1NBYigHKXmNVYdvvRThaoFMyO3o=; b=Xm7geGVA96DH4yD3AorPBr8LiCpkTqcILM4uXChfTqkBvTRfQZnM6H7nEPgZe3zchSwVCLxyk4GndydGApFmtxWPl8A7x2Auz3QOyw32kdThi2fbFGTDtMm4M6LEEU8c9vXgdIrFCVinGDrMrddY8D9HprxhxGAfUksm91w5kDg= 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 1666589089082832.2355137021863; Sun, 23 Oct 2022 22:24:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omptF-00087J-2b; Mon, 24 Oct 2022 01:20: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 1omps8-0006rK-Ef for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:39 -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 1omprw-0002Os-Dd for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:36 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d24so7589257pls.4 for ; Sun, 23 Oct 2022 22:19:23 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=5O6PpkAZ96UkPrcZ1NBYigHKXmNVYdvvRThaoFMyO3o=; b=a3ka5AeCtPXpyHHO1XJP+Xs35zsvC764YXj1oqUoIXmeH1fF1nxfeK7hkK/0f072Em M0wa1jqhgt53gM3xFa7qn/zQ0At5c5cDspftFNSl39Ml2Ew+s4RRkpDZ+HOQdBTc47Zt WxgEOWDmhISmYECkOoaEOUX6MhvRuePLan27qs8ICcnBc0yaX5SqwdqytGJ9vdjAu1IV LaJvme5V2MfVIVqBxtLeeFWWxlsfqIUljirVK2kwQghbDHgHXXTOHPOAVy0qiWqirY1d cvQiC1u06/onNssyXRQoa7i+rnzIZFGjXN/VKTFKlAVOMiRPr29OY0P9iCJA8qYleK6z 6fmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5O6PpkAZ96UkPrcZ1NBYigHKXmNVYdvvRThaoFMyO3o=; b=njwPBOATFCbbkpyikR76AqcYgv/YEP33mHcQECHFWUWlwbrqFWVvAMKq0cuKSLLgLw Viqr88LehZbH/NXfb3GoHS4ACJI4fYzLbg4qle1JppEBfIyKh8XGaQ6hOrq3INwgA0io mq8oX0INA0WcAM2zSjWJP2hGB4D2ny8eqoRyX0oPiuqGbMaRUDe63s7Abz4xVLstZuSy L/aYFkFInqf46dlb26fn57Iq3ssl0ZLNta1EGnAowA4QyfBl7Mx0gj0EzqYL91IpCHT6 pNtNdKU4nZFmAEJPY5oYa/PT5ca0AzZfajEA8ClAGxWX3W5G8QVFlHiVw4fNbTtAHduB b80w== X-Gm-Message-State: ACrzQf2pW+qmzeCNN2GfIuqtVCHzTa0xr90oHjDINuN+dnr98Iilonkv N7aYtE3pPEOTe1hovx7lLDd+Prtrq/pBCY2R X-Google-Smtp-Source: AMsMyM61isjymFdqBEUtPExs1U1AbZLeU2dbdi/KE+u6ME7+aURak0MwbzZyN//E2abcU5ifx6Lc2Q== X-Received: by 2002:a17:903:22cb:b0:186:a8ae:d0ff with SMTP id y11-20020a17090322cb00b00186a8aed0ffmr3610864plg.71.1666588763061; Sun, 23 Oct 2022 22:19:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 09/14] target/arm: Don't shift attrs in get_phys_addr_lpae Date: Mon, 24 Oct 2022 15:18:46 +1000 Message-Id: <20221024051851.3074715-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666589089743100001 Content-Type: text/plain; charset="utf-8" Leave the upper and lower attributes in the place they originate from in the descriptor. Shifting them around is confusing, since one cannot read the bit numbers out of the manual. Also, new attributes have been added which would alter the shifts. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/ptw.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index cd16b42c96..cc7751218c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1069,7 +1069,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, hwaddr descaddr, indexmask, indexmask_grainsize; uint32_t tableattrs; target_ulong page_size; - uint32_t attrs; + uint64_t attrs; int32_t stride; int addrsize, inputsize, outputsize; uint64_t tcr =3D regime_tcr(env, mmu_idx); @@ -1343,49 +1343,48 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); /* Extract attributes from the descriptor */ - attrs =3D extract64(descriptor, 2, 10) - | (extract64(descriptor, 52, 12) << 10); + attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 1= 2)); =20 if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fields */ goto skip_attrs; } /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 3; /* NS */ + attrs |=3D nstable << 5; /* NS */ guarded =3D extract64(descriptor, 50, 1); /* GP */ if (param.hpd) { /* HPD disables all the table attributes except NSTable. */ goto skip_attrs; } - attrs |=3D extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ + 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 ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> AP[1= ] */ - attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> AP[2]= */ + attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D> AP[1= ] */ + attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D> AP[2]= */ skip_attrs: =20 /* * Here descaddr is the final physical address, and attributes * are all in attrs. */ - if ((attrs & (1 << 8)) =3D=3D 0) { + if ((attrs & (1 << 10)) =3D=3D 0) { /* Access flag */ fi->type =3D ARMFault_AccessFlag; goto do_fault; } =20 - ap =3D extract32(attrs, 4, 2); + ap =3D extract32(attrs, 6, 2); =20 if (regime_is_stage2(mmu_idx)) { ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; - xn =3D extract32(attrs, 11, 2); + xn =3D extract64(attrs, 53, 2); result->f.prot =3D get_S2prot(env, ap, xn, s1_is_el0); } else { - ns =3D extract32(attrs, 3, 1); - xn =3D extract32(attrs, 12, 1); - pxn =3D extract32(attrs, 11, 1); + ns =3D extract32(attrs, 5, 1); + xn =3D extract64(attrs, 54, 1); + pxn =3D extract64(attrs, 53, 1); result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, p= xn); } =20 @@ -1410,10 +1409,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, =20 if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format =3D true; - result->cacheattrs.attrs =3D extract32(attrs, 0, 4); + result->cacheattrs.attrs =3D extract32(attrs, 2, 4); } else { /* Index into MAIR registers for cache attributes */ - uint8_t attrindx =3D extract32(attrs, 0, 3); + uint8_t attrindx =3D extract32(attrs, 2, 3); uint64_t mair =3D env->cp15.mair_el[regime_el(env, mmu_idx)]; assert(attrindx <=3D 7); result->cacheattrs.is_s2_format =3D false; @@ -1428,7 +1427,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (param.ds) { result->cacheattrs.shareability =3D param.sh; } else { - result->cacheattrs.shareability =3D extract32(attrs, 6, 2); + result->cacheattrs.shareability =3D extract32(attrs, 8, 2); } =20 result->f.phys_addr =3D descaddr; --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666592075; cv=none; d=zohomail.com; s=zohoarc; b=BZcQy54dEibOvXhGK2cchXsDK59+4fgZIt3Nnji+ogmxCeGJttjO8F+3hX6jIzxc2GN9ctIPD+rwA1oUrQYubB74mKIVBpRapYOi4IOfSA3WY/azPYLu8uMJrjL4Z+S/lHGZ5gWibfqWFiG1cR2RJ9GNuOqHHm2VbmvqnaIbfvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666592075; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IWw+aq7JNeHsl9fq/os7SQInlY545GVW3QOnHQy7rg0=; b=YLpUeYsTUxCu0ufjO4DmVX49MitdVMyAVbPM0UnJLG9VFbgOCx+LbwQ/vp+5gkfBY32D4HukWf3BKnDNTkHsy07nqGtio9Xl7trU39EnYEVG5Bh3etjEH2VeuVO7hxNmxUKRJ6ckVBmNM+yDsNt1xAuiZ2iUj4LXUJTBN3qViJ4= 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 166659207504086.31765290517694; Sun, 23 Oct 2022 23: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 1ompsv-0007ZI-42; Mon, 24 Oct 2022 01:20: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 1omps9-0006rR-Lh for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:39 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omps8-0002PU-0w for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:37 -0400 Received: by mail-pf1-x430.google.com with SMTP id m6so8169008pfb.0 for ; Sun, 23 Oct 2022 22:19:27 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=IWw+aq7JNeHsl9fq/os7SQInlY545GVW3QOnHQy7rg0=; b=zClpVoaHHqvDQGxHaG61TifYrcxiBqg/7hR7bhQ6rq57WCCFDvjg6nyP05HOvD0r9r Tvd8jNuMd0v7C6H1CegQnSO+bqlls2w+m5ZTMWBaTb2rtikAh3RdO64jB8BNGJrSQgj8 fJw7Zd4B/sX3Xhuzv0gyTjH/NqHLO81iuBRGuy+eJxiGIPnfaC6XWv4eb+v74B3zWtEF kfqbwf+/l1PbY6Puv4LDCs/W6kTu1U5C9/Xs0cAXYEDe4ttyEUml+NrQMHDXxYEd4Dxy CzyFAbC/b8lDWOqz+vrCM5SNAE3HjxF5WlUvAcVi7izmsrTX/XHjQ5QT+p58STF1EcWo 72WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=IWw+aq7JNeHsl9fq/os7SQInlY545GVW3QOnHQy7rg0=; b=7KBeMQH7AV8/HEAi8d9UN3dGAkVBu5hR42kWzFFM17Fd5shh9X368cenqt7XSR8r+b /PKRflaWnSoQZ8LydznQWFgtVo3qPHVLgBu0i0unRPJ97QG+OD6EAy/EDdaLbdy/qXtd yOBMm8Dx5oaZjm55sDFsW97sMv3I77WfZ0wMw6WU2J6jsvQRAKbgN9ZDiTvisp/jBe5h pcduO+Zue7PsLA+QVTQMSGmOgNH5TRuZH3hHmW6DH//eqF+7kznOIP/C5ynIZgp8Gd0H W5p6NA5WwiTerpIp/M1Czpvx+tnOr+OXMKb+b3uJJW+X3fyYhTX2lp+PNE8N10ie+Kfj gyPA== X-Gm-Message-State: ACrzQf2aqc/I4idO31awAP9vEbXqxqUYZ6qF1Qe8f0lww6gilejYfefe iL1saIPBFP+CUsJDVpdk7WYmyLz7uMxI3ll/ X-Google-Smtp-Source: AMsMyM6sCvZg5MoWnZwannvG3QucH+3t+a+hehibnrSzien5LR0wdgYYt0aXDdj+KAsdDESXb/vUHw== X-Received: by 2002:a05:6a02:282:b0:439:7a97:ccd with SMTP id bk2-20020a056a02028200b004397a970ccdmr27308494pgb.297.1666588766214; Sun, 23 Oct 2022 22:19:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v6 10/14] target/arm: Consider GP an attribute in get_phys_addr_lpae Date: Mon, 24 Oct 2022 15:18:47 +1000 Message-Id: <20221024051851.3074715-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666592075624100001 Both GP and DBM are in the upper attribute block. Extend the computation of attrs to include them, then simplify the setting of guarded. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- target/arm/ptw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index cc7751218c..8004ca86df 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1077,7 +1077,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint32_t el =3D regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); - bool guarded =3D false; uint64_t descriptor; bool nstable; =20 @@ -1343,7 +1342,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); /* Extract attributes from the descriptor */ - attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 1= 2)); + attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); =20 if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fields */ @@ -1351,7 +1350,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, } /* Merge in attributes from table descriptors */ attrs |=3D nstable << 5; /* NS */ - guarded =3D extract64(descriptor, 50, 1); /* GP */ if (param.hpd) { /* HPD disables all the table attributes except NSTable. */ goto skip_attrs; @@ -1404,7 +1402,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. = */ if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { - result->f.guarded =3D guarded; + result->f.guarded =3D extract64(attrs, 50, 1); /* GP */ } =20 if (regime_is_stage2(mmu_idx)) { --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666591823; cv=none; d=zohomail.com; s=zohoarc; b=CtpFonkVYoPzAnXu8MfVo9xnRU0JAi0m98XJyx8rXNt1XJmWHWk4MDZnUPpfL80ysvMri52L9CYsgqBZEJBirszRgdMaXeODUSFV4V//YFTnMV8Yi7Sx1gzFv18W33mp8HkkH9S/wnnGL2wjMR0n7rmDqzSjg+fw5cannK4S2fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666591823; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1vmy8B3i0MTxOCpkYy56RCPt7fyDU4i6hN7JG5wlZ40=; b=FUWdB2jbCHcn4cscZ75cqWxCuvmtfvmqhBz0x9uri6uov2aESglFcumPGwPsZyj30MOOJZV+MqXKbySVfZyCSP5iGqLNnfsA5nEgIxA9hzGyatHwVZnHUL9S75Ez1en3EBa+K1I/3r2FLFFe4gDAewAa2ftvMFSgnNGmpnhKbdY= 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 1666591822983583.1808367480777; Sun, 23 Oct 2022 23:10:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompt8-0007oM-60; Mon, 24 Oct 2022 01:20: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 1ompsC-0006sl-MH for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:43 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omps8-0002Pi-88 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:39 -0400 Received: by mail-pf1-x429.google.com with SMTP id d10so8111298pfh.6 for ; Sun, 23 Oct 2022 22:19:30 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=1vmy8B3i0MTxOCpkYy56RCPt7fyDU4i6hN7JG5wlZ40=; b=TQcBUOk9NqlJ7uQE83Nm72JBJnkRXJgWvEKOxP+7DzXAv/RDKjztBHKdCyOWqajPQk HPk0nSxxZZH4u1spYhPkPo3zFlgFdfFSijMauzxI37HsESMto6sQbkDaFsfLHbpAjhM4 EhruGI4BP1ZTD/4LVq90YD0kwamp+M1K6oJQnKJFU7fMEwothaCsrLbppgIkQZjrPF/b im73e90DvhwPbxUlMidXMwdJ5p2s8hj8/wZEYb3/BdbOtQS5UDZAmxtFVKhlC26b8+Ur Gi+lxHe7WEl4TED+NDDLdVriZJbr+UmWQhVXd5wmXcSb4bpFm5//zutaRucZjI47WXUw bZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=1vmy8B3i0MTxOCpkYy56RCPt7fyDU4i6hN7JG5wlZ40=; b=QGmU+kZU6ByPD+oaXZtF+ZljwP+ithsxbVq72ziN7xCeoU1eSqbhBLatOCOc+mT6U7 bCuX+Wr0NbS2BlE1DkyAKRRK1+XfMFP+NYsGfJ9O9pSvGMIeR9s2fGevzGGBkDYnRtKI nwdUnDcgeNZ9WVlL0eyUS+DG5d/0SKNe4tb0TQk1et3sWxtu2LtM1Qwm2ljveTkPx+CA VxKhvL6Zk22tBXV4O26U3t7yMW3s24iEX30BaulJ+u5RgAOYYpjxyIsowIUmURHnObYX AWB1pOucwjtV/U43MC6ga4N/KbrYrpxeAa5/FdDjZ2xqZhwhV5eouZ7T5fjtlABd4pga 6M/A== X-Gm-Message-State: ACrzQf1pMm5x8bzJX83Pn8pkvlSc8ddBbZq94VtgCSt4DADCRXtu3s7Y 4s11AyLwDdr4kFttsaj/anPNQhbFa2WLtVcE X-Google-Smtp-Source: AMsMyM6t5yPg1OLnMWac0wnEC59QLQdZd3/TNboBspyKz2uRi1Yjqu0omrMW5Z8ETdeJmBX9J1adIw== X-Received: by 2002:a05:6a00:851:b0:563:6c6a:2b7b with SMTP id q17-20020a056a00085100b005636c6a2b7bmr31696144pfk.45.1666588768905; Sun, 23 Oct 2022 22:19:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v6 11/14] target/arm: Tidy merging of attributes from descriptor and table Date: Mon, 24 Oct 2022 15:18:48 +1000 Message-Id: <20221024051851.3074715-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666591825149100003 Content-Type: text/plain; charset="utf-8" Replace some gotos with some nested if statements. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- target/arm/ptw.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8004ca86df..282828992e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1341,27 +1341,25 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, page_size =3D (1ULL << ((stride * (4 - level)) + 3)); descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); =20 - if (regime_is_stage2(mmu_idx)) { - /* Stage 2 table descriptors do not include any attribute fields */ - goto skip_attrs; - } - /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 5; /* NS */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - goto skip_attrs; - } - 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. + * Extract attributes from the descriptor, and apply table descriptors. + * Stage 2 table descriptors do not include any attribute fields. + * HPD disables all the table attributes except NSTable. */ - attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D> AP[1= ] */ - attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D> AP[2]= */ - skip_attrs: + attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); + if (!regime_is_stage2(mmu_idx)) { + attrs |=3D nstable << 5; /* NS */ + 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 /* * Here descaddr is the final physical address, and attributes --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666591490; cv=none; d=zohomail.com; s=zohoarc; b=RY2rK5qDOC0u81ibt/4vxALgpVfy7crkdwIB8VDI4GHHsvhpl8wAdeTPmcS3FfbL+qesvsrN3THKnSrf0Kv7u0HgwSPN8ig2+nauKGpqylc6OFXFdBHQ6PjDpSdLOz/nmxH2jsyO36dJXH/16zpqpmyc++VKZgq5p0SvGXmjrJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666591490; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vqqhe7ok+952FMeoYC9dG+eusN1LKoZKt0UmNCjl0DQ=; b=FIq8ZTigoETxsKmulU/BLjNeMCWjCEkiqPszTPmKZoqBRJWlMQ8UD8bl8gb1w1zR62h3u0P1RFCy1TnhkvMbk/xKS5/upFXbupN8gpUCpQGBzAyalATBRfUAJpqJ41mbWVJIhzn9Am6wrdV5x0LB8rqaysbeC8ewK0Wcfzs05b8= 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 1666591490042474.84778933235316; Sun, 23 Oct 2022 23:04:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompt5-0007lq-FN; Mon, 24 Oct 2022 01:20: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 1ompsC-0006sk-Lp for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:43 -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 1omps8-0002RD-1y for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:39 -0400 Received: by mail-pl1-x62e.google.com with SMTP id g24so2582660plq.3 for ; Sun, 23 Oct 2022 22:19:32 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=vqqhe7ok+952FMeoYC9dG+eusN1LKoZKt0UmNCjl0DQ=; b=lA3VuMzHfeZVjcDGVcj/tcuhSkjE/pMPlcJX0gPXzzGjiePf8V76ex2LDe+dQxo7Z4 RvTH6GgDWweeW0z7rBBIGbY0GjSLuQYvVn69/QlQW04udvF+GFjUWbmB8En2zuwMiKLO teOoELMUkTnRRr0dOsC3HhYMjTsvcwJ3/yTDd9lI7gjKIJ9OW9wobXWPET9oX+2mmf2g RXpEKNYh4jNIIWRrkp8bIaWm+pXdJzpLgpCQx0zkQc1acA2Vh74j/pbMT9xkEJq3hIPc YPM4+m1b7YQ3aI/ednmmkl1h1t53pKW6yxd+JydBUXIKsTggZeDeMrCLq/6o4OoxYPcs y49w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vqqhe7ok+952FMeoYC9dG+eusN1LKoZKt0UmNCjl0DQ=; b=LDGqji9yW00xBrTgpaXCpki7SdSXStHzxItcyZah6h67VwhWGuUK09WRqQFTiZVNXE oTYdhQWH5CfejW1khNbV7osNhvBbEfiqgWj0iX3NTPzySqLu4a/HWonS5xWAMNQQBDKK PC75CnUBtK8JxwHYW8SwwmoZKAUeAtIFxg6dX2wPGJ8gObrYatgeCFuYxbiR11KTfrsj rM75ZU5GwmQ8oUEAMf1XAyVo4yRUWl5xHMSkQ7G2GpaL0OTJfrWPZTjJjVqM95+ackE4 U4PfQGp4+SJXsNWOQjFjwZ8wFIm0uX/NNq9fCLY2CC3Dlj+5kN5HIp1NyILMmEo5l32+ zxdg== X-Gm-Message-State: ACrzQf0ZB5nWRqJkTFVerXCMaRfx07PHzQQ8QIMnN2xBiB5WgHqnUonY Ka+i2X+FK1dLeMKQXmMSpHZjR+Q07z3ee9Zu X-Google-Smtp-Source: AMsMyM5BJyWb1jK12Y+1jrPj1l5unDpAv0WTC+ZLh2vatZklZyd1i+2imlFigPlEheZf/+Hrv3gm1Q== X-Received: by 2002:a17:90a:fa42:b0:212:f0d3:2ff4 with SMTP id dt2-20020a17090afa4200b00212f0d32ff4mr9406255pjb.104.1666588771768; Sun, 23 Oct 2022 22:19:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 12/14] target/arm: Implement FEAT_HAFDBS, access flag portion Date: Mon, 24 Oct 2022 15:18:49 +1000 Message-Id: <20221024051851.3074715-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666591491770100003 Content-Type: text/plain; charset="utf-8" Perform the atomic update for hardware management of the access flag. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v4: Raise permission fault if pte read-only and atomic update reqd. Split out dirty bit portion. Prepare for a single update for AF + DB. v5: Fix s1ns typo; incorporate i_yzsvv comment. Move the AF update before attributes are extracted and merged. Do permission check before pte writeback, per AArch64.S1Translate. --- docs/system/arm/emulation.rst | 1 + target/arm/cpu64.c | 1 + target/arm/ptw.c | 176 +++++++++++++++++++++++++++++----- 3 files changed, 156 insertions(+), 22 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index cfb4b0768b..580e67b190 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -32,6 +32,7 @@ the following architecture extensions: - FEAT_FlagM (Flag manipulation instructions v2) - FEAT_FlagM2 (Enhancements to flag manipulation instructions) - FEAT_GTG (Guest translation granule size) +- FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) - FEAT_HCX (Support for the HCRX_EL2 register) - FEAT_HPDS (Hierarchical permission disables) - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 85e0d1daf1..fe1369fe96 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1165,6 +1165,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64mmfr0 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; + t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF onl= y */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ t =3D FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 282828992e..d9f89b6105 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -21,7 +21,9 @@ typedef struct S1Translate { bool in_secure; bool in_debug; bool out_secure; + bool out_rw; bool out_be; + hwaddr out_virt; hwaddr out_phys; void *out_host; } S1Translate; @@ -238,6 +240,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, uint8_t pte_attrs; bool pte_secure; =20 + ptw->out_virt =3D addr; + if (unlikely(ptw->in_debug)) { /* * From gdbstub, do not use softmmu so that we don't modify the @@ -266,6 +270,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, pte_secure =3D is_secure; } ptw->out_host =3D NULL; + ptw->out_rw =3D false; } else { CPUTLBEntryFull *full; int flags; @@ -280,6 +285,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, goto fail; } ptw->out_phys =3D full->phys_addr; + ptw->out_rw =3D full->prot & PROT_WRITE; pte_attrs =3D full->pte_attrs; pte_secure =3D full->attrs.secure; } @@ -323,14 +329,16 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Trans= late *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); + void *host =3D ptw->out_host; uint32_t data; =20 - if (likely(ptw->out_host)) { + if (likely(host)) { /* Page tables are in RAM, and we have the host address. */ + data =3D qatomic_read((uint32_t *)host); if (ptw->out_be) { - data =3D ldl_be_p(ptw->out_host); + data =3D be32_to_cpu(data); } else { - data =3D ldl_le_p(ptw->out_host); + data =3D le32_to_cpu(data); } } else { /* Page tables are in MMIO. */ @@ -356,15 +364,25 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Trans= late *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); + void *host =3D ptw->out_host; uint64_t data; =20 - if (likely(ptw->out_host)) { + if (likely(host)) { /* Page tables are in RAM, and we have the host address. */ +#ifdef CONFIG_ATOMIC64 + data =3D qatomic_read__nocheck((uint64_t *)host); if (ptw->out_be) { - data =3D ldq_be_p(ptw->out_host); + data =3D be64_to_cpu(data); } else { - data =3D ldq_le_p(ptw->out_host); + data =3D le64_to_cpu(data); } +#else + if (ptw->out_be) { + data =3D ldq_be_p(host); + } else { + data =3D ldq_le_p(host); + } +#endif } else { /* Page tables are in MMIO. */ MemTxAttrs attrs =3D { .secure =3D ptw->out_secure }; @@ -385,6 +403,91 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Transl= ate *ptw, return data; } =20 +static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val, + uint64_t new_val, S1Translate *ptw, + ARMMMUFaultInfo *fi) +{ + uint64_t cur_val; + void *host =3D ptw->out_host; + + if (unlikely(!host)) { + fi->type =3D ARMFault_UnsuppAtomicUpdate; + fi->s1ptw =3D true; + return 0; + } + + /* + * Raising a stage2 Protection fault for an atomic update to a read-on= ly + * page is delayed until it is certain that there is a change to make. + */ + if (unlikely(!ptw->out_rw)) { + int flags; + void *discard; + + env->tlb_fi =3D fi; + flags =3D probe_access_flags(env, ptw->out_virt, MMU_DATA_STORE, + arm_to_core_mmu_idx(ptw->in_ptw_idx), + true, &discard, 0); + env->tlb_fi =3D NULL; + + if (unlikely(flags & TLB_INVALID_MASK)) { + assert(fi->type !=3D ARMFault_None); + fi->s2addr =3D ptw->out_virt; + fi->stage2 =3D true; + fi->s1ptw =3D true; + fi->s1ns =3D !ptw->in_secure; + return 0; + } + + /* In case CAS mismatches and we loop, remember writability. */ + ptw->out_rw =3D true; + } + +#ifdef CONFIG_ATOMIC64 + if (ptw->out_be) { + old_val =3D cpu_to_be64(old_val); + new_val =3D cpu_to_be64(new_val); + cur_val =3D qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, ne= w_val); + cur_val =3D be64_to_cpu(cur_val); + } else { + old_val =3D cpu_to_le64(old_val); + new_val =3D cpu_to_le64(new_val); + cur_val =3D qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, ne= w_val); + cur_val =3D le64_to_cpu(cur_val); + } +#else + /* + * We can't support the full 64-bit atomic cmpxchg on the host. + * Because this is only used for FEAT_HAFDBS, which is only for AA64, + * we know that TCG_OVERSIZED_GUEST is set, which means that we are + * running in round-robin mode and could only race with dma i/o. + */ +#ifndef TCG_OVERSIZED_GUEST +# error "Unexpected configuration" +#endif + bool locked =3D qemu_mutex_iothread_locked(); + if (!locked) { + qemu_mutex_lock_iothread(); + } + if (ptw->out_be) { + cur_val =3D ldq_be_p(host); + if (cur_val =3D=3D old_val) { + stq_be_p(host, new_val); + } + } else { + cur_val =3D ldq_le_p(host); + if (cur_val =3D=3D old_val) { + stq_le_p(host, new_val); + } + } + if (!locked) { + qemu_mutex_unlock_iothread(); + } +#endif + + return cur_val; +} + static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t *table, uint32_t address) { @@ -1077,7 +1180,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint32_t el =3D regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); - uint64_t descriptor; + uint64_t descriptor, new_descriptor; bool nstable; =20 /* TODO: This code does not support shareability levels. */ @@ -1291,7 +1394,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (fi->type !=3D ARMFault_None) { goto do_fault; } + new_descriptor =3D descriptor; =20 + restart_atomic_update: if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { /* Invalid, or the Reserved level 3 encoding */ goto do_translation_fault; @@ -1337,17 +1442,36 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, * to give a correct page or table address, the address field * in a block descriptor is smaller; so we need to explicitly * clear the lower bits here before ORing in the low vaddr bits. + * + * Afterward, descaddr is the final physical address. */ page_size =3D (1ULL << ((stride * (4 - level)) + 3)); descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); =20 + if (likely(!ptw->in_debug)) { + /* + * Access flag. + * If HA is enabled, prepare to update the descriptor below. + * Otherwise, pass the access fault on to software. + */ + if (!(descriptor & (1 << 10))) { + if (param.ha) { + new_descriptor |=3D 1 << 10; /* AF */ + } else { + fi->type =3D ARMFault_AccessFlag; + goto do_fault; + } + } + } + /* - * Extract attributes from the descriptor, and apply table descriptors. - * Stage 2 table descriptors do not include any attribute fields. - * HPD disables all the table attributes except NSTable. + * Extract attributes from the (modified) descriptor, and apply + * table descriptors. Stage 2 table descriptors do not include + * any attribute fields. HPD disables all the table attributes + * except NSTable. */ - attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); + attrs =3D new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(5= 0, 14)); if (!regime_is_stage2(mmu_idx)) { attrs |=3D nstable << 5; /* NS */ if (!param.hpd) { @@ -1361,18 +1485,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, } } =20 - /* - * Here descaddr is the final physical address, and attributes - * are all in attrs. - */ - if ((attrs & (1 << 10)) =3D=3D 0) { - /* Access flag */ - fi->type =3D ARMFault_AccessFlag; - goto do_fault; - } - ap =3D extract32(attrs, 6, 2); - if (regime_is_stage2(mmu_idx)) { ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; xn =3D extract64(attrs, 53, 2); @@ -1389,6 +1502,25 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, goto do_fault; } =20 + /* 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); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + /* + * I_YZSVV says that if the in-memory descriptor has changed, + * then we must use the information in that new value + * (which might include a different output address, different + * attributes, or generate a fault). + * Restart the handling of the descriptor value from scratch. + */ + if (new_descriptor !=3D descriptor) { + descriptor =3D new_descriptor; + goto restart_atomic_update; + } + } + if (ns) { /* * The NS bit will (as required by the architecture) have no effec= t if --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666591193; cv=none; d=zohomail.com; s=zohoarc; b=aWtXImKpHipGbXpGfh2MBzp4TFe5b8G9VmcoMKftfpKy7aUPF0iVHr/bKXLL+qPJLuOawWPG+BbXKoqrDv5m7h/n82DtL88YF+3cwFn3oSRBemBHk74zNdjJ8JR1bqLg0K65KZ7qTkcWmp4tCifQwwLkWewEtv1tyA7BpsEIQZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666591193; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fmhV53NBm0GuAqG7xZExjY3NVZwOXtngOnvaKeyYV/A=; b=S+W+mISz6SIFHaQI1MxWI4L7ujfzoa8/58anPTcWNET20d9FTPCzO9ohu2s4EFYy6h/ZOERtgfGenIxvGjF5xX0zP6Ba5qfTz1PkqOrVcQhu69tHl3Vzgmak+ojDl6brwANsV7UADM/N2qsTQnrW9Jk+nmPwtHyYndtIkoNF3Rk= 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 1666591193530384.890157073459; Sun, 23 Oct 2022 22:59:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ompsw-0007dY-Vq; Mon, 24 Oct 2022 01:20: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 1ompsB-0006ri-0L for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:43 -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 1omps8-0002SP-5f for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:38 -0400 Received: by mail-pl1-x629.google.com with SMTP id n7so7600136plp.1 for ; Sun, 23 Oct 2022 22:19:35 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=fmhV53NBm0GuAqG7xZExjY3NVZwOXtngOnvaKeyYV/A=; b=hD/hgcLgHogKhfFD2gfVE+9DpeWgQyUA2U8XggbR3Znnh+9MJKW6NaFuUJT+0wW+d9 4BEXWgxI8910oJCPdCHchZzpzBHvTAhUoqaEW0m1ho5AOkNDziLTOtVkAzY2YvcXs2Ae /Q1eUl3jS3fIobqhdPRkGtkaYlS0SG8+wWHNtyttf13/JSXAhBLVFb9Ds5KEBer1oWFl vc+DB2ZSsBxg1WQ1N/ZgwGvHRCLcXrPVmOME7jC6jZG7IyPupZ+aAzs1Q/zUS+8BbHqH UDVsQSbMJ/AYMC3Kk4HphPkahXO5Jgu/suWa/nIrFAzFc5z9p4pg9S++39bU0aFLOMIh J59g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fmhV53NBm0GuAqG7xZExjY3NVZwOXtngOnvaKeyYV/A=; b=QZEsWr6A35PQgQFAr5bEeEe8xsa9WaE0pxwIVz4U/lAF7CWyYNXxYvLrKqXZHZTjkF t/DzxihZc2VAeyqYBGEnNn/r5QsfdFqZ9MCIsyRRfFjTF9e8Ipp963OpWeK4NaiGlzH/ RnOT9+Co6PajM6R949ut77jPqnMcbl5hagEr2RKJXlKlrNqSwq2Xx28RDuOmqGphu5Vg C5/bKRp60q7NGj8fD5dAoKZir3WuKlwCcgmCEPTFshHXtoQvmLriyDlscjNrbCAewDmD z+VXNeLcDh7l2HOY8+M79jF2yCsUyHTrdXdIERN9amMg+YI2imOzVVSaWunE7bqQHLJm e5lw== X-Gm-Message-State: ACrzQf01Sbzcwsi8ZOELmWNSiCPao6ws6+rc2Bu0rLl0O7eoSIwww/6x C8DP/9mwWPV1G3qJ/ruy8HEm9aQZOxD+uSxr X-Google-Smtp-Source: AMsMyM5wJbRaqGnF83TxzApRByzItgKAYtOX7KqUbhvbROG7+2Y0rA8WZZLmx1B/SeVCXxMcYD49IA== X-Received: by 2002:a17:90b:1e0c:b0:20f:bcbf:ab5 with SMTP id pg12-20020a17090b1e0c00b0020fbcbf0ab5mr34887522pjb.187.1666588774276; Sun, 23 Oct 2022 22:19:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v6 13/14] target/arm: Implement FEAT_HAFDBS, dirty bit portion Date: Mon, 24 Oct 2022 15:18:50 +1000 Message-Id: <20221024051851.3074715-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666591194341100002 Content-Type: text/plain; charset="utf-8" Perform the atomic update for hardware management of the dirty bit. Signed-off-by: Richard Henderson --- v5: Move the DB update before attributes are extracted and merged. --- target/arm/cpu64.c | 2 +- target/arm/ptw.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index fe1369fe96..0732796559 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1165,7 +1165,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64mmfr0 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; - t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF onl= y */ + t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ t =3D FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index d9f89b6105..d87757a700 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1463,6 +1463,22 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, goto do_fault; } } + + /* + * Dirty Bit. + * If HD is enabled, pre-emptively set/clear the appropriate AP/S2= AP + * bit for writeback. The actual write protection test may still be + * overridden by tableattrs, to be merged below. + */ + if (param.hd + && extract64(descriptor, 51, 1) /* DBM */ + && access_type =3D=3D MMU_DATA_STORE) { + if (regime_is_stage2(mmu_idx)) { + new_descriptor |=3D 1ull << 7; /* set S2AP[1] */ + } else { + new_descriptor &=3D ~(1ull << 7); /* clear AP[2] */ + } + } } =20 /* --=20 2.34.1 From nobody Sat May 11 08:32:22 2024 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=1666590023; cv=none; d=zohomail.com; s=zohoarc; b=TpAaaHE8YzZvfdw+ctuxzB8YjLcbV1XLmYnuTteMv1wEgc+mxU+glr8XU8OgSkdD7epVnVdU61cCQO0g53OKt1YCkjGAfrVCg4unA1WJhDgbbHP4ETZ5smSmS7pvlPTov7M72RunsClgLatpI0EdVxQPbQ7z6YiYD37Wx3s8Dvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666590023; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WUDIrJHIS5cE7phXWe1119p8UIq5Q+ilAQsTbi3H87M=; b=GjUlsPOu4tpuUI1NHD4sftTppQamJRrwn5LynR6A6k8W2+txmu48U5yGrPH8EU2Yja7/ML9sK3Yrg40yMc4qXz0lKDJu4bs3M/Kwt8hBliUz4bsFKcVUowRL//OHuLx0rSPvwi66e78NX/sn2/OX/I+Y55MleYwqW7Y32XufuZM= 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 1666590023576946.4619049901897; Sun, 23 Oct 2022 22:40:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omptC-0007yA-Vc; Mon, 24 Oct 2022 01:20:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ompsC-0006sm-M8 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:43 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ompsA-0002TP-Oz for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:40 -0400 Received: by mail-pj1-x102f.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so2460695pjc.3 for ; Sun, 23 Oct 2022 22:19:38 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=WUDIrJHIS5cE7phXWe1119p8UIq5Q+ilAQsTbi3H87M=; b=LjrA9yHAlxUnyXwYnoxeQ8nP4QKz/mgB2tnqmJvX2hb8R5jf4SJINLW68wjvinBTnE qONjMvjC6c9aLYJ+DLmA0oxom+tdU18KI9m2XCD0H1U10+k3BM36L6GpTKvHH41aenUl tu1r1jzthaG/Wy15koCjKUSb20wCKuS7Z2KVzlNvmsHf+yYTpowNkCUpXS2ttxqpuNi2 ZUmb3bAEPL0LXReGCT+TVm3Og7kl/nzbZGpbBwp57qkeaqeTSJHoqOpNpJC7gCzuEcWH AwbjEl1FclqurMTIb+Epu+eQGGiGJiObJcW68aSqx3mIvl5XUHeIG9bgUO4H0fm9wljW B+ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=WUDIrJHIS5cE7phXWe1119p8UIq5Q+ilAQsTbi3H87M=; b=XRLIGhjmvFem+uExbVrZF5g08x5rdqpJ7i6PuG15gGuUzX6BoFc4ShR1/3DQRU46Kq pQ2PYU6NlJqhhYCTQWhkFESuMJlo9xbZBqpPSSjrn3VQuAq0LybUOldLlnZ8ESPoWWFI /+M+tpOd1/IQ1q/8w35HL21spDK/N6jmdi9Ce2PtKbDgSUbgHWIkNWvJX5CSTZqGRKFE fFcGWVR1SG7XOMRKqakacBNuVBR8jJzqGlFBSKT+/vj3ofBInKvJhFxwjLBEyhmXflwk JocNlHkF4v577RKr2wtCyex6XZf5j3mMHVqMd76etX+l8XBn7+Z2Cn3HGi8RZCKMSy56 gWhA== X-Gm-Message-State: ACrzQf36ZLHcBO7khPvFssGtXAoOPhd/L1vZXfhM66ii3LT7dMg0STER etQPS2usUuZKYbujywexrqZySiIaU4pJuhlT X-Google-Smtp-Source: AMsMyM5bZT0p/adYBx2OrckrFiUJhQswuPtaF9KM0HQnzxffIJSAXXEg4WHoocjISamSatj/RgoJzA== X-Received: by 2002:a17:902:7e0e:b0:17f:8edd:5f00 with SMTP id b14-20020a1709027e0e00b0017f8edd5f00mr32140107plm.96.1666588777246; Sun, 23 Oct 2022 22:19:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Marc Zyngier , Peter Maydell Subject: [PATCH v6 14/14] target/arm: Use the max page size in a 2-stage ptw Date: Mon, 24 Oct 2022 15:18:51 +1000 Message-Id: <20221024051851.3074715-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-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::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666590025398100003 Content-Type: text/plain; charset="utf-8" We had only been reporting the stage2 page size. This causes problems if stage1 is using a larger page size (16k, 2M, etc), but stage2 is using a smaller page size, because cputlb does not set large_page_{addr,mask} properly. Fix by using the max of the two page sizes. Reported-by: Marc Zyngier Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index d87757a700..b80a5c68ae 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2589,7 +2589,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, ARMMMUFaultInfo *fi) { hwaddr ipa; - int s1_prot; + int s1_prot, s1_lgpgsz; bool is_secure =3D ptw->in_secure; bool ret, ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; @@ -2625,6 +2625,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, * Save the stage1 results so that we may merge prot and cacheattrs la= ter. */ s1_prot =3D result->f.prot; + s1_lgpgsz =3D result->f.lg_page_size; cacheattrs1 =3D result->cacheattrs; memset(result, 0, sizeof(*result)); =20 @@ -2639,6 +2640,14 @@ static bool get_phys_addr_twostage(CPUARMState *env,= S1Translate *ptw, return ret; } =20 + /* + * Use the maximum of the S1 & S2 page size, so that invalidation + * of pages > TARGET_PAGE_SIZE works correctly. + */ + if (result->f.lg_page_size < s1_lgpgsz) { + result->f.lg_page_size =3D s1_lgpgsz; + } + /* Combine the S1 and S2 cache attributes. */ hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); if (hcr & HCR_DC) { --=20 2.34.1