Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalBlk committed Jul 12, 2022
2 parents a00319b + b580904 commit 1743771
Show file tree
Hide file tree
Showing 43 changed files with 287 additions and 431 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- run: ./verify-pycodestyle.sh

build_mips_gcc:
name: Build MIPS (GCC + KASAN)
name: Build MIPS (GCC)
runs-on: self-hosted
needs: [verify_c_style, verify_py_style]
steps:
Expand All @@ -46,10 +46,10 @@ jobs:
needs: [verify_c_style, verify_py_style]
steps:
- uses: actions/checkout@v2
- run: make BOARD=malta CLANG=1
- run: make BOARD=malta LLVM=1 KASAN=1 LOCKDEP=1

build_aarch64_gcc:
name: Build AArch64 (GCC + KASAN)
name: Build AArch64 (GCC)
runs-on: self-hosted
needs: [verify_c_style, verify_py_style]
steps:
Expand All @@ -73,10 +73,10 @@ jobs:
needs: [verify_c_style, verify_py_style]
steps:
- uses: actions/checkout@v2
- run: make BOARD=rpi3 CLANG=1
- run: make BOARD=rpi3 LLVM=1 KASAN=1 LOCKDEP=1

build_rv32_gcc:
name: Build RISC-V 32-bit (GCC + KASAN)
name: Build RISC-V 32-bit (GCC)
runs-on: self-hosted
needs: [verify_c_style, verify_py_style]
steps:
Expand All @@ -98,10 +98,18 @@ jobs:
needs: [verify_c_style, verify_py_style]
steps:
- uses: actions/checkout@v2
- run: make BOARD=litex-riscv CLANG=1
- run: make BOARD=litex-riscv LLVM=1 KASAN=1 LOCKDEP=1

build_rv64_clang:
name: Build RISC-V 64-bit (Clang)
runs-on: self-hosted
needs: [verify_c_style, verify_py_style]
steps:
- uses: actions/checkout@v2
- run: make BOARD=sifive_u LLVM=1 KASAN=1 LOCKDEP=1

kernel_tests_mips_gcc:
name: Tests MIPS (GCC + KASAN)
name: Tests MIPS (GCC)
runs-on: self-hosted
needs: build_mips_gcc
steps:
Expand All @@ -112,7 +120,7 @@ jobs:
- run: ./run_tests.py --board malta --timeout=80 --times=50

kernel_tests_aarch64_gcc:
name: Tests AArch64 (GCC + KASAN)
name: Tests AArch64 (GCC)
runs-on: self-hosted
needs: build_aarch64_gcc
steps:
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ WORKDIR /root
RUN apt-get -q update && apt-get upgrade -y
RUN apt-get install -y --no-install-recommends -t bullseye-backports \
git make cpio curl universal-ctags cscope socat patch gperf quilt \
bmake byacc python3-pip clang clang-format device-tree-compiler tmux \
libmpfr6 libfdt1 libpython3.9 libsdl2-2.0-0 libglib2.0-0 libpixman-1-0
bmake byacc python3-pip clang clang-format llvm lld \
device-tree-compiler tmux libmpfr6 libfdt1 libpython3.9 \
libsdl2-2.0-0 libglib2.0-0 libpixman-1-0
# patch & quilt required by lua and programs in contrib/
# gperf required by libterminfo
# socat & tmux required by launch
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test: sys-build initrd.cpio

PHONY-TARGETS += setup test

IMGVER = 1.9.0
IMGVER = 1.9.1
IMGNAME = cahirwpz/mimiker-ci

docker-build:
Expand Down
3 changes: 1 addition & 2 deletions bin/date/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ TOPDIR = $(realpath ../..)

PROGRAM = date
FORMAT-EXCLUDE = $(SOURCES)
LDLIBS = -lutil

include $(TOPDIR)/build/build.prog.mk

LDLIBS = -lutil
29 changes: 14 additions & 15 deletions build/arch.aarch64.mk
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
# vim: tabstop=8 shiftwidth=8 noexpandtab:
# vim: tabstop=2 shiftwidth=2 noexpandtab:
#
# Common makefile which specifies aarch64 architecture specific settings.
#
# Required common variables: KERNEL, BOARD.
#

TARGET := aarch64-mimiker-elf
GCC_ABIFLAGS := -mno-outline-atomics
CLANG_ABIFLAGS := -target aarch64-elf
ELFTYPE := elf64-littleaarch64
ELFARCH := aarch64

ifeq ($(LLVM), 1)
TARGET := aarch64-linux-mimiker-elf
ABIFLAGS :=
else
TARGET := aarch64-mimiker-elf
ABIFLAGS := -mno-outline-atomics
endif

# NOTE(pj): We set A, SA, SA0 bits for SCTLR_EL1 register (sys/aarch64/boot.c)
# as a result not aligned access to memory causes an exception. It's okay but
# user-space (taken from NetBSD) doesn't care about that by default. It
# requies STRICT_ALIGNMENT to be defined. It's also important for the kernel
# because we share bcopy (memcpy) implementation with user-space.
CPPFLAGS += -DSTRICT_ALIGNMENT=1

ASAN_SHADOW_OFFSET := 0xe0001f0000000000

ifeq ($(KERNEL), 1)
CFLAGS += -mcpu=cortex-a53+nofp -march=armv8-a+nofp -mgeneral-regs-only
ifeq ($(KASAN), 1)
# Added to files that are sanitized
CFLAGS_KASAN = -fsanitize=kernel-address \
-fasan-shadow-offset=0xe0001f0000000000 \
--param asan-globals=1 \
--param asan-stack=1 \
--param asan-instrument-allocas=1
endif
CFLAGS += -mcpu=cortex-a53+nofp -march=armv8-a+nofp -mgeneral-regs-only
else
CFLAGS += -mcpu=cortex-a53 -march=armv8-a
CFLAGS += -mcpu=cortex-a53 -march=armv8-a
endif

ifeq ($(BOARD), rpi3)
KERNEL-IMAGES := mimiker.img mimiker.img.gz
KERNEL-IMAGES := mimiker.img mimiker.img.gz
endif
35 changes: 15 additions & 20 deletions build/arch.mips.mk
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
# vim: tabstop=8 shiftwidth=8 noexpandtab:
# vim: tabstop=2 shiftwidth=2 noexpandtab:
#
# Common makefile which specifies MIPS architecture specific settings.
#
# Required common variables: KERNEL, BOARD.

TARGET := mipsel-mimiker-elf
ELFARCH := mips

# -G 0 disables small-data and small-bss,
# as otherwise they would exceed 64KB limit
GCC_ABIFLAGS := -mips32r2 -EL -G 0
CLANG_ABIFLAGS := -target mipsel-elf -march=mips32r2 -mno-abicalls \
-modd-spreg -G 0 -D__ELF__=1
ELFTYPE := elf32-littlemips
ELFARCH := mips
ifeq ($(LLVM), 1)
TARGET := mipsel-linux-mimiker-elf
ABIFLAGS := -march=mips32r2 -mno-abicalls -modd-spreg -G 0 -D__ELF__=1
ELFTYPE := elf32-tradlittlemips
else
TARGET := mipsel-mimiker-elf
ABIFLAGS := -mips32r2 -EL -G 0
ELFTYPE := elf32-littlemips
endif

ASAN_SHADOW_OFFSET := 0xD8000000

ifeq ($(KERNEL), 1)
ifeq ($(KASAN), 1)
# Added to files that are sanitized
CFLAGS_KASAN = -fsanitize=kernel-address -fasan-shadow-offset=0xD8000000 \
--param asan-globals=1 \
--param asan-stack=1 \
--param asan-instrument-allocas=1
endif
# Added to all files
GCC_ABIFLAGS += -msoft-float
CLANG_ABIFLAGS += -msoft-float
ifeq ($(KGPROF), 1)
CFLAGS_KGPROF = -finstrument-functions
endif
ABIFLAGS += -msoft-float
endif
72 changes: 34 additions & 38 deletions build/arch.riscv.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vim: tabstop=8 shiftwidth=8 noexpandtab:
# vim: tabstop=2 shiftwidth=2 noexpandtab:
#
# Common makefile which specifies RISC-V architecture specific settings.
#
Expand All @@ -8,53 +8,49 @@
# Required common variables: KERNEL, BOARD.
#

TARGET := riscv$(XLEN)-mimiker-elf
ELFTYPE := elf$(XLEN)-littleriscv
ELFARCH := riscv

ifeq ($(BOARD), litex-riscv)
ifeq ($(CLANG), 1)
EXT := ima
else
EXT := ima_zicsr_zifencei
endif
ABI := ilp32
KERNEL_PHYS := 0x40000000
KERNEL-IMAGES := mimiker.img
ifeq ($(KERNEL), 1)
CPPFLAGS += -DFPU=0
ifeq ($(KASAN), 1)
CFLAGS_KASAN += -fasan-shadow-offset=0x90000000
endif
endif
ifeq ($(LLVM), 1)
EXT := ima
else
EXT := ima_zicsr_zifencei
endif
ABI := ilp32
KERNEL_PHYS := 0x40000000
KERNEL_VIRT := 0x80000000
KERNEL-IMAGES := mimiker.img
ifeq ($(KERNEL), 1)
CPPFLAGS += -DFPU=0
ASAN_SHADOW_OFFSET := 0x90000000
endif
endif

ifeq ($(BOARD), sifive_u)
EXT := g
ABI := lp64d
KERNEL_PHYS := 0x80200000
ifeq ($(KERNEL), 1)
CPPFLAGS += -DFPU=1
ifeq ($(KASAN), 1)
CFLAGS_KASAN += -fasan-shadow-offset=0xdfffffe000000000
endif
endif
ifeq ($(CLANG), 1)
CPPFLAGS += -D__riscv_d -D__riscv_f
EXT := g
ABI := lp64d
KERNEL_PHYS := 0x80200000
KERNEL_VIRT := 0xffffffc000000000
ifeq ($(KERNEL), 1)
CPPFLAGS += -DFPU=1
ASAN_SHADOW_OFFSET := 0xdfffffe000000000
endif
ifeq ($(LLVM), 1)
CPPFLAGS += -D__riscv_d -D__riscv_f
endif
endif

ifeq ($(LLVM), 1)
TARGET := riscv$(XLEN)-linux-mimiker-elf
else
TARGET := riscv$(XLEN)-mimiker-elf
endif

GCC_ABIFLAGS += -march=rv$(XLEN)$(EXT) -mabi=$(ABI)
CLANG_ABIFLAGS += -target riscv$(XLEN)-elf -march=rv$(XLEN)$(EXT) -mabi=$(ABI)
ABIFLAGS += -march=rv$(XLEN)$(EXT) -mabi=$(ABI)

ifeq ($(KERNEL), 1)
CFLAGS += -mcmodel=medany
CPPFLAGS += -DKERNEL_PHYS=$(KERNEL_PHYS)
CPPLDSCRIPT := 1
ifeq ($(KASAN), 1)
CFLAGS_KASAN += -fsanitize=kernel-address \
--param asan-globals=1 \
--param asan-stack=1 \
--param asan-instrument-allocas=1
endif
CFLAGS += -mcmodel=medany
CPPFLAGS += -DKERNEL_PHYS=$(KERNEL_PHYS) -DKERNEL_VIRT=$(KERNEL_VIRT)
CPPLDSCRIPT := 1
endif
10 changes: 1 addition & 9 deletions build/build.kern.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,4 @@ $(KLIB): $(OBJECTS) $(KLIBDEPS)
@echo "[DTB] $(DIR)$< -> $(DIR)$@"
dtc -O dtb -o $@ $<

%_dtb.o: %.dtb
@echo "[OBJCOPY] $(DIR)$< -> $(DIR)$@"
$(OBJCOPY) -I binary -O $(ELFTYPE) -B $(ELFARCH) \
--redefine-sym _binary_$(@:%.o=%)_start=__$(@:%.o=%)_start \
--redefine-sym _binary_$(@:%.o=%)_end=__$(@:%.o=%)_end \
--redefine-sym _binary_$(@:%.o=%)_size=__$(@:%.o=%)_size \
$< $@

CLEAN-FILES += *_dtb.o *.dtb
CLEAN-FILES += *.dtb
2 changes: 1 addition & 1 deletion build/compile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $(DEPENDENCY-FILES): $(SOURCES_GEN)

.%.D: %.S
@echo "[DEP] $(DIR)$@"
$(AS) $(ASFLAGS) $(CPPFLAGS) -MT $*.o -MM -MG $^ -MF $@
$(CC) $(ASFLAGS) $(CPPFLAGS) -MT $*.o -MM -MG $^ -MF $@

ifeq ($(words $(findstring $(MAKECMDGOALS), download clean distclean)), 0)
-include $(DEPENDENCY-FILES)
Expand Down
25 changes: 24 additions & 1 deletion build/flags.kern.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vim: tabstop=8 shiftwidth=8 noexpandtab:
# vim: tabstop=2 shiftwidth=2 noexpandtab:
#
# Common makefile used to supplement the compilation flags with the kernel
# specific flags.
Expand All @@ -17,4 +17,27 @@ ifeq ($(KCSAN), 1)
--param tsan-distinguish-volatile=1
endif

ifeq ($(KASAN), 1)
# Added to files that are sanitized
ifeq ($(LLVM), 1)
CFLAGS_KASAN = -fsanitize=kernel-address \
-mllvm -asan-mapping-offset=$(ASAN_SHADOW_OFFSET) \
-mllvm -asan-instrumentation-with-call-threshold=0 \
-mllvm -asan-globals=true \
-mllvm -asan-stack=true \
-mllvm -asan-instrument-dynamic-allocas=true
else
CFLAGS_KASAN = -fsanitize=kernel-address \
-fasan-shadow-offset=$(ASAN_SHADOW_OFFSET) \
--param asan-instrumentation-with-call-threshold=0 \
--param asan-globals=1 \
--param asan-stack=1 \
--param asan-instrument-allocas=1
endif
endif

ifeq ($(KGPROF), 1)
CFLAGS_KGPROF = -finstrument-functions
endif

KERNEL := 1
5 changes: 2 additions & 3 deletions build/flags.user.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ include $(TOPDIR)/build/flags.mk

CPPFLAGS += -nostdinc --sysroot=$(SYSROOT) -I$(TOPDIR)/include
CFLAGS += -ffreestanding -fno-builtin
LDFLAGS += -nostartfiles -nodefaultlibs --sysroot=$(SYSROOT) \
-L= -T lib/ld.script
LDLIBS +=
LDFLAGS += --sysroot=$(SYSROOT) -L=/lib
LDLIBS += -T $(SYSROOT)/lib/ld.script
Loading

0 comments on commit 1743771

Please sign in to comment.