From patchwork Sat Oct 1 16:22:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 611401 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp282343pvb; Sat, 1 Oct 2022 09:52:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nh6vBC+shV7/R79lVc9dRiC5qtsXW6xJUR+FTBB2gjRfFnxgpbqYFd6xvArmB7dEyWtcA X-Received: by 2002:a05:620a:444e:b0:6ce:968b:d460 with SMTP id w14-20020a05620a444e00b006ce968bd460mr9590550qkp.240.1664643153009; Sat, 01 Oct 2022 09:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664643153; cv=none; d=google.com; s=arc-20160816; b=y0RUNxcEl1fvxNHwgFxuPvBF49yq09pyISA+gIH2+9MKvoceEynHYQvdi3AT4NJ/6g i10nZ1sf7QCUqvUzrqymJX3Txr684cblWFbztm5SG0BAmvMaTPzfVUCXuVq1az3tyB+c 1WkpvYO7eFKm8OHnpH2J2HJZ/6Th2JSjvFC/aojzEUSKc0/Ljd8T7GUlPC/nQO1m9w4s 10P99gayyfTA45QNcOfu5xEgzDRxZ9Umf/kl4s2+b1IGPI//YJT4Hc9G/w5Nw9X0OUOg Pgp6R7nR35JkWBv+zB/0GWOdS5L1LRgpOMo8xYHYi0tOXiQJIeZ2U4ZU1Xn5cDdPQ0TA /86g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=K3rpZd1EKThuVcaxZvC1gnAW/rSp7G0JgKV3rWVzF/U=; b=vo11x216VFlO/wit4GjsmSJrT6e5lwSJLCZvWXGgB4kxdhs4/22c9vQ0uqWjEMxLZ6 e1Ulb/Gd1w7s/wJENP7qZSsg28ce+ja3EGcH5s2ZsdpTbX9Pm+fwLDj9gMAUWyEWcBjZ mM95sz+155rzrHUWW5Iy7agwJqaxyYtWMwJwXsabeuePYxq5esQL+T05kAvUixbyf6+z GKI8a94i3daTW6VabvqjLpHgyu4w53V4bQvsEQExWZ1wHzFkcXzkSUB2adTzbzaB8ms/ om+HuWlYhneewEJz41MRXCm0odopr2RW81bhvfBA/WsglWKNmnmwgdXs1VH4DcZyjA43 KjIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ax2/MuvR"; 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 ef6-20020a05620a808600b006cdf0aacfa2si2367445qkb.730.2022.10.01.09.52.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Oct 2022 09:52:33 -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="ax2/MuvR"; 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]:38354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oefj6-00058f-IX for patch@linaro.org; Sat, 01 Oct 2022 12:52:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefHg-0006ox-9A for qemu-devel@nongnu.org; Sat, 01 Oct 2022 12:24:12 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:46856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefHe-0006Hd-4M for qemu-devel@nongnu.org; Sat, 01 Oct 2022 12:24:11 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id j8so4634387qvt.13 for ; Sat, 01 Oct 2022 09:24: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; bh=K3rpZd1EKThuVcaxZvC1gnAW/rSp7G0JgKV3rWVzF/U=; b=ax2/MuvRV0e/qM/5d/H45ZxqBfRqNzK1my09PMLQHUi1M0OFCKGMwUNiaDik9Bvv11 rB83RCT8CraxqZ2gTuqF2M1yDvAW+pmQHIsE+6GfaMExgA84HlozRGvCemJD6t+sdLfR zaRgk2X1aebi8PpSpTseudwwD/1T4CxG8bHoRPUXnuSmI3VZZhAtGVAuOPOmVRjN3+6v uvb7PWkzPotow0lwMWoFLN8wt1eGHw0rChZlHBm2PZbgGp4oUPr+t2c4hpt0+qcHxOos 5zb0PYpPkFQaH0Y6vzWhkizPvCW4ODziQy8QAgSmjPD+uIrp7xUtcNw0H2QTemLexYC8 MJAg== 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; bh=K3rpZd1EKThuVcaxZvC1gnAW/rSp7G0JgKV3rWVzF/U=; b=kO2jiMD3zPVjJNNTb/O7FhaBZYrvj6sweAdhUDEGQOhNSWVTT4Jl20k5rlBZVh2+TC 2DHEA7xZL7wFmVM4Z5arqRpnd01Ipwd4UJr8XWJijbiFChhIrXgjXGJCbJsLijVouepj RtP5EUnej6M+vid+akTLI9tDO5Nkh8bfvCT2BVzWq3/3gcwNNzLa48NhXhmS+JPLRzln /OfDG5QhSW8BVEhQQUOlPJODaP67qH6BNyBomB5MvoFfHQNfrm7T8bqlzPJn8B5fqS+V wAL+q7PMWLCJlwc2smvIQ20exeT7LTHVuKUcaFdMiT2T4LofIYUxXjQ/D0YWTGKcqahA qqAw== X-Gm-Message-State: ACrzQf0RVgf91egTSEUod4ZK5QDHMawcnXYk/oUsXsW/8FsmE+kyt62p TzXO48s8oTJaZab2upzr8x+2DxUCqaurTw== X-Received: by 2002:a05:6214:2385:b0:474:78de:f8dd with SMTP id fw5-20020a056214238500b0047478def8ddmr11227933qvb.66.1664641449269; Sat, 01 Oct 2022 09:24:09 -0700 (PDT) Received: from stoup.. ([2605:ef80:8084:91a4:f7cb:db31:c505:b931]) by smtp.gmail.com with ESMTPSA id t4-20020a37ea04000000b006d1d8fdea8asm4387445qkj.85.2022.10.01.09.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 09:24:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v3 19/42] target/arm: Fix cacheattr in get_phys_addr_disabled Date: Sat, 1 Oct 2022 09:22:55 -0700 Message-Id: <20221001162318.153420-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221001162318.153420-1-richard.henderson@linaro.org> References: <20221001162318.153420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not apply memattr or shareability for Stage2 translations. Make sure to apply HCR_{DC,DCT} only to Regime_EL10, per the pseudocode in AArch64.S1DisabledOutput. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v3: Do not use a switch or a goto. --- target/arm/ptw.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index e494a9de67..8d27a98a42 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2282,11 +2282,12 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { - uint64_t hcr; - uint8_t memattr; + uint8_t memattr = 0x00; /* Device nGnRnE */ + uint8_t shareability = 0; /* non-sharable */ if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { int r_el = regime_el(env, mmu_idx); + if (arm_el_is_aa64(env, r_el)) { int pamax = arm_pamax(env_archcpu(env)); uint64_t tcr = env->cp15.tcr_el[r_el]; @@ -2314,32 +2315,33 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, */ address = extract64(address, 0, 52); } + + /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ + if (r_el == 1) { + uint64_t hcr = arm_hcr_el2_eff_secstate(env, is_secure); + if (hcr & HCR_DC) { + if (hcr & HCR_DCT) { + memattr = 0xf0; /* Tagged, Normal, WB, RWA */ + } else { + memattr = 0xff; /* Normal, WB, RWA */ + } + } + } + if (memattr == 0 && access_type == MMU_INST_FETCH) { + if (regime_sctlr(env, mmu_idx) & SCTLR_I) { + memattr = 0xee; /* Normal, WT, RA, NT */ + } else { + memattr = 0x44; /* Normal, NC, No */ + } + shareability = 2; /* outer sharable */ + } + result->cacheattrs.is_s2_format = false; } result->phys = address; result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; result->page_size = TARGET_PAGE_SIZE; - - /* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ - hcr = arm_hcr_el2_eff_secstate(env, is_secure); - result->cacheattrs.shareability = 0; - result->cacheattrs.is_s2_format = false; - if (hcr & HCR_DC) { - if (hcr & HCR_DCT) { - memattr = 0xf0; /* Tagged, Normal, WB, RWA */ - } else { - memattr = 0xff; /* Normal, WB, RWA */ - } - } else if (access_type == MMU_INST_FETCH) { - if (regime_sctlr(env, mmu_idx) & SCTLR_I) { - memattr = 0xee; /* Normal, WT, RA, NT */ - } else { - memattr = 0x44; /* Normal, NC, No */ - } - result->cacheattrs.shareability = 2; /* outer sharable */ - } else { - memattr = 0x00; /* Device, nGnRnE */ - } + result->cacheattrs.shareability = shareability; result->cacheattrs.attrs = memattr; return 0; }