Re: [PATCH 6/9] gpu: nova-core: generalize `flush_into_kvec` to `flush_into_vec`
From: Danilo Krummrich
Date: Tue Mar 17 2026 - 06:52:03 EST
On Tue Mar 17, 2026 at 2:55 AM CET, Alexandre Courbot wrote:
> We shouldn't be doing that - I think we are limited by the current
> CoherentAllocation API though. But IIUC this is something that I/O
> projections will allow us to handle properly?
Why do we need projections to avoid UB here? driver_read_area() already even
peeks into the firmware abstraction layer, which is where MsgqData technically
belongs into (despite being trivial).
let gsp_mem = &unsafe { self.0.as_slice(0, 1) }.unwrap()[0];
let data = &gsp_mem.gspq.msgq.data;
Why do we need I/O projections to do raw pointer arithmetic where creating a
reference is UB?
(Eventually, we want to use IoView of course, as this is a textbook example of
what I proposed IoSlice for.)
Another option in the meantime would be / have been to use dma_read!() and
extract (copy) the data right away in driver_read_area(), which I'd probably
prefer over raw pointer arithmetic.
But in any case, this can (and should) be fixed even without IoView.
Besides that, nothing prevents us doing the same thing I did for gsp_write_ptr()
in the meantime to not break out of the firmware abstraction layer.
> This is guaranteed by the inability to update the CPU read pointer for
> as long as the slices exists.
Fair enough.
> Unless we decide to not trust the GSP, but that would be opening a whole
> new can of worms.
I thought about this as well, and I think it's fine. The safety comment within
the function has to justify why the device won't access the memory. If the
device does so regardless, it's simply a bug.
>> I don't want to merge any code that builds on top of this before we have sorted
>> this out.
>
> If what I have written above is correct, then the fix should simply be
> to use I/O projections to create properly-bounded references.
I still don't think we need I/O projections for a reasonable fix and I also
don't agree that we should keep UB until new features land.