pc: fix crash on attempted cpu unplug
PATCH 1/1 pc: fix crash on attempted cpu unplug
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using device_del results in null pointer dereference at:
#0 object_get_class
#1 pc_machine_device_unplug_request_cb
#2 qmp_marshal_device_del
which is caused by pcms->acpi_dev == NULL due to ACPI support being disabled.
Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/i386/pc.c +5 -0
@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev); +if (!pcms->acpi_dev) { +error_setg (&local_err,"not supported without acpi" ); + goto out; + } +pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx);assert (idx !=-1 );if (idx ==0 ) {
Signature · 1 line
2.7.4
Quoted 8 lines · Igor Mammedov
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using
device_delresults in null pointer dereference at:#0
object_get_class
#1pc_machine_device_unplug_request_cb
#2qmp_marshal_device_del
Quoted 8 lines
which is caused by
pcms->acpi_dev== NULL due to ACPI support being disabled.Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
Signed-off-by Igor Mammedov <[email protected]>
But I have one small suggestion:
Quoted 9 lines
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)hw/i386/pc.c +0
-0
hw/i386/pc.c static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, · line 1846
Quoted 5 lines
hw/i386/pc.c +2
-0@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev); +if (!pcms->acpi_dev) { +error_setg (&local_err,"not supported without acpi" );
I suggest "CPU hot unplug not supported without ACPI" instead.
Quoted 9 lines
hw/i386/pc.c +3
-0+ goto out; + } +pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx);assert (idx !=-1 );if (idx ==0 ) {Signature · 1 line
2.7.4
Signature · 1 line
Eduardo
Quoted 34 lines · On Mon, 20 Nov 2017 12:44:54 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 8 lines · Igor Mammedov
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using
device_delresults in null pointer dereference at:#0
object_get_class
#1pc_machine_device_unplug_request_cb
#2qmp_marshal_device_delQuoted 8 lines
which is caused by
pcms->acpi_dev== NULL due to ACPI support being disabled.Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>But I have one small suggestion:
Quoted 12 lines
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)hw/i386/pc.c +0
-0@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev);
Quoted 4 lines
hw/i386/pc.c static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, · line 1846
Quoted 2 lines
hw/i386/pc.c +2
-0+if (!pcms->acpi_dev) { +error_setg (&local_err,"not supported without acpi" );I suggest "CPU hot unplug not supported without ACPI" instead.
I've thought about it but considering error is issued in context of device_del command, I've opted for more concise variant.
Would you still like me to respin patch with your suggestion?
Quoted 11 lines
Quoted 10 lines
hw/i386/pc.c +3
-0+ goto out; + } +pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx);assert (idx !=-1 );if (idx ==0 ) {Signature · 1 line
2.7.4
Quoted 37 lines · Igor Mammedov
Quoted 34 lines · On Mon, 20 Nov 2017 12:44:54 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 8 lines · Igor Mammedov
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using
device_delresults in null pointer dereference at:#0
object_get_class
#1pc_machine_device_unplug_request_cb
#2qmp_marshal_device_delQuoted 8 lines
which is caused by
pcms->acpi_dev== NULL due to ACPI support being disabled.Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>But I have one small suggestion:
Quoted 12 lines
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)hw/i386/pc.c +0
-0@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev);
Quoted 8 lines
Quoted 4 lines
hw/i386/pc.c static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, · line 1846
Quoted 2 lines
hw/i386/pc.c +2
-0+if (!pcms->acpi_dev) { +error_setg (&local_err,"not supported without acpi" );I suggest "CPU hot unplug not supported without ACPI" instead.
I've thought about it but considering error is issued in context of
device_delcommand, I've opted for more concise variant.Would you still like me to respin patch with your suggestion?
I'd prefer to, so the error message would make sense even if out of context. But you still have my Reviewed-by in case Michael wants to apply this version.
Quoted 13 lines
Quoted 12 lines
Quoted 11 lines
hw/i386/pc.c +3
-0+ goto out; + } +pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx);assert (idx !=-1 );if (idx ==0 ) {Signature · 1 line
2.7.4
Signature · 1 line
Eduardo
Quoted 42 lines · Eduardo Habkost
Quoted 41 lines · Igor Mammedov
Quoted 38 lines · On Mon, 20 Nov 2017 12:44:54 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 8 lines · Igor Mammedov
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using
device_delresults in null pointer dereference at:#0
object_get_class
#1pc_machine_device_unplug_request_cb
#2qmp_marshal_device_delQuoted 8 lines
which is caused by
pcms->acpi_dev== NULL due to ACPI support being disabled.Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>But I have one small suggestion:
Quoted 9 lines
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)hw/i386/pc.c +0
-0hw/i386/pc.c static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, · line 1846
Quoted 5 lines
hw/i386/pc.c +2
-0@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev); +if (!pcms->acpi_dev) { +error_setg (&local_err,"not supported without acpi" );I suggest "CPU hot unplug not supported without ACPI" instead.
Quoted 8 lines
Quoted 4 lines
I've thought about it but considering error is issued in context of
device_delcommand, I've opted for more concise variant.Would you still like me to respin patch with your suggestion?
I'd prefer to, so the error message would make sense even if out of context. But you still have my Reviewed-by in case Michael wants to apply this version.
I made the change and queued the patch.
Paolo
Quoted 46 lines · On Tue, 28 Nov 2017 12:28:43 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 45 lines · Eduardo Habkost
Quoted 44 lines · Igor Mammedov
Quoted 34 lines · On Mon, 20 Nov 2017 12:44:54 -0200 Eduardo Habkost <[email protected]> wrote:
Quoted 8 lines · Igor Mammedov
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using
device_delresults in null pointer dereference at:#0
object_get_class
#1pc_machine_device_unplug_request_cb
#2qmp_marshal_device_delQuoted 8 lines
which is caused by
pcms->acpi_dev== NULL due to ACPI support being disabled.Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>But I have one small suggestion:
Quoted 12 lines
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)hw/i386/pc.c +0
-0@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev);Quoted 4 lines
hw/i386/pc.c static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, · line 1846
Quoted 2 lines
hw/i386/pc.c +2
-0+if (!pcms->acpi_dev) { +error_setg (&local_err,"not supported without acpi" );I suggest "CPU hot unplug not supported without ACPI" instead.
I've thought about it but considering error is issued in context of
device_delcommand, I've opted for more concise variant.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Would you still like me to respin patch with your suggestion?
I'd prefer to, so the error message would make sense even if out of context. But you still have my Reviewed-by in case Michael wants to apply this version.
I made the change and queued the patch.
I've thought Michael (CCed) queued v2
but he hasn't sent a pull req yet.
Quoted 1 line
Paolo