Skip to content

Commit 0352142

Browse files
committed
i386: valid opcodes for 386, 486 and Pentium
I discovered accidentally while trying to run the kernel in an old machine equipied with an Intel Pentium MMX that the kernel currently does not boot on anything lower than i686. This is a regression because trying to run Build 134 on the same machine boots fine. Once I read the docs of QEMU, I set the machine type to 486 and I could reproduce the bug in QEMU. It does not have a profile for 386, so 486 will be the lowest architecture that I can debug in the time being. After bisecting different commits of the code and using the gdb integration for QEMU, I found that commit 59afb6c (vtcon: virtual multiple consoles, 2022-01-19) causes an 0x06 Invalid Opcode Exception when the following code is executed in anything lower than a Pentium II: fg = i < 3 ? 0x1 : 0x7; (Line 62 of kernel/device/vtcon/vtcon.c for that specific commit). Switching clang to a lower profile using the -march flag fixes this. I've set the march to i386, despite QEMU is only able to emulate 486 and my retro test hardware is a Pentium MMX (P5-i586).
1 parent 4f4df49 commit 0352142

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ dist/nativeos-${PROFILE}.iso: compile/${PROFILE}/kernel dist/ramdisk.tar
6464

6565

6666
qemu: check-profile dist/nativeos-${PROFILE}.iso
67-
$(QEMU) -cdrom dist/nativeos-${PROFILE}.iso -serial stdio
67+
$(QEMU) -m 16 -cpu 486 -cdrom dist/nativeos-${PROFILE}.iso -serial stdio
6868

6969
qemu-gdb: check-profile dist/nativeos-${PROFILE}.iso
70-
$(QEMU) -cdrom dist/nativeos-${PROFILE}.iso -serial stdio -s -S
70+
$(QEMU) -m 16 -cpu 486 -cdrom dist/nativeos-${PROFILE}.iso -serial stdio -s -S
7171

7272
clean:
7373
rm -rf compile

conf/I386

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ arch i386
88
define VERSION_NAME="\"NativeOS Preview\""
99

1010
# Turn on useful tools for debug
11-
makeoption CFLAGS+="-g -O0"
11+
makeoption CFLAGS+="-g -O0 -march=i386"
1212
option debug
1313

1414
define KERNEL_STACK_SIZE=0x4000

0 commit comments

Comments
 (0)