{"id":2227191,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2227191/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260423100229.2941820-3-peter.maydell@linaro.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260423100229.2941820-3-peter.maydell@linaro.org>","date":"2026-04-23T10:01:32","name":"[PULL,02/59] hw/core/machine: topology functions capabilities added","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"f64c216255ff898dc50cd74380efc8e6e068f26e","submitter":{"id":5111,"url":"http://patchwork.ozlabs.org/api/1.1/people/5111/?format=json","name":"Peter Maydell","email":"peter.maydell@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260423100229.2941820-3-peter.maydell@linaro.org/mbox/","series":[{"id":501172,"url":"http://patchwork.ozlabs.org/api/1.1/series/501172/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501172","date":"2026-04-23T10:01:35","name":"[PULL,01/59] target/arm/tcg: increase cache level for cpu=max","version":1,"mbox":"http://patchwork.ozlabs.org/series/501172/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2227191/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2227191/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=Q3YQHn/H;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1Wsl0fQ9z1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 20:04:42 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFqtR-0006Jl-4R; Thu, 23 Apr 2026 06:02:45 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peter.maydell@linaro.org>)\n id 1wFqtK-0006IG-Kg\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 06:02:39 -0400","from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <peter.maydell@linaro.org>)\n id 1wFqtH-0001t3-Op\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 06:02:38 -0400","by mail-wr1-x42a.google.com with SMTP id\n ffacd0b85a97d-43d03db7f87so4400704f8f.3\n for <qemu-devel@nongnu.org>; Thu, 23 Apr 2026 03:02:35 -0700 (PDT)","from lanath.. (wildly.archaic.org.uk. [81.2.115.145])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43fe4e4eec9sm49323930f8f.34.2026.04.23.03.02.32\n for <qemu-devel@nongnu.org>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 23 Apr 2026 03:02:32 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1776938553; x=1777543353; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:to:from:from:to:cc:subject:date:message-id\n :reply-to; bh=e4SVw6/0iy8VqNnBZElqRdTaBGFeTVDwu9oinIEbAL0=;\n b=Q3YQHn/HubgLxujEtJmWVdy33TL/Lv8+zGGZ/JqOPDS5Znbj5kHJQXK/zc6KIbTxvv\n fJ6hucKX6cF4pUnsrvdxuiwbpdGlDeDytL8drbr69mLP1iR0dERiKQ3Ze0gpV4fRxPfI\n rhXYRE+NGrl0VvPAlegNg4o9APTWPWvdkx9BlwcpqAIgnb0PFeXW9BvjEtBMaDsAmmHa\n /IBHUqzTPZiw1Rfee4u1WTP98PljsNoy2qt88RMdXhXhHNl+4mVIZ+YVCXgIjZpAtvAN\n VYTmFOZlpmovHHsh+WsP+ax/BE6Jt72JcoC8kr/iScDoX0kBHq9YcDKwZc79P+XCN2Yn\n USZg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776938553; x=1777543353;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=e4SVw6/0iy8VqNnBZElqRdTaBGFeTVDwu9oinIEbAL0=;\n b=ewaqwmrU9xZGEP7VQzau2ebFcbziNtsJfUe188NAexF9BwpiiL6O9gh2SUBRxtV/Bz\n s+vUg/JTCBLZ194joXD1clGpOCMi4NfjwTeP3mN1U69NjNjfXO8EZkR2uuVms4VSmBOx\n Wyz+V/aTHTtih+kkDwCAXIOngW4odskEG3ricjP8jfAdeHpsppK2RFxExOu5Ko4+OBld\n GGAvsLfFPVs9ZpY5XqcbKas5W+R61Gv+439JkzdwrplkZnpc9nDduqhSPBXYNLGyN4W4\n fFujUcXX9Jb2jWzEAKj+05VLKuiUrpdfP9m9lGOJDbARX1ykJYBWDxCtUAW8i2bgsN3y\n Jz7Q==","X-Gm-Message-State":"AOJu0YwQKiw0o/uEnEaPHR2lThRHsQh7wOp1/BYBuOSMUYuF2w/aafkI\n i70079WrmpLv5T3tFg4/kP5O4EDIOYvxFqD8VFr3bZNwkBnVM7r+NDexzHy9iO7qFo6+lfpmb+r\n zVlVf","X-Gm-Gg":"AeBDieuesy7Rov4G8F8UlnYgQpeu1zspGET2RNEf3/f7+EbA3bjVfgmd7HrQZC0R+A3\n iyVuZpxeEs11uu1TJA891jsa8Wr4EX2NWCv0P3M33oXpto2DCoJC+V3jObuIS4GD3qOk0D5OCZT\n 2kdKvQouAv4uTl+65eHM9Hao5iB3uBz9rQD7TWISQlXXeyVcGl1B/EihSyMPqkZGgnn8EwQ+D3v\n CjAFcf4Zdgby/r0NNMtZWe4V60TZQ3qeB6pf+GCRFU96RE58Chlq4weN9TGn/feaJ4rtyOgfmBy\n Y/B5OUG4IaGh0g8t9QlS+P5tBndSHVac5QCUX8D9KcHRkVqfbr8RZn1Ezcw9huvFCf/mVR3OyKo\n jGHSVOlHotjImEcRQPTIze+qJ29teAB33+sZs6eVA/qtLCD5sPUspUAFF7gWz04jLTrJ6z1+asr\n bljwBGV/yS9y8VmleGAR2sEhGj0hjAWFNE8unk1wfNvCV2bxoAobKODBOeI+mWIGo5FsFy5tzov\n 9Ols/TS2s7Gg4EucW+fOO5CTnMDwsMZE+YKeQiBGQ==","X-Received":"by 2002:a05:6000:144d:b0:43c:fe0e:5bbc with SMTP id\n ffacd0b85a97d-43fe3dc59a6mr39049155f8f.19.1776938553227;\n Thu, 23 Apr 2026 03:02:33 -0700 (PDT)","From":"Peter Maydell <peter.maydell@linaro.org>","To":"qemu-devel@nongnu.org","Subject":"[PULL 02/59] hw/core/machine: topology functions capabilities added","Date":"Thu, 23 Apr 2026 11:01:32 +0100","Message-ID":"<20260423100229.2941820-3-peter.maydell@linaro.org>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260423100229.2941820-1-peter.maydell@linaro.org>","References":"<20260423100229.2941820-1-peter.maydell@linaro.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2a00:1450:4864:20::42a;\n envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n 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":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Alireza Sanaee <alireza.sanaee@huawei.com>\n\nAdd two functions one of which finds the lowest cache level defined in\nthe cache description input, and the other checks if a given cache\ntopology is defined at a particular cache level\n\nReviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>\nSigned-off-by: Alireza Sanaee <alireza.sanaee@huawei.com>\nReviewed-by: Gustavo Romero <gustavo.romero@linaro.org>\nMessage-id: 20260311160609.358-3-alireza.sanaee@huawei.com\nSigned-off-by: Peter Maydell <peter.maydell@linaro.org>\n---\n hw/core/machine-smp.c    | 52 ++++++++++++++++++++++++++++++++++++++++\n include/hw/core/boards.h |  5 ++++\n 2 files changed, 57 insertions(+)","diff":"diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c\nindex 189c70015f..bef04aa2d7 100644\n--- a/hw/core/machine-smp.c\n+++ b/hw/core/machine-smp.c\n@@ -406,3 +406,55 @@ bool machine_check_smp_cache(const MachineState *ms, Error **errp)\n \n     return true;\n }\n+\n+/*\n+ * This function assumes L3 and L2 have unified cache and L1 is split L1d and\n+ * L1i.\n+ */\n+bool machine_find_lowest_level_cache_at_topo_level(const MachineState *ms,\n+                                                   int *lowest_cache_level,\n+                                                   CpuTopologyLevel topo_level)\n+{\n+    enum CacheLevelAndType cache_level;\n+    enum CpuTopologyLevel t;\n+\n+    for (cache_level = CACHE_LEVEL_AND_TYPE_L1D;\n+         cache_level < CACHE_LEVEL_AND_TYPE__MAX; cache_level++) {\n+        t = machine_get_cache_topo_level(ms, cache_level);\n+        if (t == topo_level) {\n+            /* Assume L1 is split into L1d and L1i caches. */\n+            if (cache_level == CACHE_LEVEL_AND_TYPE_L1D ||\n+                cache_level == CACHE_LEVEL_AND_TYPE_L1I) {\n+                *lowest_cache_level = 1; /* L1 */\n+            } else {\n+                /* Assume the other caches are unified. */\n+                *lowest_cache_level = cache_level;\n+            }\n+\n+            return true;\n+        }\n+    }\n+\n+    return false;\n+}\n+\n+/*\n+ * Check if there are caches defined at a particular level. It supports only\n+ * L1, L2 and L3 caches, but this can be extended to more levels as needed.\n+ *\n+ * Return True on success, False otherwise.\n+ */\n+bool machine_defines_cache_at_topo_level(const MachineState *ms,\n+                                         CpuTopologyLevel topology)\n+{\n+    enum CacheLevelAndType cache_level;\n+\n+    for (cache_level = CACHE_LEVEL_AND_TYPE_L1D;\n+         cache_level < CACHE_LEVEL_AND_TYPE__MAX; cache_level++) {\n+        if (machine_get_cache_topo_level(ms, cache_level) == topology) {\n+            return true;\n+        }\n+    }\n+\n+    return false;\n+}\ndiff --git a/include/hw/core/boards.h b/include/hw/core/boards.h\nindex b8dad0a107..f38b3f5f78 100644\n--- a/include/hw/core/boards.h\n+++ b/include/hw/core/boards.h\n@@ -60,6 +60,11 @@ void machine_set_cache_topo_level(MachineState *ms, CacheLevelAndType cache,\n                                   CpuTopologyLevel level);\n bool machine_check_smp_cache(const MachineState *ms, Error **errp);\n void machine_memory_devices_init(MachineState *ms, hwaddr base, uint64_t size);\n+bool machine_defines_cache_at_topo_level(const MachineState *ms,\n+                                         CpuTopologyLevel topology);\n+bool machine_find_lowest_level_cache_at_topo_level(const MachineState *ms,\n+                                                   int *lowest_cache_level,\n+                                                   CpuTopologyLevel topo_level);\n \n /**\n  * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices\n","prefixes":["PULL","02/59"]}