Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2143411pja; Thu, 26 Mar 2020 10:21:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvaA4+JxTDbRx24FkLiZOYRGzoLWo4mv4zNaZd9ujmOLaK39iSj4RemuuxmsO9ERTlONdPl X-Received: by 2002:a05:6830:4008:: with SMTP id h8mr7415376ots.295.1585243262472; Thu, 26 Mar 2020 10:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585243262; cv=none; d=google.com; s=arc-20160816; b=CfmxOdLk5mkwp06E9tDqWe4Pfcbj9r+hOtOXbxAQ7OGefm7beJnSI2Jjl9vSLgUDot f0otpE7uiwVYclS/Sbv4gkIoy4ijEKVPvZwCwGYPCNfVDsi5jZ5Cd9iE9tunPIIAGkUc VAv+bmCjeltPl6tnv/+OdDIvlPJxRNUMU0R00sWr/iMHv6NyYPQm7rK8TxN7mG9pq4Wg elKTzWXdUJ7bgtICuesIBrDIhB1b8m8dJwGAmomU3DLmSzfz67r7o3eQ42uGLqoxLDGA UY53aXykfiCbHoiX4C/utxdXoI0QaYetKHdJ5wE4NahliTXHIJpdOkIWm8aTCj6PlpnJ XRgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0r/SurdDSCSAHVti9CZwgq0zi7acyKoJlvToplzgYwo=; b=xxHg41QLndE8P1l8u8dVulOBBvphwRqjhWecD0HcOylyC2C7lInlZaww/ZbvfVCsX0 m5TCGvFNFtLSWKEKAWX4HyVDombKTyHlOVkrulW66/cKFbZ31Px2avNfA4xexADSC5Hx HyG+87yOzlKjyG9l+QDlpt5IPcGcSIbBOgEKsGF7xA53wEXV8elZl43jufOztRkpl75b rwFZNWrL5vpq7nY+Uh5DHaOI5KSavedd1JaEWUsxJvb3r4Z/qgNf6toiXG9mJh4demQl WWW/S3Ob1kwxAQ4t66BLlGc0WRlq6u5nNzOQ3W/XmD0PeHpBm/7Ay1sr35eEhYcid8kI JPCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vk72SUbH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t125si1120192oie.167.2020.03.26.10.20.49; Thu, 26 Mar 2020 10:21:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vk72SUbH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbgCZRTA (ORCPT + 99 others); Thu, 26 Mar 2020 13:19:00 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43264 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgCZRS7 (ORCPT ); Thu, 26 Mar 2020 13:18:59 -0400 Received: by mail-pg1-f193.google.com with SMTP id u12so3192770pgb.10 for ; Thu, 26 Mar 2020 10:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0r/SurdDSCSAHVti9CZwgq0zi7acyKoJlvToplzgYwo=; b=Vk72SUbH0AvbkhQ5XzcwGL7Voe73IZEF73e/9vZHeWg3ayRXD7y/T9U7Uh5KWQjjP8 CngWsDMtAPuLWsVlmB7aXos16mH3SNU0M8VlXfCMvp/8Bx9WCHkMBqDmkU0TZ7L01CCW e/AUEQ1wJPERfVcLRtO1/uNX+Ay7mqmrzOVwtTg97qIX6gAwTaUXjesu1tEQ/zlL9/rk 1cmlxmMeuk46R2/U46OrkAlX4oM9FUMXLbvQnIGajbNyi8POyK6bFhuk1yWjrqUn7rqr ODl5/33x6szSqlJdysIchhk/nbfRB0LxnzH2MWIHVjMQ4woLENNRFnDJkF0NI40SjDXK iXZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0r/SurdDSCSAHVti9CZwgq0zi7acyKoJlvToplzgYwo=; b=kQVphSg6t/bbd2nBzYOZLbeJqUNDCEnI1f5HsWf68DE//PL+FB2M83uS8bsezhk88i dj0LOj33ETnsdNRhny1z0sGCX5LLQcEw473VZLjwgXcSX5WsEV5GwS56Aw+PMpex19Wa hWNOutEDzBVkQ19mK576m1AMZSKd169GwNJIYj5IIiUmyjaq2XSk9IofIBLtb7Jb4n7f q6ElVKk6oEfCYg8Q7BHXy/mSs3dLjnRDX75s784k8IhE2u2QFapI1PV17MBB/jPdDpPb RK/46wlJFEiu26HCAmc6gDD0Cu8GruNTkxU46FiXhnDQWOnUmlbDQ2ogA74wPtb+5lFH HAhA== X-Gm-Message-State: ANhLgQ0gjTashibggpb4GD4uTwqoYN2c8aRtE9MqY07ikR3eR3cEuROa 6p6UkDakW9YAObsjX8Wnj2Vcc2/sr8026I5nOJ9xQg== X-Received: by 2002:a63:a34d:: with SMTP id v13mr9360167pgn.10.1585243137461; Thu, 26 Mar 2020 10:18:57 -0700 (PDT) MIME-Version: 1.0 References: <20200323114207.222412-1-courbet@google.com> <20200326123841.134068-1-courbet@google.com> In-Reply-To: <20200326123841.134068-1-courbet@google.com> From: Nick Desaulniers Date: Thu, 26 Mar 2020 10:18:45 -0700 Message-ID: Subject: Re: [PATCH] x86: Alias memset to __builtin_memset. To: Clement Courbet Cc: Nathan Chancellor , Kees Cook , Joe Perches , Bernd Petrovitsch , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Segher Boessenkool , Greg Kroah-Hartman , Allison Randal , linuxppc-dev , LKML , clang-built-linux Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 26, 2020 at 5:38 AM Clement Courbet wrote: > > I discussed with the original authors who added freestanding to our > build. It turns out that it was added globally but this was just to > to workaround powerpc not compiling under clang, but they felt the > fix was appropriate globally. > > Now Nick has dug up https://lkml.org/lkml/2019/8/29/1300, which > advises against freestanding. Also, I've did some research and > discovered that the original reason for using freestanding for > powerpc has been fixed here: > https://lore.kernel.org/linuxppc-dev/20191119045712.39633-3-natechancellor@gmail.com/ > > I'm going to remove -ffreestanding from downstream, so we don't really need > this anymore, sorry for waisting people's time. > > I wonder if the freestanding fix from the aforementioned patch is really needed > though. I think that clang is actually right to point out the issue. > I don't see any reason why setjmp()/longjmp() are declared as taking longs > rather than ints. The implementation looks like it only ever propagates the > value (in longjmp) or sets it to 1 (in setjmp), and we only ever call longjmp > with integer parameters. But I'm not a PowerPC expert, so I might > be misreading the code. > > > So it seems that we could just remove freestanding altogether and rewrite the > code to: > > diff --git a/arch/powerpc/include/asm/setjmp.h b/arch/powerpc/include/asm/setjmp.h > index 279d03a1eec6..7941ae68fe21 100644 > --- a/arch/powerpc/include/asm/setjmp.h > +++ b/arch/powerpc/include/asm/setjmp.h > @@ -12,7 +12,9 @@ > > #define JMP_BUF_LEN 23 > -extern long setjmp(long *); > -extern void longjmp(long *, long); > +typedef long * jmp_buf; > + > +extern int setjmp(jmp_buf); > +extern void longjmp(jmp_buf, int); > > I'm happy to send a patch for this, and get rid of more -ffreestanding. > Opinions ? Yes, I think the above diff and additionally cleaning up -ffreestanding from arch/powerpc/kernel/Makefile and arch/powerpc/xmon/Makefile would be a much better approach. If that's good enough to fix the warning, I kind of can't believe we didn't spot that in the original code review! Actually, the god awful warning was: ./arch/powerpc/include/asm/setjmp.h:10:13: error: declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header . [-Werror,-Wincomplete-setjmp-declaration] extern long setjmp(long *) __attribute__((returns_twice)); ^ So jmp_buf was missing, wasn't used, but also the long vs int confusion. I tested the above diff, all calls to setjmp under arch/powerpc/ just compare the return value against 0. Callers of longjmp just pass 1 for the final parameter. So the above changes should be no functional change. -- Thanks, ~Nick Desaulniers