From b50084d4dd70f2cc1b7b3c85cafeba0499725068 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 15 Aug 2025 19:45:23 +0000 Subject: [PATCH 01/13] Add option to run Windows QEMU when using WSL2 --- mk/qemu.mk | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index 1bfa5d404..de43e4299 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -124,6 +124,17 @@ ifneq ($(ARCH),$(HOST_ARCH)) kvm?=no endif +# wsl2: run qemu on windows instead +ifeq ($(QEMU_ON_WINDOWS),1) + QEMU:=$(QEMU).exe + WINDOWS_DISK=/mnt/c/ProgramData/redox.qcow2 + disk=windows + net=windows + QEMU_MACHINE=pc + FIRMWARE= + QEMU_KERNEL= +endif + ifneq ($(FIRMWARE),) QEMUFLAGS+=-bios $(FIRMWARE) endif @@ -186,6 +197,8 @@ else # port 8080 and 8083 - webservers # port 64126 - our gdbserver implementation QEMUFLAGS+=-netdev user,id=net0,hostfwd=tcp::8080-:8080,hostfwd=tcp::8083-:8083,hostfwd=tcp::64126-:64126$(EXTRANETARGS) + else ifeq ($(net),windows) + QEMUFLAGS+=-netdev user,id=net0$(EXTRANETARGS) else QEMUFLAGS+=-netdev user,id=net0$(EXTRANETARGS) -object filter-dump,id=f1,netdev=net0,file=$(BUILD)/network.pcap endif @@ -228,6 +241,9 @@ else ifeq ($(disk),cdrom) else ifeq ($(disk),sdcard) QEMUFLAGS+=-drive file=$(DISK),if=sd,format=raw +else ifeq ($(disk),windows) + QEMUFLAGS+= \ + -drive file="$(shell wslpath -w $(WINDOWS_DISK))",if=virtio endif ifeq ($(gdb),yes) @@ -236,7 +252,11 @@ endif ifeq ($(UNAME),Linux) ifneq ($(kvm),no) - QEMUFLAGS+=-enable-kvm -cpu host + ifeq ($(QEMU_ON_WINDOWS),1) + QEMUFLAGS+=-accel whpx,kernel-irqchip=off -cpu Haswell,-tsc + else + QEMUFLAGS+=-enable-kvm -cpu host + endif else QEMUFLAGS+=-cpu $(QEMU_CPU) endif @@ -260,6 +280,8 @@ qemu-deps: $(DISK) ifeq ($(disk),usb) else ifeq ($(disk),sdcard) +else ifeq ($(disk),windows) +qemu-deps: $(WINDOWS_DISK) else qemu-deps: $(EXTRA_DISK) endif @@ -281,6 +303,11 @@ endif $(EXTRA_DISK): truncate -s 1g $@ +$(WINDOWS_DISK): $(BUILD)/harddrive.img + rm -f $@ + mkdir -p $(shell dirname $@) + qemu-img.exe convert -f raw -O qcow2 "\$(shell wslpath -w $<)" "$(shell wslpath -w $@)" + $(BUILD)/raspi3bp_uboot.rom: wget -O $@ https://gitlab.redox-os.org/Ivan/redox_firmware/-/raw/main/platform/raspberry_pi/rpi3/u-boot-rpi-3-b-plus.bin From 6c52a6833df450a4f265df50d64ced438907f91c Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Sun, 17 Aug 2025 06:18:51 +0000 Subject: [PATCH 02/13] Use binstall for rustinstall.sh --- .gitlab-ci.yml | 5 +---- podman/rustinstall.sh | 12 +++++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 261dbfbe9..21c9f449b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,10 +40,7 @@ img: script: - | source "$HOME/.cargo/env" && - curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash && - cargo binstall --no-confirm --version 0.1.1 cargo-config && - cargo binstall --no-confirm --version 1.16.0 just && - cargo binstall --no-confirm --version 0.27.0 cbindgen && + bash podman/rustinstall.sh && cargo build --manifest-path installer/Cargo.toml --release && PODMAN_BUILD=0 REPO_BINARY=1 make ci-img IMG_TAG=$CI_COMMIT_REF_NAME && ([ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" ] && rm -rf build/img/* || true) diff --git a/podman/rustinstall.sh b/podman/rustinstall.sh index 2210dcc20..e229bdcbe 100755 --- a/podman/rustinstall.sh +++ b/podman/rustinstall.sh @@ -5,10 +5,8 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable -SCCACHE_PATH=https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(uname -m)-unknown-linux-musl.tar.gz -curl -sSL $SCCACHE_PATH | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' -export RUSTC_WRAPPER=sccache - -cargo +stable install --force --version 0.1.1 cargo-config -cargo +stable install --force --version 1.16.0 just -cargo +stable install --force --version 0.27.0 cbindgen +curl -sSLf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +cargo +stable binstall --no-confirm --force --version 0.10.0 sccache +cargo +stable binstall --no-confirm --force --version 1.16.0 just +cargo +stable binstall --no-confirm --force --version 0.27.0 cbindgen +cargo +stable install --force --version 0.1.1 cargo-config # TODO: Remove From cb363699052f90e045b60c41ea275ea915907384 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Mon, 18 Aug 2025 10:10:09 +0000 Subject: [PATCH 03/13] Apply apic and mouse fixes --- mk/qemu.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index 7b6930f31..fb7468ad8 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -132,12 +132,13 @@ endif # wsl2: run qemu on windows instead ifeq ($(QEMU_ON_WINDOWS),1) QEMU:=$(QEMU).exe - WINDOWS_DISK=/mnt/c/ProgramData/redox.qcow2 + WINDOWS_DISK=/mnt/c/ProgramData/redox.img disk=windows net=windows QEMU_MACHINE=pc FIRMWARE= QEMU_KERNEL= + QEMUFLAGS+=-device usb-tablet endif ifneq ($(FIRMWARE),) @@ -248,7 +249,7 @@ else ifeq ($(disk),sdcard) QEMUFLAGS+=-drive file=$(DISK),if=sd,format=raw else ifeq ($(disk),windows) QEMUFLAGS+= \ - -drive file="$(shell wslpath -w $(WINDOWS_DISK))",if=virtio + -drive file="$(shell wslpath -w $(WINDOWS_DISK))",format=raw,if=virtio endif ifeq ($(gdb),yes) @@ -258,7 +259,7 @@ endif ifeq ($(UNAME),Linux) ifneq ($(kvm),no) ifeq ($(QEMU_ON_WINDOWS),1) - QEMUFLAGS+=-accel whpx,kernel-irqchip=off -cpu Haswell,-tsc + QEMUFLAGS+=-accel whpx,kernel-irqchip=off -cpu Broadwell,x2apic=off else QEMUFLAGS+=-enable-kvm -cpu host endif @@ -315,7 +316,7 @@ $(EXTRA_DISK): $(WINDOWS_DISK): $(BUILD)/harddrive.img rm -f $@ mkdir -p $(shell dirname $@) - qemu-img.exe convert -f raw -O qcow2 "\$(shell wslpath -w $<)" "$(shell wslpath -w $@)" + cp "$<" "$@" $(BUILD)/raspi3bp_uboot.rom: wget -O $@ https://gitlab.redox-os.org/Ivan/redox_firmware/-/raw/main/platform/raspberry_pi/rpi3/u-boot-rpi-3-b-plus.bin From c09215748d50617b76f8a58665b5e3f15a2c0a27 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Mon, 18 Aug 2025 10:37:28 +0000 Subject: [PATCH 04/13] Formatting --- mk/qemu.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index fb7468ad8..9ab81160d 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -244,12 +244,10 @@ else ifeq ($(disk),cdrom) QEMUFLAGS+= \ -boot d -cdrom $(DISK) \ -drive file=$(EXTRA_DISK),format=raw - else ifeq ($(disk),sdcard) QEMUFLAGS+=-drive file=$(DISK),if=sd,format=raw else ifeq ($(disk),windows) - QEMUFLAGS+= \ - -drive file="$(shell wslpath -w $(WINDOWS_DISK))",format=raw,if=virtio + QEMUFLAGS+=-drive file="$(shell wslpath -w $(WINDOWS_DISK))",format=raw,if=virtio endif ifeq ($(gdb),yes) From 84a85bdc9b983a65ebfafbca1b5a9c492eeeec13 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 22 Aug 2025 10:41:10 +0000 Subject: [PATCH 05/13] Bump podman cbindgen and just --- podman/rustinstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/podman/rustinstall.sh b/podman/rustinstall.sh index e229bdcbe..3cdd68643 100755 --- a/podman/rustinstall.sh +++ b/podman/rustinstall.sh @@ -7,6 +7,6 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable curl -sSLf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash cargo +stable binstall --no-confirm --force --version 0.10.0 sccache -cargo +stable binstall --no-confirm --force --version 1.16.0 just -cargo +stable binstall --no-confirm --force --version 0.27.0 cbindgen +cargo +stable binstall --no-confirm --force --version 1.42.4 just +cargo +stable binstall --no-confirm --force --version 0.29.0 cbindgen cargo +stable install --force --version 0.1.1 cargo-config # TODO: Remove From 86f4f305b1b5e8ad1dfa3752e4d220193a409f2e Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 24 Aug 2025 08:29:19 -0600 Subject: [PATCH 06/13] Update cookbook --- cookbook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook b/cookbook index cc58d96c6..fc48fb9cf 160000 --- a/cookbook +++ b/cookbook @@ -1 +1 @@ -Subproject commit cc58d96c6f3747f7d80c9f393db0df24bc17030d +Subproject commit fc48fb9cf460833a91d0fd76911b39c1ef9d57bf From 5d7fcad842cbf3112cc7d50e2414451e22a066be Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Aug 2025 16:31:54 +0200 Subject: [PATCH 07/13] Rework qemu gpu configuration * Make gpu=no work on arm64 and riscv64 * Register gpu's with the firmware as vga card on x86 where possible * Add a virtio-gl option for virtio-gpu with OpenGL support (no support on the driver side yet) * Support ramfb on x86 --- mk/qemu.mk | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index 1bfa5d404..9713bf37a 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -3,10 +3,13 @@ QEMU=SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-$(QEMU_ARCH) QEMUFLAGS=-d guest_errors -name "Redox OS $(ARCH)" netboot?=no +VGA_SUPPORTED=no ifeq ($(ARCH),i686) audio?=ac97 + gpu?=vga uefi=no + VGA_SUPPORTED=yes QEMU_ARCH=i386 QEMU_MACHINE?=pc QEMU_CPU?=pentium2 @@ -18,6 +21,8 @@ ifeq ($(ARCH),i686) kvm?=yes endif else ifeq ($(ARCH),x86_64) + gpu?=vga + VGA_SUPPORTED=yes QEMU_ARCH=x86_64 QEMU_MACHINE?=q35 QEMU_CPU?=core2duo @@ -43,6 +48,7 @@ else ifeq ($(ARCH),aarch64) # setting up a framebuffer ourself. uefi?=yes live?=yes + gpu?=ramfb QEMU_ARCH=aarch64 QEMU_MACHINE?=virt QEMU_CPU=max @@ -73,9 +79,6 @@ else ifeq ($(ARCH),aarch64) else FIRMWARE=$(BUILD)/qemu_uboot.rom endif - ifneq ($(gpu),no) - QEMUFLAGS+=-device ramfb - endif ifneq ($(usb),no) QEMUFLAGS+=-device qemu-xhci -device usb-kbd -device usb-tablet endif @@ -84,7 +87,7 @@ else ifeq ($(ARCH),riscv64gc) live=no efi=yes audio=no - vga=no # virtio-gpu-pci + gpu?=ramfb net=bridge QEMU_ARCH=riscv64 # QEMU_MACHINE=virt for ACPI mode instead of DTB @@ -106,9 +109,6 @@ else ifeq ($(ARCH),riscv64gc) $(wildcard /usr/share/qemu/edk2-riscv-vars.fd) \ $(wildcard /opt/homebrew/opt/qemu/share/qemu/edk2-riscv-vars.fd) \ ) - ifneq ($(vga),no) - QEMUFLAGS+=-device ramfb - endif ifneq ($(usb),no) QEMUFLAGS+=-device qemu-xhci -device usb-kbd -device usb-tablet endif @@ -193,12 +193,32 @@ endif ifeq ($(gpu),no) QEMUFLAGS+=-nographic -vga none +else ifeq ($(gpu),vga) + ifeq ($(VGA_SUPPORTED),yes) + QEMUFLAGS+=-vga std + else + QEMUFLAGS+=-vga none -device secondary-vga + endif +else ifeq ($(gpu),ramfb) + QEMUFLAGS+=-vga none -device ramfb else ifeq ($(gpu),multi) - QEMUFLAGS+=-display sdl -vga none -device virtio-gpu,max_outputs=2 + ifeq ($(VGA_SUPPORTED),yes) + QEMUFLAGS+=-display sdl -vga none -device virtio-vga,max_outputs=2 + else + QEMUFLAGS+=-display sdl -vga none -device virtio-gpu,max_outputs=2 + endif else ifeq ($(gpu),virtio) - QEMUFLAGS+=-vga virtio -else ifeq ($(vga),virtio-gpu-pci) - QEMUFLAGS+= -vga virtio-gpu-pci + ifeq ($(VGA_SUPPORTED),yes) + QEMUFLAGS+=-vga none -device virtio-vga + else + QEMUFLAGS+=-vga none -device virtio-gpu + endif +else ifeq ($(gpu),virtio-gl) + ifeq ($(VGA_SUPPORTED),yes) + QEMUFLAGS+=-display gtk,gl=on -vga none -device virtio-vga-gl + else + QEMUFLAGS+=-display gtk,gl=on -vga none -device virtio-gpu-gl + endif endif EXTRA_DISK=$(BUILD)/extra.img From f3a8336ad259b4f76eccfd6facc97d280c0ea488 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 24 Aug 2025 08:40:48 -0600 Subject: [PATCH 08/13] Update relibc --- relibc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relibc b/relibc index f170902a2..92bc01247 160000 --- a/relibc +++ b/relibc @@ -1 +1 @@ -Subproject commit f170902a29f0b7c10cc2bce087c8b6f0d9478d9d +Subproject commit 92bc01247ad9c9ebae6e47740a1bb9e2f556635b From 57fe06d1edc8de502fa5f18a7a2025d193f8a159 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 24 Aug 2025 09:06:07 -0600 Subject: [PATCH 09/13] Disable gears in demo config --- config/x86_64/demo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/x86_64/demo.toml b/config/x86_64/demo.toml index 02985d613..f951724c4 100644 --- a/config/x86_64/demo.toml +++ b/config/x86_64/demo.toml @@ -39,7 +39,7 @@ acid = {} orbclient = {} pixelcannon = {} rodioplay = {} -gears = {} +# gears = {} # sccache issue # MIDI freepats = {} From 716cca1b4e9dd4ba77bcfe77a5cfe520c5f6b016 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Aug 2025 18:40:01 +0200 Subject: [PATCH 10/13] Enable UEFI by default on x86_64 It boots faster and more reliable than SeaBIOS. And in practice you are unlikely to use BIOS on real hardware if you have an x86_64 capable CPU anyway. --- mk/qemu.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index 202aca169..62db45e8e 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -22,6 +22,7 @@ ifeq ($(ARCH),i686) endif else ifeq ($(ARCH),x86_64) gpu?=vga + uefi?=yes VGA_SUPPORTED=yes QEMU_ARCH=x86_64 QEMU_MACHINE?=q35 @@ -90,7 +91,6 @@ else ifeq ($(ARCH),aarch64) endif else ifeq ($(ARCH),riscv64gc) live=no - efi=yes audio=no gpu?=ramfb net=bridge From 16e98e3f28bb6995eddc976515b46f077e5ac4ab Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Aug 2025 18:56:39 +0200 Subject: [PATCH 11/13] Add a make qemu mode to allow attaching gdb without waiting for it This way you can unconditionally enable this mode during development without being forced to attach a debugger every time you start a VM. --- mk/qemu.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mk/qemu.mk b/mk/qemu.mk index 62db45e8e..b9740e619 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -272,6 +272,9 @@ endif ifeq ($(gdb),yes) QEMUFLAGS+=-d cpu_reset -s -S +else ifeq ($(gdb),nonblock) + # Allow attaching gdb, but don't block for it + QEMUFLAGS+=-d cpu_reset -s endif ifeq ($(UNAME),Linux) From 4f2efe1c56e85202d9371a91294c8fbbe94e4e9f Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Aug 2025 19:05:28 +0200 Subject: [PATCH 12/13] Simplify gdb-userspace Turns out gdb already handles locating the .text section when you don't specify the offset. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43dd5c14a..cda1b2109 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ gdb: FORCE # has started or you need to debug the interaction between the application and the kernel. # tl;dr: DO NOT USE THIS TARGET UNLESS YOU HAVE TO gdb-userspace: FORCE - rust-gdb $(GDB_APP_FILE) --eval-command="add-symbol-file $(GDB_KERNEL_FILE) 0x$(shell readelf -S $(GDB_KERNEL_FILE) | grep .text | cut -c43-58)" --eval-command="target remote :1234" + rust-gdb $(GDB_APP_FILE) --eval-command="add-symbol-file $(GDB_KERNEL_FILE)" --eval-command="target remote :1234" # An empty target FORCE: From db63dae1877a02349dd1cf359704c81351efb220 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 24 Aug 2025 18:30:24 -0600 Subject: [PATCH 13/13] Update relibc --- relibc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relibc b/relibc index 92bc01247..fd9a1c966 160000 --- a/relibc +++ b/relibc @@ -1 +1 @@ -Subproject commit 92bc01247ad9c9ebae6e47740a1bb9e2f556635b +Subproject commit fd9a1c9668c10d122eab9839d0f0f7f4d88703ab