From: "Chun Yan Liu" Subject: Re: [Xen-devel] [RFC PATCH V3 2/2] qemu: support xen hvm direct kernel boot Date: Sun, 22 Jun 2014 21:36:45 -0600 Message-ID: <53A8114D020000660003CD7D@soto.provo.novell.com> References: <1403244196-19630-1-git-send-email-cyliu@suse.com> <1403244196-19630-3-git-send-email-cyliu@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org To: stefano.stabellini@eu.citrix.com Cc: xen-devel@lists.xensource.com, Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com, qemu-devel@nongnu.org List-Id: xen-devel@lists.xenproject.org >>> On 6/20/2014 at 08:08 PM, in message , Stefano Stabellini wrote:=20 > On Fri, 20 Jun 2014, Chunyan Liu wrote:=20 > > qemu side patch to support xen HVM direct kernel boot:=20 > > if -kernel exists, calls xen_load_linux(), which will read kernel/initr= d=20 > > and add a linuxboot.bin or multiboot.bin option rom. The=20 > > linuxboot.bin/multiboot.bin will load kernel/initrd and jump to = execute=20 > > kernel directly. It's working when xen uses seabios.=20 > > =20 > > Signed-off-by: Chunyan Liu =20 > > ---=20 > > hw/i386/pc.c | 22 ++++++++++++++++++++++=20 > > hw/i386/pc_piix.c | 7 +++++++=20 > > hw/i386/xen/xen_apic.c | 1 +=20 > > include/hw/i386/pc.h | 5 +++++=20 > > 4 files changed, 35 insertions(+)=20 > > =20 > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c=20 > > index 3e0ecf1..e005136 100644=20 > > --- a/hw/i386/pc.c=20 > > +++ b/hw/i386/pc.c=20 > > @@ -1183,6 +1183,28 @@ void pc_acpi_init(const char *default_dsdt)=20 > > }=20 > > }=20 > > =20 > > +FWCfgState *xen_load_linux(const char *kernel_filename,=20 > > + const char *kernel_cmdline,=20 > > + const char *initrd_filename,=20 > > + ram_addr_t below_4g_mem_size,=20 > > + PcGuestInfo *guest_info)=20 > > +{=20 > > + int i;=20 > > + FWCfgState *fw_cfg;=20 > > +=20 > > + assert(kernel_filename !=3D NULL);=20 > > +=20 > > + fw_cfg =3D fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, = 0);=20 > =20 > Is it actually OK to initialize just BIOS_CFG_IOPORT and avoid=20 > everything else currently done in bochs_bios_init?=20 > Would it make sense to simply call bochs_bios_init?=20 > =20 > =20 > > + rom_set_fw(fw_cfg);=20 > > +=20 > > + load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdlin= e, =20 > below_4g_mem_size);=20 > > + for (i =3D 0; i < nb_option_roms; i++) {=20 > > + rom_add_option(option_rom[i].name, option_rom[i].bootindex);= =20 > > + }=20 > =20 > Wouldn't this have the unintended consequence of possibly loading = other=20 > option_roms into the guest memory?=20 For xen, no. Before this patch, indeed there is another option_rom "kvmvapic" in the = list, but since the option_rom list is never loaded in xen case, that won't = harm. But as expected, I think in xen case, it should not be in option_rom list at = all, since we won't expect to load it. In v1, I tried to check the option_rom name to bypass it and load multiboot.bin/linuxboot.bin only. In comments, Paolo Bonzini suggests a better way, that is to add following = line in xen_apic_realize(): + s->vapic_control =3D 0; In this way, "kvmvapic" won't be added to the option_rom list. I think = that should be the normal way for xen. So, since V2, I updated in this way. http://lists.gnu.org/archive/html/qemu-devel/2014-06/msg00704.html > =20 > =20 > > + guest_info->fw_cfg =3D fw_cfg;=20 > > + return fw_cfg;=20 > > +}=20 > > +=20 > > FWCfgState *pc_memory_init(MemoryRegion *system_memory,=20 > > const char *kernel_filename,=20 > > const char *kernel_cmdline,=20 > > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c=20 > > index a48e263..b737868 100644=20 > > --- a/hw/i386/pc_piix.c=20 > > +++ b/hw/i386/pc_piix.c=20 > > @@ -158,6 +158,13 @@ static void pc_init1(MachineState *machine,=20 > > machine->initrd_filename,=20 > > below_4g_mem_size, above_4g_mem_size,=20 > > rom_memory, &ram_memory, guest_info);=20 > > + } else if (machine->kernel_filename !=3D NULL) {=20 > > + /* For xen HVM direct kernel boot, load linux here */=20 > > + fw_cfg =3D xen_load_linux(machine->kernel_filename,=20 > > + machine->kernel_cmdline,=20 > > + machine->initrd_filename,=20 > > + below_4g_mem_size,=20 > > + guest_info);=20 > > }=20 > > =20 > > gsi_state =3D g_malloc0(sizeof(*gsi_state));=20 > > diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c=20 > > index 63bb7f7..f5acd6a 100644=20 > > --- a/hw/i386/xen/xen_apic.c=20 > > +++ b/hw/i386/xen/xen_apic.c=20 > > @@ -40,6 +40,7 @@ static void xen_apic_realize(DeviceState *dev, Error = =20 > **errp)=20 > > {=20 > > APICCommonState *s =3D APIC_COMMON(dev);=20 > > =20 > > + s->vapic_control =3D 0;=20 > > memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, = s,=20 > > "xen-apic-msi", APIC_SPACE_SIZE);=20 > =20 > Why this change? It is not mentioned in the commit message.=20 > =20 > =20 > > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h=20 > > index ca7a0bd..171a597 100644=20 > > --- a/include/hw/i386/pc.h=20 > > +++ b/include/hw/i386/pc.h=20 > > @@ -134,6 +134,11 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t =20 > below_4g_mem_size,=20 > > void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory= ,=20 > > MemoryRegion *pci_address_space);=20 > > =20 > > +FWCfgState *xen_load_linux(const char *kernel_filename,=20 > > + const char *kernel_cmdline,=20 > > + const char *initrd_filename,=20 > > + ram_addr_t below_4g_mem_size,=20 > > + PcGuestInfo *guest_info);=20 > > FWCfgState *pc_memory_init(MemoryRegion *system_memory,=20 > > const char *kernel_filename,=20 > > const char *kernel_cmdline,=20 > > -- =20 > > 1.8.4.5=20 > > =20 > =20 > _______________________________________________=20 > Xen-devel mailing list=20 > Xen-devel@lists.xen.org=20 > http://lists.xen.org/xen-devel=20 > =20 > =20