From patchwork Thu Aug 24 09:28:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 716532 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1237406wrp; Thu, 24 Aug 2023 02:33:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhkgun6DGm/VRsRLad5HDANaTdvNqksPzY89reUw3+a/C+he4DkjnVO/6SOBX3b8YKNr2a X-Received: by 2002:a0c:f1ca:0:b0:635:f412:6a70 with SMTP id u10-20020a0cf1ca000000b00635f4126a70mr13593491qvl.47.1692869631547; Thu, 24 Aug 2023 02:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692869631; cv=none; d=google.com; s=arc-20160816; b=XP3ha7W4ttnLUARdhI++JONfNzJ4p24pioTV+KvEvAe7MNTU53m389sQwWk1yemUTX 9VwOMJS64N3SmTc9Ge8Q0+vs+jAWSCdiH1VY7UnEamp80mmxdzeP1vw+tpPD4yfARlLv T/XxIwoNddu31IuzCisifGvGRX9D05h4pH7EMmh3xvJbSuBQxD/rCEqsMAx+Qcba9OtR aE8AlI8Hak+XP1brwKapTAeGt+e81o7TqqTURAyzDUgQSNnwSlCnIRp30pDKuxhxk/Yr irPVFuqag76ZMi43lRY37zFh5wtSZPO+9JXv+npdRIQlYTlzgV6L/nbVY8uULpK5kCCx RDQA== 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=x2CxREWJG7MgeLcSqs2FqHmGhWzoHCJcynkCy/gC8pQ=; fh=bFDrUYhlTVi/QyetgXx/byg2+yO/22Hp9SjwoefyKLk=; b=dhB9f1bBgxDRpz0D9B5HZvfXBIGhXsMYOio7/VgYsBuPANK+PCzdq3IJ/kbGMVC01c hv6fvlPfdH2bdVyMYYqWjk3cZ4g5OCfvnopqQxWCBV9JHjxAzyNmBa+uCuYfzsedD9T+ L69YExcEzeZqezFQOCabFbw34neV0x8jVro8wSDj5OCjDyJyt78rOttczUEiyIylxgfA n10hrdG4KOE+yy6yxE8rFIdRjqS4mJfVkx1ipYoY7e65+xH9OGBb+EDiFTN/dIjBrwtM fRIYPgNuWVN5HdS14fHwf6/nwkXKqINjeifDxzUJT5+SmoSvX85CXQVX7tDd1rMjNdv8 FaBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UBcs5oKC; 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 bk14-20020a05620a1a0e00b0076e9b9f669bsi943140qkb.253.2023.08.24.02.33.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Aug 2023 02:33:51 -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=UBcs5oKC; 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 1qZ6eu-0008E7-3h; Thu, 24 Aug 2023 05:29: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 1qZ6eB-0004A2-E7 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 05:28:59 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZ6e7-00051X-76 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 05:28:59 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31aeef88a55so4076427f8f.2 for ; Thu, 24 Aug 2023 02:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692869331; x=1693474131; 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=x2CxREWJG7MgeLcSqs2FqHmGhWzoHCJcynkCy/gC8pQ=; b=UBcs5oKCSv41A+i2hRKfjKx9jo16hZM2pQhv+JbYMKC8PUUCajaZORVQqh6l2YTsyI tdfDJlhvFh8quvSRo9O7toSCkrP3OuOwOR1tetVO0HvCtK1zuAB0ha+piMHk0LZV+bOW HppJAtfhfAFlNaoN3ctPxim3WSsupGxHTYbKCIiFpDbkrgwgzW0M2uZo37MQFAvHMuge DlW9XJISnXydKoqqgsxwqjoLttHzheI1iMFXp0o93EmqgaCVB65rdQm2eBGmrJYNtASW GJm1JzZ4foLKLAG0VkIzNZFi4ThWDlUvpjjTjaQA2L2eR1jxmvXLSn0sWeNNspfVzIyR QTdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692869331; x=1693474131; 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=x2CxREWJG7MgeLcSqs2FqHmGhWzoHCJcynkCy/gC8pQ=; b=IHee1tTYiQpf/CQrfzd6SjJqDflDEXY+fsCw4AkpwWU9MiFE/6lB6bBjJO8Va2S5jq E4xzrPbwCjutVu6drmeTMXoqzFzdzGIn7wu0YPDJzNef5onK11wjqncUKCqMqA2Bv/Tc nWZbPLKmdpPveYy8qjuJAverDw7KMFv2eSbH95VM8CXPZLsALBh/wAgHXPr6Y7iAKykY YeX5NfFeM67bYo6uDuvX6auXMGKfDhsewoCDDDQgi6dsSzJIeL5OxkcWZKzN1lP6Ziak VRaOTy6dRwV874Xymc1LyAHDUTu4WsQRcjEYyRUmVLTqLSAdvCc7SbKQl30I2/1Z+YHU L52Q== X-Gm-Message-State: AOJu0Yz9iLopPl3jRmRPl9myD73eSZJZ1U0jWW+/pQLQPng1gQnyd4Fn lX3HmRfFbJqvgwGEX96IOKNNQYFIEAKbt4szO5U= X-Received: by 2002:a5d:62cd:0:b0:319:785a:fce0 with SMTP id o13-20020a5d62cd000000b00319785afce0mr11543150wrv.26.1692869330879; Thu, 24 Aug 2023 02:28:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id s12-20020adfeccc000000b00317b5c8a4f1sm21844004wro.60.2023.08.24.02.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 02:28:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/35] target/arm: Adjust PAR_EL1.SH for Device and Normal-NC memory types Date: Thu, 24 Aug 2023 10:28:28 +0100 Message-Id: <20230824092836.2239644-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824092836.2239644-1-peter.maydell@linaro.org> References: <20230824092836.2239644-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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 The PAR_EL1.SH field documents that for the cases of: * Device memory * Normal memory with both Inner and Outer Non-Cacheable the field should be 0b10 rather than whatever was in the translation table descriptor field. (In the pseudocode this is handled by PAREncodeShareability().) Perform this adjustment when assembling a PAR value. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230807141514.19075-16-peter.maydell@linaro.org --- target/arm/helper.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 8290ca0aaad..da5db6d3ff6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3342,6 +3342,19 @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, } #ifdef CONFIG_TCG +static int par_el1_shareability(GetPhysAddrResult *res) +{ + /* + * The PAR_EL1.SH field must be 0b10 for Device or Normal-NC + * memory -- see pseudocode PAREncodeShareability(). + */ + if (((res->cacheattrs.attrs & 0xf0) == 0) || + res->cacheattrs.attrs == 0x44 || res->cacheattrs.attrs == 0x40) { + return 2; + } + return res->cacheattrs.shareability; +} + static uint64_t do_ats_write(CPUARMState *env, uint64_t value, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool is_secure) @@ -3470,7 +3483,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, par64 |= (1 << 9); /* NS */ } par64 |= (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */ - par64 |= res.cacheattrs.shareability << 7; /* SH */ + par64 |= par_el1_shareability(&res) << 7; /* SH */ } else { uint32_t fsr = arm_fi_to_lfsc(&fi);