🐛 Drop a bad UPLOADS_WRITTEN record, and run its buffer
065432241 failed a command buffer at its begin where a record of its UPLOADS_WRITTEN named no Managed buffer, or bytes past one. A buffer answered CB_SUBMITTED at its doorbell has posted its CB_SUBMITTED and CB_SCHEDULED by then, so it failed with them where a buffer its queue's thread took failed without them: the fuzz caught it (an_answer_at_the_doorbell_keeps_the_order_of_a_take, case 11 of the default seed). The record is dropped now, logged once, as the host drops a BUFFER_DID_MODIFY_RANGE it refuses, and the buffer runs and completes as it would behind that message, the same whether or not it was answered at its doorbell. The records beside it are carried out. Only a guest that names an object its bundle never made a chunk of sees the difference.
This commit is contained in:
1 parent
a4a91ef8e2
commit
3c60f57f72
4 files changed
+59
-41
No files matched your search
@@ -1799,9 +1799,7 @@ impl<P: Platform> GraphicsDecoder<P> {
|
||||
};
|
||||
// The bytes it wrote in its `Managed` chunks reach their GPU copies by its commit, before
|
||||
// its work, as a range message of each before it would bring them.
|
||||
if let Err(e) = self.uploads_written(&take.written) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
self.uploads_written(&take.written);
|
||||
let Some(cb) = queue.command_buffer(ON)? else {
|
||||
return Ok(Err(DecodeError::Refused));
|
||||
};
|
||||
|
||||
@@ -219,6 +219,20 @@ fn in_place_shape(create: &RgfxManagedTextureCreate) -> bool {
|
||||
&& d.sample_count <= 1
|
||||
}
|
||||
|
||||
/// Logs, the first time, an `UPLOADS_WRITTEN` record the host drops: `what` it does wrong.
|
||||
fn log_upload_dropped(w: &RgfxUploadWritten, what: &str) {
|
||||
static LOGGED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
|
||||
if !LOGGED.swap(true, std::sync::atomic::Ordering::Relaxed) {
|
||||
log::warn!(
|
||||
target: "reims_vgpu::graphics",
|
||||
"an UPLOADS_WRITTEN record of object {:#x}, {} bytes, {what}: dropped, and its \
|
||||
command buffer runs (logged once)",
|
||||
w.buffer_obj_id,
|
||||
w.length
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Logs, the first time, a `Managed` texture of a shape that lies over its CPU copy on a GPU that
|
||||
/// shares the CPU's memory, whose texture over its CPU copy's buffer the platform refused: it is
|
||||
/// two copies, and the guest, which knows the shape alone, reads its CPU copy, which shows the
|
||||
@@ -567,11 +581,12 @@ impl<P: Platform> GraphicsDecoder<P> {
|
||||
/// `didModifyRange:` of each buffer's bytes from its start, which brings them to its GPU copy
|
||||
/// by the buffer's commit, at once, as the buffer's own chunks are used by no command buffer
|
||||
/// committed before it (the module doc). A buffer whose create the host refused holds
|
||||
/// nothing to bring over ([`super::refused`]). A bad reference for an object that is no
|
||||
/// `Managed` buffer, malformed for bytes past it, each before any is carried out; a raise of
|
||||
/// the platform's is logged, and the rest are carried out, as a range message's is.
|
||||
pub(super) fn uploads_written(&self, written: &[RgfxUploadWritten]) -> Result<(), DecodeError> {
|
||||
let mut buffers = Vec::with_capacity(written.len());
|
||||
/// nothing to bring over ([`super::refused`]). A record of an object that is no `Managed`
|
||||
/// buffer, or of bytes past one, is dropped (logged once), and so is one the platform raises
|
||||
/// at (logged), as a range message the host refuses or cannot carry out is, and the buffer
|
||||
/// runs, as it would behind such a message, the same whether or not it was answered at its
|
||||
/// doorbell before its begin.
|
||||
pub(super) fn uploads_written(&self, written: &[RgfxUploadWritten]) {
|
||||
for w in written {
|
||||
if let Some(ObjHandle::Refused(r)) = self.named(w.buffer_obj_id) {
|
||||
r.used(w.buffer_obj_id);
|
||||
@@ -581,17 +596,17 @@ impl<P: Platform> GraphicsDecoder<P> {
|
||||
self.named(w.buffer_obj_id),
|
||||
self.managed_copy(w.buffer_obj_id),
|
||||
) else {
|
||||
return Err(DecodeError::BadReference);
|
||||
log_upload_dropped(w, "names no Managed buffer");
|
||||
continue;
|
||||
};
|
||||
if copy.layout.is_some() || w.length > copy.length {
|
||||
return Err(DecodeError::Malformed);
|
||||
log_upload_dropped(w, "reaches past its Managed buffer");
|
||||
continue;
|
||||
}
|
||||
if w.length != 0 {
|
||||
buffers.push((w.buffer_obj_id, buffer.clone_ref(), w.length));
|
||||
if w.length == 0 {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (obj_id, buffer, length) in buffers {
|
||||
let range = NsRange::new(0, length);
|
||||
let (obj_id, range) = (w.buffer_obj_id, NsRange::new(0, w.length));
|
||||
if let Err(raise) = refusing(|| buffer.did_modify_range(OnFault::Return, range)) {
|
||||
log::warn!(
|
||||
target: "reims_vgpu::graphics", kind:% = raise;
|
||||
@@ -600,7 +615,6 @@ impl<P: Platform> GraphicsDecoder<P> {
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether a `Managed` object `name` makes may take the CPU copy that lies over `span` (its
|
||||
|
||||
@@ -7458,10 +7458,11 @@ fn uploads_written_are_carried_out_before_their_command_buffer_s_commit() {
|
||||
assert_eq!((done.cb_obj_id, done.status), (100, RGFX_CB_OK));
|
||||
}
|
||||
|
||||
/// A command buffer whose `UPLOADS_WRITTEN` names an object that is no `Managed` buffer, or bytes
|
||||
/// past one, fails, and nothing it names is carried out; the queue's next buffer completes
|
||||
/// A record of a command buffer's `UPLOADS_WRITTEN` that names an object that is no `Managed`
|
||||
/// buffer, or bytes past one, is dropped, as a range message the host refuses is, and the buffer
|
||||
/// runs and completes; the records beside it are carried out
|
||||
#[test]
|
||||
fn uploads_written_of_no_managed_buffer_fail_their_command_buffer() {
|
||||
fn uploads_written_of_no_managed_buffer_are_dropped() {
|
||||
use reims_vgpu_graphics::ops::{RGFX_OP_UPLOADS_WRITTEN, RgfxUploadWritten};
|
||||
|
||||
let raised = Arc::new(AtomicU32::new(0));
|
||||
@@ -7492,16 +7493,16 @@ fn uploads_written_of_no_managed_buffer_fail_their_command_buffer() {
|
||||
(obj(1, 2), 0x1001, "past the buffer"),
|
||||
];
|
||||
for (n, (buffer_obj_id, length, what)) in (100..).zip(cases) {
|
||||
// The Managed buffer's bytes first, which a failing record after them keeps back too.
|
||||
// The Managed buffer's bytes, a record beside the dropped one.
|
||||
let written = [
|
||||
RgfxUploadWritten {
|
||||
buffer_obj_id: obj(1, 2),
|
||||
length: 0x20,
|
||||
},
|
||||
RgfxUploadWritten {
|
||||
buffer_obj_id,
|
||||
length,
|
||||
},
|
||||
RgfxUploadWritten {
|
||||
buffer_obj_id: obj(1, 2),
|
||||
length: 0x20 + n,
|
||||
},
|
||||
];
|
||||
ring.send(
|
||||
&device,
|
||||
@@ -7515,19 +7516,23 @@ fn uploads_written_of_no_managed_buffer_fail_their_command_buffer() {
|
||||
complete_until_event(&platform, &mut ring),
|
||||
"{what}: no completion"
|
||||
);
|
||||
let failed = RgfxCbComplete::read_from_bytes(&ring.event().unwrap()).unwrap();
|
||||
assert_eq!(failed.cb_obj_id, n, "{what}");
|
||||
assert_ne!(failed.status, RGFX_CB_OK, "{what}");
|
||||
let done = RgfxCbComplete::read_from_bytes(&ring.event().unwrap()).unwrap();
|
||||
assert_eq!((done.cb_obj_id, done.status), (n, RGFX_CB_OK), "{what}");
|
||||
}
|
||||
let calls = platform.call_log().calls();
|
||||
assert!(
|
||||
!calls.iter().any(|c| c.sel == "didModifyRange:"),
|
||||
"carried out"
|
||||
let modified: Vec<Arg> = (platform.call_log().calls().iter())
|
||||
.filter(|c| c.sel == "didModifyRange:")
|
||||
.filter_map(|c| c.args.first().cloned())
|
||||
.collect();
|
||||
let range = |length| {
|
||||
Arg::val(&reims_vgpu_vulkan::core::platform::types::NsRange::new(
|
||||
0, length,
|
||||
))
|
||||
};
|
||||
assert_eq!(
|
||||
modified,
|
||||
[range(0x20 + 100), range(0x20 + 101), range(0x20 + 102)],
|
||||
"the Managed buffer's records alone"
|
||||
);
|
||||
ring.send(&device, command_buffer(obj(1, 1), 110));
|
||||
assert!(complete_until_event(&platform, &mut ring), "no completion");
|
||||
let done = RgfxCbComplete::read_from_bytes(&ring.event().unwrap()).unwrap();
|
||||
assert_eq!((done.cb_obj_id, done.status), (110, RGFX_CB_OK));
|
||||
}
|
||||
|
||||
/// A process's queue rings at `submit`, `complete` (data `RING_DATA`), queue `n` of context 1,
|
||||
|
||||
@@ -2276,12 +2276,13 @@ only where no negotiation can carry it.
|
||||
so the buffer waits at the gate for no range message on ring 0: no command
|
||||
buffer committed before it uses a chunk it names, as the bundle gives a
|
||||
chunk back only once the buffer that used it has completed. A record of an
|
||||
object that is no Managed buffer, or of bytes past one, fails the buffer,
|
||||
and none of its records is carried out. Every host offers it, and both kexts
|
||||
take it; the bundle names the bytes there where its chunks are Managed (the
|
||||
device answers `hasUnifiedMemory` NO), and else, on a host that did not
|
||||
offer it, sends a `BUFFER_DID_MODIFY_RANGE` of each chunk ahead of the
|
||||
buffer, as before the bit.
|
||||
object that is no Managed buffer, or of bytes past one, is dropped (logged
|
||||
once), as a range message the host refuses is, and the buffer runs, the
|
||||
same whether or not it was answered at its doorbell. Every host
|
||||
offers the bit, and both kexts take it. The bundle names the bytes there
|
||||
where its chunks are Managed (the device answers `hasUnifiedMemory` NO), and
|
||||
on a host that did not offer the bit it sends a `BUFFER_DID_MODIFY_RANGE` of
|
||||
each chunk ahead of the buffer, as before the bit.
|
||||
|
||||
**BAR2: the region.** A 64-bit prefetchable BAR over host memory (1 GiB),
|
||||
mapped write-back by the guest. The device places the control rings at fixed
|
||||
|
||||
Reference in new issue
Block a user