Rust for Linux List
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: "Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
	"Kees Cook" <kees@kernel.org>, "Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Russell King" <linux@armlinux.org.uk>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Madhavan Srinivasan" <maddy@linux.ibm.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"WANG Xuerui" <kernel@xen0n.name>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Christophe Leroy" <chleroy@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, linux-mm@kvack.org,
	linux-um@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev,
	linux-s390@vger.kernel.org, linux-mips@vger.kernel.org,
	rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org,
	"Jan Stancek" <jstancek@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>,
	"Alexandre Ghiti" <alexghiti@rivosinc.com>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: [PATCH v5 18/24] riscv: vdso: Enable the vdsocheck tool
Date: Tue, 08 Sep 2026 08:33:52 +0200	[thread overview]
Message-ID: <20260908-vdso-absolute-reloc-v5-18-3a93791af1cf@linutronix.de> (raw)
In-Reply-To: <20260908-vdso-absolute-reloc-v5-0-3a93791af1cf@linutronix.de>

The vdsocheck tool validates the object files and final .so library.
It can detect if the compiler created relocations which are incompatible
with the vDSO which need to be worked around.

Wire it up for the architecture.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 arch/riscv/Kconfig              |  1 +
 arch/riscv/kernel/vdso/Makefile |  4 ++--
 lib/vdso/check/vdsocheck.rs     | 26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index f8e26c4bed2b..f580d2afecf7 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -229,6 +229,7 @@ config RISCV
 	select THREAD_INFO_IN_TASK
 	select TRACE_IRQFLAGS_SUPPORT
 	select UACCESS_MEMCPY if !MMU
+	select VDSO_CHECK if MMU
 	select VDSO_DATASTORE if MMU
 	select VDSO_GETRANDOM if MMU && 64BIT
 	select USER_STACKTRACE_SUPPORT
diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index 8dbf2532a573..7e707fdff26c 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -74,7 +74,7 @@ endif
 $(obj)/$(vdso_o): $(obj)/$(vdso_so)
 
 # link rule for the .so file, .lds has to be first
-$(obj)/$(vdso_so_dbg): $(obj)/$(vdso_lds) $(obj-vdso) FORCE
+$(obj)/$(vdso_so_dbg): $(obj)/$(vdso_lds) $(obj-vdso) $(vdsocheck) FORCE
 	$(call if_changed,vdsold_and_check)
 LDFLAGS_$(vdso_so_dbg) = -shared -soname=linux-vdso.so.1 \
 	--build-id=sha1 --eh-frame-hdr
@@ -96,7 +96,7 @@ include/generated/$(vdso_offsets): $(obj)/$(vdso_so_dbg) FORCE
 # The DSO images are built using a special linker script
 # Make sure only to export the intended __vdso_xxx symbol offsets.
 quiet_cmd_vdsold_and_check = VDSOLD  $@
-      cmd_vdsold_and_check = $(LD) $(CFI_FULL) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
+      cmd_vdsold_and_check = $(LD) $(CFI_FULL) $(ld_flags) -T $(filter-out FORCE $(vdsocheck),$^) -o $@.tmp && \
                    $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
                    rm $@.tmp && \
                    $(cmd_vdso_check)
diff --git a/lib/vdso/check/vdsocheck.rs b/lib/vdso/check/vdsocheck.rs
index 429bdcd65818..67562d21f877 100644
--- a/lib/vdso/check/vdsocheck.rs
+++ b/lib/vdso/check/vdsocheck.rs
@@ -96,6 +96,32 @@ fn allowed_relocations_for_machine(machine: u16) -> Option<AllowedRelocations<'s
             ..Default::default()
         }
         .into(),
+        bindings::EM_RISCV => AllowedRelocations {
+            in_object_file: &[
+                bindings::R_RISCV_BRANCH,
+                bindings::R_RISCV_JAL,
+                bindings::R_RISCV_CALL,
+                bindings::R_RISCV_CALL_PLT,
+                bindings::R_RISCV_PCREL_HI20,
+                bindings::R_RISCV_PCREL_LO12_I,
+                bindings::R_RISCV_PCREL_LO12_S,
+                bindings::R_RISCV_ADD8,
+                bindings::R_RISCV_ADD16,
+                bindings::R_RISCV_ADD32,
+                bindings::R_RISCV_ADD64,
+                bindings::R_RISCV_SUB8,
+                bindings::R_RISCV_SUB16,
+                bindings::R_RISCV_SUB32,
+                bindings::R_RISCV_SUB64,
+                bindings::R_RISCV_ALIGN,
+                bindings::R_RISCV_RVC_BRANCH,
+                bindings::R_RISCV_RVC_JUMP,
+                bindings::R_RISCV_RELAX,
+                bindings::R_RISCV_32_PCREL,
+            ],
+            ..Default::default()
+        }
+        .into(),
         _ => None,
     }
 }

-- 
2.55.0


  parent reply	other threads:[~2026-09-08  6:34 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  6:33 [PATCH v5 00/24] vdso: Reject absolute relocations during build Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 01/24] elf, uapi: Add a header for relocation constants Thomas Weißschuh
2026-09-08  9:00   ` Christophe Leroy (CS GROUP)
2026-09-10  6:31   ` Mukesh Kumar Chaurasiya
2026-09-08  6:33 ` [PATCH v5 02/24] x86/elf, um/x86/elf: Move relocation constants to UAPI Thomas Weißschuh
2026-09-08 13:55   ` Borislav Petkov
2026-09-08 14:26     ` Thomas Weißschuh
2026-09-08 15:12       ` Borislav Petkov
2026-09-09  5:59         ` Thomas Weißschuh
2026-09-09 14:49           ` Borislav Petkov
2026-09-09 19:27             ` H. Peter Anvin
2026-09-09 19:47               ` Borislav Petkov
2026-09-10  8:33             ` Thomas Weißschuh
2026-09-08 14:32     ` Christophe Leroy (CS GROUP)
2026-09-08  6:33 ` [PATCH v5 03/24] ARM: elf: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 04/24] arm64: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 05/24] powerpc/elf: " Thomas Weißschuh
2026-09-08  9:02   ` Christophe Leroy (CS GROUP)
2026-09-08 14:01   ` R Nageswara Sastry
2026-09-10  6:30   ` Mukesh Kumar Chaurasiya
2026-09-08  6:33 ` [PATCH v5 06/24] riscv: elf: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 07/24] LoongArch: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 08/24] s390/elf: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 09/24] MIPS: ELF: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 10/24] sparc: elf: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 11/24] tools headers UAPI: Sync ELF headers with the kernel sources Thomas Weißschuh
2026-09-08  8:56   ` Christophe Leroy (CS GROUP)
2026-09-08  9:37     ` Thomas Weißschuh
2026-09-08  9:09   ` Christophe Leroy (CS GROUP)
2026-09-08  6:33 ` [PATCH v5 12/24] vdso: Add the vdsocheck tool Thomas Weißschuh
2026-09-08  7:19   ` Peter Zijlstra
2026-09-08  7:35     ` Thomas Weißschuh
2026-09-08  7:37       ` Peter Zijlstra
2026-09-09 19:31     ` H. Peter Anvin
2026-09-09 19:38       ` Miguel Ojeda
2026-09-10  6:52   ` Mukesh Kumar Chaurasiya
2026-09-08  6:33 ` [PATCH v5 13/24] x86/vdso: Enable " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 14/24] ARM: vdso: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 15/24] arm64: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 16/24] powerpc/elf: Add 32-bit REL16 relocation definitions Thomas Weißschuh
2026-09-08  9:21   ` Christophe Leroy (CS GROUP)
2026-09-08 14:01   ` R Nageswara Sastry
2026-09-08  6:33 ` [PATCH v5 17/24] powerpc/vdso: Enable the vdsocheck tool Thomas Weißschuh
2026-09-08 14:02   ` R Nageswara Sastry
2026-09-08 14:41   ` Christophe Leroy (CS GROUP)
2026-09-09  6:09     ` Thomas Weißschuh
2026-09-08  6:33 ` Thomas Weißschuh [this message]
2026-09-08  6:33 ` [PATCH v5 19/24] LoongArch: vDSO: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 20/24] s390/vdso: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 21/24] MIPS: ELF: Add more PC-relative relocation definitions Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 22/24] MIPS: vdso: Enable the vdsocheck tool Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 23/24] sparc: " Thomas Weißschuh
2026-09-08  6:33 ` [PATCH v5 24/24] vDSO: Automatically enable VDSO_CHECK Thomas Weißschuh

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=20260908-vdso-absolute-reloc-v5-18-3a93791af1cf@linutronix.de \
    --to=thomas.weissschuh@linutronix.de \
    --cc=a.hindborg@kernel.org \
    --cc=acme@redhat.com \
    --cc=agordeev@linux.ibm.com \
    --cc=alex.gaynor@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=alexghiti@rivosinc.com \
    --cc=aliceryhl@google.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=chleroy@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=gary@garyguo.net \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hpa@zytor.com \
    --cc=johannes@sipsolutions.net \
    --cc=jstancek@redhat.com \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=llvm@lists.linux.dev \
    --cc=loongarch@lists.linux.dev \
    --cc=lossin@kernel.org \
    --cc=luto@kernel.org \
    --cc=maddy@linux.ibm.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=mpe@ellerman.id.au \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=richard@nod.at \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    --cc=tglx@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=tsbogend@alpha.franken.de \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    --cc=x86@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