xen: Fix crash of "-machine xenfv, accel=kvm"
cover xen: Fix crash of "-machine xenfv, accel=kvm"
This series fixes the following crash:
$ ./x86_64-softmmu/qemu-system-x86_64 -machine xenfv,accel=kvm Segmentation fault (core dumped)
The crash happens because xen-platform calls xc_hvm_set_mem_type() with a NULL xen_xc on reset, at platform_fixed_ioport_writeb().
Crash is replaced by the following error message:
$ ./x86_64-softmmu/qemu-system-x86_64 -machine xenfv,accel=kvm qemu-system-x86_64: xenfv machine requires the xen accelerator
Eduardo Habkost (2):
pc: Require xen when initializing xenfv machine
xen-platform: Ensure xen is enabled when initializing
hw/i386/pc_piix.c | 5 +++++ hw/i386/xen/xen_platform.c | 3 +++ 2 files changed, 8 insertions(+)
Signature · 1 line
2.1.0
PATCH 1/2 pc: Require xen when initializing xenfv machine
Without this check, the xen-platform device will crash on reset if using the accel option with anything other than xen (e.g. "-machine xenfv,accel=kvm").
--- hw/i386/pc_piix.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/i386/pc_piix.c +5 -0
@@ -434,6 +434,11 @@ static void pc_xen_hvm_init(MachineState *machine) {PCIBus *bus; +if (!xen_enabled ()) { +error_report ("xenfv machine requires the xen accelerator" ); +exit (1 ); + } +pc_xen_hvm_init_pci (machine); bus =pci_find_primary_bus ();
Signature · 1 line
2.1.0
Re: [Qemu-devel] [PATCH 1/2] pc: Require xen when initializing xenfv machine
Quoted 5 lines · Eduardo Habkost
Without this check, the xen-platform device will crash on reset if using the accel option with anything other than xen (e.g. "-machine xenfv,accel=kvm").
Signed-off-by Eduardo Habkost <[email protected]>
Quoted 22 lines
hw/i386/pc_piix.c | 5 +++++ 1 file changed, 5 insertions(+)hw/i386/pc_piix.c +5
-0@@ -434,6 +434,11 @@ static void pc_xen_hvm_init(MachineState *machine) {PCIBus *bus; +if (!xen_enabled ()) { +error_report ("xenfv machine requires the xen accelerator" ); +exit (1 ); + } +pc_xen_hvm_init_pci (machine); bus =pci_find_primary_bus ();Signature · 1 line
2.1.0
PATCH 2/2 xen-platform: Ensure xen is enabled when initializing
In reply to Eduardo HabkostThe xen-platform code crashes on reset if the xen backend is not initialized, because it calls xc_hvm_set_mem_type(). Ensure xen-platform won't be created without initializing the xen backend.
The assert can't be triggered by the user because the device is not hotpluggable, and the only code creating it (at pc_xen_hvm_init()) already checks xen_enabled().
--- hw/i386/xen/xen_platform.c | 3 +++ 1 file changed, 3 insertions(+)
hw/i386/xen/xen_platform.c +3 -0
@@ -387,6 +387,9 @@ static int xen_platform_initfn(PCIDevice *dev)PCIXenPlatformState *d =XEN_PLATFORM (dev);uint8_t *pci_conf; +/* Device will crash on reset if xen is not initialized */ +assert (xen_enabled ()); + pci_conf = dev->config;pci_set_word (pci_conf +PCI_COMMAND ,PCI_COMMAND_IO |PCI_COMMAND_MEMORY );
Signature · 1 line
2.1.0
Re: [Qemu-devel] [PATCH 2/2] xen-platform: Ensure xen is enabled when initializing
Quoted 9 lines · Eduardo Habkost
The xen-platform code crashes on reset if the xen backend is not initialized, because it calls
xc_hvm_set_mem_type(). Ensure xen-platform won't be created without initializing the xen backend.The assert can't be triggered by the user because the device is not hotpluggable, and the only code creating it (at
pc_xen_hvm_init()) already checksxen_enabled().Signed-off-by Eduardo Habkost <[email protected]>
Quoted 20 lines
hw/i386/xen/xen_platform.c | 3 +++ 1 file changed, 3 insertions(+)hw/i386/xen/xen_platform.c +3
-0@@ -387,6 +387,9 @@ static int xen_platform_initfn(PCIDevice *dev)PCIXenPlatformState *d =XEN_PLATFORM (dev);uint8_t *pci_conf; +/* Device will crash on reset if xen is not initialized */ +assert (xen_enabled ()); + pci_conf = dev->config;pci_set_word (pci_conf +PCI_COMMAND ,PCI_COMMAND_IO |PCI_COMMAND_MEMORY );Signature · 1 line
2.1.0
Quoted 13 lines · Eduardo Habkost
This series fixes the following crash:
$ ./x86_64-softmmu/qemu-system-x86_64 -machine xenfv,accel=kvm Segmentation fault (core dumped)The crash happens because xen-platform calls
xc_hvm_set_mem_type()with a NULLxen_xcon reset, atplatform_fixed_ioport_writeb().Crash is replaced by the following error message:
$ ./x86_64-softmmu/qemu-system-x86_64 -machine xenfv,accel=kvm qemu-system-x86_64: xenfv machine requires the xen accelerator
Quoted 7 lines
Eduardo Habkost (2):
pc: Require xen when initializing xenfv machine
xen-platform: Ensure xen is enabled when initializinghw/i386/pc_piix.c | 5 +++++ hw/i386/xen/xen_platform.c | 3 +++ 2 files changed, 8 insertions(+)
All add them to my queue