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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6dbc27f8-5261-59c5-acba-70f6c6a74ba1@rwth-aachen.de>
Date:   Mon, 1 Feb 2021 12:49:31 +0100
From:   Jan Henrik Weinstock <jan.weinstock@...h-aachen.de>
To:     Stafford Horne <shorne@...il.com>, <geert@...ux-m68k.org>
CC:     <jonas@...thpole.se>, <stefan.kristiansson@...nalahti.fi>,
        <openrisc@...ts.librecores.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v2] openrisc: use device tree to determine present cpus

Use the device tree to determine the present cpus instead of assuming 
all CONFIG_NRCPUS are actually present in the system.

Signed-off-by: Jan Henrik Weinstock <jan.weinstock@...h-aachen.de>
---
Changes since v1:
  1. use for_each_of_cpu_node
  2. possible_cpus is now what is in the devicetree, up to NR_CPUS
  3. present_cpus is now all possible cpus, up to max_cpus

  arch/openrisc/kernel/smp.c | 31 +++++++++++++++----------------
  1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c
index 75be7e34f..83cbf43d4 100644
--- a/arch/openrisc/kernel/smp.c
+++ b/arch/openrisc/kernel/smp.c
@@ -61,32 +61,31 @@ void __init smp_prepare_boot_cpu(void)

  void __init smp_init_cpus(void)
  {
-	int i;
+	struct device_node* cpu;
+	u32 cpu_id;
+
+	for_each_of_cpu_node(cpu) {
+		if (of_property_read_u32(cpu, "reg", &cpu_id)) {
+			pr_warn("%s missing reg property", cpu->full_name);
+			continue;
+		}

-	for (i = 0; i < NR_CPUS; i++)
-		set_cpu_possible(i, true);
+		if (cpu_id < NR_CPUS)
+			set_cpu_possible(cpu_id, true);
+	}
  }

  void __init smp_prepare_cpus(unsigned int max_cpus)
  {
-	u32 cpu_id;
-	struct device_node *cpu, *cpus;
+	unsigned int cpu;

  	/*
  	 * Initialise the present map, which describes the set of CPUs
  	 * actually populated at the present time.
  	 */
-	cpus = of_find_node_by_path("/cpus");
-	for_each_child_of_node(cpus, cpu) {
-		if (of_property_read_u32(cpu, "reg", &cpu_id)) {
-			pr_warn("%s missing reg property", cpu->full_name);
-			continue;
-		}
-
-		if (cpu_id >= max_cpus)
-			continue;
-
-		set_cpu_present(cpu_id, true);
+	for_each_possible_cpu(cpu) {
+		if (cpu < max_cpus)
+			set_cpu_present(cpu, true);
  	}
  }

-- 
2.17.1


Download attachment "smime.p7s" of type "application/pkcs7-signature" (5316 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ