diff --git a/crates/stela-loader/src/host_firmware/bundle/tests.rs b/crates/stela-loader/src/host_firmware/bundle/tests.rs index 356e586342..56757b595c 100644 --- a/crates/stela-loader/src/host_firmware/bundle/tests.rs +++ b/crates/stela-loader/src/host_firmware/bundle/tests.rs @@ -21,8 +21,8 @@ fn the_complete_bundle_holds_every_recipe_once_by_content() { assert_eq!(count, objects.len()); // The RTL8168H and RTL8168M share a file, as the RTL9151A and RTL9151AS do. assert_eq!(count + 2, recipes().count()); - // The recipes' recorded lengths: 86 files, 115.8 MiB. - assert_eq!((count, bytes), (86, 121_467_160), "{count} {bytes}"); + // The recipes' recorded lengths: 87 files, 115.8 MiB. + assert_eq!((count, bytes), (87, 121_468_440), "{count} {bytes}"); // The GPU's large images come last, for a volume short of room. assert_eq!(objects.last().unwrap().length, 63_571_696); let manifest = manifest(&complete()).unwrap(); diff --git a/crates/stela-loader/src/host_firmware/recipes.rs b/crates/stela-loader/src/host_firmware/recipes.rs index c9449d1a86..92ee7a4168 100644 --- a/crates/stela-loader/src/host_firmware/recipes.rs +++ b/crates/stela-loader/src/host_firmware/recipes.rs @@ -733,7 +733,9 @@ const fn gsp(member: &'static str, length: usize, sha256: &'static str) -> Recip } } -/// Every GSP-RM file linux-firmware holds for [`GSP_RELEASE`]. +/// Every GSP-RM file linux-firmware holds for [`GSP_RELEASE`], and the +/// unversioned ACR bootloader Turing's FWSEC path loads beside them +/// ([`ACR_BOOTLOADER`]). pub const GSP: &[Recipe] = &[ gsp( "nvidia/ad102/gsp/booter_load-570.144.bin", @@ -820,6 +822,11 @@ pub const GSP: &[Recipe] = &[ 166600, "f3ce25f3897c860e4cdde183ebf09b254d94a5d8191d666c12afb33cc7121107", ), + gsp( + "nvidia/tu102/acr/bl.bin", + 1280, + "01326cc997716bebb0eab9fe1f463fffa0ee586079e4ca0e5bb096ab6fcfedab", + ), gsp( "nvidia/tu102/gsp/booter_load-570.144.bin", 59272, @@ -872,14 +879,41 @@ fn gsp_directory(chip: &str) -> Option<&'static str> { }) } +/// The ACR bootloader nouveau loads beside the GSP-RM files, unversioned and +/// outside the `gsp` directory, as `nvkm_firmware_get(subdev, "acr/bl", 0)` +/// names it. +const ACR_BOOTLOADER: &str = "acr/bl.bin"; + +/// The chip whose `acr` directory linux-firmware's `WHENCE` links `chip`'s to. +/// +/// Only Turing has one. A chip's VBIOS says which FWSEC image it carries, and +/// nouveau boots a v2 one (`nvkm_gsp_fwsec_v2`) with this separate bootloader, +/// where a v3 one (`nvkm_gsp_fwsec_v3`, Ampere and later) signs its own and +/// loads no second file. A Turing GPU whose stick lacks this file fails +/// `fwsec-sb` with `-ENOENT` and never boots its GSP. Both Turing `gsp` +/// directories hold the same bootloader byte for byte, so one file serves +/// every Turing chip, as `tu116`'s shared GSP-RM files do. +fn acr_directory(chip: &str) -> Option<&'static str> { + matches!(gsp_directory(chip)?, "tu102" | "tu116").then_some("tu102") +} + /// nouveau's request for a chip's GSP-RM file, through `WHENCE`'s links: the /// firmware itself runs on families of chips, and only the signed booters -/// differ between them. +/// differ between them. The ACR bootloader follows the same links. fn select_gsp(request: &Request) -> Option<&'static Recipe> { if request.target.hardware != "nvidia" || request.target.revision != "linux-firmware" { return None; } - let (chip, file) = request.name.strip_prefix("nvidia/")?.split_once("/gsp/")?; + let named = request.name.strip_prefix("nvidia/")?; + if let Some(chip) = named + .strip_suffix(ACR_BOOTLOADER) + .and_then(|prefix| prefix.strip_suffix('/')) + { + let directory = acr_directory(chip)?; + let member = format!("nvidia/{directory}/{ACR_BOOTLOADER}"); + return GSP.iter().find(|recipe| recipe.image.member == member); + } + let (chip, file) = named.split_once("/gsp/")?; let directory = gsp_directory(chip)?; let (kind, release) = file.strip_suffix(".bin")?.split_once('-')?; if release != GSP_RELEASE { @@ -925,7 +959,8 @@ pub fn nvidia_chip(device: u16) -> Option<&'static str> { } /// Requires the GSP-RM files nouveau asks for on `chip`, named as it names -/// chips: `tu104`, `ga104`, `ad104`. +/// chips: `tu104`, `ga104`, `ad104`. A Turing chip also takes the ACR +/// bootloader its FWSEC v2 image boots with ([`acr_directory`]). pub fn require_gsp(inventory: &mut Inventory, chip: &str) -> Result<(), Error> { let target = Target { driver: "nouveau", @@ -946,6 +981,17 @@ pub fn require_gsp(inventory: &mut Inventory, chip: &str) -> Result<(), Error> { found = true; } } + // Not a GSP-RM release file, so it neither follows `GSP_KINDS` nor proves + // on its own that nouveau runs GSP-RM on the chip. + let acr = format!("nvidia/{chip}/{ACR_BOOTLOADER}"); + let request = Requirement { + name: &acr, + target, + minimum_bytes: 1, + }; + if select_gsp(&Request::from(request)).is_some() { + inventory.observe(request)?; + } if found { Ok(()) } else { @@ -1597,9 +1643,26 @@ mod tests { }; for name in names("tu104") { assert!(gsp_member(&name).is_some(), "{name}"); - assert!(name.starts_with("nvidia/tu104/gsp/"), "{name}"); + assert!( + name.starts_with("nvidia/tu104/gsp/") || name == "nvidia/tu104/acr/bl.bin", + "{name}" + ); } assert!(names("tu104").iter().any(|name| name.contains("/gsp-"))); + // Turing's FWSEC v2 image boots with the ACR bootloader, and a stick + // without it stops `fwsec-sb` at `-ENOENT`. + assert!( + names("tu104") + .iter() + .any(|name| name == "nvidia/tu104/acr/bl.bin") + ); + assert!( + names("ga104") + .iter() + .all(|name| !name.contains("/acr/")), + "{:?}", + names("ga104") + ); assert!( names("ad104") .iter() @@ -1637,6 +1700,12 @@ mod tests { "nvidia/gb207/gsp/fmc-570.144.bin", "nvidia/gb202/gsp/fmc-570.144.bin", ), + // The ACR bootloader follows the same links, unversioned, and + // every Turing chip shares `tu102`'s copy of it. + ("nvidia/tu102/acr/bl.bin", "nvidia/tu102/acr/bl.bin"), + ("nvidia/tu106/acr/bl.bin", "nvidia/tu102/acr/bl.bin"), + ("nvidia/tu116/acr/bl.bin", "nvidia/tu102/acr/bl.bin"), + ("nvidia/tu117/acr/bl.bin", "nvidia/tu102/acr/bl.bin"), ] { assert_eq!(gsp_member(name), Some(member), "{name}"); } @@ -1645,6 +1714,12 @@ mod tests { "nvidia/gk104/gsp/gsp-570.144.bin", "nvidia/ga102/gsp/fmc-570.144.bin", "nvidia/ga102/acr/bl-570.144.bin", + // Ampere and later carry a v3 FWSEC image, which boots without a + // separate bootloader; linux-firmware holds no `acr` file for them. + "nvidia/ga102/acr/bl.bin", + "nvidia/ad102/acr/bl.bin", + "nvidia/gb202/acr/bl.bin", + "nvidia/gk104/acr/bl.bin", ] { assert_eq!(gsp_member(name), None, "{name}"); } @@ -1664,6 +1739,12 @@ mod tests { assert!(gsp_member(&name).is_some(), "{name}"); } } + // Every Turing chip also boots its FWSEC v2 image with the ACR + // bootloader, which is not a GSP-RM release file. + for chip in ["tu102", "tu104", "tu106", "tu116", "tu117"] { + let name = format!("nvidia/{chip}/acr/bl.bin"); + assert!(gsp_member(&name).is_some(), "{name}"); + } for chip in [ "gh100", "gb100", "gb102", "gb202", "gb203", "gb205", "gb206", "gb207", ] {