[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_-Nh_dDifS1lvOD@pollux>
Date: Wed, 16 Apr 2025 12:59:19 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Danilo Krummrich <dakr@...hat.com>, 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>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
linux-pm@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>,
Stephen Boyd <sboyd@...nel.org>, Nishanth Menon <nm@...com>,
rust-for-linux@...r.kernel.org,
Manos Pitsidianakis <manos.pitsidianakis@...aro.org>,
Alex Bennée <alex.bennee@...aro.org>,
Joakim Bech <joakim.bech@...aro.org>, Rob Herring <robh@...nel.org>,
Yury Norov <yury.norov@...il.com>, Burak Emir <bqe@...gle.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Russell King <linux@...linux.org.uk>, linux-clk@...r.kernel.org,
Michael Turquette <mturquette@...libre.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH V10 13/15] rust: cpufreq: Extend abstractions for driver
registration
On Wed, Apr 16, 2025 at 03:47:26PM +0530, Viresh Kumar wrote:
> On 16-04-25, 11:04, Danilo Krummrich wrote:
> > You need to justify why drv is a valid pointer to be passed to
> > cpufreq_register_driver(), i.e. something like
> >
> > // SAFETY:
> > // - `drv` comes from Self::VTABLE and hence is a valid pointer to a `struct cpufreq_driver`,
> > // - `cpufreq_register_driver()` never attempts to modify the data `drv` points to
>
> The cpufreq core can try to change the data pointed by `drv`. For now
> it updates the `cpufreq_driver->boost_enabled` flag.
VTABLE is const and hence ends up in the read-only section of the binary.
I assumed that struct cpufreq_driver (like most driver structures) is const.
Actually, I think it should be.
Anyways, that doesn't help for now. Unfortunately, I think you actually need to
dynamically allocate it. There's no need to revert everything though. You can
just allocate a new KBox from VTABLE, i.e.
let vtable = KBox::new(Self::VTABLE, GFP_KERNEL)?;
This makes it easy for you to remove the dynamic allocation once (or if) cpufreq
is ever reworked to allow a static const struct cpufreq_driver.
Powered by blists - more mailing lists