[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011
From: |
Manos Pitsidianakis |
Subject: |
Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011 |
Date: |
Thu, 25 Jul 2024 17:48:04 +0300 |
On Thu, 25 Jul 2024 at 14:19, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On Thu, Jul 25, 2024 at 12:14 PM Manos Pitsidianakis
> <manos.pitsidianakis@linaro.org> wrote:
> > >Unfortunately that's a *mut, not a &mut. A &mut must be unique, so the cast
> > >in pl011_read() is undefined behavior.
> >
> > Actually it's:
> >
> > unsafe { qemu_chr_fe_accept_input(&mut self.char_backend) };
> >
> > And you can ensure there's no disjoint borrowing by making a wrapper
> > function that mutably borrows self, e.g.
> >
> > fn accept_input(&mut self) {
> > unsafe { qemu_chr_fe_accept_input(&mut self.char_backend) };
> > }
> >
> > This is not undefined behavior, since the cast in pl011_read creates a
> > mutable reference that does not outlive the same call to pl011_read.
>
> pl011_receive (called by qemu_chr_fe_accept_input) creates a mutable
> reference that *overlaps* the lifetime of the outer reference created
> by pl011_read. This is undefined behavior. You're effectively writing:
There is no overlap there, sorry. Once qemu_chr_fe_accept_input
returns, any references it created do not exist anymore.
- [RFC PATCH v5 8/8] rust/pl011: vendor dependencies, (continued)
- [RFC PATCH v5 8/8] rust/pl011: vendor dependencies, Manos Pitsidianakis, 2024/07/22
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/23
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/24
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/24
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/25
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/25
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/25
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/25
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011,
Manos Pitsidianakis <=
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/25
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/26
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/26
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/26
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/31
- Re: [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011, Paolo Bonzini, 2024/07/31