Skip to content

[PW_SID:1098362] riscv: Implement _THIS_IP_ using inline asm#1986

Closed
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1098362
Closed

[PW_SID:1098362] riscv: Implement _THIS_IP_ using inline asm#1986
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1098362

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1098362 applied to workflow__riscv__fixes

Name: riscv: Implement THIS_IP using inline asm
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1098362
Version: 1

Both GCC [1] and Clang [2] consider the generic version of _THIS_IP_ to
be broken:

        #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })

In particular, the address of a label is only expected to be used with a
computed goto.

While the generic version more or less works today, it is known to be
brittle and may break with current and future optimizations. For
example, Clang -O2 always returns 1 when this function is inlined:

        static inline unsigned long get_ip(void)
        { return ({ __label__ __here; __here: (unsigned long)&&__here; }); }

Fix it by overriding _THIS_IP_ in <asm/linkage.h> (which is included by
<linux/instruction_pointer.h>) using an architecture-specific inline asm
version. Additionally, avoiding taking the address of a label prevents
compilers from emitting spurious indirect branch targets (e.g. ENDBR or
BTI) under control-flow integrity schemes.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120071 [1]
Link: llvm/llvm-project#138272 [2]
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 113.53 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 2224.67 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2988.37 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 76.47 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
kdoc
Desc: Detects for kdoc errors
Duration: 0.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
module-param
Desc: Detect module_param changes
Duration: 0.39 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: Implement THIS_IP using inline asm"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1098362 branch May 21, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants