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-next>] [day] [month] [year] [list]
Date: Sun,  7 Apr 2024 18:26:43 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: tglx@...utronix.de
Cc: adobriyan@...il.com,
	mingo@...hat.com,
	bp@...en8.de,
	dave.hansen@...ux.intel.com,
	x86@...nel.org,
	hpa@...or.com,
	linux-kernel@...r.kernel.org,
	peterz@...radead.org,
	Jonathan.Cameron@...wei.com,
	linuxarm@...wei.com,
	linux@...ck-us.net,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: [PATCH 1/2] x86/cpu/topology: don't write to immutable cpu_present_mask

Workaround the following oops:

	topology_hotplug_apic
	topo_set_cpuids
		set_cpu_possible(cpu, true);
		// write to __ro_after_init section after init

adobriyan: I'm not sure what's going on, can it set unset bit here?
If not, then why does it repeat the job and set already set bits.

Anyhow, let's not oops peoples' machines for now.

Reported-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Suggested-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
---
 arch/x86/kernel/cpu/topology.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index aaca8d235dc2..42f4a17f8019 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -117,13 +117,18 @@ static __init int topo_get_cpunr(u32 apic_id)
 	return topo_info.nr_assigned_cpus++;
 }
 
-static void topo_set_cpuids(unsigned int cpu, u32 apic_id, u32 acpi_id)
+static void topo_set_cpuids(unsigned int cpu, u32 apic_id, u32 acpi_id, bool from_init)
 {
 #if defined(CONFIG_SMP) || defined(CONFIG_X86_64)
 	early_per_cpu(x86_cpu_to_apicid, cpu) = apic_id;
 	early_per_cpu(x86_cpu_to_acpiid, cpu) = acpi_id;
 #endif
-	set_cpu_possible(cpu, true);
+	if (from_init) {
+		set_cpu_possible(cpu, true);
+	} else {
+		/* cpu_possible_mask is supposed to be fixed by now. */
+		WARN_ON(!cpumask_test_cpu(cpu, cpu_possible_mask));
+	}
 	set_cpu_present(cpu, true);
 }
 
@@ -191,7 +196,7 @@ static __init void topo_register_apic(u32 apic_id, u32 acpi_id, bool present)
 			cpu = topo_get_cpunr(apic_id);
 
 		cpuid_to_apicid[cpu] = apic_id;
-		topo_set_cpuids(cpu, apic_id, acpi_id);
+		topo_set_cpuids(cpu, apic_id, acpi_id, true);
 	} else {
 		u32 pkgid = topo_apicid(apic_id, TOPO_PKG_DOMAIN);
 
@@ -343,7 +348,7 @@ int topology_hotplug_apic(u32 apic_id, u32 acpi_id)
 		return -ENOSPC;
 
 	set_bit(apic_id, phys_cpu_present_map);
-	topo_set_cpuids(cpu, apic_id, acpi_id);
+	topo_set_cpuids(cpu, apic_id, acpi_id, false);
 	cpu_mark_primary_thread(cpu, apic_id);
 	return cpu;
 }
-- 
2.43.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ