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: <aIXUnsZao-7Xs5XM@google.com>
Date: Sun, 27 Jul 2025 07:26:22 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Lyude Paul <lyude@...hat.com>, rust-for-linux@...r.kernel.org, 
	Thomas Gleixner <tglx@...utronix.de>, Boqun Feng <boqun.feng@...il.com>, linux-kernel@...r.kernel.org, 
	Andreas Hindborg <a.hindborg@...nel.org>, FUJITA Tomonori <fujita.tomonori@...il.com>, 
	Frederic Weisbecker <frederic@...nel.org>, Anna-Maria Behnsen <anna-maria@...utronix.de>, 
	John Stultz <jstultz@...gle.com>, Stephen Boyd <sboyd@...nel.org>, Miguel Ojeda <ojeda@...nel.org>, 
	Alex Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>, 
	"Björn Roy Baron" <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>, 
	Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>
Subject: Re: [PATCH 2/2] rust: time: Implement basic arithmetic operations for Delta

On Fri, Jul 25, 2025 at 10:20:08AM +0900, Alexandre Courbot wrote:
> On Fri Jul 25, 2025 at 3:54 AM JST, Lyude Paul wrote:
> > While rvkms is only going to be using a few of these, since Deltas are
> > basically the same as i64 it's easy enough to just implement all of the
> > basic arithmetic operations for Delta types.
> >
> > Note that for division and remainders, we currently limit these operations
> > to CONFIG_64BIT as u64 / u64 and u64 % u64 is not supported on all 32 bit
> > platforms natively. The correct solution we want to aim for here in the
> > future is to use the kernel's math library for performing these operations
> > so they're emulated on 32 bit platforms.
> >
> > Signed-off-by: Lyude Paul <lyude@...hat.com>
> > ---
> >  rust/kernel/time.rs | 86 +++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 86 insertions(+)
> >
> > diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
> > index ac5cab62070c6..8ece5a5d5a11b 100644
> > --- a/rust/kernel/time.rs
> > +++ b/rust/kernel/time.rs
> > @@ -251,6 +251,92 @@ pub struct Delta {
> >      nanos: i64,
> >  }
> >  
> > +impl ops::Add for Delta {
> > +    type Output = Self;
> > +
> > +    fn add(self, rhs: Self) -> Self {
> > +        Self {
> > +            nanos: self.nanos + rhs.nanos,
> 
> Should we use saturating ops here as well?

I'm not so sure ... I think it is useful for + to have the same meaning
always, and that meaning is "addition where overflow is a bug".

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ