smp/hotplug: Fix last minute wreckage
Subsystems (2)
cover smp/hotplug: Fix last minute wreckage
The last minute changes to the hotplug core code wreckaged the dynamically allocated states. The AMD mce code crashes as a result.
Fix the brainfart and make the AMD code more robust.
Thanks,
tglx
PATCH 1/2 smp/hotplug: Undo tglxs brainfart
The attempt to prevent overwriting an active state resulted in a disaster which effectively disables all dynamically allocated hotplug states.
Cleanup the mess.
--- kernel/cpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/cpu.c +8 -1
@@ -1471,6 +1471,7 @@ int __cpuhp_setup_state(enum cpuhp_state bool multi_instance) {int cpu, ret =0 ; +bool dynstate;if (cpuhp_cb_check (state) || !name)return -EINVAL ;
@@ -1480,6 +1481,12 @@ int __cpuhp_setup_state(enum cpuhp_state ret =cpuhp_store_callbacks (state, name, startup, teardown, multi_instance); + dynstate = state ==CPUHP_AP_ONLINE_DYN ; +if (ret >0 && dynstate) { + state = ret; + ret =0 ; + } +if (ret || !invoke || !startup) goto out;
@@ -1508,7 +1515,7 @@ int __cpuhp_setup_state(enum cpuhp_state* If the requested state is CPUHP_AP_ONLINE_DYN, return the * dynamically allocated state in case of success. */ -if (!ret && state ==CPUHP_AP_ONLINE_DYN ) +if (!ret && dynstate)return state;return ret; }
PATCH 2/2 x86/mce/AMD: Make the init code more robust
In reply to Thomas GleixnerIf mce_device_init() fails then the mce device pointer is NULL and the AMD mce code happily dereferences it.
Add a sanity check.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/mcheck/mce_amd.c +3 -0
@@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigneconst char *name =get_name (bank,NULL );int err =0 ; +if (!dev) +return -ENODEV ; +if (is_shared_bank (bank)) { nb =node_to_amd_nb (amd_get_nb_id (cpu));
Re: [patch 2/2] x86/mce/AMD: Make the init code more robust
Quoted 15 lines · Thomas Gleixner
If
mce_device_init()fails then the mce device pointer is NULL and the AMD mce code happily dereferences it.Add a sanity check.
Reported-by Markus Trippelsdorf <[email protected]>Reported-by Boris Ostrovsky <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/mcheck/mce_amd.c static int threshold_create_bank(unsigne · line 1189
Quoted 8 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +3
-0@@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigneconst char *name =get_name (bank,NULL );int err =0 ; +if (!dev) +return -ENODEV ; +if (is_shared_bank (bank)) { nb =node_to_amd_nb (amd_get_nb_id (cpu));
Quoted 1 line
From looking at that code, though, it could use some more involved
straightening later.
/me puts it on TODO list.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--