Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp314754rwd; Mon, 12 Jun 2023 14:05:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5iexGx8u2HhfxrPwiAodALpHkkwmkn57O31E9/zo5EZw0hXQBurC+0f4Uc+vfJP/En6wlo X-Received: by 2002:a17:902:e88c:b0:1af:d812:d27 with SMTP id w12-20020a170902e88c00b001afd8120d27mr10491579plg.9.1686603915942; Mon, 12 Jun 2023 14:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603915; cv=none; d=google.com; s=arc-20160816; b=OyYUg4uJZ4rqdV2ejFI4oTtWYyKQM3TzJ1xHoCeuxY3UwubHAsMsJZZYPvZFsQZp0E ZuEoLIA61op1QJm01I52Vwf/UvIBC6ytkdNP4XcwiaT464Vla6qy2Rr9mVGLB7DsnjRZ wRqWJyfZLwFv/ewcL6QubADJdlbHiQxSNXFGIVcNNsX7ntUqGuc9ZTmN12rbqfx8rIn9 kYdvyI4RTyYHgM34yaXH7Z0d+Cd0nWS3SZZg8JiiBFVYsrNrX7eoSzKmlBqpdmLtj5sS pmkJ8fYYG2LWEHd3KMd/DL1bt5WaQWSNQ5YpILiFygZo28tsLw26/WNBD7rSa1Tk+ZUg GL4g== 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=uC89yjat/oW3A+F9zMnUu8H1kTobr3xcMmKfZU4gA08=; b=OnKUKaGYy3JpcGMZOvj4bpzYMHchy9t41ruHSSMioG2QwBT9v1qwQWXjC/n8ttOPY5 3OQV5dHEL+mK8S1cydBWktI6LghIoifSuqz9/W7OLuu5YT2kABOtAGq/gqxNf6Q1ToV6 /9dcu+8CXbCSpNA9L/JFtr5XssFVnAAXl+J3Z98LYWqm/cmotQItRiNnVP33CLyR73Dx ard/eyjDGL7IdSUXltMtxihuaKjbC3URf1MDqaCL+mkPbMt8VTfzy4RrlibDNCFowJ1P KfVVpnt5hn7J7LZEXY1HqhVoG3tY98Cq/am5nIFGLi4hvXvr5R7w+Tb3l/mVnkcJPx+e cIJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZNnxDU1T; 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 e7-20020a17090301c700b001b1cdef2654si3655620plh.645.2023.06.12.14.05.02; Mon, 12 Jun 2023 14:05:15 -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=ZNnxDU1T; 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 S238068AbjFLUsm (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbjFLUra (ORCPT ); Mon, 12 Jun 2023 16:47:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2394F295A for ; Mon, 12 Jun 2023 13:46:37 -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 8517262F03 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8AFBC43443; 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=tOuRtkHYs9MNwpbcUTDT/8K9pnXHgkjL97lAfJJGhgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZNnxDU1TXOuRT3FMSlYGWrX0TkT4AnPHvMcSbWXHi5JWoxLutDnUjo15h76iV4cKW qslqvv7be++VpA8Zr3gwFpBBSiOqQblpmO5Zmed38F94zw01qMYj0ShI3GVKjca1Uk zMSSY+BHp81+3g7VxTFbVp3LEZibSYBeoubXkpLFBZsLnQ/vyPASWFl/ljpH0kHC2P SMu+jlclqrf6MsdDE++4fzt0ZmYc4NGhtLSfb3xf+CTQmSlcZdk3CGDz9cV8NKfnBd f/WP4YI79WjskRDkr5yz6J2y2Ir5xmayucKTJbE2o5qjFNuBT2bW7C/V9MSnNTMuT8 xOoUzA2A1ILZA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DD080CE3A68; 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 23/53] tools/nolibc: mips: add stackprotector support Date: Mon, 12 Jun 2023 13:44:44 -0700 Message-Id: <20230612204514.292087-23-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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-mips.h | 8 +++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 8822f150e72f..65c19ccc7f9d 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -179,14 +179,20 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code, note that it's called __start on MIPS */ -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 ( /*".set nomips16\n"*/ ".set push\n" ".set noreorder\n" ".option pic0\n" +#ifdef NOLIBC_STACKPROTECTOR + "jal __stack_chk_init\n" /* initialize stack protector */ + "nop\n" /* delayed slot */ +#endif /*".ent __start\n"*/ /*"__start:\n"*/ "lw $a0,($sp)\n" /* argc was in the stack */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index ab6e7c0c2494..6d660d922240 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_mips = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ -- 2.40.1