From nobody Mon Feb 9 11:47:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55770C7EE43 for ; Mon, 12 Jun 2023 20:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238481AbjFLUvZ (ORCPT ); Mon, 12 Jun 2023 16:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238095AbjFLUtC (ORCPT ); Mon, 12 Jun 2023 16:49:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCB6296B for ; Mon, 12 Jun 2023 13:46:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EEDDF62F26 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFB9DC43444; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=GOuO4QtR996HCmcdYQAWMIyqhycVTQWVHdyq4/4h32g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hlX9DSdeVteob3wFd4346DXdfp9KfFrfNJiGAadHUIRiM6b+gRTHNEz55OCXoCxeu wcmoVXHUN/Rm6bbMMhM6nv2BgUopEg1fxrK0EwG6Qfsv524xW7vZR32zJvrsb8zDX1 S8Kct9/+0fmKNRLv2YDiwFcTcb9SCf/7yo6HKe8os/YoFWVDuwi6vTCTfRAK7ToMxu gzxchzk2GJFjeehNtu691BdXiQTsE+u4Y5NRS2nrvXgt+j7MqGtNdR/YHsRVlZiF3p thnz5Qdwc0gC3C1nxga7E+bdlSOGiRDL+LpnoNNv6T+9VKLsj3vIysP4BCnl7B97d2 T/jxKSuR7M0Eg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DF9B1CE3A6A; Mon, 12 Jun 2023 13:45:15 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Palmer Dabbelt , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 24/53] tools/nolibc: riscv: add stackprotector support Date: Mon, 12 Jun 2023 13:44:45 -0700 Message-Id: <20230612204514.292087-24-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Wei=C3=9Fschuh Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Palmer Dabbelt Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-riscv.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-= riscv.h index 992a1739dd9c..d0439249c9c9 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -177,14 +177,19 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); =20 +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(= void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_= protector)) _start(void) { __asm__ volatile ( ".option push\n" ".option norelax\n" "lla gp, __global_pointer$\n" ".option pop\n" +#ifdef NOLIBC_STACKPROTECTOR + "call __stack_chk_init\n" /* initialize stack protector = */ +#endif REG_L" a0, 0(sp)\n" /* argc (a0) was in the stack = */ "add a1, sp, "SZREG"\n" /* argv (a1) =3D sp = */ "slli a2, a0, "PTRLOG"\n" /* envp (a2) =3D SZREG*argc ... = */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 6d660d922240..bd41102ea299 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -85,6 +85,7 @@ CFLAGS_STKP_x86 =3D $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 =3D $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm =3D $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_mips =3D $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_riscv =3D $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_loongarch =3D $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 =3D -m64 CFLAGS ?=3D -Os -fno-ident -fno-asynchronous-unwind-tables -std=3Dc89 \ --=20 2.40.1