From nobody Sat Feb 7 12:11:42 2026 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 5064C1BC9E8; Fri, 16 Aug 2024 14:37:08 +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=1723819030; cv=none; b=TzanzOK+VX31gtu+qSxyxiCd4vlF6gXVxcW2V5rFt3jz736kxReBJLQL9oibfqfeVRFKmV5mZK/nMTTYED61tn4FkKgHIXZY50LJFh3XqM1HRT+8ZdN1PS0PNw/06mgXk5QJYYCLg5KJXU9SCvX0jPsEaqhVPiCYpTrRm0/TE60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819030; c=relaxed/simple; bh=K++segjJQr8QF64fs4Z+bGhGMQj57/fKQI86HMCyRto=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ibWkm3JdcUfO+/n8aB3f1iHqqnAeEYMRldSLn7PKsKI1nZuvbAYp5HvAqTBHjq9iji4iz5ZdTjauTPrWAny0A/po40KHSaoAs9zdBceXRvCUFpd8pgeBPDlZmCHNE4k462erKJQ74uNRsZaHPkMkHxvhWySpEvqxN0Jkt5QYqi0= 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 4Wll1h3NLbz9sS7; Fri, 16 Aug 2024 16:36:56 +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 KOqG54dVypJt; Fri, 16 Aug 2024 16:36:56 +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 4Wll1h2X2Qz9rvV; Fri, 16 Aug 2024 16:36:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 43F2A8B776; Fri, 16 Aug 2024 16:36:56 +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 Z6kyv2FpVyLW; Fri, 16 Aug 2024 16:36:56 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7A3C08B775; Fri, 16 Aug 2024 16:36:55 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 1/9] powerpc/vdso: Don't discard rela sections Date: Fri, 16 Aug 2024 16:36:48 +0200 Message-ID: <93652438073547f350feea0daca91464336024b2.1723817900.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=1900; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=K++segjJQr8QF64fs4Z+bGhGMQj57/fKQI86HMCyRto=; b=is2TYmfppFjvvakpgBHCsGYWlGaf4/CT2PO7c1dZ5PW6hB2pSeIlflfQNa1SyamqARpJZsuGV 0xczDv0ttdtAuPZwXoeq1vhCP0xsOMTY62EFySZcbZYirXZpMouyAcA 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" After building the VDSO, there is a verification that it contains no dynamic relocation, see commit aff69273af61 ("vdso: Improve cmd_vdso_check to check all dynamic relocations"). This verification uses readelf -r and doesn't work if rela sections are discarded. Fixes: 8ad57add77d3 ("powerpc/build: vdso linker warning for orphan section= s") Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/vdso/vdso32.lds.S | 4 +++- arch/powerpc/kernel/vdso/vdso64.lds.S | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/vdso/vdso32.lds.S b/arch/powerpc/kernel/vd= so/vdso32.lds.S index 426e1ccc6971..8f57107000a2 100644 --- a/arch/powerpc/kernel/vdso/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso/vdso32.lds.S @@ -74,6 +74,8 @@ SECTIONS .got : { *(.got) } :text .plt : { *(.plt) } =20 + .rela.dyn : { *(.rela .rela*) } + _end =3D .; __end =3D .; PROVIDE(end =3D .); @@ -87,7 +89,7 @@ SECTIONS *(.branch_lt) *(.data .data.* .gnu.linkonce.d.* .sdata*) *(.bss .sbss .dynbss .dynsbss) - *(.got1 .glink .iplt .rela*) + *(.got1 .glink .iplt) } } =20 diff --git a/arch/powerpc/kernel/vdso/vdso64.lds.S b/arch/powerpc/kernel/vd= so/vdso64.lds.S index bda6c8cdd459..400819258c06 100644 --- a/arch/powerpc/kernel/vdso/vdso64.lds.S +++ b/arch/powerpc/kernel/vdso/vdso64.lds.S @@ -69,7 +69,7 @@ SECTIONS .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text .gcc_except_table : { *(.gcc_except_table) } - .rela.dyn ALIGN(8) : { *(.rela.dyn) } + .rela.dyn ALIGN(8) : { *(.rela .rela*) } =20 .got ALIGN(8) : { *(.got .toc) } =20 @@ -86,7 +86,7 @@ SECTIONS *(.data .data.* .gnu.linkonce.d.* .sdata*) *(.bss .sbss .dynbss .dynsbss) *(.opd) - *(.glink .iplt .plt .rela*) + *(.glink .iplt .plt) } } =20 --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 E2EB11BD026; Fri, 16 Aug 2024 14:37:12 +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=1723819034; cv=none; b=Nxf3PlZig6CjGgt3mRu77y0zXVUMNjMpbAM3qmpQI8SLzuZMcfWbKKaRLiy7Zfp3kEDc42tlOiXyTkk/ECZd0eSZr/Wn13R9k1nKdcp2B2rtqny2NK0hsbNfn1UipRSCA5dgd5ltTHufrwL4jdl7WnBygEOa2fMVsJ92f+hIrxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819034; c=relaxed/simple; bh=utdv6V/SvZxVA50hOk7t/lkGWDvSE1q/kJYchx6i5SU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=STUWJTu6Hte3y8z0S7OKoCzXt3ffhhIj655KYNS8/zYNGl4r3iG+Xyp0MVwng0lyIN09HIKBVS/Zg1vmusHMcr3SDj96pyJjbnGXRpV/S5K+EYupfms7BMR93dj2YXRooyb3QdwhIv32DKEgxSGclMknndeYOvJGl6GwCP1ogi4= 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 4Wll1j1tVVz9sS8; Fri, 16 Aug 2024 16:36:57 +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 j0dj-jWml6uV; Fri, 16 Aug 2024 16:36:57 +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 4Wll1j10wDz9rvV; Fri, 16 Aug 2024 16:36:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0EB088B776; Fri, 16 Aug 2024 16:36:57 +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 9GCrhH04VNha; Fri, 16 Aug 2024 16:36:56 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 431B48B764; Fri, 16 Aug 2024 16:36:56 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 2/9] powerpc/vdso32: Add crtsavres Date: Fri, 16 Aug 2024 16:36:49 +0200 Message-ID: <1c3ff5733a04f2b8001c5e01b7979ede060e131a.1723817900.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=2796; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=utdv6V/SvZxVA50hOk7t/lkGWDvSE1q/kJYchx6i5SU=; b=1LvWYgK0Ua12qLRceENYeUtOHkTWZVzF3evpTFlhRCHJNYxtTHuwBXeYa7P1s8mbrCVbiUF7s KwOD94uSh7+CP8Jcgzosm3mKRbz3h9LeJaXkDvyKhUhNYcse9+mdwiR 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" Commit 08c18b63d965 ("powerpc/vdso32: Add missing _restgpr_31_x to fix build failure") added _restgpr_31_x to the vdso for gettimeofday, but the work on getrandom shows that we will need more of those functions. Remove _restgpr_31_x and link in crtsavres.o so that we get all save/restore functions when optimising the kernel for size. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/vdso/Makefile | 5 ++++- arch/powerpc/kernel/vdso/gettimeofday.S | 13 ------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/M= akefile index 1425b6edc66b..c07a425b8f78 100644 --- a/arch/powerpc/kernel/vdso/Makefile +++ b/arch/powerpc/kernel/vdso/Makefile @@ -43,6 +43,7 @@ else endif =20 targets :=3D $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o +targets +=3D crtsavres-32.o obj-vdso32 :=3D $(addprefix $(obj)/, $(obj-vdso32)) targets +=3D $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o obj-vdso64 :=3D $(addprefix $(obj)/, $(obj-vdso64)) @@ -68,7 +69,7 @@ targets +=3D vdso64.lds CPPFLAGS_vdso64.lds +=3D -P -C =20 # link rule for the .so file, .lds has to be first -$(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday= -32.o FORCE +$(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday= -32.o $(obj)/crtsavres-32.o FORCE $(call if_changed,vdso32ld_and_check) $(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday= -64.o FORCE $(call if_changed,vdso64ld_and_check) @@ -76,6 +77,8 @@ $(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(o= bj)/vgettimeofday-64.o # assembly rules for the .S files $(obj-vdso32): %-32.o: %.S FORCE $(call if_changed_dep,vdso32as) +$(obj)/crtsavres-32.o: %-32.o: $(srctree)/arch/powerpc/lib/crtsavres.S FOR= CE + $(call if_changed_dep,vdso32as) $(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE $(call if_changed_dep,vdso32cc) $(obj-vdso64): %-64.o: %.S FORCE diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/= vdso/gettimeofday.S index 48fc6658053a..67254ac9c8bb 100644 --- a/arch/powerpc/kernel/vdso/gettimeofday.S +++ b/arch/powerpc/kernel/vdso/gettimeofday.S @@ -118,16 +118,3 @@ V_FUNCTION_END(__kernel_clock_getres) V_FUNCTION_BEGIN(__kernel_time) cvdso_call __c_kernel_time call_time=3D1 V_FUNCTION_END(__kernel_time) - -/* Routines for restoring integer registers, called by the compiler. */ -/* Called with r11 pointing to the stack header word of the caller of the = */ -/* function, just beyond the end of the integer restore area. */ -#ifndef __powerpc64__ -_GLOBAL(_restgpr_31_x) -_GLOBAL(_rest32gpr_31_x) - lwz r0,4(r11) - lwz r31,-4(r11) - mtlr r0 - mr r1,r11 - blr -#endif --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 575D41BD026; Fri, 16 Aug 2024 14:37:17 +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=1723819039; cv=none; b=foEFz2X+WYP6W4twz2hNxowSMeGkHTutrtuMgNxWk9kRNyXdnJOPDQCNcgb50lMfvda67sugTZ8mKcy9PwY0jUWexbmQ5SRxuW7p0mntZAOlyoNcugnX9xoJDaLDvS1YLHfFtvxInen91Focc681koRi9Ijj0Dewh+uSMKZE4oY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819039; c=relaxed/simple; bh=HDpYFMxKyFSQNp1ED9l2KJtE8nHJLjdbcKdsJZlVrDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YIz5dfBDoUDRmRFROAfBBlarN2o91HubVYxdO0akHsGBG5746GdQ8d4FfFnnrQuXdTh7GDg2kclf+944bGUBVOhL5i4hmmZNMlAXB4McIP/s0sv5DLMVZZri7Xb/bay27QOnDvnO6K4nmIvWZY4L88Lb/J71tzENFj3C7TUa+so= 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 4Wll1k32D7z9sSC; Fri, 16 Aug 2024 16:36:58 +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 QTPzywU7GyLN; Fri, 16 Aug 2024 16:36:58 +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 4Wll1j6HNxz9rvV; Fri, 16 Aug 2024 16:36:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C4A0C8B776; Fri, 16 Aug 2024 16:36:57 +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 Kweo3eDSzfhe; Fri, 16 Aug 2024 16:36:57 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 037108B775; Fri, 16 Aug 2024 16:36:56 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 3/9] vdso: Add __arch_get_k_vdso_rng_data() Date: Fri, 16 Aug 2024 16:36:50 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=3092; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=HDpYFMxKyFSQNp1ED9l2KJtE8nHJLjdbcKdsJZlVrDs=; b=2M/fjHzyxYljs6mfOSqvlZx3E1n1R8eSkNJjLxXQit+LDCGGDfD+JqTMNOdrnKVDHdCRy374y R4PaYgn/QvJBHjhPeuOdx19w9E7nvHd51Hraaxab3bMvXjVWfZTJM2x 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" _vdso_data is specific to x86 and __arch_get_k_vdso_data() is provided so that all architectures can provide the requested pointer. Do the same with _vdso_rng_data, provide __arch_get_k_vdso_rng_data() and don't use x86 _vdso_rng_data directly. Signed-off-by: Christophe Leroy --- arch/x86/include/asm/vdso/vsyscall.h | 7 +++++++ drivers/char/random.c | 5 +++-- include/asm-generic/vdso/vsyscall.h | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vd= so/vsyscall.h index 972415a8be31..92b85189b8fe 100644 --- a/arch/x86/include/asm/vdso/vsyscall.h +++ b/arch/x86/include/asm/vdso/vsyscall.h @@ -22,6 +22,13 @@ struct vdso_data *__x86_get_k_vdso_data(void) } #define __arch_get_k_vdso_data __x86_get_k_vdso_data =20 +static __always_inline +struct vdso_rng_data *__x86_get_k_vdso_rng_data(void) +{ + return &_vdso_rng_data; +} +#define __arch_get_k_vdso_rng_data __x86_get_k_vdso_rng_data + /* The asm-generic header needs to be included after the definitions above= */ #include =20 diff --git a/drivers/char/random.c b/drivers/char/random.c index 87fe61295ea1..77968309e2c2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -59,6 +59,7 @@ #ifdef CONFIG_VDSO_GETRANDOM #include #include +#include #endif #include #include @@ -282,7 +283,7 @@ static void crng_reseed(struct work_struct *work) * is ordered with the write above to base_crng.generation. Pairs with * the smp_rmb() before the syscall in the vDSO code. */ - smp_store_release(&_vdso_rng_data.generation, next_gen + 1); + smp_store_release(&__arch_get_k_vdso_rng_data()->generation, next_gen + 1= ); #endif if (!static_branch_likely(&crng_is_ready)) crng_init =3D CRNG_READY; @@ -735,7 +736,7 @@ static void __cold _credit_init_bits(size_t bits) queue_work(system_unbound_wq, &set_ready); atomic_notifier_call_chain(&random_ready_notifier, 0, NULL); #ifdef CONFIG_VDSO_GETRANDOM - WRITE_ONCE(_vdso_rng_data.is_ready, true); + WRITE_ONCE(__arch_get_k_vdso_rng_data()->is_ready, true); #endif wake_up_interruptible(&crng_init_wait); kill_fasync(&fasync, SIGIO, POLL_IN); diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso= /vsyscall.h index c835607f78ae..d44a828e34a4 100644 --- a/include/asm-generic/vdso/vsyscall.h +++ b/include/asm-generic/vdso/vsyscall.h @@ -11,6 +11,13 @@ static __always_inline struct vdso_data *__arch_get_k_vd= so_data(void) } #endif /* __arch_get_k_vdso_data */ =20 +#ifndef __arch_get_k_vdso_rng_data +static __always_inline struct vdso_rng_data *__arch_get_k_vdso_rng_data(vo= id) +{ + return NULL; +} +#endif /* __arch_get_k_vdso_rng_data */ + #ifndef __arch_update_vsyscall static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk) --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 3FF631A7074; Fri, 16 Aug 2024 14:37:22 +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=1723819043; cv=none; b=TbdJBHRnv6QcM8R+fLOFfucN/HMcxBaQZfMMGBOHtHxEqscpFvBBE731JBW/hAd/dXN6YMxxDHZ6qUIz+JodolpIiWvYhqMygOBYZhT3Lw2LHAUi7ngEOH0FUB8UsvmK9sFdIZQ+3pvqu8kJuylLwa8Rb+oHIKRS9NSyAi3hyX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819043; c=relaxed/simple; bh=raZtB3D/FN8lwMI2ox/iRuvaT/4s6XJ1Ie7o2wYJiiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=stm7nR0sbeCMtkptV7oPCx4zRsSD+XS4d+wqQ5Lb1uwBVOzo+0YYb4Hz41v2OMkpZnbG51NlqmkSJoBpLhZpUJGcogq0OvmabrE1t7ruIY3TWzTNYjlD4XM5rVafDUqg4+8PB/ummxaDYUKaOpSh+3Z1MCtDh49sER0bet7s6+0= 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 4Wll1l1KyGz9sSH; Fri, 16 Aug 2024 16:36:59 +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 D4x0hs1ixq-x; Fri, 16 Aug 2024 16:36:59 +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 4Wll1k4Jmfz9rvV; Fri, 16 Aug 2024 16:36:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 802828B775; Fri, 16 Aug 2024 16:36:58 +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 Zxbdy1l84p6x; Fri, 16 Aug 2024 16:36:58 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BBDF78B764; Fri, 16 Aug 2024 16:36:57 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 4/9] vdso: Add missing c-getrandom-y in Makefile Date: Fri, 16 Aug 2024 16:36:51 +0200 Message-ID: <5859ac80d54c8cb7c46f81ad6f1fd253e5a5f5b1.1723817900.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=917; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=raZtB3D/FN8lwMI2ox/iRuvaT/4s6XJ1Ie7o2wYJiiw=; b=teOiR430IbKYisIa9qeJvQUA3zExcPi5TaGUSUlPI3tZM8NfXjKiPKFM6557JJnVQNguoXKmA MqMTkii+U8yBGBW/clM//qpOMAt6i4N0tKDHC2k4jsh7jpA9/5THFVQ 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" Same as for gettimeofday CVDSO implementation, add c-getrandom-y to ease the including of lib/vdso/getrandom.c in architectures VDSO builds. Signed-off-by: Christophe Leroy --- lib/vdso/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile index 9f031eafc465..cedbf15f8087 100644 --- a/lib/vdso/Makefile +++ b/lib/vdso/Makefile @@ -4,6 +4,7 @@ GENERIC_VDSO_MK_PATH :=3D $(abspath $(lastword $(MAKEFILE_L= IST))) GENERIC_VDSO_DIR :=3D $(dir $(GENERIC_VDSO_MK_PATH)) =20 c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) :=3D $(addprefix $(GENERIC_V= DSO_DIR), gettimeofday.c) +c-getrandom-$(CONFIG_VDSO_GETRANDOM) :=3D $(addprefix $(GENERIC_VDSO_DIR),= getrandom.c) =20 # This cmd checks that the vdso library does not contain dynamic relocatio= ns. # It has to be called after the linking of the vdso library and requires it --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 9112B1BCA14; Fri, 16 Aug 2024 14:37:26 +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=1723819049; cv=none; b=UHEAvu3kCPX+Vz853fSzQjodWgxa7JyB7Xq4ZLQbQB1CkaVC6/pvo8bTUfXv7eRiPDdBnU50wsKCnABhCRxshyk1UDdbajP1p2tiNa1pvytEf2peYBk39xzInx5a23hwXkTUZrjYTEKJL7/LpfHdG9JXOgUXAn282jkzjmikSVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819049; c=relaxed/simple; bh=CrwMxKdC9EG6K+skjM2PZ6vc4+LiPcnzB9hzBfW5oy8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZAqAY70S+EI9gX8+5oFXCzAt9C70UPkd92iv5Pex8Co1SdrDFTV0jROUcVxrW1Rm7dye3z30NXHbSLezFmi+K3BO+D9OPlmUcqTUOHj0OXljSKeuKHwKdrQrK82Qjb10wtw/3N/eO0BDdlbcrHy7ZfL6HOBBHt0KugGZPVbAxMA= 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 4Wll1m1P0jz9sSL; Fri, 16 Aug 2024 16:37:00 +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 UbagSwJXMetO; Fri, 16 Aug 2024 16:37:00 +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 4Wll1l2WbGz9rvV; Fri, 16 Aug 2024 16:36:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 428958B775; Fri, 16 Aug 2024 16:36:59 +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 UvuuFuuH4N6N; Fri, 16 Aug 2024 16:36:59 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8348A8B776; Fri, 16 Aug 2024 16:36:58 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 5/9] vdso: Avoid call to memset() by getrandom Date: Fri, 16 Aug 2024 16:36:52 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=1272; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=CrwMxKdC9EG6K+skjM2PZ6vc4+LiPcnzB9hzBfW5oy8=; b=YeBID6WvEtA5bi7WLD75S6AnFHkqZFicDNiRtcy07EMW8xc9ZMNW3X2gcsmfv0ZiaCv7SWist ZeeMgG4vrMtDV2lg2gaTqySeTWTuM9iBBltf93yBrYA2DS2XN5iPy7i 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" With the current implementation, __cvdso_getrandom_data() calls memset(), which is unexpected in the VDSO. Rewrite opaque data initialisation to avoid memset(). Signed-off-by: Christophe Leroy --- lib/vdso/getrandom.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index b230f0b10832..425a422651de 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -73,11 +73,15 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_= info, void *buffer, size_ u32 counter[2] =3D { 0 }; =20 if (unlikely(opaque_len =3D=3D ~0UL && !buffer && !len && !flags)) { - *(struct vgetrandom_opaque_params *)opaque_state =3D (struct vgetrandom_= opaque_params) { - .size_of_opaque_state =3D sizeof(*state), - .mmap_prot =3D PROT_READ | PROT_WRITE, - .mmap_flags =3D MAP_DROPPABLE | MAP_ANONYMOUS - }; + struct vgetrandom_opaque_params *params =3D opaque_state; + int i; + + params->size_of_opaque_state =3D sizeof(*state); + params->mmap_prot =3D PROT_READ | PROT_WRITE; + params->mmap_flags =3D MAP_DROPPABLE | MAP_ANONYMOUS; + for (i =3D 0; i < ARRAY_SIZE(params->reserved); i++) + params->reserved[i] =3D 0; + return 0; } =20 --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 B44881BD015; Fri, 16 Aug 2024 14:37:31 +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=1723819054; cv=none; b=ON15Y1AnWffWFu2b9UAf2/rj26piioE8u6Q0Pgh8RaebIa642dEfuQqZIviURrjH11ZsR1SF5y+FZYOYfkKPRXf/iXLoWjDqHVBG/5pZOO4xHNoalpAXYNjl+L8PCbnLhNXoIJIMfbpTNDrKgb+Kn8roHyvylUsTh01hlrBHepo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819054; c=relaxed/simple; bh=a4FUUwepBwN5mNCP2XZj9T9GcESiUNu7cFEKFwi5oe0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eowZ3yAE76SkiWUKu9AWTN/98tvzbBJgkhgQWPJfpv06QJ+5/UDhRFQiHV8IsqKmLE2+nmZGK4VpZMdtAXe9jwDHHNjRomN+8BP4gUaARoIOPtpp9HdXDXu0LivBacrlGPqwpkHjQFf/1GoYDKrAGUX4AyJfjjm4HeufloA2OXM= 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 4Wll1n29jtz9sSN; Fri, 16 Aug 2024 16:37:01 +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 g9vYESeDoJdb; Fri, 16 Aug 2024 16:37:01 +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 4Wll1m0gSmz9sSK; Fri, 16 Aug 2024 16:37:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 066E18B775; Fri, 16 Aug 2024 16:37:00 +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 PPQ3DFzlm0IO; Fri, 16 Aug 2024 16:36:59 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4246D8B764; Fri, 16 Aug 2024 16:36:59 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 6/9] vdso: Only use MAP_DROPPABLE when VM_DROPPABLE exists Date: Fri, 16 Aug 2024 16:36:53 +0200 Message-ID: <712424314ffe0bd65b603925ca1283e7d2a3745f.1723817900.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=1039; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=a4FUUwepBwN5mNCP2XZj9T9GcESiUNu7cFEKFwi5oe0=; b=JTJKpvHJwPkKX/A+Rhg4IQmN4zJeE5RYjU1IFBVGLChXuZCKHQwfcskeTnmjMTTUiAcBGCgFY jGuGavvt1atDe6zhW0cyeXNinoFDn4NBjXUUgrTBNg11X7Rj03nTfEk 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" Commit 9651fcedf7b9 ("mm: add MAP_DROPPABLE for designating always lazily freeable mappings") only adds MAP_DROPPABLE for 64 bits architectures, so don't use it on 32 bits as it leads to ENOTSUPP on mmap(). Signed-off-by: Christophe Leroy --- lib/vdso/getrandom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index 425a422651de..11ba6dbf3b5e 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -78,7 +78,11 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_i= nfo, void *buffer, size_ =20 params->size_of_opaque_state =3D sizeof(*state); params->mmap_prot =3D PROT_READ | PROT_WRITE; - params->mmap_flags =3D MAP_DROPPABLE | MAP_ANONYMOUS; + if (IS_ENABLED(CONFIG_64BIT)) + params->mmap_flags =3D MAP_DROPPABLE | MAP_ANONYMOUS; + else + params->mmap_flags =3D MAP_PRIVATE | MAP_ANONYMOUS; + for (i =3D 0; i < ARRAY_SIZE(params->reserved); i++) params->reserved[i] =3D 0; =20 --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 8E0A71BD015; Fri, 16 Aug 2024 14:37:36 +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=1723819058; cv=none; b=bK1MJPNZLU0jaoH2GbXKCPt0PbrTg4VGgtfaktBTkDSmSfz5yLxi+Zgx42+Z2MIzYnBkdkwFqQVUuh3000Ry9jgjhGZiOXS63RJ7IDy9cE4jYhI1J9pX/1STG+LwKntY+nz+qpq6sQOKGDFpihyhmaXavgBThcImOsZo4P3eB4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819058; c=relaxed/simple; bh=ZRZ74nUfhlj//3k0SFeHq4s60ExiEQUmJYVI6+7VWwQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QCDR9fhLsbZWcrXY1Mvrg3QookbvAgOpJviN5K4dFH/rdYbfQQ+cD90z8nzkqBCDDIeBWEQ0UKoWR3yPE//4ykd9GbLT769EXczaPzrH7B57mfvZF+WxPo7XatTnrojb04cDukbbRaFCX21XU5+yrpZ5T7iliwMUuWyaUCAP3lE= 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 4Wll1p2rL0z9sSZ; Fri, 16 Aug 2024 16:37:02 +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 0FGio_3SM76h; Fri, 16 Aug 2024 16:37:02 +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 4Wll1m655vz9rvV; Fri, 16 Aug 2024 16:37:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BD9988B764; Fri, 16 Aug 2024 16:37:00 +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 aeg8OhdT1BTv; Fri, 16 Aug 2024 16:37:00 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 080968B776; Fri, 16 Aug 2024 16:36:59 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 7/9] powerpc: Add little endian variants of LHZX_BE and friends Date: Fri, 16 Aug 2024 16:36:54 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819011; l=2150; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=ZRZ74nUfhlj//3k0SFeHq4s60ExiEQUmJYVI6+7VWwQ=; b=kOKzSdAaDCocEGjcwOOPnE+zyg2ugOITM5x4/kDd+DSi3Cnis0XztcJ0bnyXg3azflp+Ah2lp f1aaVakKCwqCagp9h8RMNaoyAhus0oxNEiHBcWf0t94NrqIHTc9X41i 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" To support getrandom in VDSO which is based on little endian storage, add macros equivalent to LHZX_BE for little endian accesses. And move it outside of __powerpc64__ #ifdef so that it can also be used for PPC32. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/asm-compat.h | 40 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/a= sm/asm-compat.h index 2bc53c646ccd..ef8e79ae669a 100644 --- a/arch/powerpc/include/asm/asm-compat.h +++ b/arch/powerpc/include/asm/asm-compat.h @@ -25,20 +25,6 @@ #define PPC_LR_STKOFF 16 #define PPC_MIN_STKFRM 112 =20 -#ifdef __BIG_ENDIAN__ -#define LHZX_BE stringify_in_c(lhzx) -#define LWZX_BE stringify_in_c(lwzx) -#define LDX_BE stringify_in_c(ldx) -#define STWX_BE stringify_in_c(stwx) -#define STDX_BE stringify_in_c(stdx) -#else -#define LHZX_BE stringify_in_c(lhbrx) -#define LWZX_BE stringify_in_c(lwbrx) -#define LDX_BE stringify_in_c(ldbrx) -#define STWX_BE stringify_in_c(stwbrx) -#define STDX_BE stringify_in_c(stdbrx) -#endif - #else /* 32-bit */ =20 /* operations for longs and pointers */ @@ -61,4 +47,30 @@ =20 #endif =20 +#ifdef __BIG_ENDIAN__ +#define LHZX_BE stringify_in_c(lhzx) +#define LWZX_BE stringify_in_c(lwzx) +#define LDX_BE stringify_in_c(ldx) +#define STWX_BE stringify_in_c(stwx) +#define STDX_BE stringify_in_c(stdx) + +#define LHZX_LE stringify_in_c(lhbrx) +#define LWZX_LE stringify_in_c(lwbrx) +#define LDX_LE stringify_in_c(ldbrx) +#define STWX_LE stringify_in_c(stwbrx) +#define STDX_LE stringify_in_c(stdbrx) +#else +#define LHZX_BE stringify_in_c(lhbrx) +#define LWZX_BE stringify_in_c(lwbrx) +#define LDX_BE stringify_in_c(ldbrx) +#define STWX_BE stringify_in_c(stwbrx) +#define STDX_BE stringify_in_c(stdbrx) + +#define LHZX_LE stringify_in_c(lhzx) +#define LWZX_LE stringify_in_c(lwzx) +#define LDX_LE stringify_in_c(ldx) +#define STWX_LE stringify_in_c(stwx) +#define STDX_LE stringify_in_c(stdx) +#endif + #endif /* _ASM_POWERPC_ASM_COMPAT_H */ --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 C4BCE1BD015; Fri, 16 Aug 2024 14:37:40 +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=1723819063; cv=none; b=sCQa+ehBxKBWNA+6JV/KnW8lky7HauPl9Fj73R5ZMu1RQN8tIgg97K4qf+vlZ+toHB6MQUW/hMsP/L0MTKwE3DLr90gWNqDgkd5dNFuSZaBZozttEi20v3/rOXdOJIhgy9zuDmq0Y6R0YxJnDBDZFjCojc4ZYG0WBiion5fo/N8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819063; c=relaxed/simple; bh=XrmofFtku9UFtlIRoRQATwK6AOMTi8xpHx3tASxzQf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iXQD10SffraoUUUGFls38ecmtCekpT9GnBVPe80X3gxB+k12Sgq3HkgDC+34e9DEVKtK7uScnjnXOQbeBP2KxlmyOWFjNeG2f7bppx8cxuzVxr1vZDLM8DYQvpaj1nOklIk39B2jq/++dLhk9ccCi7s7vm6Ms6g5z+JoUirmNWw= 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 4Wll1q0y4zz9sSb; Fri, 16 Aug 2024 16:37:03 +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 rO7cTVIDJce1; Fri, 16 Aug 2024 16:37:03 +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 4Wll1n5MJFz9sSK; Fri, 16 Aug 2024 16:37:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A6CCA8B764; Fri, 16 Aug 2024 16:37:01 +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 j3Gv5iHN7xf1; Fri, 16 Aug 2024 16:37:01 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C07D18B775; Fri, 16 Aug 2024 16:37:00 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 8/9] powerpc/vdso: Wire up getrandom() vDSO implementation Date: Fri, 16 Aug 2024 16:36:55 +0200 Message-ID: <7e118080fc47a5c2e5616a7bfc7da127763d3bad.1723817900.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819012; l=20771; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=XrmofFtku9UFtlIRoRQATwK6AOMTi8xpHx3tASxzQf4=; b=EwPsFl3yvISLaJF3TBDgnAdtVAaHl8uhn6zIaMUN45iZDSCdG/mwDW6mZ13XTTl9R/Sd9hgD3 TInc8PrlSqAA3CSrxbZcXdnLcGunkqqVQogmfk567eeZVz+ua0Mag/y 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" To be consistent with other VDSO functions, the function is called __kernel_getrandom() __arch_chacha20_blocks_nostack() fonction is implemented basically with 32 bits operations. It performs 4 QUARTERROUND operations in parallele. There are enough registers to avoid using the stack: On input: r3: output bytes r4: 32-byte key input r5: 8-byte counter input/output r6: number of 64-byte blocks to write to output During operation: r0: counter of blocks (initialised with r6) r4: Value '4' after key has been read. r6-r13: key r14-r15 : block counter r16-r31 : chacha state At the end: r0, r6-r13: Zeroised r14-r31: Restored Performance on powerpc 885 (using kernel selftest): ~# ./vdso_test_getrandom bench-single vdso: 2500000 times in 7.897495392 seconds libc: 2500000 times in 56.091632232 seconds syscall: 2500000 times in 55.704851989 seconds Performance on powerpc 8321 (using kernel selftest): ~# ./vdso_test_getrandom bench-single vdso: 2500000 times in 2.017183250 seconds libc: 2500000 times in 13.088533630 seconds syscall: 2500000 times in 12.952458068 seconds Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/vdso/getrandom.h | 61 ++++ arch/powerpc/include/asm/vdso/vsyscall.h | 7 + arch/powerpc/include/asm/vdso_datapage.h | 2 + arch/powerpc/kernel/asm-offsets.c | 1 + arch/powerpc/kernel/vdso/Makefile | 41 ++- arch/powerpc/kernel/vdso/getrandom.S | 62 ++++ arch/powerpc/kernel/vdso/vdso32.lds.S | 1 + arch/powerpc/kernel/vdso/vdso64.lds.S | 1 + arch/powerpc/kernel/vdso/vgetrandom-chacha.S | 297 +++++++++++++++++++ arch/powerpc/kernel/vdso/vgetrandom.c | 12 + 11 files changed, 482 insertions(+), 4 deletions(-) create mode 100644 arch/powerpc/include/asm/vdso/getrandom.h create mode 100644 arch/powerpc/kernel/vdso/getrandom.S create mode 100644 arch/powerpc/kernel/vdso/vgetrandom-chacha.S create mode 100644 arch/powerpc/kernel/vdso/vgetrandom.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index d7b09b064a8a..f61cfa9ac360 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -311,6 +311,7 @@ config PPC select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK select TRACE_IRQFLAGS_SUPPORT + select VDSO_GETRANDOM if !COMPAT # # Please keep this list sorted alphabetically. # diff --git a/arch/powerpc/include/asm/vdso/getrandom.h b/arch/powerpc/inclu= de/asm/vdso/getrandom.h new file mode 100644 index 000000000000..37a678d982b4 --- /dev/null +++ b/arch/powerpc/include/asm/vdso/getrandom.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_VDSO_GETRANDOM_H +#define _ASM_POWERPC_VDSO_GETRANDOM_H + +#ifndef __ASSEMBLY__ + +static __always_inline int do_syscall_3(const unsigned long _r0, const uns= igned long _r3, + const unsigned long _r4, const unsigned long _r5) +{ + register long r0 asm("r0") =3D _r0; + register unsigned long r3 asm("r3") =3D _r3; + register unsigned long r4 asm("r4") =3D _r4; + register unsigned long r5 asm("r5") =3D _r5; + register int ret asm ("r3"); + + asm volatile( + " sc\n" + " bns+ 1f\n" + " neg %0, %0\n" + "1:\n" + : "=3Dr" (ret), "+r" (r4), "+r" (r5), "+r" (r0) + : "r" (r3) + : "memory", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "cr0", "ctr"); + + return ret; +} + +/** + * getrandom_syscall - Invoke the getrandom() syscall. + * @buffer: Destination buffer to fill with random bytes. + * @len: Size of @buffer in bytes. + * @flags: Zero or more GRND_* flags. + * Returns: The number of random bytes written to @buffer, or a negative v= alue indicating an error. + */ +static __always_inline ssize_t getrandom_syscall(void *buffer, size_t len,= unsigned int flags) +{ + return do_syscall_3(__NR_getrandom, (unsigned long)buffer, + (unsigned long)len, (unsigned long)flags); +} + +const struct vdso_rng_data *__arch_get_vdso_rng_data(void); + +ssize_t __c_kernel_getrandom(void *buffer, size_t len, unsigned int flags,= void *opaque_state, + size_t opaque_len, const struct vdso_rng_data *vd); + +/** + * __arch_chacha20_blocks_nostack - Generate ChaCha20 stream without using= the stack. + * @dst_bytes: Destination buffer to hold @nblocks * 64 bytes of output. + * @key: 32-byte input key. + * @counter: 8-byte counter, read on input and updated on return. + * @nblocks: Number of blocks to generate. + * + * Generates a given positive number of blocks of ChaCha20 output with non= ce=3D0, and does not write + * to any stack or memory outside of the parameters passed to it, in order= to mitigate stack data + * leaking into forked child processes. + */ +void __arch_chacha20_blocks_nostack(u8 *dst_bytes, const u32 *key, u32 *co= unter, size_t nblocks); + +#endif /* !__ASSEMBLY__ */ + +#endif /* _ASM_POWERPC_VDSO_GETRANDOM_H */ diff --git a/arch/powerpc/include/asm/vdso/vsyscall.h b/arch/powerpc/includ= e/asm/vdso/vsyscall.h index 48cf23f1e273..ed60a21bba40 100644 --- a/arch/powerpc/include/asm/vdso/vsyscall.h +++ b/arch/powerpc/include/asm/vdso/vsyscall.h @@ -17,6 +17,13 @@ struct vdso_data *__arch_get_k_vdso_data(void) } #define __arch_get_k_vdso_data __arch_get_k_vdso_data =20 +static __always_inline +struct vdso_rng_data *__arch_get_k_vdso_rng_data(void) +{ + return &vdso_data->rng_data; +} +#define __arch_get_k_vdso_rng_data __arch_get_k_vdso_rng_data + /* The asm-generic header needs to be included after the definitions above= */ #include =20 diff --git a/arch/powerpc/include/asm/vdso_datapage.h b/arch/powerpc/includ= e/asm/vdso_datapage.h index a585c8e538ff..e17500c5237e 100644 --- a/arch/powerpc/include/asm/vdso_datapage.h +++ b/arch/powerpc/include/asm/vdso_datapage.h @@ -83,6 +83,7 @@ struct vdso_arch_data { __u32 compat_syscall_map[SYSCALL_MAP_SIZE]; /* Map of compat syscalls */ =20 struct vdso_data data[CS_BASES]; + struct vdso_rng_data rng_data; }; =20 #else /* CONFIG_PPC64 */ @@ -95,6 +96,7 @@ struct vdso_arch_data { __u32 syscall_map[SYSCALL_MAP_SIZE]; /* Map of syscalls */ __u32 compat_syscall_map[0]; /* No compat syscalls on PPC32 */ struct vdso_data data[CS_BASES]; + struct vdso_rng_data rng_data; }; =20 #endif /* CONFIG_PPC64 */ diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-of= fsets.c index 23733282de4d..eedb2e04c785 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -335,6 +335,7 @@ int main(void) =20 /* datapage offsets for use by vdso */ OFFSET(VDSO_DATA_OFFSET, vdso_arch_data, data); + OFFSET(VDSO_RNG_DATA_OFFSET, vdso_arch_data, rng_data); OFFSET(CFG_TB_TICKS_PER_SEC, vdso_arch_data, tb_ticks_per_sec); #ifdef CONFIG_PPC64 OFFSET(CFG_ICACHE_BLOCKSZ, vdso_arch_data, icache_block_size); diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/M= akefile index c07a425b8f78..b380af35001a 100644 --- a/arch/powerpc/kernel/vdso/Makefile +++ b/arch/powerpc/kernel/vdso/Makefile @@ -8,6 +8,9 @@ include $(srctree)/lib/vdso/Makefile obj-vdso32 =3D sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-= 32.o note-32.o getcpu-32.o obj-vdso64 =3D sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-= 64.o note-64.o getcpu-64.o =20 +obj-vdso32 +=3D getrandom-32.o vgetrandom-chacha-32.o +obj-vdso64 +=3D getrandom-64.o vgetrandom-chacha-64.o + ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday-32.o +=3D -include $(c-gettimeofday-y) CFLAGS_vgettimeofday-32.o +=3D $(DISABLE_LATENT_ENTROPY_PLUGIN) @@ -34,6 +37,32 @@ ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday-64.o +=3D $(call cc-option, -ffixed-r30) endif =20 +ifneq ($(c-getrandom-y),) + CFLAGS_vgetrandom-32.o +=3D -include $(c-getrandom-y) + CFLAGS_vgetrandom-32.o +=3D $(DISABLE_LATENT_ENTROPY_PLUGIN) + CFLAGS_vgetrandom-32.o +=3D $(call cc-option, -fno-stack-protector) + CFLAGS_vgetrandom-32.o +=3D -DDISABLE_BRANCH_PROFILING + CFLAGS_vgetrandom-32.o +=3D -ffreestanding -fasynchronous-unwind-tables + CFLAGS_REMOVE_vgetrandom-32.o =3D $(CC_FLAGS_FTRACE) + CFLAGS_REMOVE_vgetrandom-32.o +=3D -mcmodel=3Dmedium -mabi=3Delfv1 -mabi= =3Delfv2 -mcall-aixdesc + # This flag is supported by clang for 64-bit but not 32-bit so it will c= ause + # an unused command line flag warning for this file. + ifdef CONFIG_CC_IS_CLANG + CFLAGS_REMOVE_vgetrandom-32.o +=3D -fno-stack-clash-protection + endif + CFLAGS_vgetrandom-64.o +=3D -include $(c-getrandom-y) + CFLAGS_vgetrandom-64.o +=3D $(DISABLE_LATENT_ENTROPY_PLUGIN) + CFLAGS_vgetrandom-64.o +=3D $(call cc-option, -fno-stack-protector) + CFLAGS_vgetrandom-64.o +=3D -DDISABLE_BRANCH_PROFILING + CFLAGS_vgetrandom-64.o +=3D -ffreestanding -fasynchronous-unwind-tables + CFLAGS_REMOVE_vgetrandom-64.o =3D $(CC_FLAGS_FTRACE) +# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That u= sed to be true +# by accident when the VDSO was hand-written asm code, but may not be now = that the VDSO is +# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact= on code +# generation is minimal, it will just use r29 instead. + CFLAGS_vgetrandom-64.o +=3D $(call cc-option, -ffixed-r30) +endif + # Build rules =20 ifdef CROSS32_COMPILE @@ -42,10 +71,10 @@ else VDSOCC :=3D $(CC) endif =20 -targets :=3D $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o +targets :=3D $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o vgetrandom-32.o targets +=3D crtsavres-32.o obj-vdso32 :=3D $(addprefix $(obj)/, $(obj-vdso32)) -targets +=3D $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o +targets +=3D $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o vgetrandom-64.o obj-vdso64 :=3D $(addprefix $(obj)/, $(obj-vdso64)) =20 ccflags-y :=3D -fno-common -fno-builtin @@ -69,9 +98,9 @@ targets +=3D vdso64.lds CPPFLAGS_vdso64.lds +=3D -P -C =20 # link rule for the .so file, .lds has to be first -$(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday= -32.o $(obj)/crtsavres-32.o FORCE +$(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday= -32.o $(obj)/vgetrandom-32.o $(obj)/crtsavres-32.o FORCE $(call if_changed,vdso32ld_and_check) -$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday= -64.o FORCE +$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday= -64.o $(obj)/vgetrandom-64.o FORCE $(call if_changed,vdso64ld_and_check) =20 # assembly rules for the .S files @@ -81,10 +110,14 @@ $(obj)/crtsavres-32.o: %-32.o: $(srctree)/arch/powerpc= /lib/crtsavres.S FORCE $(call if_changed_dep,vdso32as) $(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE $(call if_changed_dep,vdso32cc) +$(obj)/vgetrandom-32.o: %-32.o: %.c FORCE + $(call if_changed_dep,vdso32cc) $(obj-vdso64): %-64.o: %.S FORCE $(call if_changed_dep,vdso64as) $(obj)/vgettimeofday-64.o: %-64.o: %.c FORCE $(call if_changed_dep,cc_o_c) +$(obj)/vgetrandom-64.o: %-64.o: %.c FORCE + $(call if_changed_dep,cc_o_c) =20 # Generate VDSO offsets using helper script gen-vdso32sym :=3D $(src)/gen_vdso32_offsets.sh diff --git a/arch/powerpc/kernel/vdso/getrandom.S b/arch/powerpc/kernel/vds= o/getrandom.S new file mode 100644 index 000000000000..e196a61a6634 --- /dev/null +++ b/arch/powerpc/kernel/vdso/getrandom.S @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Userland implementation of getrandom() for processes + * for use in the vDSO + * + * Copyright (C) 2024 Christophe Leroy , CS G= ROUP France + */ +#include +#include +#include +#include +#include +#include + +/* + * The macro sets two stack frames, one for the caller and one for the cal= lee + * because there are no requirement for the caller to set a stack frame wh= en + * calling VDSO so it may have omitted to set one, especially on PPC64 + */ + +.macro cvdso_call funct + .cfi_startproc + PPC_STLU r1, -PPC_MIN_STKFRM(r1) + .cfi_adjust_cfa_offset PPC_MIN_STKFRM + mflr r0 + PPC_STLU r1, -PPC_MIN_STKFRM(r1) + .cfi_adjust_cfa_offset PPC_MIN_STKFRM + PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) + .cfi_rel_offset lr, PPC_MIN_STKFRM + PPC_LR_STKOFF +#ifdef __powerpc64__ + PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) + .cfi_rel_offset r2, PPC_MIN_STKFRM + STK_GOT +#endif + get_datapage r8 + addi r8, r8, VDSO_RNG_DATA_OFFSET +#ifdef __powerpc64__ + bl CFUNC(DOTSYM(\funct)) +#else + bl \funct +#endif + PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) + .cfi_restore r2 +#endif + cmpwi r3, 0 + mtlr r0 + addi r1, r1, 2 * PPC_MIN_STKFRM + .cfi_restore lr + .cfi_def_cfa_offset 0 + crclr so + bgelr+ + crset so + neg r3, r3 + blr + .cfi_endproc +.endm + + .text +V_FUNCTION_BEGIN(__kernel_getrandom) + cvdso_call __c_kernel_getrandom +V_FUNCTION_END(__kernel_getrandom) diff --git a/arch/powerpc/kernel/vdso/vdso32.lds.S b/arch/powerpc/kernel/vd= so/vdso32.lds.S index 8f57107000a2..7b41d5d256e8 100644 --- a/arch/powerpc/kernel/vdso/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso/vdso32.lds.S @@ -130,6 +130,7 @@ VERSION #if defined(CONFIG_PPC64) || !defined(CONFIG_SMP) __kernel_getcpu; #endif + __kernel_getrandom; =20 local: *; }; diff --git a/arch/powerpc/kernel/vdso/vdso64.lds.S b/arch/powerpc/kernel/vd= so/vdso64.lds.S index 400819258c06..9481e4b892ed 100644 --- a/arch/powerpc/kernel/vdso/vdso64.lds.S +++ b/arch/powerpc/kernel/vdso/vdso64.lds.S @@ -123,6 +123,7 @@ VERSION __kernel_sigtramp_rt64; __kernel_getcpu; __kernel_time; + __kernel_getrandom; =20 local: *; }; diff --git a/arch/powerpc/kernel/vdso/vgetrandom-chacha.S b/arch/powerpc/ke= rnel/vdso/vgetrandom-chacha.S new file mode 100644 index 000000000000..355594f814e0 --- /dev/null +++ b/arch/powerpc/kernel/vdso/vgetrandom-chacha.S @@ -0,0 +1,297 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Christophe Leroy , CS G= ROUP France + */ + +#include + +#include + +.macro quarterround4 a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 a4 b4 c4 d4 + add \a1, \a1, \b1 + add \a2, \a2, \b2 + add \a3, \a3, \b3 + add \a4, \a4, \b4 + xor \d1, \d1, \a1 + xor \d2, \d2, \a2 + xor \d3, \d3, \a3 + xor \d4, \d4, \a4 + rotlwi \d1, \d1, 16 + rotlwi \d2, \d2, 16 + rotlwi \d3, \d3, 16 + rotlwi \d4, \d4, 16 + add \c1, \c1, \d1 + add \c2, \c2, \d2 + add \c3, \c3, \d3 + add \c4, \c4, \d4 + xor \b1, \b1, \c1 + xor \b2, \b2, \c2 + xor \b3, \b3, \c3 + xor \b4, \b4, \c4 + rotlwi \b1, \b1, 12 + rotlwi \b2, \b2, 12 + rotlwi \b3, \b3, 12 + rotlwi \b4, \b4, 12 + add \a1, \a1, \b1 + add \a2, \a2, \b2 + add \a3, \a3, \b3 + add \a4, \a4, \b4 + xor \d1, \d1, \a1 + xor \d2, \d2, \a2 + xor \d3, \d3, \a3 + xor \d4, \d4, \a4 + rotlwi \d1, \d1, 8 + rotlwi \d2, \d2, 8 + rotlwi \d3, \d3, 8 + rotlwi \d4, \d4, 8 + add \c1, \c1, \d1 + add \c2, \c2, \d2 + add \c3, \c3, \d3 + add \c4, \c4, \d4 + xor \b1, \b1, \c1 + xor \b2, \b2, \c2 + xor \b3, \b3, \c3 + xor \b4, \b4, \c4 + rotlwi \b1, \b1, 7 + rotlwi \b2, \b2, 7 + rotlwi \b3, \b3, 7 + rotlwi \b4, \b4, 7 +.endm + +#define QUARTERROUND4(a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,a4,b4,c4,d4) qua= rterround4 16+a1 16+b1 16+c1 16+d1 16+a2 16+b2 16+c2 16+d2 16+a3 16+b3 16+c= 3 16+d3 16+a4 16+b4 16+c4 16+d4 + +/* + * Very basic 32 bits implementation of ChaCha20. Produces a given positiv= e number + * of blocks of output with a nonce of 0, taking an input key and 8-byte + * counter. Importantly does not spill to the stack. Its arguments are: + * + * r3: output bytes + * r4: 32-byte key input + * r5: 8-byte counter input/output + * r6: number of 64-byte blocks to write to output + * + * r0: counter of blocks (initialised with r6) + * r4: Value '4' after key has been read. + * r6-r13: key + * r14-r15 : counter + * r16-r31 : state + */ +SYM_FUNC_START(__arch_chacha20_blocks_nostack) +#ifdef __powerpc64__ + std r14,-144(r1) + std r15,-136(r1) + std r16,-128(r1) + std r17,-120(r1) + std r18,-112(r1) + std r19,-104(r1) + std r20,-96(r1) + std r21,-88(r1) + std r22,-80(r1) + std r23,-72(r1) + std r24,-64(r1) + std r25,-56(r1) + std r26,-48(r1) + std r27,-40(r1) + std r28,-32(r1) + std r29,-24(r1) + std r30,-16(r1) + std r31,-8(r1) +#else + stwu r1, -96(r1) +#if defined(CONFIG_CPU_LITTLE_ENDIAN) + stw r14,24(r1) + stw r15,28(r1) + stw r16,32(r1) + stw r17,36(r1) + stw r18,40(r1) + stw r19,44(r1) + stw r20,48(r1) + stw r21,52(r1) + stw r22,56(r1) + stw r23,60(r1) + stw r24,64(r1) + stw r25,68(r1) + stw r26,72(r1) + stw r27,76(r1) + stw r28,80(r1) + stw r29,84(r1) + stw r30,88(r1) + stw r31,92(r1) +#else + stmw r14, 24(r1) +#endif +#endif + mr r0, r6 + + li r31, 4 + + LWZX_LE r6, 0, r4 + LWZX_LE r7, r31, r4 + addi r4, r4, 8 + LWZX_LE r8, 0, r4 + LWZX_LE r9, r31, r4 + addi r4, r4, 8 + LWZX_LE r10, 0, r4 + LWZX_LE r11, r31, r4 + addi r4, r4, 8 + LWZX_LE r12, 0, r4 + LWZX_LE r13, r31, r4 + + li r4, 4 + +#ifdef __powerpc64__ + LDX_LE r14, 0, r5 + srdi r15, r14, 32 +#else + LWZX_LE r14, 0, r5 + LWZX_LE r15, r4, r5 +#endif +.Lblock: + li r31, 10 + + lis r16, 0x6170 + lis r17, 0x3320 + lis r18, 0x7962 + lis r19, 0x6b20 + addi r16, r16, 0x7865 + addi r17, r17, 0x646e + addi r18, r18, 0x2d32 + addi r19, r19, 0x6574 + + mtctr r31 + + mr r20, r6 + mr r21, r7 + mr r22, r8 + mr r23, r9 + mr r24, r10 + mr r25, r11 + mr r26, r12 + mr r27, r13 + + mr r28, r14 + mr r29, r15 + li r30, 0 + li r31, 0 + +.Lpermute: + QUARTERROUND4( 0, 4, 8,12, 1, 5, 9,13, 2, 6,10,14, 3, 7,11,15) + QUARTERROUND4( 0, 5,10,15, 1, 6,11,12, 2, 7, 8,13, 3, 4, 9,14) + + bdnz .Lpermute + + addis r16, r16, 0x6170 + addis r17, r17, 0x3320 + addis r18, r18, 0x7962 + addis r19, r19, 0x6b20 + addi r16, r16, 0x7865 + addi r17, r17, 0x646e + addi r18, r18, 0x2d32 + addi r19, r19, 0x6574 + + add r20, r20, r6 + add r21, r21, r7 + add r22, r22, r8 + add r23, r23, r9 + add r24, r24, r10 + add r25, r25, r11 + add r26, r26, r12 + add r27, r27, r13 + + add r28, r28, r14 + add r29, r29, r15 + + STWX_LE r16, 0, r3 + STWX_LE r17, r4, r3 + addi r3, r3, 8 + STWX_LE r18, 0, r3 + STWX_LE r19, r4, r3 + addi r3, r3, 8 + STWX_LE r20, 0, r3 + STWX_LE r21, r4, r3 + addi r3, r3, 8 + STWX_LE r22, 0, r3 + STWX_LE r23, r4, r3 + addi r3, r3, 8 + STWX_LE r24, 0, r3 + STWX_LE r25, r4, r3 + addi r3, r3, 8 + STWX_LE r26, 0, r3 + STWX_LE r27, r4, r3 + addi r3, r3, 8 + STWX_LE r28, 0, r3 + STWX_LE r29, r4, r3 + addi r3, r3, 8 + STWX_LE r30, 0, r3 + STWX_LE r31, r4, r3 + addi r3, r3, 8 + +#ifdef __powerpc64__ + addi r14, r14, 1 + srdi r15, r14, 32 +#else + addic r14, r14, 1 + addze r15, r15 +#endif + + subic. r0, r0, 1 + bne .Lblock + + STWX_LE r14, 0, r5 + STWX_LE r15, r4, r5 + + li r6, 0 + li r7, 0 + li r8, 0 + li r9, 0 + li r10, 0 + li r11, 0 + li r12, 0 + li r13, 0 + +#ifdef __powerpc64__ + ld r14,-144(r1) + ld r15,-136(r1) + ld r16,-128(r1) + ld r17,-120(r1) + ld r18,-112(r1) + ld r19,-104(r1) + ld r20,-96(r1) + ld r21,-88(r1) + ld r22,-80(r1) + ld r23,-72(r1) + ld r24,-64(r1) + ld r25,-56(r1) + ld r26,-48(r1) + ld r27,-40(r1) + ld r28,-32(r1) + ld r29,-24(r1) + ld r30,-16(r1) + ld r31,-8(r1) +#else +#if defined(CONFIG_CPU_LITTLE_ENDIAN) + lwz r14,24(r1) + lwz r15,28(r1) + lwz r16,32(r1) + lwz r17,36(r1) + lwz r18,40(r1) + lwz r19,44(r1) + lwz r20,48(r1) + lwz r21,52(r1) + lwz r22,56(r1) + lwz r23,60(r1) + lwz r24,64(r1) + lwz r25,68(r1) + lwz r26,72(r1) + lwz r27,76(r1) + lwz r28,80(r1) + lwz r29,84(r1) + lwz r30,88(r1) + lwz r31,92(r1) +#else + lmw r14, 24(r1) +#endif + addi r1, r1, 96 +#endif + blr +SYM_FUNC_END(__arch_chacha20_blocks_nostack) diff --git a/arch/powerpc/kernel/vdso/vgetrandom.c b/arch/powerpc/kernel/vd= so/vgetrandom.c new file mode 100644 index 000000000000..f442396c3715 --- /dev/null +++ b/arch/powerpc/kernel/vdso/vgetrandom.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Powerpc userspace implementations of getrandom() + */ +#include +#include + +ssize_t __c_kernel_getrandom(void *buffer, size_t len, unsigned int flags,= void *opaque_state, + size_t opaque_len, const struct vdso_rng_data *vd) +{ + return __cvdso_getrandom_data(vd, buffer, len, flags, opaque_state,= opaque_len); +} --=20 2.44.0 From nobody Sat Feb 7 12:11:42 2026 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 C34D01BE874; Fri, 16 Aug 2024 14:37:46 +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=1723819068; cv=none; b=aNadJXsJ7GZ9UYXVhMeDZgs3C+8Nypab8Ths16NotH+4V4gSWEBx11GlTR5n30HEG8MEN30ZoWfMGrJW97bmbkYODqohFwdTl8AD2OupG+luIStrLQl97yAs8IJUnVTavsNLUEpD+ND8WfaQ6GyOGUf4BfRC7dGLdglmfQ6cba4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723819068; c=relaxed/simple; bh=Byt1zoXBB7tbRE1Z7pCXViKFciqFPibE+/C8OmNKnow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GivJRqfJ9ItaIf3UBWk9yjxtXr9FeHQRekU/ZVrjgU5IffU0RbYIHq0Oz0EO5ml0hRyp4tXnC/DV0qkdGUF6bhlRnZbH4tgR56PWuXrCDmgQQCpjvVF2Vmi8BpgzQAuuzFNub9j1Wl0L26TqzQ/Zfmn1v0Eqf/NVDO4lt+kSwPE= 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 4Wll1r2rNSz9sSK; Fri, 16 Aug 2024 16:37:04 +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 CWmBAs4xDq_e; Fri, 16 Aug 2024 16:37:04 +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 4Wll1p434yz9rvV; Fri, 16 Aug 2024 16:37:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 77EF58B764; Fri, 16 Aug 2024 16:37:02 +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 H7XpVLTItS-Q; Fri, 16 Aug 2024 16:37:02 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.147]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A71118B776; Fri, 16 Aug 2024 16:37:01 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Andy Lutomirski , Vincenzo Frascino , Arnd Bergmann Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org Subject: [PATCH 9/9] selftests: [NOT TO BE MERGED] Modifications for testing VDSO getrandom implementation on PPC32 Date: Fri, 16 Aug 2024 16:36:56 +0200 Message-ID: <376843e024ffa73793e8ed99b72d299c6b239799.1723817900.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: 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=1723819012; l=4941; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=Byt1zoXBB7tbRE1Z7pCXViKFciqFPibE+/C8OmNKnow=; b=0TkkqDKBkMMgL0ugpEAIOflzNK0D+cMm8lg8Wj+L/em3AddbhyydfpVg0Uc1yaCGhlbwMZx9z ux/X3n02YZGAOdDI+RT4hyUEpPrGZEF6i58grcim8hG8jyssOxRE0TY 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" arch/.../entry/vdso/ is specific to x86. Every architecture has a different path. On powerpc it is in arch/.../kernel/vdso/ vdso_test_getrandom is a bit too long with 25000000. Something is wrong with macros INT_MAX ... : In file included from /home/chleroy/linux-powerpc/include/linux/limits.h:7, from /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc= 64-buildroot-linux-gnu/sysroot/usr/include/bits/local_lim.h:38, from /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc= 64-buildroot-linux-gnu/sysroot/usr/include/bits/posix1_lim.h:161, from /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc= 64-buildroot-linux-gnu/sysroot/usr/include/limits.h:195, from /opt/powerpc64-e5500--glibc--stable-2024.02-1/lib/gcc= /powerpc64-buildroot-linux-gnu/12.3.0/include-fixed/limits.h:203, from /opt/powerpc64-e5500--glibc--stable-2024.02-1/lib/gcc= /powerpc64-buildroot-linux-gnu/12.3.0/include-fixed/syslimits.h:7, from /opt/powerpc64-e5500--glibc--stable-2024.02-1/lib/gcc= /powerpc64-buildroot-linux-gnu/12.3.0/include-fixed/limits.h:34, from /tmp/sodium/usr/local/include/sodium/export.h:7, from /tmp/sodium/usr/local/include/sodium/crypto_stream_ch= acha20.h:14, from vdso_test_chacha.c:6: /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu= /sysroot/usr/include/bits/xopen_lim.h:99:6: error: missing binary operator = before token "(" 99 | # if INT_MAX =3D=3D 32767 | ^~~~~~~ /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu= /sysroot/usr/include/bits/xopen_lim.h:102:7: error: missing binary operator= before token "(" 102 | # if INT_MAX =3D=3D 2147483647 | ^~~~~~~ /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu= /sysroot/usr/include/bits/xopen_lim.h:126:6: error: missing binary operator= before token "(" 126 | # if LONG_MAX =3D=3D 2147483647 | ^~~~~~~~ Signed-off-by: Christophe Leroy --- include/vdso/limits.h | 4 ++-- tools/testing/selftests/vDSO/Makefile | 2 +- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/vdso/limits.h b/include/vdso/limits.h index 0197888ad0e0..b0459332e45f 100644 --- a/include/vdso/limits.h +++ b/include/vdso/limits.h @@ -5,10 +5,10 @@ #define USHRT_MAX ((unsigned short)~0U) #define SHRT_MAX ((short)(USHRT_MAX >> 1)) #define SHRT_MIN ((short)(-SHRT_MAX - 1)) -#define INT_MAX ((int)(~0U >> 1)) +#define INT_MAX 2147483647 #define INT_MIN (-INT_MAX - 1) #define UINT_MAX (~0U) -#define LONG_MAX ((long)(~0UL >> 1)) +#define LONG_MAX 2147483647 #define LONG_MIN (-LONG_MAX - 1) #define ULONG_MAX (~0UL) #define LLONG_MAX ((long long)(~0ULL >> 1)) diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftest= s/vDSO/Makefile index 3de8e7e052ae..8010e7be66c6 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -40,7 +40,7 @@ $(OUTPUT)/vdso_test_getrandom: parse_vdso.c $(OUTPUT)/vdso_test_getrandom: CFLAGS +=3D -isystem $(top_srcdir)/tools/in= clude \ -isystem $(top_srcdir)/include/ua= pi =20 -$(OUTPUT)/vdso_test_chacha: $(top_srcdir)/arch/$(ARCH)/entry/vdso/vgetrand= om-chacha.S +$(OUTPUT)/vdso_test_chacha: $(top_srcdir)/arch/$(ARCH)/kernel/vdso/vgetran= dom-chacha.S $(OUTPUT)/vdso_test_chacha: CFLAGS +=3D -idirafter $(top_srcdir)/tools/inc= lude \ -isystem $(top_srcdir)/arch/$(ARCH)/= include \ -isystem $(top_srcdir)/include \ diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/tes= ting/selftests/vDSO/vdso_test_getrandom.c index 05122425a873..f25301c9d46b 100644 --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c @@ -115,9 +115,9 @@ static void vgetrandom_init(void) exit(KSFT_SKIP); } vdso_init_from_sysinfo_ehdr(sysinfo_ehdr); - grnd_ctx.fn =3D (__typeof__(grnd_ctx.fn))vdso_sym("LINUX_2.6", "__vdso_ge= trandom"); + grnd_ctx.fn =3D (__typeof__(grnd_ctx.fn))vdso_sym("LINUX_2.6.15", "__kern= el_getrandom"); if (!grnd_ctx.fn) { - printf("__vdso_getrandom is missing!\n"); + printf("__kernel_getrandom is missing!\n"); exit(KSFT_FAIL); } if (grnd_ctx.fn(NULL, 0, 0, &grnd_ctx.params, ~0UL) !=3D 0) { @@ -146,7 +146,7 @@ static ssize_t vgetrandom(void *buf, size_t len, unsign= ed long flags) return grnd_ctx.fn(buf, len, flags, state, grnd_ctx.params.size_of_opaque= _state); } =20 -enum { TRIALS =3D 25000000, THREADS =3D 256 }; +enum { TRIALS =3D 2500000, THREADS =3D 256 }; =20 static void *test_vdso_getrandom(void *) { --=20 2.44.0