Re: [SeaBIOS] [PATCH v2 4/4] i386: ACPI table generation code from seabios

2013-07-08 Thread Michael S. Tsirkin
On Mon, Jul 08, 2013 at 02:16:13PM -0500, Anthony Liguori wrote:
> "Michael S. Tsirkin"  writes:
> 
> > This adds C code for generating ACPI tables at runtime,
> > imported from seabios git tree
> > commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd
> >
> > Although ACPI tables come from a system BIOS on real hw,
> > it makes sense that the ACPI tables are coupled with the
> > virtual machine, since they have to abstract the x86 machine to
> > the OS's.
> >
> > This is widely desired as a way to avoid the churn
> > and proliferation of QEMU-specific interfaces
> > associated with ACPI tables in bios code.
> >
> > Notes:
> > The code structure was intentionally kept as close
> > to the seabios original as possible, to simplify
> > comparison and making sure we didn't lose anything
> > in translation.
> >
> > Minor code duplication results, to help ensure there are no functional
> > regressions, I think it's better to merge it like this and do more code
> > changes in follow-up patches.
> >
> > Cross-version compatibility concerns have been addressed:
> > ACPI tables are exposed to guest as FW_CFG entries.
> > When running with -M 1.5 and older, this patch disables ACPI
> > table generation, and doesn't expose ACPI
> > tables to guest.
> >
> > As table content is likely to change over time,
> > the following measures are taken to simplify
> > cross-version migration:
> > - All tables besides the RSDP are packed in a single FW CFG entry.
> >   This entry size is currently 23K. We round it up to 64K
> >   to avoid too much churn there.
> > - Tables are placed in special ROM blob (not mapped into guest memory)
> >   which is automatically migrated together with the guest, same
> >   as BIOS code.
> 
> This seems reasonable.
> 
> >
> > This patch reuses some code from SeaBIOS, which was originally under
> > LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This
> > relicensing has been acked by all contributors that had contributed to the
> > code since the v2->v3 relicense. ACKs approving the v2+ relicensing are
> > listed below. The list might include ACKs from people not holding
> > copyright on any parts of the reused code, but it's better to err on the
> > side of caution and include them.
> 
> Thank you for collecting the Acks.
> 
> >
> > Affected SeaBIOS files (GPLv2+ license headers added)
> > :
> >
> >  src/acpi-dsdt-cpu-hotplug.dsl
> >  src/acpi-dsdt-dbug.dsl
> >  src/acpi-dsdt-hpet.dsl
> >  src/acpi-dsdt-isa.dsl
> >  src/acpi-dsdt-pci-crs.dsl
> >  src/acpi.c
> >  src/acpi.h
> >  src/ssdt-misc.dsl
> >  src/ssdt-pcihp.dsl
> >  src/ssdt-proc.dsl
> >  tools/acpi_extract.py
> >  tools/acpi_extract_preprocess.py
> >
> > Each one of the listed people agreed to the following:
> >
> >> If you allow the use of your contribution in QEMU under the
> >> terms of GPLv2 or later as proposed by this patch,
> >> please respond to this mail including the line:
> >>
> >> Acked-by: Name 
> >
> >   Acked-by: Gerd Hoffmann 
> >   Acked-by: Jan Kiszka 
> >   Acked-by: Jason Baron 
> >   Acked-by: David Woodhouse 
> >   Acked-by: Gleb Natapov 
> >   Acked-by: Marcelo Tosatti 
> >   Acked-by: Dave Frodin 
> >   Acked-by: Paolo Bonzini 
> >   Acked-by: Kevin O'Connor 
> >   Acked-by: Laszlo Ersek 
> >   Acked-by: Kenji Kaneshige 
> >   Acked-by: Isaku Yamahata 
> >   Acked-by: Magnus Christensson 
> >   Acked-by: Hu Tao 
> >   Acked-by: Eduardo Habkost 
> >
> > Signed-off-by: Michael S. Tsirkin 
> > ---
> >  hw/i386/Makefile.objs|   2 +
> >  hw/i386/acpi-build.c | 723 
> > +++
> >  hw/i386/acpi-defs.h  | 327 +++
> >  hw/i386/pc.c |   2 +
> >  hw/i386/pc_piix.c|   3 +
> >  hw/i386/pc_q35.c |   3 +
> >  hw/i386/ssdt-misc.dsl|  46 +++
> >  include/hw/i386/acpi-build.h |   9 +
> >  include/hw/i386/pc.h |   1 +
> >  9 files changed, 1116 insertions(+)
> >  create mode 100644 hw/i386/acpi-build.c
> >  create mode 100644 hw/i386/acpi-defs.h
> >  create mode 100644 include/hw/i386/acpi-build.h
> >
> > diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
> > index e783050..2ab2572 100644
> > --- a/hw/i386/Makefile.objs
> > +++ b/hw/i386/Makefile.objs
> > @@ -4,7 +4,9 @@ obj-y += pc.o pc_piix.o pc_q35.o
> >  obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
> >  
> >  obj-y += kvmvapic.o
> > +obj-y += acpi-build.o
> >  obj-y += bios-linker-loader.o
> > +hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex 
> > hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex 
> > hw/i386/q35-acpi-dsdt.hex
> >  hw/i386/pc_piix.o: hw/i386/pc_piix.c hw/i386/acpi-dsdt.hex
> >  hw/i386/pc_q35.o: hw/i386/pc_q35.c hw/i386/q35-acpi-dsdt.hex
> >  
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > new file mode 100644
> > index 000..bc44

Re: [SeaBIOS] [PATCH v2 4/4] i386: ACPI table generation code from seabios

2013-07-08 Thread Anthony Liguori
"Michael S. Tsirkin"  writes:

> This adds C code for generating ACPI tables at runtime,
> imported from seabios git tree
> commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd
>
> Although ACPI tables come from a system BIOS on real hw,
> it makes sense that the ACPI tables are coupled with the
> virtual machine, since they have to abstract the x86 machine to
> the OS's.
>
> This is widely desired as a way to avoid the churn
> and proliferation of QEMU-specific interfaces
> associated with ACPI tables in bios code.
>
> Notes:
> The code structure was intentionally kept as close
> to the seabios original as possible, to simplify
> comparison and making sure we didn't lose anything
> in translation.
>
> Minor code duplication results, to help ensure there are no functional
> regressions, I think it's better to merge it like this and do more code
> changes in follow-up patches.
>
> Cross-version compatibility concerns have been addressed:
> ACPI tables are exposed to guest as FW_CFG entries.
> When running with -M 1.5 and older, this patch disables ACPI
> table generation, and doesn't expose ACPI
> tables to guest.
>
> As table content is likely to change over time,
> the following measures are taken to simplify
> cross-version migration:
> - All tables besides the RSDP are packed in a single FW CFG entry.
>   This entry size is currently 23K. We round it up to 64K
>   to avoid too much churn there.
> - Tables are placed in special ROM blob (not mapped into guest memory)
>   which is automatically migrated together with the guest, same
>   as BIOS code.

This seems reasonable.

>
> This patch reuses some code from SeaBIOS, which was originally under
> LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This
> relicensing has been acked by all contributors that had contributed to the
> code since the v2->v3 relicense. ACKs approving the v2+ relicensing are
> listed below. The list might include ACKs from people not holding
> copyright on any parts of the reused code, but it's better to err on the
> side of caution and include them.

Thank you for collecting the Acks.

>
> Affected SeaBIOS files (GPLv2+ license headers added)
> :
>
>  src/acpi-dsdt-cpu-hotplug.dsl
>  src/acpi-dsdt-dbug.dsl
>  src/acpi-dsdt-hpet.dsl
>  src/acpi-dsdt-isa.dsl
>  src/acpi-dsdt-pci-crs.dsl
>  src/acpi.c
>  src/acpi.h
>  src/ssdt-misc.dsl
>  src/ssdt-pcihp.dsl
>  src/ssdt-proc.dsl
>  tools/acpi_extract.py
>  tools/acpi_extract_preprocess.py
>
> Each one of the listed people agreed to the following:
>
>> If you allow the use of your contribution in QEMU under the
>> terms of GPLv2 or later as proposed by this patch,
>> please respond to this mail including the line:
>>
>> Acked-by: Name 
>
>   Acked-by: Gerd Hoffmann 
>   Acked-by: Jan Kiszka 
>   Acked-by: Jason Baron 
>   Acked-by: David Woodhouse 
>   Acked-by: Gleb Natapov 
>   Acked-by: Marcelo Tosatti 
>   Acked-by: Dave Frodin 
>   Acked-by: Paolo Bonzini 
>   Acked-by: Kevin O'Connor 
>   Acked-by: Laszlo Ersek 
>   Acked-by: Kenji Kaneshige 
>   Acked-by: Isaku Yamahata 
>   Acked-by: Magnus Christensson 
>   Acked-by: Hu Tao 
>   Acked-by: Eduardo Habkost 
>
> Signed-off-by: Michael S. Tsirkin 
> ---
>  hw/i386/Makefile.objs|   2 +
>  hw/i386/acpi-build.c | 723 
> +++
>  hw/i386/acpi-defs.h  | 327 +++
>  hw/i386/pc.c |   2 +
>  hw/i386/pc_piix.c|   3 +
>  hw/i386/pc_q35.c |   3 +
>  hw/i386/ssdt-misc.dsl|  46 +++
>  include/hw/i386/acpi-build.h |   9 +
>  include/hw/i386/pc.h |   1 +
>  9 files changed, 1116 insertions(+)
>  create mode 100644 hw/i386/acpi-build.c
>  create mode 100644 hw/i386/acpi-defs.h
>  create mode 100644 include/hw/i386/acpi-build.h
>
> diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
> index e783050..2ab2572 100644
> --- a/hw/i386/Makefile.objs
> +++ b/hw/i386/Makefile.objs
> @@ -4,7 +4,9 @@ obj-y += pc.o pc_piix.o pc_q35.o
>  obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
>  
>  obj-y += kvmvapic.o
> +obj-y += acpi-build.o
>  obj-y += bios-linker-loader.o
> +hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex 
> hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex 
> hw/i386/q35-acpi-dsdt.hex
>  hw/i386/pc_piix.o: hw/i386/pc_piix.c hw/i386/acpi-dsdt.hex
>  hw/i386/pc_q35.o: hw/i386/pc_q35.c hw/i386/q35-acpi-dsdt.hex
>  
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> new file mode 100644
> index 000..bc44f95
> --- /dev/null
> +++ b/hw/i386/acpi-build.c
> @@ -0,0 +1,723 @@
> +/* Support for generating ACPI tables and passing them to Guests
> + *
> + * Copyright (C) 2008-2010  Kevin O'Connor 
> + * Copyright (C) 2006 Fabrice Bellard
> + * Copyright (C) 2013 Red Hat Inc
> + *
> + * Author: Michael S. Tsirkin 
> + *
> + * This pr

[SeaBIOS] [PATCH v2 4/4] i386: ACPI table generation code from seabios

2013-07-08 Thread Michael S. Tsirkin
This adds C code for generating ACPI tables at runtime,
imported from seabios git tree
commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd

Although ACPI tables come from a system BIOS on real hw,
it makes sense that the ACPI tables are coupled with the
virtual machine, since they have to abstract the x86 machine to
the OS's.

This is widely desired as a way to avoid the churn
and proliferation of QEMU-specific interfaces
associated with ACPI tables in bios code.

Notes:
The code structure was intentionally kept as close
to the seabios original as possible, to simplify
comparison and making sure we didn't lose anything
in translation.

Minor code duplication results, to help ensure there are no functional
regressions, I think it's better to merge it like this and do more code
changes in follow-up patches.

Cross-version compatibility concerns have been addressed:
ACPI tables are exposed to guest as FW_CFG entries.
When running with -M 1.5 and older, this patch disables ACPI
table generation, and doesn't expose ACPI
tables to guest.

As table content is likely to change over time,
the following measures are taken to simplify
cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry.
  This entry size is currently 23K. We round it up to 64K
  to avoid too much churn there.
- Tables are placed in special ROM blob (not mapped into guest memory)
  which is automatically migrated together with the guest, same
  as BIOS code.

This patch reuses some code from SeaBIOS, which was originally under
LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This
relicensing has been acked by all contributors that had contributed to the
code since the v2->v3 relicense. ACKs approving the v2+ relicensing are
listed below. The list might include ACKs from people not holding
copyright on any parts of the reused code, but it's better to err on the
side of caution and include them.

Affected SeaBIOS files (GPLv2+ license headers added)
:

 src/acpi-dsdt-cpu-hotplug.dsl
 src/acpi-dsdt-dbug.dsl
 src/acpi-dsdt-hpet.dsl
 src/acpi-dsdt-isa.dsl
 src/acpi-dsdt-pci-crs.dsl
 src/acpi.c
 src/acpi.h
 src/ssdt-misc.dsl
 src/ssdt-pcihp.dsl
 src/ssdt-proc.dsl
 tools/acpi_extract.py
 tools/acpi_extract_preprocess.py

Each one of the listed people agreed to the following:

> If you allow the use of your contribution in QEMU under the
> terms of GPLv2 or later as proposed by this patch,
> please respond to this mail including the line:
>
> Acked-by: Name 

  Acked-by: Gerd Hoffmann 
  Acked-by: Jan Kiszka 
  Acked-by: Jason Baron 
  Acked-by: David Woodhouse 
  Acked-by: Gleb Natapov 
  Acked-by: Marcelo Tosatti 
  Acked-by: Dave Frodin 
  Acked-by: Paolo Bonzini 
  Acked-by: Kevin O'Connor 
  Acked-by: Laszlo Ersek 
  Acked-by: Kenji Kaneshige 
  Acked-by: Isaku Yamahata 
  Acked-by: Magnus Christensson 
  Acked-by: Hu Tao 
  Acked-by: Eduardo Habkost 

Signed-off-by: Michael S. Tsirkin 
---
 hw/i386/Makefile.objs|   2 +
 hw/i386/acpi-build.c | 723 +++
 hw/i386/acpi-defs.h  | 327 +++
 hw/i386/pc.c |   2 +
 hw/i386/pc_piix.c|   3 +
 hw/i386/pc_q35.c |   3 +
 hw/i386/ssdt-misc.dsl|  46 +++
 include/hw/i386/acpi-build.h |   9 +
 include/hw/i386/pc.h |   1 +
 9 files changed, 1116 insertions(+)
 create mode 100644 hw/i386/acpi-build.c
 create mode 100644 hw/i386/acpi-defs.h
 create mode 100644 include/hw/i386/acpi-build.h

diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index e783050..2ab2572 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -4,7 +4,9 @@ obj-y += pc.o pc_piix.o pc_q35.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 obj-y += kvmvapic.o
+obj-y += acpi-build.o
 obj-y += bios-linker-loader.o
+hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex 
hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex 
hw/i386/q35-acpi-dsdt.hex
 hw/i386/pc_piix.o: hw/i386/pc_piix.c hw/i386/acpi-dsdt.hex
 hw/i386/pc_q35.o: hw/i386/pc_q35.c hw/i386/q35-acpi-dsdt.hex
 
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
new file mode 100644
index 000..bc44f95
--- /dev/null
+++ b/hw/i386/acpi-build.c
@@ -0,0 +1,723 @@
+/* Support for generating ACPI tables and passing them to Guests
+ *
+ * Copyright (C) 2008-2010  Kevin O'Connor 
+ * Copyright (C) 2006 Fabrice Bellard
+ * Copyright (C) 2013 Red Hat Inc
+ *
+ * Author: Michael S. Tsirkin 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;