Snippets

Jürgen Walter IOMMU via coreboot for APU2 (pcengines)

Created by Jürgen Walter last modified
2016-03-22-16:02, Jürgen Walter, juwalter@mailbox.org

Help needed getting XEN with IOMMU to work with coreboot on APU2/pcengines.ch
==============================================================================

Background
----------

We recently acquired 2x APU2 from PCEngines [1], a SoC based on AMD GX-412TC. The folks 
at pcengines packaged everything up nicely and use a very open design, including corebooot [2]
Its source is available at [3]

[1] http://www.pcengines.ch/apu2c4.htm
[2] https://blogs.coreboot.org/about/
[3] http://pcengines.ch/howto.htm#coreboot
[4] https://www.datatroniq.com

Issue
-----

We [4] want to build a commercial data logger for "industrial IoT". For better security and isolation 
of components, we would also like to run XEN [5] - a hypervisor - on it. Our first attempts looked very promising, 
as the APU supports HVM (hardware virtualization), however, we are currently stuck, 
because "IOMMU" support seems to be lacking, even though the hardware/CPU seems to support it [6]

Some initial investigations (see below) also seem to indicate support for IOMMU in the (custom) coreboot code.
We also have access to some AMD documentation 
"52740 Rev 3.04 - March 16, 2015 BKDG for AMD Family 16h Models 30h-3Fh (Mullins) Processors"
which I can share with you. It talks in length about 
 - IOMMU Configuration Space
 - IOMMU Initialization, IOMMU L1 Initialization and IOMMU L2 Initialization

[4] https://www.datatroniq.com
[5] https://wiki.debian.org/Xen#Xen_Overview
[6] https://en.wikipedia.org/wiki/AMD_Accelerated_Processing_Unit

you
----

we would like to hire [7] someone to help us 
a) getting IOMMU to work on the APU2 
b) and open source the patch

[7] you tell us what works best for you: invoice, https://www.bountysource.com/, etc.
root@apu001:~# nvramtool -a -y ./cmos.layout

boot_option = Fallback
last_boot = Fallback
ECC_memory = Disable
baud_rate = 57600
hw_scrubber = Disable
interleave_chip_selects = Disable
max_mem_clock = 400Mhz
multi_core = Enable
power_on_after_fail = Disable
# Bad value -> debug_level = 0x0
boot_first = Network
boot_second = Network
boot_third = Network
boot_index = 0x0
boot_countdown = 0x4
slow_cpu = off
nmi = Enable
iommu = Enable
~/apu2b-20160304$ grep -nrw IOMMU .

./src/northbridge/amd/pi/agesawrapper.h:35:    PICK_IVRS,      /* IOMMU ACPI IVRS(I/O Virtualization Reporting Structure) table */
./src/northbridge/amd/amdk8/Kconfig:116:config IOMMU
./src/mainboard/pcengines/apu2/agesawrapper.h:41:    PICK_IVRS,      /* IOMMU ACPI IVRS(I/O Virtualization Reporting Structure) table */
./src/mainboard/pcengines/apu2/devicetree.cb:32:                device pci 0.2 off end # IOMMU
./3rdparty/pi/amd/00730F01/AGESA.h:797:///IOMMU requestor ID
./3rdparty/pi/amd/00730F01/AGESA.h:895:  IN  BOOLEAN    IommuSupport;            ///< IOMMU support.
./3rdparty/pi/amd/00730F01/AGESA.h:896:                                          ///< @li FALSE = Disabled. Disable and hide IOMMU device.
./3rdparty/pi/amd/00730F01/AGESA.h:897:                                          ///< @li TRUE  = Initialize IOMMU subsystem. Generate ACPI IVRS table.
./3rdparty/pi/amd/00730F01/AGESA.h:2336:  AMD_ACPI_IVRS_BUFFER_HANDLE,                  ///< Assign 0x000D00A buffer handle to IOMMU IVRS table
./3rdparty/pi/amd/00730F01/AGESA.h:2484:  Iommu,                                         ///< An IOMMU is in use in the system.
./3rdparty/pi/amd/00730F01/AGESA.h:2763:  IN BOOLEAN    CfgIommuSupport;                  ///< IOMMU support
./3rdparty/pi/amd/00730F01/AGESA.h:3367:     OUT   VOID                   *AcpiIvrs;              ///< IOMMU ACPI IVRS(I/O Virtualization Reporting Structure) table
./3rdparty/pi/amd/00730F01/Include/Ids.h:1110:  TpGnbIommuIvrsTable,                                ///< AC .. GNB Late pcie IOMMU
./3rdparty/pi/amd/00730F01/Proc/CPU/heapManager.h:184:  AMD_GNB_IOMMU_SCRATCH_MEM_HANDLE,               ///< Assign 0x000A023 buffer handle to be used for GNB IOMMU scratch memory
./3rdparty/pi/amd/00730F01/Proc/CPU/cpuLateInit.h:844:  UINT32 IommuPresent:1;             ///< IOMMU Present
michael@michael-desktop64:~/apu2b-20160304$ 
(XEN) Xen version 4.6.0 (Debian 4.6.0-1+nmu2) (ijc@debian.org) (gcc (Debian 5.3.1-8) 5.3.1 20160205) debug=n Tue Feb  9 17:46:27 UTC 2016
(XEN) Bootloader: GRUB 2.02-pve4
(XEN) Command line: iommu=1 dom0_mem=512M,max:1024Mlog lvl=all guest_loglvl=all placeholder
(XEN) Video information:
(XEN)  No VGA detected
(XEN) Disc information:
(XEN)  Found 2 MBR signatures
(XEN)  Found 2 EDD information structures
(XEN) Xen-e820 RAM map:
(XEN)  0000000000000000 - 000000000009f800 (usable)
(XEN)  000000000009f800 - 00000000000a0000 (reserved)
(XEN)  00000000000f0000 - 0000000000100000 (reserved)
(XEN)  0000000000100000 - 00000000dffae000 (usable)
(XEN)  00000000dffae000 - 00000000e0000000 (reserved)
(XEN)  00000000f8000000 - 00000000fc000000 (reserved)
(XEN)  0000000100000000 - 000000011f000000 (usable)
(XEN) ACPI: RSDP 000F30D0, 0024 (r2 CORE  )
(XEN) ACPI: XSDT DFFB80E0, 005C (r1 CORE   COREBOOT        0 CORE        0)
(XEN) ACPI: FACP DFFB96F0, 00F4 (r4 CORE   COREBOOT        0 CORE        0)
(XEN) ACPI: DSDT DFFB8250, 1496 (r2 AMD    COREBOOT    10001 INTL 20140114)
(XEN) ACPI: FACS DFFB8210, 0040
(XEN) ACPI: SSDT DFFB97F0, 0045 (r2 CORE   COREBOOT       2A CORE       2A)
(XEN) ACPI: APIC DFFB9840, 007E (r1 CORE   COREBOOT        0 CORE        0)
(XEN) ACPI: HEST DFFB98C0, 01D0 (r1 CORE   COREBOOT        0 CORE        0)
(XEN) ACPI: SSDT DFFB9A90, 48A6 (r2 AMD    AGESA           2 MSFT  4000000)
(XEN) ACPI: SSDT DFFBE340, 07C8 (r1 AMD    AGESA           1 AMD         1)
(XEN) ACPI: HPET DFFBEB10, 0038 (r1 CORE   COREBOOT        0 CORE        0)
(XEN) System RAM: 4079MB (4177204kB)
(XEN) Domain heap initialised
ing 32
(XEN) Processor #0 7:0 APIC version 16
(XEN) Processor #1 7:0 APIC version 16
(XEN) Processor #2 7:0 APIC version 16
(XEN) Processor #3 7:0 APIC version 16
(XEN) IOAPIC[0]: apic_id 4, version 33, address 0xfec00000, GSI 0-23
(XEN) IOAPIC[1]: apic_id 5, version 33, address 0xfec20000, GSI 24-55
(XEN) Enabling APIC mode:  Flat.  Using 2 I/O APICs
(XEN) xstate_init: using cntxt_size: 0x340 and states: 0x7
(XEN) Using scheduler: SMP Credit Scheduler (credit)
(XEN) Detected 998.158 MHz processor.
(XEN) Initing memory sharing.
(XEN) AMD-Vi: IOMMU not found!
(XEN) I/O virtualisation disabled

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.