On Thu, Dec 07, 2017 at 06:18:07PM +0800, Haozhong Zhang wrote: > Xen is going to reuse QEMU to build ACPI of some devices (e.g., NFIT > and SSDT for NVDIMM) for HVM domains. The existing QEMU ACPI build > code requires a fw_cfg interface which will also be used to pass QEMU > built ACPI to Xen. Therefore, we need to initialize fw_cfg when any > ACPI is going to be built by QEMU. > > Signed-off-by: Haozhong Zhang <haozhong.zh...@intel.com> > --- > Cc: Stefano Stabellini <sstabell...@kernel.org> > Cc: Anthony Perard <anthony.per...@citrix.com> > Cc: "Michael S. Tsirkin" <m...@redhat.com> > Cc: Paolo Bonzini <pbonz...@redhat.com> > Cc: Richard Henderson <r...@twiddle.net> > Cc: Eduardo Habkost <ehabk...@redhat.com> > --- > hw/i386/xen/xen-hvm.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c > index fe01b7a025..4b29f4052b 100644 > --- a/hw/i386/xen/xen-hvm.c > +++ b/hw/i386/xen/xen-hvm.c > @@ -14,6 +14,7 @@ > #include "hw/pci/pci.h" > #include "hw/i386/pc.h" > #include "hw/i386/apic-msidef.h" > +#include "hw/loader.h" > #include "hw/xen/xen_common.h" > #include "hw/xen/xen_backend.h" > #include "qmp-commands.h" > @@ -1234,6 +1235,14 @@ static void xen_wakeup_notifier(Notifier *notifier, > void *data) > xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); > } > > +static void xen_fw_cfg_init(PCMachineState *pcms) > +{
The fw_cfg interface might already be initialized, it is used for "direct kernel boot" on hvm. It is initialized in xen_load_linux(). > + FWCfgState *fw_cfg = fw_cfg_init_io(FW_CFG_IO_BASE); > + > + rom_set_fw(fw_cfg); > + pcms->fw_cfg = fw_cfg; > +} > + > void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) > { > int i, rc; > @@ -1384,6 +1393,9 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion > **ram_memory) > > /* Disable ACPI build because Xen handles it */ > pcms->acpi_build_enabled = false; > + if (pcms->acpi_build_enabled) { > + xen_fw_cfg_init(pcms); > + } > > return; > > -- > 2.15.1 > -- Anthony PERARD