runtime: GP0 source key and overlay_region_floor follow the 8 MiB window

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthew Stanley
2026-09-26 08:03:58 -07:00
parent 1721739a73
commit ec4c91cd94
4 changed files with 19 additions and 12 deletions
+7 -5
View File
@@ -517,18 +517,20 @@ static RuntimeConfig parse_runtime_block(const toml::value& cfg, const fs::path&
if (raw < 0 || raw > 0xFFFFFFFFll) {
throw std::runtime_error(fmt::format(
"[runtime] overlay_region_floor out of range "
"(0x10000..0x1FFFFF physical, KSEG0/KSEG1 prefix allowed): {}",
"(0x10000..0x7FFFFF physical, KSEG0/KSEG1 prefix allowed): {}",
raw));
}
floor = static_cast<uint32_t>(raw);
}
// The floor names a main-RAM physical address above the kernel window;
// fail loud here instead of relying on the runtime clamp/mask.
// The floor names a main-RAM physical address above the kernel window,
// inside the 8 MiB decode window (the opt-in 8 MB map's text may end
// above 2 MiB; on retail RAM the runtime clamps it to the live end).
// Fail loud here instead of relying on the runtime clamp/mask.
const uint32_t phys = floor & 0x1FFFFFFFu;
if (phys < 0x00010000u || phys >= 0x00200000u) {
if (phys < 0x00010000u || phys >= 0x00800000u) {
throw std::runtime_error(fmt::format(
"[runtime] overlay_region_floor out of range "
"(0x10000..0x1FFFFF physical, KSEG0/KSEG1 prefix allowed): 0x{:08X}",
"(0x10000..0x7FFFFF physical, KSEG0/KSEG1 prefix allowed): 0x{:08X}",
floor));
}
rt.overlay_region_floor = floor;
+3 -1
View File
@@ -1290,7 +1290,9 @@ static void mmio_write32(uint32_t addr, uint32_t val) {
if (addr == 0x1F801810u) {
uint32_t src = addr;
if (g_debug_last_store_pc == 0xBFC38B1Cu && debug_cpu_ptr) {
src = (debug_cpu_ptr->gpr[4] - 4u) & 0x1FFFFCu;
/* Word-aligned RAM key through the live geometry (retail: the
* 0x1FFFFC fold, identical to the DMA/GPU source keys). */
src = psx_ram_canonical_offset(debug_cpu_ptr->gpr[4] - 4u) & ~3u;
}
gpu_set_gp0_source(src);
gpu_write_gp0(val);
@@ -19,7 +19,7 @@ assert 'parse_hex(v.as_string(), "runtime.overlay_region_floor")' in LOADER_CPP,
# negative or >32-bit TOML integer must not wrap into a different address, and
# the value must name main RAM above the kernel window.
assert "raw < 0 || raw > 0xFFFFFFFFll" in LOADER_CPP, "integer form must reject wrap-around values"
assert "phys < 0x00010000u || phys >= 0x00200000u" in LOADER_CPP, "floor must be validated against main RAM"
assert "phys < 0x00010000u || phys >= 0x00800000u" in LOADER_CPP, "floor must be validated against the main-RAM decode window"
assert LOADER_CPP.count("overlay_region_floor out of range") == 2, "both rejections must fail loud"
cfg = MAIN.index("gc.runtime.has_overlay_region_floor")
@@ -12,11 +12,14 @@ SDL_MAIN_HEADER = "<SDL3/SDL_main.h>"
def main() -> int:
runtime = ROOT / "runtime"
owners = []
for pattern in ("*.c", "*.cpp", "*.h"):
for path in runtime.rglob(pattern):
source = path.read_text(encoding="utf-8")
if SDL_MAIN_HEADER in source:
owners.append(path.relative_to(ROOT).as_posix())
# Sources only: a build tree under runtime/ (the documented runtime/build
# layout) holds generated binary-ish headers such as vk_shaders_spv.h.
for tree in ("src", "include", "tests"):
for pattern in ("*.c", "*.cpp", "*.h"):
for path in (runtime / tree).rglob(pattern):
source = path.read_text(encoding="utf-8")
if SDL_MAIN_HEADER in source:
owners.append(path.relative_to(ROOT).as_posix())
if owners != ["runtime/src/main.cpp"]:
raise AssertionError(