[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [edk2] OVMF broken under Xen (in PCI initialisation)



On Thu, May 05, 2016 at 08:03:05AM +0000, Ni, Ruiyu wrote:
> Gary,
> Can you kindly teach me how to run OVMF under Xen?
> 
> I worked out a draft fix and need to verify whether
> everything is fine.
> 
Hi Ray,

1. Install the Xen host. I use openSUSE Leap 42.1 as the host system
   and it's available in https://software.opensuse.org/421/
   Just download the iso file and burn the DVD or make a live USB as
   mentioned here: https://en.opensuse.org/Live_USB_stick
   BTW, I encountered some problem with my test machine (an old HP notebook)
   when booting the Xen kernel. Swithcing from UEFI to legacy mode works
   for me.

2. After installing the base system, add the Virtualization repo to get
   the latest xen packages.
   $ wget 
http://download.opensuse.org/repositories/Virtualization/openSUSE_Leap_42.1/Virtualization.repo
   $ sudo cp Virtualization.repo /etc/zypp/repos.d/
   $ sudo zypper ref

3. Follow the steps to install Xen server with YaST:
   https://tr.opensuse.org/How_to_Install_a_Xen_VM_Server
   You don't need to create the grub2 entry since yast already takes
   care of it. Use 'rpm -qi xen-tools' to make sure xen-tools >= 4.7.0
   is installed.

4. Reboot the system to the Xen kernel. You will see a Xen entry on the
   grub2 menu. Choose the entry to boot Domain0.

5. Now you have a xen server, the next is the config for HVM guest. Here
   is my config:

builder = 'hvm'
name = 'xen-test'
vcpus = 2
memory = 1024
disk = ['/home/linux/VM/xen-test.qcow2,qcow2,xvda,w', 
'file:/home/linux/iso/opensuse-42.1.iso,hdc:cdrom,r']
on_poweroff="destroy"
on_reboot="destroy"
on_crash="destroy"
sdl=1
bios='ovmf'
bios_override='/home/linux/git/edk2/Build/OvmfX64/DEBUG_GCC48/FV/OVMF.fd'
device_model_args = ["-debugcon", "file:debug.log", "-global", 
"isa-debugcon.iobase=0x402"]

   Just create a config file such as xen-test.cfg and add the options.
   The qcow2 and iso are only necessary if you want to install a guest OS.
   Please modify the path of "bios_override" according to your setup.
   BTW, the parameters in "device_model_args" will direct the OVMF debug
   message to debug.log. It's useful for debugging.

6. Build your own OVMF. In case you need any package to build OVMF, try

   $ sudo zypper in <package name>

   to install the package or search the package with

   $ sudo zypper se <package name>

7. Start the HVM guest as root.

   # xl create xen-test.cfg

8. Destroy the HVM guest. The instance won't be destroyed automatically
   after closing the sdl window. You have to destroy the instance
   manually.

   # xl destroy <name in cfg>
   
   In my case, it's
   
   # xl destroy xen-test

Let me know if you need more information to setup xen server/guest :)

Thanks,

Gary Lin

> Regards,
> Ray
> 
> >-----Original Message-----
> >From: Laszlo Ersek [mailto:lersek@xxxxxxxxxx]
> >Sent: Thursday, April 28, 2016 6:36 PM
> >To: Ni, Ruiyu <ruiyu.ni@xxxxxxxxx>; Gary Lin <glin@xxxxxxxx>
> >Cc: edk2-devel@xxxxxxxxxxxx <edk2-devel@xxxxxxxxxxx>; Xen Devel 
> ><xen-devel@xxxxxxxxxxxxx>; Kinney, Michael D
> ><michael.d.kinney@xxxxxxxxx>
> >Subject: Re: [edk2] OVMF broken under Xen (in PCI initialisation)
> >
> >On 04/28/16 07:08, Ni, Ruiyu wrote:
> >
> >
> >>>>> Do you know whether Xen passes the PCI device resource
> >>>>> information to firmware?
> >>>
> >>> I don't think so, no.
> >>>
> >>> But, given that the previous PciHostBridgeDxe driver was working on Xen,
> >>> can we perhaps emulate that behavior in
> >>> "OvmfPkg/Library/PciHostBridgeLib" somehow?
> >>
> >> Let me explain the reason why previous PciHostBridgeDxe driver was
> >> working on Xen:
> >> The PciRootBridgeIo.Configuration() in new driver only create resource
> >> descriptor when the resource status is allocated:
> >>
> >> if (ResAllocNode->Status != ResAllocated) {
> >>   continue;
> >> }
> >>
> >> The same function in old driver doesn't check the Status field so it
> >> unconditionally returns BUS descriptor with AddrRangeMin and
> >> AddrRangeMax both equal 0. So that PciEnumeratorLight()
> >> in PciBus driver can still search the devices from starting bus 0.
> >> It just happened to work.
> >>
> >> I think the new driver's Configuration() implementation is correct
> >> while the old driver's one is wrong. So I don't want to change to
> >> wrong implementation to fix this issue.
> >
> >Makes sense, thank you for the explanation.
> >
> >> The issue can be resolved if we have a way to tell PciBus
> >> PciEnumeratorLight() which bus number to start searching.
> >>
> >> It's almost true that starting bus number for root bridge #0
> >> is 0. But it might not be true for the rest root bridges.
> >>
> >> OVMF's PciHostBridgeLib currently returns multiple root bridges
> >> and for root bridge #1, the starting bus number is obviously
> >> not 0 unless "etc/extra-pci-roots" doesn't exist or is 0 so there is
> >> only one root bridge.
> >>
> >> My question is in OVMF over Xen, does "etc/extra-pci-roots" exist?
> >> If it exists, device behind root bridge #1, #2... can *not* be found
> >> with the current implementation.
> >
> >"etc/extra-pci-roots" (more precisely, fw_cfg in general) is specific to
> >QEMU. QemuFwCfgLib runs alright in Xen guests, but whenever you look for
> >an fw_cfg file, it is not found -- which is good behavior.
> >
> >So, OVMF's PciHostBridgeLib produces exactly one PCI_ROOT_BRIDGE object
> >when it runs on Xen. ExtraRootBridges is set to zero, the loop runs zero
> >times, and the one InitRootBridge() call after the loop produces one
> >PCI_ROOT_BRIDGE object, with the following parameters:
> >- Bus.Base = 0
> >- Bus.Limit = PCI_MAX_BUS
> >
> >Thanks
> >Laszlo
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.