Skip to contentSkip to conversation

hw/i386/pc: enable PVH only for machine type >= 4.0

PATCH In review Stefano Garzarella 4 participants 4 messages Jan 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/i386/pc: enable PVH only for machine type >= 4.0

In order to avoid migration issues, we enable PVH only for machine type >= 4.0

---
Based-on: <[email protected]>

 hw/i386/pc.c         | 4 +++-
 hw/i386/pc_piix.c    | 3 +++
 hw/i386/pc_q35.c     | 3 +++
 include/hw/i386/pc.h | 3 +++
 4 files changed, 12 insertions(+), 1 deletion(-)
hw/i386/pc.c +3 -1
index 2833b130ba..3be4a06c4f 100644
@@ -1211,7 +1211,8 @@ static void load_linux(PCMachineState *pcms,
          * saving the PVH entry point used by the x86/HVM direct boot ABI.
          * If load_elfboot() is successful, populate the fw_cfg info.
          */
-        if (load_elfboot(kernel_filename, kernel_size,
+        if (pcmc->pvh_enabled &&
+            load_elfboot(kernel_filename, kernel_size,
                          header, pvh_start_addr, fw_cfg)) {
             fclose(f);
 
@@ -2774,6 +2775,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     pcmc->acpi_data_size = 0x20000 + 0x8000;
     pcmc->save_tsc_khz = true;
     pcmc->linuxboot_dma_enabled = true;
+    pcmc->pvh_enabled = true;
     assert(!mc->get_hotplug_handler);
     mc->get_hotplug_handler = pc_get_hotpug_handler;
     mc->cpu_index_to_instance_props = pc_cpu_index_to_props;
hw/i386/pc_piix.c +3 -0
index 5088e2f492..a51b83e50e 100644
@@ -440,9 +440,12 @@ DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL,
 
 static void pc_i440fx_3_1_machine_options(MachineClass *m)
 {
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+
     pc_i440fx_4_0_machine_options(m);
     m->is_default = 0;
     m->alias = NULL;
+    pcmc->pvh_enabled = false;
     compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
     compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
 }
hw/i386/pc_q35.c +3 -0
index b7b7959934..4a175ea50e 100644
@@ -376,9 +376,12 @@ DEFINE_Q35_MACHINE(v4_0, "pc-q35-4.0", NULL,
 
 static void pc_q35_3_1_machine_options(MachineClass *m)
 {
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+
     pc_q35_4_0_machine_options(m);
     m->default_kernel_irqchip_split = false;
     m->alias = NULL;
+    pcmc->pvh_enabled = false;
     compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
     compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
 }
include/hw/i386/pc.h +3 -0
index 0abbe45637..e4e2c1352d 100644
@@ -133,6 +133,9 @@ struct PCMachineClass {
 
     /* use DMA capable linuxboot option rom */
     bool linuxboot_dma_enabled;
+
+    /* use PVH to load kernels that support this feature */
+    bool pvh_enabled;
 };
 
 #define TYPE_PC_MACHINE "generic-pc-machine"
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Stefano Garzarella

In order to avoid migration issues, we enable PVH only for machine type >= 4.0

Quoted 8 lines

---
Based-on: <[email protected]>

 hw/i386/pc.c         | 4 +++-
 hw/i386/pc_piix.c    | 3 +++
 hw/i386/pc_q35.c     | 3 +++
 include/hw/i386/pc.h | 3 +++
 4 files changed, 12 insertions(+), 1 deletion(-)
Reviewed-by on v1 1/1
#3 lore raw
In reply to Stefano Garzarella
Quoted 5 lines · Stefano Garzarella

In order to avoid migration issues, we enable PVH only for machine type >= 4.0

Quoted 80 lines

---
Based-on: <[email protected]>

  hw/i386/pc.c         | 4 +++-
  hw/i386/pc_piix.c    | 3 +++
  hw/i386/pc_q35.c     | 3 +++
  include/hw/i386/pc.h | 3 +++
  4 files changed, 12 insertions(+), 1 deletion(-)
hw/i386/pc.c +3 -1
index 2833b130ba..3be4a06c4f 100644
@@ -1211,7 +1211,8 @@ static void load_linux(PCMachineState *pcms,
           * saving the PVH entry point used by the x86/HVM direct boot ABI.
           * If load_elfboot() is successful, populate the fw_cfg info.
           */
-        if (load_elfboot(kernel_filename, kernel_size,
+        if (pcmc->pvh_enabled &&
+            load_elfboot(kernel_filename, kernel_size,
                           header, pvh_start_addr, fw_cfg)) {
              fclose(f);
 
@@ -2774,6 +2775,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
      pcmc->acpi_data_size = 0x20000 + 0x8000;
      pcmc->save_tsc_khz = true;
      pcmc->linuxboot_dma_enabled = true;
+    pcmc->pvh_enabled = true;
      assert(!mc->get_hotplug_handler);
      mc->get_hotplug_handler = pc_get_hotpug_handler;
      mc->cpu_index_to_instance_props = pc_cpu_index_to_props;
hw/i386/pc_piix.c +3 -0
index 5088e2f492..a51b83e50e 100644
@@ -440,9 +440,12 @@ DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL,
 
  static void pc_i440fx_3_1_machine_options(MachineClass *m)
  {
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+
      pc_i440fx_4_0_machine_options(m);
      m->is_default = 0;
      m->alias = NULL;
+    pcmc->pvh_enabled = false;
      compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
      compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
  }
hw/i386/pc_q35.c +3 -0
index b7b7959934..4a175ea50e 100644
@@ -376,9 +376,12 @@ DEFINE_Q35_MACHINE(v4_0, "pc-q35-4.0", NULL,
 
  static void pc_q35_3_1_machine_options(MachineClass *m)
  {
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+
      pc_q35_4_0_machine_options(m);
      m->default_kernel_irqchip_split = false;
      m->alias = NULL;
+    pcmc->pvh_enabled = false;
      compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
      compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
  }
include/hw/i386/pc.h +3 -0
index 0abbe45637..e4e2c1352d 100644
@@ -133,6 +133,9 @@ struct PCMachineClass {
 
      /* use DMA capable linuxboot option rom */
      bool linuxboot_dma_enabled;
+
+    /* use PVH to load kernels that support this feature */
+    bool pvh_enabled;
  };
 
  #define TYPE_PC_MACHINE "generic-pc-machine"