From patchwork Mon Oct 24 05:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617849 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2519499pvb; Sun, 23 Oct 2022 23:27:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zSnQgbZq2BqP38rdxPrguoSFaFJ5Xq85CdpkxP9WtyTMezlSCEIz6AWmQAKv3Us7PhLj9 X-Received: by 2002:a05:622a:387:b0:394:7a0a:9584 with SMTP id j7-20020a05622a038700b003947a0a9584mr26591951qtx.60.1666592832215; Sun, 23 Oct 2022 23:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666592832; cv=none; d=google.com; s=arc-20160816; b=LPHqPCeGIU8lGMYKhslv7VKdjh3u3dZ800Z8MxbFxoN5NYpvE0nYnWpQppxCl8ALyb c2ntvJMyyK1YqwLn3vZnahuBYkWcCioMNAey/9D5WMrkVovJkxlB6gT0Rw01wvQcLFRI twUrMxoaixKqHnKfPkxSSZqSwn4zdy3TY31+YWaE6lfmFtOPNvRMxPt8SgZ9Gtumf67z RQ0XMN3rIQqvKpYSJ3UbuRSh0FM4fgJCzsML2hrCDo1eYp8cRhNlff4l0Cj76WDWJEt7 8fag+n9ufzVtiUytx4GqILwmX+S7S88MTI6cvEuEXc/VIBHfaAORzSVsGPVfCqnP+Ubt HWEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dRBUuDv4xO4FSH5BCO5y+i5Lk2hVQIRJPv1ndVT7mQw=; b=D6kYnimGTlMcrsonV8D6r3oLwniOKmJ6vkmMiKeVRCJxYTLpihRBwNlLyR52nH8uba oOlQ4+7uMJAmHMqwTPq6csPuNiIospjoveGHObsUe/Qa6obsVEATOn6fiK37L0QkHFSN oQsVb1LPB1SXZ+63T+B93t2uscQiZgInyu9AjZn/5bJO3MHXwlpV946Vkp/EawIsDG4y dKLd5uEortP4cCCrx5EZOh1ytPRN1CroE1acc53Mkov5HIXQseiSeETLFVIk4HxNePSf OR2SaYaYssaE/xshxCJA4e+vzqL2mvmp3xJDtJHYp+xCJkKcz0YM6RZV4jmNxcamnF/E by2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lIfskUFu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s14-20020a05620a030e00b006f64a8202a7si220694qkm.146.2022.10.23.23.27.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lIfskUFu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-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 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+patch=linaro.org@nongnu.org Reduce the amount of typing required for this check. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé 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, ARMMMUIdx mmu_idx) } } +static inline bool regime_is_stage2(ARMMMUIdx mmu_idx) +{ + return mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S; +} + /* Return the exception level which controls this address translation regime */ 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 mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 37, 2); - } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == 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 == ARMMMUIdx_Stage2 || mmu_idx == 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 = env_archcpu(env); - bool stage2 = mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S; + bool stage2 = regime_is_stage2(mmu_idx); if (!regime_has_2_ranges(mmu_idx)) { select = 0; @@ -10532,22 +10532,18 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, } ds = false; } else if (ds) { - switch (mmu_idx) { - case ARMMMUIdx_Stage2: - case ARMMMUIdx_Stage2_S: + if (regime_is_stage2(mmu_idx)) { if (gran == Gran16K) { ds = cpu_isar_feature(aa64_tgran16_2_lpa2, cpu); } else { ds = cpu_isar_feature(aa64_tgran4_2_lpa2, cpu); } - break; - default: + } else { if (gran == Gran16K) { ds = cpu_isar_feature(aa64_tgran16_lpa2, cpu); } else { ds = cpu_isar_feature(aa64_tgran4_lpa2, cpu); } - break; } if (ds) { min_tsz = 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_idx, bool is_aa64, bool have_wxn; int wxn = 0; - assert(mmu_idx != ARMMMUIdx_Stage2); - assert(mmu_idx != ARMMMUIdx_Stage2_S); + assert(!regime_is_stage2(mmu_idx)); user_rw = simple_ap_to_rw_prot_is_user(ap, true); if (is_user) { @@ -1171,7 +1170,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, goto do_fault; } - if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { + if (!regime_is_stage2(mmu_idx)) { /* * The starting level depends on the virtual address size (which can * be up to 48 bits) and the translation granule size. It indicates @@ -1342,7 +1341,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, attrs = extract64(descriptor, 2, 10) | (extract64(descriptor, 52, 12) << 10); - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { + if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fields */ break; } @@ -1374,7 +1373,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, ap = extract32(attrs, 4, 2); - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { + if (regime_is_stage2(mmu_idx)) { ns = mmu_idx == ARMMMUIdx_Stage2; xn = extract32(attrs, 11, 2); result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); @@ -1404,7 +1403,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.guarded = guarded; } - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { + if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format = true; result->cacheattrs.attrs = extract32(attrs, 0, 4); } else { @@ -1435,8 +1434,7 @@ do_fault: fi->type = fault_type; fi->level = level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 || - mmu_idx == ARMMMUIdx_Stage2_S); + fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx); fi->s1ns = mmu_idx == ARMMMUIdx_Stage2; return true; } From patchwork Mon Oct 24 05:18:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617851 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2522726pvb; Sun, 23 Oct 2022 23:34:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MkR+Q6Tniu5PDKorHsEB1uJweWDNWTtmILEt2ElH4Xkmh2TBm0XrDcQcVyI9wJWGNcTz5 X-Received: by 2002:a05:622a:58f:b0:39d:10f3:cae4 with SMTP id c15-20020a05622a058f00b0039d10f3cae4mr16711630qtb.604.1666593282694; Sun, 23 Oct 2022 23:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666593282; cv=none; d=google.com; s=arc-20160816; b=szIq1bSShJ8aLbYvowtKBYHjXI5BjhmT2sicPMHzCzfNs0H2Rqd/F4k1kgQrTb4F67 Clka9cPT5xvq0fL8ONFBwWHwo4XtpjXC6hMD6SsvGIEojJhcLgDk8fjl1+n0DAdh9hNf 5/SrwZwWs8TW831pQeL/C1T5V18vh9DCXHpIP2Zzh8Y4mvQ09D90lPvkAdD2oFube+4g 6EVFgxIOqSrtcf8YaUIMmoIw+wDtqMpKVRLangy9DVXpceki6Avm3zTs9VD0NIrNSOFL zU9J51auGAULsH8WdhVp34vug+oY6lEDLQDW0o0XOnha8JLcgPxLuQVH6PIaUjqiwhm+ cB9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TugH2ukoL/GP7ZN02ws3Cq0+tk08ipGAjprVUPkbIZQ=; b=RSR5OxYw7PhUppwsO/QK6u+bVJQmZnxUjb3uc/gInewARJgLbEZs4ikDmZzcgm/M6J qOeOIBiGCG/dS5Jvr4My/ex1rWrajE97oKob/lFdhdsi5ohUCwcXF4Qd0/Ms18SzpZDJ WjwxRA94YVBDv+5C7ZUoef7hQm6E3wnrdA6iYlMwfInGGxiB8AmNWq6K/3n6kYofP7aj gZ3bh5lWeEcSaB782gIFefT7BCXhigHAyNRvILUucnHmWIG47z2XIYE+LrZO23NR1ICQ yeI0pWO2U+JzMsJTaCXDintaC5Rcnp/jZWX5Sk/p+DGvxwCI/VbxGYyi3I2OHvci4jty amYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lrW4Kubt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dv5-20020a05620a1b8500b006f0ff5743e3si4631232qkb.69.2022.10.23.23.34.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:34:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lrW4Kubt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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ée Tested-by: Alex Bennée --- 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 @@ 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, S1Translate *ptw, { bool is_secure = ptw->in_secure; ARMMMUIdx mmu_idx = ptw->in_mmu_idx; - ARMMMUIdx s2_mmu_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; - bool s2_phys = false; + ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx; uint8_t pte_attrs; bool pte_secure; - if (!arm_mmu_idx_is_stage1_of_2(mmu_idx) - || regime_translation_disabled(env, s2_mmu_idx, is_secure)) { - s2_mmu_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; - s2_phys = 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 = addr; - pte_attrs = 0; - pte_secure = is_secure; - } else { + if (regime_is_stage2(s2_mmu_idx)) { S1Translate s2ptw = { .in_mmu_idx = s2_mmu_idx, + .in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS, .in_secure = is_secure, .in_debug = true, }; GetPhysAddrResult s2 = { }; + 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, S1Translate *ptw, ptw->out_phys = s2.f.phys_addr; pte_attrs = s2.cacheattrs.attrs; pte_secure = s2.f.attrs.secure; + } else { + /* Regime is physical. */ + ptw->out_phys = addr; + pte_attrs = 0; + pte_secure = is_secure; } ptw->out_host = NULL; } else { @@ -287,7 +284,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, pte_secure = full->attrs.secure; } - if (!s2_phys) { + if (regime_is_stage2(s2_mmu_idx)) { uint64_t hcr = arm_hcr_el2_eff_secstate(env, is_secure); if ((hcr & HCR_PTW) && S2_attrs_are_device(hcr, pte_attrs)) { @@ -1282,7 +1279,18 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr |= (address >> (stride * (4 - level))) & indexmask; descaddr &= ~7ULL; nstable = extract32(tableattrs, 4, 1); - ptw->in_secure = !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) != 0); + QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S); + ptw->in_ptw_idx &= ~1; + ptw->in_secure = false; + } descriptor = arm_ldq_ptw(env, ptw, descaddr, fi); if (fi->type != ARMFault_None) { goto do_fault; @@ -2468,6 +2476,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; + ptw->in_ptw_idx = s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; ptw->in_secure = s2walk_secure; /* @@ -2527,10 +2536,32 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { ARMMMUIdx mmu_idx = ptw->in_mmu_idx; - ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx); bool is_secure = ptw->in_secure; + ARMMMUIdx s1_mmu_idx; - if (mmu_idx != 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 = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; + break; + + case ARMMMUIdx_E10_0: + s1_mmu_idx = ARMMMUIdx_Stage1_E0; + goto do_twostage; + case ARMMMUIdx_E10_1: + s1_mmu_idx = ARMMMUIdx_Stage1_E1; + goto do_twostage; + case ARMMMUIdx_E10_1_PAN: + s1_mmu_idx = 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 *env, 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 = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; + break; } /* From patchwork Mon Oct 24 05:18:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617844 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2512195pvb; Sun, 23 Oct 2022 23:07:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6FqavCIi7RLhyy0sdjefKN2sJvM7ltk5/m/HwSmnSdSVDAVqhZ80Ef7TEyjD/qAMVaE700 X-Received: by 2002:a05:620a:c4f:b0:6cf:8135:e803 with SMTP id u15-20020a05620a0c4f00b006cf8135e803mr21922741qki.67.1666591657279; Sun, 23 Oct 2022 23:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666591657; cv=none; d=google.com; s=arc-20160816; b=AM6KWKrfZpL9IKt2a2tjFzJH3GjcrlwtDXqr5K8KcTBrzs0NxvTjovtWekRjtQyWGA Adhfo0f3Sfgtlrosx4qjlbVwXn3MvsI9HleVG+OEPgxQB3HO6ejcNbmBDG6+uZ0lcE9R WOaxkG7PUyrWZSF7wfj5ZBNjzaTU/KJrtVVB9UZrTJMofNXD+SYrlEspg/f9sCnV5g0t TOEtnaZOAff4RxPGbo0fG4rKel6r/RrMIUAc4fw36eInTWv/+voyGSq7Mil9XwKbIFX8 bLCkpS1tCF9NvpSnSQ8sp01Xd2IBAT+hF8JPl3rpq7TH9D9hHDNk4PqZfVRRqSGPrnRT v+Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xwpoipf+qBrSAl33zLnSt6wN4K7EGIfNiIUVkyXEfCo=; b=YeMaZqrh2+Ihz8DzKkAKn5tW70zF8pGyGu+D2mljN1Fy62uO+vwgowR78btA+EQlS5 MFNzDh+c5Y5h/xSxP24/9PMz6LZM8GrmKWqd09LX8x20fZr7eM9PXqbSMgUNrX7Q5mKw bR8PaYKREE3xt5/W0M05CsT8N5Fl6yhjSYh3nyORIzdPAydF4e2dFhrJxg92oHMAyiGP 2B9tUkpIIPJyBMfSPNkIV8GA6s8LJWB68ecvW7tEQC1H5pj3vIDRhnAWqyoK4ub1cnDp 1vbCApIN0T8mv6z8QDhU3CQmUg/h+reHrbpZVQ0EXpGBw7BNN/B92MqCjiWRxXftmhaj OYbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dbfi46uB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a12-20020ac8108c000000b0039c0c68fd90si15303855qtj.207.2022.10.23.23.07.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dbfi46uB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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 ARMISARegisters *id) return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) != 0; } +static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) != 0; +} + +static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >= 2; +} + static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0; From patchwork Mon Oct 24 05:18:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617853 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2524851pvb; Sun, 23 Oct 2022 23:40:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/eMi6RTS4pJZI6Q11j3Zm6smvwO62s60QkIdUMaA+Eo4o3sh6T9yz8+PGYzzhQUw+IPZr X-Received: by 2002:a05:620a:4244:b0:6cf:8a7b:3224 with SMTP id w4-20020a05620a424400b006cf8a7b3224mr21709204qko.32.1666593634116; Sun, 23 Oct 2022 23:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666593634; cv=none; d=google.com; s=arc-20160816; b=KdjyheuSKwMvM8f68YkHJ57fM2ydCZRF1qkmLlMUyChT+gX0YHEfh0Z6QQZrkx/2Ch H4ap1n1eMBqtm78Ty3JLj80/l111Qv/LWR9GjM6dF7hE88dffSbcQ3kfZDKalpZyFQ8e FhMJEwn/90P+JiSwst8QzePVb7xZj4WP2jPfzQE/90mgVhsIDz0JW/fNCkRY8OsF8mnU nyhaTZbLP9V8siMC2+GGW2rtl+MG0WE5zy+cDFc9fTVbx52BF43Pr7hAh8wxUgYdiJ8w Ps1QNehPjZIr/GvMgCLP+99UM4qA/TFSkHZQqVe+7GgHjzixf3yU+u+MpZREZ7hb52A8 gJCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ALv+diZzer09a5GMXMjosNYk9lCWFpNzZXXMnFTG3Zg=; b=lO3ULrJEspVR+T/Sb1bB0oDYdh+nL+72RVdh2JaWVYL4CMgO0q8ZCAaDvlTKkb/H6v BUrsUECfrdAJ5kKLs5RyIqbrL5o4/CI5qyiqhwHLibDTJV8yjBMWBp32+Sd7+QbV6xoB 7T0HIhyZ1Xrbqjx1uiXDPrAI8eu6aZP+AV3VT16xJtk2I9Jq5bpXfPWtPyr0jSn5JJ3m JZlq4Qwfx/VReHlliw+rHWZ8AGT6yyDcSL0HCC+ypEgGUqqH3WKrsg5ltsHivYrVNtSu lAFq5Pd24g4D/am8fUPayYBxWrBP6fgVWNj5F+CBo7mcgNHnIIZMqyZziwRS7n9ylv6A kIyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2KHSzBA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c2-20020a056214224200b004bb5d39df91si3874215qvc.366.2022.10.23.23.40.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2KHSzBA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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; 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 = 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 = env_archcpu(env); @@ -10489,6 +10489,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, epd = false; sh = extract32(tcr, 12, 2); ps = extract32(tcr, 16, 3); + ha = extract32(tcr, 21, 1) && cpu_isar_feature(aa64_hafs, cpu); + hd = extract32(tcr, 22, 1) && cpu_isar_feature(aa64_hdbs, cpu); ds = extract64(tcr, 32, 1); } else { /* @@ -10510,6 +10512,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, hpd = extract64(tcr, 42, 1); } ps = extract64(tcr, 32, 3); + ha = extract64(tcr, 39, 1) && cpu_isar_feature(aa64_hafs, cpu); + hd = extract64(tcr, 40, 1) && cpu_isar_feature(aa64_hdbs, cpu); ds = extract64(tcr, 59, 1); } @@ -10577,6 +10581,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, .hpd = hpd, .tsz_oob = tsz_oob, .ds = ds, + .ha = ha, + .hd = ha && hd, .gran = gran, }; } From patchwork Mon Oct 24 05:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617850 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2521936pvb; Sun, 23 Oct 2022 23:32:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/pMIvO9L+G36N+e8UdNBjV4PsD54XCxHWClI+JQvFvQZ+1CXnOq3vx74siryaSFFlMdwE X-Received: by 2002:a05:6214:300e:b0:4bb:704a:ec5d with SMTP id ke14-20020a056214300e00b004bb704aec5dmr3126471qvb.42.1666593149557; Sun, 23 Oct 2022 23:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666593149; cv=none; d=google.com; s=arc-20160816; b=mFw3B/+wuLjOUfCVUrbZpS8sji/WjTEDlPa72s6F0fy6wvk3QwZ/NzXBrcmofBnmh/ GEhAk4JhEJpGbVkKszNNzRBOKsIMWGY494EGWFdkvm3RD63V0ShYRuYXWzqt/FEP2MXf mi0jahGZBDj9AiwK5LtJu4WadwdMkSW5dcHjPl8bTWznvST0lv31BzJRruI/alHDL11G ItEmOF9lgziPZfvQev4ZAIRkxUONKlv99ogGjGYRY2kV1pAEdtnog3g2TO+115DBiVSn X8gKPkbjDb5AKhu16eh340GwJBrpjJkQqhg+WNwvm3Hfy9WLlb+BS9HFOqCzXd+GIJlY 7k8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=cpiX6kzx4jFi17vlEBQq3hvA5Iad+hA9MDkISV1+E1VKimsHRYn2J5ywpc4aOX5xge 6oQedsGR68m/U90ETlHeTD7V25rSsMdhx8ne7HLHLhbhZhQbfTayFxYXU4mvHdx+/u9s N5v1Q40L2DBgWGYz5NFfMMDdacBXMH+mJqRQEuORlyM+dGFb1W56t4JiF4u2cYDZWQ07 8DdYAIiG0axPMVvJAHgvH3NswyB6eaP/bZUia5S53waDBXbz+HWZ3Mtzk/+D5h1h86Q/ yljGuQZ2QpxwWAPJQy427d6FwEADBPZG4iE6axyeLpr/XGYNTQU4nNl/wIN8iokDGXhJ Ywjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IfYYdXX5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k2-20020a37ba02000000b006ee0b43d2dfsi14884093qkf.238.2022.10.23.23.32.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:32:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IfYYdXX5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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, S1Translate *ptw, } /* 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 addr, +static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs = env_cpu(env); uint32_t data; - 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, S1Translate *ptw, hwaddr addr, return data; } -static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr, +static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs = env_cpu(env); uint64_t data; - 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, S1Translate *ptw, fi->type = ARMFault_Translation; goto do_fault; } - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -564,7 +555,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Translate *ptw, /* Fine pagetable. */ table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); } - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -649,7 +643,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw, fi->type = ARMFault_Translation; goto do_fault; } - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -702,7 +699,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw, ns = extract32(desc, 3, 1); /* Lookup l2 entry. */ table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -1291,7 +1291,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, ptw->in_ptw_idx &= ~1; ptw->in_secure = false; } - descriptor = arm_ldq_ptw(env, ptw, descaddr, fi); + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor = arm_ldq_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } From patchwork Mon Oct 24 05:18:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617848 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2517173pvb; Sun, 23 Oct 2022 23:20:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fP8uCs+y/HMYtrkMLY5LUf5E+RLM2D7wOY06cxumEJeJhTufW2Y3SBi3IoRJaClFTank9 X-Received: by 2002:a05:620a:1a9e:b0:6ee:d7f8:e437 with SMTP id bl30-20020a05620a1a9e00b006eed7f8e437mr22002966qkb.162.1666592445361; Sun, 23 Oct 2022 23:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666592445; cv=none; d=google.com; s=arc-20160816; b=vkAnQhM0kK2aooOmqcQ4UKQIVeSIlcsxZVly/YOxAXQRDJ8AebeUzYY58b27sOYvcp k6YSkmlqTiVWOLrZJdag78ea6QxyiVkNqf1hf1MOa+6pM51uVRxoKlqOJF49Xr0qLpnW N18M3VKkdoPaVuiwp5a9JMCNccgrjpraihhfFdE1E9B+YH2UlCrPHs3PF6D90uYUkt15 QAK4A2xXDTXWJz5+w/FfVi3NcqdI5GRcSPlB0Wep+K3Mly1WA9i2/RgvXv9XHggb1cGq KREQUhHXBU0T4OTCSvsLkj4DeFp2GVbBJM6ctdMt7bCtplP4K4LeXZ2YVBrAe3HQ7/lQ +L5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GPM9sD1J7LDvJDVQg9T/5F8YfP6ZpygL4aiMX7D6XJM=; b=NZg8/VgYGoqIV1q2dWkhXg/l96RVhfIK0NOafUhofermlv8aqJYQKJ2/s99CS5VB24 VMeZrsRFc0o8xJN4EajMaYq8i8aOXXmmAgyh9ojKc76k3i62RwYO2KhpYSLyZSKRLBkO 1LfFJEPjBZqdscRKolRRB69IescCSwzfJWV3VfSO2PR8tlvWobuwM8K+NGaBkR8UWbhr nw6gv/OMxI97xZ9Eq1LQTlzy6Tw+/BP2FNnc5P1wFI/WM3LSZuqIh8xmEe2VvABNK05Z iTXlsvaO1sYgeoL1M5CyOuHDKs3MJTVGz3LVaQKGoy6t4EPKMripRxq6hpqDhpYd1oUD kvrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gc+bfP7h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jm15-20020ad45ecf000000b004b408320573si17808168qvb.484.2022.10.23.23.20.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gc+bfP7h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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ée --- 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 = 0x30; break; + case ARMFault_UnsuppAtomicUpdate: + fsc = 0x31; + break; case ARMFault_Lockdown: fsc = 0x34; break; From patchwork Mon Oct 24 05:18:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617852 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2524432pvb; Sun, 23 Oct 2022 23:39:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5AjGcaLNTQUojRutmpKcTxuLJEEKu2CvdHHWnleXnFGT09+g1K/5+3UOQQmQHoscKB434t X-Received: by 2002:a05:6214:ac1:b0:4bb:67f6:930f with SMTP id g1-20020a0562140ac100b004bb67f6930fmr4969393qvi.79.1666593562814; Sun, 23 Oct 2022 23:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666593562; cv=none; d=google.com; s=arc-20160816; b=J4Z/d4cQUVWK4OLDh7GneJYrzbmbaeQOZhvUEYNJ/zRlMfbmu+904gK6ZFOUvCnKDD pPbh90Lut/RKRYjxEsTyt3pnaXCWru55mCSX9TaEwW7RdFg/hVodCoFFvmZsOMumWqZl DoZ+PWiJTkHflswKQtETq0ZmKj1m7PZxoWeVw4Tqfen/WhvSNFzL11FbyLVGQA5pjn16 9Gqo6rZvSIUh8g3sIaOKP/wTpQ5zWLsZEgDU3GMEknljQXKFeHhXd36u7PU4nVo3aL27 d3NKtpRsINl3wttIP9/9T/YHituN9/jmI+Rnws8PL+mQesFMqX1VsWTSwDo4lfwNtAvf nLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/GiKSj2DI/fM8k5gjQPIZReGKnYnqJ3VPV7yF0e0HWE=; b=wy9DqY+xtKcP4e1d3yfto2njmzC6ys9biWjlEaEnc/CC5Jk+3EV1Kgm9koboPizQ4S eNeHSRyd2ea0YHC2kTFioMnVevURt+lt6aw5sPwfkPhNwvn8/HPAA0Vzk+8WSC60KNPf 1K/vVRc/YN2zh6DPQ421ONyeglj2qvuJFv3Fiiwu7FAEjBTvFT65AqLIafWZTTxdi6qQ vae4ev21ecatn/CB4FsaAiUVdRtWSclVQG/HoNndhr6bzbnxNEo2Hm850hN0iQMRZw1t 8fhMKPakbJImewNj/uqeDalzkLUiC7XCu1k1ehdb5VaL+vOmxehH6XyTHwK/eazYJDI8 qwfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QYO+VEO8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fv25-20020a05622a4a1900b0039cc530c012si16700881qtb.21.2022.10.23.23.39.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:39:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QYO+VEO8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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, S1Translate *ptw, uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); bool guarded = false; + uint64_t descriptor; + bool nstable; /* 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 = is_secure ? 0 : (1 << 4); - for (;;) { - uint64_t descriptor; - bool nstable; - - descaddr |= (address >> (stride * (4 - level))) & indexmask; - descaddr &= ~7ULL; - nstable = 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) != 0); - QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S); - ptw->in_ptw_idx &= ~1; - ptw->in_secure = false; - } - if (!S1_ptw_translate(env, ptw, descaddr, fi)) { - goto do_fault; - } - descriptor = arm_ldq_ptw(env, ptw, fi); - if (fi->type != ARMFault_None) { - goto do_fault; - } - - if (!(descriptor & 1) || - (!(descriptor & 2) && (level == 3))) { - /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; - } - - descaddr = descriptor & descaddrmask; + next_level: + descaddr |= (address >> (stride * (4 - level))) & indexmask; + descaddr &= ~7ULL; + nstable = extract32(tableattrs, 4, 1); + if (!nstable) { /* - * For FEAT_LPA and PS=6, 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 |= extract64(descriptor, 8, 2) << 50; - } else { - descaddr |= extract64(descriptor, 12, 4) << 48; - } - } else if (descaddr >> outputsize) { - fault_type = 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 |= extract64(descriptor, 59, 5); - level++; - indexmask = 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 = (1ULL << ((stride * (4 - level)) + 3)); - descaddr &= ~(hwaddr)(page_size - 1); - descaddr |= (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs = 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 */ - break; - } - /* Merge in attributes from table descriptors */ - attrs |= nstable << 3; /* NS */ - guarded = extract64(descriptor, 50, 1); /* GP */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - break; - } - attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ - /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 - * means "force PL1 access only", which means forcing AP[1] to 0. - */ - attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ - attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ - break; + QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) != 0); + QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S); + ptw->in_ptw_idx &= ~1; + ptw->in_secure = false; } + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor = arm_ldq_ptw(env, ptw, fi); + if (fi->type != ARMFault_None) { + goto do_fault; + } + + if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) { + /* Invalid, or the Reserved level 3 encoding */ + goto do_fault; + } + + descaddr = descriptor & descaddrmask; + + /* + * For FEAT_LPA and PS=6, 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 |= extract64(descriptor, 8, 2) << 50; + } else { + descaddr |= extract64(descriptor, 12, 4) << 48; + } + } else if (descaddr >> outputsize) { + fault_type = 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 |= extract64(descriptor, 59, 5); + level++; + indexmask = 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 = (1ULL << ((stride * (4 - level)) + 3)); + descaddr &= ~(hwaddr)(page_size - 1); + descaddr |= (address & (page_size - 1)); + /* Extract attributes from the descriptor */ + attrs = 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 |= nstable << 3; /* NS */ + guarded = extract64(descriptor, 50, 1); /* GP */ + if (param.hpd) { + /* HPD disables all the table attributes except NSTable. */ + goto skip_attrs; + } + attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ + attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ + skip_attrs: + /* * Here descaddr is the final physical address, and attributes * are all in attrs. From patchwork Mon Oct 24 05:18:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617847 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2515881pvb; Sun, 23 Oct 2022 23:17:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tsbkyXBxK9ZnCg4G5Ac0cgAtkxPVTPPbUvmID7YRDqVUoys9vP97PR4UmnppzridzLCVH X-Received: by 2002:a05:622a:148d:b0:39c:d2a5:dbb4 with SMTP id t13-20020a05622a148d00b0039cd2a5dbb4mr26409490qtx.284.1666592258230; Sun, 23 Oct 2022 23:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666592258; cv=none; d=google.com; s=arc-20160816; b=en8Bs++fXR2BVuQaK4ME20Rch+maHLfc6R94ysLaedPuG/lLcU8C4VvBi+eaDU8AEu 4FOjxhXtvb7D6qr60W/VFoOsWDZoR6UW7CyYLkkfHyQVuJEeTxlt0m/OQLDt/PajTSk1 y8i8rYVBLRmwQ1oqgjA+i2zI7vp4i35l65jf7gw5KJkwn0VkYFA42zj/uO5e4s1UAZtM +ejoCT5Fo+hZgBHACCqrc3l67A9b+T97xSszMXWo/g+1k+aiMO8Wtfa2ZkDcxShkrfIG FRfqJMmMGCmoWT298TGvRmm5WZ8wljncPXO2Y03quIFwmZJFmSuwLDEMR0oDclfR/lHG D+ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sdisIrMnl1TYgX+y3Jca2Lvj3mz6slgwmrdpC7jGGrw=; b=CyFplnJL+AaVDdjIBSRRQWMVpj5ttnRJR9M6IlytfvJf3D6Z10xhqmYr6GF4AqCben 29+cZw6T2hd79H1TQUtfMtAwrpLwQG/MWBCdZ1Vv7Ac6CHMbmcLWUNLLH8VQSWAjaCU6 SMFDDtFL2PtKGWkcBOrGHxxq4c1kIsK8Ox2JnaphZ/4cykRoNtiHtm6j6smEAfH2QLI9 rSz7Iar53k4Xwj3iUdv2tM+xfxSsV4nLrmcA1HjYuVVEpfg6C6yCh3glJ4KqjIPRSc3y zQJwcUrFdcHA9LWbDy162SBu8PPvIt+I/vhIB1nFBOCkDX30At8qi6qoGK87rSJ6MmWV lHwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=og12VUip; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jn1-20020ad45de1000000b004ad0cc999besi15901753qvb.347.2022.10.23.23.17.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:17:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=og12VUip; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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ée --- 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, S1Translate *ptw, ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = ptw->in_mmu_idx; bool is_secure = ptw->in_secure; - /* Read an LPAE long-descriptor translation table. */ - ARMFaultType fault_type = ARMFault_Translation; uint32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1101,8 +1099,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, * so our choice is to always raise the fault. */ if (param.tsz_oob) { - fault_type = ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } addrsize = 64 - 8 * param.tbi; @@ -1139,8 +1136,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, addrsize - inputsize); if (-top_bits != param.select) { /* The gap between the two regions is a Translation fault */ - fault_type = ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } } @@ -1166,7 +1162,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, * Translation table walk disabled => Translation fault on TLB miss * Note: This is always 0 on 64-bit EL2 and EL3. */ - goto do_fault; + goto do_translation_fault; } if (!regime_is_stage2(mmu_idx)) { @@ -1197,8 +1193,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, if (param.ds && stride == 9 && sl2) { if (sl0 != 0) { level = 0; - fault_type = ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } startlevel = -1; } else if (!aarch64 || stride == 9) { @@ -1217,8 +1212,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, ok = check_s2_mmu_setup(cpu, aarch64, startlevel, inputsize, stride, outputsize); if (!ok) { - fault_type = ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } level = startlevel; } @@ -1240,7 +1234,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr |= extract64(ttbr, 2, 4) << 48; } else if (descaddr >> outputsize) { level = 0; - fault_type = ARMFault_AddressSize; + fi->type = ARMFault_AddressSize; goto do_fault; } @@ -1301,7 +1295,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) { /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; + goto do_translation_fault; } descaddr = descriptor & descaddrmask; @@ -1319,7 +1313,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr |= extract64(descriptor, 12, 4) << 48; } } else if (descaddr >> outputsize) { - fault_type = ARMFault_AddressSize; + fi->type = ARMFault_AddressSize; goto do_fault; } @@ -1376,9 +1370,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, * Here descaddr is the final physical address, and attributes * are all in attrs. */ - fault_type = ARMFault_AccessFlag; if ((attrs & (1 << 8)) == 0) { /* Access flag */ + fi->type = ARMFault_AccessFlag; goto do_fault; } @@ -1395,8 +1389,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); } - fault_type = ARMFault_Permission; if (!(result->f.prot & (1 << access_type))) { + fi->type = ARMFault_Permission; goto do_fault; } @@ -1441,8 +1435,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.lg_page_size = ctz64(page_size); return false; -do_fault: - fi->type = fault_type; + do_translation_fault: + fi->type = ARMFault_Translation; + do_fault: fi->level = level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ fi->stage2 = fi->s1ptw || regime_is_stage2(mmu_idx); From patchwork Mon Oct 24 05:18:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617840 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2497204pvb; Sun, 23 Oct 2022 22:24:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bpgmKw9jIXCLEltNLOwz2XsMlOVaKlkPDLGB5TcxKDHbPYMytsP6M7jwd17p/p5ymjnwL X-Received: by 2002:a05:6214:2528:b0:4b8:2025:5f6b with SMTP id gg8-20020a056214252800b004b820255f6bmr17732442qvb.47.1666589088636; Sun, 23 Oct 2022 22:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666589088; cv=none; d=google.com; s=arc-20160816; b=hY53luuuJA4ywJMIXXfkUOkVlakxiv33+gbl6Ovn5c8C9Uc4xeHmyW1JKyNPWvhEEv CBc8p/kWXfjEG9vuHK45jACJ6cQNvWH0e89PecPDD2sGjVg/HpQ4oOyggLAgxyJAfiI4 1m+Js7A+Zhy27Q4zboFg0igouFvrKhHzKaTgpfyzW1RkyHjH1dMY+l7s9mHc3CPE43vq mNdFzIC2hViKLqUxi7G8JxSPJi/T5r+ZirilQv2X7/+T5Mhh5QFcVjezxKe7zsE0aloG L4nuSiFsJcWdyOoP6ZXI0O//4pXBcv9wgEaCSjLDD/M0448Cz6MBwTHYeI5jCumLTmIe +62g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5O6PpkAZ96UkPrcZ1NBYigHKXmNVYdvvRThaoFMyO3o=; b=TmU613wQXHzetP3X9qdgiEhscynMnMkBoQO9msLo3BnYTzH4nw/mS/AXedilm2hFLD cbruCt9antJg9LuM2gaV6KAU5Fui625WFpxwxof/mL1AxyS66wJdgEaN3GWuTh/Q2GlL JpMv53a0Z+awIZKgFLuKq4ePvcm7W7puQ+QdFNNtF//j5b5ljvqyVudy0NH8+ZzECt79 qMMBavAT/HplZIFreHcCWZ+CPbDiniXFRmEHgn4tMuIkGkR3FxEalb8It9eHkZQ5Qbd0 /fzvm7xofXiMg8zEGDXMT4WC2LgccgcV+b76oL0DrX5lNQkrZzGVB7oIVCtsNbFhWc39 rJ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a3ka5AeC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t22-20020ac865d6000000b0035cbddbaf4csi15271188qto.477.2022.10.23.22.24.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 22:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a3ka5AeC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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é --- 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, S1Translate *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 = regime_tcr(env, mmu_idx); @@ -1343,49 +1343,48 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr &= ~(hwaddr)(page_size - 1); descaddr |= (address & (page_size - 1)); /* Extract attributes from the descriptor */ - attrs = extract64(descriptor, 2, 10) - | (extract64(descriptor, 52, 12) << 10); + attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 12)); 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 |= nstable << 3; /* NS */ + attrs |= nstable << 5; /* NS */ guarded = extract64(descriptor, 50, 1); /* GP */ if (param.hpd) { /* HPD disables all the table attributes except NSTable. */ goto skip_attrs; } - attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ + attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 * means "force PL1 access only", which means forcing AP[1] to 0. */ - attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ - attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ + attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */ + attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */ skip_attrs: /* * Here descaddr is the final physical address, and attributes * are all in attrs. */ - if ((attrs & (1 << 8)) == 0) { + if ((attrs & (1 << 10)) == 0) { /* Access flag */ fi->type = ARMFault_AccessFlag; goto do_fault; } - ap = extract32(attrs, 4, 2); + ap = extract32(attrs, 6, 2); if (regime_is_stage2(mmu_idx)) { ns = mmu_idx == ARMMMUIdx_Stage2; - xn = extract32(attrs, 11, 2); + xn = extract64(attrs, 53, 2); result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); } else { - ns = extract32(attrs, 3, 1); - xn = extract32(attrs, 12, 1); - pxn = extract32(attrs, 11, 1); + ns = extract32(attrs, 5, 1); + xn = extract64(attrs, 54, 1); + pxn = extract64(attrs, 53, 1); result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); } @@ -1410,10 +1409,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format = true; - result->cacheattrs.attrs = extract32(attrs, 0, 4); + result->cacheattrs.attrs = extract32(attrs, 2, 4); } else { /* Index into MAIR registers for cache attributes */ - uint8_t attrindx = extract32(attrs, 0, 3); + uint8_t attrindx = extract32(attrs, 2, 3); uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; assert(attrindx <= 7); result->cacheattrs.is_s2_format = false; @@ -1428,7 +1427,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, if (param.ds) { result->cacheattrs.shareability = param.sh; } else { - result->cacheattrs.shareability = extract32(attrs, 6, 2); + result->cacheattrs.shareability = extract32(attrs, 8, 2); } result->f.phys_addr = descaddr; From patchwork Mon Oct 24 05:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617846 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2514718pvb; Sun, 23 Oct 2022 23:14:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6A+NX4JFXVFv45Ef2RNuJPdR/JO+vGbsjRTSrjkunJ39uRewbcPabaV4p3VqJSocD0Q4Xf X-Received: by 2002:ac8:4615:0:b0:39c:fa1a:aeb5 with SMTP id p21-20020ac84615000000b0039cfa1aaeb5mr24525225qtn.176.1666592074584; Sun, 23 Oct 2022 23:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666592074; cv=none; d=google.com; s=arc-20160816; b=LPvWdTGfvsTGxRmZjKos57OBG4QDr+ttWIuVYJf7ipPUdDAmeNf5VNKRRMLwTsWgkF 0pZlR0JAWWIsSqplmxcPY2nUKgHk423qA0zR+p4AlxQoerw5nnqA1yIw5870P/aGTztQ Oy+1ZAmjSeGyjJiL8nohiP3H4kWjS1GLcGj54GMvtB2MHsxBYHEYtk3dkNZ/vKQ3Cmkv 0Lf4qD+GmOoj8vdRahMI3nNxP11F25OdA9ZTE1Fiy0Ed58eawQWGgp5Akw/VMxESs8n3 fvl8TBYcR9vjvlX0a1Nw9QF0ZKe9KvINF9hJuDRPyuKtX0TfltJ4MzzBHIcioX+9trq2 GnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IWw+aq7JNeHsl9fq/os7SQInlY545GVW3QOnHQy7rg0=; b=U4J7YZJ6ELAxUjF6UHAJ37QbVWBvDc3VR6oGp+OcaFuO3yIfYl1eln1zlJBseAYdjy jn/NqUg+ob0JJ8iXAuwztPrJqAlTgWRhklN9a2Y9dYHqBmBS/WH/v68iIEntsaCxDku4 lS8fMQuR9Z8DSpBF55Oj7MEJljv7kiUvFzXSGrXfIHtTTE5A2sZXcP5b7gSHRD6ZfcFy 8+/wfpnwlRqIcx73aLF1B1A3uZm7XaGStwKDsNv1ej3/UJnte7FsB6txC1nS1jqHEHZ1 KODkBnkQnJBiAl6y8LajLxls1epqT8h72tbhuAfk45nP0F1C8sjT99V71uAw76Fbqx8P djTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zClpVoaH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bm11-20020a05620a198b00b006eb52f0e3b5si17106586qkb.603.2022.10.23.23.14.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:14:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zClpVoaH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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, S1Translate *ptw, uint32_t el = regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); - bool guarded = false; uint64_t descriptor; bool nstable; @@ -1343,7 +1342,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr &= ~(hwaddr)(page_size - 1); descaddr |= (address & (page_size - 1)); /* Extract attributes from the descriptor */ - attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 12)); + attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); 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, S1Translate *ptw, } /* Merge in attributes from table descriptors */ attrs |= nstable << 5; /* NS */ - guarded = 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, S1Translate *ptw, /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { - result->f.guarded = guarded; + result->f.guarded = extract64(attrs, 50, 1); /* GP */ } if (regime_is_stage2(mmu_idx)) { From patchwork Mon Oct 24 05:18:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617845 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2513167pvb; Sun, 23 Oct 2022 23:10:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hL8atAND7HYhV8JdZdbv7rrHdME5bhiiZQKjEhLpkE3AYlcMnIVm0iarzcrwHO11xf22H X-Received: by 2002:a37:8dc6:0:b0:6cf:33cd:2c4f with SMTP id p189-20020a378dc6000000b006cf33cd2c4fmr21213075qkd.372.1666591822504; Sun, 23 Oct 2022 23:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666591822; cv=none; d=google.com; s=arc-20160816; b=vE/sKZ/m67/Pu4ZJTkA+9jrhJWSZFBaNI/yXBS8zv6MCwPVrKcg4vmstzlZIU+RDnY tmogbxBm7+Ij6REDOJ4QCuVr7hJjLi23hyUdGqK/nEdvAYVa+qDB9Iks5LGy77cRVwi5 +zoskmiCWxemPNoINMOocbxT40Q7WFusNLh3s6XhoyPqNWkNTiCdIuKZIHzL/joyYSEz +1eW0ToGey0Th0Zm7LL+gM2onUT1Y6cNHzY1Oqtk5yFXHrmqtImPkwmJ7GsVl+2Xanqv A30vL80aBYi11KVBV9POhy+gONy9GJIfmhi0Ee+tZVSSRqNE+DC8Ms1hqJau3/Olsco6 PdVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1vmy8B3i0MTxOCpkYy56RCPt7fyDU4i6hN7JG5wlZ40=; b=srXMF2i0a+vrfgIjPi38EbvDlKRao2C9176j103+Qwk3n4Nz07+3Sdzrxcv8uc/rnK 0AQ9cntMTiUYMibwsBE6z0D79hQI6PPxN1sEO/I0FyKNISObCKEVLL3JlYwbxXnvRhgN zO8fmlRyQntpEKdkEv5/Y8bH4mSj2aKgB9IFnFpbE21NYqOrQThhe6Xnyzu8QNqb4vv2 xL1de/SJKCs1sMn3GFeNDUkWUauSwNvWrznEcJv9ZsOIRVepE+UTFrsvxBbKf4jY9f/Z tvjT+5yXRqkxHNdDDx1AF+cbwika93Hbk+gVvSKMfuRv2poAiJsRrcdAx/rhCoaGGqj0 Fcgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TQcBUOk9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s20-20020ac85ed4000000b0035bb6064313si15451055qtx.170.2022.10.23.23.10.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:10:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TQcBUOk9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Replace some gotos with some nested if statements. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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, S1Translate *ptw, page_size = (1ULL << ((stride * (4 - level)) + 3)); descaddr &= ~(hwaddr)(page_size - 1); descaddr |= (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); - 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 |= nstable << 5; /* NS */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - goto skip_attrs; - } - attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 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 &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */ - attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */ - skip_attrs: + attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); + if (!regime_is_stage2(mmu_idx)) { + attrs |= nstable << 5; /* NS */ + if (!param.hpd) { + attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */ + attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */ + } + } /* * Here descaddr is the final physical address, and attributes From patchwork Mon Oct 24 05:18:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617843 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2511073pvb; Sun, 23 Oct 2022 23:04:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6cufhUXu/wnUHwD1aPJnUbp0OWhKA48aysQ4LbOgVdmTozbcOFGor+z2h6993830m8qlHi X-Received: by 2002:a05:6214:250c:b0:4b1:a1e7:1d89 with SMTP id gf12-20020a056214250c00b004b1a1e71d89mr26419477qvb.1.1666591489576; Sun, 23 Oct 2022 23:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666591489; cv=none; d=google.com; s=arc-20160816; b=eJ/+7I9cfVEjEYdhxGAYcbgf0cu1nqXXDKv2Djg5Ye7yZNsM0x+Z2y9jAcaKclAYK5 SB9C1Of56QSO0fzfDlKJjwUsX/nsEDKKpNSP6dSVPC4yRTofmJWIrQrZYJz0paRKqsVc 1IJD6OxQ1miVrnZW9UyWAJW/dz3cHWaN5ff1pdCLBWol1iiWZNPC8wVZxLiHEw9GPUbT pfHSDIH3iDQWI/Q4bh1Eqo0rvgiLoieC1GDvCPrbrTIM0mhhbWoyFGJymh72WxD6IABg tVs/fcJc3Ylb6I64OK6ccL+SIOSHMNvM1XJvWViBlt8MRYSr5XlpM2+TayjyVxs2X7dN DM7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vqqhe7ok+952FMeoYC9dG+eusN1LKoZKt0UmNCjl0DQ=; b=JY4M3tzloNVDgLXPxexY9gkUzRxIvy6Tdxn+/zCh5jo8jt3OsYqMV7fsmUAJL5lHLF HjL/eNPvUCMz2kmo7tSUB0zX5Ew2iiIGwYR6Qzr0DBVNIA9TaVAQzS8I2Xu4k5Tg6gNn WsF75cd7gdS71CSB5urkKyH7IF8v8qh7Bz9ayfqB4ediJU6yAMMxJz6i2YFccyjNi4Zu pcahIRmfA4tKxVTLcr6Hu0pS/gvN6ROIoN2SHboX1uDOQ2LPmoVwSbYbhE2rlwSf3HgB tqgNWMfiIn8HAsYZKE4nDkuHO6ZMGY4E9H6XZpRola6X+Yixe+hxxIK+vUe5U6mhKDC3 dC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lA3VuMzH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s20-20020ac85ed4000000b0035bb6064313si15445862qtx.170.2022.10.23.23.04.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lA3VuMzH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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 = t; t = cpu->isar.id_aa64mmfr1; + t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF only */ t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ t = 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, S1Translate *ptw, uint8_t pte_attrs; bool pte_secure; + ptw->out_virt = 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, S1Translate *ptw, pte_secure = is_secure; } ptw->out_host = NULL; + ptw->out_rw = false; } else { CPUTLBEntryFull *full; int flags; @@ -280,6 +285,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, goto fail; } ptw->out_phys = full->phys_addr; + ptw->out_rw = full->prot & PROT_WRITE; pte_attrs = full->pte_attrs; pte_secure = full->attrs.secure; } @@ -323,14 +329,16 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs = env_cpu(env); + void *host = ptw->out_host; uint32_t data; - if (likely(ptw->out_host)) { + if (likely(host)) { /* Page tables are in RAM, and we have the host address. */ + data = qatomic_read((uint32_t *)host); if (ptw->out_be) { - data = ldl_be_p(ptw->out_host); + data = be32_to_cpu(data); } else { - data = ldl_le_p(ptw->out_host); + data = le32_to_cpu(data); } } else { /* Page tables are in MMIO. */ @@ -356,15 +364,25 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs = env_cpu(env); + void *host = ptw->out_host; uint64_t data; - if (likely(ptw->out_host)) { + if (likely(host)) { /* Page tables are in RAM, and we have the host address. */ +#ifdef CONFIG_ATOMIC64 + data = qatomic_read__nocheck((uint64_t *)host); if (ptw->out_be) { - data = ldq_be_p(ptw->out_host); + data = be64_to_cpu(data); } else { - data = ldq_le_p(ptw->out_host); + data = le64_to_cpu(data); } +#else + if (ptw->out_be) { + data = ldq_be_p(host); + } else { + data = ldq_le_p(host); + } +#endif } else { /* Page tables are in MMIO. */ MemTxAttrs attrs = { .secure = ptw->out_secure }; @@ -385,6 +403,91 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, return data; } +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 = ptw->out_host; + + if (unlikely(!host)) { + fi->type = ARMFault_UnsuppAtomicUpdate; + fi->s1ptw = true; + return 0; + } + + /* + * Raising a stage2 Protection fault for an atomic update to a read-only + * 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 = fi; + flags = 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 = NULL; + + if (unlikely(flags & TLB_INVALID_MASK)) { + assert(fi->type != ARMFault_None); + fi->s2addr = ptw->out_virt; + fi->stage2 = true; + fi->s1ptw = true; + fi->s1ns = !ptw->in_secure; + return 0; + } + + /* In case CAS mismatches and we loop, remember writability. */ + ptw->out_rw = true; + } + +#ifdef CONFIG_ATOMIC64 + if (ptw->out_be) { + old_val = cpu_to_be64(old_val); + new_val = cpu_to_be64(new_val); + cur_val = qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, new_val); + cur_val = be64_to_cpu(cur_val); + } else { + old_val = cpu_to_le64(old_val); + new_val = cpu_to_le64(new_val); + cur_val = qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, new_val); + cur_val = 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 = qemu_mutex_iothread_locked(); + if (!locked) { + qemu_mutex_lock_iothread(); + } + if (ptw->out_be) { + cur_val = ldq_be_p(host); + if (cur_val == old_val) { + stq_be_p(host, new_val); + } + } else { + cur_val = ldq_le_p(host); + if (cur_val == 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, S1Translate *ptw, uint32_t el = regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); - uint64_t descriptor; + uint64_t descriptor, new_descriptor; bool nstable; /* TODO: This code does not support shareability levels. */ @@ -1291,7 +1394,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, if (fi->type != ARMFault_None) { goto do_fault; } + new_descriptor = descriptor; + restart_atomic_update: if (!(descriptor & 1) || (!(descriptor & 2) && (level == 3))) { /* Invalid, or the Reserved level 3 encoding */ goto do_translation_fault; @@ -1337,17 +1442,36 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *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 = (1ULL << ((stride * (4 - level)) + 3)); descaddr &= ~(hwaddr)(page_size - 1); descaddr |= (address & (page_size - 1)); + 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 |= 1 << 10; /* AF */ + } else { + fi->type = 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 = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); + attrs = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); if (!regime_is_stage2(mmu_idx)) { attrs |= nstable << 5; /* NS */ if (!param.hpd) { @@ -1361,18 +1485,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, } } - /* - * Here descaddr is the final physical address, and attributes - * are all in attrs. - */ - if ((attrs & (1 << 10)) == 0) { - /* Access flag */ - fi->type = ARMFault_AccessFlag; - goto do_fault; - } - ap = extract32(attrs, 6, 2); - if (regime_is_stage2(mmu_idx)) { ns = mmu_idx == ARMMMUIdx_Stage2; xn = extract64(attrs, 53, 2); @@ -1389,6 +1502,25 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, goto do_fault; } + /* If FEAT_HAFDBS has made changes, update the PTE. */ + if (new_descriptor != descriptor) { + new_descriptor = arm_casq_ptw(env, descriptor, new_descriptor, ptw, fi); + if (fi->type != 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 != descriptor) { + descriptor = new_descriptor; + goto restart_atomic_update; + } + } + if (ns) { /* * The NS bit will (as required by the architecture) have no effect if From patchwork Mon Oct 24 05:18:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617842 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2508959pvb; Sun, 23 Oct 2022 22:59:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78Yg1kMvKiaVcU1SeiyOsUW9BuVzCmPY3RPxhEPCsBuVStvzj2Jyurtb+nD/7ZuMqj+IUQ X-Received: by 2002:a05:622a:1054:b0:39c:fff0:9d32 with SMTP id f20-20020a05622a105400b0039cfff09d32mr20665688qte.677.1666591193163; Sun, 23 Oct 2022 22:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666591193; cv=none; d=google.com; s=arc-20160816; b=0mwBgXSmC+uxHttbcCV2Sm1DI8B48VfKNf611BZtSw1y8aIKQ9nRwSblLr2oL4FfiY gb9TrIw8GDQJr5K6OZmp/XTQt06pwfQGXdqGrn/MywGjYZI2ICslSqROdRmf39cDG9cQ dUjlYvSogbn0ghL+IHEsOxglO2P9YdZj84BqL23SO1hNV1ZkPsGCFtDSpbhPYLRDXGBJ NZp78eGi2iAZOhhDUIZJFHGDNkLp7F3L7BX/zv5nAqbtQtxm1V4jBWGpp6/7tCpuoC1e OioUwe/mJl2Drro6zOUAjJ4Yjh2QyDgfaghfDPPcqQRjmUYG4zeQrqPz5AalC5RNOckl swOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fmhV53NBm0GuAqG7xZExjY3NVZwOXtngOnvaKeyYV/A=; b=Uw/GKr2K5Vhce5jwb/yZfiN73/fdQVr2wfgSLnTmg6nQSFVqDC80Bj9PNCld7pxf0g Y34oQBRaD3IKV9ceqLBO8qZIIXVul+jr3dTDgiCavMOW168EUKUvZqxnx2mUTkHeDn9i D804Cu8Ed4ucakQ6KIevaA8x9W8WSO0Xr2C7erw4Rt3PZx3mgMJSbkG/XTOQ2NMHIF0U NAcKCiePL5+t/w78P5y/3CwRp2frDWSBDGQxp6AjYXb7HNUPv58LkcFEcLHGp3uc0x4D fDH8pXHvlHSiqDI/KZeo2WmMQ1o6UlEpcIP+fdt2ixwMs0SN2j9AxbWEzU5uOU2YHYJ6 uI4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hD/hgcLg"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h2-20020ac85482000000b00399a6c4c4cesi15396297qtq.134.2022.10.23.22.59.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 22:59:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hD/hgcLg"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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 = t; t = cpu->isar.id_aa64mmfr1; - t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF only */ + t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ t = 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, S1Translate *ptw, goto do_fault; } } + + /* + * Dirty Bit. + * If HD is enabled, pre-emptively set/clear the appropriate AP/S2AP + * 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 == MMU_DATA_STORE) { + if (regime_is_stage2(mmu_idx)) { + new_descriptor |= 1ull << 7; /* set S2AP[1] */ + } else { + new_descriptor &= ~(1ull << 7); /* clear AP[2] */ + } + } } /* From patchwork Mon Oct 24 05:18:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617841 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2503169pvb; Sun, 23 Oct 2022 22:40:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6DtNNB4sSiKOKYbH+xMQP7wVCortrVm04OYqYOv65bJQhcxHeqWe1KdF8xH2XOfsytFa+3 X-Received: by 2002:a05:620a:1505:b0:6e9:168f:76a5 with SMTP id i5-20020a05620a150500b006e9168f76a5mr21753547qkk.142.1666590022804; Sun, 23 Oct 2022 22:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666590022; cv=none; d=google.com; s=arc-20160816; b=xsmnhpSwVhcZ42ZqkNJcz50IKKSli/eLTo7Vtw2tzeDdSW3VSOVvjl1NTtJQvgQu/G P5t7kcRFAZ9Ds7gWGCt5wkfIC1bKN/zeM/guIdw4zVlPYCwUTrg1RqaTUWeDYgnJECHf JJE3LtMlAeWBTcTD1lTzNI+vgAzRfPjzQc8UPx2sKzE78Pugk5h3XefLsvrMZLpbtyIx cwVct4ZVuIjOUL5cEXHm6Wn/jY9pSoL4pZvPpYLmbZKBuVjPD9fbFtnVC4e7pNwDrPLU EqgiREGZyPrRPVU18UgTkqufIX8Z11mX/IRsmAOLFO4vEL56u/utdNkEmltM18imeh0y 9abg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WUDIrJHIS5cE7phXWe1119p8UIq5Q+ilAQsTbi3H87M=; b=KrsE1hVmW6MB/C1ORwQaWuQUA3Zn2IfAxTw2ZhmRmTNZ4qtt9SBJMk9GkEJPB9X8uP FB+bV95VwKLGjxqAdNVIov/YG2GQ1VW6wijdbaK/+MT9id6hy0LRpkChDDjuwXphcN1k cFZHJMbwxlfVCmOkW884XNn3QkiLdjH39x3IOBxR9w/qZpNMFU/rj+H35ek41hK5Ytq7 z92yhQ1SnW66dPzU8uywHFXCx71pWccjB+/alPUZoaTs9RmBah1ZD/XUI6EYHhlsJK2b heqMTAVnsElGuy6grzsjsdZV1WgRKi/09uS2wtemTrQgAq55Ypv9lc4BLl9of4EgaGHs swjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LjrA9yHA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fo13-20020ad45f0d000000b004b8b28b3cfesi6485932qvb.213.2022.10.23.22.40.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 22:40:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LjrA9yHA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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 = 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 later. */ s1_prot = result->f.prot; + s1_lgpgsz = result->f.lg_page_size; cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); @@ -2639,6 +2640,14 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, return ret; } + /* + * 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 = s1_lgpgsz; + } + /* Combine the S1 and S2 cache attributes. */ hcr = arm_hcr_el2_eff_secstate(env, is_secure); if (hcr & HCR_DC) {