Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .github/workflows/sdk.yaml
Empty file.
60 changes: 30 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ members = [
]

[workspace.dependencies.sel4-capdl-initializer]
git = "https://github.com/seL4/rust-sel4"
rev = "2541371f62dd097f7d47127125c44a0922145fa5"
git = "https://github.com/au-ts/rust-sel4"
rev = "121798b0260d0ff5ca1185702a0d3285d01ef439"

[workspace.dependencies.sel4-capdl-initializer-types]
git = "https://github.com/seL4/rust-sel4"
rev = "2541371f62dd097f7d47127125c44a0922145fa5"
git = "https://github.com/au-ts/rust-sel4"
rev = "121798b0260d0ff5ca1185702a0d3285d01ef439"

[profile.release.package.microkit-tool]
strip = true
3 changes: 1 addition & 2 deletions build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
DEFAULT_KERNEL_OPTIONS_X86_64 = {
"KernelPlatform": "pc99",
"KernelX86MicroArch": "generic",
# See https://github.com/seL4/microkit/issues/418 for details.
"KernelIOMMU": False,
"KernelIOMMU": True,
} | DEFAULT_KERNEL_OPTIONS


Expand Down
72 changes: 72 additions & 0 deletions example/x86_64_iommu_dma_test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# Copyright 2026, UNSW
#
# SPDX-License-Identifier: BSD-2-Clause
#
ifeq ($(strip $(BUILD_DIR)),)
$(error BUILD_DIR must be specified)
endif

ifeq ($(strip $(MICROKIT_SDK)),)
$(error MICROKIT_SDK must be specified)
endif

ifeq ($(strip $(MICROKIT_BOARD)),)
$(error MICROKIT_BOARD must be specified)
endif

ifeq ($(strip $(MICROKIT_CONFIG)),)
$(error MICROKIT_CONFIG must be specified)
endif

BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG)

ARCH := ${shell grep 'CONFIG_SEL4_ARCH ' $(BOARD_DIR)/include/kernel/gen_config.h | cut -d' ' -f4}

ifeq ($(ARCH),x86_64)
TOOLCHAIN := x86_64-linux-gnu
CFLAGS_ARCH := -march=x86-64 -mtune=generic
else
$(error Unsupported ARCH)
endif

CC := $(TOOLCHAIN)-gcc
LD := $(TOOLCHAIN)-ld
AS := $(TOOLCHAIN)-as
OBJCOPY := $(TOOLCHAIN)-objcopy
MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit

IMAGES := x86_64_iommu_dma_test.elf
CFLAGS := -nostdlib -ffreestanding -g3 -O3 -I$(BOARD_DIR)/include $(CFLAGS_ARCH)
LDFLAGS := -L$(BOARD_DIR)/lib -z noexecstack
LIBS := -lmicrokit -Tmicrokit.ld

INITIAL_TASK = $(BUILD_DIR)/initialiser.elf
KERNEL = $(BUILD_DIR)/sel4.elf
KERNEL_32B = $(BUILD_DIR)/sel4_32.elf
REPORT = $(BUILD_DIR)/report.txt
SPEC = $(BUILD_DIR)/capdl_spec.json

all: $(KERNEL) $(INITIAL_TASK)
qemu: $(KERNEL_32B) $(INITIAL_TASK)

$(BUILD_DIR)/x86_64_iommu_dma_test.o: x86_64_iommu_dma_test.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/x86_64_iommu_dma_test.elf: $(BUILD_DIR)/x86_64_iommu_dma_test.o
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(KERNEL) $(KERNEL_32B) $(INITIAL_TASK): $(addprefix $(BUILD_DIR)/, $(IMAGES)) x86_64_iommu_dma_test.system
$(MICROKIT_TOOL) x86_64_iommu_dma_test.system --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) -o $(INITIAL_TASK) -r $(REPORT) --capdl-json $(SPEC)

qemu:
qemu-system-x86_64 \
-machine q35 \
-cpu qemu64,+fsgsbase,+pdpe1gb,+xsaveopt,+xsave \
-m "4G" \
-display none \
-serial mon:stdio \
-device intel-iommu,intremap=off,aw-bits=39 \
-device edu,dma_mask=0xffffffffffffffff,bus=pcie.0,addr=0x04.0 \
-kernel $(KERNEL_32B) \
-initrd $(INITIAL_TASK)
25 changes: 25 additions & 0 deletions example/x86_64_iommu_dma_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Copyright 2026, UNSW
SPDX-License-Identifier: CC-BY-SA-4.0
-->
# x86_64_iommu_dma_test

This example checks x86 IOMMU mappings with QEMU's EDU PCI device. It maps one
RAM page into the EDU device's IOSpace, asks the device to DMA from that page
into its internal SRAM, then asks the device to DMA the SRAM contents back into
a second offset in the same RAM page and verifies the data.

The QEMU command in the Makefile pins the EDU device at PCI BDF `00:04.0`, which
must match the `pcidev="0:4.0"` attribute in the system description.

To build and run:

```sh
mkdir build
make -C example/x86_64_iommu_dma_test \
BUILD_DIR=build \
MICROKIT_SDK=/path/to/microkit-sdk \
MICROKIT_BOARD=x86_64_generic \
MICROKIT_CONFIG=debug \
qemu
```
Loading