Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2992523ybh; Mon, 16 Mar 2020 13:40:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt0JKvQYJz32hf4vNSmxj8ZmwjfIMgoaYCf7T8uERgAbUqsSSxS/c8n5y/pvSnusyXg/Qqk X-Received: by 2002:aca:3d04:: with SMTP id k4mr1019732oia.45.1584391246868; Mon, 16 Mar 2020 13:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584391246; cv=none; d=google.com; s=arc-20160816; b=K4Dz/ng403bpfKGdkHiByKwATICQ2Nzi1NNzZiCg2DmrEjBRgIoX3cXsUbTI7tHezi aA1CFLZ5vX+pjwU1r8zoYysZSlpR1Gz0WXEFq2E1gk6XW0DTpeykE3VvE6zuSa7VMZXZ BRXltK1OBP+/J7skdWCsO+I20qDOuyK/ATXnPDT0rI3rkU2VfbxUz9J2srOT+UI3CSVm v4KUPmL8D49zzlKytTCx1pvtwxhJFu7jqXsJr8EPD9kfO7XiAOPgYSCzkAztuZkFnMy0 ee13+unCqFdLBT5Xd7aSwoL15aLU1qnmUUDT91Kuw1DXtlRVBeF+TQy4M+XUddAZF0du Mbvw== 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:date:from:dkim-signature; bh=XwiLZWZJb8LiTm8ChhHd1B7qjQwdImHaIuZO9qfo7Wk=; b=mhjVRJtgItfTJLoLQe+GChYxauzCRB4O2yjZheESOdMkFgw1swGvAsJdq9SDIiSM5V I7kHtOuK8SXTGEKCcbXeSPNIZm3w9K3wqz2c2FCuj1LvLFggkAe1vXdhTe7hqxDvDA1Q dXERDA46S31qXY17RXxjDAJwoQf6SHoInqbMlGermPyNARunizk+xg6ljK8zlJZ5NkjA m8ASuijYHZQLLrutH4WeC6Cqw7h1MDC3OrTVa701Cs8cjbATggD5CO92zuieeWxrvvBY bZ0nLrLXjA6Mm+vMENnDWixMot56IS51TwRwP4jguQVLAmva0ymC7FtfE9rQW6rzGP2N nsvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=iv2J3Jh3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si495946otl.122.2020.03.16.13.40.34; Mon, 16 Mar 2020 13:40:46 -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=fail header.i=@gmail.com header.s=20161025 header.b=iv2J3Jh3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732561AbgCPUkF (ORCPT + 99 others); Mon, 16 Mar 2020 16:40:05 -0400 Received: from mail-qv1-f67.google.com ([209.85.219.67]:37383 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732516AbgCPUkE (ORCPT ); Mon, 16 Mar 2020 16:40:04 -0400 Received: by mail-qv1-f67.google.com with SMTP id n1so5888203qvz.4 for ; Mon, 16 Mar 2020 13:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XwiLZWZJb8LiTm8ChhHd1B7qjQwdImHaIuZO9qfo7Wk=; b=iv2J3Jh3WGpOtrZZo0BUOC8zfCEp1RreMxscAFeisExPnF+fn8M1sV5Biw+viJS2KQ tB92PwP/q6Z9Oy3CmhZIixYUJIPgoxlWpEBDWPUKs0jsgcol2cZ/KX0SMQIn1fOsIiXL B5G4IkZxRzwL9YLoLis36ChA1ULWssU0UQDEv1skK2Lk1E9cx4qd1Uk5KBays/IpYpPL uN4kdVZm1svPKQ8bv/ik1B8wCm+dE4a3a1QwKueppZ8OmFogsZMS6YLdkYs5CC+EImme Dx/fdNhe/QegIDXVeCQXirnSdT7EtahJ9OfHiNMJGPqNus2CDeFvegINY4IOe74KCxve 7pww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=XwiLZWZJb8LiTm8ChhHd1B7qjQwdImHaIuZO9qfo7Wk=; b=KLr6hre4e9+ad6Sx8jGznGMtnEtnSklKgnKaWzD+MF8HjDSKAIrfu96qSETj7LVLf0 C7ozAUhCtRmNmDUhjuDsjgdVJ1zo6+CPxk+rAaYPIGO9GIekTLJk581hrnjJmyek3KAX ckXKUQTJ1+S8mak/g4YrX416KT6r7KeTvD/yTTY92b7xBl4AmKhaCs9iIyV2mgrqsp/P g4gnmSIYrTSGhTKFEs4MlB5IEq2qVTMlT0OXJtmA6UtrEe9NPj7SnEahvjKNp9K7KjQ0 +EZO2IXk/uvWU4PH3Tw+XXXV5jXg0ffiXGkp5X1iFTvzs7LrzYAd0ZoG253IQHCNxxxK ZEiA== X-Gm-Message-State: ANhLgQ14oAGTqFB/Z/tXAZH7GnSuCbRVbfjsekyyB2z8/C5NSAU5Vzu6 27U6bR0Q+MEfwphyKJEaRY8= X-Received: by 2002:a0c:c246:: with SMTP id w6mr1690744qvh.250.1584391203426; Mon, 16 Mar 2020 13:40:03 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id i13sm523174qke.56.2020.03.16.13.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 13:40:02 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Mon, 16 Mar 2020 16:40:01 -0400 To: Jakub Jelinek Cc: Arvind Sankar , Borislav Petkov , Peter Zijlstra , Sergei Trofimovich , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , x86@kernel.org Subject: Re: [PATCH] x86: fix early boot crash on gcc-10 Message-ID: <20200316204000.GB768497@rani.riverdale.lan> References: <20200314164451.346497-1-slyfox@gentoo.org> <20200316130414.GC12561@hirez.programming.kicks-ass.net> <20200316132648.GM2156@tucnak> <20200316134234.GE12561@hirez.programming.kicks-ass.net> <20200316175450.GO26126@zn.tnic> <20200316181957.GA348193@rani.riverdale.lan> <20200316185418.GA372474@rani.riverdale.lan> <20200316195340.GA768497@rani.riverdale.lan> <20200316200855.GS2156@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200316200855.GS2156@tucnak> 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 Mon, Mar 16, 2020 at 09:08:55PM +0100, Jakub Jelinek wrote: > On Mon, Mar 16, 2020 at 03:53:41PM -0400, Arvind Sankar wrote: > > > /* > > > * Initialize the stackprotector canary value. > > > * > > > * NOTE: this must only be called from functions that never return, > > > * and it must always be inlined. > > > */ > > > static __always_inline void boot_init_stack_canary(void) > > > > Ugh, gcc10 tail-call optimizes the cpu_startup_entry call, and so checks > > the canary before jumping out. The xen one will need to have stack > > protector disabled too. It doesn't optimize the arch_call_rest_init call > > in start_kernel for some reason, but we should probably disable it there > > too. > > If you mark cpu_startup_entry with __attribute__((noreturn)), then gcc won't > tail call it. So I've actually noticed this before -- what's the reason we don't tail-call optimize calls to noreturn functions? The code remains a call with nothing after it, but wouldn't a jump still be better? Or if it has to be a call, at least an undefined opcode or int 3 after the call in case it was erroneously annotated and returns anyway? objtool apparently doesn't like what gcc does when calling noreturn functions, complains about control falling through to next function. Though it isn't good enough to detect that that's happening even in start_secondary because there's some cold code following the call :) init/main.o: warning: objtool: rest_init() falls through to next function kernel_init() > If you don't, you could add asm (""); after the call to avoid the tail call > too. > > > > a06: 0f ae f8 sfence > > a09: 48 8b 44 24 08 mov 0x8(%rsp),%rax > > a0e: 65 48 2b 04 25 28 00 sub %gs:0x28,%rax > > a15: 00 00 > > a17: 75 1b jne a34 > > a19: 48 83 c4 10 add $0x10,%rsp > > a1d: bf 8d 00 00 00 mov $0x8d,%edi > > a22: 5b pop %rbx > > a23: e9 00 00 00 00 jmpq a28 > > a24: R_X86_64_PLT32 cpu_startup_entry-0x4 > > a28: 0f 01 1d 00 00 00 00 lidt 0x0(%rip) # a2f > > a2b: R_X86_64_PC32 debug_idt_descr-0x4 > > a2f: e9 cc fe ff ff jmpq 900 > > a34: e8 00 00 00 00 callq a39 > > a35: R_X86_64_PLT32 __stack_chk_fail-0x4 > > Jakub >