lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240622043408.1566962-1-chenhuacai@loongson.cn>
Date: Sat, 22 Jun 2024 12:34:08 +0800
From: Huacai Chen <chenhuacai@...ngson.cn>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: loongarch@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	Xuefeng Li <lixuefeng@...ngson.cn>,
	Huacai Chen <chenhuacai@...il.com>,
	Jiaxun Yang <jiaxun.yang@...goat.com>,
	Huacai Chen <chenhuacai@...ngson.cn>
Subject: [PATCH V3] irqchip/loongson-eiointc: Use early_cpu_to_node() instead of cpu_to_node()

When we use "nr_cpus=n" to hard limit the CPU number, cpu_to_node() is
not usable for CPUs exceeding the limit. Because cpu_to_node() depends
on the per-cpu area, and the per-cpu area is only applied on "possible"
CPUs. On the other hand, early_cpu_to_node() is always usable because it
uses plain arrays to record the cpu-node mapping, and the architectural
code ensures those arrays are correctly initialized. So here we can use
early_cpu_to_node() instead.

Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
---
V2: Fix build for !NUMA.
V3: Adjust header file order and update commit messages.

 1 file changed, 3 insertions(+), 2 deletions(-)
 drivers/irqchip/irq-loongson-eiointc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c
index c7ddebf312ad..b1f2080be2be 100644
--- a/drivers/irqchip/irq-loongson-eiointc.c
+++ b/drivers/irqchip/irq-loongson-eiointc.c
@@ -15,6 +15,7 @@
 #include <linux/irqchip/chained_irq.h>
 #include <linux/kernel.h>
 #include <linux/syscore_ops.h>
+#include <asm/numa.h>
 
 #define EIOINTC_REG_NODEMAP	0x14a0
 #define EIOINTC_REG_IPMAP	0x14c0
@@ -339,7 +340,7 @@ static int __init pch_msi_parse_madt(union acpi_subtable_headers *header,
 	int node;
 
 	if (cpu_has_flatmode)
-		node = cpu_to_node(eiointc_priv[nr_pics - 1]->node * CORES_PER_EIO_NODE);
+		node = early_cpu_to_node(eiointc_priv[nr_pics - 1]->node * CORES_PER_EIO_NODE);
 	else
 		node = eiointc_priv[nr_pics - 1]->node;
 
@@ -431,7 +432,7 @@ int __init eiointc_acpi_init(struct irq_domain *parent,
 		goto out_free_handle;
 
 	if (cpu_has_flatmode)
-		node = cpu_to_node(acpi_eiointc->node * CORES_PER_EIO_NODE);
+		node = early_cpu_to_node(acpi_eiointc->node * CORES_PER_EIO_NODE);
 	else
 		node = acpi_eiointc->node;
 	acpi_set_vec_parent(node, priv->eiointc_domain, pch_group);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ