feat(agx): name every 26A434 GPU and place the sgx banks and MMU by family

This commit is contained in:
Tyler Smith committed 2026-10-20 16:11:20 +00:00
1 parent a9b5c91f9a
commit ca20b2ae37
6 files changed
+661 -131

No files matched your search

+7 -2
View File
@@ -299,7 +299,12 @@ fn hide_unprovided_buttons(tree: &mut DeviceTree, hidden: &mut Vec<String>) {
/// which the running firmware never walks.
fn publish_gpu_ttbat(tree: &mut DeviceTree, notes: &mut Vec<String>) {
let mut gpus = Vec::new();
visible_paths(&tree.root, "", &|node| named(node, soc::SGX), &mut gpus);
visible_paths(
&tree.root,
"",
&|node| compatibles(node).any(soc::admitted_gpu),
&mut gpus,
);
for path in gpus {
let node = tree.node_mut(&path).expect("visited path");
if node.property(GPTBAT_READY).is_some() {
@@ -618,7 +623,7 @@ mod tests {
#[test]
fn a_visible_gpu_gets_the_handed_off_ttbat_published() {
let gpu = |base: u64| {
let mut sgx = node("sgx", Some(soc::SGX.as_bytes()), vec![]);
let mut sgx = node("sgx", Some(b"gpu,t8112".as_slice()), vec![]);
sgx.set_property(GPU_REGION_BASE, base.to_le_bytes().to_vec())
.unwrap();
DeviceTree {
+12 -10
View File
@@ -12,7 +12,7 @@ use crate::platform::apple::{
aes::{self, Aes},
agx::{
firmware::Coprocessor as GfxCoprocessor,
sgx::{self, Sgx},
sgx::Sgx,
uat::{self, Agent},
},
aic::{Aic2, Aic2Config},
@@ -1011,17 +1011,18 @@ impl AppleDevices {
self.bus
.map(asc, placement.wrapper.0, placement.wrapper.1, 0)
.map_err(|e| format!("GFX ASC placement: {e:?}"))?;
// The 64 MiB `sgx` window spans the `gfx-asc` wrapper and a PMGR
// fabric bridge; each physical byte has one owner, so the block owns
// T8112's 64 MiB `sgx` window spans the `gfx-asc` wrapper and a PMGR
// fabric bridge; each physical byte has one owner, so each bank owns
// only what the smaller banks placed before it leave.
let block = self.bus.add(Box::new(
Sgx::handed_off(sgx::T8112, placement.ttbat, placement.shared_l2)
Sgx::handed_off(placement.gpu, placement.ttbat, placement.shared_l2)
.map_err(String::from)?,
));
let (base, bytes) = placement.sgx;
self.bus
.map_gaps(block, base, bytes, 0)
.map_err(|e| format!("sgx placement: {e:?}"))?;
for &(base, bytes, offset) in &placement.sgx {
self.bus
.map_gaps(block, base, bytes, offset)
.map_err(|e| format!("sgx placement: {e:?}"))?;
}
self.gfx_masters.push((asc, block));
Ok(())
}
@@ -2703,15 +2704,16 @@ mod tests {
#[test]
fn gfx_firmware_reads_its_initdata_through_the_uat_the_sgx_mmu_roots() {
use crate::machine::soc::GfxController;
use crate::platform::apple::agx::{firmware, uat as table};
use crate::platform::apple::agx::{firmware, generation, uat as table};
use crate::platform::dma::tests::Ram;
const WRAPPER: u64 = 0x2_0640_0000;
const SGX: u64 = 0x2_0400_0000;
const RAM: u64 = 0x8_0000_0000;
let placement = GfxController {
gpu: generation::by_compatible("gpu,t8112").unwrap(),
wrapper: (WRAPPER, 0x6c000),
interrupts: [0x2c6, 0x2c5, 0x2c8, 0x2c7],
sgx: (SGX, sgx::BYTES),
sgx: vec![(SGX, 0x400_0000, 0)],
ttbat: RAM,
shared_l2: RAM + 0x8000,
};
+85 -18
View File
@@ -1181,7 +1181,7 @@ pub fn models<'a>(name: &str, property: impl Fn(&str) -> Option<&'a [u8]>) -> bo
DISPEXT,
]
.contains(&name)
|| GPU_ADMITTED && [SGX, GFX_MAPPER].contains(&name)
|| GPU_ADMITTED && (name == GFX_MAPPER || admitted_gpu(name))
|| AICS.contains(&name)
|| ATC_PHY_LAYOUTS.iter().any(|&(layout, _)| layout == name)
|| SOCS
@@ -2239,20 +2239,33 @@ fn pmp_controller(
}))
}
/// The `sgx` GPU's compatible and its firmware mapper's.
pub const SGX: &str = "gpu,t8112";
/// The GPU's firmware mapper's compatible.
pub const GFX_MAPPER: &str = "iommu-mapper,gfx";
/// Whether `compatible` names an `sgx` GPU whose whole interface is modeled
/// (`agx::generation`, every SoC 26A434 supports; only admitted ones stay
/// visible).
pub fn admitted_gpu(compatible: &str) -> bool {
agx::generation::by_compatible(compatible).is_some_and(|gpu| gpu.admitted().is_ok())
}
/// The AGX GPU's DT placement: the `gfx-asc` wrapper (`reg[0]`) and its four
/// mailbox interrupts, and the `sgx` register block (`reg[0]`; `reg[1]` lies
/// inside it). The firmware reaches memory through the UAT the `sgx` MMU
/// configuration roots, which `gfx-asc`'s `iommu-parent` (`mapper-gfx-asc`,
/// `AGXArmFirmwareMapper`) names; no DART stream is involved.
/// mailbox interrupts, and the `sgx` register banks. The firmware reaches
/// memory through the UAT the `sgx` MMU configuration roots, which
/// `gfx-asc`'s `iommu-parent` (`mapper-gfx-asc`, `AGXArmFirmwareMapper`)
/// names; no DART stream is involved.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GfxController {
/// The census entry the `sgx` node's `compatible` names.
pub gpu: &'static agx::generation::Gpu,
pub wrapper: (u64, u64),
pub interrupts: [u16; 4],
pub sgx: (u64, u64),
/// The `sgx` banks as `(physical base, bytes, register offset)`. Register
/// offsets are relative to `reg[0]`'s base, as `readGFXReg32` takes them:
/// `reg[0]` is the first bank, and `reg[1]` another unless it lies inside
/// `reg[0]` (T8112). On the Pro/Max SoCs `reg[0]` is 1 MiB and the
/// registers lie in `reg[1]` (docs/research/agx.md §6).
pub sgx: Vec<(u64, u64, u64)>,
/// The GPU's TTBAT as the boot stage publishes it (`gptbat-ready`,
/// `ttbat-phys-addr-base` in 16 KiB pages; the loader sets it to
/// `gpu-region-base`): the MMU is handed off rooted there
@@ -2263,6 +2276,22 @@ pub struct GfxController {
pub shared_l2: u64,
}
/// The `sgx` banks of [`GfxController::sgx`] from `reg[0]` and `reg[1]`
/// (physical base, bytes).
fn sgx_banks(block: (u64, u64), info: (u64, u64)) -> Result<Vec<(u64, u64, u64)>, &'static str> {
if info.0 < block.0 {
return Err("sgx reg[1] lies below reg[0]");
}
let mut banks = vec![(block.0, block.1, 0)];
if info.0 + info.1 > block.0 + block.1 {
if info.0 < block.0 + block.1 {
return Err("sgx reg[1] straddles the end of reg[0]");
}
banks.push((info.0, info.1, info.0 - block.0));
}
Ok(banks)
}
fn gfx_controller(
io: &Node<'_>,
translate: &dyn Fn(u64) -> Option<u64>,
@@ -2270,12 +2299,19 @@ fn gfx_controller(
let asc = io
.child("gfx-asc")
.filter(|n| n.compatible(ASC) && n.property("role") == Some(b"GFX\0".as_slice()));
let sgx = io.child("sgx").filter(|n| n.compatible(SGX));
let (asc, sgx) = match (asc, sgx) {
let sgx = io.child("sgx").and_then(|n| {
agx::generation::GPUS
.iter()
.find(|gpu| n.compatible(gpu.compatible))
.map(|gpu| (n, gpu))
});
let (asc, (sgx, gpu)) = match (asc, sgx) {
(None, None) => return Ok(None),
(Some(asc), Some(sgx)) => (asc, sgx),
_ => return Err("the GFX coprocessor and the sgx GPU must be visible together".into()),
};
gpu.admitted()
.map_err(|reason| format!("{} is not modeled: {reason}", gpu.compatible))?;
let nub = asc
.child("iop-gfx-nub")
.filter(|nub| nub.compatible(RTBUDDY))
@@ -2291,11 +2327,10 @@ fn gfx_controller(
Ok::<_, String>((physical, bytes))
};
let wrapper = place(&asc, 0, asc::WRAPPER_BYTES, "gfx-asc wrapper")?;
let block = place(&sgx, 0, agx::sgx::BYTES, "sgx register")?;
let block = place(&sgx, 0, 1, "sgx register")?;
let info = place(&sgx, 1, 1, "sgx info")?;
if info.0 < block.0 || info.0 + info.1 > block.0 + block.1 {
return Err("sgx reg[1] lies outside reg[0]".into());
}
let banks = sgx_banks(block, info)?;
agx::sgx::covers(gpu.family, &banks)?;
let irqs = asc
.cells32("interrupts")
.ok_or("gfx-asc has no interrupts")?;
@@ -2326,9 +2361,10 @@ fn gfx_controller(
_ => return Err("sgx gfx-shared-l2-region is not one nonzero 16 KiB page".into()),
};
Ok(Some(GfxController {
gpu,
wrapper,
interrupts: [irq(0)?, irq(1)?, irq(2)?, irq(3)?],
sgx: (block.0, agx::sgx::BYTES),
sgx: banks,
ttbat,
shared_l2,
}))
@@ -5056,7 +5092,11 @@ mod tests {
model_children(ASC, gfx_role).len(),
usize::from(GPU_ADMITTED)
);
assert_eq!(models(SGX, |_| None), GPU_ADMITTED);
assert_eq!(models("gpu,t8112", |_| None), GPU_ADMITTED);
// A GPU whose family the firmware model does not implement stays
// hidden.
assert!(!models("gpu,t8103", |_| None));
assert!(!models("gpu,t6041", |_| None));
assert_eq!(models(GFX_MAPPER, |_| None), GPU_ADMITTED);
assert!(!models(ASC, |key| (key == "role").then_some(b"GFX2\0".as_slice())));
assert!(models(SEP, |key| (key == "role").then_some(b"SEP\0".as_slice())));
@@ -5097,7 +5137,7 @@ mod tests {
if asc_visible {
asc.push(("compatible", &asc_compatible));
}
let (sgx_name, sgx_compatible) = (z("sgx"), z(SGX));
let (sgx_name, sgx_compatible) = (z("sgx"), z("gpu,t8112"));
let sgx_reg = pairs(&[(0x400_0000, 0x400_0000), (0x4d0_0000, 0x2_0000)]);
let ttbat_page = cells(&[0x20_0011]);
let l2_base = 0x8_0008_8000u64.to_le_bytes();
@@ -5129,9 +5169,10 @@ mod tests {
assert_eq!(
placed(true, true).unwrap(),
Some(GfxController {
gpu: agx::generation::by_compatible("gpu,t8112").unwrap(),
wrapper: (0x2_0640_0000, 0x6c000),
interrupts: [0x2c6, 0x2c5, 0x2c8, 0x2c7],
sgx: (0x2_0400_0000, 0x400_0000),
sgx: vec![(0x2_0400_0000, 0x400_0000, 0)],
ttbat: 0x8_0004_4000,
shared_l2: 0x8_0008_8000,
})
@@ -5141,6 +5182,32 @@ mod tests {
assert!(placed(false, true).is_err());
}
/// The census `sgx` layouts: T8112's `reg[1]` inside `reg[0]`, the
/// T6000's 1 MiB `reg[0]` with the registers in `reg[1]`, and the
/// T6020's longer `reg[1]` that holds the G14X core masks.
#[test]
fn sgx_banks_place_the_registers_at_their_offsets_from_reg0() {
use agx::generation::{G13X, G14G, G14X};
let t8112 = sgx_banks((0x2_0400_0000, 0x400_0000), (0x2_04d0_0000, 0x2_0000)).unwrap();
assert_eq!(t8112, [(0x2_0400_0000, 0x400_0000, 0)]);
assert_eq!(agx::sgx::covers(&G14G, &t8112), Ok(()));
let t6000 = sgx_banks((0x2_0400_0000, 0x10_0000), (0x2_04d0_0000, 0x2_0000)).unwrap();
assert_eq!(
t6000,
[
(0x2_0400_0000, 0x10_0000, 0),
(0x2_04d0_0000, 0x2_0000, 0xd0_0000)
]
);
assert_eq!(agx::sgx::covers(&G13X, &t6000), Ok(()));
// The G14X core masks at 0xe01500 need T6020's 0x16c000-byte bank.
assert!(agx::sgx::covers(&G14X, &t6000).is_err());
let t6020 = sgx_banks((0x2_0400_0000, 0x10_0000), (0x2_04d0_0000, 0x16_c000)).unwrap();
assert_eq!(agx::sgx::covers(&G14X, &t6020), Ok(()));
assert!(sgx_banks((0x2_0400_0000, 0x10_0000), (0x2_0000_0000, 0x10)).is_err());
assert!(sgx_banks((0x2_0400_0000, 0x10_0000), (0x2_040f_0000, 0x2_0000)).is_err());
}
/// The J473AP SMC subtree: its wrapper and watchdog banks, the nub's
/// shared-page region and the `pKW4` functions other nodes route
/// through `smc-pmu`.
@@ -1,10 +1,13 @@
//! The Apple AGX G14G GPU (`sgx`, `gfx-asc`) of the T8112, modeled as a native
//! coprocessor at its AP-facing firmware protocol plus a GPU execution engine.
//! Apple's `armfw_g14g` is not executed. The chosen route, the full 26A434
//! interface inventory and the Known/Inferred/Unknown status are in
//! docs/research/agx.md.
//! The Apple AGX GPUs (`sgx`, `gfx-asc`), modeled as a native coprocessor at
//! their AP-facing firmware protocol plus a GPU execution engine. Apple's GFX
//! firmware is not executed. The chosen route, the full 26A434 interface
//! inventory and the Known/Inferred/Unknown status are in
//! docs/research/agx.md; [`generation`] names every SoC's GPU and which
//! families the model implements (G14G today).
//!
//! Layers, each its own submodule:
//! - [`generation`]: the census of every 26A434 GPU (compatible, kext,
//! firmware, identity, MMU layout, initdata magic) and admission.
//! - [`firmware`]: the GFX RTKit application endpoints (0x20 message, 0x21
//! doorbell) and the firmware-protocol state (initdata pointer, work and
//! firmware-control doorbells).
@@ -45,6 +48,7 @@ pub mod event;
pub mod exec;
pub mod firmware;
pub mod format;
pub mod generation;
pub mod initdata;
pub mod isa;
pub mod observe;
@@ -0,0 +1,406 @@
//! The Apple GPUs 26A434 supports: each SoC's `sgx` compatible, the AGX kext
//! its kernelcache links, the GFX firmware its BuildManifest names, and the
//! facts each kext fixes about the AP-visible interface (docs/research/agx.md
//! §6, the census of all 59 board DeviceTrees and all 13 AGX kexts).
//!
//! Known (every 26A434 kernelcache, `AGXAccelerator*::readChipInfo`,
//! `AGXSecureMonitor*::setupMMUConfig`/`invalidateGPUTTBACache` and
//! `AGXArmFirmware::initFirmwareData` of each kext; offsets per kext in §6):
//! - every kext reads the identification words at 0xd04000.. and requires
//! one generation in bits 31:24 of 0xd04000 ([`Family::generations`]);
//! - G13's MMU block puts the TTBAT page at 0xd08024 and the TTBA-cache
//! invalidation at 0xd08028 behind eight fixed words; G14 onwards use
//! 0xd0802c and 0xd08030 behind ten ([`Mmu`]). The page field is 26 bits on
//! the G13G and G14G kexts and 28 bits on every other;
//! - the initdata root's first word differs between interface revisions; the
//! G13G, G13X and G14G kexts write the same one ([`Family::initdata_magic`]).
//!
//! A family is admitted ([`Gpu::admitted`]) only when every layout the GFX
//! firmware model and the `sgx` model use has been checked against that
//! family's own kext and firmware. Today that is G14G alone; every other
//! family is named here with the facts recovered so far and stays hidden
//! by the loader, its refusal naming what is missing.
use super::sgx::Identity;
/// The MMU block's layout (`setupMMUConfig`, `invalidateGPUTTBACache`).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Mmu {
/// The TTBAT physical page number register.
pub ttbat: u64,
/// Width of its page-number field (`ubfx x2, x0, #14, #bits`).
pub ttbat_page_bits: u32,
/// The TTBA-cache invalidation register (`a << 8 | b`).
pub invalidate: u64,
/// The fixed configuration words `setupMMUConfig` writes, with the only
/// value each accepts.
pub configuration: &'static [(u64, u32)],
}
/// The MMU enable, read first by every `setupMMUConfig` (nonzero skips it).
pub const MMU_ENABLE: u64 = 0xd0_8000;
/// G13's fixed words (`AGXSecureMonitorG13::setupMMUConfig`).
const G13_MMU_CONFIGURATION: [(u64, u32); 8] = [
(0xd0_800c, 0x80d8),
(0xd0_8010, 0x80d8),
(0xd0_8004, 0),
(0xd0_8008, 0),
(0xd0_8014, 0),
(0xd0_8018, 0),
(0xd0_801c, 0),
(0xd0_8020, 0),
];
/// G14 and later (`AGXSecureMonitorG14::setupMMUConfig` and its successors).
const G14_MMU_CONFIGURATION: [(u64, u32); 10] = [
(0xd0_8014, 0x80d8),
(0xd0_8018, 0x80d8),
(0xd0_800c, 0),
(0xd0_8010, 0),
(0xd0_801c, 0),
(0xd0_8020, 0),
(0xd0_8024, 0),
(0xd0_8028, 0),
(0xd0_8008, 1),
(0xd0_8004, 0x3ff),
];
const fn g13_mmu(ttbat_page_bits: u32) -> Mmu {
Mmu {
ttbat: 0xd0_8024,
ttbat_page_bits,
invalidate: 0xd0_8028,
configuration: &G13_MMU_CONFIGURATION,
}
}
const fn g14_mmu(ttbat_page_bits: u32) -> Mmu {
Mmu {
ttbat: 0xd0_802c,
ttbat_page_bits,
invalidate: 0xd0_8030,
configuration: &G14_MMU_CONFIGURATION,
}
}
/// The core-mask words of G13 and G14G (`AGXAcceleratorG13/G14::
/// readChipInfo`: 0xd01500 and the word 0x14 above it) and of G14X onwards
/// (0xe01500 and the two words after it; Public, Asahi `regs.rs`
/// `CORE_MASKS_G14X`).
const G13_G14G_CORE_MASKS: [u64; 2] = [0xd0_1500, 0xd0_1514];
const G14X_CORE_MASKS: [u64; 3] = [0xe0_1500, 0xe0_1504, 0xe0_1508];
/// The initdata root magic of the G13G, G13X and G14G kexts.
pub const MAGIC_G13_G14G: u64 = 0x0c8a_6342_8392_04c8;
/// Whether the model implements a family's interface.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Interface {
/// Every layout the models use is checked against this family.
Modeled,
/// Not admitted, for the stated reason.
Unrecovered(&'static str),
}
/// One AGX kext of the 26A434 kernelcaches and the interface it fixes.
#[derive(Debug, PartialEq, Eq)]
pub struct Family {
/// The kext's family name (`AGX<name>`).
pub name: &'static str,
/// The kext's bundle identifier.
pub kext: &'static str,
/// The kernelcache that links it (`kernelcache.release.<kernelcache>`).
pub kernelcache: &'static str,
/// The generations `readChipInfo` accepts in 0xd04000 bits 31:24.
pub generations: &'static [u8],
/// The core-mask words, cluster 0's cores first (`readChipInfo`).
pub core_masks: &'static [u64],
pub mmu: Mmu,
/// The initdata root's first word, when it is a constant the kext
/// writes (`AGXArmFirmware::initFirmwareData`); `None` when the kext
/// builds it otherwise and the census has not recovered it.
pub initdata_magic: Option<u64>,
pub interface: Interface,
}
/// One SoC's GPU.
#[derive(Debug, PartialEq, Eq)]
pub struct Gpu {
/// The `sgx` node's `compatible`.
pub compatible: &'static str,
/// The SoC's ApChipID.
pub chip_id: u16,
pub family: &'static Family,
/// The GFX firmware the BuildManifest names (`Firmware/agx/<name>.im4p`).
pub firmware: &'static str,
/// The identification the `sgx` registers report, when a source states
/// it.
pub identity: Option<Identity>,
}
const NOT_CHECKED: &str = "its GFX firmware layouts have not been checked against the model's";
pub const G13G: Family = Family {
name: "G13G",
kext: "com.apple.AGXG13G",
kernelcache: "mac13g",
generations: &[4],
core_masks: &G13_G14G_CORE_MASKS,
mmu: g13_mmu(26),
initdata_magic: Some(MAGIC_G13_G14G),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G13X: Family = Family {
name: "G13X",
kext: "com.apple.AGXG13X",
kernelcache: "mac13j",
generations: &[4],
core_masks: &G13_G14G_CORE_MASKS,
mmu: g13_mmu(28),
initdata_magic: Some(MAGIC_G13_G14G),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G14G: Family = Family {
name: "G14G",
kext: "com.apple.AGXG14G",
kernelcache: "mac14g",
generations: &[5],
core_masks: &G13_G14G_CORE_MASKS,
mmu: g14_mmu(26),
initdata_magic: Some(MAGIC_G13_G14G),
interface: Interface::Modeled,
};
pub const G14X: Family = Family {
name: "G14X",
kext: "com.apple.AGXG14X",
kernelcache: "mac14j",
generations: &[6],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: Some(0x0c8a_636f_0494_04b8),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G15G: Family = Family {
name: "G15G",
kext: "com.apple.AGXG15G",
kernelcache: "mac15g",
generations: &[7],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: Some(0x0c8a_636f_0394_04b8),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G15S: Family = Family {
name: "G15S",
kext: "com.apple.AGXG15S",
kernelcache: "mac15s",
generations: &[7],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: Some(0x0c8a_636f_0394_04b8),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G15C: Family = Family {
name: "G15C",
kext: "com.apple.AGXG15C",
kernelcache: "mac15j",
generations: &[7],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: Some(0x0c8a_636f_0496_04b8),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G16G: Family = Family {
name: "G16G",
kext: "com.apple.AGXG16G",
kernelcache: "mac16g",
generations: &[8, 0xa],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: Some(0x0c8a_636f_0392_04b8),
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G16X: Family = Family {
name: "G16X",
kext: "com.apple.AGXG16X",
kernelcache: "mac16j",
generations: &[8, 0xa],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: None,
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G17G: Family = Family {
name: "G17G",
kext: "com.apple.AGXG17G",
kernelcache: "mac17g",
generations: &[0xb],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: None,
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G17X: Family = Family {
name: "G17X",
kext: "com.apple.AGXG17X",
kernelcache: "mac17j",
generations: &[0xb],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: None,
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G17P: Family = Family {
name: "G17P",
kext: "com.apple.AGXG17P",
kernelcache: "mac17p",
generations: &[8, 0xa],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: None,
interface: Interface::Unrecovered(NOT_CHECKED),
};
pub const G18G: Family = Family {
name: "G18G",
kext: "com.apple.AGXG18G",
kernelcache: "mac18g",
generations: &[0xc],
core_masks: &G14X_CORE_MASKS,
mmu: g14_mmu(28),
initdata_magic: None,
interface: Interface::Unrecovered(NOT_CHECKED),
};
/// T8112: G14G B0, one cluster of 10 cores, 10 fragment units and 4 GPs
/// (Public: Asahi `hw/t8112.rs` for the counts, `regs.rs` for variant G =
/// 2; revision B0 is m1n1's `gpu_rev`, read before m1n1's AI notice).
pub const T8112: Identity = Identity {
generation: 5,
variant: 2,
revision: 0x10,
clusters: 1,
cores: 10,
frags: 10,
gps: 4,
core_mask: [0x3ff, 0, 0],
};
const fn gpu(
compatible: &'static str,
chip_id: u16,
family: &'static Family,
firmware: &'static str,
) -> Gpu {
Gpu {
compatible,
chip_id,
family,
firmware,
identity: None,
}
}
/// Every `sgx` of the 26A434 board DeviceTrees, by ApChipID.
pub const GPUS: [Gpu; 20] = [
gpu("gpu,t8103", 0x8103, &G13G, "armfw_g13g"),
gpu("gpu,t6000", 0x6000, &G13X, "armfw_g13x"),
gpu("gpu,t6001", 0x6001, &G13X, "armfw_g13x"),
gpu("gpu,t6002", 0x6002, &G13X, "armfw_g13x"),
Gpu {
compatible: "gpu,t8112",
chip_id: 0x8112,
family: &G14G,
firmware: "armfw_g14g",
identity: Some(T8112),
},
gpu("gpu,t6020", 0x6020, &G14X, "armfw_g14s"),
gpu("gpu,t6021", 0x6021, &G14X, "armfw_g14c"),
gpu("gpu,t6022", 0x6022, &G14X, "armfw_g14d"),
gpu("gpu,t8122", 0x8122, &G15G, "armfw_g15g"),
gpu("gpu,t6030", 0x6030, &G15S, "armfw_g15s"),
gpu("gpu,t6031", 0x6031, &G15C, "armfw_g15c"),
gpu("gpu,t6032", 0x6032, &G15C, "armfw_g15d"),
gpu("gpu,t6034", 0x6034, &G15C, "armfw_g15c"),
gpu("gpu,t8132", 0x8132, &G16G, "armfw_g16g"),
gpu("gpu,t6040", 0x6040, &G16X, "armfw_g16s"),
gpu("gpu,t6041", 0x6041, &G16X, "armfw_g16c"),
gpu("gpu,t8140", 0x8140, &G17P, "armfw_g17p"),
gpu("gpu,t8142", 0x8142, &G17G, "armfw_g17g"),
gpu("gpu,t6050", 0x6050, &G17X, "armfw_g17x"),
gpu("gpu,t8152", 0x8152, &G18G, "armfw_g18g"),
];
/// The GPU whose `sgx` carries `compatible`.
pub fn by_compatible(compatible: &str) -> Option<&'static Gpu> {
GPUS.iter().find(|gpu| gpu.compatible == compatible)
}
impl Gpu {
/// The identification the model reports, when the GPU's whole interface
/// is modeled; otherwise why it is not.
pub fn admitted(&self) -> Result<Identity, &'static str> {
if let Interface::Unrecovered(reason) = self.family.interface {
return Err(reason);
}
let identity = self
.identity
.ok_or("no source states the GPU's identification registers")?;
if !self.family.generations.contains(&identity.generation) {
return Err("the GPU's generation is not one its kext accepts");
}
Ok(identity)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_census_gpu_is_named_once_and_only_t8112_is_admitted() {
for (index, gpu) in GPUS.iter().enumerate() {
assert!(gpu.compatible.starts_with("gpu,t"));
assert_eq!(
gpu.compatible[5..],
alloc::format!("{:x}", gpu.chip_id),
"{} names its own chip",
gpu.compatible
);
assert!(
GPUS[..index]
.iter()
.all(|other| other.chip_id != gpu.chip_id)
);
assert!(gpu.firmware.starts_with("armfw_g"));
assert!(gpu.family.kext.ends_with(gpu.family.name));
}
let admitted: alloc::vec::Vec<_> = GPUS
.iter()
.filter(|gpu| gpu.admitted().is_ok())
.map(|gpu| gpu.compatible)
.collect();
assert_eq!(admitted, ["gpu,t8112"]);
assert_eq!(by_compatible("gpu,t8112").unwrap().admitted(), Ok(T8112));
assert_eq!(
by_compatible("gpu,t8103").unwrap().admitted(),
Err(NOT_CHECKED)
);
assert!(by_compatible("gpu,t9999").is_none());
}
#[test]
fn mmu_layouts_follow_the_two_secure_monitor_generations() {
for gpu in &GPUS {
let mmu = gpu.family.mmu;
let g13 = gpu.family.generations == [4];
assert_eq!(mmu.ttbat, if g13 { 0xd0_8024 } else { 0xd0_802c });
assert_eq!(mmu.invalidate, mmu.ttbat + 4);
assert!(mmu.configuration.iter().all(|&(offset, _)| {
(MMU_ENABLE + 4..mmu.ttbat).contains(&offset) && offset % 4 == 0
}));
let narrow = ["G13G", "G14G"].contains(&gpu.family.name);
assert_eq!(mmu.ttbat_page_bits, if narrow { 26 } else { 28 });
}
}
}
@@ -1,11 +1,15 @@
//! The `sgx` register block (`gpu,t8112`, ADT `reg[0]` `0x2_0400_0000` +
//! 64 MiB; `reg[1]` `0x2_04d0_0000` + 128 KiB lies inside it): the registers
//! the AP touches directly. Everything else the GPU has is driven by the GFX
//! firmware, which Stela models natively, so every other offset refuses.
//! The `sgx` register block: the registers the AP touches directly. Offsets
//! are relative to the node's `reg[0]` base, as `readGFXReg32` takes them;
//! on T8112 `reg[0]` (`0x2_0400_0000` + 64 MiB) spans them all, while on the
//! Pro/Max SoCs `reg[0]` is 1 MiB and they lie in `reg[1]`
//! (`0x2_04d0_0000`.., docs/research/agx.md §6). Everything else the GPU
//! has is driven by the GFX firmware, which Stela models natively, so every
//! other offset refuses.
//!
//! Known (26A434 `AGXG14G`; every AP access goes through
//! `AGXAccelerator::readGFXReg32` 0x1b7f868 / `writeGFXReg32` 0x1b80ce0,
//! whose callers are listed in docs/research/agx.md §4):
//! whose callers are listed in docs/research/agx.md §4; the other families'
//! readings are in §6 and [`generation`]):
//! - `AGXAcceleratorG14::readChipInfo` (0x1b62f88) reads the identification
//! words 0xd04000, 0xd04010, 0xd04014, 0xd04018 and 0xd0401c and the core
//! mask at 0xd01500. It requires generation 5 (bits 31:24 of 0xd04000),
@@ -19,7 +23,7 @@
//! 0xd0800c, 0xd08010, 0xd0801c..0xd08028, 1 to 0xd08008, 0x3ff to 0xd08004
//! and finally 1 to 0xd08000, reading each back.
//! `invalidateGPUTTBACache(a, b)` (0x1b67788) writes `a << 8 | b` to 0xd08030
//! and reads it back.
//! and reads it back. The family's [`Mmu`] gives these per kext.
//! - `G14::AGXFenderCommon` reads the GPC performance state from 0xd01000
//! bits 3:0 (`getGPCPerformanceState` 0x1b64b0c), sets host-interrupt
//! enables 0xd01010 bits 0..2 by type (`enableGPCHostInterrupts`
@@ -28,11 +32,9 @@
//! `AGXArmFenderChinook::disable/enableDynamicFenderGating` (0x1b643cc,
//! 0x1b644c0) set 0xd06030 bit 2, or clear bits 2:1.
//!
//! Public (Asahi `regs.rs`, `hw/t8112.rs` and m1n1 `agx/initdata.py`, pinned
//! in docs/research/agx.md): T8112 is G14 generation 5, variant G (2),
//! revision B0 (0x10), one cluster of 10 cores, 10 fragment units, 4 GPs.
//!
//! Model decisions:
//! - The GPU must be admitted ([`generation::Gpu::admitted`]): its identity
//! comes from the census, its MMU and core-mask registers from its family.
//! - Identification subfields no source names (0xd04010 bits 31:16, 0xd04014
//! bits 15:0 and 31:24, 0xd04018, 0xd0401c outside bits 19:12) read as zero.
//! The kext multiplies some of them into its core configuration
@@ -50,23 +52,21 @@
//! from `gpu-region-base`. 0xd08000 then reads nonzero and `setupMMUConfig`
//! returns at once.
//! - The model has one performance state (0), no GPC power transitions and
//! so no GPC host interrupts; none of the five `sgx` interrupt lines is
//! raised. Enables and dynamic gating are held as written.
//! so no GPC host interrupts; none of the `sgx` interrupt lines is raised.
//! Enables and dynamic gating are held as written.
use super::super::bus::{Access, Direction, MmioDevice, MmioError, Width, refuse};
use super::generation::{Family, Gpu, MMU_ENABLE, Mmu};
use super::uat::{self, Uat};
use alloc::vec;
use alloc::vec::Vec;
const NAME: &str = "agx-sgx";
/// The block's span (ADT `reg[0]`).
pub const BYTES: u64 = 0x400_0000;
const GPC_PERFORMANCE_STATE: u64 = 0xd0_1000;
const GPC_HOST_INTERRUPT_ENABLE: u64 = 0xd0_1010;
const GPC_HOST_INTERRUPT_STATUS: u64 = 0xd0_1014;
/// Host-interrupt types 0..2 (`GPCHostInterruptType`).
const GPC_HOST_INTERRUPTS: u32 = 0b111;
const CORE_MASK_0: u64 = 0xd0_1500;
const CORE_MASK_1: u64 = 0xd0_1514;
const ID_VERSION: u64 = 0xd0_4000;
const ID_COUNTS_1: u64 = 0xd0_4010;
@@ -78,27 +78,41 @@ const GATING_CONTROL: u64 = 0xd0_6030;
/// The dynamic-gating bits the Fender writes (bit 2 disables).
const GATING_BITS: u32 = 0b110;
const MMU_ENABLE: u64 = 0xd0_8000;
const MMU_TTBAT: u64 = 0xd0_802c;
const MMU_TTBA_INVALIDATE: u64 = 0xd0_8030;
/// The TTBAT page number field (`ubfx x2, x0, #14, #26`).
const TTBAT_PAGE_BITS: u32 = 26;
/// Check that `banks` (`(physical base, bytes, register offset)`) cover
/// every register the model serves for `family`.
pub fn covers(family: &Family, banks: &[(u64, u64, u64)]) -> Result<(), &'static str> {
let fixed = [
GPC_PERFORMANCE_STATE,
GPC_HOST_INTERRUPT_ENABLE,
GPC_HOST_INTERRUPT_STATUS,
ID_VERSION,
ID_COUNTS_1,
ID_COUNTS_2,
ID_UNK18,
ID_CLUSTERS,
GATING_CONTROL,
MMU_ENABLE,
family.mmu.ttbat,
family.mmu.invalidate,
];
let mut registers = fixed
.into_iter()
.chain(family.core_masks.iter().copied())
.chain(family.mmu.configuration.iter().map(|&(offset, _)| offset));
let covered = |offset: u64| {
banks
.iter()
.any(|&(_, bytes, at)| (at..at + bytes).contains(&offset))
};
if registers.all(covered) {
Ok(())
} else {
Err("the sgx banks leave a modeled register unmapped")
}
}
/// The fixed MMU configuration words and the only value each accepts.
const MMU_CONFIGURATION: [(u64, u32); 10] = [
(0xd0_8004, 0x3ff),
(0xd0_8008, 1),
(0xd0_800c, 0),
(0xd0_8010, 0),
(0xd0_8014, 0x80d8),
(0xd0_8018, 0x80d8),
(0xd0_801c, 0),
(0xd0_8020, 0),
(0xd0_8024, 0),
(0xd0_8028, 0),
];
/// The T8112 GPU's identity (see the module documentation).
/// A GPU's identification registers ([`super::generation`] states each
/// SoC's values and their sources).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Identity {
pub generation: u8,
@@ -108,22 +122,11 @@ pub struct Identity {
pub cores: u8,
pub frags: u8,
pub gps: u8,
/// Enabled cores, cluster 0 first, packed `cores` bits per cluster.
pub core_mask: [u32; 2],
/// Enabled cores, cluster 0 first, packed `cores` bits per cluster, one
/// word per core-mask register of the family.
pub core_mask: [u32; 3],
}
/// T8112: G14G B0, one cluster of 10 cores.
pub const T8112: Identity = Identity {
generation: 5,
variant: 2,
revision: 0x10,
clusters: 1,
cores: 10,
frags: 10,
gps: 4,
core_mask: [0x3ff, 0],
};
impl Identity {
fn version(&self) -> u32 {
u32::from(self.generation) << 24
@@ -144,47 +147,52 @@ impl Identity {
/// The `sgx` registers and the UAT they configure.
pub struct Sgx {
identity: Identity,
family: &'static Family,
interrupt_enable: u32,
gating: u32,
mmu_enabled: bool,
ttbat_page: u32,
configuration: [u32; MMU_CONFIGURATION.len()],
configuration: Vec<u32>,
last_invalidate: u32,
uat: Uat,
}
impl Sgx {
pub fn new(identity: Identity) -> Self {
Self {
/// The registers of `gpu`, which must be admitted.
pub fn new(gpu: &'static Gpu) -> Result<Self, &'static str> {
let identity = gpu.admitted()?;
Ok(Self {
identity,
family: gpu.family,
interrupt_enable: 0,
gating: 0,
mmu_enabled: false,
ttbat_page: 0,
configuration: [0; MMU_CONFIGURATION.len()],
configuration: vec![0; gpu.family.mmu.configuration.len()],
last_invalidate: 0,
uat: Uat::default(),
}
})
}
/// The GPU as the boot stage hands it off: the MMU configured as
/// `setupMMUConfig` would and enabled at the 16 KiB-aligned `ttbat`,
/// with the shared TTBR1 window resolving from the page-directory page
/// `shared_l2` (`gfx-shared-l2-region`, [`uat::SHARED_INDEX`]).
pub fn handed_off(
identity: Identity,
ttbat: u64,
shared_l2: u64,
) -> Result<Self, &'static str> {
pub fn handed_off(gpu: &'static Gpu, ttbat: u64, shared_l2: u64) -> Result<Self, &'static str> {
let mut sgx = Self::new(gpu)?;
let page = ttbat >> uat::PAGE_SHIFT;
if ttbat == 0 || page >> TTBAT_PAGE_BITS != 0 {
return Err("GPU TTBAT outside the MMU's 26-bit page field");
if ttbat == 0 || page >> sgx.mmu().ttbat_page_bits != 0 {
return Err("GPU TTBAT outside the MMU's page field");
}
let mut sgx = Self::new(identity);
sgx.uat.configure(ttbat)?;
sgx.uat.share_kernel_window(shared_l2)?;
sgx.ttbat_page = page as u32;
sgx.configuration = MMU_CONFIGURATION.map(|(_, value)| value);
sgx.configuration = sgx
.mmu()
.configuration
.iter()
.map(|&(_, value)| value)
.collect();
sgx.mmu_enabled = true;
Ok(sgx)
}
@@ -194,22 +202,39 @@ impl Sgx {
&mut self.uat
}
fn configuration_slot(offset: u64) -> Option<(usize, u32)> {
MMU_CONFIGURATION
fn mmu(&self) -> &'static Mmu {
&self.family.mmu
}
fn configuration_slot(&self, offset: u64) -> Option<(usize, u32)> {
self.mmu()
.configuration
.iter()
.enumerate()
.find(|(_, (register, _))| *register == offset)
.map(|(slot, &(_, value))| (slot, value))
}
fn core_mask_slot(&self, offset: u64) -> Option<usize> {
self.family
.core_masks
.iter()
.position(|&register| register == offset)
}
fn read32(&self, offset: u64) -> Result<u32, &'static str> {
let id = &self.identity;
let mmu = self.mmu();
if let Some(slot) = self.core_mask_slot(offset) {
return Ok(id.core_mask[slot]);
}
if let Some((slot, _)) = self.configuration_slot(offset) {
return Ok(self.configuration[slot]);
}
Ok(match offset {
GPC_PERFORMANCE_STATE => 0,
GPC_HOST_INTERRUPT_ENABLE => self.interrupt_enable,
GPC_HOST_INTERRUPT_STATUS => 0,
CORE_MASK_0 => id.core_mask[0],
CORE_MASK_1 => id.core_mask[1],
ID_VERSION => id.version(),
ID_COUNTS_1 => id.counts_1(),
ID_COUNTS_2 => id.counts_2(),
@@ -217,16 +242,17 @@ impl Sgx {
ID_CLUSTERS => id.clusters(),
GATING_CONTROL => self.gating,
MMU_ENABLE => u32::from(self.mmu_enabled),
MMU_TTBAT => self.ttbat_page,
MMU_TTBA_INVALIDATE => self.last_invalidate,
_ => match Self::configuration_slot(offset) {
Some((slot, _)) => self.configuration[slot],
None => return Err("sgx register is not modeled"),
},
_ if offset == mmu.ttbat => self.ttbat_page,
_ if offset == mmu.invalidate => self.last_invalidate,
_ => return Err("sgx register is not modeled"),
})
}
fn write32(&mut self, offset: u64, value: u32) -> Result<(), &'static str> {
let mmu = self.mmu();
let mmu_register = offset == MMU_ENABLE
|| offset == mmu.ttbat
|| self.configuration_slot(offset).is_some();
match offset {
GPC_HOST_INTERRUPT_ENABLE => {
if value & !GPC_HOST_INTERRUPTS != 0 {
@@ -246,13 +272,13 @@ impl Sgx {
}
self.gating = value;
}
MMU_TTBA_INVALIDATE => self.last_invalidate = value,
_ if self.mmu_enabled && (MMU_ENABLE..MMU_TTBA_INVALIDATE).contains(&offset) => {
_ if offset == mmu.invalidate => self.last_invalidate = value,
_ if self.mmu_enabled && mmu_register => {
return Err("reconfiguring an enabled GPU MMU is not modeled");
}
MMU_TTBAT => {
if value >> TTBAT_PAGE_BITS != 0 {
return Err("TTBAT page number above 26 bits");
_ if offset == mmu.ttbat => {
if value >> mmu.ttbat_page_bits != 0 {
return Err("TTBAT page number wider than the MMU's field");
}
self.ttbat_page = value;
}
@@ -260,10 +286,11 @@ impl Sgx {
0 => {}
1 => {
let ttbat = u64::from(self.ttbat_page) << uat::PAGE_SHIFT;
let configured = MMU_CONFIGURATION
let configured = mmu
.configuration
.iter()
.zip(self.configuration)
.all(|(&(_, wanted), held)| wanted == held);
.zip(&self.configuration)
.all(|(&(_, wanted), &held)| wanted == held);
if !configured || ttbat == 0 {
return Err("GPU MMU enabled before its configuration is written");
}
@@ -272,7 +299,7 @@ impl Sgx {
}
_ => return Err("GPU MMU enable value is not modeled"),
},
_ => match Self::configuration_slot(offset) {
_ => match self.configuration_slot(offset) {
Some((slot, wanted)) if value == wanted => self.configuration[slot] = value,
Some(_) => return Err("GPU MMU configuration value is not modeled"),
None => return Err("sgx register is not modeled"),
@@ -324,9 +351,19 @@ impl MmioDevice for Sgx {
#[cfg(test)]
mod tests {
use super::super::generation::{self, GPUS};
use super::*;
use crate::platform::apple::interrupt::InterruptLatch;
const MMU_TTBAT: u64 = 0xd0_802c;
const MMU_TTBA_INVALIDATE: u64 = 0xd0_8030;
const CORE_MASK_0: u64 = 0xd0_1500;
const CORE_MASK_1: u64 = 0xd0_1514;
fn t8112() -> &'static Gpu {
generation::by_compatible("gpu,t8112").unwrap()
}
fn read(sgx: &mut Sgx, offset: u64) -> Result<u64, MmioError> {
let mut latch = InterruptLatch::new();
let mut access = Access::new(0, 0, &mut latch);
@@ -341,7 +378,7 @@ mod tests {
#[test]
fn identification_decodes_as_readchipinfo_reads_it() {
let mut sgx = Sgx::new(T8112);
let mut sgx = Sgx::new(t8112()).unwrap();
let version = read(&mut sgx, ID_VERSION).unwrap();
assert_eq!(version >> 24, 5);
assert_eq!((version >> 16) & 0xff, 2);
@@ -353,14 +390,23 @@ mod tests {
assert_eq!((read(&mut sgx, ID_CLUSTERS).unwrap() >> 12) & 0xff, 1);
assert_eq!(read(&mut sgx, CORE_MASK_0).unwrap(), 0x3ff);
assert_eq!(read(&mut sgx, CORE_MASK_1).unwrap(), 0);
// A word no AP code reads refuses, as do other widths.
// A word no AP code reads refuses, as do other widths and the
// core-mask words of another family.
assert!(read(&mut sgx, 0xd0_4008).is_err());
assert!(read(&mut sgx, 0xe0_1500).is_err());
assert!(read(&mut sgx, 0).is_err());
let mut latch = InterruptLatch::new();
let mut access = Access::new(0, 0, &mut latch);
assert!(sgx.read(ID_VERSION, Width::Double, &mut access).is_err());
}
#[test]
fn a_gpu_whose_family_is_not_modeled_has_no_registers() {
for gpu in GPUS.iter().filter(|gpu| gpu.admitted().is_err()) {
assert!(Sgx::new(gpu).is_err(), "{}", gpu.compatible);
}
}
/// The register writes of `setupMMUConfig`, in its order.
fn setup_mmu(sgx: &mut Sgx, ttbat: u64) -> Result<(), MmioError> {
assert_eq!(read(sgx, MMU_ENABLE)?, 0);
@@ -385,7 +431,7 @@ mod tests {
#[test]
fn the_mmu_configuration_roots_the_uat_at_the_programmed_ttbat() {
let mut sgx = Sgx::new(T8112);
let mut sgx = Sgx::new(t8112()).unwrap();
assert_eq!(sgx.uat().ttbat(), None);
setup_mmu(&mut sgx, 0x8_1234_4000).unwrap();
assert_eq!(read(&mut sgx, MMU_ENABLE).unwrap(), 1);
@@ -399,27 +445,27 @@ mod tests {
#[test]
fn the_boot_stage_hands_off_the_mmu_setup_would_have_configured() {
let mut configured = Sgx::new(T8112);
let mut configured = Sgx::new(t8112()).unwrap();
setup_mmu(&mut configured, 0x8_0004_4000).unwrap();
let mut handed = Sgx::handed_off(T8112, 0x8_0004_4000, 0x8_0008_8000).unwrap();
let mut handed = Sgx::handed_off(t8112(), 0x8_0004_4000, 0x8_0008_8000).unwrap();
for offset in [MMU_ENABLE, MMU_TTBAT]
.into_iter()
.chain(MMU_CONFIGURATION.map(|(offset, _)| offset))
.chain(t8112().family.mmu.configuration.iter().map(|&(o, _)| o))
{
assert_eq!(read(&mut handed, offset), read(&mut configured, offset));
}
assert_eq!(handed.uat().ttbat(), Some(0x8_0004_4000));
// setupMMUConfig then returns at once; a rewrite refuses.
assert!(write(&mut handed, MMU_TTBAT, 0x1).is_err());
assert!(Sgx::handed_off(T8112, 0, 0x8_0008_8000).is_err());
assert!(Sgx::handed_off(T8112, 0x8_0004_4001, 0x8_0008_8000).is_err());
assert!(Sgx::handed_off(T8112, 1 << 40, 0x8_0008_8000).is_err());
assert!(Sgx::handed_off(T8112, 0x8_0004_4000, 0x8_0008_8001).is_err());
assert!(Sgx::handed_off(t8112(), 0, 0x8_0008_8000).is_err());
assert!(Sgx::handed_off(t8112(), 0x8_0004_4001, 0x8_0008_8000).is_err());
assert!(Sgx::handed_off(t8112(), 1 << 40, 0x8_0008_8000).is_err());
assert!(Sgx::handed_off(t8112(), 0x8_0004_4000, 0x8_0008_8001).is_err());
}
#[test]
fn an_unknown_mmu_configuration_refuses() {
let mut sgx = Sgx::new(T8112);
let mut sgx = Sgx::new(t8112()).unwrap();
assert!(write(&mut sgx, 0xd0_8014, 0x80d9).is_err());
// Enabling before the configuration is written refuses.
write(&mut sgx, MMU_TTBAT, 0x2_0000).unwrap();
@@ -429,7 +475,7 @@ mod tests {
#[test]
fn fender_controls_hold_their_bits_and_raise_nothing() {
let mut sgx = Sgx::new(T8112);
let mut sgx = Sgx::new(t8112()).unwrap();
assert_eq!(read(&mut sgx, GPC_PERFORMANCE_STATE).unwrap(), 0);
write(&mut sgx, GPC_HOST_INTERRUPT_ENABLE, 0b101).unwrap();
assert_eq!(read(&mut sgx, GPC_HOST_INTERRUPT_ENABLE).unwrap(), 0b101);