Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5178689pxj; Wed, 9 Jun 2021 10:57:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVECOvbw+S98co8WHQxGJi84TMqPxUa5OUgYjcHJBp1vretI3hg6Ofm7rlFkVDPuWAbRBc X-Received: by 2002:a17:906:e01:: with SMTP id l1mr1030097eji.280.1623261473970; Wed, 09 Jun 2021 10:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623261473; cv=none; d=google.com; s=arc-20160816; b=xSUlmB/z3d/XjYQCCMkEGcLs+rw77ZXEIbD3nUSIVEGfs9UpJvWuEkdH9oYTwqHjKW Exea82u8GxNWprVPJriRvkKA/CmKjv64O8/qnNYHa23CQ8aRE+dQaNdxOi/gHl8kNXyo 8IlKe/xuem3ceLV0uODvzqMlqd9eeAzY3J43apYBOafUy9z1UFdME01fQAA8ZtXakYy0 fHHzdf6trLlziM5Lq/clJyzYHSmqOy+8Vke+tcqLXV7l0gC7D8SHmr7pwWlubHBJFHn6 wXhETkMJznB16gp3YPCR+0gHBiKUD8PIi1eDrx1+9Asf4+QX2yHvaXZ6MLFvO763E/mE HeIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bGSDp9v/6VI6NXx/o7FnCwfsLH/DQ2C/TbgATT+JAzk=; b=tgag8BxeU/zlmfiPFuoYOPz5nlXZkbLmqgVaWzt6p3lKNpDSWx9RFEcjilxqeEG0s8 e0qFXGCfIJ8WgLuPI9KG0qJgn5jL6s3SgNiz/vOUhV2nqA0jsWTuM5AC2fj5NWTMWdli fze78KNbh5R3IwU7gHIkOHTwWEZiFSLlUyQbtslQa3tITMAl7pFgMdzXcLee08Gk+0FN iEG5E6xxoQrFi29f//HSwjReIuxz+1rxRzggckjwBycDeKtrDJpOCtCXTwxTRnqMPt9X IuPfH67IMZsdJ2yZFAx6oIUXfhBco7CyHea6sUnP92LmsjwOGqlUiUHaw8xEWFV8obaB CCsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=alauMrl6; 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 u15si346513eju.20.2021.06.09.10.57.30; Wed, 09 Jun 2021 10:57:53 -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=@infradead.org header.s=desiato.20200630 header.b=alauMrl6; 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 S234522AbhFIPKO (ORCPT + 99 others); Wed, 9 Jun 2021 11:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234324AbhFIPKN (ORCPT ); Wed, 9 Jun 2021 11:10:13 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744D7C061574 for ; Wed, 9 Jun 2021 08:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=bGSDp9v/6VI6NXx/o7FnCwfsLH/DQ2C/TbgATT+JAzk=; b=alauMrl6iIqgexH+GlokqYcd9d kTXvMTkzYzT3PGba8L5NL/J5yDhxneLXYhCPfHxazp9MzeYV8fQB26UyJHU8HmNWk2GrZyIgoahab eQjUDubGZLWp6ipbY8nDZp8HrGKIdgjXKtH0AyJZHwooQUHg5EtrtDCNZMaVUu4M3H25y/z0uF5Jd 6R/XSDqQZ4OXAGy/+5SzrXNpbz7GEI9LrbT+EA8sR0AMNE40Tzjyo5ojrAkBBWTwy+sy2dSqJYAyJ YuEuoo53lA8DWANTzo355nn3lJbD07P4VrVKFFBGp7PychvnATZ+N2Fo4Xu4FNyVG0mFJyUwp6r50 4q340DQg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqzoG-0057e5-CX; Wed, 09 Jun 2021 15:08:07 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id F3A239867D0; Wed, 9 Jun 2021 17:08:04 +0200 (CEST) Date: Wed, 9 Jun 2021 17:08:04 +0200 From: Peter Zijlstra To: Lukasz Majczak Cc: Nathan Chancellor , Nick Desaulniers , =?utf-8?B?RsSBbmctcnXDrCBTw7JuZw==?= , Josh Poimboeuf , Guenter Roeck , Juergen Gross , =?utf-8?Q?=C5=81ukasz?= Bartosik , LKML , mbenes@suse.com, =?utf-8?B?UmFkb3PFgmF3?= Biernacki , upstream@semihalf.com, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , clang-built-linux , Sami Tolvanen Subject: Re: [PATCH v3 16/16] objtool,x86: Rewrite retpoline thunk calls Message-ID: <20210609150804.GF68208@worktop.programming.kicks-ass.net> References: <5dd58dce-c3a7-39e5-8959-b858de95b72c@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 09, 2021 at 02:23:28PM +0200, Lukasz Majczak wrote: > śr., 9 cze 2021 o 09:20 Peter Zijlstra napisał(a): > > > > On Wed, Jun 09, 2021 at 09:11:18AM +0200, Lukasz Majczak wrote: > > > > > I'm sorry I was on vacation last week - do you still need the requested debugs? > > > > If the patch here: > > > > https://lkml.kernel.org/r/YL3q1qFO9QIRL/BA@hirez.programming.kicks-ass.net > > > > does not fix things for you (don't think it actually will), then yes, > > please send me the information requested. > > Ok, it didn't help. Peter, Josh I have sent you a private email with > requested information. OK, I think I've found it. Check this one: 5d5: 0f 85 00 00 00 00 jne 5db 5d7: R_X86_64_PLT32 __x86_indirect_thunk_r11-0x4 +Relocation section '.rela.altinstructions' at offset 0 contains 14 entries: + Offset Info Type Symbol's Value Symbol's Name + Addend +0000000000000018 0000000200000002 R_X86_64_PC32 0000000000000000 .text + 5d5 +000000000000001c 0000009200000002 R_X86_64_PC32 0000000000000000 __x86_indirect_alt_call_r11 + 0 Apparently we get conditional branches to retpoline thunks and objtool completely messes that up. I'm betting this also explains the problems Nathan is having. *groan*,.. not sure what to do about this, except return to having objtool generate code, which everybody hated on. For now I'll make it skip the conditional branches. I wonder if the compiler will also generate conditional tail calls, and what that does with static_call... now I have to check all that. --- diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 24295d39713b..523aa4157f80 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -747,6 +747,10 @@ int arch_rewrite_retpolines(struct objtool_file *file) list_for_each_entry(insn, &file->retpoline_call_list, call_node) { + if (insn->type != INSN_JUMP_DYNAMIC && + insn->type != INSN_CALL_DYNAMIC) + continue; + if (!strcmp(insn->sec->name, ".text.__x86.indirect_thunk")) continue;