From nobody Sat Nov 23 22:59:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1730846944; cv=none; d=zohomail.com; s=zohoarc; b=c4hUHr0hc8fqwYokiO4gJIWdKcolj2RITuIvOt+vLEUCxZsGl0kv1LiVSeyrGPuIyIqFOE6WltvansP7CFEdH832gdWZ1uflL8Lfg24B6ENAv9bY9Sh1SSeysxXiarN2YO+vlJvcVnmU+T/8tuYk205s3VyGwEmpEOPcwcKZ9aA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730846944; 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=yO4H0PQU46poZcawdHKCxAwWzKVbcu49KDTCodEmFUE=; b=nQVJjFyYkrhCNJP8ABVOY/A8oqxvie6ntSYfzNCgxWZz7I46T6IBslau/EpOR7pjraOJygP4WeglGinBNPgw3iBWl8tcwgZJJiGcgrPodZfVO82U40PSZw6bhn3Yho7/tmYM3pTTOpbNErRWHmTyAtc/E7YGC7zHurnGkdWNmUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730846944339442.8027434186042; Tue, 5 Nov 2024 14:49:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8SLg-00065Y-Tf; Tue, 05 Nov 2024 17:48:33 -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 1t8SLb-00062l-6d for qemu-devel@nongnu.org; Tue, 05 Nov 2024 17:48:27 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8SLZ-0004EE-Ha for qemu-devel@nongnu.org; Tue, 05 Nov 2024 17:48:26 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-37d4d1b48f3so3455138f8f.1 for ; Tue, 05 Nov 2024 14:48:25 -0800 (PST) Received: from localhost.localdomain ([89.101.241.141]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10d4983sm17248159f8f.33.2024.11.05.14.48.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Nov 2024 14:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730846904; x=1731451704; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yO4H0PQU46poZcawdHKCxAwWzKVbcu49KDTCodEmFUE=; b=G5uXkCnQPKSLSTaocfWms1jF1mt8gdTBQ1WY24u9uQ+VYuHSEKhgMVSzmdLLxfzmsv rbMF6+mcnRz4iiUkw06zwBKEx8+yUvx0fs0bDOzyz6iztKJDH0VDV0carm7VnuMX9HAK kVheJNI3TxmWS1/aqCrcQH9vfN4ufTCae2FP/pc8sZo3by6lTk59vSZyVuVpY4rrUXfO RQpii4peuAQq8xQvkXreRE+zo818S8UhFwpt1j1hu5e/dz2A1krNQLu/m7pjGHjjwIlH QgK6eXUFZjSjBOc0X737CfgeETCUerg/knnLcCRbhUf1t3ouubiG3zNhUUMW6M12baF3 9X0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730846904; x=1731451704; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yO4H0PQU46poZcawdHKCxAwWzKVbcu49KDTCodEmFUE=; b=PMZmggsd8Jwa5rsePdeSq8f5dEErTKdVknh8MhbVxWCf9NmUVUeS5RnOBMhejHiPRv XrDSzODRzbKRSDv6jgGAVaestu+ESnw4XGil+iktBol2GAtmXGqAhOBcDpFjSrEsLJVt LtO0X1pTBQAUfWUmPfbHUvyW6T4rLl9ZcPxkNep13xueXPS3E3MPMn7c5LOmeUxj/7Uc xO7sQimNFMCztMNd9NFvcku+kqFwZrn6AV2CcgRpKhejArFxtL8i1aXo5kKBv3JSwPyE EZNhjXFa9cPtrM5cobycGUjKopmRF6eKQaUs1W9KGw+GVWLvZAxzU76/oL8GzRKuYImw Q0Ow== X-Gm-Message-State: AOJu0YxCGTMhVoP6yUEGf2deNDfz6uoDDDre2/97Yoyl4CKIfntT5Jxk QdZ6zd+OxVmSrfEFTZadAb4bymCKEiUmHzb2XefXh8LcHZlk/pozhxI35dOMnjjsMhj1LAfV4Ho 4yKx9/Q== X-Google-Smtp-Source: AGHT+IHvN25WsBvfZJLyuxKIT55PHYhNcg4cTWo/PSDGzc0icZfRcaZzGZFHe1JfYMi5TT58x1bE7Q== X-Received: by 2002:adf:ec4f:0:b0:374:c614:73df with SMTP id ffacd0b85a97d-381b710f3f4mr16151267f8f.57.1730846903726; Tue, 05 Nov 2024 14:48:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Zhao Liu , Yongwei Ma , Jonathan Cameron , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 10/29] hw/core: Check smp cache topology support for machine Date: Tue, 5 Nov 2024 22:47:08 +0000 Message-ID: <20241105224727.53059-11-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241105224727.53059-1-philmd@linaro.org> References: <20241105224727.53059-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1730846945211116600 From: Zhao Liu Add cache_supported flags in SMPCompatProps to allow machines to configure various caches support. And check the compatibility of the cache properties with the machine support in machine_parse_smp_cache(). Signed-off-by: Zhao Liu Tested-by: Yongwei Ma Reviewed-by: Jonathan Cameron Message-ID: <20241101083331.340178-5-zhao1.liu@intel.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/boards.h | 3 +++ hw/core/machine-smp.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index b3a8064ccc9..edf1a8ca1c4 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -153,6 +153,8 @@ typedef struct { * @books_supported - whether books are supported by the machine * @drawers_supported - whether drawers are supported by the machine * @modules_supported - whether modules are supported by the machine + * @cache_supported - whether cache (l1d, l1i, l2 and l3) configuration are + * supported by the machine */ typedef struct { bool prefer_sockets; @@ -162,6 +164,7 @@ typedef struct { bool books_supported; bool drawers_supported; bool modules_supported; + bool cache_supported[CACHE_LEVEL_AND_TYPE__MAX]; } SMPCompatProps; =20 /** diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index c6d90cd6d41..ebb7a134a7b 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -261,10 +261,32 @@ void machine_parse_smp_config(MachineState *ms, } } =20 +static bool machine_check_topo_support(MachineState *ms, + CpuTopologyLevel topo, + Error **errp) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + + if ((topo =3D=3D CPU_TOPOLOGY_LEVEL_MODULE && !mc->smp_props.modules_s= upported) || + (topo =3D=3D CPU_TOPOLOGY_LEVEL_CLUSTER && !mc->smp_props.clusters= _supported) || + (topo =3D=3D CPU_TOPOLOGY_LEVEL_DIE && !mc->smp_props.dies_support= ed) || + (topo =3D=3D CPU_TOPOLOGY_LEVEL_BOOK && !mc->smp_props.books_suppo= rted) || + (topo =3D=3D CPU_TOPOLOGY_LEVEL_DRAWER && !mc->smp_props.drawers_s= upported)) { + error_setg(errp, + "Invalid topology level: %s. " + "The topology level is not supported by this machine", + CpuTopologyLevel_str(topo)); + return false; + } + + return true; +} + bool machine_parse_smp_cache(MachineState *ms, const SmpCachePropertiesList *caches, Error **errp) { + MachineClass *mc =3D MACHINE_GET_CLASS(ms); const SmpCachePropertiesList *node; DECLARE_BITMAP(caches_bitmap, CACHE_LEVEL_AND_TYPE__MAX); =20 @@ -283,6 +305,25 @@ bool machine_parse_smp_cache(MachineState *ms, set_bit(node->value->cache, caches_bitmap); } =20 + for (int i =3D 0; i < CACHE_LEVEL_AND_TYPE__MAX; i++) { + const SmpCacheProperties *props =3D &ms->smp_cache.props[i]; + + /* + * Reject non "default" topology level if the cache isn't + * supported by the machine. + */ + if (props->topology !=3D CPU_TOPOLOGY_LEVEL_DEFAULT && + !mc->smp_props.cache_supported[props->cache]) { + error_setg(errp, + "%s cache topology not supported by this machine", + CacheLevelAndType_str(node->value->cache)); + return false; + } + + if (!machine_check_topo_support(ms, props->topology, errp)) { + return false; + } + } return true; } =20 --=20 2.45.2