Skip to content

Commit 18d87e6

Browse files
committed
Introduce ENABLE_ON_TEST
The MMU test suite relies on rv32emu's syscall function instead of its syscall table, unlike the Linux kernel. Therefore, use the ON_TEST macro to distinguish between the Linux kernel and MMU test suite as the emulation target.
1 parent 6b5f105 commit 18d87e6

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- name: MMU test
7272
run: |
7373
make -C tests/system/mmu/
74-
make distclean && make ENABLE_USE_ELF=1 ENABLE_SYSTEM=1 mmu-test -j$(nproc)
74+
make distclean && make ENABLE_ON_TEST=1 ENABLE_USE_ELF=1 ENABLE_SYSTEM=1 mmu-test -j$(nproc)
7575
- name: gdbstub test
7676
run: |
7777
make distclean && make ENABLE_GDBSTUB=1 gdbstub-test -j$(nproc)

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ ifeq ($(call has, USE_ELF), 1)
2020
DEFINE_USE_ELF := -DUSE_ELF
2121
endif
2222

23+
# The MMU test suite relies on rv32emu's syscall function instead of
24+
# its syscall table, unlike the Linux kernel. Therefore, use the
25+
# ON_TEST macro to distinguish between the Linux kernel and MMU test
26+
# suite as the emulation target.
27+
ENABLE_ON_TEST ?= 0
28+
ifeq ($(call has, ON_TEST), 1)
29+
DEFINE_ON_TEST := -DON_TEST
30+
endif
31+
2332
ENABLE_SYSTEM ?= 0
2433
$(call set-feature, SYSTEM)
2534

@@ -251,7 +260,7 @@ endif
251260

252261
$(OUT)/%.o: src/%.c $(deps_emcc)
253262
$(VECHO) " CC\t$@\n"
254-
$(Q)$(CC) $(DEFINE_USE_ELF) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
263+
$(Q)$(CC) $(DEFINE_USE_ELF) $(DEFINE_ON_TEST) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
255264

256265
$(BIN): $(OBJS) $(DEV_OBJS)
257266
$(VECHO) " LD\t$@\n"

src/emulate.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,15 @@ void ebreak_handler(riscv_t *rv)
12031203
void ecall_handler(riscv_t *rv)
12041204
{
12051205
assert(rv);
1206-
#if RV32_HAS(SYSTEM)
1206+
1207+
/*
1208+
* FIXME: MMU test suite rely on rv32emu syscall instead of its own syscall
1209+
* table
1210+
*/
1211+
#if defined(ON_TEST)
1212+
rv->PC += 4;
1213+
syscall_handler(rv);
1214+
#elif RV32_HAS(SYSTEM)
12071215
if (rv->priv_mode == RV_PRIV_U_MODE) {
12081216
SET_CAUSE_AND_TVAL_THEN_TRAP(rv, ECALL_U, 0);
12091217
} else if (rv->priv_mode ==

0 commit comments

Comments
 (0)