Skip to contentSkip to conversation

Fix ram_memory initialization under Xen

PATCH In review Anthony PERARD 3 participants 5 messages Sep 2, 2013 – Sep 6, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover Fix ram_memory initialization under Xen

Hi all,

The first patch fix the initialization of ram_memory in pc_init1() in pc_piix.c.

The second call the initialization code of Xen while running with the Q35 chipset even if Q35 still those not work with Xen. There need some work in the HVM Loader and in libxl at least.

Thanks,

Anthony PERARD (2):
pc: Initializing ram_memory under Xen.
pc_q35: Initialize Xen.

 hw/i386/pc_piix.c    | 2 +-
 hw/i386/pc_q35.c     | 5 +++++
 include/hw/xen/xen.h | 4 +---
 xen-all.c            | 7 ++++---
 4 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
Anthony PERARD
#1 lore raw

PATCH v2 1/2 pc: Initializing ram_memory under Xen.

---
 hw/i386/pc_piix.c    | 2 +-
 include/hw/xen/xen.h | 4 +---
 xen-all.c            | 7 ++++---
 3 files changed, 6 insertions(+), 7 deletions(-)
hw/i386/pc_piix.c +1 -1
index 3c36a2a..a5ea582 100644
@@ -89,7 +89,7 @@ static void pc_init1(QEMUMachineInitArgs *args,
     FWCfgState *fw_cfg = NULL;
     PcGuestInfo *guest_info;
 
-    if (xen_enabled() && xen_hvm_init() != 0) {
+    if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
         fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
         exit(1);
     }
include/hw/xen/xen.h +1 -3
index 6d42dd1..e1f88bf 100644
@@ -37,17 +37,15 @@ void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
 qemu_irq *xen_interrupt_controller_init(void);
 
 int xen_init(void);
-int xen_hvm_init(void);
+int xen_hvm_init(MemoryRegion **ram_memory);
 void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
 
 #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
-struct MemoryRegion;
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
                    struct MemoryRegion *mr);
 void xen_modified_memory(ram_addr_t start, ram_addr_t length);
 #endif
 
-struct MemoryRegion;
 void xen_register_framebuffer(struct MemoryRegion *mr);
 
 #if defined(CONFIG_XEN) && CONFIG_XEN_CTRL_INTERFACE_VERSION < 400
xen-all.c +4 -3
index eb13111..839f14f 100644
@@ -154,7 +154,7 @@ qemu_irq *xen_interrupt_controller_init(void)
 
 /* Memory Ops */
 
-static void xen_ram_init(ram_addr_t ram_size)
+static void xen_ram_init(ram_addr_t ram_size, MemoryRegion **ram_memory_p)
 {
     MemoryRegion *sysmem = get_system_memory();
     ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
@@ -168,6 +168,7 @@ static void xen_ram_init(ram_addr_t ram_size)
         block_len += HVM_BELOW_4G_MMIO_LENGTH;
     }
     memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len);
+    *ram_memory_p = &ram_memory;
     vmstate_register_ram_global(&ram_memory);
 
     if (ram_size >= HVM_BELOW_4G_RAM_END) {
@@ -1059,7 +1060,7 @@ static void xen_read_physmap(XenIOState *state)
     free(entries);
 }
 
-int xen_hvm_init(void)
+int xen_hvm_init(MemoryRegion **ram_memory)
 {
     int i, rc;
     unsigned long ioreq_pfn;
@@ -1134,7 +1135,7 @@ int xen_hvm_init(void)
 
     /* Init RAM management */
     xen_map_cache_init(xen_phys_offset_to_gaddr, state);
-    xen_ram_init(ram_size);
+    xen_ram_init(ram_size, ram_memory);
 
     qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
 
Signature · 1 line
Anthony PERARD
#2 lore raw

PATCH v2 2/2 pc_q35: Initialize Xen.

In reply to Anthony PERARD

---

Right now, starting an HVM with Q35 chipset those not works because HVMLoader (the Xen pre-bios) look for the standard chipset i440FX. Especialy the PCI/ISA bridge.

Error message from HVMLoader:
assertion '(devfn != PCI_ISA_DEVFN) || ((vendor_id == 0x8086) && (device_id == 0x7000))'

with PCI_ISA_DEVFN 0x08 /* dev 1, fn 0 */

---
 hw/i386/pc_q35.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/i386/pc_q35.c +5 -0
index 198c785..51b93f0 100644
@@ -76,6 +76,11 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
     DeviceState *icc_bridge;
     PcGuestInfo *guest_info;
 
+    if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
+        fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
+        exit(1);
+    }
+
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
Signature · 1 line
Anthony PERARD
Acked-by on the v2 series
#3 lore raw
In reply to Anthony PERARD
Quoted 9 lines · Anthony PERARD

Hi all,

The first patch fix the initialization of ram_memory in pc_init1() in pc_piix.c.

The second call the initialization code of Xen while running with the Q35 chipset even if Q35 still those not work with Xen. There need some work in the HVM Loader and in libxl at least.

Thanks,

For the series,

Quoted 12 lines

Anthony PERARD (2):
pc: Initializing ram_memory under Xen.
pc_q35: Initialize Xen.

 hw/i386/pc_piix.c    | 2 +-
 hw/i386/pc_q35.c     | 5 +++++
 include/hw/xen/xen.h | 4 +---
 xen-all.c            | 7 ++++---
 4 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
Anthony PERARD
#4 lore raw

v2 cover Fix ram_memory initialization under Xen

In reply to Anthony PERARD
Quoted 14 lines

Hi all,

The first patch fix the initialization of ram_memory in pc_init1() in pc_piix.c.

The second call the initialization code of Xen while running with the Q35 chipset even if Q35 still those not work with Xen. There need some work in the HVM Loader and in libxl at least.

Thanks,

Anthony PERARD (2):
pc: Initializing ram_memory under Xen.
pc_q35: Initialize Xen.

Quoted 8 lines
  hw/i386/pc_piix.c    | 2 +-
  hw/i386/pc_q35.c     | 5 +++++
  include/hw/xen/xen.h | 4 +---
  xen-all.c            | 7 ++++---
  4 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
Anthony PERARD

This fix for critical bugs with hvm domUs start posted 4 days ago from Anthony Perard seem to be good and complete. Can be added to qemu git and also backported to 1.6 stable branch?