From 98c2596fafda5bb742bd72137f9efbf9dd8c44a4 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 9 Jul 2024 09:10:40 +1000 Subject: [PATCH 01/25] examples/virtio: begin new makefile system Signed-off-by: Alex Brown --- examples/virtio/Makefile | 358 +++--------------------- examples/virtio/include/blk_config.h | 2 +- examples/virtio/include/serial_config.h | 2 +- examples/virtio/virtio.mk | 123 ++++++++ 4 files changed, 166 insertions(+), 319 deletions(-) create mode 100644 examples/virtio/virtio.mk diff --git a/examples/virtio/Makefile b/examples/virtio/Makefile index b1e42ea3..98077371 100644 --- a/examples/virtio/Makefile +++ b/examples/virtio/Makefile @@ -1,335 +1,59 @@ # -# Copyright 2021, Breakaway Consulting Pty. Ltd. -# Copyright 2022, UNSW (ABN 57 195 873 179) +# Copyright 2024, UNSW # # SPDX-License-Identifier: BSD-2-Clause # -# Default build directory, pass BUILD_DIR= to override BUILD_DIR ?= build -# Default config is a debug build, pass CONFIG= to override -CONFIG ?= debug +export MICROKIT_CONFIG ?= debug ifeq ($(strip $(MICROKIT_SDK)),) - $(error MICROKIT_SDK must be specified) +$(error MICROKIT_SDK must be specified) endif - -ifndef BOARD - $(error BOARD must be specified) -endif - -ifeq ($(filter $(BOARD), odroidc4 qemu_arm_virt),) - $(error "Board $(BOARD) is not supported") -endif - -# @ivanv: check that all dependencies exist -# Specify that we use bash for all shell commands -SHELL=/bin/bash -# All dependencies needed to compile the VMM -QEMU := qemu-system-aarch64 -DTC := dtc - -CC := clang -CC_USERLEVEL := zig cc -LD := ld.lld -AR := llvm-ar -RANLIB := llvm-ranlib - -MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit - -# @ivanv: need to have a step for putting in the initrd node into the DTB, -# right now it is unfortunately hard-coded. - -# @ivanv: check that the path of SDK_PATH/BOARD exists -# @ivanv: Have a list of supported boards to check with, if it's not one of those -# have a helpful message that lists all the support boards. - -# @ivanv: incremental builds don't work with IMAGE_DIR changing -BOARD_DIR := $(MICROKIT_SDK)/board/$(BOARD)/$(CONFIG) -LIBVMM := $(abspath ../..) -LIBVMM_TOOLS := $(LIBVMM)/tools -LIBVMM_SRC_DIR := $(LIBVMM)/src -SYSTEM_DESCRIPTION := board/$(BOARD)/virtio.system - -CURRENT_DIR := $(shell pwd) - -LINUX_DIR := $(LIBVMM_TOOLS)/linux -LINUX_BLK_DIR := $(LINUX_DIR)/blk -LINUX_BLK_BOARD_DIR := $(LINUX_BLK_DIR)/board/$(BOARD) - -UIO_DIR := $(LINUX_DIR)/uio -UIO_DRIVER_BLK_DIR := $(LINUX_DIR)/uio_drivers/blk - -SDDF_DIR := $(abspath ../../dep/sddf) - -VMM_INCLUDE := include - -BLK_DRIVER_VM_DIR := board/$(BOARD)/blk_driver_vm -BLK_DRIVER_VM_DTS_DIR := $(BLK_DRIVER_VM_DIR)/dts -BLK_DRIVER_VM_ROOTFS_TMP_DIR := $(BUILD_DIR)/blk_driver_vm_rootfs - -CLIENT_VM_DIR := board/$(BOARD)/client_vm -CLIENT_VM_DTS_DIR := $(CLIENT_VM_DIR)/dts -CLIENT_VM_ROOTFS_TMP_DIR := $(BUILD_DIR)/client_vm_rootfs - - -BLK_DRIVER_VM_LINUX := $(BLK_DRIVER_VM_DIR)/linux -BLK_DRIVER_VM_INITRD := $(BLK_DRIVER_VM_DIR)/rootfs.cpio.gz -BLK_DRIVER_VM_INITRD_MODIFIED := $(BUILD_DIR)/blk_driver_vm_rootfs.cpio.gz -BLK_DRIVER_VM_BASE_DTS := $(BLK_DRIVER_VM_DTS_DIR)/linux.dts -BLK_DRIVER_VM_DTS_OVERLAYS_qemu_arm_virt := $(BLK_DRIVER_VM_DTS_DIR)/init.dts \ - $(BLK_DRIVER_VM_DTS_DIR)/io.dts \ - $(BLK_DRIVER_VM_DTS_DIR)/disable.dts -BLK_DRIVER_VM_DTS_OVERLAYS_odroidc4 := $(BLK_DRIVER_VM_DTS_DIR)/init.dts \ - $(BLK_DRIVER_VM_DTS_DIR)/io.dts \ - $(BLK_DRIVER_VM_DTS_DIR)/disable.dts -BLK_DRIVER_VM_DTS_OVERLAYS := ${BLK_DRIVER_VM_DTS_OVERLAYS_${BOARD}} -BLK_DRIVER_VM_DTB := $(BUILD_DIR)/blk_driver_vm.dtb - - -CLIENT_VM_LINUX := $(CLIENT_VM_DIR)/linux -CLIENT_VM_INITRD := $(CLIENT_VM_DIR)/rootfs.cpio.gz -CLIENT_VM_INITRD_MODIFIED := $(BUILD_DIR)/client_vm_rootfs.cpio.gz -CLIENT_VM_BASE_DTS := $(CLIENT_VM_DTS_DIR)/linux.dts -CLIENT_VM_DTS_OVERLAYS_qemu_arm_virt := $(CLIENT_VM_DTS_DIR)/init.dts \ - $(CLIENT_VM_DTS_DIR)/virtio.dts -CLIENT_VM_DTS_OVERLAYS_odroidc4 := $(CLIENT_VM_DTS_DIR)/init.dts \ - $(CLIENT_VM_DTS_DIR)/virtio.dts\ - $(CLIENT_VM_DTS_DIR)/disable.dts -CLIENT_VM_DTS_OVERLAYS := ${CLIENT_VM_DTS_OVERLAYS_${BOARD}} -CLIENT_VM_DTB := $(BUILD_DIR)/client_vm.dtb - -SDDF_BLK_COMPONENTS := $(SDDF_DIR)/blk/components -SDDF_BLK_UTIL := $(SDDF_DIR)/blk/util - -ifeq ($(strip $(BOARD)), odroidc4) - export UART_DRIVER_DIR := meson -else ifeq ($(strip $(BOARD)), qemu_arm_virt) - export UART_DRIVER_DIR := arm +export override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) + +ifeq ($(strip $(MICROKIT_BOARD)), odroidc4) + export UART_DRIVER := meson + export CPU := cortex-a55 +else ifeq ($(strip $(MICROKIT_BOARD)), imx8mm_evk) + export UART_DRIVER := imx + export CPU := cortex-a53 +else ifeq ($(strip $(MICROKIT_BOARD)), maaxboard) + export UART_DRIVER := imx + export CPU := cortex-a53 +else ifeq ($(strip $(MICROKIT_BOARD)), qemu_arm_virt) + export UART_DRIVER := arm + export CPU := cortex-a53 + QEMU := qemu-system-aarch64 else -$(error Unsupported BOARD given) -endif -SDDF_SERIAL_DRIVER := $(SDDF_DIR)/drivers/serial/$(UART_DRIVER_DIR) - -ELFS := client_vmm.elf blk_driver_vmm.elf serial_virt_tx.elf serial_virt_rx.elf uart_driver.elf blk_virt.elf - -BLK_DRIVER_VM_USERLEVEL := uio_blk_driver -BLK_DRIVER_VM_USERLEVEL_INIT := blk_driver_init - -CLIENT_VM_USERLEVEL := -CLIENT_VM_USERLEVEL_INIT := blk_client_init - -IMAGE_FILE = $(BUILD_DIR)/loader.img -REPORT_FILE = $(BUILD_DIR)/report.txt - -# @ivanv: should only compile printf.o in debug -VMM_OBJS := printf.o \ - virq.o \ - linux.o \ - guest.o \ - psci.o \ - smc.o \ - fault.o \ - util.o \ - vgic.o \ - vgic_v2.o \ - tcb.o \ - vcpu.o - -CLIENT_VMM_OBJS := $(VMM_OBJS) \ - client_images.o \ - client_vmm.o \ - console.o \ - block.o \ - mmio.o \ - libsddf_util_debug.a - -BLK_DRIVER_VMM_OBJS := $(VMM_OBJS) \ - blk_driver_images.o \ - blk_driver_vmm.o \ - console.o \ - mmio.o - -BLK_VIRT_OBJS := sddf_blk_virt.o libsddf_util_debug.a -UIO_BLK_DRIVER_OBJS := blk.o libuio.o - -# Toolchain flags -# FIXME: For optimisation we should consider providing the flag -mcpu. -# FIXME: We should also consider whether -mgeneral-regs-only should be -# used to avoid the use of the FPU and therefore seL4 does not have to -# context switch the FPU. -# Note we only need -Wno-unused-command-line-argument because in Nix -# passes an extra `--gcc-toolchain` flag which we do not need. -CFLAGS := -mstrict-align \ - -g3 \ - -O3 \ - -ffreestanding \ - -nostdlib \ - -Wno-unused-command-line-argument \ - -Wall -Wno-unused-function -Werror \ - -I$(BOARD_DIR)/include \ - -I$(SDDF_DIR)/include \ - -I$(LIBVMM)/include \ - -I$(VMM_INCLUDE) \ - -DBOARD_$(BOARD) \ - -DCONFIG_$(CONFIG) \ - -target aarch64-none-elf - -CFLAGS_LINUX := -g3 \ - -O3 \ - -Wno-unused-command-line-argument \ - -Wall -Wno-unused-function -Werror \ - -D_GNU_SOURCE \ - -I$(SDDF_DIR)/include \ - -I$(LINUX_DIR)/include \ - -I$(VMM_INCLUDE) \ - -target aarch64-linux-gnu - -LDFLAGS := -L$(BOARD_DIR)/lib -LIBS := -lmicrokit -Tmicrokit.ld $(BUILD_DIR)/libsddf_util_debug.a - -ifeq ($(BOARD), qemu_arm_virt) - NUM_PART = 2 - BLK_SIZE = 512 - BLK_MEM ?= 2101248 +$(error Unsupported MICROKIT_BOARD given) endif -all: directories $(IMAGE_FILE) - -clean: - rm -rf $(BUILD_DIR) - -qemu: all $(BUILD_DIR)/storage - # @ivanv: check that the amount of RAM given to QEMU is at least the number of RAM that QEMU is setup with for seL4. - if ! command -v $(QEMU) &> /dev/null; then echo "Could not find dependency: qemu-system-aarch64"; exit 1; fi - $(QEMU) -machine virt,virtualization=on,secure=off \ - -cpu cortex-a53 \ - -serial mon:stdio \ - -device loader,file=$(IMAGE_FILE),addr=0x70000000,cpu-num=0 \ - -m size=2G \ - -nographic \ - -drive file=$(BUILD_DIR)/storage,format=raw,if=none,id=drive0 \ - -device virtio-blk-device,drive=drive0,id=virtblk0,num-queues=1 - -directories: - $(shell mkdir -p $(BUILD_DIR)) - $(shell mkdir -p $(BUILD_DIR)/util) - $(shell mkdir -p $(BUILD_DIR)/serial) - -SDDF_LIB_UTIL_DBG_OBJS := cache.o sddf_printf.o newlibc.o assert.o putchar_debug.o bitarray.o fsmalloc.o - -$(BUILD_DIR)/libsddf_util_debug.a: $(addprefix ${BUILD_DIR}/util/, ${SDDF_LIB_UTIL_DBG_OBJS}) - ${AR} rv $@ $^ - ${RANLIB} $@ - -$(BUILD_DIR)/util/sddf_printf.o: ${SDDF_DIR}/util/printf.c - ${CC} ${CFLAGS} -c -o $@ $< - -$(BUILD_DIR)/util/%.o: ${SDDF_DIR}/util/%.c - ${CC} ${CFLAGS} -c -o $@ $< - -$(BUILD_DIR)/uart_driver.elf: $(BUILD_DIR)/serial/uart_driver.o - $(LD) $(LDFLAGS) $< $(LIBS) -o $@ - -$(BUILD_DIR)/serial/uart_driver.o: ${SDDF_SERIAL_DRIVER}/uart.c - $(CC) -c $(CFLAGS) -I${SDDF_SERIAL_DRIVER}/include -o $@ $< - -$(BUILD_DIR)/serial_virt_%.elf: $(BUILD_DIR)/serial/virt_%.o - $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ - -$(BUILD_DIR)/serial/virt_%.o: ${SDDF_DIR}/serial/components/virt_%.c - ${CC} ${CFLAGS} -o $@ -c $< - -$(BUILD_DIR)/storage: - $(LIBVMM_TOOLS)/mkvirtdisk $@ $(NUM_PART) $(BLK_SIZE) $(BLK_MEM) - -# Unpack rootfs, put the userlevel in /root and userlevel_init in /etc/init.d/S99, repack rootfs -$(BLK_DRIVER_VM_INITRD_MODIFIED): $(addprefix $(BUILD_DIR)/, $(BLK_DRIVER_VM_USERLEVEL)) \ - $(addprefix $(BUILD_DIR)/, $(BLK_DRIVER_VM_USERLEVEL_INIT)) - $(LIBVMM_TOOLS)/packrootfs $(BLK_DRIVER_VM_INITRD) $(BLK_DRIVER_VM_ROOTFS_TMP_DIR) -o $(BLK_DRIVER_VM_INITRD_MODIFIED) \ - --startup $(addprefix $(BUILD_DIR)/, $(BLK_DRIVER_VM_USERLEVEL_INIT)) \ - --home $(addprefix $(BUILD_DIR)/, $(BLK_DRIVER_VM_USERLEVEL)) - -$(CLIENT_VM_INITRD_MODIFIED): $(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL)) \ - $(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL_INIT)) - $(LIBVMM_TOOLS)/packrootfs $(CLIENT_VM_INITRD) $(CLIENT_VM_ROOTFS_TMP_DIR) -o $(CLIENT_VM_INITRD_MODIFIED) \ - --startup $(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL_INIT)) \ - --home $(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL)) - -$(BLK_DRIVER_VM_DTB): $(BLK_DRIVER_VM_BASE_DTS) $(BLK_DRIVER_VM_DTS_OVERLAYS) - $(LIBVMM_TOOLS)/dtscat $^ > $(BUILD_DIR)/blk_driver_vm.dts - $(DTC) -q -I dts -O dtb $(BUILD_DIR)/blk_driver_vm.dts > $@ - -$(CLIENT_VM_DTB): $(CLIENT_VM_BASE_DTS) $(CLIENT_VM_DTS_OVERLAYS) - $(LIBVMM_TOOLS)/dtscat $^ > $(BUILD_DIR)/client_vm.dts - $(DTC) -q -I dts -O dtb $(BUILD_DIR)/client_vm.dts > $@ - -$(BUILD_DIR)/blk_driver_images.o: $(LIBVMM_TOOLS)/package_guest_images.S $(BLK_DRIVER_VM_LINUX) $(BLK_DRIVER_VM_DTB) $(BLK_DRIVER_VM_INITRD_MODIFIED) - $(CC) -c -g3 -x assembler-with-cpp \ - -DGUEST_KERNEL_IMAGE_PATH=\"$(BLK_DRIVER_VM_LINUX)\" \ - -DGUEST_DTB_IMAGE_PATH=\"$(BLK_DRIVER_VM_DTB)\" \ - -DGUEST_INITRD_IMAGE_PATH=\"$(BLK_DRIVER_VM_INITRD_MODIFIED)\" \ - -target aarch64-none-elf \ - $< -o $@ - -$(BUILD_DIR)/client_images.o: $(LIBVMM_TOOLS)/package_guest_images.S $(CLIENT_VM_LINUX) $(CLIENT_VM_DTB) $(CLIENT_VM_INITRD_MODIFIED) - $(CC) -c -g3 -x assembler-with-cpp \ - -DGUEST_KERNEL_IMAGE_PATH=\"$(CLIENT_VM_LINUX)\" \ - -DGUEST_DTB_IMAGE_PATH=\"$(CLIENT_VM_DTB)\" \ - -DGUEST_INITRD_IMAGE_PATH=\"$(CLIENT_VM_INITRD_MODIFIED)\" \ - -target aarch64-none-elf \ - $< -o $@ - -$(BUILD_DIR)/%.o: %.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/util/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/arch/aarch64/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/arch/aarch64/vgic/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/virtio/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/sddf_blk_%.o: $(SDDF_BLK_COMPONENTS)/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/sddf_blk_%.o: $(SDDF_BLK_UTIL)/%.c Makefile - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/client_vmm.elf: $(addprefix $(BUILD_DIR)/, $(CLIENT_VMM_OBJS)) - $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ - -$(BUILD_DIR)/blk_driver_vmm.elf: $(addprefix $(BUILD_DIR)/, $(BLK_DRIVER_VMM_OBJS)) - $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ - -$(BUILD_DIR)/blk_virt.elf: $(addprefix $(BUILD_DIR)/, $(BLK_VIRT_OBJS)) - $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ - -$(BUILD_DIR)/postmark: $(LINUX_BLK_DIR)/postmark.c - $(CC_USERLEVEL) $(CFLAGS_LINUX) $< -o $@ +export BUILD_DIR:=$(abspath ${BUILD_DIR}) +export MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) +export VIRTIO_EXAMPLE:=$(abspath .) -$(BUILD_DIR)/blk_client_init: $(LINUX_BLK_DIR)/blk_client_init - cp $< $@ +export TARGET := aarch64-none-elf +export CC := clang +export LD := ld.lld +export AS := llvm-as +export AR := llvm-ar +export DTC := dtc +export RANLIB := llvm-ranlib +export MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit +export SDDF=$(abspath ../../dep/sddf) +export VMM=$(abspath ../../) -$(BUILD_DIR)/blk_driver_init: $(LINUX_BLK_BOARD_DIR)/blk_driver_init - cp $< $@ +IMAGE_FILE := $(BUILD_DIR)/loader.img +REPORT_FILE := $(BUILD_DIR)/report.txt -$(BUILD_DIR)/%.o: $(UIO_DIR)/%.c Makefile - $(CC_USERLEVEL) -c $(CFLAGS_LINUX) $< -o $@ +all: ${IMAGE_FILE} -$(BUILD_DIR)/%.o: $(UIO_DRIVER_BLK_DIR)/%.c Makefile - $(CC_USERLEVEL) -c $(CFLAGS_LINUX) $< -o $@ +qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE + ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) -$(BUILD_DIR)/uio_blk_driver: $(addprefix $(BUILD_DIR)/, $(UIO_BLK_DRIVER_OBJS)) - $(CC_USERLEVEL) $(CFLAGS_LINUX) $^ -o $@ +${BUILD_DIR}/Makefile: virtio.mk + mkdir -p ${BUILD_DIR} + cp virtio.mk $@ -$(IMAGE_FILE) $(REPORT_FILE): $(addprefix $(BUILD_DIR)/, $(ELFS)) $(SYSTEM_DESCRIPTION) - $(MICROKIT_TOOL) $(SYSTEM_DESCRIPTION) --search-path $(BUILD_DIR) --board $(BOARD) --config $(CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE) \ No newline at end of file +FORCE: diff --git a/examples/virtio/include/blk_config.h b/examples/virtio/include/blk_config.h index 47b6f294..5d030e20 100644 --- a/examples/virtio/include/blk_config.h +++ b/examples/virtio/include/blk_config.h @@ -3,7 +3,7 @@ #include #include -#define BLK_NUM_CLIENTS 2 +// #define BLK_NUM_CLIENTS 2 #define BLK_NAME_CLI0 "CLIENT_VMM-1" #define BLK_NAME_CLI1 "CLIENT_VMM-2" diff --git a/examples/virtio/include/serial_config.h b/examples/virtio/include/serial_config.h index d3e4b5bb..4e12fb2e 100644 --- a/examples/virtio/include/serial_config.h +++ b/examples/virtio/include/serial_config.h @@ -6,7 +6,7 @@ #include /* Number of clients */ -#define SERIAL_NUM_CLIENTS 3 +// #define SERIAL_NUM_CLIENTS 3 /* Only support transmission and not receive. */ #define SERIAL_TX_ONLY 0 diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk new file mode 100644 index 00000000..3e5b122f --- /dev/null +++ b/examples/virtio/virtio.mk @@ -0,0 +1,123 @@ +QEMU := qemu-system-aarch64 + +MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit +SDDF_INCLUDE := $(SDDF)/include/sddf +UTIL := $(SDDF)/util + +UART_DRIVER := $(SDDF)/drivers/serial/$(UART_DRIVER) +SERIAL_COMPONENTS := $(SDDF)/serial/components +BLK_COMPONENTS := $(SDDF)/blk/components + +SERIAL_NUM_CLIENTS := -DSERIAL_NUM_CLIENTS=3 +BLK_NUM_CLIENTS := -DBLK_NUM_CLIENTS=2 + +BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) +SYSTEM_DIR := ${VIRTIO_EXAMPLE}/board/$(MICROKIT_BOARD) +SYSTEM_FILE := ${SYSTEM_DIR}/virtio.system +IMAGE_FILE := loader.img +REPORT_FILE := report.txt + +vpath %.c ${SDDF} ${VMM} ${VIRTIO_EXAMPLE} ${NETWORK_COMPONENTS} + +include ${SDDF}/util/util.mk +include ${UART_DRIVER}/uart_driver.mk +include ${SERIAL_COMPONENTS}/serial_components.mk +include ${BLK_COMPONENTS}/blk_components.mk +include ${VMM}/vmm.mk + +IMAGES := client_vmm.elf blk_driver_vmm.elf \ + $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf + +CFLAGS := \ + -mstrict-align \ + -ffreestanding \ + -g3 -O3 -Wall \ + -Wno-unused-function \ + -DMICROKIT_CONFIG_$(MICROKIT_CONFIG) \ + -DBOARD_$(MICROKIT_BOARD) \ + -DCONFIG_$(MICROKIT_CONFIG) \ + -I$(BOARD_DIR)/include \ + -I$(SDDF)/include \ + -I${VMM}/src \ + -I${VMM}/src/arch/aarch64 \ + -I${VMM}/src/util \ + -I${VIRTIO_EXAMPLE}/include \ + -I${SDDF}/$(LWIPDIR)/include \ + -I${SDDF}/$(LWIPDIR)/include/ipv4 \ + -MD \ + -MP \ + -target $(TARGET) + +LDFLAGS := -L$(BOARD_DIR)/lib +LIBS := --start-group -lmicrokit -Tmicrokit.ld libsddf_util_debug.a libvmm.a --end-group + +CHECK_FLAGS_BOARD_MD5:=.board_cflags-$(shell echo -- ${CFLAGS} ${BOARD} ${MICROKIT_CONFIG} | shasum | sed 's/ *-//') + +${CHECK_FLAGS_BOARD_MD5}: + -rm -f .board_cflags-* + touch $@ + +%_vmm.elf: %_vm/vmm.o %_vm/images.o + $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ + +all: loader.img + +-include vmm.d + +${IMAGES}: libsddf_util_debug.a libvmm.a + +${IMAGE_FILE} $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) + $(MICROKIT_TOOL) $(SYSTEM_FILE) --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE) + +%_vm: + mkdir -p $@ + +# TODO: sort out userlevel scripts & build userlevel processes +client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz + $(VMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz client_vm/rootfs -o $@ \ + --startup $(CLIENT_VM_USERLEVEL) \ + --home $(CLIENT_VM_USERLEVEL) + +# %_vm/rootfs.cpio.gz: %_vm $(SYSTEM_DIR)/%_vm/rootfs.cpio.gz +# $(VMM)/tools/packrootfs $(SYSTEM_DIR)/$ $@ + +%_vm/vm.dtb: %_vm/vm.dts %_vm + $(DTC) -q -I dts -O dtb $< > $@ + +%_vm/vmm.o: ${VIRTIO_EXAMPLE}/%_vmm.c ${CHECK_FLAGS_BOARD_MD5} %_vm + $(CC) $(CFLAGS) -c -o $@ $< + +%_vm/images.o: %_vm $(VMM)/tools/package_guest_images.S $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz + $(CC) -c -g3 -x assembler-with-cpp \ + -DGUEST_KERNEL_IMAGE_PATH=\"$(SYSTEM_DIR)/$ Date: Tue, 9 Jul 2024 09:43:57 +1000 Subject: [PATCH 02/25] examples/virtio: make: switch ${} to $() Signed-off-by: Alex Brown --- examples/virtio/Makefile | 16 +++++++-------- examples/virtio/virtio.mk | 42 +++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/virtio/Makefile b/examples/virtio/Makefile index 98077371..3ce298e6 100644 --- a/examples/virtio/Makefile +++ b/examples/virtio/Makefile @@ -10,7 +10,7 @@ export MICROKIT_CONFIG ?= debug ifeq ($(strip $(MICROKIT_SDK)),) $(error MICROKIT_SDK must be specified) endif -export override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) +export override MICROKIT_SDK:=$(abspath $(MICROKIT_SDK)) ifeq ($(strip $(MICROKIT_BOARD)), odroidc4) export UART_DRIVER := meson @@ -29,8 +29,8 @@ else $(error Unsupported MICROKIT_BOARD given) endif -export BUILD_DIR:=$(abspath ${BUILD_DIR}) -export MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) +export BUILD_DIR:=$(abspath $(BUILD_DIR)) +export MICROKIT_SDK:=$(abspath $(MICROKIT_SDK)) export VIRTIO_EXAMPLE:=$(abspath .) export TARGET := aarch64-none-elf @@ -47,13 +47,13 @@ export VMM=$(abspath ../../) IMAGE_FILE := $(BUILD_DIR)/loader.img REPORT_FILE := $(BUILD_DIR)/report.txt -all: ${IMAGE_FILE} +all: $(IMAGE_FILE) -qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE - ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) +qemu $(IMAGE_FILE) $(REPORT_FILE) clean clobber: $(BUILD_DIR)/Makefile FORCE + $(MAKE) -C $(BUILD_DIR) MICROKIT_SDK=$(MICROKIT_SDK) $(notdir $@) -${BUILD_DIR}/Makefile: virtio.mk - mkdir -p ${BUILD_DIR} +$(BUILD_DIR)/Makefile: virtio.mk + mkdir -p $(BUILD_DIR) cp virtio.mk $@ FORCE: diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 3e5b122f..89b71b45 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -12,18 +12,18 @@ SERIAL_NUM_CLIENTS := -DSERIAL_NUM_CLIENTS=3 BLK_NUM_CLIENTS := -DBLK_NUM_CLIENTS=2 BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) -SYSTEM_DIR := ${VIRTIO_EXAMPLE}/board/$(MICROKIT_BOARD) -SYSTEM_FILE := ${SYSTEM_DIR}/virtio.system +SYSTEM_DIR := $(VIRTIO_EXAMPLE)/board/$(MICROKIT_BOARD) +SYSTEM_FILE := $(SYSTEM_DIR)/virtio.system IMAGE_FILE := loader.img REPORT_FILE := report.txt -vpath %.c ${SDDF} ${VMM} ${VIRTIO_EXAMPLE} ${NETWORK_COMPONENTS} +vpath %.c $(SDDF) $(VMM) $(VIRTIO_EXAMPLE) $(NETWORK_COMPONENTS) -include ${SDDF}/util/util.mk -include ${UART_DRIVER}/uart_driver.mk -include ${SERIAL_COMPONENTS}/serial_components.mk -include ${BLK_COMPONENTS}/blk_components.mk -include ${VMM}/vmm.mk +include $(SDDF)/util/util.mk +include $(UART_DRIVER)/uart_driver.mk +include $(SERIAL_COMPONENTS)/serial_components.mk +include $(BLK_COMPONENTS)/blk_components.mk +include $(VMM)/vmm.mk IMAGES := client_vmm.elf blk_driver_vmm.elf \ $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf @@ -38,12 +38,12 @@ CFLAGS := \ -DCONFIG_$(MICROKIT_CONFIG) \ -I$(BOARD_DIR)/include \ -I$(SDDF)/include \ - -I${VMM}/src \ - -I${VMM}/src/arch/aarch64 \ - -I${VMM}/src/util \ - -I${VIRTIO_EXAMPLE}/include \ - -I${SDDF}/$(LWIPDIR)/include \ - -I${SDDF}/$(LWIPDIR)/include/ipv4 \ + -I$(VMM)/src \ + -I$(VMM)/src/arch/aarch64 \ + -I$(VMM)/src/util \ + -I$(VIRTIO_EXAMPLE)/include \ + -I$(SDDF)/$(LWIPDIR)/include \ + -I$(SDDF)/$(LWIPDIR)/include/ipv4 \ -MD \ -MP \ -target $(TARGET) @@ -51,9 +51,9 @@ CFLAGS := \ LDFLAGS := -L$(BOARD_DIR)/lib LIBS := --start-group -lmicrokit -Tmicrokit.ld libsddf_util_debug.a libvmm.a --end-group -CHECK_FLAGS_BOARD_MD5:=.board_cflags-$(shell echo -- ${CFLAGS} ${BOARD} ${MICROKIT_CONFIG} | shasum | sed 's/ *-//') +CHECK_FLAGS_BOARD_MD5:=.board_cflags-$(shell echo -- $(CFLAGS) $(BOARD) $(MICROKIT_CONFIG) | shasum | sed 's/ *-//') -${CHECK_FLAGS_BOARD_MD5}: +$(CHECK_FLAGS_BOARD_MD5): -rm -f .board_cflags-* touch $@ @@ -64,9 +64,9 @@ all: loader.img -include vmm.d -${IMAGES}: libsddf_util_debug.a libvmm.a +$(IMAGES): libsddf_util_debug.a libvmm.a -${IMAGE_FILE} $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) +$(IMAGE_FILE) $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) $(MICROKIT_TOOL) $(SYSTEM_FILE) --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE) %_vm: @@ -87,7 +87,7 @@ client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz %_vm/vm.dtb: %_vm/vm.dts %_vm $(DTC) -q -I dts -O dtb $< > $@ -%_vm/vmm.o: ${VIRTIO_EXAMPLE}/%_vmm.c ${CHECK_FLAGS_BOARD_MD5} %_vm +%_vm/vmm.o: $(VIRTIO_EXAMPLE)/%_vmm.c $(CHECK_FLAGS_BOARD_MD5) %_vm $(CC) $(CFLAGS) -c -o $@ $< %_vm/images.o: %_vm $(VMM)/tools/package_guest_images.S $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz @@ -115,9 +115,9 @@ qemu: $(IMAGE_FILE) -d guest_errors clean:: - ${RM} -f *.elf .depend* $ + $(RM) -f *.elf .depend* $ find . -name \*.[do] |xargs --no-run-if-empty rm clobber:: clean rm -f *.a - rm -f ${IMAGE_FILE} ${REPORT_FILE} + rm -f $(IMAGE_FILE) $(REPORT_FILE) From e624b26f42f665124528ffcc278af034fddf40f3 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 9 Jul 2024 09:45:48 +1000 Subject: [PATCH 03/25] examples/virtio: make: change VMM to LIBVMM Signed-off-by: Alex Brown --- examples/virtio/Makefile | 2 +- examples/virtio/virtio.mk | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/virtio/Makefile b/examples/virtio/Makefile index 3ce298e6..c425fd26 100644 --- a/examples/virtio/Makefile +++ b/examples/virtio/Makefile @@ -42,7 +42,7 @@ export DTC := dtc export RANLIB := llvm-ranlib export MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit export SDDF=$(abspath ../../dep/sddf) -export VMM=$(abspath ../../) +export LIBVMM=$(abspath ../../) IMAGE_FILE := $(BUILD_DIR)/loader.img REPORT_FILE := $(BUILD_DIR)/report.txt diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 89b71b45..e4b89258 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -17,13 +17,13 @@ SYSTEM_FILE := $(SYSTEM_DIR)/virtio.system IMAGE_FILE := loader.img REPORT_FILE := report.txt -vpath %.c $(SDDF) $(VMM) $(VIRTIO_EXAMPLE) $(NETWORK_COMPONENTS) +vpath %.c $(SDDF) $(LIBVMM) $(VIRTIO_EXAMPLE) $(NETWORK_COMPONENTS) include $(SDDF)/util/util.mk include $(UART_DRIVER)/uart_driver.mk include $(SERIAL_COMPONENTS)/serial_components.mk include $(BLK_COMPONENTS)/blk_components.mk -include $(VMM)/vmm.mk +include $(LIBVMM)/vmm.mk IMAGES := client_vmm.elf blk_driver_vmm.elf \ $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf @@ -38,9 +38,7 @@ CFLAGS := \ -DCONFIG_$(MICROKIT_CONFIG) \ -I$(BOARD_DIR)/include \ -I$(SDDF)/include \ - -I$(VMM)/src \ - -I$(VMM)/src/arch/aarch64 \ - -I$(VMM)/src/util \ + -I$(LIBVMM)/include \ -I$(VIRTIO_EXAMPLE)/include \ -I$(SDDF)/$(LWIPDIR)/include \ -I$(SDDF)/$(LWIPDIR)/include/ipv4 \ @@ -74,15 +72,15 @@ $(IMAGE_FILE) $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) # TODO: sort out userlevel scripts & build userlevel processes client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz - $(VMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz client_vm/rootfs -o $@ \ + $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz client_vm/rootfs -o $@ \ --startup $(CLIENT_VM_USERLEVEL) \ --home $(CLIENT_VM_USERLEVEL) # %_vm/rootfs.cpio.gz: %_vm $(SYSTEM_DIR)/%_vm/rootfs.cpio.gz -# $(VMM)/tools/packrootfs $(SYSTEM_DIR)/$ $@ + $(LIBVMM)/tools/dtscat $^ > $@ %_vm/vm.dtb: %_vm/vm.dts %_vm $(DTC) -q -I dts -O dtb $< > $@ @@ -90,13 +88,13 @@ client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz %_vm/vmm.o: $(VIRTIO_EXAMPLE)/%_vmm.c $(CHECK_FLAGS_BOARD_MD5) %_vm $(CC) $(CFLAGS) -c -o $@ $< -%_vm/images.o: %_vm $(VMM)/tools/package_guest_images.S $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz +%_vm/images.o: %_vm $(LIBVMM)/tools/package_guest_images.S $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz $(CC) -c -g3 -x assembler-with-cpp \ -DGUEST_KERNEL_IMAGE_PATH=\"$(SYSTEM_DIR)/$ Date: Tue, 9 Jul 2024 09:49:02 +1000 Subject: [PATCH 04/25] examples/virtio: make: remove -DCONFIG Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index e4b89258..67d00b91 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -35,7 +35,6 @@ CFLAGS := \ -Wno-unused-function \ -DMICROKIT_CONFIG_$(MICROKIT_CONFIG) \ -DBOARD_$(MICROKIT_BOARD) \ - -DCONFIG_$(MICROKIT_CONFIG) \ -I$(BOARD_DIR)/include \ -I$(SDDF)/include \ -I$(LIBVMM)/include \ From 0c2ee7e7774795f62b214e5d5f8ca129c365870d Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 9 Jul 2024 10:51:43 +1000 Subject: [PATCH 05/25] examples/virtio: make: add userlevel snippets Signed-off-by: Alex Brown --- examples/virtio/Makefile | 5 +++ examples/virtio/include/blk_config.h | 2 +- examples/virtio/virtio.mk | 41 ++++++++++++++++++------ tools/linux/blk/blk_init.mk | 21 ++++++++++++ tools/linux/uio_drivers/blk/uio_blk.mk | 44 ++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 tools/linux/blk/blk_init.mk create mode 100644 tools/linux/uio_drivers/blk/uio_blk.mk diff --git a/examples/virtio/Makefile b/examples/virtio/Makefile index c425fd26..7f001cf9 100644 --- a/examples/virtio/Makefile +++ b/examples/virtio/Makefile @@ -25,6 +25,10 @@ else ifeq ($(strip $(MICROKIT_BOARD)), qemu_arm_virt) export UART_DRIVER := arm export CPU := cortex-a53 QEMU := qemu-system-aarch64 + + export BLK_NUM_PART = 2 + export BLK_SIZE = 512 + export BLK_MEM ?= 2101248 else $(error Unsupported MICROKIT_BOARD given) endif @@ -35,6 +39,7 @@ export VIRTIO_EXAMPLE:=$(abspath .) export TARGET := aarch64-none-elf export CC := clang +export CC_USERLEVEL := zig cc export LD := ld.lld export AS := llvm-as export AR := llvm-ar diff --git a/examples/virtio/include/blk_config.h b/examples/virtio/include/blk_config.h index 5d030e20..47b6f294 100644 --- a/examples/virtio/include/blk_config.h +++ b/examples/virtio/include/blk_config.h @@ -3,7 +3,7 @@ #include #include -// #define BLK_NUM_CLIENTS 2 +#define BLK_NUM_CLIENTS 2 #define BLK_NAME_CLI0 "CLIENT_VMM-1" #define BLK_NAME_CLI1 "CLIENT_VMM-2" diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 67d00b91..22be4347 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -1,5 +1,6 @@ QEMU := qemu-system-aarch64 +VMM_TOOLS := $(LIBVMM)/tools MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit SDDF_INCLUDE := $(SDDF)/include/sddf UTIL := $(SDDF)/util @@ -9,7 +10,6 @@ SERIAL_COMPONENTS := $(SDDF)/serial/components BLK_COMPONENTS := $(SDDF)/blk/components SERIAL_NUM_CLIENTS := -DSERIAL_NUM_CLIENTS=3 -BLK_NUM_CLIENTS := -DBLK_NUM_CLIENTS=2 BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) SYSTEM_DIR := $(VIRTIO_EXAMPLE)/board/$(MICROKIT_BOARD) @@ -17,6 +17,11 @@ SYSTEM_FILE := $(SYSTEM_DIR)/virtio.system IMAGE_FILE := loader.img REPORT_FILE := report.txt +CLIENT_VM_USERLEVEL := +CLIENT_VM_USERLEVEL_INIT := blk_client_init +BLK_DRIVER_VM_USERLEVEL := uio_blk_driver +BLK_DRIVER_VM_USERLEVEL_INIT := blk_driver_init + vpath %.c $(SDDF) $(LIBVMM) $(VIRTIO_EXAMPLE) $(NETWORK_COMPONENTS) include $(SDDF)/util/util.mk @@ -24,6 +29,8 @@ include $(UART_DRIVER)/uart_driver.mk include $(SERIAL_COMPONENTS)/serial_components.mk include $(BLK_COMPONENTS)/blk_components.mk include $(LIBVMM)/vmm.mk +include $(VMM_TOOLS)/linux/blk/blk_init.mk +include $(VMM_TOOLS)/linux/uio_drivers/blk/uio_blk.mk IMAGES := client_vmm.elf blk_driver_vmm.elf \ $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf @@ -45,6 +52,15 @@ CFLAGS := \ -MP \ -target $(TARGET) +CFLAGS_USERLEVEL := \ + -g3 \ + -O3 \ + -Wno-unused-command-line-argument \ + -Wall -Wno-unused-function -Werror \ + -D_GNU_SOURCE \ + -I$(VIRTIO_EXAMPLE)/include \ + -target aarch64-linux-gnu + LDFLAGS := -L$(BOARD_DIR)/lib LIBS := --start-group -lmicrokit -Tmicrokit.ld libsddf_util_debug.a libvmm.a --end-group @@ -69,12 +85,19 @@ $(IMAGE_FILE) $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) %_vm: mkdir -p $@ -# TODO: sort out userlevel scripts & build userlevel processes -client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz +client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz client_vm/rootfs -o $@ \ - --startup $(CLIENT_VM_USERLEVEL) \ + --startup $(CLIENT_VM_USERLEVEL_INIT) \ --home $(CLIENT_VM_USERLEVEL) +blk_driver_vm/rootfs.cpio.gz: blk_driver_vm $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) + $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz blk_driver_vm/rootfs -o $@ \ + --startup $(BLK_DRIVER_VM_USERLEVEL_INIT) \ + --home $(BLK_DRIVER_VM_USERLEVEL) + +blk_storage: + $(VMM_TOOLS)/mkvirtdisk $@ $(BLK_NUM_PART) $(BLK_SIZE) $(BLK_MEM) + # %_vm/rootfs.cpio.gz: %_vm $(SYSTEM_DIR)/%_vm/rootfs.cpio.gz # $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/$ Date: Tue, 9 Jul 2024 11:00:55 +1000 Subject: [PATCH 06/25] Update sDDF commit for blk snippets Signed-off-by: Alex Brown --- dep/sddf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dep/sddf b/dep/sddf index 96f9d3ad..7ee2c908 160000 --- a/dep/sddf +++ b/dep/sddf @@ -1 +1 @@ -Subproject commit 96f9d3adb16639166637e293e5ee66bc0c54b547 +Subproject commit 7ee2c90834e69403a8c96430614edca3a67f9ab4 From 4da247203a30d5bf00e4835268078bef7635ef66 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 9 Jul 2024 11:59:19 +1000 Subject: [PATCH 07/25] examples/virtio: fix dts overlays Signed-off-by: Alex Brown --- .../odroidc4/blk_driver_vm/dts/{ => overlays}/disable.dts | 0 .../board/odroidc4/blk_driver_vm/dts/{ => overlays}/init.dts | 0 .../board/odroidc4/blk_driver_vm/dts/{ => overlays}/io.dts | 0 .../board/odroidc4/client_vm/dts/{ => overlays}/disable.dts | 0 .../board/odroidc4/client_vm/dts/{ => overlays}/init.dts | 0 .../board/odroidc4/client_vm/dts/{ => overlays}/virtio.dts | 0 .../blk_driver_vm/dts/{ => overlays}/disable.dts | 0 .../qemu_arm_virt/blk_driver_vm/dts/{ => overlays}/init.dts | 0 .../qemu_arm_virt/blk_driver_vm/dts/{ => overlays}/io.dts | 0 .../qemu_arm_virt/client_vm/dts/{ => overlays}/init.dts | 0 .../qemu_arm_virt/client_vm/dts/{ => overlays}/virtio.dts | 0 examples/virtio/virtio.mk | 5 +---- 12 files changed, 1 insertion(+), 4 deletions(-) rename examples/virtio/board/odroidc4/blk_driver_vm/dts/{ => overlays}/disable.dts (100%) rename examples/virtio/board/odroidc4/blk_driver_vm/dts/{ => overlays}/init.dts (100%) rename examples/virtio/board/odroidc4/blk_driver_vm/dts/{ => overlays}/io.dts (100%) rename examples/virtio/board/odroidc4/client_vm/dts/{ => overlays}/disable.dts (100%) rename examples/virtio/board/odroidc4/client_vm/dts/{ => overlays}/init.dts (100%) rename examples/virtio/board/odroidc4/client_vm/dts/{ => overlays}/virtio.dts (100%) rename examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/{ => overlays}/disable.dts (100%) rename examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/{ => overlays}/init.dts (100%) rename examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/{ => overlays}/io.dts (100%) rename examples/virtio/board/qemu_arm_virt/client_vm/dts/{ => overlays}/init.dts (100%) rename examples/virtio/board/qemu_arm_virt/client_vm/dts/{ => overlays}/virtio.dts (100%) diff --git a/examples/virtio/board/odroidc4/blk_driver_vm/dts/disable.dts b/examples/virtio/board/odroidc4/blk_driver_vm/dts/overlays/disable.dts similarity index 100% rename from examples/virtio/board/odroidc4/blk_driver_vm/dts/disable.dts rename to examples/virtio/board/odroidc4/blk_driver_vm/dts/overlays/disable.dts diff --git a/examples/virtio/board/odroidc4/blk_driver_vm/dts/init.dts b/examples/virtio/board/odroidc4/blk_driver_vm/dts/overlays/init.dts similarity index 100% rename from examples/virtio/board/odroidc4/blk_driver_vm/dts/init.dts rename to examples/virtio/board/odroidc4/blk_driver_vm/dts/overlays/init.dts diff --git a/examples/virtio/board/odroidc4/blk_driver_vm/dts/io.dts b/examples/virtio/board/odroidc4/blk_driver_vm/dts/overlays/io.dts similarity index 100% rename from examples/virtio/board/odroidc4/blk_driver_vm/dts/io.dts rename to examples/virtio/board/odroidc4/blk_driver_vm/dts/overlays/io.dts diff --git a/examples/virtio/board/odroidc4/client_vm/dts/disable.dts b/examples/virtio/board/odroidc4/client_vm/dts/overlays/disable.dts similarity index 100% rename from examples/virtio/board/odroidc4/client_vm/dts/disable.dts rename to examples/virtio/board/odroidc4/client_vm/dts/overlays/disable.dts diff --git a/examples/virtio/board/odroidc4/client_vm/dts/init.dts b/examples/virtio/board/odroidc4/client_vm/dts/overlays/init.dts similarity index 100% rename from examples/virtio/board/odroidc4/client_vm/dts/init.dts rename to examples/virtio/board/odroidc4/client_vm/dts/overlays/init.dts diff --git a/examples/virtio/board/odroidc4/client_vm/dts/virtio.dts b/examples/virtio/board/odroidc4/client_vm/dts/overlays/virtio.dts similarity index 100% rename from examples/virtio/board/odroidc4/client_vm/dts/virtio.dts rename to examples/virtio/board/odroidc4/client_vm/dts/overlays/virtio.dts diff --git a/examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/disable.dts b/examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/overlays/disable.dts similarity index 100% rename from examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/disable.dts rename to examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/overlays/disable.dts diff --git a/examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/init.dts b/examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/overlays/init.dts similarity index 100% rename from examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/init.dts rename to examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/overlays/init.dts diff --git a/examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/io.dts b/examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/overlays/io.dts similarity index 100% rename from examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/io.dts rename to examples/virtio/board/qemu_arm_virt/blk_driver_vm/dts/overlays/io.dts diff --git a/examples/virtio/board/qemu_arm_virt/client_vm/dts/init.dts b/examples/virtio/board/qemu_arm_virt/client_vm/dts/overlays/init.dts similarity index 100% rename from examples/virtio/board/qemu_arm_virt/client_vm/dts/init.dts rename to examples/virtio/board/qemu_arm_virt/client_vm/dts/overlays/init.dts diff --git a/examples/virtio/board/qemu_arm_virt/client_vm/dts/virtio.dts b/examples/virtio/board/qemu_arm_virt/client_vm/dts/overlays/virtio.dts similarity index 100% rename from examples/virtio/board/qemu_arm_virt/client_vm/dts/virtio.dts rename to examples/virtio/board/qemu_arm_virt/client_vm/dts/overlays/virtio.dts diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 22be4347..eb7c186e 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -98,10 +98,7 @@ blk_driver_vm/rootfs.cpio.gz: blk_driver_vm $(SYSTEM_DIR)/blk_driver_vm/rootfs.c blk_storage: $(VMM_TOOLS)/mkvirtdisk $@ $(BLK_NUM_PART) $(BLK_SIZE) $(BLK_MEM) -# %_vm/rootfs.cpio.gz: %_vm $(SYSTEM_DIR)/%_vm/rootfs.cpio.gz -# $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/$ $@ %_vm/vm.dtb: %_vm/vm.dts %_vm From 4bca7ae117eb9d0ef170443822fe4730f5ce5a11 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 9 Jul 2024 12:25:10 +1000 Subject: [PATCH 08/25] Add libuio makefile snippet Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 1 + tools/linux/uio/uio.mk | 43 ++++++++++++++++++++++++++ tools/linux/uio_drivers/blk/uio_blk.mk | 6 ++-- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 tools/linux/uio/uio.mk diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index eb7c186e..15b4c8eb 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -29,6 +29,7 @@ include $(UART_DRIVER)/uart_driver.mk include $(SERIAL_COMPONENTS)/serial_components.mk include $(BLK_COMPONENTS)/blk_components.mk include $(LIBVMM)/vmm.mk +include $(VMM_TOOLS)/linux/uio/uio.mk include $(VMM_TOOLS)/linux/blk/blk_init.mk include $(VMM_TOOLS)/linux/uio_drivers/blk/uio_blk.mk diff --git a/tools/linux/uio/uio.mk b/tools/linux/uio/uio.mk new file mode 100644 index 00000000..f9de767a --- /dev/null +++ b/tools/linux/uio/uio.mk @@ -0,0 +1,43 @@ +# +# Copyright 2024, UNSW +# +# SPDX-License-Identifier: BSD-2-Clause +# +# This Makefile snippet builds block UIO driver +# + +ifeq ($(strip $(VMM_TOOLS)),) +$(error VMM_TOOLS must be specified) +endif +ifeq ($(strip $(SDDF)),) +$(error SDDF must be specified) +endif +ifeq ($(strip $(CC_USERLEVEL)),) +$(error CC_USERLEVEL must be specified) +endif + +LIBUIO_IMAGES := libuio.a + +CFLAGS_libuio := -I$(SDDF)/include -I$(VMM_TOOLS)/linux/include + +CHECK_LIBUIO_FLAGS_MD5:=.libuio_cflags-$(shell echo -- $(CFLAGS_USERLEVEL) $(CFLAGS_libuio) | shasum | sed 's/ *-//') + +$(CHECK_LIBUIO_FLAGS_MD5): + -rm -f .libuio_cflags-* + touch $@ + + +libuio.a: libuio.o + ar rv $@ $^ + +libuio.o: $(CHECK_LIBUIO_FLAGS_MD5) +libuio.o: $(VMM_TOOLS)/linux/uio/libuio.c + $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_libuio) -o $@ -c $< + +clean:: + rm -f libuio.[od] .libuio_cflags-* + +clobber:: + rm -f $(UIO_BLK_IMAGES) + +-include libuio.d diff --git a/tools/linux/uio_drivers/blk/uio_blk.mk b/tools/linux/uio_drivers/blk/uio_blk.mk index 78381d53..721bdffc 100644 --- a/tools/linux/uio_drivers/blk/uio_blk.mk +++ b/tools/linux/uio_drivers/blk/uio_blk.mk @@ -26,10 +26,8 @@ $(CHECK_UIO_BLK_DRIVER_FLAGS_MD5): -rm -f .uio_blk_driver_cflags-* touch $@ - -# This shouldn't have a -c but for some reason it only works with one -uio_blk_driver: uio_blk_driver.o - $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_uio_blk_driver) -o $@ -c $< +uio_blk_driver: uio_blk_driver.o libuio.a + $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_uio_blk_driver) $^ -o $@ uio_blk_driver.o: $(CHECK_UIO_BLK_DRIVER_FLAGS_MD5) uio_blk_driver.o: $(VMM_TOOLS)/linux/uio_drivers/blk/blk.c From c149f249035c1f4ce4e58e17d814316840d24aa2 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 9 Jul 2024 13:29:05 +1000 Subject: [PATCH 09/25] examples/virtio: update CI Signed-off-by: Alex Brown --- ci/examples.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/examples.sh b/ci/examples.sh index 264785ed..dc35869e 100755 --- a/ci/examples.sh +++ b/ci/examples.sh @@ -92,8 +92,8 @@ build_virtio() { mkdir -p ${BUILD_DIR} make -C examples/virtio -B \ BUILD_DIR=${BUILD_DIR} \ - CONFIG=${CONFIG} \ - BOARD=${BOARD} \ + MICROKIT_CONFIG=${CONFIG} \ + MICROKIT_BOARD=${BOARD} \ MICROKIT_SDK=${SDK_PATH} } From c865e12c935d65b1146efcf5dd74ef29888dc6f0 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 16 Jul 2024 09:33:17 +1000 Subject: [PATCH 10/25] examples/virtio: fix SERIAL_NUM_CLIENTS Signed-off-by: Alex Brown --- examples/virtio/include/serial_config.h | 2 +- examples/virtio/virtio.mk | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/virtio/include/serial_config.h b/examples/virtio/include/serial_config.h index 4e12fb2e..d3e4b5bb 100644 --- a/examples/virtio/include/serial_config.h +++ b/examples/virtio/include/serial_config.h @@ -6,7 +6,7 @@ #include /* Number of clients */ -// #define SERIAL_NUM_CLIENTS 3 +#define SERIAL_NUM_CLIENTS 3 /* Only support transmission and not receive. */ #define SERIAL_TX_ONLY 0 diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 15b4c8eb..ad2062e4 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -9,8 +9,6 @@ UART_DRIVER := $(SDDF)/drivers/serial/$(UART_DRIVER) SERIAL_COMPONENTS := $(SDDF)/serial/components BLK_COMPONENTS := $(SDDF)/blk/components -SERIAL_NUM_CLIENTS := -DSERIAL_NUM_CLIENTS=3 - BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) SYSTEM_DIR := $(VIRTIO_EXAMPLE)/board/$(MICROKIT_BOARD) SYSTEM_FILE := $(SYSTEM_DIR)/virtio.system From 7b62f46ed2ae74735b1df32bfc2d143b7d558d7e Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Tue, 16 Jul 2024 12:38:33 +1000 Subject: [PATCH 11/25] examples/virtio: move make includes after LIBS Some snippets require LIBS to be defined such as sddf's network_components.mk. Without this, we get linking errors as microkit is not linked. Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index ad2062e4..6db59c15 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -22,18 +22,6 @@ BLK_DRIVER_VM_USERLEVEL_INIT := blk_driver_init vpath %.c $(SDDF) $(LIBVMM) $(VIRTIO_EXAMPLE) $(NETWORK_COMPONENTS) -include $(SDDF)/util/util.mk -include $(UART_DRIVER)/uart_driver.mk -include $(SERIAL_COMPONENTS)/serial_components.mk -include $(BLK_COMPONENTS)/blk_components.mk -include $(LIBVMM)/vmm.mk -include $(VMM_TOOLS)/linux/uio/uio.mk -include $(VMM_TOOLS)/linux/blk/blk_init.mk -include $(VMM_TOOLS)/linux/uio_drivers/blk/uio_blk.mk - -IMAGES := client_vmm.elf blk_driver_vmm.elf \ - $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf - CFLAGS := \ -mstrict-align \ -ffreestanding \ @@ -63,6 +51,18 @@ CFLAGS_USERLEVEL := \ LDFLAGS := -L$(BOARD_DIR)/lib LIBS := --start-group -lmicrokit -Tmicrokit.ld libsddf_util_debug.a libvmm.a --end-group +include $(SDDF)/util/util.mk +include $(UART_DRIVER)/uart_driver.mk +include $(SERIAL_COMPONENTS)/serial_components.mk +include $(BLK_COMPONENTS)/blk_components.mk +include $(LIBVMM)/vmm.mk +include $(VMM_TOOLS)/linux/uio/uio.mk +include $(VMM_TOOLS)/linux/blk/blk_init.mk +include $(VMM_TOOLS)/linux/uio_drivers/blk/uio_blk.mk + +IMAGES := client_vmm.elf blk_driver_vmm.elf \ + $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf + CHECK_FLAGS_BOARD_MD5:=.board_cflags-$(shell echo -- $(CFLAGS) $(BOARD) $(MICROKIT_CONFIG) | shasum | sed 's/ *-//') $(CHECK_FLAGS_BOARD_MD5): From 25f387535023374c7fda755368a6d80d68b627c4 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 22 Jul 2024 11:09:58 +1000 Subject: [PATCH 12/25] examples/virtio: make: reduce line size Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 6db59c15..961dccb3 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -79,18 +79,23 @@ all: loader.img $(IMAGES): libsddf_util_debug.a libvmm.a $(IMAGE_FILE) $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) - $(MICROKIT_TOOL) $(SYSTEM_FILE) --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE) + $(MICROKIT_TOOL) $(SYSTEM_FILE) --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) \ + --config $(MICROKIT_CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE) %_vm: mkdir -p $@ -client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) - $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz client_vm/rootfs -o $@ \ +client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ + $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) + $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ + client_vm/rootfs -o $@ \ --startup $(CLIENT_VM_USERLEVEL_INIT) \ --home $(CLIENT_VM_USERLEVEL) -blk_driver_vm/rootfs.cpio.gz: blk_driver_vm $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) - $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz blk_driver_vm/rootfs -o $@ \ +blk_driver_vm/rootfs.cpio.gz: blk_driver_vm $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ + $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) + $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ + blk_driver_vm/rootfs -o $@ \ --startup $(BLK_DRIVER_VM_USERLEVEL_INIT) \ --home $(BLK_DRIVER_VM_USERLEVEL) @@ -106,7 +111,8 @@ blk_storage: %_vm/vmm.o: $(VIRTIO_EXAMPLE)/%_vmm.c $(CHECK_FLAGS_BOARD_MD5) %_vm $(CC) $(CFLAGS) -c -o $@ $< -%_vm/images.o: %_vm $(LIBVMM)/tools/package_guest_images.S $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz +%_vm/images.o: %_vm $(LIBVMM)/tools/package_guest_images.S \ + $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz $(CC) -c -g3 -x assembler-with-cpp \ -DGUEST_KERNEL_IMAGE_PATH=\"$(SYSTEM_DIR)/$ Date: Mon, 22 Jul 2024 11:19:05 +1000 Subject: [PATCH 13/25] examples/virtio: use exist depends for directory Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 961dccb3..1cb37dd1 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -85,15 +85,15 @@ $(IMAGE_FILE) $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) %_vm: mkdir -p $@ -client_vm/rootfs.cpio.gz: client_vm $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ - $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) +client_vm/rootfs.cpio.gz: $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ + $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) |client_vm $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ client_vm/rootfs -o $@ \ --startup $(CLIENT_VM_USERLEVEL_INIT) \ --home $(CLIENT_VM_USERLEVEL) -blk_driver_vm/rootfs.cpio.gz: blk_driver_vm $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ - $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) +blk_driver_vm/rootfs.cpio.gz: $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ + $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) |blk_driver_vm $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ blk_driver_vm/rootfs -o $@ \ --startup $(BLK_DRIVER_VM_USERLEVEL_INIT) \ @@ -105,18 +105,18 @@ blk_storage: %_vm/vm.dts: $(SYSTEM_DIR)/%_vm/dts/linux.dts $(SYSTEM_DIR)/%_vm/dts/overlays/*.dts $(LIBVMM)/tools/dtscat $^ > $@ -%_vm/vm.dtb: %_vm/vm.dts %_vm +%_vm/vm.dtb: %_vm/vm.dts |%_vm $(DTC) -q -I dts -O dtb $< > $@ -%_vm/vmm.o: $(VIRTIO_EXAMPLE)/%_vmm.c $(CHECK_FLAGS_BOARD_MD5) %_vm +%_vm/vmm.o: $(VIRTIO_EXAMPLE)/%_vmm.c $(CHECK_FLAGS_BOARD_MD5) |%_vm $(CC) $(CFLAGS) -c -o $@ $< -%_vm/images.o: %_vm $(LIBVMM)/tools/package_guest_images.S \ +%_vm/images.o: $(LIBVMM)/tools/package_guest_images.S \ $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz $(CC) -c -g3 -x assembler-with-cpp \ - -DGUEST_KERNEL_IMAGE_PATH=\"$(SYSTEM_DIR)/$ Date: Mon, 22 Jul 2024 11:23:30 +1000 Subject: [PATCH 14/25] examples/virtio: remove trailing whitespace Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 1cb37dd1..c9263ca7 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -86,14 +86,14 @@ $(IMAGE_FILE) $(REPORT_FILE): $(IMAGES) $(SYSTEM_FILE) mkdir -p $@ client_vm/rootfs.cpio.gz: $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ - $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) |client_vm + $(CLIENT_VM_USERLEVEL) $(CLIENT_VM_USERLEVEL_INIT) |client_vm $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/client_vm/rootfs.cpio.gz \ client_vm/rootfs -o $@ \ --startup $(CLIENT_VM_USERLEVEL_INIT) \ --home $(CLIENT_VM_USERLEVEL) blk_driver_vm/rootfs.cpio.gz: $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ - $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) |blk_driver_vm + $(BLK_DRIVER_VM_USERLEVEL) $(BLK_DRIVER_VM_USERLEVEL_INIT) |blk_driver_vm $(LIBVMM)/tools/packrootfs $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ blk_driver_vm/rootfs -o $@ \ --startup $(BLK_DRIVER_VM_USERLEVEL_INIT) \ From ff6b955fb8e06aeb2b3bd05003aadf29851f64fd Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 22 Jul 2024 13:33:55 +1000 Subject: [PATCH 15/25] make: rename VMM_TOOLS to LIBVMM_TOOLS Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 10 +++++----- tools/linux/uio/uio.mk | 8 ++++---- tools/linux/uio_drivers/blk/uio_blk.mk | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index c9263ca7..f67a421b 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -1,6 +1,6 @@ QEMU := qemu-system-aarch64 -VMM_TOOLS := $(LIBVMM)/tools +LIBVMM_TOOLS := $(LIBVMM)/tools MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit SDDF_INCLUDE := $(SDDF)/include/sddf UTIL := $(SDDF)/util @@ -56,9 +56,9 @@ include $(UART_DRIVER)/uart_driver.mk include $(SERIAL_COMPONENTS)/serial_components.mk include $(BLK_COMPONENTS)/blk_components.mk include $(LIBVMM)/vmm.mk -include $(VMM_TOOLS)/linux/uio/uio.mk -include $(VMM_TOOLS)/linux/blk/blk_init.mk -include $(VMM_TOOLS)/linux/uio_drivers/blk/uio_blk.mk +include $(LIBVMM_TOOLS)/linux/uio/uio.mk +include $(LIBVMM_TOOLS)/linux/blk/blk_init.mk +include $(LIBVMM_TOOLS)/linux/uio_drivers/blk/uio_blk.mk IMAGES := client_vmm.elf blk_driver_vmm.elf \ $(SERIAL_IMAGES) $(BLK_IMAGES) uart_driver.elf @@ -100,7 +100,7 @@ blk_driver_vm/rootfs.cpio.gz: $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ --home $(BLK_DRIVER_VM_USERLEVEL) blk_storage: - $(VMM_TOOLS)/mkvirtdisk $@ $(BLK_NUM_PART) $(BLK_SIZE) $(BLK_MEM) + $(LIBVMM_TOOLS)/mkvirtdisk $@ $(BLK_NUM_PART) $(BLK_SIZE) $(BLK_MEM) %_vm/vm.dts: $(SYSTEM_DIR)/%_vm/dts/linux.dts $(SYSTEM_DIR)/%_vm/dts/overlays/*.dts $(LIBVMM)/tools/dtscat $^ > $@ diff --git a/tools/linux/uio/uio.mk b/tools/linux/uio/uio.mk index f9de767a..2c2c2e45 100644 --- a/tools/linux/uio/uio.mk +++ b/tools/linux/uio/uio.mk @@ -6,8 +6,8 @@ # This Makefile snippet builds block UIO driver # -ifeq ($(strip $(VMM_TOOLS)),) -$(error VMM_TOOLS must be specified) +ifeq ($(strip $(LIBVMM_TOOLS)),) +$(error LIBVMM_TOOLS must be specified) endif ifeq ($(strip $(SDDF)),) $(error SDDF must be specified) @@ -18,7 +18,7 @@ endif LIBUIO_IMAGES := libuio.a -CFLAGS_libuio := -I$(SDDF)/include -I$(VMM_TOOLS)/linux/include +CFLAGS_libuio := -I$(SDDF)/include -I$(LIBVMM_TOOLS)/linux/include CHECK_LIBUIO_FLAGS_MD5:=.libuio_cflags-$(shell echo -- $(CFLAGS_USERLEVEL) $(CFLAGS_libuio) | shasum | sed 's/ *-//') @@ -31,7 +31,7 @@ libuio.a: libuio.o ar rv $@ $^ libuio.o: $(CHECK_LIBUIO_FLAGS_MD5) -libuio.o: $(VMM_TOOLS)/linux/uio/libuio.c +libuio.o: $(LIBVMM_TOOLS)/linux/uio/libuio.c $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_libuio) -o $@ -c $< clean:: diff --git a/tools/linux/uio_drivers/blk/uio_blk.mk b/tools/linux/uio_drivers/blk/uio_blk.mk index 721bdffc..7e067f12 100644 --- a/tools/linux/uio_drivers/blk/uio_blk.mk +++ b/tools/linux/uio_drivers/blk/uio_blk.mk @@ -6,8 +6,8 @@ # This Makefile snippet builds block UIO driver # -ifeq ($(strip $(VMM_TOOLS)),) -$(error VMM_TOOLS must be specified) +ifeq ($(strip $(LIBVMM_TOOLS)),) +$(error LIBVMM_TOOLS must be specified) endif ifeq ($(strip $(SDDF)),) $(error SDDF must be specified) @@ -18,7 +18,7 @@ endif UIO_BLK_IMAGES := uio_blk_driver -CFLAGS_uio_blk_driver := -I$(SDDF)/include -I$(VMM_TOOLS)/linux/include +CFLAGS_uio_blk_driver := -I$(SDDF)/include -I$(LIBVMM_TOOLS)/linux/include CHECK_UIO_BLK_DRIVER_FLAGS_MD5:=.uio_blk_driver_cflags-$(shell echo -- $(CFLAGS_USERLEVEL) $(CFLAGS_uio_blk_driver) | shasum | sed 's/ *-//') @@ -30,7 +30,7 @@ uio_blk_driver: uio_blk_driver.o libuio.a $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_uio_blk_driver) $^ -o $@ uio_blk_driver.o: $(CHECK_UIO_BLK_DRIVER_FLAGS_MD5) -uio_blk_driver.o: $(VMM_TOOLS)/linux/uio_drivers/blk/blk.c +uio_blk_driver.o: $(LIBVMM_TOOLS)/linux/uio_drivers/blk/blk.c $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_uio_blk_driver) -o $@ -c $< clean:: From ebbd6b2998870a465d0d1506091ea4a8f160323d Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 22 Jul 2024 14:07:14 +1000 Subject: [PATCH 16/25] examples/virtio: use PRECIOUS to keep intermediates Without PRECIOUS, intermediate files (i.e., %_vm/*) are deleted Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index f67a421b..e6248117 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -121,12 +121,11 @@ blk_storage: $(LIBVMM)/tools/package_guest_images.S -o $@ # Stop make from deleting intermediate files -client_vm_files:: client_vm client_vm/vm.dts client_vm/vm.dtb \ - client_vm/rootfs.cpio.gz client_vm/images.o client_vm/vmm.o - -blk_driver_vm_files:: blk_driver_vm blk_driver_vm/vm.dts \ +.PRECIOUS: blk_driver_vm blk_driver_vm/vm.dts \ blk_driver_vm/vm.dtb blk_driver_vm/rootfs.cpio.gz \ - blk_driver_vm/images.o blk_driver_vm/vmm.o + blk_driver_vm/images.o blk_driver_vm/vmm.o \ + client_vm client_vm/vm.dts client_vm/vm.dtb \ + client_vm/rootfs.cpio.gz client_vm/images.o client_vm/vmm.o qemu: $(IMAGE_FILE) blk_storage $(QEMU) -machine virt,virtualization=on,secure=off \ From 85fb3b6a117feec87bf3726bd26e58826c51287b Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 22 Jul 2024 15:22:25 +1000 Subject: [PATCH 17/25] examples/virtio: fix make clean and clobber Before make tried to delete directory `init.d`. Add file filter to find command to ensure we only delete dependency files. Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index e6248117..a6cefa46 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -139,7 +139,7 @@ qemu: $(IMAGE_FILE) blk_storage clean:: $(RM) -f *.elf .depend* $ - find . -name \*.[do] |xargs --no-run-if-empty rm + find . -name \*.[do] -type f |xargs --no-run-if-empty rm clobber:: clean rm -f *.a From c78cbff1095b582802aa33af40cea6786eb28ce5 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 22 Jul 2024 15:30:46 +1000 Subject: [PATCH 18/25] examples/virtio: check board for qemu Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index a6cefa46..0d8e9eaa 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -128,6 +128,7 @@ blk_storage: client_vm/rootfs.cpio.gz client_vm/images.o client_vm/vmm.o qemu: $(IMAGE_FILE) blk_storage + [ ${MICROKIT_BOARD} = qemu_arm_virt ] $(QEMU) -machine virt,virtualization=on,secure=off \ -cpu cortex-a53 \ -serial mon:stdio \ From c18b900373947dbe98dd099a3d71977ea8d79c4f Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 22 Jul 2024 16:06:18 +1000 Subject: [PATCH 19/25] examples/virtio: fix check for CFLAGS changing vm.dts needs to depend on the CFLAGS as if the board is changed the dts files must be updated as well. Signed-off-by: Alex Brown --- examples/virtio/virtio.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/virtio/virtio.mk b/examples/virtio/virtio.mk index 0d8e9eaa..4222fad5 100644 --- a/examples/virtio/virtio.mk +++ b/examples/virtio/virtio.mk @@ -102,7 +102,8 @@ blk_driver_vm/rootfs.cpio.gz: $(SYSTEM_DIR)/blk_driver_vm/rootfs.cpio.gz \ blk_storage: $(LIBVMM_TOOLS)/mkvirtdisk $@ $(BLK_NUM_PART) $(BLK_SIZE) $(BLK_MEM) -%_vm/vm.dts: $(SYSTEM_DIR)/%_vm/dts/linux.dts $(SYSTEM_DIR)/%_vm/dts/overlays/*.dts +%_vm/vm.dts: $(SYSTEM_DIR)/%_vm/dts/linux.dts \ + $(SYSTEM_DIR)/%_vm/dts/overlays/*.dts $(CHECK_FLAGS_BOARD_MD5) |%_vm $(LIBVMM)/tools/dtscat $^ > $@ %_vm/vm.dtb: %_vm/vm.dts |%_vm @@ -111,7 +112,7 @@ blk_storage: %_vm/vmm.o: $(VIRTIO_EXAMPLE)/%_vmm.c $(CHECK_FLAGS_BOARD_MD5) |%_vm $(CC) $(CFLAGS) -c -o $@ $< -%_vm/images.o: $(LIBVMM)/tools/package_guest_images.S \ +%_vm/images.o: $(LIBVMM)/tools/package_guest_images.S $(CHECK_FLAGS_BOARD_MD5) \ $(SYSTEM_DIR)/%_vm/linux %_vm/vm.dtb %_vm/rootfs.cpio.gz $(CC) -c -g3 -x assembler-with-cpp \ -DGUEST_KERNEL_IMAGE_PATH=\"$(SYSTEM_DIR)/$(@D)/linux\" \ From 282cad92d36ff3fe73ecd9c747e7ae1a08ab7717 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 5 Aug 2024 09:33:24 +1000 Subject: [PATCH 20/25] examples/virtio: remove need for LIBVMM:= Signed-off-by: Alex Brown --- tools/linux/blk/blk_init.mk | 6 +++--- tools/linux/uio/uio.mk | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/linux/blk/blk_init.mk b/tools/linux/blk/blk_init.mk index 675bf8bd..5798905a 100644 --- a/tools/linux/blk/blk_init.mk +++ b/tools/linux/blk/blk_init.mk @@ -4,13 +4,13 @@ # SPDX-License-Identifier: BSD-2-Clause # -ifeq ($(strip $(LIBVMM)),) -$(error LIBVMM must be specified) -endif ifeq ($(strip $(MICROKIT_BOARD)),) $(error MICROKIT_BOARD must be specified) endif +LINUX_BLK_DIR := $(abs $(dir $(last ${MAKEFILES_LIST}))) +LIBVMM ?= $(realpath ${LINUX_BLK_DIR}/../../../) + blk_client_init: $(LIBVMM)/tools/linux/blk/blk_client_init cp $^ $@ diff --git a/tools/linux/uio/uio.mk b/tools/linux/uio/uio.mk index 2c2c2e45..abe43324 100644 --- a/tools/linux/uio/uio.mk +++ b/tools/linux/uio/uio.mk @@ -6,9 +6,6 @@ # This Makefile snippet builds block UIO driver # -ifeq ($(strip $(LIBVMM_TOOLS)),) -$(error LIBVMM_TOOLS must be specified) -endif ifeq ($(strip $(SDDF)),) $(error SDDF must be specified) endif @@ -16,9 +13,12 @@ ifeq ($(strip $(CC_USERLEVEL)),) $(error CC_USERLEVEL must be specified) endif +LINUX_UIO_DIR := $(abs $(dir $(last ${MAKEFILES_LIST}))) +LIBVMM ?= $(realpath ${LINUX_UIO_DIR}/../../../) + LIBUIO_IMAGES := libuio.a -CFLAGS_libuio := -I$(SDDF)/include -I$(LIBVMM_TOOLS)/linux/include +CFLAGS_libuio := -I$(SDDF)/include -I$(LIBVMM)/tools/linux/include CHECK_LIBUIO_FLAGS_MD5:=.libuio_cflags-$(shell echo -- $(CFLAGS_USERLEVEL) $(CFLAGS_libuio) | shasum | sed 's/ *-//') @@ -31,7 +31,7 @@ libuio.a: libuio.o ar rv $@ $^ libuio.o: $(CHECK_LIBUIO_FLAGS_MD5) -libuio.o: $(LIBVMM_TOOLS)/linux/uio/libuio.c +libuio.o: $(LIBVMM)/tools/linux/uio/libuio.c $(CC_USERLEVEL) $(CFLAGS_USERLEVEL) $(CFLAGS_libuio) -o $@ -c $< clean:: From d648c3778208ea2e4e3f443439db11041b7cf325 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 5 Aug 2024 09:41:50 +1000 Subject: [PATCH 21/25] examples/virtio: fix make comments Signed-off-by: Alex Brown --- tools/linux/blk/blk_init.mk | 2 ++ tools/linux/uio/uio.mk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/linux/blk/blk_init.mk b/tools/linux/blk/blk_init.mk index 5798905a..0a54f38c 100644 --- a/tools/linux/blk/blk_init.mk +++ b/tools/linux/blk/blk_init.mk @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: BSD-2-Clause # +# Generates blk_client_init and blk_driver_init scripts +# ifeq ($(strip $(MICROKIT_BOARD)),) $(error MICROKIT_BOARD must be specified) diff --git a/tools/linux/uio/uio.mk b/tools/linux/uio/uio.mk index abe43324..c7efdd04 100644 --- a/tools/linux/uio/uio.mk +++ b/tools/linux/uio/uio.mk @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: BSD-2-Clause # -# This Makefile snippet builds block UIO driver +# Generates library libuio.a to be linked against userlevel drivers # ifeq ($(strip $(SDDF)),) From 81069e71bc18c05dcafdb21c416925cecb14a0a1 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 5 Aug 2024 10:14:09 +1000 Subject: [PATCH 22/25] examples/virtio: fix blk config Signed-off-by: Alex Brown --- examples/virtio/include/blk_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/virtio/include/blk_config.h b/examples/virtio/include/blk_config.h index 47b6f294..d44a1c16 100644 --- a/examples/virtio/include/blk_config.h +++ b/examples/virtio/include/blk_config.h @@ -31,6 +31,8 @@ _Static_assert(BLK_DATA_REGION_SIZE_CLI1 >= BLK_TRANSFER_SIZE && BLK_DATA_REGION _Static_assert(BLK_DATA_REGION_SIZE_DRIV >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_DRIV % BLK_TRANSFER_SIZE == 0, "Driver data region size must be a multiple of the transfer size"); +static const int blk_partition_mapping[BLK_NUM_CLIENTS] = { 0, 1 }; + static inline blk_storage_info_t *blk_virt_cli_config_info(blk_storage_info_t *info, unsigned int id) { switch (id) { From b47988db41bec28f2b2f519fef08505a44e3c096 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 5 Aug 2024 10:14:33 +1000 Subject: [PATCH 23/25] Update sDDF commit Signed-off-by: Alex Brown --- dep/sddf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dep/sddf b/dep/sddf index 7ee2c908..33cf47c0 160000 --- a/dep/sddf +++ b/dep/sddf @@ -1 +1 @@ -Subproject commit 7ee2c90834e69403a8c96430614edca3a67f9ab4 +Subproject commit 33cf47c04c3533369322b920a9e9087f28cb6c67 From e34a2cb40d1ab84a38e3e4c4fac8ea4f8a249c54 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 5 Aug 2024 10:20:51 +1000 Subject: [PATCH 24/25] examples/virtio: fix style Signed-off-by: Alex Brown --- examples/virtio/include/blk_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/virtio/include/blk_config.h b/examples/virtio/include/blk_config.h index d44a1c16..1f34b44c 100644 --- a/examples/virtio/include/blk_config.h +++ b/examples/virtio/include/blk_config.h @@ -88,7 +88,7 @@ static inline blk_resp_queue_t *blk_virt_cli_resp_queue(blk_resp_queue_t *resp, return resp; case 1: return (blk_resp_queue_t *)((uintptr_t)resp + BLK_QUEUE_REGION_SIZE_CLI0); - default: + default: return NULL; } } From 6ad64021b860ee1c03450d0ee032965305e6fb31 Mon Sep 17 00:00:00 2001 From: Alex Brown Date: Mon, 5 Aug 2024 10:24:12 +1000 Subject: [PATCH 25/25] examples/virtio: fix style Signed-off-by: Alex Brown --- examples/virtio/include/blk_config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/virtio/include/blk_config.h b/examples/virtio/include/blk_config.h index 1f34b44c..f8c7acd9 100644 --- a/examples/virtio/include/blk_config.h +++ b/examples/virtio/include/blk_config.h @@ -24,11 +24,11 @@ #define BLK_QUEUE_REGION_SIZE_CLI1 BLK_REGION_SIZE #define BLK_QUEUE_REGION_SIZE_DRIV BLK_REGION_SIZE -_Static_assert(BLK_DATA_REGION_SIZE_CLI0 >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_CLI0 % BLK_TRANSFER_SIZE == 0, +_Static_assert(BLK_DATA_REGION_SIZE_CLI0 >= BLK_TRANSFER_SIZE &&BLK_DATA_REGION_SIZE_CLI0 % BLK_TRANSFER_SIZE == 0, "Client0 data region size must be a multiple of the transfer size"); -_Static_assert(BLK_DATA_REGION_SIZE_CLI1 >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_CLI1 % BLK_TRANSFER_SIZE == 0, +_Static_assert(BLK_DATA_REGION_SIZE_CLI1 >= BLK_TRANSFER_SIZE &&BLK_DATA_REGION_SIZE_CLI1 % BLK_TRANSFER_SIZE == 0, "Client1 data region size must be a multiple of the transfer size"); -_Static_assert(BLK_DATA_REGION_SIZE_DRIV >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_DRIV % BLK_TRANSFER_SIZE == 0, +_Static_assert(BLK_DATA_REGION_SIZE_DRIV >= BLK_TRANSFER_SIZE &&BLK_DATA_REGION_SIZE_DRIV % BLK_TRANSFER_SIZE == 0, "Driver data region size must be a multiple of the transfer size"); static const int blk_partition_mapping[BLK_NUM_CLIENTS] = { 0, 1 };