hvmloader: Build IVRS table
PATCH v6 1/1 hvmloader: Build IVRS table
From 27b1830d7bf046bdb63962537a9898c94fa3af01 Mon Sep 17 00:00:00 2001
From: Wei Wang <[email protected]>
Date: Wed, 26 Sep 2012 11:46:34 +0200
Subject: [PATCH 3/6] hvmloader: Build IVRS table.
There are 32 ivrs padding entries allocated at the beginning. If a passthru device has been found from qemu bus, a padding entry will be replaced by a real device entry. This patch has been tested with both rombios and seabios
Signed-off-by Wei Wang <[email protected]>
--- Config.mk | 2 +- tools/firmware/hvmloader/acpi/acpi2_0.h | 54 ++++++++++++++++++ tools/firmware/hvmloader/acpi/build.c | 91 +++++++++++++++++++++++++++++++ tools/firmware/hvmloader/pci.c | 30 ++++++++++- 4 files changed, 175 insertions(+), 2 deletions(-)
Config.mk +1 -1
@@ -202,7 +202,7 @@ QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-upstream-unstable.git SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git else OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git -QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-upstream-unstable.git +QEMU_UPSTREAM_URL ?= git://git.qemu.org/qemu.git SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git endif OVMF_UPSTREAM_REVISION ?= b0855f925c6e2e0b21fbb03fab4b5fb5b6876871
tools/firmware/hvmloader/acpi/acpi2_0.h +54 -0
60 lines not on this page · raw message
tools/firmware/hvmloader/acpi/build.c +91 -0
115 lines not on this page · raw message
tools/firmware/hvmloader/pci.c +29 -1
@@ -34,11 +34,17 @@ unsigned long pci_mem_end = PCI_MEM_END;enum virtual_vga virtual_vga = VGA_none;unsigned long igd_opregion_pgbase =0 ; +/* support up to 32 passthrough devices */ +#define PT_DEV_MAX_NR 32 +uint32_t ptdev_bdf[PT_DEV_MAX_NR ]; +uint32_t ptdev_nr; +uint32_t iommu_bdf =0 ; +void pci_setup (void ) {uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd, mmio_total =0 ;uint32_t vga_devfn =256 ; -uint16_t class, vendor_id, device_id; +uint16_t class, vendor_id, device_id, sub_vendor_id;unsigned int bar, pin, link, isa_irq;/* Resources assignable to PCI devices via BARs. */
@@ -72,12 +78,34 @@ void pci_setup(void) class =pci_readw (devfn,PCI_CLASS_DEVICE ); vendor_id =pci_readw (devfn,PCI_VENDOR_ID ); device_id =pci_readw (devfn,PCI_DEVICE_ID ); + sub_vendor_id =pci_readw (devfn,PCI_SUBSYSTEM_VENDOR_ID ); +if ( (vendor_id ==0xffff ) && (device_id ==0xffff ) )continue ;ASSERT ((devfn !=PCI_ISA_DEVFN ) || ((vendor_id ==0x8086 ) && (device_id ==0x7000 ))); +/* Found amd iommu device. */ +if ( class ==0x0806 && vendor_id ==0x1022 ) + { + iommu_bdf = devfn; +continue ; + } +/* IVRS: Detecting passthrough devices. +* sub_vendor_id != citrix && sub_vendor_id != qemu */ +if ( sub_vendor_id !=0x5853 && sub_vendor_id !=0x1af4 ) + { +/* found a passthru device */ +if ( ptdev_nr <PT_DEV_MAX_NR ) + { + ptdev_bdf[ptdev_nr] = devfn; + ptdev_nr++; + } +else +printf ("Number of passthru devices > PT_DEV_MAX_NR \n" ); + } +switch ( class ) {case 0x0300 :
Signature · 1 line
1.7.4
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel