From: Xiongfeng Wang wangxiongfeng2@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4KCU2 CVE: NA
----------------------------------------
When we set 'nr_cpus=1' in kernel parameter, we get the following error. It's because 'acpi_map_cpuid()' return -ENODEV in 'acpi_map_cpu()' when there are not enough logical CPU numbers. So we need to check the returned logical CPU number and return error if it is negative.
'acpi_map_cpu' when there are not enough logical CPU [ 0.025955] Unable to handle kernel paging request at virtual address ffff00002915b828 [ 0.025958] Mem abort info: [ 0.025959] ESR = 0x96000006 [ 0.025961] Exception class = DABT (current EL), IL = 32 bits [ 0.025963] SET = 0, FnV = 0 [ 0.025965] EA = 0, S1PTW = 0 [ 0.025966] Data abort info: [ 0.025968] ISV = 0, ISS = 0x00000006 [ 0.025970] CM = 0, WnR = 0 [ 0.025972] swapper pgtable: 4k pages, 48-bit VAs, pgdp = (____ptrval____) [ 0.025974] [ffff00002915b828] pgd=000000013fffe003, pud=000000013fffd003, pmd=0000000000000000 [ 0.025979] Internal error: Oops: 96000006 [#1] SMP [ 0.025981] Modules linked in: [ 0.025983] Process swapper/0 (pid: 1, stack limit = 0x(____ptrval____)) [ 0.025986] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.19.141+ #37 [ 0.025988] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 [ 0.025991] pstate: a0c00005 (NzCv daif +PAN +UAO) [ 0.025993] pc : acpi_map_cpu+0xe0/0x170 [ 0.025996] lr : acpi_map_cpu+0xb8/0x170 [ 0.025997] sp : ffff8000fef1fa50 [ 0.025999] x29: ffff8000fef1fa50 x28: ffff000008e22058 [ 0.026001] x27: ffff0000092a6000 x26: ffff000008d60778 [ 0.026004] x25: ffff0000094c3000 x24: 0000000000000001 [ 0.026006] x23: ffff8000fe802c18 x22: 00000000ffffffff [ 0.026008] x21: ffff000008a16000 x20: ffff000008a16a20 [ 0.026011] x19: 00000000ffffffed x18: ffffffffffffffff [ 0.026013] x17: 0000000087411dcf x16: 00000000b93a5600 [ 0.026015] x15: ffff000009159708 x14: 0720072007200720 [ 0.026018] x13: 0720072007200720 x12: 0720072007200720 [ 0.026020] x11: 072007200720073d x10: 073d073d073d073d [ 0.026022] x9 : 073d073d073d0764 x8 : 0765076607660766 [ 0.026024] x7 : 0766076607660778 x6 : 0000000000000130 [ 0.026027] x5 : ffff0000085955c8 x4 : 0000000000000000 [ 0.026029] x3 : 0000000000000000 x2 : ffff00000915b830 [ 0.026031] x1 : ffff00002915b828 x0 : 0000200000000000 [ 0.026033] Call trace: [ 0.026035] acpi_map_cpu+0xe0/0x170 [ 0.026038] acpi_processor_add+0x44c/0x640 [ 0.026040] acpi_bus_attach+0x174/0x218 [ 0.026043] acpi_bus_attach+0xa8/0x218 [ 0.026045] acpi_bus_attach+0xa8/0x218 [ 0.026047] acpi_bus_attach+0xa8/0x218 [ 0.026049] acpi_bus_scan+0x58/0xb8 [ 0.026052] acpi_scan_init+0xf4/0x234 [ 0.026054] acpi_init+0x318/0x384 [ 0.026056] do_one_initcall+0x54/0x250 [ 0.026059] kernel_init_freeable+0x2d4/0x3c0 [ 0.026061] kernel_init+0x18/0x118 [ 0.026063] ret_from_fork+0x10/0x18 [ 0.026066] Code: d2800020 9120c042 8b010c41 9ad32000 (f820303f)
Signed-off-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com Reviewed-by: Keqian Zhu zhukeqian1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com --- arch/arm64/kernel/acpi.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index b51ffac3b38d..a81105cfe57e 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -410,6 +410,10 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, int cpu, nid;
cpu = acpi_map_cpuid(physid, acpi_id); + if (cpu < 0) { + pr_info("Unable to map GICC to logical cpu number\n"); + return cpu; + } nid = acpi_get_node(handle); if (nid != NUMA_NO_NODE) { set_cpu_numa_node(cpu, nid);