cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
Subsystems (3)
v2 cover cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
This is a repost of the previous patch (#2) and adding Boris (Ostrovsky)'s suggestion regarding the XEN bits. The previous post can be found at
https://lore.kernel.org/all/[email protected]/
Sebastian
PATCH v2 1/2 x86/xen: Allow to retry if cpu_initialize_context() failed.
From: Boris Ostrovsky <[email protected]>
If memory allocation in cpu_initialize_context() fails then it will bring up the VCPU and leave with the corresponding CPU bit set in xen_cpu_initialized_map.
The following (presumably successful) CPU bring up will BUG in xen_pv_cpu_up() because nothing for that VCPU would be initialized.
Clear the CPU bits, that were set in cpu_initialize_context() in case the memory allocation fails.
[ bigeasy: Creating a patch from Boris' email. ]
--- arch/x86/xen/smp_pv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/smp_pv.c +4 -1
@@ -277,8 +277,11 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)return 0 ; ctxt =kzalloc (sizeof (*ctxt),GFP_KERNEL ); -if (ctxt ==NULL ) +if (ctxt ==NULL ) { +cpumask_clear_cpu (cpu, xen_cpu_initialized_map); +cpumask_clear_cpu (cpu, cpu_callout_mask);return -ENOMEM ; + } gdt =get_cpu_gdt_rw (cpu);
Signature · 1 line
2.34.1
PATCH v2 2/2 cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
In reply to Sebastian Andrzej SiewiorFrom: "Longpeng(Mike)" <[email protected]>
A CPU will not show up in virtualized environment which includes an Enclave. The VM splits its resources into a primary VM and a Enclave VM. While the Enclave is active, the hypervisor will ignore all requests to bring up a CPU and this CPU will remain in CPU_UP_PREPARE state. The kernel will wait up to ten seconds for CPU to show up (do_boot_cpu()) and then rollback the hotplug state back to CPUHP_OFFLINE leaving the CPU state in CPU_UP_PREPARE. The CPU state is set back to CPUHP_TEARDOWN_CPU during the CPU_POST_DEAD stage.
After the Enclave VM terminates, the primary VM can bring up the CPU again.
Allow to bring up the CPU if it is in the CPU_UP_PREPARE state.
[bigeasy: Rewrite commit description.]
--- kernel/smpboot.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)*/ return -EAGAIN ; +case CPU_UP_PREPARE : +/* +* Timeout while waiting for the CPU to show up. Allow to try +* again later. +*/ +return 0 ; +default :/* Should not happen. Famous last words. */
Signature · 1 line
2.34.1
Quoted 4 lines · On 2021-12-06 16:20:32 [+0100], To [email protected] wrote:
This is a repost of the previous patch (#2) and adding Boris (Ostrovsky)'s suggestion regarding the XEN bits. The previous post can be found at
https://lore.kernel.org/all/[email protected]/
ping.
Sebastian