From 3e1accbc78f9ca5fac0f2a3ff5f87906dc27c5c4 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 7 Nov 2026 21:23:22 -0800 Subject: [PATCH] :fire: Load an added kext on every Darwin version unless bounded A kext given with --add-kext and no bounds loaded on Darwin 25.0.0 to 25.99.99 alone, macOS 26, the range Lilu had. Lilu is gone, replaced by Graft, which reims-vgpu's own kext set carries, and Graft decides from the running system what it can bind, so reims-vgpu's kexts need no kernel range: reims-ctl gives each by its path alone, to load on every macOS from 11 to 26. - KEXT_MIN_KERNEL and KEXT_MAX_KERNEL go. A bound left out or empty is now OpenCore's empty MinKernel or MaxKernel, which bounds nothing. - PATH,MIN,MAX keeps working for a kext that wants a range; a MIN past MAX is still refused, and a MIN alone no longer needs to be at most 25.99.99. - README.md, --add-kext's help and the doc comments say so. --- README.md | 13 +++++++------ src/cli.rs | 2 +- src/opencore/added.rs | 30 ++++++++++++++++-------------- src/opencore/config.rs | 8 ++------ 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index a52f5b0..a516b71 100644 --- a/README.md +++ b/README.md @@ -108,15 +108,16 @@ order you give them, so give a kext after the ones it links against. ```sh reims-util opencore -o OpenCore.qcow2 \ - --add-kext ~/kexts/Loader.kext,25.4.0,25.99.99 --add-kext ~/kexts/Plugin.kext,25.4.0 + --add-kext ~/kexts/Loader.kext --add-kext ~/kexts/Plugin.kext,25.4.0 ``` Each value is `PATH[,MIN[,MAX]]`: the bundle, then the Darwin versions it loads on, as OpenCore's -MinKernel and MaxKernel take them (25.4.0 is macOS 26.4). Left out, they're 25.0.0 and 25.99.99, -macOS 26. The bundle is copied whole into `EFI/OC/Kexts`, without its dotfiles, and OpenCore loads -the executable its Info.plist names, or none for a kext with no code. reims-util refuses a kext -with the name or bundle identifier of one given before it (the image's FAT32 partition doesn't -tell names apart by case), and one that links against a kext given after it. +MinKernel and MaxKernel take them (25.4.0 is macOS 26.4). A version left out is no bound, so +Loader.kext above loads on every macOS, and Plugin.kext on macOS 26.4 and later. The bundle is +copied whole into `EFI/OC/Kexts`, without its dotfiles, and OpenCore loads the executable its +Info.plist names, or none for a kext with no code. reims-util refuses a kext with the name or +bundle identifier of one given before it (the image's FAT32 partition doesn't tell names apart by +case), and one that links against a kext given after it. ### Online installers diff --git a/src/cli.rs b/src/cli.rs index 00aad30..1b50002 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -108,7 +108,7 @@ pub struct OpencoreArgs { /// Show OpenCore's boot picker at every boot (by default OpenCore boots the default entry) #[arg(long)] pub show_picker: bool, - /// Add a kext bundle, loaded on Darwin MIN to MAX (default 25.0.0 to 25.99.99, macOS 26). + /// Add a kext bundle, loaded on Darwin MIN to MAX, with no bound where one is left out. /// Repeat it for more: they load in the order given #[arg(long = "add-kext", value_name = "PATH[,MIN[,MAX]]", value_parser = added::parse)] pub add_kext: Vec, diff --git a/src/opencore/added.rs b/src/opencore/added.rs index 6a969a6..2fe3ad7 100644 --- a/src/opencore/added.rs +++ b/src/opencore/added.rs @@ -3,11 +3,11 @@ //! whole into `EFI/OC/Kexts` (dotfiles left out), and loaded by a Kernel > Add entry made from its //! Info.plist and the Darwin versions it was given (config.rs). -use super::config; use anyhow::{Context, Result, bail}; use std::path::{Path, PathBuf}; -/// A `--add-kext` value, `PATH[,MIN[,MAX]]`: a bundle, and the Darwin versions it loads on. +/// A `--add-kext` value, `PATH[,MIN[,MAX]]`: a bundle, and the Darwin versions it loads on, each +/// bound empty for none. #[derive(Clone, Debug, PartialEq)] pub struct Spec { pub path: PathBuf, @@ -16,8 +16,8 @@ pub struct Spec { } /// Reads `PATH[,MIN[,MAX]]`. The path ends in `.kext`, so a comma in a folder's name stays in -/// the path; MIN and MAX are versions as OpenCore takes them (25.4.0), each 25.0.0 and 25.99.99 -/// (macOS 26) when left out or empty. +/// the path; MIN and MAX are versions as OpenCore takes them (25.4.0), and one left out or empty +/// is no bound, as OpenCore takes an empty MinKernel or MaxKernel. pub fn parse(s: &str) -> Result { let usage = "give PATH[,MIN[,MAX]], such as Foo.kext,25.4.0,25.99.99"; let mut path = s; @@ -32,18 +32,20 @@ pub fn parse(s: &str) -> Result { if !is_bundle(path) { return Err(format!("{s:?} is not a .kext bundle: {usage}")); } - let bound = |i: usize, default: &str| -> Result { + let bound = |i: usize| -> Result { match bounds.get(i).map(|b| b.trim()).filter(|b| !b.is_empty()) { - None => Ok(default.to_string()), + None => Ok(String::new()), Some(b) if version(b).is_some() => Ok(b.to_string()), Some(b) => Err(format!( "{b:?} is not a Darwin version such as 25.4.0: {usage}" )), } }; - let min_kernel = bound(0, config::KEXT_MIN_KERNEL)?; - let max_kernel = bound(1, config::KEXT_MAX_KERNEL)?; - if version(&min_kernel) > version(&max_kernel) { + let min_kernel = bound(0)?; + let max_kernel = bound(1)?; + if let (Some(lo), Some(hi)) = (version(&min_kernel), version(&max_kernel)) + && lo > hi + { return Err(format!( "{s:?} loads on no Darwin version: {min_kernel} is past {max_kernel}" )); @@ -225,7 +227,7 @@ pub(crate) mod tests { #[test] fn parsed() { - let (lo, hi) = (config::KEXT_MIN_KERNEL, config::KEXT_MAX_KERNEL); + let (lo, hi) = ("", ""); for (s, want) in [ ("Foo.kext", spec("Foo.kext", lo, hi)), ("/k/Foo.kext/", spec("/k/Foo.kext/", lo, hi)), @@ -242,6 +244,7 @@ pub(crate) mod tests { spec("/a,b/Foo.kext", "25.4.0", "25.99.99"), ), ("Foo.kext,9.0.0", spec("Foo.kext", "9.0.0", hi)), + ("Foo.kext,26.0.0", spec("Foo.kext", "26.0.0", hi)), ] { assert_eq!(parse(s), Ok(want), "{s}"); } @@ -257,7 +260,6 @@ pub(crate) mod tests { ("Foo.kext,25.x.0", "not a Darwin version"), ("Foo.kext,+25.4.0", "not a Darwin version"), ("Foo.kext,25.6.0,25.4.0", "past 25.4.0"), - ("Foo.kext,26.0.0", "past 25.99.99"), ] { let e = parse(s).unwrap_err(); assert!(e.contains(says), "{s}: {e}"); @@ -322,8 +324,8 @@ pub(crate) mod tests { identifier: id.into(), executable: None, libraries: libraries.iter().map(|l| l.to_string()).collect(), - min_kernel: config::KEXT_MIN_KERNEL.into(), - max_kernel: config::KEXT_MAX_KERNEL.into(), + min_kernel: String::new(), + max_kernel: String::new(), files: Vec::new(), } } @@ -349,7 +351,7 @@ pub(crate) mod tests { assert_eq!(k.libraries, ["com.apple.kpi.libkern"]); assert_eq!( (k.min_kernel.as_str(), k.max_kernel.as_str()), - ("25.4.0", config::KEXT_MAX_KERNEL) + ("25.4.0", "") ); let paths: Vec<&str> = k.files.iter().map(|(p, _)| p.as_str()).collect(); assert_eq!( diff --git a/src/opencore/config.rs b/src/opencore/config.rs index b213115..8cc0af0 100644 --- a/src/opencore/config.rs +++ b/src/opencore/config.rs @@ -12,7 +12,7 @@ //! - the boot chime, which AudioDxe plays on the first Intel HDA controller and codec it finds, //! when the VM has one, unless macOS's "Play sound on startup" is off (`StartupMute`); //! - the kexts given with `--add-kext` (added.rs), in their order and on the Darwin versions -//! given; no others, as QEMU's `isa-applesmc` is the SMC; +//! given, or on every one; no others, as QEMU's `isa-applesmc` is the SMC; //! - one ACPI table, the `EC` and `USBX` devices macOS looks for (acpi.rs); //! - CPUID leaf 1 reported as a Skylake-SP (family 6, model 85, stepping 4), a CPU every x86-64 //! macOS from 10.13 to 26 knows, whatever `-cpu` model the VM has; @@ -45,10 +45,6 @@ pub fn drivers(o: &Options) -> Vec<&'static str> { d } -/// A kext added with no bounds of its own loads on Darwin 25 alone, macOS 26. -pub const KEXT_MIN_KERNEL: &str = "25.0.0"; -pub const KEXT_MAX_KERNEL: &str = "25.99.99"; - /// Arguments for every boot: kernel symbols in panic logs, and no panics on a TLB shootdown or a /// timeout a vCPU took because the host descheduled it. pub const DEFAULT_BOOT_ARGS: &str = "keepsyms=1 tlbto_us=0 vti=9"; @@ -281,7 +277,7 @@ pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result } /// Kernel > Add's entries, made from the sample's first: `added`, in its order, on the Darwin -/// versions each was given. +/// versions each was given (an empty bound is none). fn kernel_add(template: &Dictionary, added: &[added::Kext]) -> Vec { added .iter()