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: <DBBOD5MK9FQ9.2ZOBX2ERFIE2S@kernel.org>
Date: Mon, 14 Jul 2025 11:36:29 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Dirk Behme" <dirk.behme@...bosch.com>
Cc: "Daniel Almeida" <daniel.almeida@...labora.com>, "Benno Lossin"
 <lossin@...nel.org>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
 <alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
 <gary@...yguo.net>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, "Andreas Hindborg" <a.hindborg@...nel.org>,
 "Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
 "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>, "Rafael J. Wysocki"
 <rafael@...nel.org>, "Thomas Gleixner" <tglx@...utronix.de>, "Bjorn
 Helgaas" <bhelgaas@...gle.com>, Krzysztof Wilczyński
 <kwilczynski@...nel.org>, <linux-kernel@...r.kernel.org>,
 <rust-for-linux@...r.kernel.org>, <linux-pci@...r.kernel.org>
Subject: Re: [PATCH v6 3/6] rust: irq: add support for non-threaded IRQs and
 handlers

On Mon Jul 14, 2025 at 9:57 AM CEST, Dirk Behme wrote:
> On 13/07/2025 16:19, Danilo Krummrich wrote:
>> On Sun Jul 13, 2025 at 4:09 PM CEST, Daniel Almeida wrote:
>>> On a second look, I wonder how useful this will be.
>>>
>>>  fn handle(&self, dev: &Device<Bound>) -> IrqReturn
>>>
>>> Sorry for borrowing this terminology, but here we offer Device<Bound>, while I
>>> suspect that most drivers will be looking for the most derived Device type
>>> instead. So for drm drivers this will be drm::Device, for example, not the base
>>> dev::Device type. I assume that this pattern will hold for other subsystems as
>>> well.
>>>
>>> Which brings me to my second point: drivers can store an ARef<drm::Device> on
>>> the handler itself, and I assume that the same will be possible in other
>>> subsystems.
>> 
>> Well, the whole point is that you can use a &Device<Bound> to directly access
>> device resources without any overhead, i.e.
>> 
>> 	fn handle(&self, dev: &Device<Bound>) -> IrqReturn {
>> 	   let io = self.iomem.access(dev);
>> 
>> 	   io.write32(...);
>
> As this is exactly the example I was discussing privately with Daniel
> (many thanks!), independent on the device discussion here, just for my
> understanding:
>
> Is it ok to do a 'self.iomem.access(dev)' at each interrupt?

Absolutely, Devres::access() is a very cheap accessor, see also [1]. Compiled
down, the only thing that Revocable::access() does is deriving a pointer from
another pointer by adding an offset.

That's exactly why we want the &Device<Bound> cookie, to avoid more expensive
operations.

[1] https://rust.docs.kernel.org/src/kernel/revocable.rs.html#151

> Wouldn't it
> be cheaper/faster to pass 'io' instead of 'iomem' to the interrupt handler?

Well, consider the types of the example:

	iomem: Devres<IoMem<SIZE>>
	io: &IoMem<Size>

You can't store a reference with a non-static lifetime in something with an
open-ended lifetime, such as the Handler object.

How would you ensure that the reference is still valid? The Devres<IoMem<SIZE>>
object might have been dropped already, either by the user or by Devres revoking
the inner object due to device unbind.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ