hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IATDZ5 CVE: NA
--------------------------------
When two vCPUs of NUMA1 are hot added and then taken to online, e.g.:
In qemu monitor: device_add host-arm-cpu,socket-id=1,cluster-id=0,core-id=0, thread-id=0,id=core4 device_add host-arm-cpu,socket-id=1,cluster-id=0,core-id=0, thread-id=1,id=core5
In guest: echo 1 > /sys/devices/system/cpu/cpu4/online
it will appear calltrace as below:
WARNING: CPU: 4 PID: 286 at kernel/sched/core.c:2293 __set_cpus_allowed_ptr+0x468/0x4d4 Modules linked in: ... CPU: 4 PID: 286 Comm: cpuhp/4 Tainted: G W OE 5.10.0 #1 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 pstate: 20400085 (nzCv daIf +PAN -UAO -TCO BTYPE=--) pc : __set_cpus_allowed_ptr+0x468/0x4d4 lr : __set_cpus_allowed_ptr+0x440/0x4d4 sp : ffff800010a43c30 x29: ffff800010a43c30 x28: ffff4e2fbffe7c40 x27: ffffa34037fcb450 x26: ffffa340372f2000 x25: 0000000000000004 x24: ffffa34037c47140 x23: ffff4e2f3ffc7480 x22: 0000000000000000 x21: ffff4e2ec0fee040 x20: ffffa34037cb8530 x19: ffffa34037cb7c80 x18: ffff4e2f80242787 x17: 00000000248943a4 x16: 0000000000000000 x15: ffff800010760000 x14: 0000000000001000 x13: ffff80000fffffff x12: 0000000000007290 x11: ffff4e2fbffeeed0 x10: ffffa3403826eea8 x9 : ffffa340341b8290 x8 : 0000000000000000 x7 : ffffa3403826a3c8 x6 : ffff4e2ec0fee4f8 x5 : 0000000000000000 x4 : 00000000000007c7 x3 : ffffffffffffffff x2 : 00000000000000ff x1 : 0000000000000004 x0 : 0000000000000001 Call trace: __set_cpus_allowed_ptr+0x468/0x4d4 set_cpus_allowed_ptr+0x38/0x5c kcompactd_cpu_online+0xb0/0x190 cpuhp_invoke_callback+0x274/0xbb0 cpuhp_thread_fun+0x188/0x36c smpboot_thread_fn+0x144/0x380 kthread+0x190/0x1fc ret_from_fork+0x10/0x18
When the WARN_ON occurs, the mask variables is as follows. new_mask: 0-4 activ_mask:0-3 nr_cpus_allowed:2
numa_add_cpu() is called in secondary_start_kernel() when the CPU is brought up online. We need to remove numa_add_cpu() in acpi_map_cpu(). So it is for arch/x86. Also fix it in acpi_unmap_cpu() as well.
Fixes: 7eaf6534f708 ("arm64: Add CPU hotplug support") Signed-off-by: Xiongfeng Wang wangxiongfeng2@huawei.com Signed-off-by: Zhou Wang wangzhou1@hisilicon.com --- arch/arm64/kernel/acpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index a81105cfe57e2..f043bec3ba50f 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -417,7 +417,6 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, nid = acpi_get_node(handle); if (nid != NUMA_NO_NODE) { set_cpu_numa_node(cpu, nid); - numa_add_cpu(cpu); }
*pcpu = cpu; @@ -430,7 +429,7 @@ EXPORT_SYMBOL(acpi_map_cpu); int acpi_unmap_cpu(int cpu) { set_cpu_present(cpu, false); - numa_clear_node(cpu); + set_cpu_numa_node(cpu, NUMA_NO_NODE);
return 0; }