From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
kernel test robot <lkp@intel.com>,
Alice Ryhl <aliceryhl@google.com>,
Miguel Ojeda <ojeda@kernel.org>
Subject: [for-next][PATCH 1/2] jump_label: rust: pass a mut ptr to `static_key_count`
Date: Wed, 20 Nov 2024 21:12:27 -0500 [thread overview]
Message-ID: <20241121021257.192412005@goodmis.org> (raw)
In-Reply-To: <20241121021226.575757843@goodmis.org>
From: Alice Ryhl <aliceryhl@google.com>
When building the rust_print sample with CONFIG_JUMP_LABEL=n, the Rust
static key support falls back to using static_key_count. This function
accepts a mutable pointer to the `struct static_key`, but the Rust
abstractions are incorrectly passing a const pointer.
This means that builds using CONFIG_JUMP_LABEL=n and SAMPLE_RUST_PRINT=y
fail with the following error message:
error[E0308]: mismatched types
--> <root>/samples/rust/rust_print_main.rs:87:5
|
87 | / kernel::declare_trace! {
88 | | /// # Safety
89 | | ///
90 | | /// Always safe to call.
91 | | unsafe fn rust_sample_loaded(magic: c_int);
92 | | }
| | ^
| | |
| |_____types differ in mutability
| arguments to this function are incorrect
|
= note: expected raw pointer `*mut kernel::bindings::static_key`
found raw pointer `*const kernel::bindings::static_key`
note: function defined here
--> <root>/rust/bindings/bindings_helpers_generated.rs:33:12
|
33 | pub fn static_key_count(key: *mut static_key) -> c_int;
| ^^^^^^^^^^^^^^^^
To fix this, insert a pointer cast so that the pointer is mutable.
Link: https://lore.kernel.org/20241118202727.73646-1-aliceryhl@google.com
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202411181440.qEdcuyh6-lkp@intel.com/
Fixes: 169484ab6677 ("rust: add arch_static_branch")
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
rust/kernel/jump_label.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/jump_label.rs b/rust/kernel/jump_label.rs
index 2f2df03a3275..b5aff632ecc7 100644
--- a/rust/kernel/jump_label.rs
+++ b/rust/kernel/jump_label.rs
@@ -26,7 +26,7 @@ macro_rules! static_branch_unlikely {
#[cfg(not(CONFIG_JUMP_LABEL))]
{
- $crate::bindings::static_key_count(_key) > 0
+ $crate::bindings::static_key_count(_key.cast_mut()) > 0
}
#[cfg(CONFIG_JUMP_LABEL)]
--
2.45.2
next prev parent reply other threads:[~2024-11-21 2:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 2:12 [for-next][PATCH 0/2] tracincg/rust: Last minute updates for v6.13 Steven Rostedt
2024-11-21 2:12 ` Steven Rostedt [this message]
2024-11-21 2:12 ` [for-next][PATCH 2/2] rust: jump_label: skip formatting generated file Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241121021257.192412005@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=ojeda@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®