From nobody Wed Nov 27 12:33:10 2024 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC4DF1917C2 for ; Wed, 9 Oct 2024 22:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.235.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728512295; cv=none; b=h32uTcfWa6GdFTtRqkMTuOzk1sM1NaG9J3PyeC4gSSw/OltAJ4pB7lENWKOaI8j8QcuPqzZVmHtYySQjJggWcM+FrFTv7dJAmQVw1uLFZH9qtXZpJO9R9LeKgBNeTFoBJnMxWb/cP6mIzqgZEXNLnzw3kBVofLv/cFqV7EYmXUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728512295; c=relaxed/simple; bh=JceVaeyjo8ADvkyu50h3AeAnCcWXA45wRTnq87xS/Qg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ViBZFj9utelBC7v9OZSp6mpb6cUsJibCUIxNyZfCgg4f9KHJVK5ZQtx4xkad0reqnbypRgXkB++f/it9XIiD9reGCfV+qji8Z9OfKJf6lbPkmKxKakcBoVd7in2xqjqS/Guc6shl7vjTAbb1R7pfztbifFG6BBpsJc9MUV2nVbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.235.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4XP6ht1WHrz9sPd; Thu, 10 Oct 2024 00:18:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jJLoL-i4YJs7; Thu, 10 Oct 2024 00:18:06 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4XP6hs40Ztz9rvV; Thu, 10 Oct 2024 00:18:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EB7048B77C; Thu, 10 Oct 2024 00:18:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 94kVDWOHpuJ5; Thu, 10 Oct 2024 00:18:04 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.233.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 81DFA8B770; Thu, 10 Oct 2024 00:18:04 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/vdso: Flag VDSO64 entry points as functions Date: Thu, 10 Oct 2024 00:17:57 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728512278; l=4297; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=JceVaeyjo8ADvkyu50h3AeAnCcWXA45wRTnq87xS/Qg=; b=J1ehy/7JlqM+LBYgice6KX2Sg/ObXLCwRQZaMBq/50ZOHYb+GwNnGxbVy5zBHgqnvRJhd+ceH 4NnuFXYP9yCDSyayU29JNvF3TMh63XGF2c2zy53CQp6+DXATbLKE3rC X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On powerpc64 as shown below by readelf, vDSO functions symbols have type NOTYPE. $ powerpc64-linux-gnu-readelf -a arch/powerpc/kernel/vdso/vdso64.so.dbg ELF Header: Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: PowerPC64 Version: 0x1 ... Symbol table '.dynsym' contains 12 entries: Num: Value Size Type Bind Vis Ndx Name ... 1: 0000000000000524 84 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2= .6.15 ... 4: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LINUX_2.6.15 5: 00000000000006c0 48 NOTYPE GLOBAL DEFAULT 8 __[...]@@LINUX_2= .6.15 Symbol table '.symtab' contains 56 entries: Num: Value Size Type Bind Vis Ndx Name ... 45: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LINUX_2.6.15 46: 00000000000006c0 48 NOTYPE GLOBAL DEFAULT 8 __kernel_getcpu 47: 0000000000000524 84 NOTYPE GLOBAL DEFAULT 8 __kernel_clock_g= etres To overcome that, commit ba83b3239e65 ("selftests: vDSO: fix vDSO symbols lookup for powerpc64") was applied to have selftests also look for NOTYPE symbols, but the correct fix should be to flag VDSO entry points as functions. The original commit that brought VDSO support into powerpc/64 has the following explanation: Note that the symbols exposed by the vDSO aren't "normal" function symb= ols, apps can't be expected to link against them directly, the vDSO's are both se= en as if they were linked at 0 and the symbols just contain offsets to the various functions. This is done on purpose to avoid a relocation step (ppc64 functions normally have descriptors with abs addresses in them). When glibc uses those functions, it's expected to use it's own trampoli= nes that know how to reach them. The descriptors it's talking about are the OPD function descriptors used on ABI v1 (big endian). But it would be more correct for a text symbol to have type function, even if there's no function descriptor for it. glibc has a special case already for handling the VDSO symbols which creates a fake opd pointing at the kernel symbol. So changing the VDSO symbol type to function shouldn't affect that. For ABI v2, there is no function descriptors and VDSO functions can safely have function type. So lets flag VDSO entry points as functions and revert the selftest change. Link: https://github.com/mpe/linux-fullhistory/commit/5f2dd691b62da9d9cc54b= 938f8b29c22c93cb805 Fixes: ba83b3239e65 ("selftests: vDSO: fix vDSO symbols lookup for powerpc6= 4") Signed-off-by: Christophe Leroy Reviewed-By: Segher Boessenkool --- arch/powerpc/include/asm/vdso.h | 1 + tools/testing/selftests/vDSO/parse_vdso.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/vdso.h b/arch/powerpc/include/asm/vds= o.h index 7650b6ce14c8..8d972bc98b55 100644 --- a/arch/powerpc/include/asm/vdso.h +++ b/arch/powerpc/include/asm/vdso.h @@ -25,6 +25,7 @@ int vdso_getcpu_init(void); #ifdef __VDSO64__ #define V_FUNCTION_BEGIN(name) \ .globl name; \ + .type name,@function; \ name: \ =20 #define V_FUNCTION_END(name) \ diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/self= tests/vDSO/parse_vdso.c index 7dd5668ea8a6..28f35620c499 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -222,8 +222,7 @@ void *vdso_sym(const char *version, const char *name) ELF(Sym) *sym =3D &vdso_info.symtab[chain]; =20 /* Check for a defined global or weak function w/ right name. */ - if (ELF64_ST_TYPE(sym->st_info) !=3D STT_FUNC && - ELF64_ST_TYPE(sym->st_info) !=3D STT_NOTYPE) + if (ELF64_ST_TYPE(sym->st_info) !=3D STT_FUNC) continue; if (ELF64_ST_BIND(sym->st_info) !=3D STB_GLOBAL && ELF64_ST_BIND(sym->st_info) !=3D STB_WEAK) --=20 2.44.0