mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [for-next][PATCH 0/2] tracincg/rust: Last minute updates for v6.13
@ 2024-11-21  2:12 Steven Rostedt
  2024-11-21  2:12 ` [for-next][PATCH 1/2] jump_label: rust: pass a mut ptr to `static_key_count` Steven Rostedt
  2024-11-21  2:12 ` [for-next][PATCH 2/2] rust: jump_label: skip formatting generated file Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-11-21  2:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton

  git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
rust/for-next

Head SHA1: 8af7a50167833b6b22e30c008bbf95ab3ff1a5fb


Alice Ryhl (1):
      jump_label: rust: pass a mut ptr to `static_key_count`

Miguel Ojeda (1):
      rust: jump_label: skip formatting generated file

----
 rust/Makefile                                                       | 4 ++--
 rust/kernel/.gitignore                                              | 2 +-
 ...static_branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} | 0
 rust/kernel/jump_label.rs                                           | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)
 rename rust/kernel/{arch_static_branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} (100%)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [for-next][PATCH 1/2] jump_label: rust: pass a mut ptr to `static_key_count`
  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
  2024-11-21  2:12 ` [for-next][PATCH 2/2] rust: jump_label: skip formatting generated file Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-11-21  2:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
	kernel test robot, Alice Ryhl, Miguel Ojeda

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [for-next][PATCH 2/2] rust: jump_label: skip formatting generated file
  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 ` [for-next][PATCH 1/2] jump_label: rust: pass a mut ptr to `static_key_count` Steven Rostedt
@ 2024-11-21  2:12 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-11-21  2:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Miguel Ojeda

From: Miguel Ojeda <ojeda@kernel.org>

After a source tree build of the kernel, and having used the `RSCPP`
rule, running `rustfmt` fails with:

    error: macros that expand to items must be delimited with braces or followed by a semicolon
     --> rust/kernel/arch_static_branch_asm.rs:1:27
      |
    1 | ...ls!("1: jmp " ... ".popsection \n\t")
      |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
    help: change the delimiters to curly braces
      |
    1 | ::kernel::concat_literals!{"1: jmp " ... ".popsection \n\t"}
      |                           ~                                ~
    help: add a semicolon
      |
    1 | ::kernel::concat_literals!("1: jmp " ... ".popsection \n\t");
      |                                                             +

This file is not meant to be formatted nor works on its own since it is
meant to be textually included.

Thus skip formatting it by prefixing its name with `generated_`.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alex Gaynor <alex.gaynor@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Gary Guo <gary@garyguo.net>
Cc: Björn Roy Baron <bjorn3_gh@protonmail.com>
Cc: Benno Lossin <benno.lossin@proton.me>
Cc: Andreas Hindborg <a.hindborg@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Trevor Gross <tmgross@umich.edu>
Link: https://lore.kernel.org/20241120175916.58860-1-ojeda@kernel.org
Fixes: 169484ab6677 ("rust: add arch_static_branch")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 rust/Makefile                                                 | 4 ++--
 rust/kernel/.gitignore                                        | 2 +-
 ..._branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} | 0
 rust/kernel/jump_label.rs                                     | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
 rename rust/kernel/{arch_static_branch_asm.rs.S => generated_arch_static_branch_asm.rs.S} (100%)

diff --git a/rust/Makefile b/rust/Makefile
index bc2a9071dd29..99db963637e6 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -36,7 +36,7 @@ always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
 obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o
 obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o
 
-always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/arch_static_branch_asm.rs
+always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/generated_arch_static_branch_asm.rs
 
 # Avoids running `$(RUSTC)` for the sysroot when it may not be available.
 ifdef CONFIG_RUST
@@ -427,7 +427,7 @@ $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/alloc.o $(obj)/build_error.o \
 	+$(call if_changed_rule,rustc_library)
 
 ifdef CONFIG_JUMP_LABEL
-$(obj)/kernel.o: $(obj)/kernel/arch_static_branch_asm.rs
+$(obj)/kernel.o: $(obj)/kernel/generated_arch_static_branch_asm.rs
 endif
 
 endif # CONFIG_RUST
diff --git a/rust/kernel/.gitignore b/rust/kernel/.gitignore
index d082731007c6..6ba39a178f30 100644
--- a/rust/kernel/.gitignore
+++ b/rust/kernel/.gitignore
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 
-/arch_static_branch_asm.rs
+/generated_arch_static_branch_asm.rs
diff --git a/rust/kernel/arch_static_branch_asm.rs.S b/rust/kernel/generated_arch_static_branch_asm.rs.S
similarity index 100%
rename from rust/kernel/arch_static_branch_asm.rs.S
rename to rust/kernel/generated_arch_static_branch_asm.rs.S
diff --git a/rust/kernel/jump_label.rs b/rust/kernel/jump_label.rs
index b5aff632ecc7..4e974c768dbd 100644
--- a/rust/kernel/jump_label.rs
+++ b/rust/kernel/jump_label.rs
@@ -39,7 +39,7 @@ macro_rules! static_branch_unlikely {
 #[cfg(CONFIG_JUMP_LABEL)]
 const _: &str = include!(concat!(
     env!("OBJTREE"),
-    "/rust/kernel/arch_static_branch_asm.rs"
+    "/rust/kernel/generated_arch_static_branch_asm.rs"
 ));
 
 #[macro_export]
@@ -48,7 +48,7 @@ macro_rules! static_branch_unlikely {
 macro_rules! arch_static_branch {
     ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: {
         $crate::asm!(
-            include!(concat!(env!("OBJTREE"), "/rust/kernel/arch_static_branch_asm.rs"));
+            include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_static_branch_asm.rs"));
             l_yes = label {
                 break 'my_label true;
             },
-- 
2.45.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-21  2:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [for-next][PATCH 1/2] jump_label: rust: pass a mut ptr to `static_key_count` Steven Rostedt
2024-11-21  2:12 ` [for-next][PATCH 2/2] rust: jump_label: skip formatting generated file Steven Rostedt

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®