lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLggSET--eSW=rA_hw2jAyAO6_fa82gm0X3qeanXEvmZscA@mail.gmail.com>
Date: Thu, 23 Jan 2025 10:07:28 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Boqun Feng <boqun.feng@...il.com>
Cc: Daniel Almeida <daniel.almeida@...labora.com>, ojeda@...nel.org, alex.gaynor@...il.com, 
	gary@...yguo.net, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me, 
	a.hindborg@...nel.org, tmgross@...ch.edu, rust-for-linux@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] rust: irq: add support for request_irq()

On Thu, Jan 23, 2025 at 8:18 AM Boqun Feng <boqun.feng@...il.com> wrote:
>
> On Wed, Jan 22, 2025 at 01:39:30PM -0300, Daniel Almeida wrote:
> > Add support for registering IRQ handlers in Rust.
> >
> > IRQ handlers are extensively used in drivers when some peripheral wants to
> > obtain the CPU attention. Registering a handler will make the system invoke the
> > passed-in function whenever the chosen IRQ line is triggered.
> >
> > Both regular and threaded IRQ handlers are supported through a Handler (or
> > ThreadedHandler) trait that is meant to be implemented by a type that:
> >
> > a) provides a function to be run by the system when the IRQ fires and,
> >
> > b) holds the shared data (i.e.: `T`) between process and IRQ contexts.
> >
> > The requirement that T is Sync derives from the fact that handlers might run
> > concurrently with other processes executing the same driver, creating the
> > potential for data races.
> >
> > Ideally, some interior mutability must be in place if T is to be mutated. This
> > should usually be done through the in-flight SpinLockIrq type.
> >
> > Co-developed-by: Alice Ryhl <aliceryhl@...gle.com>
> > Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> > Signed-off-by: Daniel Almeida <daniel.almeida@...labora.com>
> > ---
> >
> > Changes from v1:
> >
> > - Added Co-developed-by tag to account for the work that Alice did in order to
> > figure out how to do this without Opaque<T> (Thanks!)
> > - Removed Opaque<T> in favor of plain T
>
> Hmmm...
>
> [...]
>
> > +#[pin_data(PinnedDrop)]
> > +pub struct Registration<T: Handler> {
> > +    irq: u32,
> > +    #[pin]
> > +    handler: T,
>
> I think you still need to make `handler` as `!Unpin` because compilers
> can assume a `&mut T` from a `Pin<&mut Registration>`, am I missing
> something here?

The current version operates under the assumption that PhantomPinned
is enough. But I'm happy to add Aliased here.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ