From patchwork Thu Aug 31 10:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 718962 Delivered-To: patch@linaro.org Received: by 2002:adf:e5c2:0:b0:31d:da82:a3b4 with SMTP id a2csp394778wrn; Thu, 31 Aug 2023 03:46:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6nSGLlmwVYthSVFTrKER3avZtQENp3E0MzJmt9Q8MQFXzROfJlBDq9bHxSjLGCWkhlAkR X-Received: by 2002:a05:620a:2448:b0:76c:97fd:c113 with SMTP id h8-20020a05620a244800b0076c97fdc113mr2396913qkn.15.1693478798081; Thu, 31 Aug 2023 03:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693478798; cv=none; d=google.com; s=arc-20160816; b=M/9zDlaFhmvhCPclQQhfhLoQ+W+pihFztYeYTEcvfkmratqpAzhh/NqMH8q5Q1AQP/ kROPhftl1lDi/ql3muO/sMTWz7FJB5Op0IZlUL1PwB7xLTcEZcWEYvEgkP0uHNPoF+QL qolsiZ51imqnFtMkdwjN2HS0pBlfqsvSZmNXhYl3zvvbHwnM+UKPxjbtiIoEujCPj+dz /aFi+BhzZPi3EUhQ3+YNdBGcqBbTSXDwFP4moSVbgQ1GSzoEKQPNoRPTjdu2JjSVBC48 oO0QI2mdor0FjkaThvKmnnvS7OHGUU/lMlOUYVQCAs0oJzW02Cwl9K/Qw0LccqV+gGW8 sKoA== 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=Zu723NqO5csexGltvqwm/VR8QzDnvxeiqLGXpa9N4pc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=V6HlN4+4rTZXAt6zao3F7HK7Ri3AHmULMvmJljeROovfsjcn95YCQOZlzf3dsTfQ55 fEQVnY7upK/NNVh7HHxJg9StkBHvyuWpwtOT9vYpbNG3hOG3xUgZd2j3ka12Wt+7Gifw EJAqj3EqOce10+83880WlmoALT644jYm96TDrFPOg0ZVNl+96al5Qk05HLeNp7KLjIvn wUe14FBgryVvGXpQoQyuwK2YBRgP2FbwEl+CtOPnTBZQkYse50yZqhgwCCcXiHUv2apu iMOnmiMN96qVgKIXnjf7LCq8OE08r7T/nGwxtnTYnKqZSvcLazil0O4aNTqZpS0dejuf luDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iWLGQauJ; 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 tx6-20020a05620a3f0600b0076813e81c12si701310qkn.239.2023.08.31.03.46.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 03:46:38 -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=iWLGQauJ; 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 1qbfBP-000461-Fc; Thu, 31 Aug 2023 06:45:51 -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 1qbfB3-0003RD-Sy for qemu-devel@nongnu.org; Thu, 31 Aug 2023 06:45:29 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbfAy-00042b-HX for qemu-devel@nongnu.org; Thu, 31 Aug 2023 06:45:27 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31c6d17aec4so487597f8f.1 for ; Thu, 31 Aug 2023 03:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693478722; x=1694083522; darn=nongnu.org; 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=Zu723NqO5csexGltvqwm/VR8QzDnvxeiqLGXpa9N4pc=; b=iWLGQauJhDnrprfvNSTZgwF8EPejP+9OuENDLwCm9ja1VbwenkyZ5+0zKqvlvARmXN O5ErTHwULLla+IFQl2/ZAJUiBW8WKMrAogD5/wV+OikWmDL8fJK7nDHYmzGB4shFeTeo oXeWJgx7UvKf/9RjXIrlJGk+d9ZhC2RHJEkeVgNKs2qh5JEjftzfco2f77pfzPMUcSp8 MLBNil0t66qxoJUpG5h6znt4mVPhJaUrSNuKCfqx1Stv8czRQ4249nGn9piIUnH1S4ME MuMQz191QKOWPiek2woQ1RobsZcZbc2dpSDdCvY6WbNcdudgl9xUnP7VrPpryePhT1GY cYSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693478722; x=1694083522; 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=Zu723NqO5csexGltvqwm/VR8QzDnvxeiqLGXpa9N4pc=; b=blRYDSNbKk0vlZJMhB79vH/H6JR3CsfFZBj2CSYDfHU3sXc73PJEL1GSxWhkgZyR7Z 1WWOHHX1wsMLvnRQIt8fCirn25OOZdczjslP7712JrpbKHgsuT6OLJ9AfcLT3vjzFlAL srp2oinsNPLXev0RXBLpz4WnltzZ0Plw8FcAmHvRmh1exxw+hpgkfXFpuXHhUq3BZBPl BWPDcvR10XTVJfrTxpSwPNWTJH1PkDpUnp7XzDLiut16MEOguBccQvgj4jBS/A0Jdp90 WNYwsmF4C1nFVBKHoDTOGQai+7r733siwpTXiF38Gm+h00SHdO9KNzKZawB07ncn8Vft jaXw== X-Gm-Message-State: AOJu0Yy3WkrTfAzFWBLMhc0b9Gct0ELDuBSWw20pOJaN4yPylJQ6DvfK Mu2aXNgq+sELj/SYpmT6SBvVXK+RvtaMHeIA788= X-Received: by 2002:a5d:4c84:0:b0:30f:bb83:e6f4 with SMTP id z4-20020a5d4c84000000b0030fbb83e6f4mr4349409wrs.0.1693478722555; Thu, 31 Aug 2023 03:45:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id l5-20020adfe585000000b0031c71693449sm1785524wrm.1.2023.08.31.03.45.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 03:45:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/24] target/arm: Introduce make_ccsidr64 Date: Thu, 31 Aug 2023 11:45:00 +0100 Message-Id: <20230831104519.3520658-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831104519.3520658-1-peter.maydell@linaro.org> References: <20230831104519.3520658-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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 From: Richard Henderson Do not hard-code the constants for Neoverse V1. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20230811214031.171020-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/tcg/cpu64.c | 48 ++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 4cd73779c80..00f39d42a8c 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -24,9 +24,36 @@ #include "qemu/module.h" #include "qapi/visitor.h" #include "hw/qdev-properties.h" +#include "qemu/units.h" #include "internals.h" #include "cpregs.h" +static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize, + unsigned cachesize) +{ + unsigned lg_linesize = ctz32(linesize); + unsigned sets; + + /* + * The 64-bit CCSIDR_EL1 format is: + * [55:32] number of sets - 1 + * [23:3] associativity - 1 + * [2:0] log2(linesize) - 4 + * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc + */ + assert(assoc != 0); + assert(is_power_of_2(linesize)); + assert(lg_linesize >= 4 && lg_linesize <= 7 + 4); + + /* sets * associativity * linesize == cachesize. */ + sets = cachesize / (assoc * linesize); + assert(cachesize % (assoc * linesize) == 0); + + return ((uint64_t)(sets - 1) << 32) + | ((assoc - 1) << 3) + | (lg_linesize - 4); +} + static void aarch64_a35_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); @@ -651,26 +678,15 @@ static void aarch64_neoverse_v1_initfn(Object *obj) * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values, * but also says it implements CCIDX, which means they should be * 64-bit format. So we here use values which are based on the textual - * information in chapter 2 of the TRM (and on the fact that - * sets * associativity * linesize == cachesize). - * - * The 64-bit CCSIDR_EL1 format is: - * [55:32] number of sets - 1 - * [23:3] associativity - 1 - * [2:0] log2(linesize) - 4 - * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc - * - * L1: 4-way set associative 64-byte line size, total size 64K, - * so sets is 256. + * information in chapter 2 of the TRM: * + * L1: 4-way set associative 64-byte line size, total size 64K. * L2: 8-way set associative, 64 byte line size, either 512K or 1MB. - * We pick 1MB, so this has 2048 sets. - * * L3: No L3 (this matches the CLIDR_EL1 value). */ - cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */ - cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */ - cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */ + cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */ + cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */ + cpu->ccsidr[2] = make_ccsidr64(8, 64, 1 * MiB); /* L2 cache */ /* From 3.2.115 SCTLR_EL3 */ cpu->reset_sctlr = 0x30c50838;