Reviewed-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>


--------------------------------------------------
汪雄峰 Wang Xiongfeng
Mobile: +86-15267087487
Email: wangxiongfeng2@huawei.com
发件人:sangyan <sangyan@huawei.com>
收件人:Xiexiuqi <xiexiuqi@huawei.com>;kernel <kernel@openeuler.org>;wangxiongfeng (C) <wangxiongfeng2@huawei.com>;Zhengzengkai <zhengzengkai@huawei.com>
抄 送:zhuling (C) <zhuling8@huawei.com>;luanjianhai <luanjianhai@huawei.com>;luolongjun <luolongjun@huawei.com>;lixiaoguang (D) <lixiaoguang2@huawei.com>;hewenliang (C) <hewenliang4@huawei.com>;sangyan <sangyan@huawei.com>;jingxiangfeng <jingxiangfeng@huawei.com>;snoweay <snoweay@163.com>;Luchunhua <luchunhua@huawei.com>
时 间:2021-03-12 19:13:04
主 题:[PATCH openEuler-21.03 v1] arm64: Uninstall cpu park after cpu up

From: Sang Yan < sangyan@huawei.com>

hulk inclusion
category: feature
bugzilla: 48159
CVE: N/A

------------------------------

One cpu in PARK state could not come up in this case:
        CPU 0                       |   CPU 1
        boot_secondary(cpu 1)       |
        --> write_park_exit(cpu 1) |
                                    |    cpu uping from PARK
                                    |    ...
        uninstall_cpu_park()        |
        --> memset to 0 park text   |
                                    |    ...
                                    |    Exception in memory !!
        wait for cpu up             |

Cpu 1 uping from PARK may trap into exception while cpu 0
clear cpu 1's park text memory.

This uninstall_cpu_park should be after waiting for cpu up.

Signed-off-by: Sang Yan < sangyan@huawei.com>
---
 arch/arm64/kernel/smp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index d7b750a..fb6007d 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -300,15 +300,15 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
                 return ret;
         }
 
-#ifdef CONFIG_ARM64_CPU_PARK
-       uninstall_cpu_park(cpu);
-#endif
         /*
          * CPU was successfully started, wait for it to come online or
          * time out.
          */
         wait_for_completion_timeout(&cpu_running,
                                     msecs_to_jiffies(5000));
+#ifdef CONFIG_ARM64_CPU_PARK
+       uninstall_cpu_park(cpu);
+#endif
         if (cpu_online(cpu))
                 return 0;
 
--
2.9.5