Repository navigation
Conversation
… one-granule remake Two boundary cases of the grooming xcl-dev#2977 changed (reported on that PR after it merged): - In the free stretch that holds the window's hole, the left reservation started at the stretch's base plus the margin. When the stretch began less than the margin before the hole, the granules between its base and the hole stayed free, and with the hole they made room for a window-sized mapping one granule before the window's address. Reproduced: with one free granule below a 512 MB hole, a window-sized reservation after grooming landed at hole - 64 KiB. The stretch that holds the hole is now reserved right up to it and from its end (the margin stays at the stretch's start only where the part before the hole is longer). - A window of one 64 KiB granule has no margin (half of it rounds to zero granules), so grooming reserved every other free stretch and left the driver no room. Such a window is not remade now (it stays the title's memory); the two restore tests use two granules for that reason. Tests: grooming_leaves_no_free_granule_next_to_the_hole (fails with the old pieces: the reservation lands one granule low), a_one_granule_window_is_left_as_it_is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@thehollowedone Pushed this for you. Plz review. |
|
Independent RTX 3080 Ti check of #2991 head Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11. On the clean PR head, I also ran
#2991 The head showed 99.0% of One non-blocking test improvement: Test-only diff for the address invariantdiff --git a/crates/xcl/src/hle/d3d12x/uma_driver.rs b/crates/xcl/src/hle/d3d12x/uma_driver.rs
@@ -388,15 +388,17 @@ mod tests {
assert_eq!(guard, all);
let hole = all + 2 * G;
let got = groom(hole, LEN);
- let p = reserve(0, LEN, 0);
+ let wrong = reserve(hole - G, LEN, 0);
+ assert_eq!(wrong, 0, "a window-sized mapping still fits before the hole");
+ let right = reserve(hole, LEN, 0);
+ assert_eq!(right, hole, "the intended hole is blocked");
ungroom(got);
- for a in [p, guard] {
+ for a in [right, guard] {
if a != 0 {
VirtualFree(a as *mut c_void, 0, MEM_RELEASE);
}
}
- println!("window reservation at {p:#x}, hole {hole:#x}");
- std::process::exit(if p == hole { 0 } else { 1 });
+ std::process::exit(77);
}
}
@@ -405,7 +407,7 @@ mod tests {
.output()
.unwrap();
let transcript = format!("{}{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
- assert_eq!(output.status.code(), Some(0), "{transcript}");
+ assert_eq!(output.status.code(), Some(77), "{transcript}");
}AI use: Codex (GPT-6.2 Sol) reviewed the diff, ran the builds, tests and smoke pair, and drafted this report. Codex (GPT-6.2 Astra) independently reviewed the low-level boundary logic. |
|
Tested PR #2991 ( Unit tests (
|
bmjask
left a comment
There was a problem hiding this comment.
Critical review of current head a497d8fc. I found no runtime blocker in the two UMA grooming boundary changes: both close holes that can let a window-sized mapping collide with the driver's reserved range. The branch now conflicts with current main, so the critical next step is a rebase that preserves the updated range arithmetic, followed by tests at both sides of the hole and the one-granule remake case. Existing Windows tests on an earlier main were green, but they do not validate the conflicted merge result. No local Windows run.
|
Reviewed and tested current head Blocking finding from the merge commit (
|
|
Agreed with Saintwolf’s current-head review. It identifies two regressions in merge commit I prepared and locally tested this candidate against Candidate patchdiff --git a/crates/xcl/src/hle/d3d12x/uma_driver.rs b/crates/xcl/src/hle/d3d12x/uma_driver.rs
--- a/crates/xcl/src/hle/d3d12x/uma_driver.rs
+++ b/crates/xcl/src/hle/d3d12x/uma_driver.rs
@@ -118,13 +118,12 @@ unsafe fn written_pages(base: usize, size: usize) -> Result<Vec<(usize, Vec<u8>)>
/// stretch that holds the hole nothing next to it is left free: a free granule there and the hole
/// make room for a window-sized mapping that starts before the window's address.
unsafe fn groom(hole: usize, len: usize) -> Vec<usize> {
- groom_with(hole, len, len.min(1 << 30), (256usize << 20).min(len / 2) & !0xFFFF)
+ groom_with(hole, len, len.min(1 << 30), groom_margin(len))
}
/// `groom` for stretches of `min_region` or more, leaving `headroom` at the start of each.
unsafe fn groom_with(hole: usize, len: usize, min_region: usize, headroom: usize) -> Vec<usize> {
let (top, mut a, mut got) = (0x7FFF_FFFE_0000usize, 0x1_0000usize, Vec::new());
- let (least, margin) = (len.min(1 << 30), groom_margin(len));
while a < top {
let mut m: MEMORY_BASIC_INFORMATION = std::mem::zeroed();
if VirtualQuery(a as *const c_void, &mut m, std::mem::size_of::<MEMORY_BASIC_INFORMATION>()) == 0 {
@@ -136,11 +135,12 @@ unsafe fn groom_with(hole: usize, len: usize, min_region: usize, headroom: usize
continue;
}
let b = (base + 0xFFFF) & !0xFFFF;
+ let start = b.saturating_add(headroom);
let pieces = if b <= hole && hole + len <= end {
// (the margin at the stretch's start, only where the part before the hole is longer)
- [(if hole - b > margin { b + margin } else { b }, hole), (hole + len, end)]
+ [(if start < hole { start } else { b }, hole), (hole + len, end)]
} else {
- [(b + margin, end), (0, 0)]
+ [(start, end), (0, 0)]
};
for (s, e) in pieces {
let mut s = s;
@@ -746,6 +746,43 @@ mod tests {
assert!(build_segments(256 << 20, &[(0, 128 << 20), (64 << 20, 64 << 20)]).is_err());
}
+ #[test]
+ fn mixed_grooming_preserves_headroom_and_blocks_other_segment_placements() {
+ use super::*;
+ const SEG: usize = 64 << 20;
+ const LEN: usize = 512 << 20;
+ const ROOM: usize = 16 << 20;
+ if std::env::var_os("XCL_TEST_GROOM_MIXED").is_some() {
+ unsafe {
+ let reserve = |at: usize, n| VirtualAlloc(at as *const c_void, n, MEM_RESERVE, PAGE_NOACCESS) as usize;
+ let all = reserve(0, TILE + SEG + LEN);
+ assert_ne!(all, 0);
+ assert_ne!(VirtualFree(all as *mut c_void, 0, MEM_RELEASE), 0);
+ let stretch = all + TILE;
+ let hole = stretch + SEG;
+ assert_eq!(reserve(all, TILE), all);
+ assert_eq!(reserve(hole, SEG), hole);
+ assert_eq!(reserve(hole + SEG, LEN - SEG), hole + SEG);
+ let got = groom_with(hole, LEN, SEG, ROOM);
+ assert_ne!(VirtualFree(hole as *mut c_void, 0, MEM_RELEASE), 0);
+ assert_eq!(reserve(stretch, SEG), 0, "a segment still fits outside the window");
+ assert_eq!(reserve(hole - TILE, SEG), 0, "a segment fits across the boundary");
+ assert_eq!(reserve(stretch, ROOM), stretch, "driver headroom is blocked");
+ assert_eq!(reserve(stretch + ROOM, TILE), 0, "too much headroom was left");
+ assert_eq!(reserve(hole, SEG), hole, "the released segment is blocked");
+ ungroom(got);
+ std::process::exit(77);
+ }
+ }
+ let output = std::process::Command::new(std::env::current_exe().unwrap())
+ .args(["--exact", "hle::d3d12x::uma_driver::tests::mixed_grooming_preserves_headroom_and_blocks_other_segment_placements", "--nocapture"])
+ .env("XCL_TEST_GROOM_MIXED", "1")
+ .output()
+ .unwrap();
+ let transcript = format!("{}{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
+ assert_eq!(output.status.code(), Some(77), "{transcript}");
+ }
+
/// A mixed window keeps the title's bytes in every segment, and the GPU reads the CPU's laterFocused verification on the exact head: AI use: Codex (GPT-6.2 Sol) prepared the candidate and ran the focused test. |
|
Review (head 700087f, diff read, not a merge-check:
Fine: reserving the hole's stretch right up to the hole while keeping the margin only when the part before it is longer, refusing a one-granule window before it's released, and the subprocess test for that edge case. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: cargo test -p xcl --lib uma_driver on this head would settle it. The rest of the suite passes, and the findings in my review stand.hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point. |
Requested by Prime · project thread
Two boundary cases of #2977's grooming, reported on that PR after it merged (thanks to the reviewer who followed up):
What is in it
crates/xcl/src/hle/d3d12x/uma_driver.rs:groomreserves the hole's own stretch up to the hole;groom_margin;remakerefuses a one-granule window before releasing it.grooming_leaves_no_free_granule_next_to_the_hole(in a process of its own, as the other grooming test): one free granule below a 512 MB hole; a window-sized reservation after grooming lands at the hole. With the old pieces it landed one granule low (0x7ff490740000for a hole at0x7ff490750000, checked by running the test against the old code).a_one_granule_window_is_left_as_it_is; the two restore tests (failed_write_watch_does_not_release_the_original_window,failed_restore_stops_before_importing_an_unbacked_window) use two granules, since one is not remade now and their failure paths would not be reached.Tested
cargo test --locked --workspace --no-fail-fast -- --test-threads=4withXCL_DXC_DIRset to DXC 1.9.2609.5: 1457 passed, 3 failed, 47 ignored. The 3 failures are tests that fail onmain623d02e4itself (1455passed,3failed,47ignored there, same command):test_title_draws_with_a_root_signature_under_the_debug_layer,test_title_runs_and_game_folder_is_untouched,test_title_runs_under_the_debug_layer_with_dred.Regression run
A commit of
main(b49be183, the last one before the shader preparation of #2555, which prepares every record before the title and does not fit a 60 s run):This PR's head (with
XCL_PREPARE=0, the switch of #2976):Not tested
AI use
Claude Code (Claude Opus 5.5) wrote the code, ran the suite and the regression runs on the hardware above, and wrote this description; Prime asked for it and owns the account. We coordinate the 8 GB work on the XCL Discord too: https://discord.gg/6B4TykyC4W
🤖 Generated with Claude Code