pc: make sure that guest isn't able to unplug the first cpu
commitc2d2a81b4196984fb74276826892838b5b69d92c
authorIgor Mammedov <imammedo@redhat.com>
Mon, 27 Aug 2018 11:07:10 +0000 (27 13:07 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 7 Sep 2018 21:05:18 +0000 (7 17:05 -0400)
tree5b47b1c92bb73e0dd3d032ca4225a3d31b943939
parent6755e618d09a81a82ab67a6163ffc9a39e743d0b
pc: make sure that guest isn't able to unplug the first cpu

The first cpu unplug wasn't ever supported and corresponding
monitor/qmp commands refuse to unplug it. However guest is able
to issue eject request either using following command:
  # echo 1 >/sys/devices/system/cpu/cpu0/firmware_node/eject
or directly writing to cpu hotplug registers, which makes
qemu crash with SIGSEGV following back trace:

   kvm_flush_coalesced_mmio_buffer ()
       while (ring->first != ring->last)
   ...
   qemu_flush_coalesced_mmio_buffer
   prepare_mmio_access
   flatview_read_continue
   flatview_read
   address_space_read_full
   address_space_rw
   kvm_cpu_exec(cpu!0)
   qemu_kvm_cpu_thread_fn

the reason for which is that ring == KVMState::coalesced_mmio_ring
happens to be a part of 1st CPU that was uplugged by guest.

Fix it by forbidding 1st cpu unplug from guest side and in addition
remove CPU0._EJ0 ACPI method to make clear that unplug of the first
CPU is not supported.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/acpi/cpu.c