From nobody Mon May 6 01:10:35 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280607; cv=none; d=zohomail.com; s=zohoarc; b=Y6iT/s/rAMxPtnVGzf99RLITNdHwQrhmS0Qh7piCaDURumCUMZyMPA2HRdT5ffKY6CFxJ7OJJppQ56mCRrm+XVIjd+xslI4l5O3JMG9DWiBaDiNRllJm8EloSoDq9q7gl658XKGrrG0qAkzRveXyMFTao7DKtGR75l/MJWUTws8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280607; h=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=VTHF01Hm6wbm7Vvnd8N/KqcTL14e1JMdyI53J6BLKd8=; b=Ohh8gUbZo+NAGB0+KnNMosr8luU/jRCLhf+fYO7R4sY+mW3+RoZ3D1C380k1Uw+UFEasGS9thk/5a+sM5OU5iSxsfFVf/QMAYBZbOfBlbBH5fYZTNdH0nLnzIxnHemXTlrSt/Ob+g/LHvTMMBzWnzAah/rria0ceYTzvjYlXlBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280607407445.4944581575012; Mon, 13 Feb 2023 01:30:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV8x-0005Er-Py; Mon, 13 Feb 2023 04:29:04 -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 1pRV8w-0005Ei-4T for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:02 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV8r-0006Fx-Qb for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:01 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:28:56 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:28:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280537; x=1707816537; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=atvZGepej5YcLFtx3mYUNr9UNgjfXy1ME0XpKL0DymQ=; b=jII4/kqWLI41RnJyTainVYNgyzEBekcK6ksEuwHTVQdHpq6Tckm4wu0X aZwYuxiZYZSHcFut08p1G2jy0PkisQ/Q/bZi122RZoiSBTmq5TJohOJxd xuyppXy7D566AR0Wwg/WvxKaN4Xce1iALgBejTekokzTU0rMl9VT0u3gK JvZ/ifiO89OC3zSq54TXcf0Pi2NBPdSKWkNU6ClKJ9+Ref12r1kDxmd1a Ifw8ToQ14Sp40hQkJfYXYmLEttn/yYJ7XMqXOv8x9qmH4tQJunr3pmjMH FTFH5b70Da9JDhmWCsRzykguKctAOfzycP63nHqZg1TwH0g3ilAnS0q9s g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875489" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875489" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659731" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659731" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 01/18] machine: Fix comment of machine_parse_smp_config() Date: Mon, 13 Feb 2023 17:36:08 +0800 Message-Id: <20230213093625.158170-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280608724100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Now smp supports dies and clusters, so add description about these 2 levels in the comment of machine_parse_smp_config(). Fixes: 864c3b5 (hw/core/machine: Introduce CPU cluster topology support) Suggested-by: Robert Hoo Signed-off-by: Zhao Liu --- hw/core/machine-smp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index c3dab007dadc..3fd9e641efde 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -51,8 +51,8 @@ static char *cpu_hierarchy_to_string(MachineState *ms) * machine_parse_smp_config: Generic function used to parse the given * SMP configuration * - * Any missing parameter in "cpus/maxcpus/sockets/cores/threads" will be - * automatically computed based on the provided ones. + * Any missing parameter in "cpus/maxcpus/sockets/dies/clusters/cores/thre= ads" + * will be automatically computed based on the provided ones. * * In the calculation of omitted sockets/cores/threads: we prefer sockets * over cores over threads before 6.2, while preferring cores over sockets @@ -66,7 +66,8 @@ static char *cpu_hierarchy_to_string(MachineState *ms) * * For compatibility, apart from the parameters that will be computed, new= ly * introduced topology members which are likely to be target specific shou= ld - * be directly set as 1 if they are omitted (e.g. dies for PC since 4.1). + * be directly set as 1 if they are omitted (e.g. dies for PC since v4.1 a= nd + * clusters for arm since v7.0). */ void machine_parse_smp_config(MachineState *ms, const SMPConfiguration *config, Error **errp) --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280596; cv=none; d=zohomail.com; s=zohoarc; b=mJZTC7ZSoeZCcRWX1oHgZ2IgwUfeqvL6EcQfDY+P+qBh2tTcf0GfMv7N2KnRBo6Fs3L2zDMR6X9OPDw1ssE8G+MF16SoN0fsSISbVhRnTD9+dqf9BSvj7ZNMZRDF6LXvEm31+67AfB8s91YLlwnGXUv1ISgVXw5TpO3Z8YnHXxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280596; h=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=Q+wHDPOx8IRlgxQE2NXbOchbTGsefWoHfTotykHrKZk=; b=Nb26Z5NtGbmx77PWeScJVQKaHCz3P75GTd3i6WETtVz3rPhTc09ktdTlWlfWWP3Nq418fvDVNPZ4mtYW9ysAhIWdi8gacHS2ZQ0dDIeeV8UKT3Mvg1AtHrf5rClAhCiSt0VOmISIqCPTzxdlnoFGvlOESw8LDWk2hvslFOB9ngU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280596310490.3041675099047; Mon, 13 Feb 2023 01:29:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV90-0005Fs-PG; Mon, 13 Feb 2023 04:29:06 -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 1pRV8y-0005FW-UG for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:04 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV8u-0006Gn-KD for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:04 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:28:58 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:28:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280540; x=1707816540; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UQCnERRP56yJTkgsHIsgOPDf4zq51DL2n5InW5S5l9s=; b=KMJ0aHFj6+ewy26mNG5YUlIwG68wwxxfh+sZX9FdtcNM6QDUeGXtBlsC iGrE0JTNTcUcTNgCAAO0PE1vblWXFss1LUzo2XK3RBkBoKFGGc75NEcr2 1qs7hmqIKSJ0JAzZoYTgdVxaUp6hGxMBtJHTFur0TdLqVpy5eiaJW2I2a yT7mZlsP1ptTExf+21q4uuT+fPkMylpKh2Gp8HzImVPzHTs6TGMfYBIQT fDyHZQfJQ8zwBBLU2tObkGkoW7iHBuljX8Ka5BTe+wTiLy84ajEwVz2Re 0ZjNDZcoEcmTq8WaMgCyXagvVfaHGG4Z14K39JVZslQnp/E7x4ICqbRcW A==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875508" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875508" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659794" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659794" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 02/18] tests: Rename test-x86-cpuid.c to test-x86-apicid.c Date: Mon, 13 Feb 2023 17:36:09 +0800 Message-Id: <20230213093625.158170-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280596619100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu In fact, this unit tests APIC ID other than CPUID. Rename to test-x86-apicid.c to make its name more in line with its actual content. Signed-off-by: Zhao Liu --- MAINTAINERS | 2 +- tests/unit/meson.build | 4 ++-- tests/unit/{test-x86-cpuid.c =3D> test-x86-apicid.c} | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename tests/unit/{test-x86-cpuid.c =3D> test-x86-apicid.c} (99%) diff --git a/MAINTAINERS b/MAINTAINERS index 96e25f62acaa..71c1bc24371b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1679,7 +1679,7 @@ F: include/hw/southbridge/piix.h F: hw/misc/sga.c F: hw/isa/apm.c F: include/hw/isa/apm.h -F: tests/unit/test-x86-cpuid.c +F: tests/unit/test-x86-apicid.c F: tests/qtest/test-x86-cpuid-compat.c =20 PC Chipset diff --git a/tests/unit/meson.build b/tests/unit/meson.build index ffa444f4323c..a9df2843e92e 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -20,8 +20,8 @@ tests =3D { 'test-opts-visitor': [testqapi], 'test-visitor-serialization': [testqapi], 'test-bitmap': [], - # all code tested by test-x86-cpuid is inside topology.h - 'test-x86-cpuid': [], + # all code tested by test-x86-apicid is inside topology.h + 'test-x86-apicid': [], 'test-cutils': [], 'test-div128': [], 'test-shift128': [], diff --git a/tests/unit/test-x86-cpuid.c b/tests/unit/test-x86-apicid.c similarity index 99% rename from tests/unit/test-x86-cpuid.c rename to tests/unit/test-x86-apicid.c index bfabc0403a1a..2b104f86d7c2 100644 --- a/tests/unit/test-x86-cpuid.c +++ b/tests/unit/test-x86-apicid.c @@ -1,5 +1,5 @@ /* - * Test code for x86 CPUID and Topology functions + * Test code for x86 APIC ID and Topology functions * * Copyright (c) 2012 Red Hat Inc. * --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280771; cv=none; d=zohomail.com; s=zohoarc; b=C1lHE/DtXburLHindHob4HYoCVsEigjbypR3DJZQrTBrmf2iLNUQB9matp6MwJ0NFmQ84yeJF1Rx8oEni1Y22Y/wGOFpF+4VovKC5FHTM4/47H8pj8RE23xi0bEyNjiD7ul2onheATvbkTSNc7m1i7+0EQtqdgPPNfVljEDXdg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280771; h=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=HCd0KFZEdr/zlgtxaKOkqGLkXNmIOzgO/rdilr+spGY=; b=bzKiT4EiCJr8gslUK7FFYAnUNJTZTvzEyaCRngSGIYMO0rUUd1RHPC93RMD/WBx2gslswJYwDZFZO124zU5i9bY3tAAev2ASKcu5igWopI9LNuwfJphjvWmnIuGpF3/VzkxKOzkCkRZhfe3fZP4RMudZ2KihkTXzaJba0ilXFJs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280771279982.207219208122; Mon, 13 Feb 2023 01:32:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV95-0005GQ-Ja; Mon, 13 Feb 2023 04:29:11 -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 1pRV93-0005G3-WB for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:10 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV8y-0006Ia-Ui for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:09 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:03 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:28:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280544; x=1707816544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ONIXpxjScTTyI+kXqVoanQmgfDC+9C4UoIt3+khElwU=; b=RBOr2/MgG1qHT5vdHo/T2S04275o2fHiBQqduNT4m/cdsUq54HADEZRC 0TlPnPFA7umc9vUYZiO52UAGPyfL38Qkuavwmmx/6tqO64nmeqsOA4XpG 2czu6bAqFFtCGaJobF28tYzCQYllSWk1Orom7pbnI0HAKjmAh47rlhcrH t854W0FyeKns0jAHqz4aU89kvF+xp+vm/cmljXVAsLt/ZVk2Eedpc1ZXE NZsYOCPmV8eukosJrkH2ly/IlWuCHkUj33dhgIPBnddA9iuH66GH7+ncH L4TCWD2LJy0vfnPVdN9Tf72XmBJu/7wTUhns8+huQVtIhBp3mxWMKM8Aq g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875538" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875538" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659833" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659833" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 03/18] softmmu: Fix CPUSTATE.nr_cores' calculation Date: Mon, 13 Feb 2023 17:36:10 +0800 Message-Id: <20230213093625.158170-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280771711100001 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding From CPUState.nr_cores' comment, it represents "number of cores within this CPU package". After 003f230 (machine: Tweak the order of topology members in struct CpuTopology), the meaning of smp.cores changed to "the number of cores in one die", but this commit missed to change CPUState.nr_cores' caculation, so that CPUState.nr_cores became wrong and now it misses to consider numbers of clusters and dies. At present, only i386 is using CPUState.nr_cores. But as for i386, which supports die level, the uses of CPUState.nr_cores are very confusing: Early uses are based on the meaning of "cores per package" (before die is introduced into i386), and later uses are based on "cores per die" (after die's introduction). This difference is due to that commit a94e142 (target/i386: Add CPUID.1F generation support for multi-dies PCMachine) misunderstood that CPUState.nr_cores means "cores per die" when caculated CPUID.1FH.01H:EBX. After that, the changes in i386 all followed this wrong understanding. With the influence of 003f230 and a94e142, for i386 currently the result of CPUState.nr_cores is "cores per die", thus the original uses of CPUState.cores based on the meaning of "cores per package" are wrong when mutiple dies exist: 1. In cpu_x86_cpuid() of target/i386/cpu.c, CPUID.01H:EBX[bits 23:16] is incorrect because it expects "cpus per package" but now the result is "cpus per die". 2. In cpu_x86_cpuid() of target/i386/cpu.c, for all leaves of CPUID.04H: EAX[bits 31:26] is incorrect because they expect "cpus per package" but now the result is "cpus per die". The error not only impacts the EAX caculation in cache_info_passthrough case, but also impacts other cases of setting cache topology for Intel CPU according to cpu topology (specifically, the incoming parameter "num_cores" expects "cores per package" in encode_cache_cpuid4()). 3. In cpu_x86_cpuid() of target/i386/cpu.c, CPUID.0BH.01H:EBX[bits 15:00] is incorrect because the EBX of 0BH.01H (core level) expects "cpus per package", which may be different with 1FH.01H (The reason is 1FH can support more levels. For QEMU, 1FH also supports die, 1FH.01H:EBX[bits 15:00] expects "cpus per die"). 4. In cpu_x86_cpuid() of target/i386/cpu.c, when CPUID.80000001H is caculated, here "cpus per package" is expected to be checked, but in fact, now it checks "cpus per die". Though "cpus per die" also works for this code logic, this isn't consistent with AMD's APM. 5. In cpu_x86_cpuid() of target/i386/cpu.c, CPUID.80000008H:ECX expects "cpus per package" but it obtains "cpus per die". 6. In simulate_rdmsr() of target/i386/hvf/x86_emu.c, in kvm_rdmsr_core_thread_count() of target/i386/kvm/kvm.c, and in helper_rdmsr() of target/i386/tcg/sysemu/misc_helper.c, MSR_CORE_THREAD_COUNT expects "cpus per package" and "cores per package", but in these functions, it obtains "cpus per die" and "cores per die". On the other hand, these uses are correct now (they are added in/after a94e142): 1. In cpu_x86_cpuid() of target/i386/cpu.c, topo_info.cores_per_die meets the actual meaning of CPUState.nr_cores ("cores per die"). 2. In cpu_x86_cpuid() of target/i386/cpu.c, vcpus_per_socket (in CPUID. 04H's caculation) considers number of dies, so it's correct. 3. In cpu_x86_cpuid() of target/i386/cpu.c, CPUID.1FH.01H:EBX[bits 15:00] needs "cpus per die" and it gets the correct result, and CPUID.1FH.02H:EBX[bits 15:00] gets correct "cpus per package". When CPUState.nr_cores is correctly changed to "cores per package" again , the above errors will be fixed without extra work, but the "currently" correct cases will go wrong and need special handling to pass correct "cpus/cores per die" they want. Thus in this patch, we fix CPUState.nr_cores' caculation to fit the original meaning "cores per package", as well as changing caculation of topo_info.cores_per_die, vcpus_per_socket and CPUID.1FH. In addition, in the nr_threads' comment, specify it represents the number of threads in the "core" to avoid confusion. Fixes: a94e142 (target/i386: Add CPUID.1F generation support for multi-dies= PCMachine) Fixes: 003f230 (machine: Tweak the order of topology members in struct CpuT= opology) Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu Reviewed-by: Yanan Wang --- include/hw/core/cpu.h | 2 +- softmmu/cpus.c | 2 +- target/i386/cpu.c | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 2417597236bc..5253e4e839bb 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -274,7 +274,7 @@ struct qemu_work_item; * QOM parent. * @tcg_cflags: Pre-computed cflags for this cpu. * @nr_cores: Number of cores within this CPU package. - * @nr_threads: Number of threads within this CPU. + * @nr_threads: Number of threads within this CPU core. * @running: #true if CPU is currently running (lockless). * @has_waiter: #true if a CPU is currently waiting for the cpu_exec_end; * valid under cpu_list_lock. diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 9cbc8172b5f2..9996e6a3b295 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -630,7 +630,7 @@ void qemu_init_vcpu(CPUState *cpu) { MachineState *ms =3D MACHINE(qdev_get_machine()); =20 - cpu->nr_cores =3D ms->smp.cores; + cpu->nr_cores =3D ms->smp.dies * ms->smp.clusters * ms->smp.cores; cpu->nr_threads =3D ms->smp.threads; cpu->stopped =3D true; cpu->random_seed =3D qemu_guest_random_seed_thread_part1(); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4d2b8d0444df..29afec12c281 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5218,7 +5218,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, X86CPUTopoInfo topo_info; =20 topo_info.dies_per_pkg =3D env->nr_dies; - topo_info.cores_per_die =3D cs->nr_cores; + topo_info.cores_per_die =3D cs->nr_cores / env->nr_dies; topo_info.threads_per_core =3D cs->nr_threads; =20 /* Calculate & apply limits for different index ranges */ @@ -5294,8 +5294,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, */ if (*eax & 31) { int host_vcpus_per_cache =3D 1 + ((*eax & 0x3FFC000) >> 14= ); - int vcpus_per_socket =3D env->nr_dies * cs->nr_cores * - cs->nr_threads; + int vcpus_per_socket =3D cs->nr_cores * cs->nr_threads; if (cs->nr_cores > 1) { *eax &=3D ~0xFC000000; *eax |=3D (pow2ceil(cs->nr_cores) - 1) << 26; @@ -5468,12 +5467,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, break; case 1: *eax =3D apicid_die_offset(&topo_info); - *ebx =3D cs->nr_cores * cs->nr_threads; + *ebx =3D topo_info.cores_per_die * topo_info.threads_per_core; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: *eax =3D apicid_pkg_offset(&topo_info); - *ebx =3D env->nr_dies * cs->nr_cores * cs->nr_threads; + *ebx =3D cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_DIE; break; default: --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280893; cv=none; d=zohomail.com; s=zohoarc; b=XFohAZUHcrQgqyJpE4H1Ir8D74755bmg2BNshDg7MnaAVz9DpUey5Zn0gbmB+cAJvbi1DlsV/912w7wbZRArP5XU8/NA+G1i74/HnVlMT2JyEpItGzp96U5zC1jOTc74CWes3FGbvPRcZH//T0r0QShlogiUvKbgFqvLWz7JELo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280893; h=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=D+6+Zx3lTd5CZ3gy5Oa+RYsMejww0/CV7ioy8Zr6b8g=; b=iG4+nJKb+GjFVdIQl0Y3U6+QH/5OCrTqOHYxJp4fufGOH3LjR3+UqPJ2VJXkhyaQmV8J+nyH5l/t+M9Kh2ltCua7p2WCIl31nsxaOaceZDwqUqu9cOgfKxyUFZAIoNLmKrXsrPbB+FAlkZY1Izir5aS7u9t/lBuJ8lBv8OaaUmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280893611604.1249547384132; Mon, 13 Feb 2023 01:34:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV98-0005IA-6t; Mon, 13 Feb 2023 04:29:14 -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 1pRV97-0005I1-60 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:13 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV93-0006Gn-KT for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:12 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:08 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280549; x=1707816549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V45KLuA9/w11xXLvmCKtl/ElVts0BqFOCOxMYWLjazE=; b=SlnvcURhzfjSTlqOdUL0qiGP8GezpjZKGCgLF5KdkT4GFe0AoI9NsosJ UbVuRSebjVD1xUhKZ3tekKXqaBAyIAZXHSprg7ix9LHT6OdYfcIfry6zI D9uV/5SgsbV+mRmtmNAcQnJaQuWHR9yTalA9EJqWciAEIcW52i3w2mhSS OFstP7+kl28kkQ972Y6ax6vEQ5iL8d9/NddbjJWcb7U8IX+Bw3uDquSkM GNq/hxecMOBGnXu50axNVZoJjKzp3h+Od2Lg9aJo9BQ/SMVrE9Pp2sXV/ yxmVLDik18xrYgSkexe10egz0LAzXuO9kl5I7StnoskUebDCfCEeRkM7t g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875568" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875568" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659866" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659866" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 04/18] i386/cpu: Fix number of addressable IDs in CPUID.04H Date: Mon, 13 Feb 2023 17:36:11 +0800 Message-Id: <20230213093625.158170-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280894578100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu For i-cache and d-cache, the maximum IDs for CPUs sharing cache ( CPUID.04H.00H:EAX[bits 25:14] and CPUID.04H.01H:EAX[bits 25:14]) are both 0, and this means i-cache and d-cache are shared in the SMT level. This is correct if there's single thread per core, but is wrong for the hyper threading case (one core contains multiple threads) since the i-cache and d-cache are shared in the core level other than SMT level. Therefore, in order to be compatible with both multi-threaded and single-threaded situations, we should set i-cache and d-cache be shared at the core level by default. Refer to the fixes of cache_info_passthrough ([1], [2]) and SDM, the CPUID.04H:EAX[bits 25:14] and CPUID.04H:EAX[bits 31:26] should use the nearest power-of-2 integer. The nearest power-of-2 integer can be caculated by pow2ceil() or by using APIC ID offset (like L3 topology using 1 << die_offset [3]). But in fact, CPUID.04H:EAX[bits 25:14] and CPUID.04H:EAX[bits 31:26] are associated with APIC ID. For example, in linux kernel, the field "num_threads_sharing" (Bits 25 - 14) is parsed with APIC ID. And for another example, on Alder Lake P, the CPUID.04H:EAX[bits 31:26] is not matched with actual core numbers and it's caculated by: "(1 << (pkg_offset - core_offset)) - 1". Therefore the offset of APIC ID should be preferred to caculate nearest power-of-2 integer for CPUID.04H:EAX[bits 25:14] and CPUID.04H:EAX[bits 31:26]: 1. d/i cache is shared in a core, 1 << core_offset should be used instand of "1" in encode_cache_cpuid4() for CPUID.04H.00H:EAX[bits 25:14] and CPUID.04H.01H:EAX[bits 25:14]. 2. L2 cache is supposed to be shared in a core as for now, thereby 1 << core_offset should also be used instand of "cs->nr_threads" in encode_cache_cpuid4() for CPUID.04H.02H:EAX[bits 25:14]. 3. Similarly, the value for CPUID.04H:EAX[bits 31:26] should also be replaced by the offsets upper SMT level in APIC ID. And since [1] and [2] are good enough to make cache_into_passthrough work well, its "pow2ceil()" uses are enough so that they're no need to be replaced by APIC ID offset way. [1]: efb3934 (x86: cpu: make sure number of addressable IDs for processor c= ores meets the spec) [2]: d7caf13 (x86: cpu: fixup number of addressable IDs for logical process= ors sharing cache) [3]: d65af28 (i386: Update new x86_apicid parsing rules with die_offset sup= port) Fixes: 7e3482f (i386: Helpers to encode cache information consistently) Suggested-by: Robert Hoo Signed-off-by: Zhao Liu --- target/i386/cpu.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 29afec12c281..7833505092d8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5212,7 +5212,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, { X86CPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - uint32_t die_offset; uint32_t limit; uint32_t signature[3]; X86CPUTopoInfo topo_info; @@ -5308,27 +5307,38 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, *eax =3D *ebx =3D *ecx =3D *edx =3D 0; } else { *eax =3D 0; + int addressable_cores_offset =3D apicid_pkg_offset(&topo_info)= - + apicid_core_offset(&topo_info); + int core_offset, die_offset; + switch (count) { case 0: /* L1 dcache info */ + core_offset =3D apicid_core_offset(&topo_info); encode_cache_cpuid4(env->cache_info_cpuid4.l1d_cache, - 1, cs->nr_cores, + (1 << core_offset), + (1 << addressable_cores_offset), eax, ebx, ecx, edx); break; case 1: /* L1 icache info */ + core_offset =3D apicid_core_offset(&topo_info); encode_cache_cpuid4(env->cache_info_cpuid4.l1i_cache, - 1, cs->nr_cores, + (1 << core_offset), + (1 << addressable_cores_offset), eax, ebx, ecx, edx); break; case 2: /* L2 cache info */ + core_offset =3D apicid_core_offset(&topo_info); encode_cache_cpuid4(env->cache_info_cpuid4.l2_cache, - cs->nr_threads, cs->nr_cores, + (1 << core_offset), + (1 << addressable_cores_offset), eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ die_offset =3D apicid_die_offset(&topo_info); if (cpu->enable_l3_cache) { encode_cache_cpuid4(env->cache_info_cpuid4.l3_cache, - (1 << die_offset), cs->nr_cores, + (1 << die_offset), + (1 << addressable_cores_offset), eax, ebx, ecx, edx); break; } --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280588; cv=none; d=zohomail.com; s=zohoarc; b=XVQxymvM+B/HtqVDp+f1Hij5ySkKj1w47Z+cLpNfuxD9gm2h/cJ2td8Da4oR5CkRY/doKl9rbn6vas/6C/eB0Xcy+juqNQIo2BDYQRlxETchfLARlYJFF02WPEIeVFfmdJgw/D+ZaPTmA4gs+H7v/jt9XFNGfRLoWifg5Qy03+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280588; h=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=yE9LxB8Gd766LKE14ItI4CvpjZXkHqmYkNujYZ6Pll4=; b=PyXCJ1uD0iFQvZzkV1yMVlnx3Erm8bTLUDNcMjWo6F7bqkFFsYyCkbFwh6I8AK8gLFdZxk6PQXrgRTQeDRwQ4JhFCa7bloLKL5yNcXBIJc5Ao4GbqKOvXdJ0rj3DDbs3+5Q/6s7SQGQX6vHwco5WL5JZ9oQHrMyRWv4zU//QLDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280588424763.9895430592801; Mon, 13 Feb 2023 01:29:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9B-0005Iw-PS; Mon, 13 Feb 2023 04:29:17 -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 1pRV9A-0005IZ-4k for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:16 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV98-0006LA-Da for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:15 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:12 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:08 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280554; x=1707816554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f72Lhnb1qreMuYyQjvZLmXZyFqFdzu6WmuXvtAAc5tw=; b=mHcZ7CVEAC7jWZIYJ2hLgYXw//Q6cvhSFYWKbNU8n7LsGjVbUX/VfOrJ /WPXEOPUnumPGu/8N+FoFEyipxOJLR8nc2bMTq/Hi7cP0shUvaGhSTfUn vEzqtyMcRdGygEWR8TejP8Rb6OR9Nb6hU2gHiyra7oHsqt51zt9sXcmvL yvegfYTA2uN24e2XzqdwihxUeQ9D/KsGSYSR4rQLKRQ8A/90kI4FiSoep iX99kAaU4PkeMhiFE/7V6x18oOKREGQZgCBkta+qwyI8s6DNyK7PADW0p KUNMwerSIFcbi1Z/mDABjV5mrBW/ROX7zB3gSQGlNwozPSZ1cVcAR1evw g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875597" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875597" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659908" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659908" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 05/18] i386/cpu: Consolidate the use of topo_info in cpu_x86_cpuid() Date: Mon, 13 Feb 2023 17:36:12 +0800 Message-Id: <20230213093625.158170-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280591089100006 Content-Type: text/plain; charset="utf-8" From: Zhao Liu In cpu_x86_cpuid(), there are many variables in representing the cpu topology, e.g., topo_info, cs->nr_cores/cs->nr_threads. Since the names of cs->nr_cores/cs->nr_threads does not accurately represent its meaning, the use of cs->nr_cores/cs->nr_threads is prone to confusion and mistakes. And the structure X86CPUTopoInfo names its memebers clearly, thus the variable "topo_info" should be preferred. Suggested-by: Robert Hoo Signed-off-by: Zhao Liu --- target/i386/cpu.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7833505092d8..4cda84eb96f1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5215,11 +5215,15 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, uint32_t limit; uint32_t signature[3]; X86CPUTopoInfo topo_info; + uint32_t cpus_per_pkg; =20 topo_info.dies_per_pkg =3D env->nr_dies; topo_info.cores_per_die =3D cs->nr_cores / env->nr_dies; topo_info.threads_per_core =3D cs->nr_threads; =20 + cpus_per_pkg =3D topo_info.dies_per_pkg * topo_info.cores_per_die * + topo_info.threads_per_core; + /* Calculate & apply limits for different index ranges */ if (index >=3D 0xC0000000) { limit =3D env->cpuid_xlevel2; @@ -5255,8 +5259,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *ecx |=3D CPUID_EXT_OSXSAVE; } *edx =3D env->features[FEAT_1_EDX]; - if (cs->nr_cores * cs->nr_threads > 1) { - *ebx |=3D (cs->nr_cores * cs->nr_threads) << 16; + if (cpus_per_pkg > 1) { + *ebx |=3D cpus_per_pkg << 16; *edx |=3D CPUID_HT; } if (!cpu->enable_pmu) { @@ -5293,10 +5297,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, */ if (*eax & 31) { int host_vcpus_per_cache =3D 1 + ((*eax & 0x3FFC000) >> 14= ); - int vcpus_per_socket =3D cs->nr_cores * cs->nr_threads; - if (cs->nr_cores > 1) { + int vcpus_per_socket =3D cpus_per_pkg; + int cores_per_socket =3D topo_info.cores_per_die * + topo_info.dies_per_pkg; + if (cores_per_socket > 1) { *eax &=3D ~0xFC000000; - *eax |=3D (pow2ceil(cs->nr_cores) - 1) << 26; + *eax |=3D (pow2ceil(cores_per_socket) - 1) << 26; } if (host_vcpus_per_cache > vcpus_per_socket) { *eax &=3D ~0x3FFC000; @@ -5436,12 +5442,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, switch (count) { case 0: *eax =3D apicid_core_offset(&topo_info); - *ebx =3D cs->nr_threads; + *ebx =3D topo_info.threads_per_core; *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: *eax =3D apicid_pkg_offset(&topo_info); - *ebx =3D cs->nr_cores * cs->nr_threads; + *ebx =3D cpus_per_pkg; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; default: @@ -5472,7 +5478,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, switch (count) { case 0: *eax =3D apicid_core_offset(&topo_info); - *ebx =3D cs->nr_threads; + *ebx =3D topo_info.threads_per_core; *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: @@ -5482,7 +5488,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, break; case 2: *eax =3D apicid_pkg_offset(&topo_info); - *ebx =3D cs->nr_cores * cs->nr_threads; + *ebx =3D cpus_per_pkg; *ecx |=3D CPUID_TOPOLOGY_LEVEL_DIE; break; default: @@ -5707,7 +5713,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, * discards multiple thread information if it is set. * So don't set it here for Intel to make Linux guests happy. */ - if (cs->nr_cores * cs->nr_threads > 1) { + if (cpus_per_pkg > 1) { if (env->cpuid_vendor1 !=3D CPUID_VENDOR_INTEL_1 || env->cpuid_vendor2 !=3D CPUID_VENDOR_INTEL_2 || env->cpuid_vendor3 !=3D CPUID_VENDOR_INTEL_3) { @@ -5769,7 +5775,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *eax |=3D (cpu_x86_virtual_addr_width(env) << 8); } *ebx =3D env->features[FEAT_8000_0008_EBX]; - if (cs->nr_cores * cs->nr_threads > 1) { + if (cpus_per_pkg > 1) { /* * Bits 15:12 is "The number of bits in the initial * Core::X86::Apic::ApicId[ApicId] value that indicate @@ -5777,7 +5783,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, * Bits 7:0 is "The number of threads in the package is NC+1" */ *ecx =3D (apicid_pkg_offset(&topo_info) << 12) | - ((cs->nr_cores * cs->nr_threads) - 1); + (cpus_per_pkg - 1); } else { *ecx =3D 0; } --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280589; cv=none; d=zohomail.com; s=zohoarc; b=RIDE3fUbbB+TrtyLXI0ZFTKrmOoMC6d76WX8EBL14+m8FsuJTK4/tJ01ISshUIJJaJiAkISRSQ0XofjaIcy9H6QLRjfi9t511kHcsFstI7Xq7Sotg1Ovw3pRx+0F7X2rz1279DO989AmCRX6gP5ftboGxNg9vd0VX34DRVecqas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280589; h=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=QKbTFFV0k77kll5Amcv7qlSgJ72yoKeWoUJJOliLFo0=; b=HfDBaxw6XlCcoNBMlmi+rNoNm/4Vwo5JlIpOm5Pz7IfrZlM2UcDAuqvzMZs0UWjy5HxTpKZJ3Oi3BYXspN/BwvMy5N7gvpAcRF4ys4hP/Xuv8vya32wGujK4lxpn4EZ4aJRFAcfOfaoLcpYSve5ub8zx3/uyBO8+NQPSpjfdJe8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280589165347.7335193221396; Mon, 13 Feb 2023 01:29:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9I-0005Ju-W0; Mon, 13 Feb 2023 04:29:25 -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 1pRV9H-0005JH-2H for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:23 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9C-0006LA-IR for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:22 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:17 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:13 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280558; x=1707816558; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vbaVTuT6+7W70CdkNUx48hHLCJIcAqUo3+IdSQy6wfc=; b=Y6zQdIQMbENq28ANTWw2zzlsLI3y97JIeeQ4wNXJ7eOtmqaJrKw5BgtT IMBePg5Quzc9JoevIFCkRRBVPQ/3i246nG0Rwpk56U9QKE0OEzyx32rAA y+vLYrvkE6Z5TCDvhDipszlXHF/4iaDMGIDF3FFq7mwU0+mwaYcIppFG7 4X+USBl5XCZDACsfre6daZeef3W+APFz9Xjq2JDjRSYDJc4/SnFadFf8P FdNd12Vv6Os6pgvUE2UE36dGMaThmN/MFA//JvXhplA4MmXXp8+uEe74A 6OQv1nA5AXjHiD5KC7mAaWYbtbEdpyvbwxa/yzA7XY+FW+CNSyNWmhAoY g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875633" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875633" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659950" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659950" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 06/18] i386: Introduce module-level cpu topology to CPUX86State Date: Mon, 13 Feb 2023 17:36:13 +0800 Message-Id: <20230213093625.158170-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280591080100005 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding smp command has the "clusters" parameter but x86 hasn't supported that level. Though "clusters" was introduced to help define L2 cache topology [1], using cluster to define x86's L2 cache topology will cause the compatibility problem: Currently, x86 defaults that the L2 cache is shared in one core, which actually implies a default setting "cores per L2 cache is 1" and therefore implicitly defaults to having as many L2 caches as cores. For example (i386 PC machine): -smp 16,sockets=3D2,dies=3D2,cores=3D2,threads=3D2,maxcpus=3D16 (*) Considering the topology of the L2 cache, this (*) implicitly means "1 core per L2 cache" and "2 L2 caches per die". If we use cluster to configure L2 cache topology with the new default setting "clusters per L2 cache is 1", the above semantics will change to "2 cores per cluster" and "1 cluster per L2 cache", that is, "2 cores per L2 cache". So the same command (*) will cause changes in the L2 cache topology, further affecting the performance of the virtual machine. Therefore, x86 should only treat cluster as a cpu topology level and avoid using it to change L2 cache by default for compatibility. "cluster" in smp is the CPU topology level which is between "core" and die. For x86, the "cluster" in smp is corresponding to the module level [2], which is above the core level. So use the "module" other than "cluster" in i386 code. And please note that x86 already has a cpu topology level also named "cluster" [2], this level is at the upper level of the package. Here, the cluster in x86 cpu topology is completely different from the "clusters" as the smp parameter. After the module level is introduced, the cluster as the smp parameter will actually refer to the module level of x86. [1]: 0d87178 (hw/core/machine: Introduce CPU cluster topology support) [2]: SDM, vol.3, ch.9, 9.9.1 Hierarchical Mapping of Shared Resources. Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu --- hw/i386/x86.c | 1 + target/i386/cpu.c | 1 + target/i386/cpu.h | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index eaff4227bd68..ae1bb562d6e2 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -306,6 +306,7 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, init_topo_info(&topo_info, x86ms); =20 env->nr_dies =3D ms->smp.dies; + env->nr_modules =3D ms->smp.clusters; =20 /* * If APIC ID is not set, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4cda84eb96f1..61ec9a7499b8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6781,6 +6781,7 @@ static void x86_cpu_initfn(Object *obj) CPUX86State *env =3D &cpu->env; =20 env->nr_dies =3D 1; + env->nr_modules =3D 1; cpu_set_cpustate_pointers(cpu); =20 object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo", diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d4bc19577a21..f3afea765982 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1810,7 +1810,13 @@ typedef struct CPUArchState { =20 TPRAccess tpr_access_type; =20 + /* Number of dies per package. */ unsigned nr_dies; + /* + * Number of modules per die. Module level in x86 cpu topology is + * corresponding to smp.clusters. + */ + unsigned nr_modules; } CPUX86State; =20 struct kvm_msrs; --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280958; cv=none; d=zohomail.com; s=zohoarc; b=hoBqmS5vzsyf80hkTW0gvcCmYCVA6C1xMQNFvHwcs60nr6gJ16kuCDdtjl4KnJMmsKprvACAaAqa+WNeOffabyTPkJ7Ied+TSI6mkAj1PU8PQQaPtvgkzwGDrqjhUL0UDfhHUXZIky0keOJKv9yPLGZHTfvfTy34yNOuv3jRUAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280958; h=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=kvhOPcPQRf1eC4jYD2QxDXnTPXc1k8JkCNa/cGJLPNM=; b=KZfJAI2MRlqUFc6dVuj0luPCZIyPnCoxPyErB/5XQEbA6wBs6dywCjxdKBCk0wmK1HCl28rHmKCl5SnT1KDvYziKxYTTl+uD9voHAPiSE2A+affZ/l5Neu0fnce2AcxTO8FIAGcP9Xb5xnai/hCwdoWM1579YyrpLxNN7tXlZD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280958635582.3859702198808; Mon, 13 Feb 2023 01:35:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9Q-0005Wa-Fq; Mon, 13 Feb 2023 04:29:32 -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 1pRV9M-0005SG-Ga for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:30 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9H-0006LA-Cf for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:28 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:22 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:17 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280563; x=1707816563; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fLBBrGgm5EIStV8jRZod2hALtXG4qDm3URUC0yBqlKw=; b=QPMciZj7dlFoh4jbJyDtkuvxz6Vv6N/nkg1Hh4jbtQqK/JjOqhSYtR5s ynkH/Efkt8PFQ5g5ZJI9W6x2te1WyVEqvyhQjyKUdmbi2KsL575E+DaT0 2EMDtHXjZlAt/dz236jK4JsV8ZqRrloHA7jqY+YUf7CYzrgJ/f1igC2w4 VDlOhMK+0ceh9KgmhVv67TAYlFXHMOy6LkH5Ze3FmQEeEOKkg2+EGBjUm q0lUZgftgFABXJLJC2rLvXw9O5NgDdvt2DUWTOzwrdW3GskxbMDOrfsxh AwhC/wPJaU5WDYsNIWVch0zHmLPhUlbhe36qm2wTatZKzgSVNWUbjUCWW Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875667" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875667" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792659998" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792659998" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 07/18] i386: Support modules_per_die in X86CPUTopoInfo Date: Mon, 13 Feb 2023 17:36:14 +0800 Message-Id: <20230213093625.158170-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280959993100001 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding Support module level in i386 cpu topology structure "X86CPUTopoInfo". Before updating APIC ID parsing rule with module level, the apicid_core_width() temporarily combines the core and module levels together. At present, we don't expose module level in CPUID.1FH because currently linux (v6.2-rc6) doesn't support module level. And exposing module and die levels at the same time in CPUID.1FH will cause linux to calculate the wrong die_id. The module level should be exposed until the real machine has the module level in CPUID.1FH. In addition, update topology structure in test-x86-apicid.c. Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu --- hw/i386/x86.c | 3 ++- include/hw/i386/topology.h | 13 ++++++++--- target/i386/cpu.c | 17 ++++++++------ tests/unit/test-x86-apicid.c | 45 +++++++++++++++++++----------------- 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index ae1bb562d6e2..1c069ff56ae7 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -71,7 +71,8 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info, MachineState *ms =3D MACHINE(x86ms); =20 topo_info->dies_per_pkg =3D ms->smp.dies; - topo_info->cores_per_die =3D ms->smp.cores; + topo_info->modules_per_die =3D ms->smp.clusters; + topo_info->cores_per_module =3D ms->smp.cores; topo_info->threads_per_core =3D ms->smp.threads; } =20 diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 81573f6cfde0..bbb00dc4aad8 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -54,7 +54,8 @@ typedef struct X86CPUTopoIDs { =20 typedef struct X86CPUTopoInfo { unsigned dies_per_pkg; - unsigned cores_per_die; + unsigned modules_per_die; + unsigned cores_per_module; unsigned threads_per_core; } X86CPUTopoInfo; =20 @@ -78,7 +79,12 @@ static inline unsigned apicid_smt_width(X86CPUTopoInfo *= topo_info) */ static inline unsigned apicid_core_width(X86CPUTopoInfo *topo_info) { - return apicid_bitwidth_for_count(topo_info->cores_per_die); + /* + * TODO: Will separate module info from core_width when update + * APIC ID with module level. + */ + return apicid_bitwidth_for_count(topo_info->cores_per_module * + topo_info->modules_per_die); } =20 /* Bit width of the Die_ID field */ @@ -128,7 +134,8 @@ static inline void x86_topo_ids_from_idx(X86CPUTopoInfo= *topo_info, X86CPUTopoIDs *topo_ids) { unsigned nr_dies =3D topo_info->dies_per_pkg; - unsigned nr_cores =3D topo_info->cores_per_die; + unsigned nr_cores =3D topo_info->cores_per_module * + topo_info->modules_per_die; unsigned nr_threads =3D topo_info->threads_per_core; =20 topo_ids->pkg_id =3D cpu_index / (nr_dies * nr_cores * nr_threads); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 61ec9a7499b8..6f3d114c7d12 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -336,7 +336,9 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *ca= che, =20 /* L3 is shared among multiple cores */ if (cache->level =3D=3D 3) { - l3_threads =3D topo_info->cores_per_die * topo_info->threads_per_c= ore; + l3_threads =3D topo_info->modules_per_die * + topo_info->cores_per_module * + topo_info->threads_per_core; *eax |=3D (l3_threads - 1) << 14; } else { *eax |=3D ((topo_info->threads_per_core - 1) << 14); @@ -5218,11 +5220,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, uint32_t cpus_per_pkg; =20 topo_info.dies_per_pkg =3D env->nr_dies; - topo_info.cores_per_die =3D cs->nr_cores / env->nr_dies; + topo_info.modules_per_die =3D env->nr_modules; + topo_info.cores_per_module =3D cs->nr_cores / env->nr_dies / env->nr_m= odules; topo_info.threads_per_core =3D cs->nr_threads; =20 - cpus_per_pkg =3D topo_info.dies_per_pkg * topo_info.cores_per_die * - topo_info.threads_per_core; + cpus_per_pkg =3D topo_info.dies_per_pkg * topo_info.modules_per_die * + topo_info.cores_per_module * topo_info.threads_per_core; =20 /* Calculate & apply limits for different index ranges */ if (index >=3D 0xC0000000) { @@ -5298,8 +5301,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, if (*eax & 31) { int host_vcpus_per_cache =3D 1 + ((*eax & 0x3FFC000) >> 14= ); int vcpus_per_socket =3D cpus_per_pkg; - int cores_per_socket =3D topo_info.cores_per_die * - topo_info.dies_per_pkg; + int cores_per_socket =3D cpus_per_pkg / + topo_info.threads_per_core; if (cores_per_socket > 1) { *eax &=3D ~0xFC000000; *eax |=3D (pow2ceil(cores_per_socket) - 1) << 26; @@ -5483,7 +5486,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, break; case 1: *eax =3D apicid_die_offset(&topo_info); - *ebx =3D topo_info.cores_per_die * topo_info.threads_per_core; + *ebx =3D cpus_per_pkg / topo_info.dies_per_pkg; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: diff --git a/tests/unit/test-x86-apicid.c b/tests/unit/test-x86-apicid.c index 2b104f86d7c2..f21b8a5d95c2 100644 --- a/tests/unit/test-x86-apicid.c +++ b/tests/unit/test-x86-apicid.c @@ -30,13 +30,16 @@ static void test_topo_bits(void) { X86CPUTopoInfo topo_info =3D {0}; =20 - /* simple tests for 1 thread per core, 1 core per die, 1 die per packa= ge */ - topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; + /* + * simple tests for 1 thread per core, 1 core per module, + * 1 module per die, 1 die per package + */ + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 1}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 0); g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 0); g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); =20 - topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 1}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), =3D=3D, 1); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), =3D=3D, 2); @@ -45,39 +48,39 @@ static void test_topo_bits(void) =20 /* Test field width calculation for multiple values */ - topo_info =3D (X86CPUTopoInfo) {1, 1, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 2}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 1); - topo_info =3D (X86CPUTopoInfo) {1, 1, 3}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); - topo_info =3D (X86CPUTopoInfo) {1, 1, 4}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 4}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); =20 - topo_info =3D (X86CPUTopoInfo) {1, 1, 14}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 14}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); - topo_info =3D (X86CPUTopoInfo) {1, 1, 15}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 15}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); - topo_info =3D (X86CPUTopoInfo) {1, 1, 16}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 16}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); - topo_info =3D (X86CPUTopoInfo) {1, 1, 17}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 17}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 5); =20 =20 - topo_info =3D (X86CPUTopoInfo) {1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 30, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); - topo_info =3D (X86CPUTopoInfo) {1, 31, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 31, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); - topo_info =3D (X86CPUTopoInfo) {1, 32, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 32, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); - topo_info =3D (X86CPUTopoInfo) {1, 33, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 33, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 6); =20 - topo_info =3D (X86CPUTopoInfo) {1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); - topo_info =3D (X86CPUTopoInfo) {2, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {2, 1, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 1); - topo_info =3D (X86CPUTopoInfo) {3, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {3, 1, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); - topo_info =3D (X86CPUTopoInfo) {4, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {4, 1, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); =20 /* build a weird topology and see if IDs are calculated correctly @@ -85,18 +88,18 @@ static void test_topo_bits(void) =20 /* This will use 2 bits for thread ID and 3 bits for core ID */ - topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 6, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); g_assert_cmpuint(apicid_core_offset(&topo_info), =3D=3D, 2); g_assert_cmpuint(apicid_die_offset(&topo_info), =3D=3D, 5); g_assert_cmpuint(apicid_pkg_offset(&topo_info), =3D=3D, 5); =20 - topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), =3D=3D, 1); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), =3D=3D, 2); =20 - topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + topo_info =3D (X86CPUTopoInfo) {1, 1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 0), =3D= =3D, (1 << 2) | 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 1), =3D= =3D, --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280874; cv=none; d=zohomail.com; s=zohoarc; b=YqB4nc8vIm/3Z/FrNRJxMXmGlCgs0XRyWaK8cL2a8XHHOFQHOuKU/AEMAANs3mphiXIQliyoubJqN38uz+83MzQEMfayxHOEgeo1d52/H1GQ1Ff9Jy/zG5TsDMhtCUjSL0ITJJ0q3KGJVjwV80H4/4oBBBGiVMH8pGY4G1HjpCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280874; h=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=z5IkmdjIZva9ki6LW7iaM8Sk6FOcGtlHRvQSiGPrenw=; b=WJTEN2XMoYZwlz16clpnVjcXgeM2TWwzjR/9Yc1ItQkoSKmR1cJRK0z2GgLfnY21b9VBpgRuVIygnEYyP9Xs0GHBNjXKKZYgM1Ystc2rlw7nroI7mV40Sae8ftL7n8cKTBPbAPQidtBN+47zkVbajUB3nDMXClnlrsCV/5avBpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280874171657.1352484761982; Mon, 13 Feb 2023 01:34:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9U-0005av-97; Mon, 13 Feb 2023 04:29: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 1pRV9R-0005Za-BQ for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:33 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9M-0006O1-LT for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:33 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:27 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:22 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280568; x=1707816568; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8TDHGfxGbBvj9UMegD4/gsrU0bcKim2fY20CZMK0XdE=; b=SD4CNPzqeErN6bqAJF5sVgSCr+b6fAaT1ufFXL5SP87RpjuHLM7RxBil JL+c3lYoae1o8O8WkW9HbzOhQxBHa6idoTxPf6gvDoW2Ft46n5SggYOb5 PllLDKux9ZbJgj5OKvKy4DraAIAbk/2RD7tC+TaXY0isvZW9beGvyU1VQ mlCtAdur9SWVp6wRU+WgS4TG8P55CnlfJIwwNdYtRIQFyn5LTemvkq4XE Ba7FAERz6hxU//7etR6k6zgHLx5O6H1jUC9upJa4k93RTU7kdJLLTfTj5 W2dPiWmlmezKaPzNTFdyebu7rMUCkRYHoQNRELZENiZ72vt+9D2CaMyom w==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875689" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875689" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660029" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660029" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 08/18] i386: Support module_id in X86CPUTopoIDs Date: Mon, 13 Feb 2023 17:36:15 +0800 Message-Id: <20230213093625.158170-9-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280874521100001 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding Add module_id member in X86CPUTopoIDs. module_id can be parsed from APIC ID, so before updating the parsing rule of APIC ID, temporarily set the module_id generated in this way to 0. module_id can be also generated from cpu topology, and before i386 supports "clusters" in smp, the default "clusters per die" is only 1, thus the module_id generated in this way is 0, so that it will not conflict with the module_id generated by APIC ID. Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu --- hw/i386/x86.c | 17 +++++++++++++++++ include/hw/i386/topology.h | 24 ++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 1c069ff56ae7..b90c6584930a 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -362,6 +362,14 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.die_id =3D cpu->die_id; topo_ids.core_id =3D cpu->core_id; topo_ids.smt_id =3D cpu->thread_id; + + /* + * TODO: This is the temporary initialization for topo_ids.module_= id to + * avoid "maybe-uninitialized" compilation errors. Will remove when + * X86CPU supports cluster_id. + */ + topo_ids.module_id =3D 0; + cpu->apic_id =3D x86_apicid_from_topo_ids(&topo_info, &topo_ids); } =20 @@ -370,6 +378,11 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, MachineState *ms =3D MACHINE(x86ms); =20 x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); + + /* + * TODO: Before APIC ID supports module level parsing, there's no = need + * to expose module_id info. + */ error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" " APIC ID %" PRIu32 ", valid index range 0:%d", @@ -495,6 +508,10 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(Machine= State *ms) ms->possible_cpus->cpus[i].props.has_die_id =3D true; ms->possible_cpus->cpus[i].props.die_id =3D topo_ids.die_id; } + if (ms->smp.clusters > 1) { + ms->possible_cpus->cpus[i].props.has_cluster_id =3D true; + ms->possible_cpus->cpus[i].props.cluster_id =3D topo_ids.modul= e_id; + } ms->possible_cpus->cpus[i].props.has_core_id =3D true; ms->possible_cpus->cpus[i].props.core_id =3D topo_ids.core_id; ms->possible_cpus->cpus[i].props.has_thread_id =3D true; diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index bbb00dc4aad8..b0174c18b7bd 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -48,6 +48,7 @@ typedef uint32_t apic_id_t; typedef struct X86CPUTopoIDs { unsigned pkg_id; unsigned die_id; + unsigned module_id; unsigned core_id; unsigned smt_id; } X86CPUTopoIDs; @@ -134,12 +135,21 @@ static inline void x86_topo_ids_from_idx(X86CPUTopoIn= fo *topo_info, X86CPUTopoIDs *topo_ids) { unsigned nr_dies =3D topo_info->dies_per_pkg; - unsigned nr_cores =3D topo_info->cores_per_module * - topo_info->modules_per_die; + unsigned nr_modules =3D topo_info->modules_per_die; + unsigned nr_cores =3D topo_info->cores_per_module; unsigned nr_threads =3D topo_info->threads_per_core; =20 - topo_ids->pkg_id =3D cpu_index / (nr_dies * nr_cores * nr_threads); - topo_ids->die_id =3D cpu_index / (nr_cores * nr_threads) % nr_dies; + /* + * Currently smp for i386 doesn't support "clusters", modules_per_die = is + * only 1. Therefore, the module_id generated from the module topology= will + * not conflict with the module_id generated according to the apicid. + */ + topo_ids->pkg_id =3D cpu_index / (nr_dies * nr_modules * + nr_cores * nr_threads); + topo_ids->die_id =3D cpu_index / (nr_modules * nr_cores * + nr_threads) % nr_dies; + topo_ids->module_id =3D cpu_index / (nr_cores * nr_threads) % + nr_modules; topo_ids->core_id =3D cpu_index / nr_threads % nr_cores; topo_ids->smt_id =3D cpu_index % nr_threads; } @@ -156,6 +166,12 @@ static inline void x86_topo_ids_from_apicid(apic_id_t = apicid, topo_ids->core_id =3D (apicid >> apicid_core_offset(topo_info)) & ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); + /* + * TODO: This is the temporary initialization for topo_ids.module_id to + * avoid "maybe-uninitialized" compilation errors. Will remove when AP= IC + * ID supports module level parsing. + */ + topo_ids->module_id =3D 0; topo_ids->die_id =3D (apicid >> apicid_die_offset(topo_info)) & ~(0xFFFFFFFFUL << apicid_die_width(topo_info)); --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280892; cv=none; d=zohomail.com; s=zohoarc; b=bhoa8xnHV7vH/D73usfu8U7wFT0hFQgBJVVDHOtLBQXu9QynMHL1QsR0eqr+XOzRmZ7weS61Ilrf5eC9tlIxJWmQRhcHsG8QDT0SvjBLFlq84R1SfcGIJn08f43Bq19kS/5OJUUuFxXnsa98pmOqw/QdMl2F0eUiQlHyg4IqD8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280892; 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=1HOHVBZvDdsy2DDxzbNKp2fJ7WVHZCErIYgP1DWDCVM=; b=evUhS8SWahpegitY/jGCEsag92OmqnMfBvKzi7UCdzC7BDBnxFkvS7ldtLakdZPxrwWJKUAaLhga4u5tP7mvpQzZm1S/V3cz9ROwi3dKBPedKbUw7It/u9Upz+2jSqu6s7EjldcrSK+k5bTs3ihzik87KR8AT90wQfw6P7/ohfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280892068124.77660990594029; Mon, 13 Feb 2023 01:34:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9X-0005fa-OR; Mon, 13 Feb 2023 04:29:39 -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 1pRV9V-0005f2-Vw for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:38 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9R-0006LA-FD for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:37 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:32 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280573; x=1707816573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xtknp8xKM3EUafI+IMYCkYLlc/7I5Ma96WMYzPwnDyU=; b=XVB4XuuhJhFYs7mt67M2CBsL0FutPTOX/omBAtvrfElSAyjecbwVo32V BtvNFQUxXu8F1aQV6hTBN2aVmYjIkTF/Gv3vKi4Uzj6IabXwfbzU54+7o SEJCrlhWEniP9C7lfqndC++aqW58MnXvFzHc+Cp0ven22QUUsSE/E+5nl CH8ajV1bMzwc/mL4O6kBwoBI5BghULz5BHuRzXrKOrEOPUqvH6jSQrHni rIoLNlxmGiYHBAIS/T8zgMoBSKqFz5iNvvBhQ/2GhEPTNSzd9Y93MwoKP 0kKkQACOFuTSNXQVyOCqMEKmB55schvGjT7cYRl3vc+HI5NtlBUtGs6v7 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875718" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875718" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660122" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660122" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 09/18] i386: Fix comment style in topology.h Date: Mon, 13 Feb 2023 17:36:16 +0800 Message-Id: <20230213093625.158170-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280892813100002 From: Zhao Liu For function comments in this file, keep the comment style consistent with other places. Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Yanan Wang --- include/hw/i386/topology.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index b0174c18b7bd..5de905dc00d3 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -24,7 +24,8 @@ #ifndef HW_I386_TOPOLOGY_H #define HW_I386_TOPOLOGY_H =20 -/* This file implements the APIC-ID-based CPU topology enumeration logic, +/* + * This file implements the APIC-ID-based CPU topology enumeration logic, * documented at the following document: * Intel=C2=AE 64 Architecture Processor Topology Enumeration * http://software.intel.com/en-us/articles/intel-64-architecture-proces= sor-topology-enumeration/ @@ -41,7 +42,8 @@ =20 #include "qemu/bitops.h" =20 -/* APIC IDs can be 32-bit, but beware: APIC IDs > 255 require x2APIC suppo= rt +/* + * APIC IDs can be 32-bit, but beware: APIC IDs > 255 require x2APIC suppo= rt */ typedef uint32_t apic_id_t; =20 @@ -60,8 +62,7 @@ typedef struct X86CPUTopoInfo { unsigned threads_per_core; } X86CPUTopoInfo; =20 -/* Return the bit width needed for 'count' IDs - */ +/* Return the bit width needed for 'count' IDs */ static unsigned apicid_bitwidth_for_count(unsigned count) { g_assert(count >=3D 1); @@ -69,15 +70,13 @@ static unsigned apicid_bitwidth_for_count(unsigned coun= t) return count ? 32 - clz32(count) : 0; } =20 -/* Bit width of the SMT_ID (thread ID) field on the APIC ID - */ +/* Bit width of the SMT_ID (thread ID) field on the APIC ID */ static inline unsigned apicid_smt_width(X86CPUTopoInfo *topo_info) { return apicid_bitwidth_for_count(topo_info->threads_per_core); } =20 -/* Bit width of the Core_ID field - */ +/* Bit width of the Core_ID field */ static inline unsigned apicid_core_width(X86CPUTopoInfo *topo_info) { /* @@ -94,8 +93,7 @@ static inline unsigned apicid_die_width(X86CPUTopoInfo *t= opo_info) return apicid_bitwidth_for_count(topo_info->dies_per_pkg); } =20 -/* Bit offset of the Core_ID field - */ +/* Bit offset of the Core_ID field */ static inline unsigned apicid_core_offset(X86CPUTopoInfo *topo_info) { return apicid_smt_width(topo_info); @@ -107,14 +105,14 @@ static inline unsigned apicid_die_offset(X86CPUTopoIn= fo *topo_info) return apicid_core_offset(topo_info) + apicid_core_width(topo_info); } =20 -/* Bit offset of the Pkg_ID (socket ID) field - */ +/* Bit offset of the Pkg_ID (socket ID) field */ static inline unsigned apicid_pkg_offset(X86CPUTopoInfo *topo_info) { return apicid_die_offset(topo_info) + apicid_die_width(topo_info); } =20 -/* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID +/* + * Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID * * The caller must make sure core_id < nr_cores and smt_id < nr_threads. */ @@ -127,7 +125,8 @@ static inline apic_id_t x86_apicid_from_topo_ids(X86CPU= TopoInfo *topo_info, topo_ids->smt_id; } =20 -/* Calculate thread/core/package IDs for a specific topology, +/* + * Calculate thread/core/package IDs for a specific topology, * based on (contiguous) CPU index */ static inline void x86_topo_ids_from_idx(X86CPUTopoInfo *topo_info, @@ -154,7 +153,8 @@ static inline void x86_topo_ids_from_idx(X86CPUTopoInfo= *topo_info, topo_ids->smt_id =3D cpu_index % nr_threads; } =20 -/* Calculate thread/core/package IDs for a specific topology, +/* + * Calculate thread/core/package IDs for a specific topology, * based on APIC ID */ static inline void x86_topo_ids_from_apicid(apic_id_t apicid, @@ -178,7 +178,8 @@ static inline void x86_topo_ids_from_apicid(apic_id_t a= picid, topo_ids->pkg_id =3D apicid >> apicid_pkg_offset(topo_info); } =20 -/* Make APIC ID for the CPU 'cpu_index' +/* + * Make APIC ID for the CPU 'cpu_index' * * 'cpu_index' is a sequential, contiguous ID for the CPU. */ --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280670; cv=none; d=zohomail.com; s=zohoarc; b=QKMXZiVAL4+N+yO23bFlJcoivmFGRwP+NtF+cEW2sMP5PQiWxn/Rmb6WGOBGQc5ITXOkWnm5p9hGeKszs0ZDz0gvVTqMSMkw5wwfokQ2Q3QQMDQjKl+eYohYgXzdnTbyG46PpZt9gELVSFE44HLWI5a3u0ZQ6uKt+JARRIbgGSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280670; h=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=qqhg1saFBuCnohoDJWsqy5uI3D2Ksk4mcy71MMT+XUI=; b=LHH3w0ljLrm9rwcB+dQq8Q+VvN8sUDD0ztaYWHMm2442TrQkStyo65sBJrSzp79L+XTAXqFi7GrzQ7a3SKLnDPCjikyQk0/z4XOyo9xAHP4qajn+nwY4g1Nf5muFxobfnh7NELnG1xtHYL+jBF/h5+2nM6cnIIuIOOwXzz1zcxg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280670187904.7514207871799; Mon, 13 Feb 2023 01:31:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9Z-0005fy-Sv; Mon, 13 Feb 2023 04:29:41 -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 1pRV9Y-0005fp-TF for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:40 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9X-0006TH-9s for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:40 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:37 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:32 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280579; x=1707816579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZCPVTglqTWHh9tmwzxjZ8ECKho/SBNd5BkeIKrK8rCs=; b=IYc3v/q1fKaD4zjaedTD9R0RmzfDBm3nVH8u1Mm6MqQZUct5Jm4bE50I am7uhrKN57m7fVb5APjRB3ZnerUdf/9Qikq43XKgJA5cCGW9biU5qum+5 q/wU8s6L71BpC1wljRY4Pir7KbLqZbxm2RaMuPA5BOb3YIdFG+VRY3nO6 UuXSK6459LwRfSOLD/WLaBJjlBt7lt/6kFmVfxK5oehzwE85jKsZ3kbfP Ap/VnC7jyFCMFTeRGCI8eZ1m0tpCqyrahcM8byzllfwodW1FUImBeUH6y AakZpdjg3qOfhLO8hcLMsri85tb9f+urIucF9y3ylra8oZKrz8t17DJXk A==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875741" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875741" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660203" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660203" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 10/18] i386: Update APIC ID parsing rule to support module level Date: Mon, 13 Feb 2023 17:36:17 +0800 Message-Id: <20230213093625.158170-11-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280671090100001 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding Add the module level parsing support for APIC ID. With this support, now the conversion between X86CPUTopoIDs, X86CPUTopoInfo and APIC ID is completed. Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu --- hw/i386/x86.c | 19 ++++++++----------- include/hw/i386/topology.h | 36 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index b90c6584930a..2a9d080a8e7a 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -311,11 +311,11 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, =20 /* * If APIC ID is not set, - * set it based on socket/die/core/thread properties. + * set it based on socket/die/cluster/core/thread properties. */ if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { - int max_socket =3D (ms->smp.max_cpus - 1) / - smp_threads / smp_cores / ms->smp.dies; + int max_socket =3D (ms->smp.max_cpus - 1) / smp_threads / smp_core= s / + ms->smp.clusters / ms->smp.dies; =20 /* * die-id was optional in QEMU 4.0 and older, so keep it optional @@ -379,15 +379,12 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, =20 x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); =20 - /* - * TODO: Before APIC ID supports module level parsing, there's no = need - * to expose module_id info. - */ error_setg(errp, - "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" - " APIC ID %" PRIu32 ", valid index range 0:%d", - topo_ids.pkg_id, topo_ids.die_id, topo_ids.core_id, topo_ids.s= mt_id, - cpu->apic_id, ms->possible_cpus->len - 1); + "Invalid CPU [socket: %u, die: %u, module: %u, core: %u, threa= d: %u]" + " with APIC ID %" PRIu32 ", valid index range 0:%d", + topo_ids.pkg_id, topo_ids.die_id, topo_ids.module_id, + topo_ids.core_id, topo_ids.smt_id, cpu->apic_id, + ms->possible_cpus->len - 1); return; } =20 diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 5de905dc00d3..3cec97b377f2 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -79,12 +79,13 @@ static inline unsigned apicid_smt_width(X86CPUTopoInfo = *topo_info) /* Bit width of the Core_ID field */ static inline unsigned apicid_core_width(X86CPUTopoInfo *topo_info) { - /* - * TODO: Will separate module info from core_width when update - * APIC ID with module level. - */ - return apicid_bitwidth_for_count(topo_info->cores_per_module * - topo_info->modules_per_die); + return apicid_bitwidth_for_count(topo_info->cores_per_module); +} + +/* Bit width of the Module_ID (cluster ID) field */ +static inline unsigned apicid_module_width(X86CPUTopoInfo *topo_info) +{ + return apicid_bitwidth_for_count(topo_info->modules_per_die); } =20 /* Bit width of the Die_ID field */ @@ -99,10 +100,16 @@ static inline unsigned apicid_core_offset(X86CPUTopoIn= fo *topo_info) return apicid_smt_width(topo_info); } =20 +/* Bit offset of the Module_ID (cluster ID) field */ +static inline unsigned apicid_module_offset(X86CPUTopoInfo *topo_info) +{ + return apicid_core_offset(topo_info) + apicid_core_width(topo_info); +} + /* Bit offset of the Die_ID field */ static inline unsigned apicid_die_offset(X86CPUTopoInfo *topo_info) { - return apicid_core_offset(topo_info) + apicid_core_width(topo_info); + return apicid_module_offset(topo_info) + apicid_module_width(topo_info= ); } =20 /* Bit offset of the Pkg_ID (socket ID) field */ @@ -121,6 +128,7 @@ static inline apic_id_t x86_apicid_from_topo_ids(X86CPU= TopoInfo *topo_info, { return (topo_ids->pkg_id << apicid_pkg_offset(topo_info)) | (topo_ids->die_id << apicid_die_offset(topo_info)) | + (topo_ids->module_id << apicid_module_offset(topo_info)) | (topo_ids->core_id << apicid_core_offset(topo_info)) | topo_ids->smt_id; } @@ -138,11 +146,6 @@ static inline void x86_topo_ids_from_idx(X86CPUTopoInf= o *topo_info, unsigned nr_cores =3D topo_info->cores_per_module; unsigned nr_threads =3D topo_info->threads_per_core; =20 - /* - * Currently smp for i386 doesn't support "clusters", modules_per_die = is - * only 1. Therefore, the module_id generated from the module topology= will - * not conflict with the module_id generated according to the apicid. - */ topo_ids->pkg_id =3D cpu_index / (nr_dies * nr_modules * nr_cores * nr_threads); topo_ids->die_id =3D cpu_index / (nr_modules * nr_cores * @@ -166,12 +169,9 @@ static inline void x86_topo_ids_from_apicid(apic_id_t = apicid, topo_ids->core_id =3D (apicid >> apicid_core_offset(topo_info)) & ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); - /* - * TODO: This is the temporary initialization for topo_ids.module_id to - * avoid "maybe-uninitialized" compilation errors. Will remove when AP= IC - * ID supports module level parsing. - */ - topo_ids->module_id =3D 0; + topo_ids->module_id =3D + (apicid >> apicid_module_offset(topo_info)) & + ~(0xFFFFFFFFUL << apicid_module_width(topo_info)); topo_ids->die_id =3D (apicid >> apicid_die_offset(topo_info)) & ~(0xFFFFFFFFUL << apicid_die_width(topo_info)); --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280607; cv=none; d=zohomail.com; s=zohoarc; b=BPaNWTDYdqIGMsZ7rRK6iRlOBMCvG6Q0fOaWdH7FQKhNrH4IZgxmO1+eIBl5MKbSlr+/k1ghc+JWsbShacAenyB6qOTcP1NpiFEP4dtXfucpasBt19vXRJVZPqAAajmOyYrL25Uo99sHlPh7lBTF8IPmE5JVXa8eXXvvTcI6g4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280607; h=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=dSSbKkmIR6PbajwvX4nboPUy85M9RpQLeMjjRG2mq9U=; b=GJsVNnbYvF7XSdtncfrfizQBjMTSG9pz42xXUO6qyO9XY48HOpR0CKZxs6FWm47ULf8948VDXCzFMaGZtsdGzFN1o66teHbGXDMZhfbP2N9/AlpMLo34Jr/04zxn/RF8NFUJrKb11luDCXDw2Kku8vyQdO9SCPk6Mc2Vksatorg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280607766903.6821341276784; Mon, 13 Feb 2023 01:30:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9h-0005vW-4S; Mon, 13 Feb 2023 04:29:49 -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 1pRV9f-0005qL-8x for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:47 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9a-0006TH-MO for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:47 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:41 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280582; x=1707816582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O9kWWFKqwj/RHJBotzkV0dcEumygn4twXu4ub9knsEQ=; b=MY9wZ5Dx7eLtBdpoQ0VcY/POH6bmwVHEkGXUl5K8lbXfoMdoryJNNpVG gcl3TpH+ZC3/LYyTRxmqXtMVSQuE9DEnBDlAKxIhnOdkHXH4AY8i1jkE2 rU64XbmLLwZvsml+EHNPB4fYN30P3/pY3uqQknx9ASjeCBKZQuAUQzYKu rUusecWjV4oqEBIfW3eZlMwrxoZveMQRn9+qU3JYbRQvAdIsu8wBu+hST MnyLMP/D1BPZ9mj/4M6crvdomMLb1YZDi7mMbnRGZeu+P3ABF6wJpkkPZ RINhWlxGML1jy6+4hcp5L/DRu3xLFXuXe5f21nNYipWK7CGrnZIZ+p9Aa Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875754" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875754" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660230" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660230" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 11/18] i386/cpu: Introduce cluster-id to X86CPU Date: Mon, 13 Feb 2023 17:36:18 +0800 Message-Id: <20230213093625.158170-12-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280608743100004 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding We introduce cluster-id other than module-id to be consistent with CpuInstanceProperties.cluster-id, and this avoids the confusion of parameter names when hotplugging. Following the legacy smp check rules, also add the cluster_id validity into x86_cpu_pre_plug(). Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu --- hw/i386/x86.c | 33 +++++++++++++++++++++++++-------- target/i386/cpu.c | 2 ++ target/i386/cpu.h | 1 + 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 2a9d080a8e7a..20ba2384bbb2 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -325,6 +325,14 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, cpu->die_id =3D 0; } =20 + /* + * cluster-id was optional in QEMU 8.0 and older, so keep it optio= nal + * if there's only one cluster per die. + */ + if (cpu->cluster_id < 0 && ms->smp.clusters =3D=3D 1) { + cpu->cluster_id =3D 0; + } + if (cpu->socket_id < 0) { error_setg(errp, "CPU socket-id is not set"); return; @@ -341,6 +349,14 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, cpu->die_id, ms->smp.dies - 1); return; } + if (cpu->cluster_id < 0) { + error_setg(errp, "CPU cluster-id is not set"); + return; + } else if (cpu->cluster_id > ms->smp.clusters - 1) { + error_setg(errp, "Invalid CPU cluster-id: %u must be in range = 0:%u", + cpu->cluster_id, ms->smp.clusters - 1); + return; + } if (cpu->core_id < 0) { error_setg(errp, "CPU core-id is not set"); return; @@ -360,16 +376,9 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, =20 topo_ids.pkg_id =3D cpu->socket_id; topo_ids.die_id =3D cpu->die_id; + topo_ids.module_id =3D cpu->cluster_id; topo_ids.core_id =3D cpu->core_id; topo_ids.smt_id =3D cpu->thread_id; - - /* - * TODO: This is the temporary initialization for topo_ids.module_= id to - * avoid "maybe-uninitialized" compilation errors. Will remove when - * X86CPU supports cluster_id. - */ - topo_ids.module_id =3D 0; - cpu->apic_id =3D x86_apicid_from_topo_ids(&topo_info, &topo_ids); } =20 @@ -416,6 +425,14 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, } cpu->die_id =3D topo_ids.die_id; =20 + if (cpu->cluster_id !=3D -1 && cpu->cluster_id !=3D topo_ids.module_id= ) { + error_setg(errp, "property cluster-id: %u doesn't match set apic-i= d:" + " 0x%x (cluster-id: %u)", cpu->cluster_id, cpu->apic_id, + topo_ids.module_id); + return; + } + cpu->cluster_id =3D topo_ids.module_id; + if (cpu->core_id !=3D -1 && cpu->core_id !=3D topo_ids.core_id) { error_setg(errp, "property core-id: %u doesn't match set apic-id:" " 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6f3d114c7d12..27bbbc36b11c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6980,12 +6980,14 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_UINT32("apic-id", X86CPU, apic_id, 0), DEFINE_PROP_INT32("thread-id", X86CPU, thread_id, 0), DEFINE_PROP_INT32("core-id", X86CPU, core_id, 0), + DEFINE_PROP_INT32("cluster-id", X86CPU, cluster_id, 0), DEFINE_PROP_INT32("die-id", X86CPU, die_id, 0), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, 0), #else DEFINE_PROP_UINT32("apic-id", X86CPU, apic_id, UNASSIGNED_APIC_ID), DEFINE_PROP_INT32("thread-id", X86CPU, thread_id, -1), DEFINE_PROP_INT32("core-id", X86CPU, core_id, -1), + DEFINE_PROP_INT32("cluster-id", X86CPU, cluster_id, -1), DEFINE_PROP_INT32("die-id", X86CPU, die_id, -1), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, -1), #endif diff --git a/target/i386/cpu.h b/target/i386/cpu.h index f3afea765982..8668e74e0c87 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1966,6 +1966,7 @@ struct ArchCPU { int32_t node_id; /* NUMA node this CPU belongs to */ int32_t socket_id; int32_t die_id; + int32_t cluster_id; int32_t core_id; int32_t thread_id; =20 --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280773; cv=none; d=zohomail.com; s=zohoarc; b=PKSfdEgQBeYtH627G0pXRho87DxMX3Mf55xMbOxlnD3k5AVOx1BOCmDAV+w4IDbChwcNDmU/FQg/2h71EHCoH35CFuVLwRVvgnlC/jDKFouOfnHddKbZGzDspy9yOO7HbyQzsMDlqect4Ls2gUEyJ+ZxZGzrFAiQLoMsPru9buQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280773; h=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=Iz9A5GKmg1cIgxUA+ybXvQDO/0u5KN7nFRlCr5/qOTc=; b=mugTF1OHPrTaAIdcjXq+6rfF6cXLEO/JNsSzLjtCZPpm5gq2xZmCUQf1VkERugXzJ3N9PHllN9RZdcTWKzuCDrCQIdcRAb+BJriZNvNQ6EDW+MuhBFasVWNWEZyTniB5Bqxa/6PB5iFl5+EtyLj4+mOyHzEk0sMPVs3z1UwOCYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280773070890.9743386626673; Mon, 13 Feb 2023 01:32:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9m-0005xw-6u; Mon, 13 Feb 2023 04:29:54 -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 1pRV9k-0005xa-5o for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:52 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9f-0006TH-Nh for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:29:51 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:46 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280587; x=1707816587; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UOLbqKmz3mKLwNGtsqF3Ql4TMAsj6E4kdhIN7yv8NuI=; b=Q2YMIxBQlDPlPp/Qd4+DAnzeZZi8lZlUBlOF/dMyfYjSvUj+mjUlpQwX 5jV1R3M79EV1I+eC5FtoD+xw1xWZbr49cYY9LbRpBMmROVplhfIT98Zkz Pz5NyTEcK4f9A20LoXU8JrlnqRKKqMAfN7itepQ6oF+XtS3llr0QqiVwr f11ASdpG2UVBkUrAqMYW06+cIQW3mYV06VXN/yiWvDMS89bBOWF/bwJkI 50S7R27b/iUo/7dpp7ttauLkNIaTWL+f55yEXayzQM2G65uztbEWD+7Ow /JHM/dD4s5ABSln1pld007mnMEBps69kn8JcCwHclgwWsBG76ZuYZeu0n w==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875769" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875769" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660258" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660258" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 12/18] tests: Add test case of APIC ID for module level parsing Date: Mon, 13 Feb 2023 17:36:19 +0800 Message-Id: <20230213093625.158170-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280773986100005 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding After i386 supports module level, it's time to add the test for module level's parsing. Signed-off-by: Zhuocheng Ding Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu Reviewed-by: Yanan Wang --- tests/unit/test-x86-apicid.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-x86-apicid.c b/tests/unit/test-x86-apicid.c index f21b8a5d95c2..55b731ccae55 100644 --- a/tests/unit/test-x86-apicid.c +++ b/tests/unit/test-x86-apicid.c @@ -37,6 +37,7 @@ static void test_topo_bits(void) topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 1}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 0); g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 0); + g_assert_cmpuint(apicid_module_width(&topo_info), =3D=3D, 0); g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); =20 topo_info =3D (X86CPUTopoInfo) {1, 1, 1, 1}; @@ -74,13 +75,22 @@ static void test_topo_bits(void) topo_info =3D (X86CPUTopoInfo) {1, 1, 33, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 6); =20 - topo_info =3D (X86CPUTopoInfo) {1, 1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {1, 6, 30, 2}; + g_assert_cmpuint(apicid_module_width(&topo_info), =3D=3D, 3); + topo_info =3D (X86CPUTopoInfo) {1, 7, 30, 2}; + g_assert_cmpuint(apicid_module_width(&topo_info), =3D=3D, 3); + topo_info =3D (X86CPUTopoInfo) {1, 8, 30, 2}; + g_assert_cmpuint(apicid_module_width(&topo_info), =3D=3D, 3); + topo_info =3D (X86CPUTopoInfo) {1, 9, 30, 2}; + g_assert_cmpuint(apicid_module_width(&topo_info), =3D=3D, 4); + + topo_info =3D (X86CPUTopoInfo) {1, 6, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); - topo_info =3D (X86CPUTopoInfo) {2, 1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {2, 6, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 1); - topo_info =3D (X86CPUTopoInfo) {3, 1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {3, 6, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); - topo_info =3D (X86CPUTopoInfo) {4, 1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {4, 6, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); =20 /* build a weird topology and see if IDs are calculated correctly @@ -91,6 +101,7 @@ static void test_topo_bits(void) topo_info =3D (X86CPUTopoInfo) {1, 1, 6, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); g_assert_cmpuint(apicid_core_offset(&topo_info), =3D=3D, 2); + g_assert_cmpuint(apicid_module_offset(&topo_info), =3D=3D, 5); g_assert_cmpuint(apicid_die_offset(&topo_info), =3D=3D, 5); g_assert_cmpuint(apicid_pkg_offset(&topo_info), =3D=3D, 5); =20 --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280848; cv=none; d=zohomail.com; s=zohoarc; b=X7dcGNuaOo61CBBYPrHm+RWdG+d8UOfYDT+VvSvwi/99UNMa+c8TS/LicUB4e8rrYbC5/41/wept5FM+MG3gK+juUdIF0Mf3nUMRGmXjOHCSjowm6h6iutRGoHZz61mzh7NpGhn7IRlvFqjWcPP3R8clbFQhoRj417khzgBPI7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280848; h=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=pC8Vf5BZT84+a31y/ZETkb3G/aEqrQJDNzMy+pE3B0I=; b=SsfD72MrdId0UyRtK3Lr4gqxpC+sVeM8Ddim2CPfBvgKLhYNgz+/E0RVq0IQpIlBQq2aIgypV8oxJgzM0omjQgtrGwa22pzjFykhuu/ez+s6xzH2qx9mcNdbn3UohvQlmCxmt86U7hX5+AkzF+5Kesnx2XQG8uccvF4e/m5qLEE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280848161255.83094539343563; Mon, 13 Feb 2023 01:34:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRV9v-0006Dv-JB; Mon, 13 Feb 2023 04:30:03 -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 1pRV9t-00064E-Np for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:01 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9p-0006TH-2m for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:01 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:51 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:46 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280597; x=1707816597; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Wk4GGeeDTDYXEDiG6v4MedNwJ0pca6ecfn6tCeHb/c=; b=VZLJXmfwaRZhMHhAZVtTwJagzkFjWfJxLgzzWm2MVC+aSx1yGt2y/Kzk FRnjdqYRCihB1xDFTwmWFf+XupYGoeEEsqMfJXDDv8g1RzQsBZQzYpOGP W6ctgA3zI495S4FrC01xIC5JXjrNAiMHc7QeGd6FKN4u84h0V0CiP0Nkz 1wsExlUAi5AV/sKCULUb8P3pwkOAKKw5+HlwPoz1LQD0yE0l8TFrbw4Z9 66/rW1F7DwqcGNBwXDrQED3iuFsgAHGb9SpKm31vCA29yRvM0oJ+zBGnm PkIDrj6ntOAyoDiMXPVAclV8GFamlMzzJpdDZUq+xwpi0whF62V3i0ZQB A==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875778" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875778" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660282" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660282" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 13/18] hw/i386/pc: Support smp.clusters for x86 PC machine Date: Mon, 13 Feb 2023 17:36:20 +0800 Message-Id: <20230213093625.158170-14-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280848369100001 Content-Type: text/plain; charset="utf-8" From: Zhuocheng Ding As module-level topology support is added to X86CPU, now we can enable the support for the cluster parameter on PC machines. With this support, we can define a 5-level x86 CPU topology with "-smp": -smp cpus=3D*,maxcpus=3D*,sockets=3D*,dies=3D*,clusters=3D*,cores=3D*,threa= ds=3D*. Additionally, add the 5-level topology example in description of "-smp". Signed-off-by: Zhuocheng Ding Signed-off-by: Zhao Liu Reviewed-by: Yanan Wang --- hw/i386/pc.c | 1 + qemu-options.hx | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6e592bd969aa..c329df56ebd2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1929,6 +1929,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D true; mc->smp_props.dies_supported =3D true; + mc->smp_props.clusters_supported =3D true; mc->default_ram_id =3D "pc.ram"; =20 object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size", diff --git a/qemu-options.hx b/qemu-options.hx index 88e93c610314..3caf9da4c3af 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -312,14 +312,14 @@ SRST -smp 8,sockets=3D2,cores=3D2,threads=3D2,maxcpus=3D8 =20 The following sub-option defines a CPU topology hierarchy (2 sockets - totally on the machine, 2 dies per socket, 2 cores per die, 2 threads - per core) for PC machines which support sockets/dies/cores/threads. - Some members of the option can be omitted but their values will be - automatically computed: + totally on the machine, 2 dies per socket, 2 clusters per die, 2 cores= per + cluster, 2 threads per core) for PC machines which support sockets/dies + /clusters/cores/threads. Some members of the option can be omitted but + their values will be automatically computed: =20 :: =20 - -smp 16,sockets=3D2,dies=3D2,cores=3D2,threads=3D2,maxcpus=3D16 + -smp 32,sockets=3D2,dies=3D2,clusters=3D2,cores=3D2,threads=3D2,ma= xcpus=3D32 =20 The following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 clusters per socket, 2 cores per cluster, --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280690; cv=none; d=zohomail.com; s=zohoarc; b=gE2LG1BvfFqMvpkazsAS5xZrW7zoPyZhSnVQTHLeMXgZPPcrB3+uMoDPaQ5TmDmUqTfg2XHvK1tJvaxf5PCisyAsZlm2DvCjcy/W9Tz3piE7R0LA5mZtHsLxjFGKrBrFmKdS/jMXnXVDg0NzhVNLUieAzQT5XUcOAwSB+zmOyGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280690; h=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=+hM7lV2N72q+7+08kCmy1C15iHAYX8DvBpOmXJbA1O0=; b=RbpTsgg/fA9V1tV3fBQ8fa0t8U2haUjFAK+U18Ghib/NgASCt/jxGvQDB5Xf5kbTRMLL3aB7TTTUMseIQAtL3TSiW5kpLIy7OREtwsCZFSaIWwgMTv8vN6DXf5DXlok9H7WbDif/z5k1o2fmHclgNYiku2IDxNbuoyMaIvoW6Ws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280690228769.9074678554231; Mon, 13 Feb 2023 01:31:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRVA8-0006Wy-5I; Mon, 13 Feb 2023 04:30:21 -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 1pRV9y-0006K7-3N for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:06 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9q-0006Xl-8K for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:05 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:29:55 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280598; x=1707816598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IjmG50bvCSw8vgMEYd9oBawb6EIkhL+/mLrbVfxWlqs=; b=a4Uc6wsFe+mB3q6i9bUTIPatdXQSm3gfNg/EEo/wOk5Q3cP2TeSC8YfF UJb65zwyf7yKGPI1v2RWg+9rQe2Ee6N5Nm+Xb6erqrWNK97MjH9sLymCh jD448986PqAp2d5aC04ckqo+BGEFCl04Q2S6I50dH8x4MU/WI0TJ2ZJFR e+oUnGdvNfWdDIZ3wE/b6mNQqxU0Gy38IkOenw70CzZ46YgfR6LGuScJA ivl6DqQa2ChrMlleEBURv6xCXgUJYmRo2T1+er4MnOkc/2ALyPZZtv97L dEZ4ACKa8SERjviYo+HmzeJOEoVvI4kTvIJHTlBfGrmtaGHR5q3AGy0DX g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875801" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875801" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660305" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660305" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 14/18] i386: Add cache topology info in CPUCacheInfo Date: Mon, 13 Feb 2023 17:36:21 +0800 Message-Id: <20230213093625.158170-15-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280691152100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Currently, by default, the cache topology is encoded as: 1. i/d cache is shared in one core. 2. L2 cache is shared in one core. 3. L3 cache is shared in one die. This default general setting has caused a misunderstanding, that is, the cache topology is completely equated with a specific cpu topology, such as the connection between L2 cache and core level, and the connection between L3 cache and die level. In fact, the settings of these topologies depend on the specific platform and are not static. For example, on Alder Lake-P, every four Atom cores share the same L2 cache. Thus, we should explicitly define the corresponding cache topology for different cache models to increase scalability. Except legacy_l2_cache_cpuid2 (its default topo level is INVALID), explicitly set the corresponding topology level for all other cache models. In order to be compatible with the existing cache topology, set the CORE level for the i/d cache, set the CORE level for L2 cache, and set the DIE level for L3 cache. The field for CPUID[4].EAX[bits 25:14] or CPUID[0x8000001D].EAX[bits 25:14] will be set based on CPUCacheInfo.share_level. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 19 +++++++++++++++++++ target/i386/cpu.h | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 27bbbc36b11c..364534e84b1b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -433,6 +433,7 @@ static CPUCacheInfo legacy_l1d_cache =3D { .sets =3D 64, .partitions =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }; =20 /*FIXME: CPUID leaf 0x80000005 is inconsistent with leaves 2 & 4 */ @@ -447,6 +448,7 @@ static CPUCacheInfo legacy_l1d_cache_amd =3D { .partitions =3D 1, .lines_per_tag =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }; =20 /* L1 instruction cache: */ @@ -460,6 +462,7 @@ static CPUCacheInfo legacy_l1i_cache =3D { .sets =3D 64, .partitions =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }; =20 /*FIXME: CPUID leaf 0x80000005 is inconsistent with leaves 2 & 4 */ @@ -474,6 +477,7 @@ static CPUCacheInfo legacy_l1i_cache_amd =3D { .partitions =3D 1, .lines_per_tag =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }; =20 /* Level 2 unified cache: */ @@ -487,6 +491,7 @@ static CPUCacheInfo legacy_l2_cache =3D { .sets =3D 4096, .partitions =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }; =20 /*FIXME: CPUID leaf 2 descriptor is inconsistent with CPUID leaf 4 */ @@ -509,6 +514,7 @@ static CPUCacheInfo legacy_l2_cache_amd =3D { .associativity =3D 16, .sets =3D 512, .partitions =3D 1, + .share_level =3D CORE, }; =20 /* Level 3 unified cache: */ @@ -524,6 +530,7 @@ static CPUCacheInfo legacy_l3_cache =3D { .self_init =3D true, .inclusive =3D true, .complex_indexing =3D true, + .share_level =3D DIE, }; =20 /* TLB definitions: */ @@ -1668,6 +1675,7 @@ static const CPUCaches epyc_cache_info =3D { .lines_per_tag =3D 1, .self_init =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }, .l1i_cache =3D &(CPUCacheInfo) { .type =3D INSTRUCTION_CACHE, @@ -1680,6 +1688,7 @@ static const CPUCaches epyc_cache_info =3D { .lines_per_tag =3D 1, .self_init =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }, .l2_cache =3D &(CPUCacheInfo) { .type =3D UNIFIED_CACHE, @@ -1690,6 +1699,7 @@ static const CPUCaches epyc_cache_info =3D { .partitions =3D 1, .sets =3D 1024, .lines_per_tag =3D 1, + .share_level =3D CORE, }, .l3_cache =3D &(CPUCacheInfo) { .type =3D UNIFIED_CACHE, @@ -1703,6 +1713,7 @@ static const CPUCaches epyc_cache_info =3D { .self_init =3D true, .inclusive =3D true, .complex_indexing =3D true, + .share_level =3D DIE, }, }; =20 @@ -1718,6 +1729,7 @@ static const CPUCaches epyc_rome_cache_info =3D { .lines_per_tag =3D 1, .self_init =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }, .l1i_cache =3D &(CPUCacheInfo) { .type =3D INSTRUCTION_CACHE, @@ -1730,6 +1742,7 @@ static const CPUCaches epyc_rome_cache_info =3D { .lines_per_tag =3D 1, .self_init =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }, .l2_cache =3D &(CPUCacheInfo) { .type =3D UNIFIED_CACHE, @@ -1740,6 +1753,7 @@ static const CPUCaches epyc_rome_cache_info =3D { .partitions =3D 1, .sets =3D 1024, .lines_per_tag =3D 1, + .share_level =3D CORE, }, .l3_cache =3D &(CPUCacheInfo) { .type =3D UNIFIED_CACHE, @@ -1753,6 +1767,7 @@ static const CPUCaches epyc_rome_cache_info =3D { .self_init =3D true, .inclusive =3D true, .complex_indexing =3D true, + .share_level =3D DIE, }, }; =20 @@ -1768,6 +1783,7 @@ static const CPUCaches epyc_milan_cache_info =3D { .lines_per_tag =3D 1, .self_init =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }, .l1i_cache =3D &(CPUCacheInfo) { .type =3D INSTRUCTION_CACHE, @@ -1780,6 +1796,7 @@ static const CPUCaches epyc_milan_cache_info =3D { .lines_per_tag =3D 1, .self_init =3D 1, .no_invd_sharing =3D true, + .share_level =3D CORE, }, .l2_cache =3D &(CPUCacheInfo) { .type =3D UNIFIED_CACHE, @@ -1790,6 +1807,7 @@ static const CPUCaches epyc_milan_cache_info =3D { .partitions =3D 1, .sets =3D 1024, .lines_per_tag =3D 1, + .share_level =3D CORE, }, .l3_cache =3D &(CPUCacheInfo) { .type =3D UNIFIED_CACHE, @@ -1803,6 +1821,7 @@ static const CPUCaches epyc_milan_cache_info =3D { .self_init =3D true, .inclusive =3D true, .complex_indexing =3D true, + .share_level =3D DIE, }, }; =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8668e74e0c87..5a955431f759 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1476,6 +1476,15 @@ enum CacheType { UNIFIED_CACHE }; =20 +enum CPUTopoLevel { + INVALID =3D 0, + SMT, + CORE, + MODULE, + DIE, + PACKAGE, +}; + typedef struct CPUCacheInfo { enum CacheType type; uint8_t level; @@ -1517,6 +1526,13 @@ typedef struct CPUCacheInfo { * address bits. CPUID[4].EDX[bit 2]. */ bool complex_indexing; + + /* + * Cache Topology. The level that cache is shared in. + * Used to encode CPUID[4].EAX[bits 25:14] or + * CPUID[0x8000001D].EAX[bits 25:14]. + */ + enum CPUTopoLevel share_level; } CPUCacheInfo; =20 =20 --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280954; cv=none; d=zohomail.com; s=zohoarc; b=L1mrIQ8H9VGaMA8pdeg87kPUEt3WrwCYyYQ8irvWLYLqK5D0Pe1LG0OaRA5gMbsGZ89dMx/8Z1ItQIjyqdelI2VjaDXmyFIfDqp1kmRvFNVNT56OmddtfrvV4CIEQ9w48R8BBrJFgr/d9ul7f1JYsI9+btfbLWnUgY588CW4Ksg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280954; h=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=vgm/Dq3ZPQUPRkKHeR3odmAmYxRNnhKXbHnKrFtc1eg=; b=UzCLU2zO1hdKvAS0EtHpjOAHoUaAahca6CBDYZi6SlxsuJDnyWzuxs2iIE8JLZb8NFH4zD+FIJak90QHljqTUxNYNH/wgosPuWOV1f86Ls9EYBwRkR5bcy8Q5BD0a/kAIX9OYg7dS6rRaU/aJwx7uBy/kngSUFqFPx0o7eQxcrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280954756501.3817613343009; Mon, 13 Feb 2023 01:35:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRVAK-0006rW-Ib; Mon, 13 Feb 2023 04:30:30 -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 1pRV9y-0006KE-3u for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:06 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRV9v-0006TH-54 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:05 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:30:00 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:29:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280603; x=1707816603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wy/HB9PCBo5jKGh1Soirwp+UxznN/hgvoS723fwEbJU=; b=bnrWbUMhWf6fCzBR1fXqzXELTrLWTVLOSxQN/x4j09RvJjIO4hsc5UGq qTmNQuFDbkI8PRIcHnLEP8BHWUkJeTYbEj7XI/d2S8DleNopP4cOFm1T/ OjqVckpaR6Wqub2f04LAmhlKf+lkX4bqYxCqbSjDT1AKASjbzUnGKrcBX 41I+LAOkqS7I2pHfSYc6yTmLTA7yKMKIMHRhCdnCWk/Zb+HqCpRguE6VV Vi61Ij1eZdN7RwlkxN3wQ6/fLqdEICIfwCF0veUigd246368gW4vUzagG H1ZnC9muDQAzLrZgmsjNUa3PCjrI7EE/mv1HdZnQPr95KlRoY4m0AQz2Z A==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875826" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875826" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660341" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660341" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 15/18] i386: Use CPUCacheInfo.share_level to encode CPUID[4].EAX[bits 25:14] Date: Mon, 13 Feb 2023 17:36:22 +0800 Message-Id: <20230213093625.158170-16-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280956021100006 Content-Type: text/plain; charset="utf-8" From: Zhao Liu CPUID[4].EAX[bits 25:14] is used to represent the cache topology for intel CPUs. After cache models have topology information, we can use CPUCacheInfo.share_level to decide which topology level to be encoded into CPUID[4].EAX[bits 25:14]. Additionally, since maximum_processor_id (original "num_apic_ids") is parsed based on cpu topology levels, which are verified when parsing smp, it's no need to check this value by "assert(num_apic_ids > 0)" again, so remove this assert. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 55 +++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 364534e84b1b..96ef96860604 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -231,22 +231,50 @@ static uint8_t cpuid2_cache_descriptor(CPUCacheInfo *= cache) ((t) =3D=3D UNIFIED_CACHE) ? CACHE_TYPE_UNIFIED : \ 0 /* Invalid value */) =20 +static uint32_t max_processor_ids_for_cache(CPUCacheInfo *cache, + X86CPUTopoInfo *topo_info) +{ + uint32_t num_ids =3D 0; + + switch (cache->share_level) { + case CORE: + num_ids =3D 1 << apicid_core_offset(topo_info); + break; + case DIE: + num_ids =3D 1 << apicid_die_offset(topo_info); + break; + default: + /* + * Currently there is no use case for SMT, MODULE and PACKAGE, so = use + * assert directly to facilitate debugging. + */ + g_assert_not_reached(); + } + + return num_ids - 1; +} + +static uint32_t max_core_ids_in_package(X86CPUTopoInfo *topo_info) +{ + uint32_t num_cores =3D 1 << (apicid_pkg_offset(topo_info) - + apicid_core_offset(topo_info)); + return num_cores - 1; +} =20 /* Encode cache info for CPUID[4] */ static void encode_cache_cpuid4(CPUCacheInfo *cache, - int num_apic_ids, int num_cores, + X86CPUTopoInfo *topo_info, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { assert(cache->size =3D=3D cache->line_size * cache->associativity * cache->partitions * cache->sets); =20 - assert(num_apic_ids > 0); *eax =3D CACHE_TYPE(cache->type) | CACHE_LEVEL(cache->level) | (cache->self_init ? CACHE_SELF_INIT_LEVEL : 0) | - ((num_cores - 1) << 26) | - ((num_apic_ids - 1) << 14); + (max_core_ids_in_package(topo_info) << 26) | + (max_processor_ids_for_cache(cache, topo_info) << 14); =20 assert(cache->line_size > 0); assert(cache->partitions > 0); @@ -5335,38 +5363,27 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, *eax =3D *ebx =3D *ecx =3D *edx =3D 0; } else { *eax =3D 0; - int addressable_cores_offset =3D apicid_pkg_offset(&topo_info)= - - apicid_core_offset(&topo_info); - int core_offset, die_offset; =20 switch (count) { case 0: /* L1 dcache info */ - core_offset =3D apicid_core_offset(&topo_info); encode_cache_cpuid4(env->cache_info_cpuid4.l1d_cache, - (1 << core_offset), - (1 << addressable_cores_offset), + &topo_info, eax, ebx, ecx, edx); break; case 1: /* L1 icache info */ - core_offset =3D apicid_core_offset(&topo_info); encode_cache_cpuid4(env->cache_info_cpuid4.l1i_cache, - (1 << core_offset), - (1 << addressable_cores_offset), + &topo_info, eax, ebx, ecx, edx); break; case 2: /* L2 cache info */ - core_offset =3D apicid_core_offset(&topo_info); encode_cache_cpuid4(env->cache_info_cpuid4.l2_cache, - (1 << core_offset), - (1 << addressable_cores_offset), + &topo_info, eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - die_offset =3D apicid_die_offset(&topo_info); if (cpu->enable_l3_cache) { encode_cache_cpuid4(env->cache_info_cpuid4.l3_cache, - (1 << die_offset), - (1 << addressable_cores_offset), + &topo_info, eax, ebx, ecx, edx); break; } --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280954; cv=none; d=zohomail.com; s=zohoarc; b=amiLnUXiLx/HROrWL+Siys6QI63VXp14/LnnZfvPM8CzDK01ajG9JSxoCIeTLbTwuWffPd/cRnKb11YhpGyjvdZpvNFs/5Gap/wgdSKtGw3Z3xMwljdzvXPGHgjdmU46wO29Ge2XVYfMYuCWyvC1ezO4+qQlg3ZTDp6pvE956T0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280954; h=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=eLIJBDEoAIcExtC7DmZrDfseFTerznrUy+IkmfnMFHA=; b=n1LjNk5PlREwM2WZyElq6Hnh4/iG5b6I45YuqNWnXxR81rgyO1CTsaTOOl53URGjaQRRh32IT7XxRcGoAAyW3r1qW6jikI1kxLfvH1WA4S4SihFnS1gUAr8NjizZFoPPRgI9G8tta06qi+Zm0GPigkKZP7O0vFWOeo13GVnbuyE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280954719801.6634815983629; Mon, 13 Feb 2023 01:35:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRVBI-0007h8-Go; Mon, 13 Feb 2023 04:31:28 -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 1pRVAA-0006mD-8X for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:21 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRVA0-0006ms-Sv for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:16 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:30:06 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:30:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280608; x=1707816608; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cy4+98KPu3JM0FYdIqdy+k8SAFPj3EZM5g5RLHeoHLc=; b=ca3chaQElRUCuXy9kKSWIojixmed8AyzHlyaxHbUUeWQUEgVGPQTF5d0 oWFhKAzNvThy+rVYXtn51M86nomkOhuWt8G6APN/yV0CAj46lWgoIxpW6 jMO3DcjarYk9smRY53xARaE2bzTH4X+d4JXJIMTaw8V53s8Vj3I9jolPJ HwDMr+TWlB79dk5Odbqt61j1rWVvS8S5hii6mCI5vSIuCAcQDzGN4l42i IljcrW71TxPUT4Qz7yeKbtJn3iuYzMLz0rucgDq86CNXitNSsr/s970Ls OB19k+1PFBp6GY1mDm8sP11zUnHBORW/mVkmMQ/934zWS0Zc2Tcu2qldy w==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875848" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875848" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660439" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660439" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 16/18] i386: Fix NumSharingCache for CPUID[0x8000001D].EAX[bits 25:14] Date: Mon, 13 Feb 2023 17:36:23 +0800 Message-Id: <20230213093625.158170-17-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280956008100005 Content-Type: text/plain; charset="utf-8" From: Zhao Liu From AMD's APM, NumSharingCache (CPUID[0x8000001D].EAX[bits 25:14]) means [1]: The number of logical processors sharing this cache is the value of this field incremented by 1. To determine which logical processors are sharing a cache, determine a Share Id for each processor as follows: ShareId =3D LocalApicId >> log2(NumSharingCache+1) Logical processors with the same ShareId then share a cache. If NumSharingCache+1 is not a power of two, round it up to the next power of two. From the description above, the caculation of this feild should be same as CPUID[4].EAX[bits 25:14] for intel cpus. So also use the offsets of APIC ID to caculate this field. Note: I don't have the hardware available, hope someone can help me to confirm whether this calculation is correct, thanks! [1]: APM, vol.3, appendix.E.4.15 Function 8000_001Dh--Cache Topology Information Signed-off-by: Zhao Liu --- target/i386/cpu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 96ef96860604..d691c02e3c06 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -355,7 +355,7 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *ca= che, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - uint32_t l3_threads; + uint32_t sharing_apic_ids; assert(cache->size =3D=3D cache->line_size * cache->associativity * cache->partitions * cache->sets); =20 @@ -364,13 +364,11 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *= cache, =20 /* L3 is shared among multiple cores */ if (cache->level =3D=3D 3) { - l3_threads =3D topo_info->modules_per_die * - topo_info->cores_per_module * - topo_info->threads_per_core; - *eax |=3D (l3_threads - 1) << 14; + sharing_apic_ids =3D 1 << apicid_die_offset(topo_info); } else { - *eax |=3D ((topo_info->threads_per_core - 1) << 14); + sharing_apic_ids =3D 1 << apicid_core_offset(topo_info); } + *eax |=3D (sharing_apic_ids - 1) << 14; =20 assert(cache->line_size > 0); assert(cache->partitions > 0); --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280891; cv=none; d=zohomail.com; s=zohoarc; b=JLV21FA6YYxXv15S6DynDH8lGsEt9uMyLw05moFhOVejGQWsr/uVeQawarjJeu+92Q8A8vDPlRGVsnw7UiUaJZcxR1cV2JFe/+jd/hkhXhOF7mITuacBbjA9QyJwq/SKDnOqjK1XqmFPJWiqfLmeU1eVCRJwvGZ3xvHX4IMLiIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280891; h=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=TOLME3hzJslfCIL14XNXopnjG/8NS3gErfJbrHEVjy4=; b=LdlKhKpPJPdWq6MraisKmWlXRgp7q8rPSBC1sxhA+Rse/V0XXky0KK45Q/gc4Ke1GdVrIbODuvLMhx8mTFXZAR93WiLw91TQ1J0pXVNJJmwmz71fgZbVKAQshT9VyuWo7c2HDgoyRp3pDy+9AEBay8/0xK5VawyiFmhKTwU+y7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280891562145.22228429403685; Mon, 13 Feb 2023 01:34:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRVAz-00076s-N9; Mon, 13 Feb 2023 04:31:11 -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 1pRVAA-0006mE-GG for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:21 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRVA4-0006nq-36 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:18 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:30:09 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:30:05 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280612; x=1707816612; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uLL+NWRhAQrmrOXrW9mrGp0p9bgRS48bvW90TKnZBAM=; b=N3deQJEE2/Qx8mmtCxg/OSci7lCeHBS7TNXY9pMUTyjrnDyCDomENlLc M7YHDz+qXyB6J07PmzeH/5BwyxmC71bUwj3C/in6Vwz2YNakZvGGueEDa GegDFCBbu3/0dLouBGA7lxBKzKfmAs+b7X+9h3vUzlHNbkti2yw1yJMbd SkfiP97YBN8BGvI9HRAPY09CBsY184SnQF1aDioWx4SREx/FVNx90+3yF 67hcumi2UwUbZTGBsQUnY/xgWAopqp7HCeZzOINzqc5hrvvgmLzUGXcqP NpySJBaqQkcoiNEYuv3fNoWp7pjNhop6UUHmyaPVRIUNgtR2zLCWuXhY2 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875874" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875874" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660509" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660509" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 17/18] i386: Use CPUCacheInfo.share_level to encode CPUID[0x8000001D].EAX[bits 25:14] Date: Mon, 13 Feb 2023 17:36:24 +0800 Message-Id: <20230213093625.158170-18-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280892810100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu CPUID[0x8000001D].EAX[bits 25:14] is used to represent the cache topology for amd CPUs. After cache models have topology information, we can use CPUCacheInfo.share_level to decide which topology level to be encoded into CPUID[0x8000001D].EAX[bits 25:14]. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d691c02e3c06..5816dc99b1d4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -355,20 +355,12 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *= cache, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - uint32_t sharing_apic_ids; assert(cache->size =3D=3D cache->line_size * cache->associativity * cache->partitions * cache->sets); =20 *eax =3D CACHE_TYPE(cache->type) | CACHE_LEVEL(cache->level) | (cache->self_init ? CACHE_SELF_INIT_LEVEL : 0); - - /* L3 is shared among multiple cores */ - if (cache->level =3D=3D 3) { - sharing_apic_ids =3D 1 << apicid_die_offset(topo_info); - } else { - sharing_apic_ids =3D 1 << apicid_core_offset(topo_info); - } - *eax |=3D (sharing_apic_ids - 1) << 14; + *eax |=3D max_processor_ids_for_cache(cache, topo_info) << 14; =20 assert(cache->line_size > 0); assert(cache->partitions > 0); --=20 2.34.1 From nobody Mon May 6 01:10:36 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676280705; cv=none; d=zohomail.com; s=zohoarc; b=GaNu4HrRyAV+lLw1R7+biH1aG/aE7qUUdiTlQ8Tqd7ucjC/aoswDcZAyUev2bnXo+qn4yd311cO1n/U5S/hsvW4wb2fnU8A+CUMbWMDCyfQJFCyCAcgioWJuXBV71rKyvzrnjrikzvCa6cND8OpL8mYWkb5fy9X79ENVTwRh4t0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676280705; h=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=va8C7UDZxGD7g+WsXPJXdKVNDUvB048AVjM1/IxH0OY=; b=XBDNTorGtRpMLuJpbVVsT/SSvzG5Fgkxk/BbysK2/SQbzHsrjXxxdH95Hr7gjxNGJNaK2ApSEY+aVr2D8oi7ARmOpyDwqL1C1PZDnOo+VFRO91eQu9LsPLG7FvYjIdt6RvdCscNqm9CpRy4Ls76mYIKMaijbejH55TQdlGNqTGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1676280705000249.4174159713442; Mon, 13 Feb 2023 01:31:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRVBB-0007OF-Mf; Mon, 13 Feb 2023 04:31:23 -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 1pRVAC-0006pK-0g for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:21 -0500 Received: from mga02.intel.com ([134.134.136.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRVA9-0006qi-VY for qemu-devel@nongnu.org; Mon, 13 Feb 2023 04:30:19 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 01:30:15 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2023 01:30:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676280617; x=1707816617; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h2l32Mxk3IIptSYvwOMjSG7Mq4ltZJOLf/uBlKfJWe8=; b=GTbgVFhZtp95/YOPWa2yZMrJtbGq+hlnIyJ63yvOvx7jKFQwl4fTrSJG D98cYA69sApv/IC8LFCxR/HfnprFHApNxF8ccXZU04WXR8OyVbjU6dBZ9 dWmrp76tnglB2y4U8rNFebDL8Izv+ixfrWp1LEWntnrCoKpi/t0tA/aJk XErB4PMwFF+kvpu2twme4v0Kv6637WjbYwK3+12dDFXH9Vbh1wFDMqikG qHYbEWbW9n4RsKqDUj96IAY1AX1iFj3mSWma8iCmaUDGJs2+ExE+Uu+cF CR9/byciT2PLPZpSykBcope4Y1yPCwpmmmHZ6Zak2I75YAZ1H2O8P/jpv Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318875907" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="318875907" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="792660564" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="792660564" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster Cc: qemu-devel@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhuocheng Ding , Robert Hoo , Xiaoyao Li , Like Xu , Zhao Liu Subject: [PATCH RESEND 18/18] i386: Add new property to control L2 cache topo in CPUID.04H Date: Mon, 13 Feb 2023 17:36:25 +0800 Message-Id: <20230213093625.158170-19-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213093625.158170-1-zhao1.liu@linux.intel.com> References: <20230213093625.158170-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=134.134.136.20; envelope-from=zhao1.liu@linux.intel.com; helo=mga02.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1676280705395100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu The property x-l2-cache-topo will be used to change the L2 cache topology in CPUID.04H. Now it allows user to set the L2 cache is shared in core level or cluster level. If user passes "-cpu x-l2-cache-topo=3D[core|cluster]" then older L2 cache topology will be overrided by the new topology setting. Here we expose to user "cluster" instead of "module", to be consistent with "cluster-id" naming. Since CPUID.04H is used by intel CPUs, this property is available on intel CPUs as for now. When necessary, it can be extended to CPUID.8000001DH for amd CPUs. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 33 ++++++++++++++++++++++++++++++++- target/i386/cpu.h | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5816dc99b1d4..cf84c720a431 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -240,12 +240,15 @@ static uint32_t max_processor_ids_for_cache(CPUCacheI= nfo *cache, case CORE: num_ids =3D 1 << apicid_core_offset(topo_info); break; + case MODULE: + num_ids =3D 1 << apicid_module_offset(topo_info); + break; case DIE: num_ids =3D 1 << apicid_die_offset(topo_info); break; default: /* - * Currently there is no use case for SMT, MODULE and PACKAGE, so = use + * Currently there is no use case for SMT and PACKAGE, so use * assert directly to facilitate debugging. */ g_assert_not_reached(); @@ -6633,6 +6636,33 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) env->cache_info_amd.l3_cache =3D &legacy_l3_cache; } =20 + if (cpu->l2_cache_topo_level) { + /* + * FIXME: Currently only supports changing CPUID[4] (for intel), a= nd + * will support changing CPUID[0x8000001D] when necessary. + */ + if (!IS_INTEL_CPU(env)) { + error_setg(errp, "only intel cpus supports x-l2-cache-topo"); + return; + } + + if (!strcmp(cpu->l2_cache_topo_level, "core")) { + env->cache_info_cpuid4.l2_cache->share_level =3D CORE; + } else if (!strcmp(cpu->l2_cache_topo_level, "cluster")) { + /* + * We expose to users "cluster" instead of "module", to be + * consistent with "cluster-id" naming. + */ + env->cache_info_cpuid4.l2_cache->share_level =3D MODULE; + } else { + error_setg(errp, + "x-l2-cache-topo doesn't support '%s', " + "and it only supports 'core' or 'cluster'", + cpu->l2_cache_topo_level); + return; + } + } + #ifndef CONFIG_USER_ONLY MachineState *ms =3D MACHINE(qdev_get_machine()); qemu_register_reset(x86_cpu_machine_reset_cb, cpu); @@ -7135,6 +7165,7 @@ static Property x86_cpu_properties[] =3D { false), DEFINE_PROP_BOOL("x-intel-pt-auto-level", X86CPU, intel_pt_auto_level, true), + DEFINE_PROP_STRING("x-l2-cache-topo", X86CPU, l2_cache_topo_level), DEFINE_PROP_END_OF_LIST() }; =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5a955431f759..aa7e96c586c7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1987,6 +1987,8 @@ struct ArchCPU { int32_t thread_id; =20 int32_t hv_max_vps; + + char *l2_cache_topo_level; }; =20 =20 --=20 2.34.1