diff options
author | Gautham R. Shenoy <ego@linux.vnet.ibm.com> | 2018-10-01 16:10:39 +0530 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-10-13 22:21:25 +1100 |
commit | dfd718a2ed1f678e66749ffe41bdeafedf3f4314 (patch) | |
tree | 02e3789275fe35c580da982fdd01bfd5f91e8c4d | |
parent | 500fe5f550ec6dbc1d7d3154d8eccc7cb834d434 (diff) | |
download | linux-dfd718a2ed1f678e66749ffe41bdeafedf3f4314.tar.bz2 |
powerpc/rtas: Fix a potential race between CPU-Offline & Migration
Live Partition Migrations require all the present CPUs to execute the
H_JOIN call, and hence rtas_ibm_suspend_me() onlines any offline CPUs
before initiating the migration for this purpose.
The commit 85a88cabad57
("powerpc/pseries: Disable CPU hotplug across migrations")
disables any CPU-hotplug operations once all the offline CPUs are
brought online to prevent any further state change. Once the
CPU-Hotplug operation is disabled, the code assumes that all the CPUs
are online.
However, there is a minor window in rtas_ibm_suspend_me() between
onlining the offline CPUs and disabling CPU-Hotplug when a concurrent
CPU-offline operations initiated by the userspace can succeed thereby
nullifying the the aformentioned assumption. In this unlikely case
these offlined CPUs will not call H_JOIN, resulting in a system hang.
Fix this by verifying that all the present CPUs are actually online
after CPU-Hotplug has been disabled, failing which we restore the
state of the offline CPUs in rtas_ibm_suspend_me() and return an
-EBUSY.
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/kernel/rtas.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index e02ac377ed64..de35bd8f047f 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -983,6 +983,14 @@ int rtas_ibm_suspend_me(u64 handle) cpu_hotplug_disable(); + /* Check if we raced with a CPU-Offline Operation */ + if (unlikely(!cpumask_equal(cpu_present_mask, cpu_online_mask))) { + pr_err("%s: Raced against a concurrent CPU-Offline\n", + __func__); + atomic_set(&data.error, -EBUSY); + goto out_hotplug_enable; + } + /* Call function on all CPUs. One of us will make the * rtas call */ @@ -994,6 +1002,7 @@ int rtas_ibm_suspend_me(u64 handle) if (atomic_read(&data.error) != 0) printk(KERN_ERR "Error doing global join\n"); +out_hotplug_enable: cpu_hotplug_enable(); /* Take down CPUs not online prior to suspend */ |