hvmloader: Build IVRS table
PATCH v4 1/1 hvmloader: Build IVRS table
In reply to a message not in the archive# HG changeset patch
# User Wei Wang <[email protected]>
# Date 1327066826 -3600
# Node ID 17fdd00a4f66479bf232ac698b962118ce3f2950 # Parent c5cd29b41f2526bb4f93c76ceade924feac1f1c3
hvmloader: Build IVRS table.
Signed-off-by Wei Wang <[email protected]>
tools/firmware/hvmloader/acpi/acpi2_0.h +54 -0
@@ -389,6 +389,60 @@ struct acpi_20_madt_intsrcovr {#define ACPI_2_0_WAET_REVISION 0x01#define ACPI_1_0_FADT_REVISION 0x01 +#define IVRS_SIGNATURE ASCII32('I','V','R','S') +#define IVRS_REVISION 1 +#define IVRS_VASIZE 64 +#define IVRS_PASIZE 52 +#define IVRS_GVASIZE 64 + +#define IVHD_BLOCK_TYPE 0x10 +#define IVHD_FLAG_HTTUNEN (1 << 0) +#define IVHD_FLAG_PASSPW (1 << 1) +#define IVHD_FLAG_RESPASSPW (1 << 2) +#define IVHD_FLAG_ISOC (1 << 3) +#define IVHD_FLAG_IOTLBSUP (1 << 4) +#define IVHD_FLAG_COHERENT (1 << 5) +#define IVHD_FLAG_PREFSUP (1 << 6) +#define IVHD_FLAG_PPRSUP (1 << 7) + +#define IVHD_EFR_GTSUP (1 << 2) +#define IVHD_EFR_IASUP (1 << 5) + +#define IVHD_SELECT_4_BYTE 0x2 + +struct ivrs_ivhd_block +{ +uint8_t type; +uint8_t flags; +uint16_t length; +uint16_t devid; +uint16_t cap_offset; +uint64_t iommu_base_addr; +uint16_t pci_segment; +uint16_t iommu_info; +uint32_t reserved; +}; + +/* IVHD 4-byte device entries */ +struct ivrs_ivhd_device +{ +uint8_t type; +uint16_t dev_id; +uint8_t flags; +}; + +#define PT_DEV_MAX_NR 32 +#define IOMMU_CAP_OFFSET 0x40 +struct acpi_40_ivrs +{ +struct acpi_header header; +uint32_t iv_info; +uint32_t reserved[2 ]; +struct ivrs_ivhd_block ivhd_block; +struct ivrs_ivhd_device ivhd_device[PT_DEV_MAX_NR ]; +}; + +#pragma pack ()struct acpi_config {
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; +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 amd iommu 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 :
_______________________________________________
osrc-patches mailing list
[email protected]
https://elbe.amd.com/mailman/listinfo/osrc-patches