✅ Hold the host's ranges outside the units, not below them

on_vulkan_the_host_s_own_ranges_lie_below_every_unit asserted that a buffer the
host places lies below RGFX_CONTEXT_VA_BASE (2^46). On rt a buffer's address is
the driver's device address, and two drivers give theirs in the upper canonical
half, above the contexts' range's end (2^47): RADV on the Radeon 780M
(0xffff8001_03400000) and Intel's Windows driver on the UHD 630
(0xffffb802_03a80000), where b339 failed. RADV on the RX 550 gives
0x1_0340_0000, and the RTX 3090 and the Iris Xe pass below 2^46.

What the guest's own picks rely on is that no host range meets the contexts'
range, [2^46, 2^47): rt finds a known block by its address alone, so a pick
there would otherwise be made inside a block it is not meant for. None meets it
on any of those devices. The test, now ..._lie_outside_every_unit, asserts that
the host's buffer lies wholly below the range or at or above its end, and
rt_platform::buffer's docs record the addresses measured.

Tests and docs only: nothing changes for the guest or the host.
This commit is contained in:
Anees Iqbal committed 2026-11-20 08:29:28 -08:00
1 parent e405748245
commit 184a2792b2
2 files changed
+24 -9

No files matched your search

@@ -30,8 +30,16 @@
//! shares the CPU's memory it keeps no copy, so a pin lies at its bytes, as a Shared one's does.
//! Any other pinned buffer is made as an unpinned one, at rt's address, which the guest observes as
//! a `gpuAddress` other than the one it pinned: counted ([`UNPINNED_CODE`]), the process's first
//! with a line. A no-copy buffer's bytes that a known Shared block maps are a range of that block,
//! with no import of their own: a Managed buffer's in a slab of the pool or in a pages block's
//! with a line. A known block is found by its address alone, so a pin the guest picks in its
//! context's range, `[2^46, 2^47)` (reims-vgpu-graphics' `RGFX_CONTEXT_VA_BASE`), lies in no known
//! block only while no device address of the driver's lies there. None did on any device measured
//! (2026-11-20, a 64 MiB Shared buffer's): RADV's on the Radeon 780M lie in the upper canonical
//! half (`0xffff8001_03400000`) and on the RX 550 below 2^46 (`0x1_0340_0000`), Intel's Windows
//! driver's on the UHD 630 in the upper half (`0xffffb802_03a80000`), and those on the RTX 3090
//! (NVIDIA) and the Iris Xe (ANV) below 2^46. reims-vgpu's test
//! `on_vulkan_the_host_s_own_ranges_lie_outside_every_unit` checks it on each device it runs on.
//! A no-copy buffer's bytes that a known Shared block maps are a range of that block, with no
//! import of their own: a Managed buffer's in a slab of the pool or in a pages block's
//! view, and those of a buffer whose pin no known block keeps, which then lies at the block's
//! address plus their offset.
//!
@@ -8613,7 +8613,7 @@ mod tests {
/// platform. Its device is the process's, and so are its addresses: under `cargo test`, whose
/// tests share one process, `on_vulkan_a_pin_meets_no_range_of_a_texture_buffer`'s pin was
/// refused in 4 of 20 one-process runs of `graphics::decode` (measured on the M3 Max), where
/// `on_vulkan_the_host_s_own_ranges_lie_below_every_unit`'s pin at the range's base, 96 KiB,
/// `on_vulkan_the_host_s_own_ranges_lie_outside_every_unit`'s pin at the range's base, 96 KiB,
/// covers its address.
static CONTEXT_RANGE_PINS: Mutex<()> = Mutex::new(());
@@ -8780,12 +8780,14 @@ mod tests {
]);
}
/// The host's own ranges lie below the guest's GPU addresses: a buffer the host places
/// itself lies below them, and, with it, a queue's range made and a texture buffer refused,
/// the first pick of every unit the kext hands the contexts out in and the last unit's last pick
/// are made.
/// The host's own ranges lie outside the guest's GPU addresses: a buffer the host places
/// itself meets none of `[RGFX_CONTEXT_VA_BASE, RGFX_CONTEXT_VA_END)`, and, with it, a queue's
/// range made and a texture buffer refused, the first pick of every unit the kext hands the
/// contexts out in and the last unit's last pick are made. On rt the buffer lies at the
/// driver's device address, below the range on some drivers and above its end on others
/// (`reims_vgpu_vulkan::rt_platform::buffer`, "A pinned address").
#[test]
fn on_vulkan_the_host_s_own_ranges_lie_below_every_unit() {
fn on_vulkan_the_host_s_own_ranges_lie_outside_every_unit() {
use reims_vgpu_graphics::wire::{
RGFX_CONTEXT_VA_BASE, RGFX_CONTEXT_VA_END, RGFX_CONTEXT_VA_UNIT, RGFX_CONTEXT_VA_UNITS,
};
@@ -8798,7 +8800,12 @@ mod tests {
let Some(ObjHandle::Buffer(buffer)) = dec.object(11) else {
panic!("no buffer 11");
};
assert!(buffer.gpu_address() < RGFX_CONTEXT_VA_BASE);
let (at, end) = (buffer.gpu_address(), buffer.gpu_address() + buffer.length());
assert!(
end <= RGFX_CONTEXT_VA_BASE || at >= RGFX_CONTEXT_VA_END,
"the host's buffer at {at:#x}..{end:#x} meets the contexts' range \
{RGFX_CONTEXT_VA_BASE:#x}..{RGFX_CONTEXT_VA_END:#x}"
);
// A pick of 64 KiB holds 96 KiB: its four pages, the guard page, rounded up to 32 KiB.
let units = u64::from(RGFX_CONTEXT_VA_UNITS);
let last = RGFX_CONTEXT_VA_END - 0x1_8000;