-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
volatile_memory: add VolatileArrayRef and &std::sync::atomic::Atomic* accessors #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Paolo,
I was just wondering, is there any fundamental reason why we should have both VolatileSlice
and VolatileArrayRef
? Right now, it seems VolatileSlice
basically corresponds to a byte slice, whereas VolatileArrayRef
behaves like a slice of some type T
. Does VolatileArrayRef
still make sense if we parametrize VolatileSlice<T>
? We can implement the common functionality in VolatileSlice<T>
, and move all methods that only make sense for a byte slice in an impl VolatileSlice<u8> { ... }
or something along those lines.
That's an interesting idea. I will take a look. |
748191a
to
aadfb54
Compare
The main obstacle here is that |
9dd2e06
to
b1d3736
Compare
57503c3
to
6993adc
Compare
A VolatileRef is essentially a pointer. It can be copied or cloned as the lifetime of the copies will be the same. Clippy says that, now that VolatileRef is Copy, we should pass it by value because it is small enough to be more efficient to always do so; obey. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Allow easily access to an array stored in a VolatileMemory object, removing the need to do multiplications and pointer offsetting. It also generalizes the existing methods copy_to and copy_from in VolatileSlice. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This allows writing safely drivers that access memory concurrently with the guest and that require memory barriers between DMA accesses. I'm adding a feature for AtomicU* types because they were only stabilized in Rust 1.34.0. Fixes: rust-vmm#16 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Allow easily access to an array stored in a VolatileMemory object, removing
the need to do multiplications and pointer offsetting.