From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1826F1B6CE0; Wed, 22 Jan 2025 20:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737576376; cv=none; b=NzYtfFbwvJ550vkakpUQLRAlexz+PziF1KMPY/GMQlvQVt7dWzlflsKZlUupsuFduujIyIJxO9ngJAUwC6rfYw9y26rPLQcGxmkxZ5R8OT4nYX8YxCXiqhDg8m3zgOPYMk02AcOy/uBcFfLyaIbIhvCregTqtwPNI55kn9oMsds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737576376; c=relaxed/simple; bh=S5TTnFvAJPPSSH0AY88qF4Q33YOQ5/7GfsUezm6tuHY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=JrNbO0RBBKfs73+CErdEqWcjUnBYbEVIVGEmGJ9AD+rTfV+8ckTVna1uIuhxP6OdYAJf892CKbcCJzNypp/tRvRbLwN51mEWb3MaL67Xi79iD6L3N8V8FwhPx8/SkQnZFCO5lNqHM0qUhMomwCVXCa9ouVWShhexIyP0ctr3ahM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EjJcG2Z6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EjJcG2Z6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60920C4CED2; Wed, 22 Jan 2025 20:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737576374; bh=S5TTnFvAJPPSSH0AY88qF4Q33YOQ5/7GfsUezm6tuHY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=EjJcG2Z66JJlh9mImcdD7SeVperH0zRWeaXzqZx1y6HpMbv1EuJrfAseTFRTFDRT2 4dYZddDKMnsHPfAciwhrI7Dyg6Z44Nui6JWwBW2wHtIXNsM6LmStoIHbJQ9MGIULl8 n7h5ok6ypAzMIhbHd2PI5OhNje8S4XYwimGLiEFJt5+mbe5Q9gDhAc7t0UuaYhoOvc 9nROdsYl2QPbFD07pMAXXMJ9+rfL+91nTQlHTaAh7nG7ibDhsv+L5uUtdrfuNDCzu5 Sj9bQmSd1Lp/1D55sHm2N2NZBdrTIPU+2gjgs+QPkxZfynS4N9htgdrwu3PGRCCeBg ZFqyDsmQGqgdg== From: Andreas Hindborg To: "Petr Pavlu" Cc: "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , "Benno Lossin" , "Alice Ryhl" , "Masahiro Yamada" , "Nathan Chancellor" , "Nicolas Schier" , "Luis Chamberlain" , "Trevor Gross" , "Adam Bratschi-Kaye" , , , , "Sami Tolvanen" , "Daniel Gomez" , "Simona Vetter" , "Greg KH" , Subject: Re: [PATCH v4 4/4] rust: add parameter support to the `module!` macro In-Reply-To: <04419f26-1411-4e47-a0f0-f774064bc2f0@suse.com> (Petr Pavlu's message of "Wed, 22 Jan 2025 17:01:32 +0100") References: <20250109-module-params-v3-v4-0-c208bcfbe11f@kernel.org> <20250109-module-params-v3-v4-4-c208bcfbe11f@kernel.org> <04419f26-1411-4e47-a0f0-f774064bc2f0@suse.com> User-Agent: mu4e 1.12.7; emacs 29.4 Date: Wed, 22 Jan 2025 21:06:00 +0100 Message-ID: <874j1q1umv.fsf@kernel.org> Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Petr Pavlu" 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