Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions kernel/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ use crate::{
task::{ProcessData, Thread, add_task_to_table, new_user_task, spawn_alarm_task},
};

#[cfg(target_arch = "riscv64")]
#[inline]
fn init_riscv_fp_state() {
use riscv::register::sstatus::{self, FS};
unsafe { sstatus::set_fs(FS::Dirty) };
}

/// Initialize and run initproc.
pub fn init(args: &[String], envs: &[String]) {
#[cfg(target_arch = "riscv64")]
init_riscv_fp_state();

Comment on lines +19 to +30
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstatus.FS is a per-hart CSR on RISC-V. Initializing it only in entry::init() (which appears to run once during initproc setup) may leave secondary harts with FS=Off, so any FP/SIMD instruction executed on those harts could still trap. Consider moving this to an earlier per-CPU/hart init hook (e.g., in the platform/axruntime CPU bring-up path) or otherwise ensuring it runs on every hart before scheduling begins there.

Copilot uses AI. Check for mistakes.
pseudofs::mount_all().expect("Failed to mount pseudofs");
spawn_alarm_task();

Expand Down
2 changes: 2 additions & 0 deletions make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# - `MEM`: Memory size (default is 128M)
# - `DISK_IMG`: Path to the virtual disk image
# - `ACCEL`: Enable hardware acceleration (KVM on linux)
# - `QEMU_BIOS`: QEMU BIOS firmware path (default is `default`)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QEMU_BIOS help text says it's a “firmware path”, but the default value is the special QEMU selector default (not a filesystem path). Consider rewording to clarify it can be either default or a BIOS/firmware image path so users don’t assume it must be a path.

Suggested change
# - `QEMU_BIOS`: QEMU BIOS firmware path (default is `default`)
# - `QEMU_BIOS`: QEMU BIOS selector (`default`) or firmware image path (default is `default`)

Copilot uses AI. Check for mistakes.
# - `QEMU_LOG`: Enable QEMU logging (log file is "qemu.log")
# - `NET_DUMP`: Enable network packet dump (log file is "netdump.pcap")
# - `NET_DEV`: QEMU netdev backend types: user, tap, bridge
Expand Down Expand Up @@ -69,6 +70,7 @@ MEM ?=
ACCEL ?=
ICOUNT ?= n
QEMU_ARGS ?=
QEMU_BIOS ?= default

DISK_IMG ?= disk.img
QEMU_LOG ?= n
Expand Down
3 changes: 2 additions & 1 deletion make/qemu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

QEMU := qemu-system-$(ARCH)


ifeq ($(BUS), mmio)
vdev-suffix := device
else ifeq ($(BUS), pci)
Expand Down Expand Up @@ -30,7 +31,7 @@ qemu_args-x86_64 := \

qemu_args-riscv64 := \
-machine $(machine) \
-bios default \
-bios $(QEMU_BIOS) \
-kernel $(FINAL_IMG)

qemu_args-aarch64 := \
Expand Down
Loading