Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp801566rwd; Sat, 20 May 2023 07:04:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Rfbp+CDaWr6+bIx5guZ2oYNYhw9B5LnRw0GVRBI6hSHE9z6HCuN5cbLPN9NviQMS1Xvp6 X-Received: by 2002:a05:6a21:3282:b0:100:900f:74a5 with SMTP id yt2-20020a056a21328200b00100900f74a5mr6125226pzb.56.1684591441030; Sat, 20 May 2023 07:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684591441; cv=none; d=google.com; s=arc-20160816; b=mf6m/QZ98rauKaLvt6X1ML0VLQftn60tCoDWos46768gAiuS/zCh+OqpKZ2pd3jFJA 0Im10T714GoumAQozxCnwXg40Li+UwW07fAxNv1MDXSwm6jRk7m0tVIV/I0yhUCNMLGs ksvTkq/DhtAkPLHf8mTjDJXKSS/Yg7NbsMPqQzI85WtrKi9T1VrfQIvRftnmsrB7SwMF 4S5YuVqA1z/fbi1KQFnHnSds5nQ/3q0SLEPtKnCBtZKeWPLVbxxNiZC1UOsLfIyI4SwW 5kTCONE+r+8tn7DRRcU/kYMbrK2uTUz9SfGYSEWgUqSUBU+oEfCecqx/ynDdxwIhrNmr Qv2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=PYWXKOX/KkFc7KjYuXL8fF3H8ruaEOSIikwnVbEuv2g=; b=w9xNKG6OQirmu9EhTUSFeIR9d2hmJkq9tJmUFNsdI26rAlmN1z2EymtQ2+FIG2dkOT GYfwJS3CvqpyL0okfyGZzqptmu/cnBmKwaY7ikoSCC4ucQjkjy2PL3tHWEHvwJjnO7DM +PKWfxBa+XJYXzrQH8gJtR/QMSyFy6sqa9pzTjzQgncEF6egwHiYcpXCtV5VqMBR+BYq Y3PZ6MPL5Uz59mIskNPOZYvtBrj/6sCFafHW5kTBda42ZY5a3xAkFn7aw6xgVj8ivn2c PA43Juyf+4o6N2IDeYtIkiBhcGNVSRxEVJJnNHcdXIuCmAYh6yObJbTQkH3AqlATULSM XRwQ== ARC-Authentication-Results: i=1; mx.google.com; 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 y6-20020aa79ae6000000b0064d32440768si1602234pfp.138.2023.05.20.07.03.45; Sat, 20 May 2023 07:04:00 -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; 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 S231379AbjETNdA (ORCPT + 99 others); Sat, 20 May 2023 09:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbjETNc5 (ORCPT ); Sat, 20 May 2023 09:32:57 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FDF7F7; Sat, 20 May 2023 06:32:55 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 34KDWbtl027582; Sat, 20 May 2023 15:32:37 +0200 Date: Sat, 20 May 2023 15:32:37 +0200 From: Willy Tarreau To: Zhangjin Wu , linux@weissschuh.net Cc: aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, shuah@kernel.org Subject: Re: [PATCH] selftests/nolibc: Fix up compile error for rv32 Message-ID: <20230520133237.GA27501@1wt.eu> References: <20230520-nolibc-stackprotector-riscv-v1-1-d8912012a034@weissschuh.net> <20230520120254.66315-1-falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230520120254.66315-1-falcon@tinylab.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 Thomas, Zhangjin, I've merged your latest patches in my branch 20230520-nolibc-rv32+stkp2, which was rebased to integrate the updated commit messages and a few missing s-o-b from mine. Please have a look: https://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git However, Thomas, I noticed something puzzling me. While I tested with gcc-9.5 (that I have here along my toolchains) I found that it would systematically fail: sysroot/x86/include/stackprotector.h:46:1: warning: 'no_stack_protector' attribute directive ignored [-Wattributes] 46 | { | ^ !!Stack smashing detected!! qemu: uncaught target signal 6 (Aborted) - core dumped 0 test(s) passed. The reason is that it doesn't support the attribute "no_stack_protector". Upon closer investigation, I noticed that _start() on x86_64 doens't have it, yet it works on more recent compilers! So I don't understand why it works with more recent compilers. I managed to avoid the crash by enclosing the __stack_chk_init() function in a #pragma GCC optimize("-fno-stack-protector") while removing the attribute (though Clang and more recent gcc use this attribute so we shouldn't completely drop it either). I consider this non-critical as we can expect that regtests are run with a reasonably recent compiler version, but if in the long term we can find a more reliable detection for this, it would be nice. For example I found that gcc defines __SSP_ALL__ to 1 when -fstack-protector is used, and 2 when -fstack-protector-all is used. With clang, it's 1 and 3 respectively. Maybe we should use that and drop NOLIBC_STACKPROTECTOR, that would be one less variable to deal with: the code would automatically adapt to whatever cflags the user sets on the compiler, which is generally better. Regards, Willy