diff --git a/.cargo/config.toml b/.cargo/config.toml index c67d7be2e..33765b046 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,7 +5,7 @@ runner = "cargo run --package jinux-build --" [alias] kcheck = "check --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem" kbuild = "build --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem" -krun = "run --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem" +krun = "run --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem --" ksctest = "run --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem -- --syscall-test" ktest = "test --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem" component-check = "component check --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem" diff --git a/Makefile b/Makefile index 25b6d5de7..bc3da864a 100644 --- a/Makefile +++ b/Makefile @@ -15,15 +15,24 @@ build: tools: @cd services/libs/comp-sys && cargo install --path cargo-component +# FIXME: Exit code manipulation is not needed using non-x86 QEMU run: build - @cargo krun || exit $$(($$? >> 1)) # FIXME: Exit code manipulation is not needed using non-x86 QEMU +ifneq ($(ENABLE_KVM), false) + cargo krun --enable-kvm || exit $$(($$? >> 1)) +else + cargo krun || exit $$(($$? >> 1)) +endif syscall_bin: @make --no-print-directory -C regression/syscall_test # Test Jinux in a QEMU guest VM and run a series of evaluations. syscall_test: syscall_bin build - @cargo ksctest || exit $$(($$? >> 1)) # FIXME: Exit code manipulation is not needed using non-x86 QEMU +ifneq ($(ENABLE_KVM), false) + @cargo ksctest --enable-kvm || exit $$(($$? >> 1)) +else + @cargo ksctest || exit $$(($$? >> 1)) +endif # The usermode cargo test of Jinux frame and Jinux standard library. test: build diff --git a/build/src/main.rs b/build/src/main.rs index 6308a0734..a65126732 100644 --- a/build/src/main.rs +++ b/build/src/main.rs @@ -23,6 +23,10 @@ struct Args { #[arg(short, long, default_value_t = false)] syscall_test: bool, + /// Enable KVM when running QEMU. + #[arg(short, long, default_value_t = false)] + enable_kvm: bool, + /// Emulate Intel IOMMU by QEMU. #[arg(short, long, default_value_t = false)] iommu: bool, @@ -36,7 +40,6 @@ const COMMON_ARGS: &[&str] = &[ "Icelake-Server,+x2apic", "-m", "2G", - "-enable-kvm", "-nographic", // TODO: figure out why grub can't shown up without it "-monitor", "vc", @@ -80,6 +83,9 @@ fn main() { let mut qemu_cmd = Command::new("qemu-system-x86_64"); let mut qemu_args = COMMON_ARGS.clone().to_vec(); + if args.enable_kvm { + qemu_args.push("-enable-kvm"); + } if args.iommu { qemu_args.extend(IOMMU_DEVICE_ARGS.clone().to_vec().iter()); } else {