From patchwork Wed Oct 9 00:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833810 Delivered-To: patch@linaro.org Received: by 2002:adf:a1d9:0:b0:367:895a:4699 with SMTP id v25csp555732wrv; Tue, 8 Oct 2024 17:06:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXJG+DWWZI1UbXgyj8Caq50HZoP/yrBE8+wRKVyIeQXNEj+dm5eRjHg4+ODYZFhZ5YyDJDKsA==@linaro.org X-Google-Smtp-Source: AGHT+IFfh5X1WB6rVMc8JjwUJNnmUKitBbjVe/XcKs6pqUShv/LRg6h6iU+FDbS9XBPZ7v+MTiSt X-Received: by 2002:a05:620a:1a8e:b0:7a9:a991:f6d7 with SMTP id af79cd13be357-7b079547907mr101780285a.48.1728432366523; Tue, 08 Oct 2024 17:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728432366; cv=none; d=google.com; s=arc-20240605; b=DOw8AIdZni49eIYXWQCt/2Jk10v5Xa0suBuPr2f6Va8DwUVa+MZn1t0ai2RyAsHG1y WEIb4Jlx+q04bJfF7sO8VeTuNqpyv5dIuj6HCKmtLBwxlNloSTOckY/hO8uBY8ZgC8gT 9WMtcOWIWoZg5yBM7/B2iTVjPbK/NUbh1qxMywTb+hx0N2EsKLvzYy+Cgo1+L81oiEko ZjNi0m/CppFaT9fGhl8hd2s5qqrd8poAFxtr+dZZUd1L3DJtz1QAE3fdiDZytUTa0nNN 0J9ZbS0d/OKSGZCVRcknbX6iiGEdsvNBxq5+0rmriGwAskmDPWlapBrbbOVdTuM/niz1 zqWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=oOELs1GBJLtlq8nQGFT7BbF8Y02om3aScvqBsVkX7+Q=; fh=rQg8EQ8KH04w/0VkDYF6/ktgEyHJ2dqn1eatHCfBaLw=; b=hoYYWQAnOi66jaBQo1RhCo1GSb13EtDFM7vZAwYJocQIU4wSssUyxeFWfsRTGNFGtO 2HjEijJkHDQE6G3DpYYB7JmEP77iUxL8yvGH/jAJacMuguvphIxxEc43V9dDU6Gc7QcM zWEaT+eRE8I35p85g1NPfOxR/Ecs1ua8DKeEiC0xffvF5kl5GldYVOXcfGpwUGXv1tua Qa+Jv+5NX1uazzCgHDEYgsKk0Euk3qnhEniFCJqIz8j02PAR18vTs5EWRyLVtZv/Uluw UpwkuoTCiY0RXcSH+n4I+uaM1IChx1GESngiT9P5H+YahXx8BVFt9P2FJERpZGGNEdK6 hAyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O05Tx7zV; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7afc60ab1a2si234924885a.137.2024.10.08.17.06.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Oct 2024 17:06:06 -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=O05Tx7zV; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1syKCc-0004UD-Lr; Tue, 08 Oct 2024 20:05:18 -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 1syKCZ-0004Rn-O2 for qemu-devel@nongnu.org; Tue, 08 Oct 2024 20:05:15 -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 1syKCX-0002wE-TO for qemu-devel@nongnu.org; Tue, 08 Oct 2024 20:05:15 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-20ba9f3824fso47871655ad.0 for ; Tue, 08 Oct 2024 17:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432312; x=1729037112; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oOELs1GBJLtlq8nQGFT7BbF8Y02om3aScvqBsVkX7+Q=; b=O05Tx7zVQ0y2zGS9Q6GqBAi4Ceok4SaAAPjFEZdlHdbxA2DwQcLdA2KSF6ltKKcyik 2qOiQeIvxoa7S0yw+9D2/xijqAPr3+NoKw264v+K7wDmbrJ3KZaQDCQ9K8GeVZBQ/1hi E+We2sccOBiPa2ZLnMGjrbP8N5w0FleyWV74vY3UYqxs81SBfUPw7dG0PeorDyOWBT62 qher5a7I45cokEAl68NrWYV1+Qu+LioWPs9IIgXcBKqIe4YBWEovsnB0yTxF2ZYPr2A/ EUWAcOl8MhaL976Qp0fzqMXxEI+pnRoKLTFGR1lLsiNpQ8iitfVaJxaoy589q04XkD3E MQQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432312; x=1729037112; 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=oOELs1GBJLtlq8nQGFT7BbF8Y02om3aScvqBsVkX7+Q=; b=CgADoFpt/Q6AxxOwN1LkgNTKJgZWTQz1aOPHp9DTwlxntHo41R97XqCO7BrqcyAUu8 w0drRCKtanhjzPtoLdAMy6dbAeM4z4v3ksIT08s84U50tlydzPLId3H6b7paSjVqrrjW +J/xzmcA6O4kTANDVcw05t7ZfjZfzWrGK6qIOpyAE4uvxYzFEH1pu9QbgjpKE9flNFNk zcgQbIpBHLnWX+LGQtgxAQ/aZh7yZMCqLl1gbGJf2by30tlNzikzy/IokNvn+AD/xoGl 6p8ePsxyie7jAL6dq22v8jQPSEVsDPpU4zRrfWi5lGSjQPuLcd9kCWcXyX72/XucDzoa +9Ag== X-Gm-Message-State: AOJu0YyRYK2ek6IVKXaYTld6txgqzz8Hi6qSdHwg16SwVgme4gg77nSG mlUdwuIw/ruh7PzterEi8uHDV8zWFdi8x7zK37FhG9mn5E2YZ+eLjklDryUtAcsE+AvKfZGkM5K g X-Received: by 2002:a17:902:ce91:b0:20b:54e5:e822 with SMTP id d9443c01a7336-20c6377b24fmr8881225ad.21.1728432312463; Tue, 08 Oct 2024 17:05:12 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 18/20] target/arm: Move device detection earlier in get_phys_addr_lpae Date: Tue, 8 Oct 2024 17:04:51 -0700 Message-ID: <20241009000453.315652-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Determine cache attributes, and thence Device vs Normal memory, earlier in the function. We have an existing regime_is_stage2 if block into which this can be slotted. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 238b2c92a9..0a1a820362 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2029,8 +2029,20 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, xn = extract64(attrs, 53, 2); result->f.prot = get_S2prot(env, ap, xn, ptw->in_s1_is_el0); } + + result->cacheattrs.is_s2_format = true; + result->cacheattrs.attrs = extract32(attrs, 2, 4); + /* + * Security state does not really affect HCR_EL2.FWB; + * we only need to filter FWB for aa32 or other FEAT. + */ + device = S2_attrs_are_device(arm_hcr_el2_eff(env), + result->cacheattrs.attrs); } else { int nse, ns = extract32(attrs, 5, 1); + uint8_t attrindx; + uint64_t mair; + switch (out_space) { case ARMSS_Root: /* @@ -2102,6 +2114,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, */ result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, xn, pxn, result->f.attrs.space, out_space); + + /* Index into MAIR registers for cache attributes */ + attrindx = extract32(attrs, 2, 3); + mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; + assert(attrindx <= 7); + result->cacheattrs.is_s2_format = false; + result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); + + /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ + if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { + result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */ + } + device = S1_attrs_are_device(result->cacheattrs.attrs); } if (!(result->f.prot & (1 << access_type))) { @@ -2131,30 +2156,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.attrs.space = out_space; result->f.attrs.secure = arm_space_is_secure(out_space); - if (regime_is_stage2(mmu_idx)) { - result->cacheattrs.is_s2_format = true; - result->cacheattrs.attrs = extract32(attrs, 2, 4); - /* - * Security state does not really affect HCR_EL2.FWB; - * we only need to filter FWB for aa32 or other FEAT. - */ - device = S2_attrs_are_device(arm_hcr_el2_eff(env), - result->cacheattrs.attrs); - } else { - /* Index into MAIR registers for cache attributes */ - 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; - result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); - - /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ - if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { - result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */ - } - device = S1_attrs_are_device(result->cacheattrs.attrs); - } - /* * Enable alignment checks on Device memory. *