Bei Guan
2012-Mar-22 08:29 UTC
[PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
Hi All, Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA bios for OVMF from the source code hvmloader/ovmf.c in the upstream Xen. I have tried the vgabios provided by Xen, but I can see nothing through the vnc client or sdl graphic window. Actually, if we check the boot trace log of OVMF, we find that OVMF has booted into the OS installer grub. When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided by OVMF, I can see the OVMF boot successfully through the vnc client or sdl graphic window. So, this patch makes the hvmloader load the cirrus_vga bios for OVMF on Xen. Any suggestions and comments are appreciated. diff -r 4e1d091d10d8 tools/firmware/Makefile --- a/tools/firmware/Makefile Fri Mar 16 15:24:25 2012 +0000 +++ b/tools/firmware/Makefile Thu Mar 22 15:47:22 2012 +0800 @@ -6,12 +6,17 @@ INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR) SUBDIRS-y :+SUBDIRS-$(CONFIG_OVMF) += ovmf SUBDIRS-$(CONFIG_SEABIOS) += seabios-dir SUBDIRS-$(CONFIG_ROMBIOS) += rombios SUBDIRS-$(CONFIG_ROMBIOS) += vgabios SUBDIRS-$(CONFIG_ROMBIOS) += etherboot SUBDIRS-y += hvmloader +ovmf: + GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf + cp ovmf-makefile ovmf/Makefile; + seabios-dir: GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(SEABIOS_UPSTREAM_URL) $(SEABIOS_UPSTREAM_TAG) seabios-dir cp seabios-config seabios-dir/.config; @@ -44,9 +49,35 @@ subdir-distclean-etherboot: .phony $(MAKE) -C etherboot distclean +subdir-distclean-ovmf: .phony + rm -rf ovmf ovmf-remote + subdir-distclean-seabios-dir: .phony rm -rf seabios-dir seabios-dir-remote +.PHONY: ovmf-find +ovmf-find: + if test -d $(OVMF_UPSTREAM_URL) ; then \ + mkdir -p ovmf; \ + else \ + export GIT=$(GIT); \ + $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf ; \ + fi + +.PHONY: ovmf-force-update +ovmf-force-update: + set -ex; \ + if [ "$(OVMF_UPSTREAM_REVISION)" ]; then \ + cd ovmf-remote; \ + $(GIT) fetch origin; \ + $(GIT) reset --hard $(OVMF_UPSTREAM_REVISION); \ + fi + +subdir-clean-ovmf: + set -e; if test -d ovmf/.; then \ + $(MAKE) -C ovmf clean; \ + fi + .PHONY: seabios-dir-force-update seabios-dir-force-update: set -ex; \ diff -r 4e1d091d10d8 tools/firmware/hvmloader/Makefile --- a/tools/firmware/hvmloader/Makefile Fri Mar 16 15:24:25 2012 +0000 +++ b/tools/firmware/hvmloader/Makefile Thu Mar 22 15:47:22 2012 +0800 @@ -57,7 +57,8 @@ OBJS += ovmf.o CFLAGS += -DENABLE_OVMF OVMF_ROM := $(OVMF_DIR)/ovmf.bin -ROMS += $(OVMF_ROM) +OVMF_CIRRUS_VGA_ROM := $(OVMF_DIR)/ovmf-cirrus-vga.bin +ROMS += $(OVMF_ROM) $(OVMF_CIRRUS_VGA_ROM) endif ifeq ($(CONFIG_ROMBIOS),y) @@ -122,6 +123,11 @@ sh ./mkhex etherboot $(ETHERBOOT_ROMS) >> $@.new echo "#endif" >> $@.new endif +ifneq ($(OVMF_CIRRUS_VGA_ROM),) + echo "#ifdef ROM_INCLUDE_OVMF_CIRRUS_VGA" >> $@.new + sh ./mkhex ovmf_cirrus_vga $(OVMF_CIRRUS_VGA_ROM) >> $@.new + echo "#endif" >> $@.new +endif mv $@.new $@ diff -r 4e1d091d10d8 tools/firmware/hvmloader/ovmf.c --- a/tools/firmware/hvmloader/ovmf.c Fri Mar 16 15:24:25 2012 +0000 +++ b/tools/firmware/hvmloader/ovmf.c Thu Mar 22 15:47:22 2012 +0800 @@ -36,6 +36,7 @@ #include <xen/memory.h> #define ROM_INCLUDE_OVMF +#define ROM_INCLUDE_OVMF_CIRRUS_VGA #include "roms.inc" #define OVMF_BEGIN 0xFFF00000ULL @@ -55,6 +56,12 @@ xen_pfn_t mfn; uint64_t addr = OVMF_BEGIN; + /* Copy video ROM. */ + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, + ovmf_cirrus_vga, sizeof(ovmf_cirrus_vga)); + printf("OVMF Cirrus [0x%x-0x%x]\n", VGABIOS_PHYSICAL_ADDRESS, + VGABIOS_PHYSICAL_ADDRESS + sizeof(ovmf_cirrus_vga)); + /* Copy low-reset vector portion. */ memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image + OVMF_SIZE Best Regards, Bei Guan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2012-Mar-22 08:57 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
On Thu, 2012-03-22 at 08:29 +0000, Bei Guan wrote:> Hi All, > > > Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA > bios for OVMF from the source code hvmloader/ovmf.c in the upstream > Xen. > I have tried the vgabios provided by Xen, but I can see nothing > through the vnc client or sdl graphic window. Actually, if we check > the boot trace log of OVMF, we find that OVMF has booted into the OS > installer grub. > When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided > by OVMF, I can see the OVMF boot successfully through the vnc client > or sdl graphic window. > > > So, this patch makes the hvmloader load the cirrus_vga bios for OVMF > on Xen. Any suggestions and comments are appreciated.I''d prefer to not expose this behaviour any further than the existing ROMBIOS use case. Can Tianocore not deploy option ROMs directly from the hardware (e.g. by using the ROM BAR on the PCI device). This would be a much preferable approach, it is supported by the QEMU emulations and ensures you get a ROM image which matches the hardware (emulated or passthrough). Ian.> > > > > diff -r 4e1d091d10d8 tools/firmware/Makefile > --- a/tools/firmware/Makefile Fri Mar 16 15:24:25 2012 +0000 > +++ b/tools/firmware/Makefile Thu Mar 22 15:47:22 2012 +0800 > @@ -6,12 +6,17 @@ > INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR) > > SUBDIRS-y :> +SUBDIRS-$(CONFIG_OVMF) += ovmf > SUBDIRS-$(CONFIG_SEABIOS) += seabios-dir > SUBDIRS-$(CONFIG_ROMBIOS) += rombios > SUBDIRS-$(CONFIG_ROMBIOS) += vgabios > SUBDIRS-$(CONFIG_ROMBIOS) += etherboot > SUBDIRS-y += hvmloader > > +ovmf: > + GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) > $(OVMF_UPSTREAM_REVISION) ovmf > + cp ovmf-makefile ovmf/Makefile; > + > seabios-dir: > GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh > $(SEABIOS_UPSTREAM_URL) $(SEABIOS_UPSTREAM_TAG) seabios-dir > cp seabios-config seabios-dir/.config; > @@ -44,9 +49,35 @@ > subdir-distclean-etherboot: .phony > $(MAKE) -C etherboot distclean > > +subdir-distclean-ovmf: .phony > + rm -rf ovmf ovmf-remote > + > subdir-distclean-seabios-dir: .phony > rm -rf seabios-dir seabios-dir-remote > > +.PHONY: ovmf-find > +ovmf-find: > + if test -d $(OVMF_UPSTREAM_URL) ; then \ > + mkdir -p ovmf; \ > + else \ > + export GIT=$(GIT); \ > + $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) > $(OVMF_UPSTREAM_REVISION) ovmf ; \ > + fi > + > +.PHONY: ovmf-force-update > +ovmf-force-update: > + set -ex; \ > + if [ "$(OVMF_UPSTREAM_REVISION)" ]; then \ > + cd ovmf-remote; \ > + $(GIT) fetch origin; \ > + $(GIT) reset --hard $(OVMF_UPSTREAM_REVISION); \ > + fi > + > +subdir-clean-ovmf: > + set -e; if test -d ovmf/.; then \ > + $(MAKE) -C ovmf clean; \ > + fi > + > .PHONY: seabios-dir-force-update > seabios-dir-force-update: > set -ex; \ > diff -r 4e1d091d10d8 tools/firmware/hvmloader/Makefile > --- a/tools/firmware/hvmloader/Makefile Fri Mar 16 15:24:25 2012 +0000 > +++ b/tools/firmware/hvmloader/Makefile Thu Mar 22 15:47:22 2012 +0800 > @@ -57,7 +57,8 @@ > OBJS += ovmf.o > CFLAGS += -DENABLE_OVMF > OVMF_ROM := $(OVMF_DIR)/ovmf.bin > -ROMS += $(OVMF_ROM) > +OVMF_CIRRUS_VGA_ROM := $(OVMF_DIR)/ovmf-cirrus-vga.bin > +ROMS += $(OVMF_ROM) $(OVMF_CIRRUS_VGA_ROM) > endif > > ifeq ($(CONFIG_ROMBIOS),y) > @@ -122,6 +123,11 @@ > sh ./mkhex etherboot $(ETHERBOOT_ROMS) >> $@.new > echo "#endif" >> $@.new > endif > +ifneq ($(OVMF_CIRRUS_VGA_ROM),) > + echo "#ifdef ROM_INCLUDE_OVMF_CIRRUS_VGA" >> $@.new > + sh ./mkhex ovmf_cirrus_vga $(OVMF_CIRRUS_VGA_ROM) >> $@.new > + echo "#endif" >> $@.new > +endif > > mv $@.new $@ > > diff -r 4e1d091d10d8 tools/firmware/hvmloader/ovmf.c > --- a/tools/firmware/hvmloader/ovmf.c Fri Mar 16 15:24:25 2012 +0000 > +++ b/tools/firmware/hvmloader/ovmf.c Thu Mar 22 15:47:22 2012 +0800 > @@ -36,6 +36,7 @@ > #include <xen/memory.h> > > #define ROM_INCLUDE_OVMF > +#define ROM_INCLUDE_OVMF_CIRRUS_VGA > #include "roms.inc" > > #define OVMF_BEGIN 0xFFF00000ULL > @@ -55,6 +56,12 @@ > xen_pfn_t mfn; > uint64_t addr = OVMF_BEGIN; > > + /* Copy video ROM. */ > + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, > + ovmf_cirrus_vga, sizeof(ovmf_cirrus_vga)); > + printf("OVMF Cirrus [0x%x-0x%x]\n", VGABIOS_PHYSICAL_ADDRESS, > + VGABIOS_PHYSICAL_ADDRESS + sizeof(ovmf_cirrus_vga)); > + > /* Copy low-reset vector portion. */ > memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image > + OVMF_SIZE > > > > > Best Regards, > Bei Guan >
Jan Beulich
2012-Mar-22 09:24 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
>>> On 22.03.12 at 09:57, Ian Campbell <Ian.Campbell@citrix.com> wrote: > On Thu, 2012-03-22 at 08:29 +0000, Bei Guan wrote: >> Hi All, >> >> >> Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA >> bios for OVMF from the source code hvmloader/ovmf.c in the upstream >> Xen. >> I have tried the vgabios provided by Xen, but I can see nothing >> through the vnc client or sdl graphic window. Actually, if we check >> the boot trace log of OVMF, we find that OVMF has booted into the OS >> installer grub. >> When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided >> by OVMF, I can see the OVMF boot successfully through the vnc client >> or sdl graphic window. >> >> >> So, this patch makes the hvmloader load the cirrus_vga bios for OVMF >> on Xen. Any suggestions and comments are appreciated. > > I''d prefer to not expose this behaviour any further than the existing > ROMBIOS use case. > > Can Tianocore not deploy option ROMs directly from the hardware (e.g. by > using the ROM BAR on the PCI device). This would be a much preferable > approach, it is supported by the QEMU emulations and ensures you get a > ROM image which matches the hardware (emulated or passthrough).UEFI should prefer not to make use of (legacy) option ROMs at all. Instead, a proper EFI driver should be loaded (and hence provided in the firmware image). Jan
Attilio Rao
2012-Mar-22 11:37 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
On 22/03/12 08:29, Bei Guan wrote:> Hi All, > > Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA > bios for OVMF from the source code hvmloader/ovmf.c in the upstream Xen. > I have tried the vgabios provided by Xen, but I can see nothing > through the vnc client or sdl graphic window. Actually, if we check > the boot trace log of OVMF, we find that OVMF has booted into the OS > installer grub. > When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided > by OVMF, I can see the OVMF boot successfully through the vnc client > or sdl graphic window. >I had specifically skipped this for several reasons: 1) This is not the right way to fix this (not including the VGA blob) 2) When I tried, it was working for me so I just assumed tiancore was fixed by using the BAR directly Maybe Andrei or Jordan can shade a light on tianocore behaviour here. In the while, can you please explain how to exactly reproduce your issue, posting all the configurations and environment you used? Attilio
Bei Guan
2012-Mar-22 13:33 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
2012/3/22 Attilio Rao <attilio.rao@citrix.com>> On 22/03/12 08:29, Bei Guan wrote: > >> Hi All, >> >> Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA bios >> for OVMF from the source code hvmloader/ovmf.c in the upstream Xen. >> I have tried the vgabios provided by Xen, but I can see nothing through >> the vnc client or sdl graphic window. Actually, if we check the boot trace >> log of OVMF, we find that OVMF has booted into the OS installer grub. >> When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided by >> OVMF, I can see the OVMF boot successfully through the vnc client or sdl >> graphic window. >> >> > I had specifically skipped this for several reasons: > 1) This is not the right way to fix this (not including the VGA blob) > 2) When I tried, it was working for me so I just assumed tiancore was > fixed by using the BAR directly > > Maybe Andrei or Jordan can shade a light on tianocore behaviour here. > In the while, can you please explain how to exactly reproduce your issue, > posting all the configurations and environment you used?Do you use the upstream qemu? Could you tell me where to get it and how to setup it? Thanks.> > > Attilio >-- Best Regards, Bei Guan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Bei Guan
2012-Mar-22 14:43 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
2012/3/22 Attilio Rao <attilio.rao@citrix.com>> On 22/03/12 08:29, Bei Guan wrote: > >> Hi All, >> >> Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA bios >> for OVMF from the source code hvmloader/ovmf.c in the upstream Xen. >> I have tried the vgabios provided by Xen, but I can see nothing through >> the vnc client or sdl graphic window. Actually, if we check the boot trace >> log of OVMF, we find that OVMF has booted into the OS installer grub. >> When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided by >> OVMF, I can see the OVMF boot successfully through the vnc client or sdl >> graphic window. >> >> > I had specifically skipped this for several reasons: > 1) This is not the right way to fix this (not including the VGA blob) > 2) When I tried, it was working for me so I just assumed tiancore was > fixed by using the BAR directly > > Maybe Andrei or Jordan can shade a light on tianocore behaviour here. > In the while, can you please explain how to exactly reproduce your issue, > posting all the configurations and environment you used?I have tried the upstream qemu and I also see nothing through the vnc or sdl graphic window. The following is how to reproduce my problem. 1. Get the upstream xen source code, apply your latest v4 patch, and run make install-xen and make install-tools. 2. Get the upstream qemu source and install it. 3. Run #xl create hvm.cfg The content of the config file hvm.cfg is list here. #================bios="ovmf" builder=''hvm'' memory = 512 name = "Ubuntu_10_10_HVMDomain" vcpus=1 pae=1 acpi=1 apic=1 vif = [ ''type=ioemu, bridge=virbr0'' ] disk = [ ''file:/root/gb/xen_img/hvm_ubuntu1010/hvm_ubuntu1010.img,ioemu:hda,w'', ''file:/root/gb/ubuntu-10.10-desktop-amd64.iso,hdc:cdrom,r'' ] on_poweroff = ''destroy'' on_reboot = ''restart'' on_crash = ''destroy'' device_model_version = ''qemu-xen'' boot="cd" sdl=1 opengl=1 vnc=0 vnclisten="0.0.0.0" vncdisplay=1 vncunused=0 vncpasswd='''' stdvga=0 serial=''pty'' monitor=1 usbdevice=''tablet'' #================ The kernel of Dom0 is root@gavin-laptop:~# uname -a Linux gavin-laptop 2.6.32-5-xen-amd64 #1 SMP Tue Jun 14 12:46:30 UTC 2011 x86_64 GNU/Linux Is there any potential issues in the procedure? However, if the ovmf-cirrus-vga loaded, the OVMF can run into the shell interface.(Just like the pictures attached) Thanks, Bei Guan> > > Attilio >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Jordan Justen
2012-Mar-22 19:27 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
On Thu, Mar 22, 2012 at 01:57, Ian Campbell <Ian.Campbell@citrix.com> wrote:> On Thu, 2012-03-22 at 08:29 +0000, Bei Guan wrote: >> Hi All, >> >> >> Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA >> bios for OVMF from the source code hvmloader/ovmf.c in the upstream >> Xen. >> I have tried the vgabios provided by Xen, but I can see nothing >> through the vnc client or sdl graphic window. Actually, if we check >> the boot trace log of OVMF, we find that OVMF has booted into the OS >> installer grub. >> When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided >> by OVMF, I can see the OVMF boot successfully through the vnc client >> or sdl graphic window. >> >> >> So, this patch makes the hvmloader load the cirrus_vga bios for OVMF >> on Xen. Any suggestions and comments are appreciated. > > I''d prefer to not expose this behaviour any further than the existing > ROMBIOS use case. > > Can Tianocore not deploy option ROMs directly from the hardware (e.g. by > using the ROM BAR on the PCI device).Yes, we can load the ROM from the PCI ROM bar. Older versions of QEMU did not support the ROM BAR, and would find the vgabios in the C000 segment, so OVMF also looks there. Yet another option is to build the cirrus logic video driver directly into the main OVMF image. I think we are going to make this change, because dealing with the separate VGABIOS ROM occasionally fails. -Jordan
Jordan Justen
2012-Mar-22 19:37 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
On Thu, Mar 22, 2012 at 07:43, Bei Guan <gbtju85@gmail.com> wrote:> > > 2012/3/22 Attilio Rao <attilio.rao@citrix.com> >> >> On 22/03/12 08:29, Bei Guan wrote: >>> >>> Hi All, >>> >>> Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA bios >>> for OVMF from the source code hvmloader/ovmf.c in the upstream Xen. >>> I have tried the vgabios provided by Xen, but I can see nothing through >>> the vnc client or sdl graphic window. Actually, if we check the boot trace >>> log of OVMF, we find that OVMF has booted into the OS installer grub. >>> When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided by >>> OVMF, I can see the OVMF boot successfully through the vnc client or sdl >>> graphic window.Can you test modifying OvmfPkg/OvmfPkgX64.dsc: Remove this from the end: [OptionRom.OvmfVideo] INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { PCI_DEVICE_ID = 0x00B8 } Add this near the ''Usb Support'' section of drivers: INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf This will embed the video driver into the OVMF FD image. Thanks, -Jordan
Bei Guan
2012-Mar-23 04:03 UTC
Re: [PATCH]Load the cirrus vga rom for the OVMF UEFI support in hvmloader
2012/3/23 Jordan Justen <jljusten@gmail.com>> On Thu, Mar 22, 2012 at 07:43, Bei Guan <gbtju85@gmail.com> wrote: > > > > > > 2012/3/22 Attilio Rao <attilio.rao@citrix.com> > >> > >> On 22/03/12 08:29, Bei Guan wrote: > >>> > >>> Hi All, > >>> > >>> Now, OVMF UEFI can boot on the Xen hvmloader. But, there is no VGA bios > >>> for OVMF from the source code hvmloader/ovmf.c in the upstream Xen. > >>> I have tried the vgabios provided by Xen, but I can see nothing through > >>> the vnc client or sdl graphic window. Actually, if we check the boot > trace > >>> log of OVMF, we find that OVMF has booted into the OS installer grub. > >>> When I try the cirrus_vga bios (named OvmfVideo.rom in edk2) provided > by > >>> OVMF, I can see the OVMF boot successfully through the vnc client or > sdl > >>> graphic window. > > Can you test modifying OvmfPkg/OvmfPkgX64.dsc: > > Remove this from the end: > [OptionRom.OvmfVideo] > INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { > PCI_DEVICE_ID = 0x00B8 > } > > Add this near the ''Usb Support'' section of drivers: > INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf > > This will embed the video driver into the OVMF FD image. >I have tried this as you said. It''s ok now. Thanks, Bei Guan> > Thanks, > > -Jordan >-- Best Regards, Bei Guan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel