[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <874j1q1umv.fsf@kernel.org>
Date: Wed, 22 Jan 2025 21:06:00 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Petr Pavlu" <petr.pavlu@...e.com>
Cc: "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>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Masahiro Yamada" <masahiroy@...nel.org>, "Nathan Chancellor"
<nathan@...nel.org>, "Nicolas Schier" <nicolas@...sle.eu>, "Luis
Chamberlain" <mcgrof@...nel.org>, "Trevor Gross" <tmgross@...ch.edu>,
"Adam Bratschi-Kaye" <ark.email@...il.com>,
<rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-kbuild@...r.kernel.org>, "Sami Tolvanen"
<samitolvanen@...gle.com>, "Daniel Gomez" <da.gomez@...sung.com>,
"Simona Vetter" <simona.vetter@...ll.ch>, "Greg KH"
<gregkh@...uxfoundation.org>, <linux-modules@...r.kernel.org>
Subject: Re: [PATCH v4 4/4] rust: add parameter support to the `module!` macro
"Petr Pavlu" <petr.pavlu@...e.com> writes:
> On 1/9/25 11:54, Andreas Hindborg wrote:
>> This patch includes changes required for Rust kernel modules to utilize
>> module parameters. This code implements read only support for integer
>> types without `sysfs` support.
>>
[cut]
>> +
>> + // SAFETY: `old_value` is valid for writes, as we have exclusive
>> + // access. `old_value` is pointing to an initialized static, an
>
> Typo: an -> and
Thanks.
[cut]
>> +
>> + fn emit_params(&mut self, info: &ModuleInfo) {
>> + let Some(params) = &info.params else {
>> + return;
>> + };
>> +
>> + for param in params {
>> + let ops = param_ops_path(¶m.ptype);
>> +
>> + // Note: The spelling of these fields is dictated by the user space
>> + // tool `modinfo`.
>> + self.emit_param("parmtype", ¶m.name, ¶m.ptype);
>> + self.emit_param("parm", ¶m.name, ¶m.description);
>> +
>> + write!(
>> + self.param_buffer,
>> + "
>> + pub(crate) static {param_name}:
>> + ::kernel::module_param::ModuleParamAccess<{param_type}> =
>> + ::kernel::module_param::ModuleParamAccess::new({param_default});
>> +
>> + #[link_section = \"__param\"]
>> + #[used]
>> + static __{module_name}_{param_name}_struct:
>> + ::kernel::module_param::RacyKernelParam =
>> + ::kernel::module_param::RacyKernelParam(::kernel::bindings::kernel_param {{
>> + name: if cfg!(MODULE) {{
>> + c\"{module_name}.{param_name}\"
>> + }} else {{
>> + c\"{param_name}\"
>> + }}.as_ptr(),
>
> This should be the other way around? Running
> 'insmod rust_minimal.ko test_parameter=2' reports for me that the
> parameter is unknown while specifying 'rust_minimal.test_parameter=2'
> works. The prefix should be used only if the module is built-in so the
> parameter can be distinguished on the kernel command line.
Thanks for testing! This actually gave me quite a headache when I was
using the series elsewhere. I forgot to resend the series with the fix,
sorry.
Best regards,
Andreas Hindborg
Powered by blists - more mailing lists