Received: by 2002:a17:504:17c4:b0:1be9:327d:8ee3 with SMTP id o4csp5888685njd; Mon, 28 Apr 2025 04:08:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8Dy1n4NOlGfR+9pdOYGNVZ18mzfAl/MYKspf5K5I8W359wvRH9Rpot2glxLyva5Rcgkh6znB12T7RkA==@linaro.org X-Google-Smtp-Source: AGHT+IGxwqrlJyQPGUhDl16LKyDSxfjy5/wCmYvBeBG/G1+8RdGnmZxJKUv2eEFC2PSXdD8Ng17/ X-Received: by 2002:a05:622a:153:b0:476:5fd5:4de7 with SMTP id d75a77b69052e-4801e4ef5c4mr200288731cf.41.1745838519717; Mon, 28 Apr 2025 04:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745838519; cv=none; d=google.com; s=arc-20240605; b=dG82lOdBqxTjPNZmSqaYD3D2ubvviq5G7YHH1WBcnmLrS/jQ9GVf/d70O51nwbrPBm zSrTUmcfcMziY6YOHRCGWMNFqIuD9HUws/+/sAe1ydaUkcdZN95VGqQx8GmDMzLaF0Gd qZG9PaE11fzmuypXF9yVZxsa1KM/RNzvAYBt/ZuKKstfRPmriuSM+pv+I3ox1rCC+KRZ /oDFFq000oipoE/u8CgPQrXXiZwFVk/bCja0xhBC1s/flxCfKuFfXcj3jZq084Aqejes 1eACpJ5Lh1iHQLPHL/RLdAAPoQBv8RwXBmTYig5a4bcOKZd7EtC8IgSv5we53krISWLc fACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:from:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to; bh=P4MjrEkE3pFzVFNs8O406ceBwsNugKQmmNOa08IAuoU=; fh=4I6C6M6UnjJSR8ua+77IMjq+L7KY+8Gqk52ai7dLWhQ=; b=BCIGbDdthaxvKhL6CxF4fvOtaJBfSALdgkWxYB7L1mIC1BoDseX73/bgFbAcVLQx2O Fnd81TpwqF04gVUXp839k5ql2ck+sCFyhZnfu82apLIYHrLOLCGmIyZQpXoNNgjOGdzv xm7NffbAMVvUsaFovsQ23wAHpb/JDuO4NPgTdpUIUCkhisjA3m4cbU9WTyF3tTbzBzlc mtnl42TzGUy4TEKHeRUREDBFTYKMYwUEqWe8VJzJDDffVkWO/F+XOGmOX7VgEGbNSull +S9/tgasmSk0qqsZYboBCYuyI9LjGTPCaR49T8nE3SqxdtGlgG9wjL7nMSwCO4EVWugJ wlkw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-47e9fa9999fsi105568911cf.174.2025.04.28.04.08.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Apr 2025 04:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9MLP-00038e-Vq; Mon, 28 Apr 2025 07:08:16 -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 1u9MLK-00034T-88; Mon, 28 Apr 2025 07:08:10 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9MLG-0001T7-00; Mon, 28 Apr 2025 07:08:08 -0400 Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4ZmLCH6LlSz6K9QY; Mon, 28 Apr 2025 19:03:07 +0800 (CST) Received: from frapeml500003.china.huawei.com (unknown [7.182.85.28]) by mail.maildlp.com (Postfix) with ESMTPS id AC4761402EF; Mon, 28 Apr 2025 19:07:55 +0800 (CST) Received: from a2303103017.china.huawei.com (10.203.177.99) by frapeml500003.china.huawei.com (7.182.85.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 28 Apr 2025 13:07:54 +0200 To: CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 0/6] Specifying cache topology on ARM Date: Mon, 28 Apr 2025 12:07:48 +0100 Message-ID: <20250428110754.48-1-alireza.sanaee@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.203.177.99] X-ClientProxiedBy: lhrpeml100012.china.huawei.com (7.191.174.184) To frapeml500003.china.huawei.com (7.182.85.28) Received-SPF: pass client-ip=185.176.79.56; envelope-from=alireza.sanaee@huawei.com; helo=frasgout.his.huawei.com 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_H2=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: , Reply-to: Alireza Sanaee From: Alireza Sanaee via Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: Zi6kaNGoAeix Specifying the cache layout in virtual machines is useful for applications and operating systems to fetch accurate information about the cache structure and make appropriate adjustments. Enforcing correct sharing information can lead to better optimizations. Patches that allow for an interface to express caches was landed in the prior cycles. This patchset uses the interface as a foundation. Thus, the device tree and ACPI/PPTT table, and device tree are populated based on user-provided information and CPU topology. Example: +----------------+ +----------------+ | Socket 0 | | Socket 1 | | (L3 Cache) | | (L3 Cache) | +--------+-------+ +--------+-------+ | | +--------+--------+ +--------+--------+ | Cluster 0 | | Cluster 0 | | (L2 Cache) | | (L2 Cache) | +--------+--------+ +--------+--------+ | | +--------+--------+ +--------+--------+ +--------+--------+ +--------+----+ | Core 0 | | Core 1 | | Core 0 | | Core 1 | | (L1i, L1d) | | (L1i, L1d) | | (L1i, L1d) | | (L1i, L1d)| +--------+--------+ +--------+--------+ +--------+--------+ +--------+----+ | | | | +--------+ +--------+ +--------+ +--------+ |Thread 0| |Thread 1| |Thread 1| |Thread 0| +--------+ +--------+ +--------+ +--------+ |Thread 1| |Thread 0| |Thread 0| |Thread 1| +--------+ +--------+ +--------+ +--------+ The following command will represent the system relying on **ACPI PPTT tables**. ./qemu-system-aarch64 \ -machine virt,smp-cache.0.cache=l1i,smp-cache.0.topology=core,smp-cache.1.cache=l1d,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp-cache.2.topology=cluseter,smp-cache.3.cache=l3,smp-cache.3.topology=socket \ -cpu max \ -m 2048 \ -smp sockets=2,clusters=1,cores=2,threads=2 \ -kernel ./Image.gz \ -append "console=ttyAMA0 root=/dev/ram rdinit=/init acpi=force" \ -initrd rootfs.cpio.gz \ -bios ./edk2-aarch64-code.fd \ -nographic The following command will represent the system relying on **the device tree**. ./qemu-system-aarch64 \ -machine virt,smp-cache.0.cache=l1i,smp-cache.0.topology=core,smp-cache.1.cache=l1d,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp-cache.2.topology=cluseter,smp-cache.3.cache=l3,smp-cache.3.topology=socket \ -cpu max \ -m 2048 \ -smp sockets=2,clusters=1,cores=2,threads=2 \ -kernel ./Image.gz \ -append "console=ttyAMA0 root=/dev/ram rdinit=/init acpi=off" \ -initrd rootfs.cpio.gz \ -nographic Failure cases: 1) There are scenarios where caches exist in systems' registers but left unspecified by users. In this case qemu returns failure. 2) SMT threads cannot share caches which is not very common. More discussions here [1]. Currently only three levels of caches are supported to be specified from the command line. However, increasing the value does not require significant changes. Further, this patch assumes l2 and l3 unified caches and does not allow l(2/3)(i/d). The level terminology is thread/core/cluster/socket right now. Hierarchy assumed in this patch: Socket level = Cluster level + 1 = Core level + 2 = Thread level + 3; TODO: 1) Making the code to work with arbitrary levels 2) Separated data and instruction cache at L2 and L3. 3) Additional cache controls. e.g. size of L3 may not want to just match the underlying system, because only some of the associated host CPUs may be bound to this VM. [1] https://lore.kernel.org/devicetree-spec/20250203120527.3534-1-alireza.sanaee@huawei.com/ Change Log: v9->v10: * PPTT rev down to 2. v8->v9: * rebase to 10 * Fixed a bug in device-tree generation related to a scenario when caches are shared at core in higher levels than 1. v7->v8: * rebase: Merge tag 'pull-nbd-2024-08-26' of https://repo.or.cz/qemu/ericb into staging * I mis-included a file in patch #4 and I removed it in this one. v6->v7: * Intel stuff got pulled up, so rebase. * added some discussions on device tree. v5->v6: * Minor bug fix. * rebase based on new Intel patchset. - https://lore.kernel.org/qemu-devel/20250110145115.1574345-1-zhao1.liu@intel.com/ v4->v5: * Added Reviewed-by tags. * Applied some comments. v3->v4: * Device tree added. Depends-on: Building PPTT with root node and identical implementation flag Depends-on: Msg-id: 20250423114130.902-1-alireza.sanaee@huawei.com Alireza Sanaee (6): target/arm/tcg: increase cache level for cpu=max arm/virt.c: add cache hierarchy to device tree bios-tables-test: prepare to change ARM ACPI virt PPTT hw/acpi/aml-build.c: add cache hierarchy to pptt table tests/qtest/bios-table-test: testing new ARM ACPI PPTT tables Update the ACPI tables according to the acpi aml_build changes hw/acpi/aml-build.c | 201 +++++++++- hw/arm/virt-acpi-build.c | 8 +- hw/arm/virt.c | 343 ++++++++++++++++++ hw/cpu/core.c | 92 +++++ hw/loongarch/virt-acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 4 +- include/hw/arm/virt.h | 4 + include/hw/cpu/core.h | 26 ++ target/arm/tcg/cpu64.c | 13 + tests/data/acpi/aarch64/virt/PPTT | Bin 96 -> 176 bytes .../data/acpi/aarch64/virt/PPTT.acpihmatvirt | Bin 176 -> 496 bytes tests/data/acpi/aarch64/virt/PPTT.topology | Bin 356 -> 676 bytes tests/qtest/bios-tables-test.c | 14 +- 13 files changed, 698 insertions(+), 9 deletions(-) -- 2.34.1