qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
@ 2013-05-13 17:04 Jordan Justen
  2013-05-13 19:01 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jordan Justen @ 2013-05-13 17:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jordan Justen, Anthony Liguori

The isapc machine with seabios currently requires the BIOS region
to be read/write memory rather than read-only memory.

KVM currently cannot support the BIOS as a ROM region, but qemu
in non-KVM mode can. Based on this, isapc machine currently only
works with KVM.

To work-around this isapc issue, this change avoids marking the
BIOS as readonly for isapc.

This change also will allow KVM to start supporting ROM mode
via KVM_CAP_READONLY_MEM.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
v2:
 * Fix build issue with this patch. Apologies for not testing
   this patch outside of my kvm-flash series.

 hw/block/pc_sysfw.c |   16 +++++++++++-----
 hw/i386/pc_piix.c   |    5 +++++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c
index aad8614..a02f320 100644
--- a/hw/block/pc_sysfw.c
+++ b/hw/block/pc_sysfw.c
@@ -39,6 +39,7 @@
 typedef struct PcSysFwDevice {
     SysBusDevice busdev;
     uint8_t rom_only;
+    uint8_t isapc_ram_fw;
 } PcSysFwDevice;
 
 static void pc_isa_bios_init(MemoryRegion *rom_memory,
@@ -139,7 +140,7 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
     pc_isa_bios_init(rom_memory, flash_mem, size);
 }
 
-static void old_pc_system_rom_init(MemoryRegion *rom_memory)
+static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
 {
     char *filename;
     MemoryRegion *bios, *isa_bios;
@@ -163,7 +164,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
     bios = g_malloc(sizeof(*bios));
     memory_region_init_ram(bios, "pc.bios", bios_size);
     vmstate_register_ram_global(bios);
-    memory_region_set_readonly(bios, true);
+    if (!isapc_ram_fw) {
+        memory_region_set_readonly(bios, true);
+    }
     ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
     if (ret != 0) {
     bios_error:
@@ -186,7 +189,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
                                         0x100000 - isa_bios_size,
                                         isa_bios,
                                         1);
-    memory_region_set_readonly(isa_bios, true);
+    if (!isapc_ram_fw) {
+        memory_region_set_readonly(isa_bios, true);
+    }
 
     /* map all the bios at the top of memory */
     memory_region_add_subregion(rom_memory,
@@ -216,7 +221,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
     qdev_init_nofail(DEVICE(sysfw_dev));
 
     if (sysfw_dev->rom_only) {
-        old_pc_system_rom_init(rom_memory);
+        old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
         return;
     }
 
@@ -234,7 +239,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
             exit(1);
         } else {
             sysfw_dev->rom_only = 1;
-            old_pc_system_rom_init(rom_memory);
+            old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
             return;
         }
     }
@@ -255,6 +260,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
 }
 
 static Property pcsysfw_properties[] = {
+    DEFINE_PROP_UINT8("isapc_ram_fw", PcSysFwDevice, isapc_ram_fw, 0),
     DEFINE_PROP_UINT8("rom_only", PcSysFwDevice, rom_only, 1),
     DEFINE_PROP_END_OF_LIST(),
 };
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index f7c80ad..c1a49ec 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -716,6 +716,11 @@ static QEMUMachine isapc_machine = {
             .property = "rom_only",
             .value    = stringify(1),
         },
+        {
+            .driver   = "pc-sysfw",
+            .property = "isapc_ram_fw",
+            .value    = stringify(1),
+        },
         { /* end of list */ }
     },
     DEFAULT_MACHINE_OPTIONS,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
  2013-05-13 17:04 [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS) Jordan Justen
@ 2013-05-13 19:01 ` Paolo Bonzini
  2013-05-14 14:57 ` Anthony Liguori
  2013-05-31 18:48 ` Anthony Liguori
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-05-13 19:01 UTC (permalink / raw)
  To: Jordan Justen; +Cc: qemu-devel, Anthony Liguori

Il 13/05/2013 19:04, Jordan Justen ha scritto:
> The isapc machine with seabios currently requires the BIOS region
> to be read/write memory rather than read-only memory.
> 
> KVM currently cannot support the BIOS as a ROM region, but qemu
> in non-KVM mode can. Based on this, isapc machine currently only
> works with KVM.
> 
> To work-around this isapc issue, this change avoids marking the
> BIOS as readonly for isapc.
> 
> This change also will allow KVM to start supporting ROM mode
> via KVM_CAP_READONLY_MEM.
> 
> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> v2:
>  * Fix build issue with this patch. Apologies for not testing
>    this patch outside of my kvm-flash series.

Not your fault, it conflicted semantically with another patch that was
committed in the meanwhile.

Paolo

>  hw/block/pc_sysfw.c |   16 +++++++++++-----
>  hw/i386/pc_piix.c   |    5 +++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c
> index aad8614..a02f320 100644
> --- a/hw/block/pc_sysfw.c
> +++ b/hw/block/pc_sysfw.c
> @@ -39,6 +39,7 @@
>  typedef struct PcSysFwDevice {
>      SysBusDevice busdev;
>      uint8_t rom_only;
> +    uint8_t isapc_ram_fw;
>  } PcSysFwDevice;
>  
>  static void pc_isa_bios_init(MemoryRegion *rom_memory,
> @@ -139,7 +140,7 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
>      pc_isa_bios_init(rom_memory, flash_mem, size);
>  }
>  
> -static void old_pc_system_rom_init(MemoryRegion *rom_memory)
> +static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
>  {
>      char *filename;
>      MemoryRegion *bios, *isa_bios;
> @@ -163,7 +164,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
>      bios = g_malloc(sizeof(*bios));
>      memory_region_init_ram(bios, "pc.bios", bios_size);
>      vmstate_register_ram_global(bios);
> -    memory_region_set_readonly(bios, true);
> +    if (!isapc_ram_fw) {
> +        memory_region_set_readonly(bios, true);
> +    }
>      ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
>      if (ret != 0) {
>      bios_error:
> @@ -186,7 +189,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
>                                          0x100000 - isa_bios_size,
>                                          isa_bios,
>                                          1);
> -    memory_region_set_readonly(isa_bios, true);
> +    if (!isapc_ram_fw) {
> +        memory_region_set_readonly(isa_bios, true);
> +    }
>  
>      /* map all the bios at the top of memory */
>      memory_region_add_subregion(rom_memory,
> @@ -216,7 +221,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
>      qdev_init_nofail(DEVICE(sysfw_dev));
>  
>      if (sysfw_dev->rom_only) {
> -        old_pc_system_rom_init(rom_memory);
> +        old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
>          return;
>      }
>  
> @@ -234,7 +239,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
>              exit(1);
>          } else {
>              sysfw_dev->rom_only = 1;
> -            old_pc_system_rom_init(rom_memory);
> +            old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
>              return;
>          }
>      }
> @@ -255,6 +260,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
>  }
>  
>  static Property pcsysfw_properties[] = {
> +    DEFINE_PROP_UINT8("isapc_ram_fw", PcSysFwDevice, isapc_ram_fw, 0),
>      DEFINE_PROP_UINT8("rom_only", PcSysFwDevice, rom_only, 1),
>      DEFINE_PROP_END_OF_LIST(),
>  };
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index f7c80ad..c1a49ec 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -716,6 +716,11 @@ static QEMUMachine isapc_machine = {
>              .property = "rom_only",
>              .value    = stringify(1),
>          },
> +        {
> +            .driver   = "pc-sysfw",
> +            .property = "isapc_ram_fw",
> +            .value    = stringify(1),
> +        },
>          { /* end of list */ }
>      },
>      DEFAULT_MACHINE_OPTIONS,
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
  2013-05-13 17:04 [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS) Jordan Justen
  2013-05-13 19:01 ` Paolo Bonzini
@ 2013-05-14 14:57 ` Anthony Liguori
  2013-05-15 16:50   ` Jordan Justen
  2013-05-31 18:48 ` Anthony Liguori
  2 siblings, 1 reply; 5+ messages in thread
From: Anthony Liguori @ 2013-05-14 14:57 UTC (permalink / raw)
  To: Jordan Justen, qemu-devel

Jordan Justen <jordan.l.justen@intel.com> writes:

> The isapc machine with seabios currently requires the BIOS region
> to be read/write memory rather than read-only memory.
>
> KVM currently cannot support the BIOS as a ROM region, but qemu
> in non-KVM mode can. Based on this, isapc machine currently only
> works with KVM.
>
> To work-around this isapc issue, this change avoids marking the
> BIOS as readonly for isapc.
>
> This change also will allow KVM to start supporting ROM mode
> via KVM_CAP_READONLY_MEM.
>
> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> v2:
>  * Fix build issue with this patch. Apologies for not testing
>    this patch outside of my kvm-flash series.

This needs to be rebased post-Paolo's revert.

Make sure you've got at least:

commit 9e1c2ec8fd8d9a9ee299ea86c5f6c986fe25e838
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Fri May 10 14:38:03 2013 +0200

    Revert "pc: Kill the "use flash device for BIOS unless KVM" misfeature"
 
Regards,

Anthony Liguori

>
>  hw/block/pc_sysfw.c |   16 +++++++++++-----
>  hw/i386/pc_piix.c   |    5 +++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c
> index aad8614..a02f320 100644
> --- a/hw/block/pc_sysfw.c
> +++ b/hw/block/pc_sysfw.c
> @@ -39,6 +39,7 @@
>  typedef struct PcSysFwDevice {
>      SysBusDevice busdev;
>      uint8_t rom_only;
> +    uint8_t isapc_ram_fw;
>  } PcSysFwDevice;
>  
>  static void pc_isa_bios_init(MemoryRegion *rom_memory,
> @@ -139,7 +140,7 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
>      pc_isa_bios_init(rom_memory, flash_mem, size);
>  }
>  
> -static void old_pc_system_rom_init(MemoryRegion *rom_memory)
> +static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
>  {
>      char *filename;
>      MemoryRegion *bios, *isa_bios;
> @@ -163,7 +164,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
>      bios = g_malloc(sizeof(*bios));
>      memory_region_init_ram(bios, "pc.bios", bios_size);
>      vmstate_register_ram_global(bios);
> -    memory_region_set_readonly(bios, true);
> +    if (!isapc_ram_fw) {
> +        memory_region_set_readonly(bios, true);
> +    }
>      ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
>      if (ret != 0) {
>      bios_error:
> @@ -186,7 +189,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
>                                          0x100000 - isa_bios_size,
>                                          isa_bios,
>                                          1);
> -    memory_region_set_readonly(isa_bios, true);
> +    if (!isapc_ram_fw) {
> +        memory_region_set_readonly(isa_bios, true);
> +    }
>  
>      /* map all the bios at the top of memory */
>      memory_region_add_subregion(rom_memory,
> @@ -216,7 +221,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
>      qdev_init_nofail(DEVICE(sysfw_dev));
>  
>      if (sysfw_dev->rom_only) {
> -        old_pc_system_rom_init(rom_memory);
> +        old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
>          return;
>      }
>  
> @@ -234,7 +239,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
>              exit(1);
>          } else {
>              sysfw_dev->rom_only = 1;
> -            old_pc_system_rom_init(rom_memory);
> +            old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
>              return;
>          }
>      }
> @@ -255,6 +260,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
>  }
>  
>  static Property pcsysfw_properties[] = {
> +    DEFINE_PROP_UINT8("isapc_ram_fw", PcSysFwDevice, isapc_ram_fw, 0),
>      DEFINE_PROP_UINT8("rom_only", PcSysFwDevice, rom_only, 1),
>      DEFINE_PROP_END_OF_LIST(),
>  };
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index f7c80ad..c1a49ec 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -716,6 +716,11 @@ static QEMUMachine isapc_machine = {
>              .property = "rom_only",
>              .value    = stringify(1),
>          },
> +        {
> +            .driver   = "pc-sysfw",
> +            .property = "isapc_ram_fw",
> +            .value    = stringify(1),
> +        },
>          { /* end of list */ }
>      },
>      DEFAULT_MACHINE_OPTIONS,
> -- 
> 1.7.10.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
  2013-05-14 14:57 ` Anthony Liguori
@ 2013-05-15 16:50   ` Jordan Justen
  0 siblings, 0 replies; 5+ messages in thread
From: Jordan Justen @ 2013-05-15 16:50 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Jordan Justen, qemu-devel

On Tue, May 14, 2013 at 7:57 AM, Anthony Liguori <anthony@codemonkey.ws> wrote:
> Jordan Justen <jordan.l.justen@intel.com> writes:
>
>> The isapc machine with seabios currently requires the BIOS region
>> to be read/write memory rather than read-only memory.
>>
>> KVM currently cannot support the BIOS as a ROM region, but qemu
>> in non-KVM mode can. Based on this, isapc machine currently only
>> works with KVM.
>>
>> To work-around this isapc issue, this change avoids marking the
>> BIOS as readonly for isapc.
>>
>> This change also will allow KVM to start supporting ROM mode
>> via KVM_CAP_READONLY_MEM.
>>
>> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
>> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> v2:
>>  * Fix build issue with this patch. Apologies for not testing
>>    this patch outside of my kvm-flash series.
>
> This needs to be rebased post-Paolo's revert.
>
> Make sure you've got at least:
>
> commit 9e1c2ec8fd8d9a9ee299ea86c5f6c986fe25e838
> Author: Paolo Bonzini <pbonzini@redhat.com>
> Date:   Fri May 10 14:38:03 2013 +0200
>
>     Revert "pc: Kill the "use flash device for BIOS unless KVM" misfeature"

I re-posted this as Patch 1 in v6 of my kvm-flash series.

-Jordan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
  2013-05-13 17:04 [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS) Jordan Justen
  2013-05-13 19:01 ` Paolo Bonzini
  2013-05-14 14:57 ` Anthony Liguori
@ 2013-05-31 18:48 ` Anthony Liguori
  2 siblings, 0 replies; 5+ messages in thread
From: Anthony Liguori @ 2013-05-31 18:48 UTC (permalink / raw)
  To: Jordan Justen, qemu-devel

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-31 18:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-13 17:04 [Qemu-devel] [PATCH v2] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS) Jordan Justen
2013-05-13 19:01 ` Paolo Bonzini
2013-05-14 14:57 ` Anthony Liguori
2013-05-15 16:50   ` Jordan Justen
2013-05-31 18:48 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).