From patchwork Fri Jul 14 15:46:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 702740 Delivered-To: patch@linaro.org Received: by 2002:adf:db4e:0:b0:314:25da:8dc4 with SMTP id f14csp1162296wrj; Fri, 14 Jul 2023 08:50:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEGHEaGlzo/t13KelWqrRacp+onSqEXWu0Hyidc8il1oJyI9dXsU5S7u5h+W9qr180JfSlC X-Received: by 2002:aca:de02:0:b0:3a1:ddc1:e25 with SMTP id v2-20020acade02000000b003a1ddc10e25mr4582284oig.58.1689349815723; Fri, 14 Jul 2023 08:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689349815; cv=none; d=google.com; s=arc-20160816; b=v2mu24e8xMAk353TX1Q5FsmQe74rk5h84cPHOw6JJZlfMX+BIUeYqg2pEVHX9XC0Ri fEynni7sfSGBMl6WjH5lQ03+3f/hqCt04UxRRq019SOOjWgu0PM3BI82DHvyo3qWL3BM lHqSTpuiJ722MvO7QAUhwAbvUlAb77cNTtplgNI/zK50+G4nz62svCTQtR4Vc8xC5GZR o2/aXaCBgSlvqpPM7btBTE6LFvZxAkMQg4P3zZgR4o5upm5o6h4KdSjb6DeviGupf2RI PYKMxreazibKzKfwaXarexNk4VI/Z4t7e2ds7NDkCpbT7t3g+1xxf8xGl+XH3YY5JpsH smDw== 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=BuUwbulU5zL9tN4hCYlIE1gc3ZvqjDoeI3CgFmuY05s=; fh=jvpdohKmRoZMO537s6xMKXXtj7EZws1LOMQI/oP4vXs=; b=CE4VdUaUs1Dt3GFqggLVO/fb6KAItcCMHHufdpiXckdQodikZ4pesY86jHn7F403BH TwI1RPyKP5HP41I5jqoVw/7NmHrB63GBWkF/mUkxeljTFeltuo//ztFqYHnURnR7IQSV pe5D+4TyVMJNUGe/cdfyKlXo4htthWdZv5iIOPkFTgbAJfbZIdkcZJtz8NP/etHg2vMJ tGOpce1P58qWQ0L59RfTIAntZ9/2ycgEFmkN1aVHTTeEXABG4TBswrypc6ahIMIye2tZ N/ua/1uJpaIMT9TL6OCL0AnLTNkdY/hY1W4rxHajtSSIoPxMjUN2Fapy3JTVgh5RSwmk a9Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K1xbhVUA; 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 n7-20020a05620a294700b00767e994ff18si3821664qkp.143.2023.07.14.08.50.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jul 2023 08:50:15 -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=K1xbhVUA; 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 1qKL0r-0007Os-G3; Fri, 14 Jul 2023 11:47:21 -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 1qKL0d-0007MG-Tm for qemu-devel@nongnu.org; Fri, 14 Jul 2023 11:47:08 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450: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 1qKL0V-000783-CC for qemu-devel@nongnu.org; Fri, 14 Jul 2023 11:47:07 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-315adee6ac8so2179507f8f.2 for ; Fri, 14 Jul 2023 08:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689349618; x=1691941618; 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=BuUwbulU5zL9tN4hCYlIE1gc3ZvqjDoeI3CgFmuY05s=; b=K1xbhVUAuJ3hjYDrUvp8TvNkYxIkOhCMjVcqGXw5fqbgbEO62fH0/9sH5BByXWlaa6 UZLJHpSHva0rC5fsnO2Wm1U8wk1JxHaNQ+ExSENQDbMw9nNniPsv33WEXUitKGkCnuoH qKs7YDS0HKCwemwhmQXYhqHx7x+XACsEkrf5WAm6qFbiGM3N5lUj0a0/KPjx9C2iDqqf 0agY5PZOd5vyOMfX7Hu2cXGjxYVDF1AUMpqdW5vImUCeKdhjjGWa7ElMAP4EtJpv0YNk Zv7lTJBNSH2MRIjqgLb/cDjYdrbhzyR3tuAPpMgZz6zPSoMIK8cLJxRF/u4d9Hbyc5Dp Ghuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689349618; x=1691941618; 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=BuUwbulU5zL9tN4hCYlIE1gc3ZvqjDoeI3CgFmuY05s=; b=StYF+bt2s5GLKXf1q/jHE3H47jlefqtJ1Fr2h11kqcBBXsg0psdBXNKJYnkQQ7wc2A ze8XhETkHoQT0/96cMFyt+0WCevV3Nnu50aaj/JkbnIdVn+aHFJ5VlbU9RpBfN9QVuhC 0vFD3RD6j2in3RaAGlfpwy8HuXAJwRUG10ILVG4xgyi2bO0tHjjQ4NLMd4ItuOHjILFJ rAqZOYW/UYj6LimEUngoaKKRdD0wF0WUGbh0gMdhHeZi+2ioYsL8R20HCPo8tVM+E2yN AgpIAUGXny6BGfI/idhs3zAX1WhzXrLbzv1tI/oENSdYWBSjf5nrVAvsjhUgFH6gcgrS SIXw== X-Gm-Message-State: ABy/qLZ9JPNG9jmZkBBV1IIIY4w7aJ/gt+PLXGqJz8z98eF8mioX+pBW RsMSSFhZI7XOwg1bK1dgmOr1GmOepJiu0hwV+/c= X-Received: by 2002:a5d:68c6:0:b0:315:9d61:6e66 with SMTP id p6-20020a5d68c6000000b003159d616e66mr4770217wrw.9.1689349617995; Fri, 14 Jul 2023 08:46:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t16-20020a5d49d0000000b003143bb5ecd5sm11214025wrs.69.2023.07.14.08.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 08:46:57 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 14/14] target/arm: Adjust PAR_EL1.SH for Device and Normal-NC memory types Date: Fri, 14 Jul 2023 16:46:48 +0100 Message-Id: <20230714154648.327466-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714154648.327466-1-peter.maydell@linaro.org> References: <20230714154648.327466-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 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: , 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 --- 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 1e45fdb47c9..f9c00827018 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);