Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2045183ybz; Thu, 23 Apr 2020 10:34:23 -0700 (PDT) X-Google-Smtp-Source: APiQypJ3T7j6H6vT3roubDDMS6Xwx4NadcDWC+UBldAJHXzSk6wOofu8QmNy1ImunWf7DRd9JGLI X-Received: by 2002:a17:906:6a02:: with SMTP id o2mr3532613ejr.223.1587663262932; Thu, 23 Apr 2020 10:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587663262; cv=none; d=google.com; s=arc-20160816; b=eRGNKNbbovPfeTi+LCOGzo8lMTcdSgyXkq/pTl9rZx1fZkbaTKjyAQ955y0VuY5+bD HeMQPxGAhEVJuqEWPAuy9ayr7o2C00J2msCgfHDfoCI4aDXaaLwQDph96DwbCXNKgHvs PJW+zYf58LInYw+Rbm7+ntzkIjfwxuTyy7PtBYbCq91yeQtksSLt+i5k8r/fxGFOCk7F PjhSvvPS5gf2nsHv/Vgp4Oyl61CPFvTtBF+rYP10AXtUshDqOMBvxIXxQ7C44QDIz0CQ hMANGZMfRweQnu/OMydo87tAbPDhIImmoJ6fRQN+ud+VlTnWW2kcvuGHZqvEZcB8PkaX EohQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=r4OL11TH+fTo0NNwv+4evRIfxa9+U11aNGFnhjxhNqc=; b=hsEOTXTfHf8ZmSmdmxkDxRtw/sF7VtDyZccpFM3/HcwmEF+X+qOp0KDucvgTrtXpqZ +fMOmNC1Cth28bOYVyTETo9qagMSezUsdh3QoYPBBN20f8zbOpiXzs1BY7FNrK0vx1v3 ilR4OCzPqjvRlvSGXQ+RjakI1sUqx8OOdjbmvHDEoiYeAP8feMtmw9K/+MNOctHMiCjw Zgy5WWzjGx+gub9AkDHRKuiBrtpP7voFN/HDEJwsgmV7AbZhb86wKnFHc622uhvL15Hy zDEXG25ZRcECRcXxTvxlKU6y1G+MgLOEYhj6PnpkQuzhGywXySaiWSG3RAddKrdFXwtK ZcSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=n+EbahP2; 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 x16si1582703eds.487.2020.04.23.10.33.54; Thu, 23 Apr 2020 10:34:22 -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=n+EbahP2; 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 S1729959AbgDWRbJ (ORCPT + 99 others); Thu, 23 Apr 2020 13:31:09 -0400 Received: from mail.skyhub.de ([5.9.137.197]:46346 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729858AbgDWRbE (ORCPT ); Thu, 23 Apr 2020 13:31:04 -0400 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 5993D1EC0D79; Thu, 23 Apr 2020 19:31:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1587663063; 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:in-reply-to:in-reply-to: references:references; bh=r4OL11TH+fTo0NNwv+4evRIfxa9+U11aNGFnhjxhNqc=; b=n+EbahP280zPlUpPoH0ixnYJEhus3hnYtW9M+sKHgVNqyOVsI6vpsO/L5f8SJVC6LO3oFp 1KQWny+ktdhF1oPkquTyXMUcITSA6CNg/Ma/tYHkz8vCok+aP4F+I3px7kTsJtvBcRryqf YUe87PkmKIE14xsGBGqXBfQM7MymD/U= Date: Thu, 23 Apr 2020 19:30:58 +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 , x86@kernel.org, clang-built-linux , Kees Cook , Martin =?utf-8?B?TGnFoWth?= Subject: Re: [PATCH] x86: Fix early boot crash on gcc-10, next try Message-ID: <20200423173058.GE26021@zn.tnic> References: <20200422102309.GA26846@zn.tnic> <20200422192113.GG26846@zn.tnic> <20200422212605.GI26846@zn.tnic> <20200423125300.GC26021@zn.tnic> <20200423161126.GD26021@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200423161126.GD26021@zn.tnic> 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 06:12:24PM +0200, Borislav Petkov wrote: > Ok, > > I have tried to summarize our odyssey so far and here's what I came up > with. Just built latest gcc from the git repo and it seems to work. > > Next I need to come up with a slick way of testing the compiler... Maybe something like this. Seems to work with both. --- From: Borislav Petkov Date: Thu, 23 Apr 2020 19:28:28 +0200 Subject: [PATCH] Check compiler Signed-off-by: Borislav Petkov --- 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