From patchwork Mon Oct 10 14:27:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 613753 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2025962pvb; Mon, 10 Oct 2022 07:55:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4PMG/YvXwBcOVaSisj9HEYbp9ttlBP/Qcp+CzHB9Ak3tkPW7avn/+HaBlGoCWW+UDAtHYI X-Received: by 2002:a05:620a:c04:b0:6e5:9234:90ea with SMTP id l4-20020a05620a0c0400b006e5923490eamr12517843qki.360.1665413712336; Mon, 10 Oct 2022 07:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665413712; cv=none; d=google.com; s=arc-20160816; b=KBj50coSxVR8P6X8TW3hvDc45zHrii25PAod1PA310rN/OOmP1faDofSXo7/8MsxLs imtO5FRBd87bXqrTbkseK+NWHoQYpCsFmj0RwwWtnXB3g7ewU+HA9LwlD2/nM60+l92Q Xv+ICixtmnBJORrGg44yq6JSqN4q7GwWM1KfuoWCuaCxFKzrexkKdH48beIXE6NftHHu Tgq4Hg/Cdql6oPV+AykIB3QF6BlpxJ9qqC+WksTM4OaUrBml9VGT2R30QZjmTItCIbT+ VdrK4uJe/T0POC05dDKqsd3eU6eZVHOUq7fBcZQzA3FlfiZ/btnOrgD3DEs5RxnQzKQE Zh2g== 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:to:from :dkim-signature; bh=uYAkUC1FMKDAZVTYLTGfkDMxAgY5msooi2W/EbleAk8=; b=Sh1VQ7yPFOvCAc5Oi7EZa6mpLCEwVecd3l3DmsYcy4VCNY+R3oLSVJbHxsvAAf1v/8 zcXZqAsWwB5pWk+y6QNNDbZ3NRKP6kwSI8JT+gnuZr6I/9NcsTL867CFYPgajhbzOVDE FF1JoHGxW6Pp1x2UVzolkRfImgLHg78JNvt5He6fcL8leNYoWVbWlB9221YJtAN5InPx wzOmpdj736pFy2QLuVZuyBYf3RSiSF8AfGnGRWdcyf73euvsKGuZ9Vz3dq8Dy99847mG eL92Qem/hF3pm++TRSda2NFqq31n8PlzE2zoKf9b04uj4CbHA70Q6pIgUceV3NBeIJwv kX2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a5toCK5D; 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 5-20020a05621420c500b004b17b26d393si5864335qve.116.2022.10.10.07.55.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 07:55: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=a5toCK5D; 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]:57954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohuBT-00072g-Qi for patch@linaro.org; Mon, 10 Oct 2022 10:55:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohtl9-0006V7-BI for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:27:59 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:35609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohtl7-0005X6-Md for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:27:59 -0400 Received: by mail-wr1-x42e.google.com with SMTP id u10so17326670wrq.2 for ; Mon, 10 Oct 2022 07:27:56 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uYAkUC1FMKDAZVTYLTGfkDMxAgY5msooi2W/EbleAk8=; b=a5toCK5D90RjDRU5Rtffi+lIWAIcjGH1vveQqSn4DXu3eVLmb7b4aed8aYQ+uXRhpA 759lL5qO8iVS3k356LiWLVRi1o4OmWyAEV0y3UnJ8AHSsrfu7hFsi+ozJ1FguYdNsIFK vNlljongbT7JVaYWxYwFSbuQkA1kwZDc+EY6iWpewyJ97I3stLinz/k5NAhW0g84LEV2 Ke7FJ6bQimgOxAKZvEZySJgR3Uad5FOYYVOR9i17uLm81hG1ReSU+FGTKG8eoPE65Axs VkRRCc1lpoTyp/NUMWuuwSNaW9yrmnlOzyre8wRiucxKauPll085BqyESsifKKHKI4Gi aRng== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uYAkUC1FMKDAZVTYLTGfkDMxAgY5msooi2W/EbleAk8=; b=mpIUdFu8h/uACn6WxjRLR/ZNwuPvRKU38QJV0Z0ZJqAuqf6DfLs+S8q//FqcTZZCxN 7rGPHUZApzlIhEG/PY5ugeKrwfB9Q8few8qcsg9mY7Ka3JYTzNddaU62xOQQirc7//LY jnr7ARFlglAQ8Zoj0xmCxHkRru8bjbzCQtHvGSnKKBaQEsjMv2Iu0Iz5nvPrWx+RPX/5 Sg/v4SuFXVN9pFYcTsz29pSl9Tld951RdIxK+Cj60k8G/cOpSZ41FqOh2sUJb++V+H1z Po/WAulNFBfd328dJdsSS7q27OYNkmji1OysIQhHiqnDNWqATucQOj75N+OjrH/vjHIY DISQ== X-Gm-Message-State: ACrzQf26REInijkElCXaeFh4Q7aQNNQlUUwPikVISXE3UcbeHxC+51iP c2Y0HjR7YdQeNFhoO8bzySP9XbaUAVT1cw== X-Received: by 2002:adf:f14b:0:b0:22e:f162:f728 with SMTP id y11-20020adff14b000000b0022ef162f728mr9053710wro.681.1665412076338; Mon, 10 Oct 2022 07:27:56 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id u6-20020adfed46000000b0022e04bfa661sm9037054wro.59.2022.10.10.07.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 07:27:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/28] target/arm: Fix cacheattr in get_phys_addr_disabled Date: Mon, 10 Oct 2022 15:27:25 +0100 Message-Id: <20221010142730.502083-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221010142730.502083-1-peter.maydell@linaro.org> References: <20221010142730.502083-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" From: Richard Henderson 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 Message-id: 20221001162318.153420-20-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- 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 96ab99c7b6f..15c37b52c97 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; }