From nobody Tue Nov 26 15:34:21 2024 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=pass (i=1 dmarc=pass fromdomain=starfivetech.com) ARC-Seal: i=2; a=rsa-sha256; t=1706524940; cv=pass; d=zohomail.com; s=zohoarc; b=hd8IHY15Nn5zWclTSK+LueM/w73NQnAHNkyjFjVUZGw0BlLjgs8/8gPooaaDhemco21CFoUUYtUzw3JxX4T+VSiKcZ19/JDsyaYMm8ql2oYDe4u3nfccXtL1JQVeMbd2E3qOo4W3AO2pt5GC84u5s07+otMc9y7tW60T7jW4adE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706524940; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LogpkUc815GghXysrVzaK5/BneHojt10kmiqRXhKgEM=; b=diQuidkx8SxPrB5GItKAp7eP5N+owd37A5NXIKH6ZUBqB1m/kFUvBkxbL4hYBKN6OEldnVHi12ZKISFjhFzd5h3dkMoW61tBpA8BVMN57eMu5XeR4CYkKTaaWvykEBlVRa+z4nuN3bTocXcRrUeZ5ESgRRZaY2l9ZH1maFSs2nc= ARC-Authentication-Results: i=2; 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=pass (i=1 dmarc=pass fromdomain=starfivetech.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706524940387826.9324679240191; Mon, 29 Jan 2024 02:42:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUP55-0003x3-M0; Mon, 29 Jan 2024 05:41:35 -0500 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 1rUP4k-0003ud-Tz; Mon, 29 Jan 2024 05:41:16 -0500 Received: from mail-bjschn02on20616.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::616] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUP4h-0005iY-IR; Mon, 29 Jan 2024 05:41:13 -0500 Received: from BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::16) by BJSPR01MB0594.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 10:41:01 +0000 Received: from BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn ([fe80::3862:65b4:c857:c4a6]) by BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn ([fe80::3862:65b4:c857:c4a6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 10:41:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aQu7nleGqbR1nD+hC+xGopo4nljNRHglAIEOPUaWRIV8H3wbdgLMcIYKnqiYC3y+7R7CX+pejFFOxLZrXL+/EErQT0DmRhDO4StL8ctfRT5tmoLe3//s/NjnO5iU3JeuKwXxRFgxW/bkxTTcoVhkD763M6e9E2MlUxr2lZh6eJdCpH6VtSUn+mNU9N9hREmRtggj7T2MC+rlrJB4y0P8rKO0sALgcAG3gwo4LEgY7XBRgw3v9amaR/a6318IUYFUzdiawGYDiTplpCWYKbOQG0hd/IKxbCQSL67hSZsxPX1G63VlSCHXvePVlJMm0P2YudTm541JIilHCDCfjNpAqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LogpkUc815GghXysrVzaK5/BneHojt10kmiqRXhKgEM=; b=Irjnel5AOseBKhbfnlphF7oW6NrmJJJRyoP2DPjtG9ipPZDqZEhw/e3To2gJJcYIBp4fLABlk0DZjgQn3LZ5yFDdS53tycDVn9ZpDTSWIWvJJpb5sQvaAXzLf8PtIExyyeL75V02jHecctl4EGtfbcgCmb8wj8rXe4/VLYf5mcJlmIeQtxj9uTiG8oHBbibGIdg2zOTPewlNiPgAASV6U9Taa/wnaoE7lPmXd2Ye+BXFBZtYXzaKPHGWHIOSCC5JPWpncURV2lk5jgoaekZSZIfNQzi37zuZlfvB8GSPhizOWwfwwvJuuQWUByEcich+yzdrd1EYt7M7CJR1AKxfxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; From: Sia Jee Heng To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org Cc: mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, shannon.zhaosl@gmail.com, jeeheng.sia@starfivetech.com, peter.maydell@linaro.org, sunilvl@ventanamicro.com, palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com Subject: [RESEND RFC 1/3] hw/acpi/aml-build: Add cache structure table creation for PPTT table Date: Mon, 29 Jan 2024 02:40:37 -0800 Message-Id: <20240129104039.117671-2-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129104039.117671-1-jeeheng.sia@starfivetech.com> References: <20240129104039.117671-1-jeeheng.sia@starfivetech.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BJSPR01CA0004.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:c::16) To BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BJSPR01MB0561:EE_|BJSPR01MB0594:EE_ X-MS-Office365-Filtering-Correlation-Id: 24989447-b928-4309-259c-08dc20b6c8e9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EiTWurddeozz1WKLYaYWjvUo7t8bvLDERP5fD2ncKAEaz2lslwZgVbNFAjl1qFMKJ7T/XC37GrvIvmz++ikp1j+var6VQOLH6RlC/WCW6ury4aAdx4DGI+q8mTPpAlYKltZ6sbOsVmejyRtVvmaHE+51TGvCrY2annuUkJ9ALEc59aGbwmOsX5tCdPaY9Puh36JgnP9yhmBEKY/azVtR2I5AyCGBFR5jBHhymRWunZwjosmGXY7XdAo2aEstlL4pFhPmFPj6/gsx6HtjeP+9tcc4CftVMxDCOwhnrAR0rGSIdiosTUeS6OxAZBONhs2xlTwPwAyd5M6LiGvFWRjo8LFz+JIlZzKYB6sD5rVKP2e+9ShPbRnDXlG6e6FSjmlyiam/+0xXjzI+CLttjB/PfqhxhOb/Gj1Y1ReF6oQYwegtaQX3WsdHpngWLO/uB7HKRmKNWzaTJZyIgWlXnSNkNqjgoPHvL+g5OSMjLv4GM9v8Q9mjPjH5/iObmz935hsfOLLfvscC9skgUBlh0o+/AOJ/rk+lp1Gxijq2ntS0xozgrQwzw7uQXH4Mi384HuRM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(136003)(346002)(396003)(39830400003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(38350700005)(41320700001)(2616005)(2906002)(52116002)(5660300002)(6666004)(7416002)(66946007)(66556008)(4326008)(26005)(1076003)(66476007)(8676002)(8936002)(38100700002)(83380400001)(508600001)(41300700001)(40180700001)(86362001)(40160700002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ajig6hKmXjKb4OKusRDgMGo4nK8eFbhVkrG2YoDLfKc2f9pcC2YIDGVISJtk?= =?us-ascii?Q?VjnOPxk05hV9Dk2L5sQ5dcu2kgd9kMF8sHsgs5IwHeXa1kBD1c+2XLoYc3yx?= =?us-ascii?Q?9vvd/58u0w/RaPUj8N2j7PlTp8zdrutkyYJME6ucr9XHLN+AMfDmG0wWKcse?= =?us-ascii?Q?TT9V6dvtieOrt3Ywa7I+ElnZwG5IwS9iln4RP+RkeX2I9KhP5d4Tr7YTmE0d?= =?us-ascii?Q?fq+oumBBkmETKdbBYH8q2qCmxd4HC9TTqodk+zfVnzJ8SR5bxszy7UBahn4u?= =?us-ascii?Q?TBNNIhQDyXNx59tVwq26J91xb3XFx6oIIo1NqQFCfJraJCUkpKYRyY6uLdvG?= =?us-ascii?Q?zCvCStBYkLDZduZAlLP+EN/zpb+wSFffUYo21hZiTRxHEUNbCICkz+esaP1D?= =?us-ascii?Q?9ij53AZuA2wBwe+7XYF2loxLeW2zmiE+I4pwB6KNbyeDM7ENvlsgHIMA52i9?= =?us-ascii?Q?iJtOYinff0AWnOUkAd5vNhtCiwyPZ+at2ElwG9iaBGnBUu38Jfnhhkq74/Pd?= =?us-ascii?Q?nOjnFWasYe6M58HReoTwj4SVXRyHd+54VsUkz8xaoekWW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ajUe3FaCBYuUBxb5QVmuGnsbmWdvYR2J?= =?us-ascii?Q?GtbO9Juginepmwm6F83a6i+lyaOie5bCNLMJ+vXYb1tjodfI2XjwWGdccgUa?= =?us-ascii?Q?rOWRH4RSUGmQPDhWZnWE31s0jDrsME01gvqdDiVja9q67tkWctoY9/DDxx46?= =?us-ascii?Q?Yg=3D=3D?= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24989447-b928-4309-259c-08dc20b6c8e9 X-MS-Exchange-CrossTenant-AuthSource: BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 10:41:00.9539 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b1RU65YzG8jUF0zhp9kK6qlWoqsrHHF7CW1ubYA6wBgOEtj7c1O2cmAlHzuhkDfu6ROpEqPZF3uT6Pakjj5L33k2pU+rlsizfI6c7Wxm7BA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJSPR01MB0594 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=2406:e500:4440:2::616; envelope-from=jeeheng.sia@starfivetech.com; helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1706524942785100005 Content-Type: text/plain; charset="utf-8" Adds cache structure table generation for the Processor Properties Topology Table (PPTT) to describe cache hierarchy information for ACPI guests. A 3-level cache topology is employed here, referring to the type 1 cache structure according to ACPI spec v6.3. The L1 cache and L2 cache are private resources for the core, while the L3 cache is the private resource for the cluster. In the absence of cluster values in the QEMU command, a 2-layer cache is expected. The default cache value should be passed in from the architecture code. Examples: 3-layer: -smp 4,sockets=3D1,clusters=3D2,cores=3D2,threads=3D1 2-layer: -smp 4,sockets=3D1,cores=3D2,threads=3D2 Signed-off-by: Sia Jee Heng --- hw/acpi/aml-build.c | 65 ++++++++++++++++++++++++++++++++++--- include/hw/acpi/aml-build.h | 26 ++++++++++++++- 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index af66bde0f5..3bbfce962b 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1994,18 +1994,48 @@ static void build_processor_hierarchy_node(GArray *= tbl, uint32_t flags, } } =20 +/* ACPI spec, Revision 6.3 Cache type structure (Type 1) */ +static void build_cache_structure(GArray *tbl, + uint32_t next_level, + CPUCacheInfo *cache_info) +{ + /* Cache type structure */ + build_append_byte(tbl, 1); + /* Length */ + build_append_byte(tbl, 24); + /* Reserved */ + build_append_int_noprefix(tbl, 0, 2); + /* Flags */ + build_append_int_noprefix(tbl, 0x7f, 4); + /* Next level cache */ + build_append_int_noprefix(tbl, next_level, 4); + /* Size */ + build_append_int_noprefix(tbl, cache_info->size, 4); + /* Number of sets */ + build_append_int_noprefix(tbl, cache_info->sets, 4); + /* Associativity */ + build_append_byte(tbl, cache_info->associativity); + /* Attributes */ + build_append_byte(tbl, cache_info->attributes); + /* Line size */ + build_append_int_noprefix(tbl, cache_info->line_size, 2); +} + /* * ACPI spec, Revision 6.3 * 5.2.29 Processor Properties Topology Table (PPTT) */ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, - const char *oem_id, const char *oem_table_id) + const char *oem_id, const char *oem_table_id, + const CPUCaches *CPUCaches) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); CPUArchIdList *cpus =3D ms->possible_cpus; int64_t socket_id =3D -1, cluster_id =3D -1, core_id =3D -1; uint32_t socket_offset =3D 0, cluster_offset =3D 0, core_offset =3D 0; uint32_t pptt_start =3D table_data->len; + uint32_t l3_offset =3D 0, priv_num =3D 0; + uint32_t priv_rsrc[3] =3D {0}; int n; AcpiTable table =3D { .sig =3D "PPTT", .rev =3D 2, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; @@ -2024,10 +2054,11 @@ void build_pptt(GArray *table_data, BIOSLinker *lin= ker, MachineState *ms, socket_id =3D cpus->cpus[n].props.socket_id; cluster_id =3D -1; core_id =3D -1; + priv_num =3D 0; socket_offset =3D table_data->len - pptt_start; build_processor_hierarchy_node(table_data, (1 << 0), /* Physical package */ - 0, socket_id, NULL, 0); + 0, socket_id, NULL, priv_num); } =20 if (mc->smp_props.clusters_supported && mc->smp_props.has_clusters= ) { @@ -2035,20 +2066,44 @@ void build_pptt(GArray *table_data, BIOSLinker *lin= ker, MachineState *ms, assert(cpus->cpus[n].props.cluster_id > cluster_id); cluster_id =3D cpus->cpus[n].props.cluster_id; core_id =3D -1; + priv_num =3D 0; + l3_offset =3D table_data->len - pptt_start; + /* L3 cache type structure */ + if (CPUCaches && CPUCaches->l3_cache) { + priv_num =3D 1; + build_cache_structure(table_data, 0, CPUCaches->l3_cac= he); + } cluster_offset =3D table_data->len - pptt_start; build_processor_hierarchy_node(table_data, (0 << 0), /* Not a physical package */ - socket_offset, cluster_id, NULL, 0); + socket_offset, cluster_id, &l3_offset, priv_num); } } else { cluster_offset =3D socket_offset; } =20 + if (CPUCaches) { + /* L2 cache type structure */ + priv_rsrc[0] =3D table_data->len - pptt_start; + build_cache_structure(table_data, 0, CPUCaches->l2_cache); + + /* L1d cache type structure */ + priv_rsrc[1] =3D table_data->len - pptt_start; + build_cache_structure(table_data, priv_rsrc[0], + CPUCaches->l1d_cache); + + /* L1i cache type structure */ + priv_rsrc[2] =3D table_data->len - pptt_start; + build_cache_structure(table_data, priv_rsrc[0], + CPUCaches->l1i_cache); + + priv_num =3D 3; + } if (ms->smp.threads =3D=3D 1) { build_processor_hierarchy_node(table_data, (1 << 1) | /* ACPI Processor ID valid */ (1 << 3), /* Node is a Leaf */ - cluster_offset, n, NULL, 0); + cluster_offset, n, priv_rsrc, priv_num); } else { if (cpus->cpus[n].props.core_id !=3D core_id) { assert(cpus->cpus[n].props.core_id > core_id); @@ -2063,7 +2118,7 @@ void build_pptt(GArray *table_data, BIOSLinker *linke= r, MachineState *ms, (1 << 1) | /* ACPI Processor ID valid */ (1 << 2) | /* Processor is a Thread */ (1 << 3), /* Node is a Leaf */ - core_offset, n, NULL, 0); + core_offset, n, priv_rsrc, priv_num); } } =20 diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index ff2a310270..2dd949f41e 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -234,6 +234,29 @@ struct CrsRangeSet { GPtrArray *mem_64bit_ranges; } CrsRangeSet; =20 +enum CacheType { + DATA_CACHE, + INSTRUCTION_CACHE, + UNIFIED_CACHE +}; + +typedef +struct CPUCacheInfo { + enum CacheType type; /* Cache Type*/ + uint32_t size; /* Size of the cache in bytes */ + uint32_t sets; /* Number of sets in the cache */ + uint8_t associativity; /* Cache associativity */ + uint8_t attributes; /* Cache attributes */ + uint16_t line_size; /* Line size in bytes */ +} CPUCacheInfo; + +typedef +struct CPUCaches { + CPUCacheInfo *l1d_cache; + CPUCacheInfo *l1i_cache; + CPUCacheInfo *l2_cache; + CPUCacheInfo *l3_cache; +} CPUCaches; =20 /* * ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors @@ -490,7 +513,8 @@ void build_slit(GArray *table_data, BIOSLinker *linker,= MachineState *ms, const char *oem_id, const char *oem_table_id); =20 void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, - const char *oem_id, const char *oem_table_id); + const char *oem_id, const char *oem_table_id, + const CPUCaches *CPUCaches); =20 void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, const char *oem_id, const char *oem_table_id); --=20 2.34.1 From nobody Tue Nov 26 15:34:21 2024 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=pass (i=1 dmarc=pass fromdomain=starfivetech.com) ARC-Seal: i=2; a=rsa-sha256; t=1706524981; cv=pass; d=zohomail.com; s=zohoarc; b=bV2XbVSBL6Hfg0W34yy02os38djlAm3gcxx3NF1GDD0pSoG6QlDzy5QGwNgajFqeRyoqN+VWDeuN6pV9hMacQl7Rj5t/X2SpP6x0J8200F8ZuanAHtEFEkbpvvau2QWm2Jd7UoZyhqKzirx0oUXzr4XPjW7phuFHfGkZOBgZsFg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706524981; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w7VCP15G1BvqWTdQRPP3FfBZvOzet9rpsAoH/InIbt8=; b=NtiwDH+w93tjmx/cDM545BRhRacnjYyydjAEaS3fxaNm9IljNCBLuijBMOApQ0YU65XAchCSHF27VQzxsI9FGYk5IWz6Hxby3QBkLEHQ+rZUNthBOZoTf5OLdDoytivHXmIUAXyPCMSqVwEbSSR9v8OGWYzZkM73BnEJJvmhH7c= ARC-Authentication-Results: i=2; 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=pass (i=1 dmarc=pass fromdomain=starfivetech.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706524981203713.2406538958005; Mon, 29 Jan 2024 02:43:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUP56-0003y4-Cd; Mon, 29 Jan 2024 05:41:36 -0500 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 1rUP4q-0003v3-Mr; Mon, 29 Jan 2024 05:41:22 -0500 Received: from mail-bjschn02on20616.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::616] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUP4m-0005iY-3b; Mon, 29 Jan 2024 05:41:18 -0500 Received: from BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::16) by BJSPR01MB0594.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 10:41:06 +0000 Received: from BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn ([fe80::3862:65b4:c857:c4a6]) by BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn ([fe80::3862:65b4:c857:c4a6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 10:41:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HXXV8g1XseaqQB/75iEEVaLF/U1w/9c0SGI+kr5T9N5mT+eL9KUrhxHKhksTK/oY11CQmgyk09edjXAXv/DQxDOgaiNsJxVPwyB/ksP/NcZ50etRGe2SDo2ybheN0FPH3rJXspnPNkSwkN4lW1/8HGvcb+Di4gLEtZkqigj88kXBX9n0NIZAAj/XUcmpKdUIL14h/C2pZ5IlfF2aid9i0wGnnA30Mscw8Labgk3UBkPrS7vzOlfQXkegUHAydH8ff+5lD8E7Go4kM4jdBs9QMagQsCqy+FUpHyn+iZsv22UZD9NkRRlMAcffa00JQq/5YP38LenYpl7v0QXLYkwdMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w7VCP15G1BvqWTdQRPP3FfBZvOzet9rpsAoH/InIbt8=; b=RRNAFGsHZ1Zv/VV3IQm7TucH+GiK1PRW6WxdPd4iaCPvGzobo7B4tofWxLy0dFZlzhKbxhjHCResZR2sQ9rlHhn5CNtJk8dkyM1/Uk3thkKgwmmptK2IdNPK/qU25fxxWvfjGxhjhZeIWKyCwBl0NcwHKRYGg8XiTUjA4aIP5y4hoPD5Hf0UUp2DhZgMqfT+chEZQctA/YOC88wvci7nW8II5Tk75tQ+RWSQkDxYW/SrV4lHQJqESxzUOAySRg+5jgfpseOTsQFlpfE3wVZSJgSFqJELt3q1yNscAftFQUhQRt9BdKnEzMD1lT5kaZNTMk06kSIiYRcqW4hbz/3vmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; From: Sia Jee Heng To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org Cc: mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, shannon.zhaosl@gmail.com, jeeheng.sia@starfivetech.com, peter.maydell@linaro.org, sunilvl@ventanamicro.com, palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com Subject: [RESEND RFC 2/3] hw/riscv/virt-acpi-build.c: Generate PPTT table Date: Mon, 29 Jan 2024 02:40:38 -0800 Message-Id: <20240129104039.117671-3-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129104039.117671-1-jeeheng.sia@starfivetech.com> References: <20240129104039.117671-1-jeeheng.sia@starfivetech.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BJSPR01CA0004.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:c::16) To BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BJSPR01MB0561:EE_|BJSPR01MB0594:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ef9589a-0228-4d00-9edd-08dc20b6cc3e X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lQGDoRwvyRYOpb9lR9RsX9n0/lVBNRKIlyQtREe5n9gkb6xR9aG+cvuXOeTrw8tK2Yobb7iP4TMotVrR0yT99ii8InBe/zKg8nz5g8VKuN2M1NzR4XueCgj/q8adYEkJd/sP48k3Vze5YaJu6DwENII2R1FK6+8qUKK7pLQPmgr7E7Wadw7nFyu3k/9jkac9xpiRflQ8dOIHNzwQAPCurBf+uVcE2KZr2W+4cZTcjDNDsg9DvJekfE8UlygB/2bqwb4Gyf00Q90FuRkfBpZspj82YMCz14rnXxHMJtw/fTfusrIQg7oW5at4xBNyhHl99KBB8NeJvDYMPKMKcVZuDIsAztjrj72aVQsMzvlUqWS98G9YPjdET3qx0uRwGJ/1Ib1avNHYovIDnNYZjLEwYBI1pMnatLJmTb5ZcbZLd3XxWE+huWJfNTfIFHUPOi6jmhaKV4wXcsMBlfF3IqjX+UvVQTyvfynXGIv+TnBc8+NF6QWYrk94PK9d0M9PihqjavsyVlU08KInw+kFDrtbu3dXrOkMxXpp19iqc2gXnJ3qu68CRLZcfYlTnykr0hSf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(136003)(346002)(396003)(39830400003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(38350700005)(41320700001)(2616005)(2906002)(52116002)(5660300002)(6666004)(7416002)(66946007)(66556008)(4326008)(26005)(1076003)(66476007)(8676002)(8936002)(38100700002)(83380400001)(508600001)(41300700001)(40180700001)(86362001)(40160700002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fmYyUEZkAyx95G1afj6YhupAyyFNeDmgEanGKNFXZKi2QvM5dYKwv6YgIRVe?= =?us-ascii?Q?UkWT86t5wP7kS0UNUgYtGTVIL1UAemE8Y3bOPYYoxD9cKkwA1okPStasj20Q?= =?us-ascii?Q?9T4aTfAJUxNjpQtacBz2rcc55uQQxJPYV7rsCuQZ+uy4cjF0JSwksx3Kqtig?= =?us-ascii?Q?8oqjmFlp6EA8T1Wo/gfwGfkfV6W7Ax060kGCwdN5yHyLBOOTEXOnJV1W9TD4?= =?us-ascii?Q?/TQ+MoUajzdfMvsEsf1Y4w/+rxk0Ym8FMgUe6dQMdP5EMFZnm36Nok4kxLbL?= =?us-ascii?Q?TX8loUFZytr5Vx3tb2Kt8C1GcmKD7VA5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Q?hVKEnyZAP2i0T2pHvBbFoj70zXTB1fm63mX8e5ysjyJFe3VtfkXwK+dZvB/X?= =?us-ascii?Q?t6C9l4IxmvaZficH5e3OZv0Kk/O2e/SqGyC8+UyaxkpKOssMHCE8HdUpvwgB?= =?us-ascii?Q?cGVJr+3ieDjUAYn/kqnecCbj1MSZZbki5zGpgfNLfl2D9k/3Mn2Dl7qGL3x7?= =?us-ascii?Q?JpUYmtrcug41EsbKMECGr5BCOYrBEhhUgW6a0wotO+MveY7hEEFNbBVWlFYI?= =?us-ascii?Q?WWjqTtzpkfjqXQ2fEbrkn5mgcMfSij2Lln9HMybyOgVDwwQ6mVtGqg7KqxYT?= =?us-ascii?Q?36rTV4gA/hxnIBeoMKlkU7PmIPEAvVJOK843dbJNmiIYi9lxTyWWOz8f+Yzc?= =?us-ascii?Q?orWEGH2wIFz9TlIKxq3WS9uDjAcr/QOG/sx/AAXz56W2cyIwFj6uP6aK4yuq?= =?us-ascii?Q?wg=3D=3D?= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ef9589a-0228-4d00-9edd-08dc20b6cc3e X-MS-Exchange-CrossTenant-AuthSource: BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 10:41:06.5652 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rvFX3C1K0rXLTcIiMkm0of+3og/Sl3cJtmEkxF1E9zf21jfYP8kWCL5/rdaYGPjvHa1H7SNRnFEHwKqqX+lrrMQQlE3Hw3byzswr7odBNUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJSPR01MB0594 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=2406:e500:4440:2::616; envelope-from=jeeheng.sia@starfivetech.com; helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1706524982939100001 Content-Type: text/plain; charset="utf-8" Generate the Processor Properties Topology Table (PPTT) with a cache type 1 structure for RISC-V virtual machine. A 3-layer cache topology is used. Signed-off-by: Sia Jee Heng --- hw/riscv/virt-acpi-build.c | 49 +++++++++++++++++++++++++++++++++++++- hw/riscv/virt.c | 1 + 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 26c7e4482d..d95ae1cf01 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -38,6 +38,7 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "qemu/units.h" #include "sysemu/reset.h" =20 #define ACPI_BUILD_TABLE_SIZE 0x20000 @@ -528,12 +529,54 @@ static void build_madt(GArray *table_data, acpi_table_end(linker, &table); } =20 +static void pptt_setup(GArray *table_data, BIOSLinker *linker, MachineStat= e *ms, + const char *oem_id, const char *oem_table_id) +{ + CPUCaches default_cache_info =3D { + .l1d_cache =3D &(CPUCacheInfo) { + .type =3D DATA_CACHE, + .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, + .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, + .size =3D 2048 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 4096, + .attributes =3D 0x0a, + }, + .l3_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .size =3D 4096 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 8192, + .attributes =3D 0x0a, + }, + }; + + build_pptt(table_data, linker, ms, oem_id, oem_table_id, + &default_cache_info); +} + static void virt_acpi_build(RISCVVirtState *s, AcpiBuildTables *tables) { GArray *table_offsets; unsigned dsdt, xsdt; GArray *tables_blob =3D tables->table_data; - + MachineState *ms =3D MACHINE(s); table_offsets =3D g_array_new(false, true, sizeof(uint32_t)); =20 @@ -555,6 +598,10 @@ static void virt_acpi_build(RISCVVirtState *s, AcpiBui= ldTables *tables) acpi_add_table(table_offsets, tables_blob); build_rhct(tables_blob, tables->linker, s); =20 + acpi_add_table(table_offsets, tables_blob); + pptt_setup(tables_blob, tables->linker, ms, + s->oem_id, s->oem_table_id); + acpi_add_table(table_offsets, tables_blob); { AcpiMcfgInfo mcfg =3D { diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index f9fd1341fc..a6f468fc22 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1710,6 +1710,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->cpu_index_to_instance_props =3D riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id =3D riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported =3D true; + mc->smp_props.clusters_supported =3D true; /* platform instead of architectural choice */ mc->cpu_cluster_has_numa_boundary =3D true; mc->default_ram_id =3D "riscv_virt_board.ram"; --=20 2.34.1 From nobody Tue Nov 26 15:34:21 2024 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=pass (i=1 dmarc=pass fromdomain=starfivetech.com) ARC-Seal: i=2; a=rsa-sha256; t=1706524963; cv=pass; d=zohomail.com; s=zohoarc; b=TL2qMg265r0F8sB9NEdyTP2aXzwX9eTjlpt4QU0PXAavfwJjQzjun3TZTwDgcz1RIkOYjAu/F2wRDf50vnibH3Tk9gf8cyH1WSNVzCHBRIJZbQ7OzO29YwsDepXW/Pwy0dd2yVsWzcymzApALj8hnKfq7niYpMYv53AdYtI31CM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706524963; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oR6oZhoEfVAJa/pd6hmVtB00Ch1tHWdIwMXgWaVHi4Y=; b=OWBaeZNpqS3kl2vq9qHNVOHLpAxEsTRtiwSsGqeaOR4Mmcf0xsJU2DaY4cbXqk4PJFUx2sImryYyAso6oUUYox9pSH476fcHi5V/lhNYArJKP/pcJe1ivza4RdMWlXlKwzpAgHjpzAdLuLVSV7ZaP662q9fYSijrk8hGSBVCmw8= ARC-Authentication-Results: i=2; 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=pass (i=1 dmarc=pass fromdomain=starfivetech.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706524963877989.0377770664381; Mon, 29 Jan 2024 02:42:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUP5D-0003zm-Bl; Mon, 29 Jan 2024 05:41:43 -0500 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 1rUP5C-0003zR-AV; Mon, 29 Jan 2024 05:41:42 -0500 Received: from mail-bjschn02on20616.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::616] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUP58-0005iY-4H; Mon, 29 Jan 2024 05:41:40 -0500 Received: from BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::16) by BJSPR01MB0594.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 10:41:12 +0000 Received: from BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn ([fe80::3862:65b4:c857:c4a6]) by BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn ([fe80::3862:65b4:c857:c4a6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 10:41:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O3tNGGXhVfExlwdiSll8IabJ3DiAzDepOpYqyIUVk7b7HmmM0BwO64+bFsMjrkHQACzZVW1QcBB27lbIjthR9B2i0z9dKiTgTnRvp10mdejz5MpBGBOL901YSk+VOMvrOZvgKMUDetpq6naqZkj5qQfVRI7+KcRAAzAnQhXz08Kl6cp3PLA0fxWSdJ5+8iS1ND8QMxiBxLEhAImkLwI28mKMflSh3CBvTCAczmOn/RQI37zIuJHzglbBLXETUHWtNlchU74psZjb+TvUZqTvIGnBvlKm34zrKkKZRdIor3uZqwmD20Z/GCTQVBhpH0hGg9iKy+cdXaMRjcIhMsyA6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oR6oZhoEfVAJa/pd6hmVtB00Ch1tHWdIwMXgWaVHi4Y=; b=JDBq9TYEfuSy8KNE4w7S107meeGWZISnINI0nbLSJDFpy9F9Bb1c/zruTDIFMEpQc5yHZxXnts+5SEKntB4Gxxn/cTZDqoImz+MWFwINGZCgnN7vahgfz4GzGkOsuNw2YYxkJN/AmyBjMjTqb6uDO/nR8hbhPz2nUIb+tlnm79QaNwQMchj42EK86KoJwvL3lQPF7UpRRnN7e6PTS+eJk2ilUjQXeIwMztjlUbzVlaloBSd738ofLixFgUwXgk4ahaGP90xa9MXOHdD7tOOULz8dVsddum9l7aY89i54pPIUwBG6Yq1adHw8oUyp/M1Atrt8Cq6FTI5anI6sJUdPFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; From: Sia Jee Heng To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org Cc: mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, shannon.zhaosl@gmail.com, jeeheng.sia@starfivetech.com, peter.maydell@linaro.org, sunilvl@ventanamicro.com, palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com Subject: [RESEND RFC 3/3] hw/arm/virt-acpi-build.c: Enable CPU cache topology Date: Mon, 29 Jan 2024 02:40:39 -0800 Message-Id: <20240129104039.117671-4-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129104039.117671-1-jeeheng.sia@starfivetech.com> References: <20240129104039.117671-1-jeeheng.sia@starfivetech.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BJSPR01CA0004.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:c::16) To BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:f::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BJSPR01MB0561:EE_|BJSPR01MB0594:EE_ X-MS-Office365-Filtering-Correlation-Id: 48926e21-ddb1-4c35-dcc1-08dc20b6cf98 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mVHKS/WfyQn6t+RlTLbmU8Qpit1iCk/SX7SSZwvp+HeLYRfYGywWFshWS7Q2Bzq9t0u1/wO5mjg89c8NRBc/Q334W5CZeXfTfhvtGAPrkaZ2EcwaKuS1YmqkkadTLw92klnJ+nkmZRzJF6jK2IS9af/i66XqOUywByrreNwJavL3rJv1ob3M1R0hmmYvAKvBhR7f639yTbh3YfP0OZUyGMGQ1jbn4PCJ0ADf/6JM1GP9eecalo7Se6vYDSqU2W+ucD3XOkkMIVMc8kdazr/YIMuBeXLlqyqm9B6zZm422klLJ157DwjbiPcpBoykUpFG8lANAhUZePTsUjkezsBiCBC+GDXElN1DFMTN7p3/ZUwqJ30RnuP7IOT4WbirNQFQinZazDa6hNNtagpTrJFL5Z/Tbcc5nXJK4uB8FI1oRa48YWk6G9Wfz+xlssja2r0QwEIMr72+bXqiabBz4I4RombKLFFype8wYVOQRrPDEXC6OAmZkghmqLKWX+ovMuYAUAYBDQnum8IyP6TjzI3+0pAc3x312Iay3A3egOGi/zQk5ezarxlQ1JsrhyUyT/Ys X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(136003)(346002)(396003)(39830400003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(38350700005)(41320700001)(2616005)(2906002)(52116002)(5660300002)(6666004)(7416002)(66946007)(66556008)(4326008)(26005)(1076003)(66476007)(8676002)(8936002)(38100700002)(83380400001)(508600001)(41300700001)(40180700001)(86362001)(40160700002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ovdp45Z/ek7alqIGCiuKL/Apqfe5eSZUa+f8MVX/KlMrSv7Kv8C21K5W2p8B?= =?us-ascii?Q?jb34YLPM2h7Yi5cDsgUAIwSTus3pM/Zd9Lj5zcIGuM8/6gWFzQ/D5X9Ckq8r?= =?us-ascii?Q?5npon7FQzg+amFS6xWl0CPcZ6q/XaSWDNipVQcOQahbSrOtLMOGwOina+Bta?= =?us-ascii?Q?0o6bXsBT1fzgT6XpsHNYsj+FyKRB25XTPwNUdeNTNcVZXfjEEwy3J6aZFvwZ?= =?us-ascii?Q?Mc6vkrTLfKnWNNATNZI18PtJQgBx2iB9rV8M7xUU23DrV2wbBguuaWlN6uJ7?= =?us-ascii?Q?wRF852M39A5fTv9xan8lUIgldAGxZTkAbXqISzJX9PSLpvL2HKaxl6E2Q2JB?= =?us-ascii?Q?rrLFqsqAYlvs2Y6MPJcQOWAkwdk4+1dtecgQa6C8Pql2DeMEpESi1ti+alks?= =?us-ascii?Q?jtAv8xu5SdxwNTSRq7Qsuz7hGy4gdazouzM3NqZk1sH3AO4n/ofY5SPLHdM3?= =?us-ascii?Q?DuSvh+qOh0O2eHWEEl+bFtpfEbh1mF20JCp4UUDOTCysWbN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UBj+b14gSqbOffiR2Kl9EZZbime6txsn2vjy?= =?us-ascii?Q?JJRo5kJV+s5DIBAOqxyaPG6n8sWRl8B4UrC1BtW3MsItoYNUkJqteKyL0yRS?= =?us-ascii?Q?N/LihBvPryNsEEmAy2sg1QOOQKdKsOAHA7iesrpUe72kSZZ3brDMInt/YGmU?= =?us-ascii?Q?W5Ud53Rf+HSgwTbDfg/Wzai738+LjbWJ/G105PqgbCX/vLwIHdxZsbHbJBzp?= =?us-ascii?Q?NQ=3D=3D?= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48926e21-ddb1-4c35-dcc1-08dc20b6cf98 X-MS-Exchange-CrossTenant-AuthSource: BJSPR01MB0561.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 10:41:12.2059 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LtqeuRVR2IUxQBxpsFOhShzog/yY7EsI2tPlzHTu4+8D0zwG9lP5v+QJaCQGoBGo+s/y5KSVwoyb6zCUNH2JD8A/yNe31adIBuapjbBXOPE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJSPR01MB0594 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=2406:e500:4440:2::616; envelope-from=jeeheng.sia@starfivetech.com; helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1706524964747100001 Content-Type: text/plain; charset="utf-8" Introduced a 3-layer cache for the ARM virtual machine. Signed-off-by: Sia Jee Heng --- hw/arm/virt-acpi-build.c | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 17aeec7a6f..c57067cd63 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -426,6 +426,48 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) g_array_free(its_idmaps, true); } =20 +static void pptt_setup(GArray *table_data, BIOSLinker *linker, MachineStat= e *ms, + const char *oem_id, const char *oem_table_id) +{ + CPUCaches default_cache_info =3D { + .l1d_cache =3D &(CPUCacheInfo) { + .type =3D DATA_CACHE, + .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, + .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, + .size =3D 2048 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 4096, + .attributes =3D 0x0a, + }, + .l3_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .size =3D 4096 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 8192, + .attributes =3D 0x0a, + }, + }; + + build_pptt(table_data, linker, ms, oem_id, oem_table_id, + &default_cache_info); +} + /* * Serial Port Console Redirection Table (SPCR) * Rev: 1.07 @@ -912,7 +954,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTa= bles *tables) =20 if (!vmc->no_cpu_topology) { acpi_add_table(table_offsets, tables_blob); - build_pptt(tables_blob, tables->linker, ms, + pptt_setup(tables_blob, tables->linker, ms, vms->oem_id, vms->oem_table_id); } =20 --=20 2.34.1