From nobody Thu Jul 23 21:13:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1784565033; cv=pass; d=zohomail.com; s=zohoarc; b=ONaKeCM1VW2bEZN/8t4Cmkp81laRngeo3wLFQ1we6cKQd8cDPYEvixodhhBlZv2YfDRX6CvYMXvyo/X2Gg4NoKlL484nxuG6revHIzWFTeG5yg8JuczUAeUDsoekW4S3Dektl1gLjCK8LXajMPHTE+soJOF33P+dvrfmC3UP4MI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784565033; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c7KiknWv6CQz3nBiJcRuHkUHq5J1xbdGZY3kwOVyjYc=; b=R/YQLm7Cj0EI2TX3BW5nfBHMZmQy7yoERPUuzCkjfLvPWhMOQgy6h8jyoBrBQgrnWePx+Su9zO6jhFwm4ZQUoAMNdavQVFEnHazuMTugGKVdfEV/ZvzexvpQES48HkM65uzU2nAdetnMx9m32TTPqKP+8NBr1Npt1+TLp9I/1wQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 178456503350037.9459678737378; Mon, 20 Jul 2026 09:30:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367301.1617103 (Exim 4.92) (envelope-from ) id 1wlqsa-0006z4-2U; Mon, 20 Jul 2026 16:30:08 +0000 Received: by outflank-mailman (output) from mailman id 1367301.1617103; Mon, 20 Jul 2026 16:30:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsZ-0006yx-Vk; Mon, 20 Jul 2026 16:30:07 +0000 Received: by outflank-mailman (input) for mailman id 1367301; Mon, 20 Jul 2026 16:30:06 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsY-0006rX-D5 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:30:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqsX-007DYj-Pd for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:30:05 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4ce3-bab6-0a2a0a5309dd-0a2a45099856-36 for ; Mon, 20 Jul 2026 18:30:05 +0200 Received: from [52.101.228.82] (helo=OS0P286CU011.outbound.protection.outlook.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4d0a-be1a-0a2a45090019-3465e452a176-3 for ; Mon, 20 Jul 2026 18:30:05 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OS9P286MB6790.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:419::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Mon, 20 Jul 2026 16:30:01 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0223.017; Mon, 20 Jul 2026 16:30:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=drJRfDV3tbzARWxwaDjZV+CQf2yx9Jht3g34j5/+Xczb9/2z66XkgebTzplWTA4+FEJzN77BdFQVzyNo5JW5TWVresG5+v7ywuPmHxOPTEp21kGeEXvcvPmL9qx2eaZYrMMVceDFbq6RsdR8ucsBkoo+1Iio1/oOKk+JRsPoWMb3T7BoTYBf33tyVJS0iNuDrF2P5f9lvqi0eGhsy//0VDk9QJL6rg0eJSfiJAmlE7wVCzL99yvrKcW7Yk58NH8vHCwPUNyi0uoxoaPpMWTELTW9dwH+smkjgJ38eKCcEMGLRzpqZOSef62xkXo/fjQLUQMqIVPw5wGVtMDn3Pf1yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c7KiknWv6CQz3nBiJcRuHkUHq5J1xbdGZY3kwOVyjYc=; b=bfrN5nopiKxa6PriyvdaZN0CZnbIm4Aqb4VnDVWQ2b3/qyt3AMuOkVQmXBaIOrdqNAt2LMp3NIS0ZPcNnNr0k7PueoFDQCHVUqgz1ZtG8cxJETl4xoGSVNludR9NyK3fA27X2Z8PWH2qhiykX7OYu0D6tM8afL+rk8cCpKZVknaba9fnp8WKBbTr/YOLYip5S2I2Nkyu1WMw7OTtnQz0lI6SiaE4G1Ctlp4CT1Hc+w24jqqg7z/rKP3XoBmLopk+fuCDP4bSZmIHIvlcyQ1heZe4qxW4JaTFYIHwnPDjqWpjo5NmzKxp0ZAC/Nv/xwJKFzZauwPsHB3gIUdJ4/8OZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c7KiknWv6CQz3nBiJcRuHkUHq5J1xbdGZY3kwOVyjYc=; b=M3FXMDumnY2fqmYkS2e3dXVBp5eC7kU8yo3+Bpq5UNCTGFI6SOQ80RL/Og9P1RzG4vcC9S/+bGvzjCt4ndJj6QM1Km2bPOpw3CQ2JmWydR0CX3JtovI7e5v3JgKdTYa6Z0VvWSVzzzi0CL+cTP5nLpRwutJnMJgbGmk9RrjjZwk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Mykyta_Poturai@epam.com, Hirokazu Takahashi , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v7 1/5] xen/device-tree: Parse 'cpu-map' node for CPU topology exploration Date: Tue, 21 Jul 2026 01:28:15 +0900 Message-ID: <20260720162819.308326-2-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720162819.308326-1-taka@valinux.co.jp> References: <20260720162819.308326-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY6P301CA0030.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:3ba::17) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OS9P286MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b33c870-dc8a-48a6-2896-08dee67c2547 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|10070799003|7416014|376014|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 9AZ8tXiRmPa1b2R4f+AlbgvcbiS6/TLlD+VReuOAWZfd9/Px2tq1UMq9L+pGJAh1T4tozlf3q4YSVgfKYC+Ui7qMTmmsXZNSQx6fXulEIIN/zb11QVAeFs5Rfqh4/wzauDN8IZ6Vs95dEBxhI/Kryt3xjQeNBI0UNxcnp4TQfW/XNoxG5rRuQKqjjMHlovUMRzNJUU+zDl8hoi8czEKMDaUS3HeJpjTZS36sB/BfCob2aJBln/Dxh6beToSYmRWkhIJL7Nok+e1duF4oYaSGlygV0ovV4j5c8ztpjKUvNn/OGvD2IPDAW55X+cTiHUlpr4rmf4Fs/vDDxRw1qhpnBFO7MANrYs/hgAzwgHD1xWpxrbc4vjiS6myXMLHG/SuQbydoHK0fVAHcE5dv0RpX3wP8G9QPRtesjZwCG1wFWyF9bkJHJ0v//JKgteDQWDBqs017K10aD73CvEsGfs52Fb1apJsy8me481ucsoLdvnVPpQuOftsqoOzXY/mJK6RjA5kd0Ez4gbI3kDcp3Liae+Lh9fB7kl8rlR4noaszDU6A8MunRjpUh1xwLNoyQfD70/NCGsYQYaZRK5IVRw1/wM8oBLaG0VxPZQzXMz/bw3KPVdsrHM9a/fXouy4LrCb8jrVhVnjL9Km4Y5cMYOq0ilO7+nd+ooHjzAfWVwWM3/0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(1800799024)(10070799003)(7416014)(376014)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?h15T4Da2efCQIlI6s997WwF8ZTVClrXnS5F4pDpkATLtdEC4+2fBlSRFC2kS?= =?us-ascii?Q?76ofwMnr2tkKOZqcGTaqp4YjlMW7gvIyKZu4HJ0azvoVK4owqri+iGB0yb8L?= =?us-ascii?Q?TqA5fPjQ339kQZ9HlzA00BGDaP64gtXN6Lgw5M450MgyWUXDVQ/KiDvKgYUe?= =?us-ascii?Q?MHZ3WHEx5c4oeS8egsAnom8yJV5YS2GvxqErvt42Tmp4lbGYXdn0phogmoxh?= =?us-ascii?Q?OuOsa/KMO3DWteXCR2ymfLowpRKVfVAD9S+w4g9xD/w2Td9g8xes6biJU6Ei?= =?us-ascii?Q?uteju2boDdHI43+Gy5hvVf0ECqXssQimfHsz0MKsB+R9qIqL1xfuz4h467f9?= =?us-ascii?Q?Dd1yQ18kZcXqFYOaZ65oPHOYpMnYAdW/E2Rh/NuzO9QTHPOl+Sf0RibMqRWW?= =?us-ascii?Q?GZyf1cFTISI7oueyph7TR+XJbidBljZkZQQHl3wews66fnLyNtmePSPPP9WS?= =?us-ascii?Q?GJUB7QxTAzJIuKkAqeO+w4ltnOSOwCzKZQVrsrKjQw2MzyP9ggCCCoqvT68t?= =?us-ascii?Q?5mYoEvQENTqHYrWrS3GDaym8dbZX4XpWHVp1Q+pNEBYLFVKitmz+F0A2/0N0?= =?us-ascii?Q?a6LYl/5jHNLmMRyn++jAEDO5W/pEQyybOZro1Yby/gCZBfyvDlc1Sy8Zem+X?= =?us-ascii?Q?t8LrKRfSyhxVvz+qpfj0CrGAo7+VncYK20DEp7eYZTguho1Dn6w2RbK9gKSg?= =?us-ascii?Q?ZA5ijm6iwZ0utBC/uK45IpDb7WAm4Lbn9dkQmjMrGfBCVsT176x9QLy5BOVN?= =?us-ascii?Q?2SO9xH93kiEYUxkW2gA4Qz/G5Xuho78KjeFco8uyLvYAYhXXuZAwsqebMryg?= =?us-ascii?Q?UfpOTmnCn6XNc6+kpf3J7Mcra0H8fbvKef05DsWVf9Bc66CeIgA+TtsTow0X?= =?us-ascii?Q?QsI0dlXqY+wrweELA76PuOo9jYrZW4L8yIBj/2AppEz3RQOXo1dzeKLkeeYT?= =?us-ascii?Q?0gIor/kHykr4hdqzdxf4JrzjWhjhVEf1IHt9BFOw6Q7dVZXmuAoja5TD9RmI?= =?us-ascii?Q?1b55VTtrbKg/rGmOACr971D2ELtBZfKRs4TWmqN3e/hUO1lGhucDYCxn3Pxh?= =?us-ascii?Q?crLj+uijnZWqIPmx2+sYYOou99iRPeM7QPy6zYQBast342cTsWC9sj+kY4HH?= =?us-ascii?Q?zA0/tLycCYBuPn5/O1fgFjRcYknEG15JedG5pgWwbcK+SBxooGhgjLbi4gFc?= =?us-ascii?Q?2qLjF0ldkNfN3LZkajjCSk10MfL9az/jzG6kUD6cywixMNsp3/KGb9z9N9MW?= =?us-ascii?Q?0ybbQx44A0temrnpbdE+w6x68H+0oRqOLUAQeQVWL3VXAEknJEcq14oJOAQA?= =?us-ascii?Q?oXeM1sGNnRtK9eFz9TAio4RJnzHWXKJesGThd35dcZNavPRNVM0jZ9jyz7vS?= =?us-ascii?Q?4ihB+HVnl9s2bfN+x/YS6ObXxEPn9fMDaq1FGsVL7usAkSaZmxyG6LQarlu7?= =?us-ascii?Q?BjYsqJw6iovHAGBkuV8ZEEg4c/26C6pDYx+5R4OoJ58dhiYwDS+ft5ox7HVQ?= =?us-ascii?Q?uheCeeEzBj3k/ijWy4aFdxh65WvYt1YvPMzOVulYw8KaV72r8BbMQMGgFnEu?= =?us-ascii?Q?9lBXEDA5gzqwWTOfBShtAXmnUXQq047AfV2exKDuCJGUYQkzRRKPLJ2WeDrb?= =?us-ascii?Q?cFe8ds+gxTK0ejHrof8wwjTUbm6+yOJw8vvnSbw2+YWZj5DOeZRNO+qkPsPf?= =?us-ascii?Q?vrq2kIU83+l1X6aTNuvkVw9TR3F/5G+65qGw9t1L9keaSt+bi92hScYO5kRd?= =?us-ascii?Q?f41reZ0OZZanlP3uV/9UooiFKje3WpY2+QZihP780OA/WL8nzLsRfBs2sw5o?= X-MS-Exchange-AntiSpam-MessageData-1: h1h4a7WScOKwyw== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 0b33c870-dc8a-48a6-2896-08dee67c2547 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2026 16:30:00.9801 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J1ZI9mV6TPw4QtazQbWtfaw0CwHY/E3pNOiLLCsdvS/ilOZd08chY0b04Rzbqc0RkBWpoDPWjLQuOA5vf5Gmnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS9P286MB6790 X-purgate-ID: tlsNG-bad1c0/1784565005-3A0C5034-6CE9F79A/0/0 X-purgate-type: clean X-purgate-size: 22035 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784565035649158500 Content-Type: text/plain; charset="utf-8" Parse the 'cpu-map' node in the Device Tree to extract CPU topology information. If the 'cpu-map' node is absent, fall back to generating the topology data from the NUMA information. This generation assumes exactly one socket per NUMA node and that SMT is unsupported. Signed-off-by: Hirokazu Takahashi Reviewed-by: Jan Beulich # common, acpi --- Changes in v7 - Graceful Fallback & Allocation: * Treated missing topology definitions as benign conditions. * Used xvzalloc_array() for temporary memory allocations during initialization. - Build & Kconfig Adjustments: * Updated Kconfig to use "depends on UNSUPPORTED" instead of "if UNSUPPOR= TED". - Code Cleanups & Style Conformance: * Used designated initializers for structure data initializations. xen/arch/arm/Kconfig | 1 + xen/arch/arm/smpboot.c | 7 + xen/common/Kconfig | 22 ++ xen/common/Makefile | 1 + xen/common/cpu-topology.c | 62 +++++ xen/common/cpu.c | 4 + xen/common/device-tree/Makefile | 1 + xen/common/device-tree/cpu-topology.c | 344 ++++++++++++++++++++++++++ xen/drivers/acpi/Kconfig | 3 + xen/drivers/acpi/Makefile | 1 + xen/drivers/acpi/topology.c | 41 +++ xen/include/xen/acpi.h | 13 + xen/include/xen/cpu-topology.h | 34 +++ xen/include/xen/dt-cpu-topology.h | 35 +++ 14 files changed, 569 insertions(+) create mode 100644 xen/common/cpu-topology.c create mode 100644 xen/common/device-tree/cpu-topology.c create mode 100644 xen/drivers/acpi/topology.c create mode 100644 xen/include/xen/cpu-topology.h create mode 100644 xen/include/xen/dt-cpu-topology.h diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 843a43897e..1e0fd4957e 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -19,6 +19,7 @@ config ARM select HAS_ALTERNATIVE if HAS_VMAP select HAS_DEVICE_TREE_DISCOVERY select HAS_DOM0LESS + select HAS_GENERIC_CPU_TOPOLOGY select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE select HAS_STACK_PROTECTOR select HAS_STATIC_MEMORY diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index ba5fd2dd52..d957553a44 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -9,10 +9,12 @@ =20 #include #include +#include #include #include #include #include +#include #include #include #include @@ -244,6 +246,9 @@ static void __init dt_smp_init_cpus(void) } else tmp_map[i] =3D hwid; + + /* Pass the info to dt_init_cpu_topology() */ + map_cpu_to_dt_node(i, cpu); } =20 if ( !bootcpu_valid ) @@ -280,6 +285,8 @@ void __init smp_init_cpus(void) else acpi_smp_init_cpus(); =20 + init_cpu_topology(); + if ( opt_hmp_unsafe ) warning_add("WARNING: HMP COMPUTING HAS BEEN ENABLED.\n" "It has implications on the security and stability of = the system,\n" diff --git a/xen/common/Kconfig b/xen/common/Kconfig index da80fdba84..29879a9131 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -140,6 +140,9 @@ config HAS_EX_TABLE config HAS_FAST_MULTIPLY bool =20 +config HAS_GENERIC_CPU_TOPOLOGY + bool + config HAS_IOPORTS bool =20 @@ -191,6 +194,25 @@ config VM_EVENT config NEEDS_LIBELF bool =20 +config GENERIC_CPU_TOPOLOGY + bool + +config DT_CPU_TOPOLOGY + bool "Device tree based CPU topology support (UNSUPPORTED)" + depends on HAS_GENERIC_CPU_TOPOLOGY && DEVICE_TREE_PARSE && UNSUPPORTED + select GENERIC_CPU_TOPOLOGY + help + Retrieve CPU topology information from the device tree to optimize + vCPU scheduling. + +config ACPI_CPU_TOPOLOGY + bool "ACPI based CPU topology support (UNSUPPORTED)" + depends on HAS_GENERIC_CPU_TOPOLOGY && ACPI && UNSUPPORTED + select GENERIC_CPU_TOPOLOGY + help + Retrieve CPU topology information from the ACPI PPTT to optimize + vCPU scheduling. + config NUMA bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index 6018e25614..901bb37925 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_GENERIC_BUG_FRAME) +=3D bug.o obj-$(CONFIG_HYPFS_CONFIG) +=3D config_data.o obj-$(CONFIG_CORE_PARKING) +=3D core_parking.o obj-y +=3D cpu.o +obj-$(CONFIG_GENERIC_CPU_TOPOLOGY) +=3D cpu-topology.init.o obj-$(CONFIG_DEBUG_TRACE) +=3D debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) +=3D device.o diff --git a/xen/common/cpu-topology.c b/xen/common/cpu-topology.c new file mode 100644 index 0000000000..3044b50b05 --- /dev/null +++ b/xen/common/cpu-topology.c @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include +#include + +static void __init free_topology_table(void) +{ + unsigned int cpu; + + for ( cpu =3D 0; cpu < nr_cpu_ids; cpu++ ) + { + free_cpumask_var(cpu_topology[cpu].thread_sibling); + free_cpumask_var(cpu_topology[cpu].core_sibling); + free_cpumask_var(cpu_topology[cpu].cluster_sibling); + } + + XVFREE(cpu_topology); +} + +void __init init_cpu_topology(void) +{ + unsigned int cpu; + int ret; + + cpu_topology =3D xvzalloc_array(struct cpu_topology, nr_cpu_ids); + if ( !cpu_topology ) + return; + + for ( cpu =3D 0; cpu < nr_cpu_ids; cpu++ ) + { + if ( !zalloc_cpumask_var(&cpu_topology[cpu].thread_sibling) + || !zalloc_cpumask_var(&cpu_topology[cpu].core_sibling) + || !zalloc_cpumask_var(&cpu_topology[cpu].cluster_sibling) ) + { + free_topology_table(); + return; + } + } + + if ( acpi_disabled ) + ret =3D dt_init_cpu_topology(); + else + ret =3D acpi_init_cpu_topology(); + + /* Free the CPU topology table if initialization fails. */ + if ( ret !=3D 0 ) + free_topology_table(); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/common/cpu.c b/xen/common/cpu.c index f09af0444b..a8ebcb5146 100644 --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -46,6 +46,10 @@ const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS= _TO_LONGS(NR_CPUS)] =3D { #undef MASK_DECLARE_2 #undef MASK_DECLARE_1 =20 +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY +struct cpu_topology *__ro_after_init cpu_topology; +#endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ + static DEFINE_RWLOCK(cpu_add_remove_lock); =20 bool get_cpu_maps(void) diff --git a/xen/common/device-tree/Makefile b/xen/common/device-tree/Makef= ile index 9036e455d6..6ee670b5f4 100644 --- a/xen/common/device-tree/Makefile +++ b/xen/common/device-tree/Makefile @@ -1,6 +1,7 @@ obj-y +=3D bootfdt.init.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D bootinfo-fdt.init.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D bootinfo.init.o +obj-$(CONFIG_DT_CPU_TOPOLOGY) +=3D cpu-topology.init.o obj-y +=3D device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) +=3D domain-build.init.o obj-$(filter $(CONFIG_DOM0LESS_BOOT),$(CONFIG_HAS_DEVICE_TREE_DISCOVERY)) = +=3D dom0less-build.init.o diff --git a/xen/common/device-tree/cpu-topology.c b/xen/common/device-tree= /cpu-topology.c new file mode 100644 index 0000000000..9259be73bc --- /dev/null +++ b/xen/common/device-tree/cpu-topology.c @@ -0,0 +1,344 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Derived from Linux kernel 7.0's $drivers/base/arch_topology.c + * Parse cpu topology information. + */ + +#include +#include +#include +#include +#include +#include + +#define INVALID_TOPO_ID (~0U) + +struct cpu_map { + unsigned int thread_id; + unsigned int core_id; + unsigned int cluster_id; + unsigned int package_id; +}; + +static struct cpu_map __initdata cpu_map[NR_CPUS] =3D { + [0 ... NR_CPUS - 1] =3D { + .thread_id =3D INVALID_TOPO_ID, + .core_id =3D INVALID_TOPO_ID, + .cluster_id =3D INVALID_TOPO_ID, + .package_id =3D INVALID_TOPO_ID, + }, +}; +static struct dt_device_node *__initdata dt_cpu_table[NR_CPUS]; + +static void __init setup_siblings_masks(unsigned int target_cpu) +{ + const struct cpu_topology *target_topo =3D &cpu_topology[target_cpu]; + const struct cpu_map *target_map =3D &cpu_map[target_cpu]; + unsigned int cpu; + + /* Update cluster, core and thread sibling masks */ + for_each_possible_cpu(cpu) + { + const struct cpu_topology *cpu_topo =3D &cpu_topology[cpu]; + const struct cpu_map *map =3D &cpu_map[cpu]; + + if ( target_cpu > cpu ) + continue; + + if ( target_map->package_id !=3D map->package_id ) + continue; + + cpumask_set_cpu(target_cpu, cpu_topo->core_sibling); + cpumask_set_cpu(cpu, target_topo->core_sibling); + + if ( target_map->cluster_id !=3D map->cluster_id ) + continue; + + if ( target_map->cluster_id !=3D INVALID_TOPO_ID ) + { + cpumask_set_cpu(target_cpu, cpu_topo->cluster_sibling); + cpumask_set_cpu(cpu, target_topo->cluster_sibling); + } + + if ( target_map->core_id !=3D map->core_id ) + continue; + + cpumask_set_cpu(target_cpu, cpu_topo->thread_sibling); + cpumask_set_cpu(cpu, target_topo->thread_sibling); + } +} + +static const struct dt_device_node *__init dt_find_child_node_by_name( + const struct dt_device_node *dt, + const char *name) +{ + const struct dt_device_node *np; + + dt_for_each_child_node(dt, np) + if ( np->name && (dt_node_cmp(np->name, name) =3D=3D 0) ) + return np; + + return NULL; +} + +void __init map_cpu_to_dt_node(unsigned int cpu, + struct dt_device_node *cpu_node) +{ + if ( cpu < ARRAY_SIZE(dt_cpu_table) ) + dt_cpu_table[cpu] =3D cpu_node; + else + printk(XENLOG_WARNING + "cpu %u exceeds the max cpus %zu\n", + cpu, ARRAY_SIZE(dt_cpu_table)); +} + +static unsigned int __init cpu_node_to_id( + const struct dt_device_node *cpu_node) +{ + unsigned int cpu; + + for_each_possible_cpu(cpu) + if ( cpu_node =3D=3D dt_cpu_table[cpu] ) + return cpu; + + return INVALID_TOPO_ID; +} + +/* + * This function returns the Xen cpu number of the DT node. + */ +static unsigned int __init get_cpu_for_node( + const struct dt_device_node *dt_node) +{ + const struct dt_device_node *cpu_node =3D + dt_parse_phandle(dt_node, "cpu", 0); + + if ( !cpu_node ) + return INVALID_TOPO_ID; + + return cpu_node_to_id(cpu_node); +} + +static int __init parse_core(const struct dt_device_node *core, + unsigned int package_id, + unsigned int cluster_id, + unsigned int core_id) +{ + bool leaf =3D true; + unsigned int thread_id; + unsigned int cpu; + + for ( thread_id =3D 0; ; thread_id++ ) + { + const struct dt_device_node *thread; + char name[20]; + + snprintf(name, sizeof(name), "thread%u", thread_id); + thread =3D dt_find_child_node_by_name(core, name); + + if ( !thread ) + break; + + leaf =3D false; + cpu =3D get_cpu_for_node(thread); + + if ( cpu =3D=3D INVALID_TOPO_ID ) + { + printk(XENLOG_ERR + "ERROR: %s: Can't get CPU for thread\n", dt_node_name(t= hread)); + return -EINVAL; + } + + ASSERT(cpu_map[cpu].package_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].cluster_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].core_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].thread_id =3D=3D INVALID_TOPO_ID); + + cpu_map[cpu].package_id =3D package_id; + cpu_map[cpu].cluster_id =3D cluster_id; + cpu_map[cpu].core_id =3D core_id; + cpu_map[cpu].thread_id =3D thread_id; + } + + cpu =3D get_cpu_for_node(core); + + if ( cpu !=3D INVALID_TOPO_ID ) + { + if ( !leaf ) + { + printk(XENLOG_ERR "ERROR: %s: Core has both threads and CPU\n", + dt_node_name(core)); + return -EINVAL; + } + + ASSERT(cpu_map[cpu].package_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].cluster_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].core_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].thread_id =3D=3D INVALID_TOPO_ID); + + cpu_map[cpu].package_id =3D package_id; + cpu_map[cpu].cluster_id =3D cluster_id; + cpu_map[cpu].core_id =3D core_id; + cpu_map[cpu].thread_id =3D 0; + } + else if ( leaf ) + { + printk(XENLOG_ERR + "ERROR: %s: Can't get CPU for leaf core\n", dt_node_name(co= re)); + return -EINVAL; + } + + return 0; +} + +static int __init parse_cluster(const struct dt_device_node *cluster, + unsigned int package_id, + unsigned int cluster_id, + unsigned int depth) +{ + bool leaf =3D true; + bool has_cores =3D false; + unsigned int core_id; + unsigned int child_cluster_id; + + /* + * First check for child clusters; we currently ignore any + * information about the nesting of clusters and present the + * scheduler with a flat list of them. + */ + for ( child_cluster_id =3D 0; ; child_cluster_id++ ) + { + const struct dt_device_node *child_cluster; + char name[20]; + int ret; + + snprintf(name, sizeof(name), "cluster%u", child_cluster_id); + child_cluster =3D dt_find_child_node_by_name(cluster, name); + + if ( !child_cluster ) + break; + + leaf =3D false; + ret =3D parse_cluster(child_cluster, package_id, child_cluster_id, + depth + 1); + if ( depth > 0 ) + printk(XENLOG_WARNING + "WARNING: Topology for clusters of clusters not yet sup= ported\n"); + if ( ret !=3D 0 ) + return ret; + } + + /* Now check for cores */ + for ( core_id =3D 0; ; core_id++ ) + { + const struct dt_device_node *core; + char name[20]; + int ret; + + snprintf(name, sizeof(name), "core%u", core_id); + core =3D dt_find_child_node_by_name(cluster, name); + + if ( !core ) + break; + + has_cores =3D true; + + if ( depth =3D=3D 0 ) + { + printk(XENLOG_ERR + "ERROR: %s: cpu-map children should be clusters\n", + dt_node_name(core)); + return -EINVAL; + } + + if ( leaf ) + { + ret =3D parse_core(core, package_id, cluster_id, core_id); + if ( ret !=3D 0 ) + return ret; + } + else + { + printk(XENLOG_ERR "ERROR: %s: Non-leaf cluster with core %s\n", + dt_node_name(cluster), name); + return -EINVAL; + } + } + + if ( leaf && !has_cores ) + printk(XENLOG_WARNING "WARNING: %s: empty cluster\n", + dt_node_name(cluster)); + + return 0; +} + +static int __init parse_socket(const struct dt_device_node *socket) +{ + bool has_socket =3D false; + unsigned int package_id; + int ret; + + for ( package_id =3D 0; ; package_id++ ) + { + const struct dt_device_node *cluster; + char name[20]; + + snprintf(name, sizeof(name), "socket%u", package_id); + cluster =3D dt_find_child_node_by_name(socket, name); + + if ( !cluster ) + break; + + has_socket =3D true; + ret =3D parse_cluster(cluster, package_id, INVALID_TOPO_ID, 0); + if ( ret !=3D 0 ) + return ret; + } + + if ( !has_socket ) + ret =3D parse_cluster(socket, 0, INVALID_TOPO_ID, 0); + + return ret; +} + +static int __init parse_dt_topology(void) +{ + const struct dt_device_node *cpus; + const struct dt_device_node *map; + + cpus =3D dt_find_node_by_path("/cpus"); + if ( !cpus ) + return -ENOENT; + + map =3D dt_find_child_node_by_name(cpus, "cpu-map"); + if ( !map ) + return -ENOENT; + + return parse_socket(map); +} + +int __init dt_init_cpu_topology(void) +{ + unsigned int cpu; + int ret; + + BUG_ON(!acpi_disabled); + BUG_ON(!cpu_topology); + + ret =3D parse_dt_topology(); + if ( ret =3D=3D 0 ) + for_each_possible_cpu(cpu) + setup_siblings_masks(cpu); + + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/drivers/acpi/Kconfig b/xen/drivers/acpi/Kconfig index e3f3d8f4b1..ef0b9a4502 100644 --- a/xen/drivers/acpi/Kconfig +++ b/xen/drivers/acpi/Kconfig @@ -2,6 +2,9 @@ config ACPI bool =20 +config ACPI_CPU_TOPOLOGY + bool + config ACPI_LEGACY_TABLES_LOOKUP bool =20 diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile index 477408afbe..6d676e91d4 100644 --- a/xen/drivers/acpi/Makefile +++ b/xen/drivers/acpi/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_ACPI_NUMA) +=3D numa.o obj-y +=3D osl.o obj-$(CONFIG_PM_STATS) +=3D pmstat.o obj-$(CONFIG_PM_OP) +=3D pm-op.o +obj-$(CONFIG_ACPI_CPU_TOPOLOGY) +=3D topology.init.o =20 obj-$(CONFIG_X86) +=3D hwregs.o obj-$(CONFIG_X86) +=3D reboot.o diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c new file mode 100644 index 0000000000..45d1f2c5be --- /dev/null +++ b/xen/drivers/acpi/topology.c @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +/* + * TODO: Populate the topology information by scanning the ACPI + * PPTT (Processor Properties Topology Table). + */ +int __init acpi_init_cpu_topology(void) +{ + unsigned int cpu; + + /* + * Generate temporary cpu topology information for now. + * It assumes that the cpu doesn't have SMT and all CPUs + * belong to the same socket. + */ + for_each_possible_cpu(cpu) + { + struct cpu_topology *topo =3D &cpu_topology[cpu]; + + cpumask_set_cpu(cpu, topo->thread_sibling); + cpumask_copy(topo->core_sibling, &cpu_possible_map); + cpumask_copy(topo->cluster_sibling, &cpu_possible_map); + } + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 2fdf38cf74..cbb02e0f35 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -135,6 +135,19 @@ static inline int acpi_boot_table_init(void) =20 #endif /*!CONFIG_ACPI*/ =20 +#ifdef CONFIG_ACPI_CPU_TOPOLOGY + +int acpi_init_cpu_topology(void); + +#else /* CONFIG_ACPI_CPU_TOPOLOGY */ + +static inline int acpi_init_cpu_topology(void) +{ + return -EOPNOTSUPP; +} + +#endif /* CONFIG_ACPI_CPU_TOPOLOGY */ + int get_cpu_id(u32 acpi_id); =20 unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_l= ow); diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h new file mode 100644 index 0000000000..7cfe3752cd --- /dev/null +++ b/xen/include/xen/cpu-topology.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_CPU_TOPOLOGY_H +#define XEN_CPU_TOPOLOGY_H + +#include + +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY + +struct cpu_topology { + cpumask_var_t thread_sibling; + cpumask_var_t core_sibling; + cpumask_var_t cluster_sibling; +}; + +extern struct cpu_topology *cpu_topology; +void init_cpu_topology(void); + +#else /* CONFIG_GENERIC_CPU_TOPOLOGY */ + +static inline void init_cpu_topology(void) {} + +#endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ + +#endif /* XEN_CPU_TOPOLOGY_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/dt-cpu-topology.h b/xen/include/xen/dt-cpu-top= ology.h new file mode 100644 index 0000000000..72b35b3cf2 --- /dev/null +++ b/xen/include/xen/dt-cpu-topology.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_DT_CPU_TOPOLOGY_H +#define XEN_DT_CPU_TOPOLOGY_H + +#include + +struct dt_device_node; + +#ifdef CONFIG_DT_CPU_TOPOLOGY + +void map_cpu_to_dt_node(unsigned int cpu, struct dt_device_node *cpu_node); +int dt_init_cpu_topology(void); + +#else /* CONFIG_DT_CPU_TOPOLOGY */ + +static inline void map_cpu_to_dt_node(unsigned int cpu, + struct dt_device_node *cpu_node) {} +static inline int dt_init_cpu_topology(void) +{ + return -EOPNOTSUPP; +} + +#endif /* CONFIG_DT_CPU_TOPOLOGY */ + +#endif /* XEN_DT_CPU_TOPOLOGY_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.43.0 From nobody Thu Jul 23 21:13:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1784565028; cv=pass; d=zohomail.com; s=zohoarc; b=itnL7phoQDBshFuI8VMLet1VjV40Q/bbHPzp9/VSq2g81F5vcbIpAJ5EbFQb0XyeRAwnhcFw5UbXsYAYQj7v5zoV+LDtU4F2kftbSqtsSclYmlyxltYzzM2+UBGNiGYCb1M60awU3vhBXX613yHhLJq+T2HdfeTag+BOuX7jnDs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784565028; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uCCcHwj5j73NphvC+8hyMO1PCrHZUjrJVgvBh+/mJyc=; b=ZboEL5Y7pdUXQ3qWhJb93g67zVcePR4Uia8U0tG8kd4AS8xl4RXmjpi65JwwewZcN6Wc5hc6Acro6qqAcaRGDOWfFbpwu2P19QD8g3vZ3RmJ1g3BEbty79Znjna3MdVWEDwpo7ibrKJWj/AxFpzaauaTCbwbnRx6RZnXwK4FpPg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784565028035334.02936104305047; Mon, 20 Jul 2026 09:30:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367302.1617113 (Exim 4.92) (envelope-from ) id 1wlqsf-0007GG-Dt; Mon, 20 Jul 2026 16:30:13 +0000 Received: by outflank-mailman (output) from mailman id 1367302.1617113; Mon, 20 Jul 2026 16:30:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsf-0007G2-9m; Mon, 20 Jul 2026 16:30:13 +0000 Received: by outflank-mailman (input) for mailman id 1367302; Mon, 20 Jul 2026 16:30:11 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsd-0007EE-D4 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:30:11 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqsc-007jXT-Py for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:30:10 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4d09-e002-0a2a0a5209dd-0a2a450187c2-16 for ; Mon, 20 Jul 2026 18:30:10 +0200 Received: from [52.101.229.80] (helo=TY3P286CU002.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4d0f-5984-0a2a45010019-3465e5506d27-3 for ; Mon, 20 Jul 2026 18:30:09 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OS9P286MB6790.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:419::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Mon, 20 Jul 2026 16:30:05 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0223.017; Mon, 20 Jul 2026 16:30:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j/jxnySjlWSVeSpB5iaDAtlsQvHV+A9F7sCDhwc/Go86/f0Fin9MjqQ1NM7zN9qVJjWhuMRBqgcaXExjrsIecrHR1Zc2vS6WZ4klZFRC6XUDg+Sb3k6ptocyO5yCRS+z/Tm3zoVjXlyE/qr7d98Xwd1LAYXDIp+snAP2n8H4TGhsqoWptPFsp83kiBzx1891WORniwPUL1QkmuBwpsfZUwt5BlD3KADcIVbmdoEDJNdXEmRPuI8Ez+xpTDD9VtZ+bEZOM1yRESdn4NkyJe7qvWyckFPLXqwZnwwZBdwk2fO/7jpoOeAGzuoFeGBuWjrVTm/PD13Y4jTuGkD/xEdBtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uCCcHwj5j73NphvC+8hyMO1PCrHZUjrJVgvBh+/mJyc=; b=U56kOPLO4zA0dinzvCD9AZ/bTYSAnpbgym0X2Iqx1p/tzELxZkSGsI65SXFGwk81T5fIhoCezPbaCpiqo7fmaHlWD1VdHmCOoApJvgI5BbxEVLEjHvCek1Mg2ueJ8d3mgRlVtpKv3NeFIbmfnvkjY3fLTjVLEu15aiLwyerMXBK+EKIul9Z1+HtMEQC07S/7DAMI9bPKzSD996nXic+Byo5odUB0VS7/anIvRMVy46tx1Ym5qdi/T07XkKQLEArq11LyWvoV+nOYzEVA/G5uInm40ah1afs462MztXhrDv7IDBe2iGeFgx/rWWoyymljj6m6s0azVvkYwjLHJNAvjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uCCcHwj5j73NphvC+8hyMO1PCrHZUjrJVgvBh+/mJyc=; b=jucDGp/Cj4Mzx1x6QT3rainBPVCnnT8mEg1XlvHqzthXhOh5phW4Fl2SvA6yP2boIMxk3kXvgHakvAHyja9aB2b3NWawj38u+Aq8qaUIyPhbUZN/KIhZr1ORVW4OPWci5VGZb4U01gLyju+Z5pn+90mwyW7Wr7qM76qvX8142No= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Mykyta_Poturai@epam.com, Hirokazu Takahashi , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Timothy Pearson , Alistair Francis , Connor Davis , Oleksii Kurochko , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v7 2/5] xen/sched: Link CPU topology to scheduler Date: Tue, 21 Jul 2026 01:28:16 +0900 Message-ID: <20260720162819.308326-3-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720162819.308326-1-taka@valinux.co.jp> References: <20260720162819.308326-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY6P301CA0041.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:3ba::10) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OS9P286MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 17c77247-d7d6-45aa-189e-08dee67c27bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|10070799003|7416014|376014|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: IWLdo8J4YZStqd1gGDGBLLsyqAg/WRzlGXPExeUiaUcPm/w1fJb+pjg11MBNUrTfZgyTSTFKQ8HtjMSxRGwlRgojYMDcYWkuBjn9AYzFg4yzVIU2GhFrREU/B3Fbhr3uvo7N0VkO4yAmqx1RDMY1ykudjoe5vMMFuLWcNMKR58Oaph+Y9GnfIcX5YRhGHWJx3ncKqv3tGSuD0xA5pcLcRnfM1tXzxxiQGekYcattqEOMbpXdsPcXhqQDpIvIjsDxsRJoyGDokDY3WfSapGiC161NZLy1dd/qETO6k2e31KpMUrJijf37D9ieHzRfY34sANr76WwlSQVEjVlFTApRHy8puPT1HDK+151ir/3D2MwyqaI6cL5zRm7eZGNh/k9FVj1Jpuwp2fPMoTWds8tky38pxsPQZmkCWR4iHDe7HSWrEQgMIhxtHwWiByHJgqiK8ddldJJarOx00lLHYED+cEkSu7w2ssI6Gg5j9H6GTjRA365cCcRuAWm4UjO0rL/r1wiTAn7jpwxv9O4dXKAvC4KS0RrFC0DPXpjNCssBsn2MlOBCSlrYW4vUxLyGhBQkvTqdHkn7FNy4r8F6GpBl7sWqx0PVni0DoyXJCzO4JYn3hOrqMqoNYfblwGe/P6ymsUU23OZu2YCXWJ8VgFaWu91uzJK8ABJxSeTRM+gp/Aw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(1800799024)(10070799003)(7416014)(376014)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?m+NUYJpMLbHzCQ6xdww29U+amPLyy5uWacYPZ/43SLY5SG1wbDKpy38jOyoP?= =?us-ascii?Q?pAQl2Xu9cAjBnht/jI0JwrXWd0leWHzHrPqPzSacVP55hvzyXug4Y3/JHlzm?= =?us-ascii?Q?tOjSnhiVv9dnYnHfPBgjhdNvffUN9g/DqwSy73zFi/3KtuvSGGb3KxebU9hZ?= =?us-ascii?Q?hJjrdccAwJ5iZ649QHqfxdRMkA4q1JUyR94heJUNJ1LvHrYrqwEcTnXpClCU?= =?us-ascii?Q?jMLX03C+IVwI4ZsfkZ0y61gxIGkreQUbg4uDv2VbZec/XNuGp/jM/lvvkjQg?= =?us-ascii?Q?RQDnY+D4CvosXw8bZUJwdHAYm92grYnKtB2r8mpnSBJuaU6yhf9Q1Xaxnhk+?= =?us-ascii?Q?M/YQzdHGjnXExskP5BLCSAiUD3bfdv/J9P/E48m7FR0BuqfK+LQPIBhaznKh?= =?us-ascii?Q?q7VMpGUrm28iEaWnPSCE7/3aHGflDZsTYQ30UIHAkQHU5qcYrxIHgHPmukAD?= =?us-ascii?Q?Fc06neqrblhgg11RzZTkUMGZkJ0wwj1AL2bgNDrxvcNVbpLjjt6tT5eUGj1F?= =?us-ascii?Q?NZm/JS3rMEzfRgpzoTp1QysBfajhYIl5se2df2xjkvjSUgqsxL3+cpo+nz6p?= =?us-ascii?Q?bLw0x6RNBXyCC4uyHnW1lMEqKsuKEu9fV07JGsHlkiyTw7eNdsS+G4pojrld?= =?us-ascii?Q?AgZrePFHJ6uoVnyveyEKFVbuOvuYaMDSyak8BS6VyC0w+Y67ov3uI8rVld2p?= =?us-ascii?Q?K9KI0EYG5gNG6j3d01n5eHKASz4+iUeGK6Wgj51n2rWUvSKFh9eaeL23qN5K?= =?us-ascii?Q?qL3yGZMxXb5Lagku0fpXBWZtZSoSZNrXXkIYRLiB0sadPbHJm+4GauF5sd9a?= =?us-ascii?Q?6WkEoPXDkYjmyXmij6o7SkhKRuYdpKYUH8FAaeJYV8dhYlwCP8MZnTzEs8jf?= =?us-ascii?Q?coCweQe0uZGkS3fVXn3V6ydyA/882ASNzaifXEhogM4IOaU53aIrIF2NE3Do?= =?us-ascii?Q?kpX/D+YzPQ22ApOnLsdMuvc5vEZh/0embus3cBwFaOB0s7XGd5/fwpYbOzeB?= =?us-ascii?Q?VUfUwPv+hIqogXtCnJZ83qbtC218FfpaeWhrxxgsDSWrvGhFtr8zMEcuBl/o?= =?us-ascii?Q?kGAD1yKaX6EPfspjeGgs6EeynFPxIdbHioJlhVxksBYG3bG5pva31rfLqozT?= =?us-ascii?Q?isko4Nwae+WH8SCfJA0e+N03qDLUdrWjBJJ1pmsBGxxXuD5F0mqtVKsmMsnU?= =?us-ascii?Q?Ye+rZTWkK/uqTtsbxOqsO/B3yz+a57FyubwMuKYR7YRPBM8Qo3Phl/fLNhcO?= =?us-ascii?Q?VRPFsPXcQPUKXgbUvgoPY4bedU9oX8HzyF8yWDSUsPWREcs9ryG5gc4C0AL/?= =?us-ascii?Q?1rVlLgZJgbHGFEH2ZbeCIYiQ2cGoaDagN8wHvHHNBIskPAATOfSzCd95bsh6?= =?us-ascii?Q?ZVDn9npQYdvcMEbTe99GbLmObaSgGF3zhOoBSocPrXdukqoW4tkcGX8g575w?= =?us-ascii?Q?AEW8//QzgWiQHLu19r4R7yAT7/E9l9JaaToe/+igAR+GkJFtHkZaIKyC38By?= =?us-ascii?Q?ifnh7suC6h394dssgyRaWntOyKzI5RqjUJ6cuzdi2qZqdQ/UUEqLSqJU9T8P?= =?us-ascii?Q?o4npkg4ox71stmCc85hfdQizbHbfyYgGCdxNvXgB2+GIm6HqNAiHp+2BFIPa?= =?us-ascii?Q?Ouv5fy7PUNhavYEZxI/BXgk/0HMFZ+fpwuH61f0OaBNg8C/Nrjwswh5bhqiV?= =?us-ascii?Q?fNxYSdregF+Y5o1KvJIutA8YScdI8UrGb1A7yyQ2lmUKvCi9H9uaIXuccsI6?= =?us-ascii?Q?ieigLxl2DHS7BojlqAPk/aqagV1ZKSh3nyh63YIVvyTQDywLsnt4IIWrTU8G?= X-MS-Exchange-AntiSpam-MessageData-1: Fu9vze8lAAKMig== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 17c77247-d7d6-45aa-189e-08dee67c27bb X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2026 16:30:05.1050 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cOQ0yqd7d2eBAScEZDYhnMvclQYsR1GhGejBM1cL1Qjns7MQqmstq68P99sFj5BF2pMsYxVDbqWJPGLUIrIQwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS9P286MB6790 X-purgate-ID: tlsNG-d62444/1784565010-1DA7E757-EE4CDF83/0/0 X-purgate-type: clean X-purgate-size: 9052 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784565029482158500 Content-Type: text/plain; charset="utf-8" Make CPU topology information available to the Xen scheduler. Additionally, ensure that this topology information is displayed when executing the 'xl info -n' command. Signed-off-by: Hirokazu Takahashi Acked-by: Jan Beulich Reviewed-by: Juergen Gross # scheduler part --- Changes in v7: - Code Cleanups & Style Conformance: * Consolidated topology helpers with IS_ENABLED(). xen/arch/arm/include/asm/processor.h | 4 -- xen/arch/arm/smpboot.c | 8 +--- xen/arch/ppc/include/asm/processor.h | 4 -- xen/arch/riscv/include/asm/processor.h | 4 -- xen/common/device-tree/cpu-topology.c | 65 ++++++++++++++++++++++++++ xen/common/sched/credit2.c | 6 +++ xen/common/sysctl.c | 1 + xen/drivers/acpi/topology.c | 3 ++ xen/include/xen/cpu-topology.h | 39 +++++++++++++++- 9 files changed, 114 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/as= m/processor.h index a3753c317f..41fa73cfc4 100644 --- a/xen/arch/arm/include/asm/processor.h +++ b/xen/arch/arm/include/asm/processor.h @@ -613,10 +613,6 @@ void show_stack(const struct cpu_user_regs *regs); =20 #define cpu_relax() barrier() /* Could yield? */ =20 -/* All a bit UP for the moment */ -#define cpu_to_core(_cpu) (0) -#define cpu_to_socket(_cpu) (0) - struct vcpu; void vcpu_regs_hyp_to_user(const struct vcpu *vcpu, struct vcpu_guest_core_regs *regs); diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index d957553a44..88b01bcfd2 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -92,13 +92,7 @@ static int setup_cpu_sibling_map(int cpu) !zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) ) return -ENOMEM; =20 - /* - * Currently we assume there is no multithread and NUMA, so - * a CPU is a sibling with itself, and the all possible CPUs - * are supposed to belong to the same socket (NUMA node). - */ - cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); - cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map); + init_cpu_sibling_map(cpu); =20 return 0; } diff --git a/xen/arch/ppc/include/asm/processor.h b/xen/arch/ppc/include/as= m/processor.h index 242346cab9..1bf6f6c66c 100644 --- a/xen/arch/ppc/include/asm/processor.h +++ b/xen/arch/ppc/include/asm/processor.h @@ -141,10 +141,6 @@ /* Macro to adjust thread priority for hardware multithreading */ #define HMT_very_low() asm volatile ( "or %r31, %r31, %r31" ) =20 -/* TODO: This isn't correct */ -#define cpu_to_core(cpu) (0) -#define cpu_to_socket(cpu) (0) - /* * User-accessible registers: most of these need to be saved/restored * for every nested Xen invocation. diff --git a/xen/arch/riscv/include/asm/processor.h b/xen/arch/riscv/includ= e/asm/processor.h index 6b89df4a2d..d478ffb76b 100644 --- a/xen/arch/riscv/include/asm/processor.h +++ b/xen/arch/riscv/include/asm/processor.h @@ -54,10 +54,6 @@ struct cpu_user_regs unsigned long pregs; }; =20 -/* TODO: need to implement */ -#define cpu_to_core(cpu) 0 -#define cpu_to_socket(cpu) 0 - static inline void cpu_relax(void) { #ifdef __riscv_zihintpause diff --git a/xen/common/device-tree/cpu-topology.c b/xen/common/device-tree= /cpu-topology.c index 9259be73bc..36560dc228 100644 --- a/xen/common/device-tree/cpu-topology.c +++ b/xen/common/device-tree/cpu-topology.c @@ -317,6 +317,67 @@ static int __init parse_dt_topology(void) return parse_socket(map); } =20 +static void __init setup_cpu_topology_ids(void) +{ + unsigned int cpu; + unsigned int next_core_id =3D 0; + unsigned int next_cluster_id =3D 0; + unsigned int next_socket_id =3D 0; + + for_each_possible_cpu(cpu) + { + unsigned int first_cpu; + struct cpu_topology *topo =3D &cpu_topology[cpu]; + + first_cpu =3D cpumask_first(topo->thread_sibling); + ASSERT(first_cpu < nr_cpu_ids); + + if ( first_cpu =3D=3D cpu ) + { + topo->phys_core_id =3D next_core_id; + next_core_id++; + } + else + { + topo->phys_core_id =3D cpu_topology[first_cpu].phys_core_id; + } + + first_cpu =3D cpumask_first(topo->cluster_sibling); + if ( first_cpu >=3D nr_cpu_ids ) + { + /* Clustering is not supported */ + topo->phys_cluster_id =3D 0; + } + else + { + if ( first_cpu =3D=3D cpu ) + { + topo->phys_cluster_id =3D next_cluster_id; + next_cluster_id++; + } + else + { + topo->phys_cluster_id =3D cpu_topology[first_cpu].phys_clu= ster_id; + } + } + + first_cpu =3D cpumask_first(topo->core_sibling); + ASSERT(first_cpu < nr_cpu_ids); + + if ( first_cpu =3D=3D cpu ) + { + topo->phys_socket_id =3D next_socket_id; + next_socket_id++; + } + else + { + topo->phys_socket_id =3D cpu_topology[first_cpu].phys_socket_i= d; + } + + topo->num_siblings =3D cpumask_weight(topo->thread_sibling); + } +} + int __init dt_init_cpu_topology(void) { unsigned int cpu; @@ -327,9 +388,13 @@ int __init dt_init_cpu_topology(void) =20 ret =3D parse_dt_topology(); if ( ret =3D=3D 0 ) + { for_each_possible_cpu(cpu) setup_siblings_masks(cpu); =20 + setup_cpu_topology_ids(); + } + return ret; } =20 diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index 95946634d1..b4a3b59601 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -9,6 +9,7 @@ * Based on an earlier verson by Emmanuel Ackaouy. */ =20 +#include #include #include #include @@ -35,6 +36,11 @@ */ static unsigned int cpu_nr_siblings(unsigned int cpu) { +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY + if ( cpu_topology ) + return cpu_topology[cpu].num_siblings; +#endif + #ifdef CONFIG_X86 return cpu_data[cpu].x86_num_siblings; #else diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 5207664252..81a68fe24c 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c index 45d1f2c5be..56fcfa4945 100644 --- a/xen/drivers/acpi/topology.c +++ b/xen/drivers/acpi/topology.c @@ -22,6 +22,9 @@ int __init acpi_init_cpu_topology(void) { struct cpu_topology *topo =3D &cpu_topology[cpu]; =20 + topo->phys_core_id =3D cpu; + topo->num_siblings =3D 1; + cpumask_set_cpu(cpu, topo->thread_sibling); cpumask_copy(topo->core_sibling, &cpu_possible_map); cpumask_copy(topo->cluster_sibling, &cpu_possible_map); diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h index 7cfe3752cd..52ee93d4d0 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -4,22 +4,59 @@ #define XEN_CPU_TOPOLOGY_H =20 #include +#include =20 -#ifdef CONFIG_GENERIC_CPU_TOPOLOGY +#include +#include =20 struct cpu_topology { cpumask_var_t thread_sibling; cpumask_var_t core_sibling; cpumask_var_t cluster_sibling; + unsigned int phys_core_id; + unsigned int phys_cluster_id; + unsigned int phys_socket_id; + unsigned int num_siblings; }; =20 extern struct cpu_topology *cpu_topology; + +static inline void init_cpu_sibling_map(unsigned int cpu) +{ + if ( IS_ENABLED(CONFIG_GENERIC_CPU_TOPOLOGY) && cpu_topology ) + { + cpumask_copy(per_cpu(cpu_sibling_mask, cpu), + cpu_topology[cpu].thread_sibling); + cpumask_copy(per_cpu(cpu_core_mask, cpu), + cpu_topology[cpu].core_sibling); + } + else + { + /* Assume all CPUs reside in the same socket and no threading. */ + cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); + cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map); + } +} + +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY + void init_cpu_topology(void); =20 +#define cpu_to_core(cpu) (cpu_topology ? cpu_topology[cpu].phys_core_id : = 0) +#define cpu_to_socket(cpu) (cpu_topology ? cpu_topology[cpu].phys_socket_i= d : 0) + #else /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 static inline void init_cpu_topology(void) {} =20 +#ifndef cpu_to_core +#define cpu_to_core(cpu) (0) +#endif + +#ifndef cpu_to_socket +#define cpu_to_socket(cpu) (0) +#endif + #endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 #endif /* XEN_CPU_TOPOLOGY_H */ --=20 2.43.0 From nobody Thu Jul 23 21:13:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1784565033; cv=pass; d=zohomail.com; s=zohoarc; b=MGwiDt+aiYnMZSyKcvMLOV0CG6mFY5utwvlnubMpsSfRadFKmKY5V36MS65rWT0RAnB3qqDJgUUhA352uQ0fNHdXTGDzBb3sxN0qtKdUOavhgSNlw4nOESWDumQMOSA8Upeux9HeOQZbqvznra4KzT4k5rBdcZF8KY3oRZLs5bE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784565033; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jhLfULqhN+7J3MRM6JeOSJ5q6A5QUJlf3TY/hwzabv0=; b=gsDK7UTRaGbQLzLJEk0vq9cGL2mKi3Totq3M+eDz2QeEpDtZIIg7dFM0ie1XmpZim3hdAodBva6swxam1twwpbQlK2CXXirXzb+V690D866igiqRnjLQgmsg/EBbJE6Ph11+Rqc73iLyTRCPmbRzmAISE1qTO2g9FDopyDVcH/Y= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784565033699473.87895471363663; Mon, 20 Jul 2026 09:30:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367303.1617122 (Exim 4.92) (envelope-from ) id 1wlqsg-0007Tu-KM; Mon, 20 Jul 2026 16:30:14 +0000 Received: by outflank-mailman (output) from mailman id 1367303.1617122; Mon, 20 Jul 2026 16:30:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsg-0007Te-He; Mon, 20 Jul 2026 16:30:14 +0000 Received: by outflank-mailman (input) for mailman id 1367303; Mon, 20 Jul 2026 16:30:12 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqse-0007Eg-Gz for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:30:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqsd-007jXT-Ty for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:30:11 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4d09-e002-0a2a0a5209dd-0a2a450187c2-20 for ; Mon, 20 Jul 2026 18:30:11 +0200 Received: from [52.101.229.80] (helo=TY3P286CU002.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4d0f-5984-0a2a45010019-3465e5506d27-4 for ; Mon, 20 Jul 2026 18:30:11 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OS9P286MB6790.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:419::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Mon, 20 Jul 2026 16:30:08 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0223.017; Mon, 20 Jul 2026 16:30:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x7by7hG821LZdoFxWp7lSGwtv5Tu6hdmj0jeR/18c9Oi5/7zW+TJW6bFlFa37vwfi3FmPPCP85Yb2FKn7Rs/jPG6ArBDflNrLZcydx4uEjvMxbnquuUogsh+snpU3spyVVtUEuHcuUofoQWIXrkrOw3jEVqPqYEvnu9ZXvBEluSj2JpppirSp8CHelAnUqrauPFdShfQ/aRy5njX4dqADkibH1/VYkxRCVSW5NSEeUmwCBvk2P46YPDp6frS6oVSdTq3C4mmzbGo9KcoAOl50H4qAem4CrPje9stgu4/v6ewwIIytM61PEwasZ9M3EfBz+RQxM2F3ihbruNNTIvFsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jhLfULqhN+7J3MRM6JeOSJ5q6A5QUJlf3TY/hwzabv0=; b=rVm1LL4Et5gVEr+621lPve/v80uP8XhbVALG2bDKzv8aAH0Jt2V47iWnqwqtPCQc6CES7OPRVCMmPR4RsZkbu0lDem3RnvbtdR8k3oRsVJFM2fyjHd5mgHvJStN16WX2mphzxRghVvEE2j+S1mbxnIS4TQ/k1DzUf75gkd1oBgNaV2r52sKmuqZJCzGkZv2+PdxNjClmgHScWMVMzcpeyom3EEVjKF1ZGReLTdVGNBL3XWZ539wGasNjbs+OcU6BAL7x8fBMOUAierqchgcaAV0NFSxuD0mllzGMf/KRGV/5UUnYeND5PKlRhKZ6oaj68ivxyrBh+gh5TA/m5BmrHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jhLfULqhN+7J3MRM6JeOSJ5q6A5QUJlf3TY/hwzabv0=; b=UCBPuoKm+AWEOnGAAQW9qkF6Wcap1sJdCICdZXlkdM8iNFKiSItjLnXqa/Eh78TpuyCuGJKW9YRvstWfSwsCYiVsL6cMWyZS/jTRxVAxReBYWmlryPWgCgKlrIc4hDePmEQ62XUoJhgvbgq7ciYTavxlf/NefvzVvaDrMlOe7zg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Mykyta_Poturai@epam.com, Hirokazu Takahashi , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v7 3/5] xen/sched: Make cpu_nr_siblings() architecture-specific Date: Tue, 21 Jul 2026 01:28:17 +0900 Message-ID: <20260720162819.308326-4-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720162819.308326-1-taka@valinux.co.jp> References: <20260720162819.308326-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY6P301CA0029.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:3ba::19) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OS9P286MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: d86b5ac2-1559-495e-c332-08dee67c298b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|10070799003|7416014|376014|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: J2LHrutS6Bx2S7nJ6o/IoNQ7flo+j+JjPpMXrb72ht+fW83pahgzGngkfarcvkZwm5ilafvPKhIot4XqUdyA/cjTUp36YWS9UWryEnzsvkWwyx8arGmBwZbiWtpWjqf6nHbSB/HfbgX9wKi63s/InWupzqyNg1gajzRQBvc1IOCnVu/SK4/dQbr0a8ZdP2MH8vo3fJeEAbFkgaBqmf2YL+RXwauv2JG8yUrPJ1K7e60p6wTt8QPPSwYX7SmTbhUvsWySKN2gvaOfXsUXjRYW8HipEJOE9rZw6I4AEnjliNJiVos1uONUgMp3FWmDWS7zBaHSpRTEZJWWY1Hg6NowHhXXly3Q6DU0p7KYGhCmx1xmfs5mL6yHOtxnW1zNULti/syv63YNssoL8qgeTg93fzmiHHJJMz7tMVtNGtvhnqZX0zN8l4Nfwa07SO3mKRBER41nxfhDXNKhO26JOBrGHl3+S/39Fn+mJeH/MM0IbXJ3xS8ucfMrRSNESt/iHzN1doKIrNpxMNIFrYcOY2B58boElR6pzWWdR9Lu1QT8Vksm/6E4mMtt0DD/2trVRpMz+sT1aAmJlYqb4jQyCz0wefEZ9WTksHQWUzEziEzPLfwbhIZeHJ6AfyawnUo4DyBWX5GyKDEFTxxXGiovb/HoCaKR0t5YisBSNpxkWmYzSzk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(1800799024)(10070799003)(7416014)(376014)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LpenT2uHFJQzqMrosZjrucl5rBJ+ItyQ92E88jYqc5oZ01grRvG3yUBfvypq?= =?us-ascii?Q?aW83e5YiZE14Tky1l9BRTXxrnE6d1wZcK38OfodYW1KyUY8aN5jBMdprfhO4?= =?us-ascii?Q?o7EHiN4uL/GpPFoa2aF8t1E/dbpQ+4+TJ3zu+WkFg2fPWMCByaEFPQzjIUJO?= =?us-ascii?Q?CcdT+9fCPqCpDe9Xm9LPR40jW0wf6D3bDhfSO1nHnqFwVEHmDvMCOW7+Sy99?= =?us-ascii?Q?n5/VuqwZkR7PIEFkulNyJofSddNyFYF10UsuyYLPD+edwoPBx9141Y0tG/2o?= =?us-ascii?Q?Cp8JkvPMq6Agsug6evXn0ZzqdakFSueOIB7w6alXhRRRfrQqtG7l4fJgizCT?= =?us-ascii?Q?4ghCuvdX5XvoZxbezzBrr3//d0qncFEz7YFLUO5b65wB/3extC8+Zc0TfssP?= =?us-ascii?Q?1XWZEauv5o7pK3Gr6nCGgw073/yAphowdYkJUhp2X/BEGnBQehzTFeq1hjQ6?= =?us-ascii?Q?MgAjvYwxuS8OM7DVHQXytUdFKTkczERRPBZtp4iQ+sDhqcgSFW4jwmMIhcn6?= =?us-ascii?Q?Hf7z8O2hXGruEPzhpMpptrO4fvVMr9y/mfWOtPFGU+SYsA7dfkDc/0W1rdVG?= =?us-ascii?Q?AbT6Q4XEQaCe4DPr20N8iyzBxpLMFuoprFrzVmjxScnG+Hfyk/h8fPZkC7MA?= =?us-ascii?Q?/Lke3oaL66uziD00oAnmjvqXKNyPlbTKRdmvPUP0Ybhk1c3b7wcqX6bfLZCh?= =?us-ascii?Q?/b40w/gEyyOhiuI2y4/V/s3QEQx1AAvAlM0Xxoe/B3jqKf+bsm1z66qB0y00?= =?us-ascii?Q?afeoCQAu6JVW3oYgDloJQ2cWUWTfbZz1KIKCwW5yuOz5+44J4oE88FRZpfeb?= =?us-ascii?Q?x3aiFLScjRZHoAlZtj2kU4ZbygTjac97k0/b/RLUOidjxukXdT/s0ueOjw+s?= =?us-ascii?Q?7xzlFIVQzrA9Npln0MAvHeTSr2V7ioGwnRzQKPV26Kmzud+IhayXLOXvw1QU?= =?us-ascii?Q?IyyLw5QzLOGyv83DpgudUvN+tK6rQdfxAbeFd11fshi04Bmm3wUaA8o/pb16?= =?us-ascii?Q?8Byixxb73HaYOzQnSXc0TbNNMXk6BNJh9XuTX6A2HaDBmpNu59vL1I47cLjl?= =?us-ascii?Q?x5SM9Tyz0woRB1RNx5ieBnLMxJhkPQOO6tECltTCpNQGwvkaX3Fq2gVOm2pe?= =?us-ascii?Q?XzPNda8Uovj7IcOKAhKGhg80M1AeF1ow31//vtiS2DdLEJuXPcr+0q9fEV7v?= =?us-ascii?Q?JX0ZqgLlOYBooxz0VZMucRBy3urEaG6kPIxKQUsnwceI4xnxycK8wqEM1+Ue?= =?us-ascii?Q?jc9WDy6S+zC8PuCuaOJ6ASoy3YQkcTaY3aRNjkZxUbnTaj5uBChM+2FSJbml?= =?us-ascii?Q?8eF0oYaQ2peia4kEl8wh8C8NJwdmNcraZfms93/wpbL4C1PTOH9elqfkRyST?= =?us-ascii?Q?/HBC0G7spTbAe+S1QcCIxj++A2npRyPsD8MvXBYnrEWNAkLq539O0m25Hkgx?= =?us-ascii?Q?HaJB9+QkW93LBGarC2QIb6l04EDVEcuWjqHk/rl7viC3bWCO23aAJGbCMI9s?= =?us-ascii?Q?dvc7HY2gh5jogWuIi54tlX5wXafWs7idkoDW6WPNm345dJ/18ehMulqSB1TR?= =?us-ascii?Q?6CmjUWnvHIGxRIJft8RFv2fU47xA/mS1qpvmgbySY42RgYW+Do0QAfdOyL43?= =?us-ascii?Q?O6TZ2PAToULeClcFHDxehpsR9+53DocLf4IXmJMCoJJm2aQf5kLoHSccfb45?= =?us-ascii?Q?eVudlPUZsNmA/QrV6iqn8BeklniY552NkP79AvW0HdSrTbZcvLZgYl1xZaMt?= =?us-ascii?Q?LWFCauCrPqV1c68YboDyQW+ptpgmz8il+gn84HTv7ei5VDl0LVr8CnliDRlZ?= X-MS-Exchange-AntiSpam-MessageData-1: 6dAAD4uF5qlB2Q== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: d86b5ac2-1559-495e-c332-08dee67c298b X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2026 16:30:08.1303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DpfTfm6nZJvMZsypvAYO+gOipArVHrZ3c5zwdZW5G1Or1N/UKfa3rIYBzmxSFBgIfL5jcvBzy5AmJtGAldgyZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS9P286MB6790 X-purgate-ID: tlsNG-d62444/1784565011-BF46D757-60D9F055/0/0 X-purgate-type: clean X-purgate-size: 3372 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784565035631158500 Content-Type: text/plain; charset="utf-8" Make cpu_nr_siblings() an architecture-specific function. This patch provides the implementation for x86 and a common version for Device Tree-based architectures. Signed-off-by: Hirokazu Takahashi Acked-by: Jan Beulich Reviewed-by: Juergen Gross # scheduler part --- xen/arch/x86/include/asm/processor.h | 1 + xen/common/sched/credit2.c | 25 +++---------------------- xen/include/xen/cpu-topology.h | 5 +++++ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/as= m/processor.h index 8ca6799a81..9758060129 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -106,6 +106,7 @@ extern void intel_init_arat(void); =20 #define cpu_to_core(_cpu) (cpu_data[_cpu].cpu_core_id) #define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id) +#define cpu_nr_siblings(_cpu) (cpu_data[_cpu].x86_num_siblings) =20 unsigned int apicid_to_socket(unsigned int apicid); =20 diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index b4a3b59601..6c645f0e21 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -29,25 +29,6 @@ /* #define d2printk printk */ #define d2printk(x...) =20 -/* - * TODO: Abstract this properly, and figure out what Credit2 wants to do w= ith - * the fact that x86_num_siblings doesn't even have the same meaning - * between x86 vendors. - */ -static unsigned int cpu_nr_siblings(unsigned int cpu) -{ -#ifdef CONFIG_GENERIC_CPU_TOPOLOGY - if ( cpu_topology ) - return cpu_topology[cpu].num_siblings; -#endif - -#ifdef CONFIG_X86 - return cpu_data[cpu].x86_num_siblings; -#else - return 1; -#endif -} - /* * Credit2 tracing events ("only" 512 available!). Check * include/public/trace.h for more details. @@ -885,9 +866,9 @@ cpu_runqueue_match(const struct csched2_runqueue_data *= rqd, unsigned int cpu) =20 /* * Additional checks, to avoid separating siblings in different runqueues. - * This deals with both Intel's HTs and AMD's CUs. An arch that does not h= ave - * any similar concept will just have cpu_nr_siblings() always return 1, a= nd - * setup the cpu_sibling_mask-s acordingly (as currently does ARM), and th= ings + * This deals with Intel's HTs, AMD's CUs and ARM's SMT. An arch that + * does not have similar concept will just have cpu_nr_siblings() always + * return 1, and setup the cpu_sibling_mask-s accordingly, and things * will just work as well. */ static bool diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h index 52ee93d4d0..fccc9cd316 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -44,6 +44,7 @@ void init_cpu_topology(void); =20 #define cpu_to_core(cpu) (cpu_topology ? cpu_topology[cpu].phys_core_id : = 0) #define cpu_to_socket(cpu) (cpu_topology ? cpu_topology[cpu].phys_socket_i= d : 0) +#define cpu_nr_siblings(cpu) (cpu_topology ? cpu_topology[cpu].num_sibling= s : 1) =20 #else /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 @@ -57,6 +58,10 @@ static inline void init_cpu_topology(void) {} #define cpu_to_socket(cpu) (0) #endif =20 +#ifndef cpu_nr_siblings +#define cpu_nr_siblings(cpu) (1) +#endif + #endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 #endif /* XEN_CPU_TOPOLOGY_H */ --=20 2.43.0 From nobody Thu Jul 23 21:13:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1784565033; cv=pass; d=zohomail.com; s=zohoarc; b=ip8BmPB6mVL19l6zfHE3mk/RRvFr2gnQ1m9HH16eTpYNhh7kveLAJPqh/pycQ89Gd4TiMjXwK39fgAVw5Iw9UfDuElcvOCrWFh1JmwDpTmsdkJxhMciGBmVUUAF/gFdIWef3eFS8kKWdpOiSfoAeo5mWPHK4fyOXw1g1q6XD5Hw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784565033; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Te1S5GfewIHDdtuLoq1qpch20NJ4D433OHueLW4276E=; b=hUqrTbW6VPowKHubqs9GIf4QHGw3ailAPvQ0pzlyqE9J0ZQBYT6Q/32i9x3fAmoaBNrEeWVSIzOHajmhD3VtCNkjff6E1c9IT5JHlai5UZxQ9U1ytJX17iDAmPxoHOAN4t7cVCfy48NdVS/upNjfhasxAjVtWNJZNShs7L717uw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784565033514608.4746688036355; Mon, 20 Jul 2026 09:30:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367305.1617131 (Exim 4.92) (envelope-from ) id 1wlqsi-0007jg-0o; Mon, 20 Jul 2026 16:30:16 +0000 Received: by outflank-mailman (output) from mailman id 1367305.1617131; Mon, 20 Jul 2026 16:30:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsh-0007jY-Tc; Mon, 20 Jul 2026 16:30:15 +0000 Received: by outflank-mailman (input) for mailman id 1367305; Mon, 20 Jul 2026 16:30:14 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsg-0007To-OS for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:30:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqsg-007jXT-53 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:30:14 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4d09-e002-0a2a0a5209dd-0a2a450187c2-26 for ; Mon, 20 Jul 2026 18:30:13 +0200 Received: from [52.101.229.80] (helo=TY3P286CU002.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4d0f-5984-0a2a45010019-3465e5506d27-5 for ; Mon, 20 Jul 2026 18:30:12 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OS9P286MB6790.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:419::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Mon, 20 Jul 2026 16:30:10 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0223.017; Mon, 20 Jul 2026 16:30:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lrfEpqbuGEVcbeby4HWHCuVJB2grqcNK0hm+WtB6P9z5yON1QRBo5wdiVQe9VpbFhmYDxE2PuTryE7V9JRBSjSf3r+N5WVHComU3EdJuP09NGgpgMDUpG7vLgTVvbI05Kmj8VF7QlxexezY9DovT8KuCGTc0eAdOU3b6BYvT5a/xUVC34SGWu7oUeqF3v5C5eL3h0TsKPS19UJ0SSdbPGD0nq1+xenMaQsxUDfM9GU5hIaYmUXflEiiKilOvT0Z75vd8FwzpIKk4wEQfhX2NDdWgfMghuG/hHQMHUl4mTgQPkyWmQQneAS0n0bPbkLjzA3T6X47bFNrapBRi6hf/Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Te1S5GfewIHDdtuLoq1qpch20NJ4D433OHueLW4276E=; b=UeA4S25f6VSzSnbxjNuO4eJGXyFcDm3LEPVNzKfr5zqffTfXjd7Nwf6RYq7ngEw5aWkYTq9UKNYBXxhuE6fyrkfnZDfq8XC5vYsmOCf9yeiQQqWQkCVXeIKA8C0Rt2MVA22AKOGiJL6ynmNh9t8cwxKRvo8yfV+Dqn/+JIBXQ0p5TjoeKmT7WtiW3d5MJVIRROVVvqxA5DjKyFHPMgX+GkUeI9cYrz7dee0S1PMbrrWemKhiAejwyVhPwMSYfX263GnBp+kaCHjHCVUykqu2CP+dnEYwi+m/TwxAvVDc2XN/NZ0TxMnYVHxvGthq12fLhpZVizeoWm/7q7vnvYe7+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Te1S5GfewIHDdtuLoq1qpch20NJ4D433OHueLW4276E=; b=Jyt7ma+DIhevnQDB9TRAvhuhJezdQTvMD4Tweg+pFBrybjPAAbf61opgLjF0RgSTK0rozLQOS6u8tfS7VhKwku1Vc+e2fKKnrBa0VQlHoOsNdCLuhNQdA1Y17o+L5c6J1gDCRVdgDJ7WBKJpK8WN3/uF/OI8vuC4lfHxy/+Ku1s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Mykyta_Poturai@epam.com, Hirokazu Takahashi , Jan Beulich Subject: [PATCH v7 4/5] xen/acpi: Import PPTT definitions from Linux Date: Tue, 21 Jul 2026 01:28:18 +0900 Message-ID: <20260720162819.308326-5-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720162819.308326-1-taka@valinux.co.jp> References: <20260720162819.308326-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY6P301CA0032.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:3ba::12) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OS9P286MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: e2ac8116-919e-4b9a-e783-08dee67c2af5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|10070799003|376014|3023799007|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 5zE6mXXwA4Q53wu7xZ6WqHsWbkc8/jz8PfP2tZejgyLY+LoKJPUFhACbVPiKJqYiY9WigKtfrB2NNtZ8Vbc09lK/93ssGJqrtwWJ32z64oCnimCWjHailNNApLgrKV8ELGEgqb3W4WvFZl8jHn0GwEr3qDDOlCSzVff52x3pNNVfl93xV+ujEPcXNsavU/NcWp8Fsbb3dq6EnyE0i+MRRD9Xw3d31W683fewtDSL6ddCQV/ZJAS4/dpIGJ74wrWWgKhYXyouxLYJDM3Edg7PyHyFO4i34QPL6WLY3g96CyXgNLe9/7uV1j9IJilZIf4CONwDB+8GwA2+wQCodoF4XCq0csvs4spd/X2y508A2BvEkFjEKYcp4Z7YSgAeB18VsO12kM5MEUm0Yl1yGyu0CATIABJ1sV87ep4Hzvbk7QXbyMqJTkb9Oxtipt4LhwEwGMkj7N7iFp7n/U6tQughOlwsrfbKLen1kXXlEadmjuH71uSSE50VbvWTNauSVgXLmnYzRUUAx6zr6gjU/vy10IpvGUC0wGRjFfD+oPwpfPrtnMX+FwDlexDx/18Xr2+KHTByOVWKewvLoOuG6N9MJ55g3t3cRIUGxG9d0LdZ2jQd5v32ZjXo3eBHAtUDKpGcKoY4C2MUf++7Vw9z6VwY+A6epFwUeUhw6lnjYZYkrrg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(1800799024)(10070799003)(376014)(3023799007)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?XVIcvudajV7egtiTkGuz/A9LoAvT8Y9K18bgGffVKueTa/nHWz491+y7/bxg?= =?us-ascii?Q?ubPVVPX47ABokw8bCbYQxfTGkA/BN+Yuwl3aBXFHWflR02t2MPFNXSPt6I9q?= =?us-ascii?Q?ukOhTHjHlIs4JUGTLI4JSvxASj0MuGy975NAP6K12c0b34k121fk3JUPS/6W?= =?us-ascii?Q?wjKQCXcXW2XkHb2bAD4ArUWNRJe6XTrQuyIMguOfzRa7Wzcq+EorlQj4raxj?= =?us-ascii?Q?2ue4MgraYT+Q1N/IHCJbPRxQAWxnm74ae0cUK/2pq9/rEgOd0x/4cmmy7Qy9?= =?us-ascii?Q?Grfg+YNNdR9xA+iI8+qB7Xf4hwEqxyS6lr+u9w/0nmlU6IyiMQQq8Vzm/WBa?= =?us-ascii?Q?RbOcRCAEqin6clJ5g94uqn0Aa3qZkEpvzzS3YruJV3aIoVNYm3lRYM4RI906?= =?us-ascii?Q?hh5u0XjSwKCMRitv2FXA1eIRE0zbWN57c98jH7K36bOCwU864OETxyEXbGVU?= =?us-ascii?Q?cxFNqpzIDZ/mhzrfPdkBic2vpnQFRWOkjm2JAfTlg7Ixbft1+HejbegM1TDC?= =?us-ascii?Q?kbr9Z4sbPc9RW32sayLSKD7VUqGtI71iKgaz1QnrouMUSm4J9SMj0iRgTraI?= =?us-ascii?Q?YmiOFjJvON+uULbqxOHs9HSTAl98i5VEmORmi0RIfAbxwcd18T1Cj6QFdl8H?= =?us-ascii?Q?BXHrRWPdxsT2dJsxPqluoEpsIoawCKhshRaYVR9mnF4zgVnPegLjPhqhn9Og?= =?us-ascii?Q?jn7i4vjObahtw1i8TVhPvffm9eZlJjp5IHKn27N8MLnXc0AouYNa+sEr1wCm?= =?us-ascii?Q?bDemp3ZChj3nDY7fJEwfj+X9CUpzNIiMWMxGmsvcE8c3j45e6lxeYEin3Lom?= =?us-ascii?Q?Lff58SZjKSkU6HI4ah8d0BYxD+6bV4NENehWOA3qQSyBd43IyQPhQI7LSIBB?= =?us-ascii?Q?N8qeCEjU+L6mB41VVPB3YDd/S2J19yfqMT8KjSFaMJTctaSUnHn55CHwQ73v?= =?us-ascii?Q?urq7H6i5DpAgO85LhScKgHYZhcNYnk4/UiJ+jGyPHlioScdzZgX6/T61Q7f2?= =?us-ascii?Q?T/3qf7H7AnNviD2R3ABfnW6kmg8G3CnVbabuRGgajCeWWaOUKjICG8HIVDi2?= =?us-ascii?Q?GDxNSz5KUuxM42pwNcjkYwdr636aPiGZR3/h7iVRSypofSQKh6P+9de4YVWM?= =?us-ascii?Q?e1+a5k53xZwrCZ57iL+cnPUyhU51NTJ2MpRpmS6zN0uQSdRGgZSIGDQQ2VtL?= =?us-ascii?Q?w/aftGo32qxxCBiMD+rrb/t2hBSOrvENRFEw0A2GaKo5h0Ml3p7LVnQEKyuB?= =?us-ascii?Q?1c7rfg+yiKy5VeCZDGUxSo/R8LV1cy+R2s0MfezOPFAgehvH1UI224QxwA+q?= =?us-ascii?Q?7km1BlaF7UhewHWtR/a5VxsJQX0gIYDsctjDFxz1iKoqOlaI+BlRAVOQeCBw?= =?us-ascii?Q?hewU50vS1J3cS2CQlukAzg5Pbq9VcK67TueYMxEqLaRexE2fHZ4q8N4E3rWj?= =?us-ascii?Q?Y41pClBRxQ9ThnY+Rn/+wf+qX6S54hpdu6B73tqCKt3zdkmKOKktcSzf668u?= =?us-ascii?Q?Ctc+fkwTZ33y4o3XbZTsSkXbqyQhvaYbvKgYYSD+k2ky/w4TsLZ96mNhSnPA?= =?us-ascii?Q?Uouk8QJswC1/PzkB+VWk+qEupxyQgrCteA5CI8d7zqcHdSKjzz2r5XP5YOwb?= =?us-ascii?Q?DHrlhQBjHpPHz+Of1Dxg9F25HtOjfiWVz0PDoBkE0h2SxPRCkXjRmIy43xKe?= =?us-ascii?Q?PQin2pUVQ/ISLjaSGR4ugJ87qOh4KTn4kxwWTQ2yhwd7SShDtHkasqp3SOKm?= =?us-ascii?Q?woATt+kGrQkX0nR+ScglDQp/6re04wntNOOTbclhNLdJ2j3nwGZ2wO19nAl3?= X-MS-Exchange-AntiSpam-MessageData-1: Z1VCIUbBoDhi4w== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: e2ac8116-919e-4b9a-e783-08dee67c2af5 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2026 16:30:10.5059 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 61sunm5PSwaN/IipvRInU5un9UDrH8nItwNfaAiQiomrWcJ7XPMrDHL0b7wxiRbt8CM/zUIx5e8BhPS2zGGPpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS9P286MB6790 X-purgate-ID: tlsNG-d62444/1784565013-1F66C757-A1437612/0/0 X-purgate-type: clean X-purgate-size: 5333 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784565035659158500 Content-Type: text/plain; charset="utf-8" Import the Processor Properties Topology Table (PPTT) definitions from the Linux kernel header (include/acpi/actbl2.h) into Xen. Signed-off-by: Hirokazu Takahashi Origin: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.g= it b8355bcac253 Origin: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.g= it e62f8227851d Origin: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.g= it 091c4af3562d Acked-by: Jan Beulich --- xen/include/acpi/actbl2.h | 113 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h index ee96e990d6..4398d98e00 100644 --- a/xen/include/acpi/actbl2.h +++ b/xen/include/acpi/actbl2.h @@ -72,6 +72,7 @@ #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Str= ucture */ #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration = table */ #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Inter= face table */ +#define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Ta= ble */ #define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description T= able */ #define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection = table */ #define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Inter= face table */ @@ -937,6 +938,118 @@ struct acpi_table_mchi { u8 pci_function; }; =20 +/*************************************************************************= ****** + * + * PPTT - Processor Properties Topology Table (ACPI 6.2) + * Version 1 + * + *************************************************************************= *****/ + +struct acpi_table_pptt { + struct acpi_table_header header; /* Common ACPI table header */ +}; + +/* Values for Type field above */ + +enum acpi_pptt_type { + ACPI_PPTT_TYPE_PROCESSOR =3D 0, + ACPI_PPTT_TYPE_CACHE =3D 1, + ACPI_PPTT_TYPE_ID =3D 2, + ACPI_PPTT_TYPE_RESERVED =3D 3 +}; + +/* 0: Processor Hierarchy Node Structure */ + +struct acpi_pptt_processor { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 parent; + u32 acpi_processor_id; + u32 number_of_priv_resources; +}; + +/* Flags */ + +#define ACPI_PPTT_PHYSICAL_PACKAGE (1) +#define ACPI_PPTT_ACPI_PROCESSOR_ID_VALID (1<<1) +#define ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD (1<<2) /* ACPI 6.3 */ +#define ACPI_PPTT_ACPI_LEAF_NODE (1<<3) /* ACPI 6.3 */ +#define ACPI_PPTT_ACPI_IDENTICAL (1<<4) /* ACPI 6.3 */ + +/* 1: Cache Type Structure */ + +struct acpi_pptt_cache { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 next_level_of_cache; + u32 size; + u32 number_of_sets; + u8 associativity; + u8 attributes; + u16 line_size; +}; + +/* 1: Cache Type Structure for PPTT version 3 */ + +struct acpi_pptt_cache_v1 { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 next_level_of_cache; + u32 size; + u32 number_of_sets; + u8 associativity; + u8 attributes; + u16 line_size; + u32 cache_id; +}; + +/* Flags */ + +#define ACPI_PPTT_SIZE_PROPERTY_VALID (1) /* Physical property valid= */ +#define ACPI_PPTT_NUMBER_OF_SETS_VALID (1<<1) /* Number of sets valid= */ +#define ACPI_PPTT_ASSOCIATIVITY_VALID (1<<2) /* Associativity valid = */ +#define ACPI_PPTT_ALLOCATION_TYPE_VALID (1<<3) /* Allocation type vali= d */ +#define ACPI_PPTT_CACHE_TYPE_VALID (1<<4) /* Cache type valid */ +#define ACPI_PPTT_WRITE_POLICY_VALID (1<<5) /* Write policy valid */ +#define ACPI_PPTT_LINE_SIZE_VALID (1<<6) /* Line size valid */ +#define ACPI_PPTT_CACHE_ID_VALID (1<<7) /* Cache ID valid */ + +/* Masks for Attributes */ + +#define ACPI_PPTT_MASK_ALLOCATION_TYPE (0x03) /* Allocation type */ +#define ACPI_PPTT_MASK_CACHE_TYPE (0x0C) /* Cache type */ +#define ACPI_PPTT_MASK_WRITE_POLICY (0x10) /* Write policy */ + +/* Attributes describing cache */ +#define ACPI_PPTT_CACHE_READ_ALLOCATE (0x0) /* Cache line is allocat= ed on read */ +#define ACPI_PPTT_CACHE_WRITE_ALLOCATE (0x01) /* Cache line is alloca= ted on write */ +#define ACPI_PPTT_CACHE_RW_ALLOCATE (0x02) /* Cache line is alloca= ted on read and write */ +#define ACPI_PPTT_CACHE_RW_ALLOCATE_ALT (0x03) /* Alternate representa= tion of above */ + +#define ACPI_PPTT_CACHE_TYPE_DATA (0x0) /* Data cache */ +#define ACPI_PPTT_CACHE_TYPE_INSTR (1<<2) /* Instruction cache */ +#define ACPI_PPTT_CACHE_TYPE_UNIFIED (2<<2) /* Unified I & D cache = */ +#define ACPI_PPTT_CACHE_TYPE_UNIFIED_ALT (3<<2) /* Alternate representa= tion of above */ + +#define ACPI_PPTT_CACHE_POLICY_WB (0x0) /* Cache is write back */ +#define ACPI_PPTT_CACHE_POLICY_WT (1<<4) /* Cache is write throu= gh */ + +/* 2: ID Structure */ + +struct acpi_pptt_id { + struct acpi_subtable_header header; + u16 reserved; + u32 vendor_id; + u64 level1_id; + u64 level2_id; + u16 major_rev; + u16 minor_rev; + u16 spin_rev; +}; + /*************************************************************************= ****** * * SLIC - Software Licensing Description Table --=20 2.43.0 From nobody Thu Jul 23 21:13:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1784565038; cv=pass; d=zohomail.com; s=zohoarc; b=ilaynF/3JcqSkEqxTupwRxOhYPAFWGpDGMYeeoroGisiKzAu0ituaj/RlThvAK42Q+PIX/ytTmB6TOGtE9CQg4VW8IlTZm3r41JKq1ZuJxjtS8/pDDfwgmAzWgRoitHxjlnbgqJM3FXl+F31YWOK7QVbPTHPavh+S1YrnV4wRDI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784565038; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tFICUonHJZJoac1NdNgiIOkW7B7hkFZDYI80EIK19zA=; b=OmuX9KfAJGndYJQ3Q7BpTKvraaYNwb5PFqnOVax5ejM80hAFgss6BY/0Jp4eg9TvbmaSjdcSRNZN+D5Uk+7NT4JazOEDN64BuJeqnM1OvlsdggSNL/ISY11SbXoQU52QZM57FohHg0aR6Es7sbb0RjmqTkUGgbxCESTUC8Uv/rs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17845650388051003.4735826161194; Mon, 20 Jul 2026 09:30:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367306.1617140 (Exim 4.92) (envelope-from ) id 1wlqsj-0007yc-AT; Mon, 20 Jul 2026 16:30:17 +0000 Received: by outflank-mailman (output) from mailman id 1367306.1617140; Mon, 20 Jul 2026 16:30:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsj-0007yN-78; Mon, 20 Jul 2026 16:30:17 +0000 Received: by outflank-mailman (input) for mailman id 1367306; Mon, 20 Jul 2026 16:30:16 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqsh-0007jH-Ru for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:30:16 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqsh-007jXT-8S for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:30:15 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4d09-e002-0a2a0a5209dd-0a2a450187c2-28 for ; Mon, 20 Jul 2026 18:30:15 +0200 Received: from [52.101.229.80] (helo=TY3P286CU002.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4d0f-5984-0a2a45010019-3465e5506d27-6 for ; Mon, 20 Jul 2026 18:30:14 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OS9P286MB6790.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:419::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Mon, 20 Jul 2026 16:30:12 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0223.017; Mon, 20 Jul 2026 16:30:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hpPBfT2zTJBuJs4DbZMM07t7LVQyH4GgW3Q1zOQGqtC5FeISPRWYQQrRR/DgzQbJurY7sPFPGgUMUiwPj5J7nu3lTCSNirB8OqMflyDsycbf3sUuEdVWXUBdUDxXRYJkn3EAuN1A6e2hA6m8HZoMMWrEQzRB1Cq1paMvTmi0/mABVZ5lcxnuiZCllChxKme4O28tljFroayo1YGR3cvsGVjk4kaltk2Cdtf+yhxzUFMWSDnWRlXf7SDpL/bvOEKvEiHojp9q/7oW6cq9cPNs5H1/TcO5tTPoNJNqj3rhPOdOEFU/94hFOkHLpAeU5ETIaStkDB/v3uWwMF2sC37isA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tFICUonHJZJoac1NdNgiIOkW7B7hkFZDYI80EIK19zA=; b=JnB/bNqQuTu+sduWN61XNodAJgz72ij6EAkmLzYDMVaZuyq/pr6V69FN2Mj1/WcuukQhuzk9frrfPbM9sARnaDKh0wqaW+p1e9Lj4nHRa2gDundHnJH5G00cWmXwmfphA1d7OF4SfX6cHZIFqMf7ecNmHmjh6l3RR97jY3SkRN1HrCGD5SmA/XSvYVXKQUQUVUcdHydqVhwEYmYLzwPUc6k0kvUx0yPTY1Rl+/9wJiV2iT3JGMppHGUrW2+GjkPDjzC+aIWEYKfgNIaSgdOwKunEyfifv+jXgkUIOnDSag16QBobwuszHJ4bmZuJ6cBYRXCwB1sOI4AKppquxu/OlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tFICUonHJZJoac1NdNgiIOkW7B7hkFZDYI80EIK19zA=; b=b8T92V/TMc0naS56rm0jgr61B/Ity7/vEvaFCLQRzONGnjba0+Nf87nRZEva0FzU1M0mEh+XCWSz6EKeyda458i/Cto/1aIsFUkzwWTzPTi9wlhM1JrBpvn3NSfcOC9pTXMQGTYY1yap0wu9CSN4IZ8KQhc+YB7r7ifswBlDWYI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Mykyta_Poturai@epam.com, Hirokazu Takahashi , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v7 5/5] xen/acpi: Parse PPTT to initialize CPU topology Date: Tue, 21 Jul 2026 01:28:19 +0900 Message-ID: <20260720162819.308326-6-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720162819.308326-1-taka@valinux.co.jp> References: <20260720162819.308326-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY4PR01CA0107.jpnprd01.prod.outlook.com (2603:1096:405:378::15) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OS9P286MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bc73da9-5fa0-4adc-268b-08dee67c2c39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|10070799003|7416014|376014|6133799003|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 8txK6h/UuKvOyOuYQOf3aSxSD958FeJgHJqhSMyvSUhgR9UzVPF8RiiO5swpzGNfR3rdGS/28iihOHTxYtiBNUf0n3O7OS+DeWJWQqYheeIp2ZIwEnuGurEQsgq3I3HkUJKfWDcPKANhDXyxHv1f4/B8nI4WWfLpjwd9uXbrBk/LEwbxaXopTEdh/doQbtuA69Ntlf974C5MRPfye+onrtq2TbcKypNbHFtfc9LUo4lSLzx8G0ZiA9AJ4Bp0erxHnS/vkIT+y4ZxLaYVbEA1HUHCGLRvRLuawvVl1ImLm7gTHOQldztTVEIpa4bctKkzwLxsVKxp9pI7umtbaHYWCyNhIlsLl40yvp5SXVnozmZqgfkdTANkRp/f7pJj2p9U8yDZMQtL6XRs5CzuVYvwqZ+/UVQXO8dTJUzVjMoOSrLhs7UeECLBRVLcT99okkUInHegygbhbnro4AE/Mzrg/gLW/Ev8oHVMXWJDsnLZZqrT7zKxj4BACvog2Ly4yTDsyyhAdtWB8Af4FPjXl+BL+ZRr14uBq6j5+jQhuVosk+81KZ0yMTVEcTv+UT20DYi2oSm60lxPHPcaCsoNGaKnnD7u9kBM/82KFkgARsLNU4n5vw+gYEDJD0R9CKzu5CtkFgUsjToxMphswsblAtnUVOYai6iXXVUWSnlj/lOQw4M= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(1800799024)(10070799003)(7416014)(376014)(6133799003)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lr1wL0Mgs2eHoMqsLPI3T2YV6qwcjawbnfD+dTLTrO0fsulAvv3XMernJlEm?= =?us-ascii?Q?cMp35FQydFPeJiqXMuV+QAhKpZVlaQ4yMXqDtRjNiHzM6kHlougDdk+Y/GjM?= =?us-ascii?Q?FTSxq/j5iDCYbvGYRNkBezxMGIvNVxdWCVE+UtygOFb886vvltFdi/qobr4R?= =?us-ascii?Q?vi8E3ysCyPmgj35iEQrUAHLzxHs0XZzLOLtgGlgeoXhH/43QrU8b0J7D80WI?= =?us-ascii?Q?/kL8R51WzrANBIBFczK7rPWAJTZyo75Ts2V7QYO/xZHvuUnS0KZUalArDYzi?= =?us-ascii?Q?1jTSAfLdPQ2LXl1Z5Wy0ajntFEzOsiLuiRBQP2aj6wy8rcCRinOA7quIY05l?= =?us-ascii?Q?OAzgA6YxfMGQzxYpGvdl+A/h/4Ooaws4Dw0ZKYu1Kq/ziwqKIGN7zOGJ1GaD?= =?us-ascii?Q?jjOryUvFx8oH1YKrxXiJyCIjx3Q43h0SfeDfoBFLVPpTvx0XhJ/WMDnO5rSR?= =?us-ascii?Q?IkePCP06O853IyCmmn2Ws6F9cjJYwgo3isqoYn3K5HirEhyEhzHtO7oy8Ni1?= =?us-ascii?Q?Cb8HgUvY6fvWFqHkOp33KBt/2g0DEw2k5gc+9tbmyAJ4Y3WKxfK2pB+L6sO/?= =?us-ascii?Q?mbJefh12jPLaHUBOkFRxqQkY0OJtt73/yJ+rHXcTVFUW19Va7DoAxnZJ/iJu?= =?us-ascii?Q?tcfZvkFLBOA4qJP13npoQDwKhX9T9vMkVxHjG+qQ2eOBf586u5F0lnweDal/?= =?us-ascii?Q?5gjwgNb148QkgW870vE1noJDDoax+779hLesTDydAb1WK9ZicjGI9Z2QX/EV?= =?us-ascii?Q?KD9UmVE0NtmogLG1xG+Hu8FUhaB9om2KtJ94mKJjYXytCMM+AoJI8jnDtMT+?= =?us-ascii?Q?yCKM0NCwhs1DI2TPHCa2FW0hlgDGpYVZRHhZa3kDQ3HLHFnGZavrOAL6f9rv?= =?us-ascii?Q?BFhuJbo5bG9twc2d8Dj9qzoKw3X8ThLawOPmsULmAeEkwYf94AR+KKtPwio2?= =?us-ascii?Q?nokuIZK2IhQGefw/U80aC1oomsSrFySH8Ep5uV/XQvG98vZPIjMRcy7mGuXc?= =?us-ascii?Q?UgAGAdYBfHuQ/FgRqyh1G+lG5cM0Rjm9/pjv/Bn12xZUKK7BW3dTe+l1Sy2X?= =?us-ascii?Q?cotLMCK8F4jo6mkgf0RJ9PSHXGLrSOBYmslDiWG9OqtgAoKw+xuqRFvBYwHk?= =?us-ascii?Q?cqTUxGGb+nXz6l83lavmEDGrn5IKX+QzCANawPKgWm5RjoVn9et6fVckgu4l?= =?us-ascii?Q?OB+ECLloXzfI9CRu4rqKC+J5c2TfAzlXEX6o1EqOfvhTTwP9GVQ8V/mKV/3d?= =?us-ascii?Q?JeN5IY3fGn3gB5Xb4+Pxm/WcvvPUb2Hby0ETlZdhFGTAnNioW2MjheZPay0Y?= =?us-ascii?Q?G31zmyncX8ZbHkSanKsLvtv3zXshF3YvDJDBo85edwdbl0pNoQm3CGsx+qm2?= =?us-ascii?Q?8xkIHmTaeCq7tZvTa8p4dXvSN4WiHw8/TdNjFTHV3qDmZGKGv+zvEaichmNW?= =?us-ascii?Q?93c2yKBGAy5B8mKBIaPW1gs6pgAKHXISlPOwbmVvuzk+ob5cK886ryefIp5t?= =?us-ascii?Q?79fzD2u2IQEiMtZrASLGNy9vxz8c59hMa56VTgDqeGkEhFYeYEdgZLKuJuLo?= =?us-ascii?Q?kSl8PwSaTHV04LGHzfpaZ2pAoLUa2S35jFvdTuLP/zqQYbKKTmmkDoJDXdXf?= =?us-ascii?Q?oOY5xIH+cEaaBYdI9HAnOD7kO95OSaVqBD5z6lrCyopeSdqC/G/wQI80bJtG?= =?us-ascii?Q?w5a3kLPnJmToOm1ZXDWPaHdI9odZlLxOH/NUWr3NZmLNtp/qjZp6adFJ1X49?= =?us-ascii?Q?EvVU28wCHQePecjdq4G/ibdFwfvV1lHY0jRuDfcm3ZK6DJcaCp1E5wAYnKqc?= X-MS-Exchange-AntiSpam-MessageData-1: ZlKmJgnXlFIhCg== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 5bc73da9-5fa0-4adc-268b-08dee67c2c39 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2026 16:30:12.6295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: knT+IIRmVPIPw5ec6002AWJPpunaeqtRw6bHbCdoKzCMR/q0jmOVkj44tofl8++TZx7q/nVZMnxY32eaEkibGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS9P286MB6790 X-purgate-ID: tlsNG-d62444/1784565015-C5540757-E8DBCCDE/0/0 X-purgate-type: clean X-purgate-size: 14249 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784565039615158500 Content-Type: text/plain; charset="utf-8" Parse the ACPI PPTT (Processor Properties Topology Table) to initialize the CPU topology. For ACPI 6.3 and later, the ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD flag is checked to determine the presence of threading. For ACPI 6.2 and earlier, CPUs are assumed not to support threading. Signed-off-by: Hirokazu Takahashi --- Changes in v7: - PPTT Table Validation & Hardening: * find_pptt_node(): Added leaf node verification (ACPI 6.3+). * acpi_init_cpu_topology(): Added bounds checks to ensure proc->parent validly references memory strictly inside the PPTT table bounds. * Factored out shared table checking helper functions used by both find_pptt_node() and acpi_init_cpu_topology(). * Added subtable alignment checks and strengthened processor structure size validation. - Graceful Fallback & Allocation: * Treated missing topology definitions as benign conditions. * Used xvzalloc_array() for temporary memory allocations during initialization. - Code Cleanups & Style Conformance: * Removed redundant error checks and reduced unnecessary pointer casts. * Switched type-based sizeof(type) to variable-based sizeof(*var). * Added leading spaces before labels ( out:) xen/arch/arm/acpi/boot.c | 2 + xen/arch/arm/include/asm/acpi.h | 2 + xen/drivers/acpi/topology.c | 312 ++++++++++++++++++++++++++++++-- xen/include/xen/acpi.h | 2 + 4 files changed, 305 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 4ac0fd8f51..fc7ecb5749 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -85,6 +85,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_inter= rupt *processor) return; } bootcpu_valid =3D true; + acpi_map_cpu_acpiid(0, processor->uid); return; } =20 @@ -119,6 +120,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_int= errupt *processor) =20 /* map the logical cpu id to cpu MPIDR */ cpu_logical_map(enabled_cpus) =3D mpidr; + acpi_map_cpu_acpiid(enabled_cpus, processor->uid); =20 enabled_cpus++; } diff --git a/xen/arch/arm/include/asm/acpi.h b/xen/arch/arm/include/asm/acp= i.h index 13756dd341..b2e156e131 100644 --- a/xen/arch/arm/include/asm/acpi.h +++ b/xen/arch/arm/include/asm/acpi.h @@ -61,6 +61,8 @@ paddr_t acpi_get_table_offset(struct membank tbl_add[], E= FI_MEM_RES index); (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \ (entry)->header.length !=3D ACPI_MADT_GICC_LENGTH) =20 +#define INVALID_ACPIID (-1U) + #ifdef CONFIG_ACPI extern bool acpi_disabled; /* Basic configuration for ACPI */ diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c index 56fcfa4945..2966117fef 100644 --- a/xen/drivers/acpi/topology.c +++ b/xen/drivers/acpi/topology.c @@ -4,33 +4,319 @@ #include #include #include +#include + +#define ACPI_PPTT_MAX_LEVELS 16 + +static uint32_t __initdata map_cpu_acpiid[NR_CPUS] =3D { + [0 ... NR_CPUS - 1] =3D INVALID_ACPIID +}; =20 /* - * TODO: Populate the topology information by scanning the ACPI - * PPTT (Processor Properties Topology Table). + * The first argument 'cpu' is the logical CPU ID assigned by Xen, + * and the second argument 'acpi_id' is passed the 'uid' field from + * the ACPI MADT Generic Interrupt subtable. */ -int __init acpi_init_cpu_topology(void) +void __init acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id) { - unsigned int cpu; + map_cpu_acpiid[cpu] =3D acpi_id; +} + +static unsigned int __init get_logical_id(unsigned int key, + unsigned int *map, + unsigned int *count) +{ + unsigned int id; + + for ( id =3D 0; id < *count; id++ ) + if ( map[id] =3D=3D key ) + return id; + + map[*count] =3D key; + + return (*count)++; +} + +static bool __init verify_subtable(const struct acpi_subtable_header *entr= y, + const struct acpi_table_pptt *pptt) +{ + unsigned long table_end =3D (unsigned long)pptt + pptt->header.length; + + if ( entry->length < sizeof(*entry) || entry->length & 3 ) + { + printk(XENLOG_ERR "ACPI: PPTT subtable length is invalid\n"); + return false; + } + + if ( (unsigned long)entry + entry->length > table_end ) + { + printk(XENLOG_ERR "ACPI: PPTT subtable extends beyond table end.\n= "); + return false; + } + + return true; +} + +static bool __init verify_proc(const struct acpi_pptt_processor *proc) +{ + unsigned long table_size; + + if ( proc->header.length < sizeof(*proc) ) + { + printk(XENLOG_ERR "ACPI: PPTT processor node length is too small.\= n"); + return false; + } =20 /* - * Generate temporary cpu topology information for now. - * It assumes that the cpu doesn't have SMT and all CPUs - * belong to the same socket. + * Each private resource is represented by a 32-bit resource ID. + * Ensure the structure length accurately accounts for the trailing ar= ray. */ + table_size =3D sizeof(*proc) + + (unsigned long)proc->number_of_priv_resources * sizeof(uint32_t); + + if ( proc->header.length !=3D table_size ) + { + printk(XENLOG_ERR "ACPI: PPTT processor node length invalid.\n"); + return false; + } + + return true; +} + +static const struct acpi_pptt_processor *__init find_pptt_node( + const struct acpi_table_pptt *pptt, uint32_t acpi_id) +{ + const struct acpi_subtable_header *entry; + unsigned long table_end; + const void *ptr; + + table_end =3D (unsigned long)pptt + pptt->header.length; + + ptr =3D pptt + 1; + + while ( (unsigned long)ptr + sizeof(*entry) <=3D table_end ) + { + entry =3D ptr; + + if ( !verify_subtable(entry, pptt) ) + break; + + if ( entry->type =3D=3D ACPI_PPTT_TYPE_PROCESSOR ) + { + const struct acpi_pptt_processor *proc; + + proc =3D container_of(entry, const struct acpi_pptt_processor, + header); + + if ( !verify_proc(proc) ) + break; + + /* + * Leaf node verification is only required for ACPI 6.3 + * (PPTT revision 2) or later. + */ + if ( (proc->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) + && proc->acpi_processor_id =3D=3D acpi_id + && (pptt->header.revision < 2 + || (proc->flags & ACPI_PPTT_ACPI_LEAF_NODE)) ) + return proc; + } + + ptr +=3D entry->length; + } + + return NULL; +} + +/* + * Populate the topology information by scanning the ACPI PPTT + * (Processor Properties Topology Table). + */ +int __init acpi_init_cpu_topology(void) +{ + acpi_status status; + struct acpi_table_header *table_header; + const struct acpi_table_pptt *pptt; + unsigned int num_sockets =3D 0; + unsigned int num_clusters =3D 0; + unsigned int num_cores =3D 0; + unsigned int *socket_map =3D xvzalloc_array(unsigned int, nr_cpu_ids); + unsigned int *cluster_map =3D xvzalloc_array(unsigned int, nr_cpu_ids); + unsigned int *core_map =3D xvzalloc_array(unsigned int, nr_cpu_ids); + unsigned int cpu; + int ret =3D 0; + + status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table_header); + if ( ACPI_FAILURE(status) ) + { + /* A missing PPTT is benign; fall back to the default topology. */ + ret =3D -ENODEV; + goto out; + } + + if ( !socket_map || !cluster_map || !core_map ) + { + printk(XENLOG_ERR + "ACPI: Failed to allocate memory for topology parsing.\n"); + ret =3D -ENOMEM; + goto out; + } + + pptt =3D container_of(table_header, const struct acpi_table_pptt, head= er); + for_each_possible_cpu(cpu) { + uint32_t acpi_id =3D map_cpu_acpiid[cpu]; struct cpu_topology *topo =3D &cpu_topology[cpu]; + const struct acpi_pptt_processor *proc; + unsigned int level; + unsigned int core_group_key =3D 0; + unsigned int cluster_group_key =3D 0; + unsigned int socket_group_key =3D 0; + bool threading =3D false; + + proc =3D find_pptt_node(pptt, acpi_id); + if ( !proc ) + { + printk(XENLOG_WARNING + "ACPI: No PPTT leaf node for CPU %u (ACPI ID 0x%u)\n", + cpu, acpi_id); + ret =3D -ENOENT; + goto out; + } + + /* + * Limit the maximum loop depth to prevent an infinite loop in case + * the PPTT is corrupted or contains cyclic references. + */ + for ( level =3D 0; level < ACPI_PPTT_MAX_LEVELS; level++ ) + { + const unsigned int offset =3D (const void *)proc - (const void= *)pptt; + + if ( proc->flags & ACPI_PPTT_PHYSICAL_PACKAGE ) + { + socket_group_key =3D offset; =20 - topo->phys_core_id =3D cpu; - topo->num_siblings =3D 1; + /* + * If cluster/core info is absent upon reaching the physic= al + * package, assume one cluster per socket and one core per + * cluster. + */ + if ( cluster_group_key =3D=3D 0 ) + cluster_group_key =3D socket_group_key; =20 - cpumask_set_cpu(cpu, topo->thread_sibling); - cpumask_copy(topo->core_sibling, &cpu_possible_map); - cpumask_copy(topo->cluster_sibling, &cpu_possible_map); + if ( core_group_key =3D=3D 0 ) + core_group_key =3D cluster_group_key; + + break; + } + else if ( level =3D=3D 0 ) + { + /* + * ACPI_PPTT_PROCESSOR_IS_THREAD is supported in PPTT + * revision 2 and later. Assume no threading support when + * PPTT revision is 1. + */ + if ( proc->flags & ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD ) + threading =3D true; + else + core_group_key =3D offset; + } + else if ( level =3D=3D 1 ) + { + if ( threading ) + core_group_key =3D offset; + else + cluster_group_key =3D offset; + } + else if ( level =3D=3D 2 && threading ) + cluster_group_key =3D offset; + + if ( !proc->parent ) + break; + + if ( (proc->parent & 3) + || proc->parent < sizeof(*pptt) + || proc->parent > pptt->header.length - sizeof(*proc) + || (proc->parent + sizeof(*proc) > offset + && proc->parent < offset + proc->header.length) ) + { + printk(XENLOG_WARNING + "ACPI: PPTT parent offset is invalid\n"); + break; + } + + proc =3D (const void *)pptt + proc->parent; + + if ( proc->header.type !=3D ACPI_PPTT_TYPE_PROCESSOR ) + { + printk(XENLOG_WARNING + "ACPI: PPTT parent node is not a processor structur= e\n"); + break; + } + + if ( !verify_subtable(&proc->header, pptt) + || !verify_proc(proc) ) + break; + } + + if ( socket_group_key =3D=3D 0 ) + { + printk(XENLOG_WARNING + "ACPI: Could not reach the physical package node for CP= U %u (ACPI ID 0x%u)\n", + cpu, acpi_id); + ret =3D -ENOENT; + goto out; + } + + topo->phys_socket_id =3D + get_logical_id(socket_group_key, socket_map, &num_sockets); + topo->phys_cluster_id =3D + get_logical_id(cluster_group_key, cluster_map, &num_clusters); + topo->phys_core_id =3D + get_logical_id(core_group_key, core_map, &num_cores); + } + + for_each_possible_cpu(cpu) + { + struct cpu_topology *topo =3D &cpu_topology[cpu]; + unsigned int tcpu; + + for_each_possible_cpu(tcpu) + { + struct cpu_topology *ttopo =3D &cpu_topology[tcpu]; + + if ( cpu > tcpu ) + continue; + + if ( topo->phys_core_id =3D=3D ttopo->phys_core_id ) + { + cpumask_set_cpu(tcpu, topo->thread_sibling); + cpumask_set_cpu(cpu, ttopo->thread_sibling); + } + + if ( topo->phys_cluster_id =3D=3D ttopo->phys_cluster_id ) + { + cpumask_set_cpu(tcpu, topo->cluster_sibling); + cpumask_set_cpu(cpu, ttopo->cluster_sibling); + } + + if ( topo->phys_socket_id =3D=3D ttopo->phys_socket_id ) + { + cpumask_set_cpu(tcpu, topo->core_sibling); + cpumask_set_cpu(cpu, ttopo->core_sibling); + } + } + + topo->num_siblings =3D cpumask_weight(topo->thread_sibling); } =20 - return 0; + out: + xvfree(socket_map); + xvfree(cluster_map); + xvfree(core_map); + + return ret; } =20 /* diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index cbb02e0f35..d2a1531893 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -137,10 +137,12 @@ static inline int acpi_boot_table_init(void) =20 #ifdef CONFIG_ACPI_CPU_TOPOLOGY =20 +void acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id); int acpi_init_cpu_topology(void); =20 #else /* CONFIG_ACPI_CPU_TOPOLOGY */ =20 +static inline void acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id)= {} static inline int acpi_init_cpu_topology(void) { return -EOPNOTSUPP; --=20 2.43.0