Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp318750rwd; Mon, 12 Jun 2023 14:08:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7c37U/bVvjTeypJkqdNkYwYcU9gm6022hLOaPPO1Z7WXKPeclq8VSgfCry9X7Hab3HEwFX X-Received: by 2002:a17:907:3e81:b0:977:eed1:453c with SMTP id hs1-20020a1709073e8100b00977eed1453cmr13442547ejc.73.1686604136715; Mon, 12 Jun 2023 14:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604136; cv=none; d=google.com; s=arc-20160816; b=xVuC0Ac6PWy/gdJ+JIMUoICdTdy9rrqcxAmI9ji8aP3szOHjL1oPbY/abnkKBSUm0q 0+eeqLlmzRu2kwBuN/3Whk5r9FjEgKExhoCmLPtmHStbB1fjMaAPWOJGGWDDmPVascAG bJkT97j14v3Z4FufN+Bb0DigZifVGHgw30w9K8k9wXw+h12lFMyEfYrfkO2B0gep1x3G 6TnJw2BK3KkngOjwk3CaQUQLe/2YyzZcQOZ97AX+fHedqRlYPAPzhFK/eusJgkJf8Ga1 NeR1njqBpm1eaTYFX+pqoddcVuLGBmWY+tBApZtSz34TDfZty/ZhVxtTcFiYbbbkemxu t62Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9lHx1WijCPG0yUBn1kqHn3u/XLFPDQiani9s1uz0B14=; b=QE6MhP1fKXcRp0tMyDNEjuDoaYbk2iUN4M1rBP/VP6sEzfhVYB7Cmr2Ke0moDmmoFo 23ESF9Aho4rp3kKkgWsIgNIBsaMUk1D3uNPnJAzpFjLg5dgS4kTlz4GnChh6EMAfKBKn 7fydJPtbtLSptZy/MKMoVqkXtbRo0xCgypALNarRRuEnkSSY4YlWWmO2zPdsQG0psq1k pt21ZrUAMQJvNT0fAuAl9AlZm8IjXJ8sETTYVsKIK2FmFuEsqzmyPo0cOjTrhBtJcphf acFlZN3HfYs3LBegEWaeqy1NaurZhFGmZf8keWVk0KV1rYznWRk3HGmGgux5r3P1vNc9 3V8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sepdplrR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d24-20020a17090648d800b00977d2d3b9b8si5406474ejt.117.2023.06.12.14.08.32; Mon, 12 Jun 2023 14:08:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sepdplrR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238502AbjFLUvb (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238186AbjFLUtX (ORCPT ); Mon, 12 Jun 2023 16:49:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE531BCA for ; Mon, 12 Jun 2023 13:46:57 -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 0043A62F2A for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB36DC43446; 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=1686602717; bh=I2MKwbUvzTuvTg2VmUjHO7LHWoQiT/tq3IBYoDNtSDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sepdplrRhQWPURYc5Eqxn1hVYV8IEGy/GYobS/5P/D2fHijzw8lby2q0YTYxZpYzo GZ7SWBWY8UUB4tkTStczqsAssWZQuy7j698x1Nk57vNGcwMx6NuT7jZKWKIOfYPRC6 5O/ik1/GEeLjn4G+JRPnr8JwvcuGTw8dombfevh2SJUl09C/0yFB3iSBDuK+OdutPk cyN5dOTO5P4yg2hSOoH0oYGKgwUDl9XLrn4NL9UcojSCGSktvSE+7E3uqv6+L6Am99 cf3FJ2fL0sJIJiCt5XGaE3YdPhNr+VBggsVzmMFx2fo2fG/e0fJDPxgZnwm8y/IPw2 s7Jd4pMZ8hEng== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DA96DCE3A66; 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?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 22/53] tools/nolibc: loongarch: add stackprotector support Date: Mon, 12 Jun 2023 13:44:43 -0700 Message-Id: <20230612204514.292087-22-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: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-loongarch.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index ec3b46a991a9..07e3b1fd7262 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -149,6 +149,8 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + #if __loongarch_grlen == 32 #define LONGLOG "2" #define SZREG "4" @@ -170,9 +172,12 @@ const unsigned long *_auxv __attribute__((weak)); #endif /* 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 ( +#ifdef NOLIBC_STACKPROTECTOR + "bl __stack_chk_init\n" /* initialize stack protector */ +#endif REG_L " $a0, $sp, 0\n" /* argc (a0) was in the stack */ LONG_ADDI " $a1, $sp, "SZREG"\n" /* argv (a1) = sp + SZREG */ LONG_SLL " $a2, $a0, "LONGLOG"\n" /* envp (a2) = SZREG*argc ... */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 7585035cbb0d..ab6e7c0c2494 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -84,6 +84,7 @@ CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ -- 2.40.1