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: <20240815082916.1210110-4-pierre.gondois@arm.com>
Date: Thu, 15 Aug 2024 10:29:07 +0200
From: Pierre Gondois <pierre.gondois@....com>
To: linux-kernel@...r.kernel.org
Cc: Pierre Gondois <pierre.gondois@....com>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Len Brown <lenb@...nel.org>,
	Viresh Kumar <viresh.kumar@...aro.org>,
	Robert Moore <robert.moore@...el.com>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Wedson Almeida Filho <wedsonaf@...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@...sung.com>,
	Alice Ryhl <aliceryhl@...gle.com>,
	Martin Rodriguez Reboredo <yakoyoku@...il.com>,
	Asahi Lina <lina@...hilina.net>,
	Danilo Krummrich <dakr@...hat.com>,
	"Rob Herring (Arm)" <robh@...nel.org>,
	FUJITA Tomonori <fujita.tomonori@...il.com>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	Manos Pitsidianakis <manos.pitsidianakis@...aro.org>,
	Thomas Bertschinger <tahbertschinger@...il.com>,
	linux-acpi@...r.kernel.org,
	linux-pm@...r.kernel.org,
	acpica-devel@...ts.linux.dev,
	rust-for-linux@...r.kernel.org
Subject: [RFC PATCH 3/6] rust: module: Allow modules to specify initcall section

To give more flexibility to modules regarding their initialization,
add an `initcall` field allowing to specify the initicall section
their initialization function belongs to.

Signed-off-by: Pierre Gondois <pierre.gondois@....com>
---
 rust/macros/module.rs | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index be03b2cf77a1..8724738f2a52 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -97,14 +97,22 @@ struct ModuleInfo {
     author: Option<String>,
     description: Option<String>,
     alias: Option<Vec<String>>,
+    initcall: Option<String>,
 }
 
 impl ModuleInfo {
     fn parse(it: &mut token_stream::IntoIter) -> Self {
         let mut info = ModuleInfo::default();
 
-        const EXPECTED_KEYS: &[&str] =
-            &["type", "name", "author", "description", "license", "alias"];
+        const EXPECTED_KEYS: &[&str] = &[
+            "type",
+            "name",
+            "author",
+            "description",
+            "license",
+            "alias",
+            "initcall",
+        ];
         const REQUIRED_KEYS: &[&str] = &["type", "name", "license"];
         let mut seen_keys = Vec::new();
 
@@ -131,6 +139,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {
                 "description" => info.description = Some(expect_string(it)),
                 "license" => info.license = expect_string_ascii(it),
                 "alias" => info.alias = Some(expect_string_array(it)),
+                "initcall" => info.initcall = Some(expect_string(it)),
                 _ => panic!(
                     "Unknown key \"{}\". Valid keys are: {:?}.",
                     key, EXPECTED_KEYS
@@ -187,6 +196,12 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
         }
     }
 
+    let initcall_section = if let Some(section) = info.initcall {
+        section
+    } else {
+        String::from(".initcall6.init")
+    };
+
     // Built-in modules also export the `file` modinfo string.
     let file =
         std::env::var("RUST_MODFILE").expect("Unable to fetch RUST_MODFILE environmental variable");
@@ -335,7 +350,7 @@ unsafe fn __exit() {{
         type_ = info.type_,
         name = info.name,
         modinfo = modinfo.buffer,
-        initcall_section = ".initcall6.init"
+        initcall_section = initcall_section,
     )
     .parse()
     .expect("Error parsing formatted string into token stream.")
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ