Skip to contentSkip to conversation

xen: Fix crash of "-machine xenfv, accel=kvm"

PATCH In review Eduardo Habkost 2 participants 6 messages Sep 28, 2015 – Sep 29, 2015

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 3ffb05f..8fab2f9 100644
@@ -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
Reviewed-by on v1 1/2
#2 lore raw

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").

Quoted 22 lines
 hw/i386/pc_piix.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc_piix.c +5 -0
index 3ffb05f..8fab2f9 100644
@@ -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
#3 lore raw

PATCH 2/2 xen-platform: Ensure xen is enabled when initializing

In reply to 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 checks xen_enabled().

---
 hw/i386/xen/xen_platform.c | 3 +++
 1 file changed, 3 insertions(+)
hw/i386/xen/xen_platform.c +3 -0
index ee45f03..8682c42 100644
@@ -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
Reviewed-by on v1 2/2
#4 lore raw

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 checks xen_enabled().

Quoted 20 lines
 hw/i386/xen/xen_platform.c | 3 +++
 1 file changed, 3 insertions(+)
hw/i386/xen/xen_platform.c +3 -0
index ee45f03..8682c42 100644
@@ -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
#5 lore raw
In reply to Eduardo Habkost
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 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
Quoted 7 lines

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(+)

All add them to my queue