Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2096225ybz; Thu, 23 Apr 2020 11:30:27 -0700 (PDT) X-Google-Smtp-Source: APiQypITvkzvB9HF+GyirHI6FpJLKUbw6yQ39oeNNq9VQD33x92tuSAiB1ClJfBuDsaS9hrw1vWf X-Received: by 2002:a17:906:5918:: with SMTP id h24mr3946852ejq.210.1587666627792; Thu, 23 Apr 2020 11:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587666627; cv=none; d=google.com; s=arc-20160816; b=jbGsoYP7Dx7LlgDZyRJEq0+Z6jqUxymdT/nUZ2ccJAPfsHbG7c16g8sBPC1yu0KYN/ bKpJBRklI+BOTbxQkuqXKmxf7J22oqbO0lM0qFK85L/CNbjPkRDUttZDvdIdWq48pnMO KdwUNhMfOLUxO+YMvfOFnIJC8nPyeaAhNhOsdbw/G4AZrvrLOh5+6HVJKcEgnxxe6USY Aqlm1XDC98LAjWxTpDsA1LuHOjIJM3Z3/EfD1fmOulsW8EmqyYoL4BWiQTdTF7RngU3Y 7al2x5w3HMssYPPRD9S/Y4SHVrUQ7czAzBQHekIvs14goo1m1AOWT+RUZXAtcd21RLMP JWkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6l2OhVohaqlD4hKfwY1YL9IkS67B6tIfRgQm/UCeQLE=; b=UlGNU0aBYat7XJmqZo9y1rSrK+iRtc7NQkNDsbsO6rKItlNTu/oGWyUJGjc2IBXqzj d/moyVzAymTCpvpqQYjtQyPMsPrZjT/YzCcxswY0NzH+Hmm8hr3hjF5/em2XKYilN40T dVT+B0OEwOfnlJlszCq2zLc5iWqQSGN+WbLrAgQplwUqqFg30vgqAOXDGP36wGCXJUAD cp0viCmTjL/OX76c3KoPZUS3l4ZZ8bp7KMa9bewupe+JBXAccH/QVryDZml15KQwru1T xjWKZyqQLfb4+BaBaXal+OoeVddPBuSnJzRvgJWQJIJ4H2rKYJ+xMfNlP7BuE9xckFym q9KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=QDpiO43D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y26si1825523edm.274.2020.04.23.11.30.04; Thu, 23 Apr 2020 11:30:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=QDpiO43D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730382AbgDWS1a (ORCPT + 99 others); Thu, 23 Apr 2020 14:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730380AbgDWS13 (ORCPT ); Thu, 23 Apr 2020 14:27:29 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFC9C09B042 for ; Thu, 23 Apr 2020 11:27:29 -0700 (PDT) Received: from zn.tnic (p200300EC2F0D2E00329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:2e00:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 7F5361EC0D8D; Thu, 23 Apr 2020 20:27:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1587666447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6l2OhVohaqlD4hKfwY1YL9IkS67B6tIfRgQm/UCeQLE=; b=QDpiO43DcGVz16U0f8CoKKwsuY8WUszZmHglJMCFciFR2AZYQNg4D6qdn3u0cejpjZK+mB xKRrzy1ZkgWGtXgQa19cUAh/o+OR6KHQNh+DRlJxtsflsxRuRa/uXLSRTcjZRnLDGu6ApT QY0QYp3vWcKi1jmjY2vjZo0edTTormM= Date: Thu, 23 Apr 2020 20:27:28 +0200 From: Borislav Petkov To: Nick Desaulniers Cc: Michael Matz , Jakub Jelinek , Sergei Trofimovich , LKML , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , clang-built-linux , Kees Cook , Martin =?utf-8?B?TGnFoWth?= , Masahiro Yamada Subject: Re: [PATCH] x86: Fix early boot crash on gcc-10, next try Message-ID: <20200423182728.GI26021@zn.tnic> References: <20200422102309.GA26846@zn.tnic> <20200422192113.GG26846@zn.tnic> <20200422212605.GI26846@zn.tnic> <20200423125300.GC26021@zn.tnic> <20200423161126.GD26021@zn.tnic> <20200423173058.GE26021@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 23, 2020 at 11:02:09AM -0700, Nick Desaulniers wrote: > Reviewed-by: Nick Desaulniers > Tested-by: Nick Desaulniers > > It's too bad that $(CC) isn't exported yet; IIUC we include the arch > specific Makefiles then later export $(CC). If that was the case, we > could just use $(CC) in the shell script, rather than passing it along > as an argument. Oh well. Aha, so that's why others pass it. I used gcc-x86_64-has-stack-protector.sh as an example to slap that one together. Below new version with proper commit message this time. > If I add `echo "hello world"` to the end of > scripts/x86-check-compiler.sh to verify this stops a build, this is > the error message I would observe: > arch/x86/Makefile:6: *** clang check failed. Aborting. Stop. Right, or you can comment out the asm("") in the script and then it matches the "jmp" and thus fails the build. As it should be. Thx. --- From: Borislav Petkov Date: Thu, 23 Apr 2020 19:28:28 +0200 Subject: [PATCH] x86: Check whether the compiler is sane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check script to verify whether the compiler is sane. This is x86-only for now and checks one thing only but should be useful for more checks in the future. Suggested-by: Martin Liška Signed-off-by: Borislav Petkov Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers --- arch/x86/Makefile | 4 ++++ scripts/x86-check-compiler.sh | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100755 scripts/x86-check-compiler.sh diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 00e378de8bc0..38d3eec5062e 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -1,6 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 # Unified Makefile for i386 and x86_64 +# Check the compiler +sane_compiler := $(shell $(srctree)/scripts/x86-check-compiler.sh $(CC)) +$(if $(sane_compiler),$(error $(CC) check failed. Aborting),) + # select defconfig based on actual architecture ifeq ($(ARCH),x86) ifeq ($(shell uname -m),x86_64) diff --git a/scripts/x86-check-compiler.sh b/scripts/x86-check-compiler.sh new file mode 100755 index 000000000000..b2b5b54b6939 --- /dev/null +++ b/scripts/x86-check-compiler.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# Check whether the compiler tail-call optimizes across an asm() statement. +# Fail the build if it does. + +echo "int foo(int a); int bar(int a) { int r = foo(a); asm(\"\"); return r; }" |\ + $* -O2 -x c -c -S - -o - 2>/dev/null |\ + grep -E "^[[:blank:]]+jmp[[:blank:]]+.*" -- 2.21.0 -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette