Skip to content
Snippets Groups Projects
  1. Nov 27, 2024
    • Masahiro Yamada's avatar
      kbuild: change working directory to external module directory with M= · 13b25489
      Masahiro Yamada authored
      
      Currently, Kbuild always operates in the output directory of the kernel,
      even when building external modules. This increases the risk of external
      module Makefiles attempting to write to the kernel directory.
      
      This commit switches the working directory to the external module
      directory, allowing the removal of the $(KBUILD_EXTMOD)/ prefix from
      some build artifacts.
      
      The command for building external modules maintains backward
      compatibility, but Makefiles that rely on working in the kernel
      directory may break. In such cases, $(objtree) and $(srctree) should
      be used to refer to the output and source directories of the kernel.
      
      The appearance of the build log will change as follows:
      
      [Before]
      
        $ make -C /path/to/my/linux M=/path/to/my/externel/module
        make: Entering directory '/path/to/my/linux'
          CC [M]  /path/to/my/externel/module/helloworld.o
          MODPOST /path/to/my/externel/module/Module.symvers
          CC [M]  /path/to/my/externel/module/helloworld.mod.o
          CC [M]  /path/to/my/externel/module/.module-common.o
          LD [M]  /path/to/my/externel/module/helloworld.ko
        make: Leaving directory '/path/to/my/linux'
      
      [After]
      
        $ make -C /path/to/my/linux M=/path/to/my/externel/module
        make: Entering directory '/path/to/my/linux'
        make[1]: Entering directory '/path/to/my/externel/module'
          CC [M]  helloworld.o
          MODPOST Module.symvers
          CC [M]  helloworld.mod.o
          CC [M]  .module-common.o
          LD [M]  helloworld.ko
        make[1]: Leaving directory '/path/to/my/externel/module'
        make: Leaving directory '/path/to/my/linux'
      
      Printing "Entering directory" twice is cumbersome. This will be
      addressed later.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <n.schier@avm.de>
      13b25489
    • Linus Torvalds's avatar
      rust: fix up formatting after merge · 1dc707e6
      Linus Torvalds authored
      
      When I merged the rust 'use' imports, I didn't realize that there's
      an offical preferred idiomatic format - so while it all worked fine,
      it doesn't match what 'make rustfmt' wants to make it.
      
      Fix it up appropriately.
      
      Suggested-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1dc707e6
  2. Nov 24, 2024
  3. Nov 20, 2024
    • Miguel Ojeda's avatar
      rust: jump_label: skip formatting generated file · 8af7a501
      Miguel Ojeda authored
      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: 169484ab ("rust: add arch_static_branch")
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      8af7a501
  4. Nov 18, 2024
  5. Nov 11, 2024
  6. Nov 10, 2024
  7. Nov 05, 2024
  8. Nov 04, 2024
    • Alice Ryhl's avatar
      rust: add arch_static_branch · 169484ab
      Alice Ryhl authored
      To allow the Rust implementation of static_key_false to use runtime code
      patching instead of the generic implementation, pull in the relevant
      inline assembly from the jump_label.h header by running the C
      preprocessor on a .rs.S file. Build rules are added for .rs.S files.
      
      Since the relevant inline asm has been adjusted to export the inline asm
      via the ARCH_STATIC_BRANCH_ASM macro in a consistent way, the Rust side
      does not need architecture specific code to pull in the asm.
      
      It is not possible to use the existing C implementation of
      arch_static_branch via a Rust helper because it passes the argument
      `key` to inline assembly as an 'i' parameter. Any attempt to add a C
      helper for this function will fail to compile because the value of `key`
      must be known at compile-time.
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Jason Baron <jbaron@akamai.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Alex Gaynor <alex.gaynor@gmail.com>
      Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
      Cc: Gary Guo <gary@garyguo.net>
      Cc: " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " <bjorn3_gh@protonmail.com>
      Cc: Benno Lossin <benno.lossin@proton.me>
      Cc: Andreas Hindborg <a.hindborg@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Uros Bizjak <ubizjak@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Fuad Tabba <tabba@google.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Anup Patel <apatel@ventanamicro.com>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
      Cc: Conor Dooley <conor.dooley@microchip.com>
      Cc: Samuel Holland <samuel.holland@sifive.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: WANG Xuerui <kernel@xen0n.name>
      Cc: Bibo Mao <maobibo@loongson.cn>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Tianrui Zhao <zhaotianrui@loongson.cn>
      Link: https://lore.kernel.org/20241030-tracepoint-v12-5-eec7f0f8ad22@google.com
      
      
      Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Co-developed-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Reviewed-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      169484ab
    • Alice Ryhl's avatar
      rust: samples: add tracepoint to Rust sample · 91d39024
      Alice Ryhl authored
      This updates the Rust printing sample to invoke a tracepoint. This
      ensures that we have a user in-tree from the get-go even though the
      patch is being merged before its real user.
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Jason Baron <jbaron@akamai.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Alex Gaynor <alex.gaynor@gmail.com>
      Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
      Cc: Gary Guo <gary@garyguo.net>
      Cc: " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " <bjorn3_gh@protonmail.com>
      Cc: Benno Lossin <benno.lossin@proton.me>
      Cc: Andreas Hindborg <a.hindborg@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Uros Bizjak <ubizjak@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Fuad Tabba <tabba@google.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Anup Patel <apatel@ventanamicro.com>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
      Cc: Conor Dooley <conor.dooley@microchip.com>
      Cc: Samuel Holland <samuel.holland@sifive.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: WANG Xuerui <kernel@xen0n.name>
      Cc: Bibo Mao <maobibo@loongson.cn>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Tianrui Zhao <zhaotianrui@loongson.cn>
      Link: https://lore.kernel.org/20241030-tracepoint-v12-3-eec7f0f8ad22@google.com
      
      
      Reviewed-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      91d39024
    • Alice Ryhl's avatar
      rust: add tracepoint support · ad37bcd9
      Alice Ryhl authored
      Make it possible to have Rust code call into tracepoints defined by C
      code. It is still required that the tracepoint is declared in a C
      header, and that this header is included in the input to bindgen.
      
      Instead of calling __DO_TRACE directly, the exported rust_do_trace_
      function calls an inline helper function. This is because the `cond`
      argument does not exist at the callsite of DEFINE_RUST_DO_TRACE.
      
      __DECLARE_TRACE always emits an inline static and an extern declaration
      that is only used when CREATE_RUST_TRACE_POINTS is set. These should not
      end up in the final binary so it is not a problem that they sometimes
      are emitted without a user.
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Jason Baron <jbaron@akamai.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Alex Gaynor <alex.gaynor@gmail.com>
      Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
      Cc: " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " <bjorn3_gh@protonmail.com>
      Cc: Benno Lossin <benno.lossin@proton.me>
      Cc: Andreas Hindborg <a.hindborg@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Uros Bizjak <ubizjak@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Fuad Tabba <tabba@google.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Anup Patel <apatel@ventanamicro.com>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
      Cc: Conor Dooley <conor.dooley@microchip.com>
      Cc: Samuel Holland <samuel.holland@sifive.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: WANG Xuerui <kernel@xen0n.name>
      Cc: Bibo Mao <maobibo@loongson.cn>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Tianrui Zhao <zhaotianrui@loongson.cn>
      Link: https://lore.kernel.org/20241030-tracepoint-v12-2-eec7f0f8ad22@google.com
      
      
      Reviewed-by: default avatarCarlos Llamas <cmllamas@google.com>
      Reviewed-by: default avatarGary Guo <gary@garyguo.net>
      Reviewed-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ad37bcd9
    • Alice Ryhl's avatar
      rust: add static_branch_unlikely for static_key_false · 6e59bcc9
      Alice Ryhl authored
      Add just enough support for static key so that we can use it from
      tracepoints. Tracepoints rely on `static_branch_unlikely` with a `struct
      static_key_false`, so we add the same functionality to Rust.
      
      This patch only provides a generic implementation without code patching
      (matching the one used when CONFIG_JUMP_LABEL is disabled). Later
      patches add support for inline asm implementations that use runtime
      patching.
      
      When CONFIG_JUMP_LABEL is unset, `static_key_count` is a static inline
      function, so a Rust helper is defined for `static_key_count` in this
      case. If Rust is compiled with LTO, this call should get inlined. The
      helper can be eliminated once we have the necessary inline asm to make
      atomic operations from Rust.
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Jason Baron <jbaron@akamai.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Alex Gaynor <alex.gaynor@gmail.com>
      Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
      Cc: " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " <bjorn3_gh@protonmail.com>
      Cc: Benno Lossin <benno.lossin@proton.me>
      Cc: Andreas Hindborg <a.hindborg@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Uros Bizjak <ubizjak@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Fuad Tabba <tabba@google.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Anup Patel <apatel@ventanamicro.com>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
      Cc: Conor Dooley <conor.dooley@microchip.com>
      Cc: Samuel Holland <samuel.holland@sifive.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: WANG Xuerui <kernel@xen0n.name>
      Cc: Bibo Mao <maobibo@loongson.cn>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Tianrui Zhao <zhaotianrui@loongson.cn>
      Link: https://lore.kernel.org/20241030-tracepoint-v12-1-eec7f0f8ad22@google.com
      
      
      Reviewed-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Reviewed-by: default avatarGary Guo <gary@garyguo.net>
      Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      6e59bcc9
  9. Nov 01, 2024
  10. Oct 24, 2024
  11. Oct 22, 2024
  12. Oct 21, 2024
  13. Oct 15, 2024
Loading