Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp750054ybz; Wed, 22 Apr 2020 07:21:03 -0700 (PDT) X-Google-Smtp-Source: APiQypK7pl4vndO9W4XJEYqvPjaky441qufLh5nHMts9D7fk1X07jemIvbMm57th+W/C7X1fQSXu X-Received: by 2002:a05:6402:206f:: with SMTP id bd15mr14105402edb.24.1587565262817; Wed, 22 Apr 2020 07:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587565262; cv=none; d=google.com; s=arc-20160816; b=v6bGBPhNej0pHrJ3asbQQpQO0HviiffyI1J+IoZMCu5RsMNRAhuk+OKVcPs8ChhATN wt649jocTk9moCPQAZAGEGHnybIt3aIcbHVDxebt8iV6EyRKmwUtEzJqQSDQ8/rcp9nk of/lSuv9tBIbWUke2QZIi72j7VGoPxo1lU8IlkQYm6Xnzur63mHtHxjEIoFKFK4CVH3M IzXmO1BbBWNqlyglRTNIQuu6x5RjS4QZgc1roLJ9/nEw/SeThWl5BVx5l/Cuv+ct6InB 7P5e+pXEKhg0BR4qxc+KKAy9sx+dAnJdRixqf2FbZwWZKRqu8p5M+YUSd+4X3NF5z72C RI5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=dpk6DwADuC9GGZXNf4vDkuxSq/4VK2Z9DdSJM2OsUFE=; b=dQ2lRqDpinL8w8WvBrivIrczre39OuNKyyx+TZeSIbWqMuqnVSvDKysqBMZBR1qrkB OLwTolmt5mWQ64Ma60PANjQ3oWnWN5EI7eecetrqhlOTX1ylMTsJUpNVnuZzGLl4Dl2y kRbsv9nxqPRrKi02fQbNdz3etZks93ZuAlWqr/0MCHRF9uFTx11sR5q02Dszd9GrxW/G K4Fz4foyp4ttTMdE4U2aZRgrS+5LJLYsAYoipgjSOz4eKdnEW2oomXSDiJ7ruobfbLF8 qUYVs+kKKWWrWIUhaFLNwjeAi3nZErlZcO3scX9xlbwxYiG7WIWRb6al7LELnCigzN1r /SLg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si3410922edw.425.2020.04.22.07.20.34; Wed, 22 Apr 2020 07:21:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbgDVOQ5 (ORCPT + 99 others); Wed, 22 Apr 2020 10:16:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:35214 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbgDVOQ5 (ORCPT ); Wed, 22 Apr 2020 10:16:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 83D49ACF1; Wed, 22 Apr 2020 14:16:54 +0000 (UTC) Subject: Re: [PATCH v2] x86: fix early boot crash on gcc-10 To: Jakub Jelinek , Borislav Petkov Cc: Peter Zijlstra , Nick Desaulniers , Michael Matz , Sergei Trofimovich , LKML , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , clang-built-linux References: <20200417085859.GU2424@tucnak> <20200417090909.GC7322@zn.tnic> <20200417190607.GY2424@tucnak> <20200422102309.GA26846@zn.tnic> <20200422114007.GC20730@hirez.programming.kicks-ass.net> <20200422134924.GB26846@zn.tnic> <20200422135531.GM2424@tucnak> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <20a91f2e-0f25-8dba-e441-3233cc1ef398@suse.cz> Date: Wed, 22 Apr 2020 16:16:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200422135531.GM2424@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/22/20 3:55 PM, Jakub Jelinek wrote: > On Wed, Apr 22, 2020 at 03:49:24PM +0200, Borislav Petkov wrote: >> On Wed, Apr 22, 2020 at 01:40:07PM +0200, Peter Zijlstra wrote: >>> You haz a whitespace issue there. >> >> Fixed. >> >>> Also, can we get this in writing, signed in blood, from the various >>> compiler teams ;-) >> >> Yah, I wouldn't want to go fix this again in gcc11 or so. That's why I >> wanted the explicit marking but let's try this first - it is too simple >> to pass over without having tested it. > > If virtual blood is enough, AFAIK GCC has never tried to accept volatile > inline asm (asm ("") is such; non-volatile asm such as int x; asm ("" : "=r" (x)); > could be e.g. dead code eliminated) in the statements between function call and > return when deciding about what function can be tail-called or can use > tail-recursion and there are no plans to change that. > > Jakub > > > One possible solution can be usage of a GCC pragma that will disable the tail-call optimization: $ cat tail.c int foo(int); #pragma GCC push_options #pragma GCC optimize("-fno-optimize-sibling-calls") int baz(int a) { int r = foo(a); return r; } #pragma GCC pop_options I'm not sure if clang provides something similar (the -foptimize-sibling-calls option is supported as well). And as I talked to Boris, I would recommend to come up with a "configure" check that a compiler does not optimize the key code sequence: $ cat asm-detect.c int foo(int a); int bar(int a) { int r = foo(a); asm (""); return r; } $ gcc -O2 -c asm-detect.c -S -o/dev/stdout | grep jmp [no output] Martin