From nobody Tue Feb 10 06:43:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1600313157; cv=none; d=zohomail.com; s=zohoarc; b=aGsK+vierGU9KfgRVdDYssstviwWaoasW0l23bRc58mBGmmeGAEQmXjxAbrRBNYTIwpE7vtwsZWzv8dd1Oc9PV7AHz+3f5HrSHgNxqgQeMvjXQf+9ZoW8EBtS/E1nskQWhxKe/EfSO0CdvmtKDZsYuScltS6HG8TLnGSR3qtpQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600313157; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a4yYG57F5HEJeTWNQuFDC14+iVA59HTEsNyguIHDQf0=; b=T4kAWoBfVVgWwmUZlEum2XFhdvweLY9cEEbFKAmvp3I4jUwoLYFb8JT5MypIJp9mqR9qbo9n55kyokWhVwGZdaCUGg6qyLLqBwX+6vn+7x4ghAL52X9XgkAVCXABQwfyJbQFrlWp1SqV34V3xPQajQGWaJl/FBzpWnTEPaLzO/M= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600313157323131.48981658305843; Wed, 16 Sep 2020 20:25:57 -0700 (PDT) Received: from localhost ([::1]:56236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIkYW-0002FS-7x for importer@patchew.org; Wed, 16 Sep 2020 23:25:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIkUP-0004zU-9w; Wed, 16 Sep 2020 23:21:41 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4748 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIkUM-0004RS-J7; Wed, 16 Sep 2020 23:21:40 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id F287774951387E5CE419; Thu, 17 Sep 2020 11:21:13 +0800 (CST) Received: from localhost (10.174.185.104) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 17 Sep 2020 11:21:04 +0800 From: Ying Fang To: Subject: [RFC PATCH 09/12] target/arm/cpu: Add CPU cache description for arm Date: Thu, 17 Sep 2020 11:20:30 +0800 Message-ID: <20200917032033.2020-10-fangying1@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200917032033.2020-1-fangying1@huawei.com> References: <20200917032033.2020-1-fangying1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.185.104] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=fangying1@huawei.com; helo=huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 23:21:09 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, zhang.zhanghailiang@huawei.com, alex.chen@huawei.com, shannon.zhaosl@gmail.com, qemu-arm@nongnu.org, alistair.francis@wdc.com, Ying Fang , imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add the CPUCacheInfo structure to hold CPU cache information for ARM cpus. A classic three level cache topology is used here. The default cache capacity is given and userspace can overwrite these values. Signed-off-by: Ying Fang --- target/arm/cpu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 27 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index c179e0752d..efa8e1974a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -27,6 +27,7 @@ #include "qapi/visitor.h" #include "cpu.h" #include "internals.h" +#include "qemu/units.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY) @@ -998,6 +999,45 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clusters= z) return (Aff1 << ARM_AFF1_SHIFT) | Aff0; } =20 +static CPUCaches default_cache_info =3D { + .l1d_cache =3D &(CPUCacheInfo) { + .type =3D DATA_CACHE, + .level =3D 1, + .size =3D 64 * KiB, + .line_size =3D 64, + .associativity =3D 4, + .sets =3D 256, + .attributes =3D 0x02, + }, + .l1i_cache =3D &(CPUCacheInfo) { + .type =3D INSTRUCTION_CACHE, + .level =3D 1, + .size =3D 64 * KiB, + .line_size =3D 64, + .associativity =3D 4, + .sets =3D 256, + .attributes =3D 0x04, + }, + .l2_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .level =3D 2, + .size =3D 512 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 1024, + .attributes =3D 0x0a, + }, + .l3_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .level =3D 3, + .size =3D 65536 * KiB, + .line_size =3D 64, + .associativity =3D 15, + .sets =3D 2048, + .attributes =3D 0x0a, + }, +}; + static void cpreg_hashtable_data_destroy(gpointer data) { /* @@ -1835,6 +1875,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) } } =20 + cpu->caches =3D default_cache_info; + qemu_init_vcpu(cs); cpu_reset(cs); =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a1c7d8ebae..e9e3817e20 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -745,6 +745,30 @@ typedef enum ARMPSCIState { =20 typedef struct ARMISARegisters ARMISARegisters; =20 +/* Cache information type */ +enum CacheType { + DATA_CACHE, + INSTRUCTION_CACHE, + UNIFIED_CACHE +}; + +typedef struct CPUCacheInfo { + enum CacheType type; /* Cache Type*/ + uint8_t level; + uint32_t size; /* Size in bytes */ + uint16_t line_size; /* Line size in bytes */ + uint8_t associativity; /* Cache associativity */ + uint32_t sets; /* Number of sets */ + uint8_t attributes; /* Cache attributest */ +} CPUCacheInfo; + +typedef struct CPUCaches { + CPUCacheInfo *l1d_cache; + CPUCacheInfo *l1i_cache; + CPUCacheInfo *l2_cache; + CPUCacheInfo *l3_cache; +} CPUCaches; + /** * ARMCPU: * @env: #CPUARMState @@ -986,6 +1010,9 @@ struct ARMCPU { =20 /* Generic timer counter frequency, in Hz */ uint64_t gt_cntfrq_hz; + + /* CPU cache information */ + CPUCaches caches; }; =20 unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); --=20 2.23.0