Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4184449rwe; Mon, 17 Apr 2023 09:04:01 -0700 (PDT) X-Google-Smtp-Source: AKy350axXJwdAhqWgQ+aO8GhNlEZX+8OVONUNjho6onTdWyDRxW9KXH/7cbUogZII+3fXQ4zQvTg X-Received: by 2002:a17:902:ce92:b0:1a6:dba5:2e3e with SMTP id f18-20020a170902ce9200b001a6dba52e3emr4689683plg.25.1681747441120; Mon, 17 Apr 2023 09:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681747441; cv=none; d=google.com; s=arc-20160816; b=0nv7oOZZdHlVl8r48yG/hB+F4FL469FeWj39jJQxgVYdftt/BcJskPSJUHYUvUqlOa vtsh/KUtkA3BpvuncB6/yWid0lqOB7OBdMf4cmqsv6RJf8n76vYqVNJ9T/bW2L9odWSo uG8VJHIhdRXmYOeF03y4N+NBBmcNK+Ds384CtOG2HNZQUQ1NUL8DCadjF+JacpAK1xPv r7cfcxibCxtcnQn7wHOIZPtc+CSkJWdSmJsR//f8g4NpOdG8CS7fuumE4+Qf9zfQX71u 9a9dmIRtCmjFLCjNtKG3sJW8h1+zEX313XlYKs8/0dCMr+9EhQSboxV4TvzWg7HP0REf pNQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:dkim-signature :from; bh=oU+T6S53O2ga0K7KqWx3fdGkT6Tg9SMgZLzw1sFrx1s=; b=oiAyn+P1g/GGn0mgZTy7WVGnIE3IalTFuHnmtm0+i+iNhU2El5n49WzweNnihxZ/od L7qs/66RKOFU+L4H8Zvlc8aq3rg4yT6fr09qN0UpkKbDMWZt6FrqdKo5k6rUOavHfuNf DgK4Ox/EfsywOsIZ/llHragqcfsmq21ecnoEgfsfSJCHKgPbDLJW+2BiIOB1esbfYijU mYBMuNFVK3Y0bnJoV/H6CLKSr4Lb0pRpfmX7pxEzqb7WDoQnpXGhOfzrhGI3zvfqi2pG ieG0HEZeBDKAek/JA38yFKFwqwFfFgnMyojc7NtwnbY74itSDmM3C6GcE56WOM0cgUk2 iFuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=nl94KQlg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a63130c000000b004fc39adf481si12590233pgl.381.2023.04.17.09.03.49; Mon, 17 Apr 2023 09:04:01 -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=@weissschuh.net header.s=mail header.b=nl94KQlg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbjDQQCQ (ORCPT + 99 others); Mon, 17 Apr 2023 12:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbjDQQBy (ORCPT ); Mon, 17 Apr 2023 12:01:54 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 272C0BBA5; Mon, 17 Apr 2023 09:01:44 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1681747302; bh=/tBIqb3YiZRud1yDXqeDbEhl0GcdVbv2DqKYt4+iwGU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nl94KQlg1GxjCKOnf3UNM2jbbKw3sUtF6qW5kFgadFHgqlsy9AH06gsgaZ0sixF+I 6A+a9ZSnWL7U5mecK+r2wOoL137aNZ6sPxhhFrRaj1nRsNTnKlwhOdGG2lL8W6CIlY Qf63zPue1aDtonPgAADlS5vgM7meZRkNFoCwZVRE= Date: Mon, 17 Apr 2023 18:01:35 +0200 Subject: [PATCH 5/6] tools/nolibc: loongarch: add stackprotector support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20230408-nolibc-stackprotector-archs-v1-5-271f5c859c71@weissschuh.net> References: <20230408-nolibc-stackprotector-archs-v1-0-271f5c859c71@weissschuh.net> In-Reply-To: <20230408-nolibc-stackprotector-archs-v1-0-271f5c859c71@weissschuh.net> To: Willy Tarreau , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681747300; l=2073; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=/tBIqb3YiZRud1yDXqeDbEhl0GcdVbv2DqKYt4+iwGU=; b=vUkGNETLBzKth36N1KX6EIz8V04NLKaAwiZOLdqvzTD05bUymN/ILZN3wB9aRQjizoh52oWpG Vtj14M8jfS4CD9pYv6bBtf3wqMtw00w0vxjbDA5lpeOdzykdGs/JFx9 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Signed-off-by: Thomas Weißschuh --- 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 8feffc790a31..efa7a51e0fcd 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -85,6 +85,7 @@ CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_riscv = $(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.0