From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA745C433F5 for ; Thu, 10 Mar 2022 09:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240755AbiCJJYJ convert rfc822-to-8bit (ORCPT ); Thu, 10 Mar 2022 04:24:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240726AbiCJJYH (ORCPT ); Thu, 10 Mar 2022 04:24:07 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 02EA22D1E5 for ; Thu, 10 Mar 2022 01:23:03 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-189-Cn9pbkHFPAe5BCPpwhZIzg-1; Thu, 10 Mar 2022 09:23:00 +0000 X-MC-Unique: Cn9pbkHFPAe5BCPpwhZIzg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Thu, 10 Mar 2022 09:22:59 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Thu, 10 Mar 2022 09:22:59 +0000 From: David Laight To: 'Peter Zijlstra' , Nick Desaulniers CC: Alexei Starovoitov , "x86@kernel.org" , "joao@overdrivepizza.com" , "hjl.tools@gmail.com" , "jpoimboe@redhat.com" , "andrew.cooper3@citrix.com" , "linux-kernel@vger.kernel.org" , "keescook@chromium.org" , "samitolvanen@google.com" , "mark.rutland@arm.com" , "alyssa.milburn@intel.com" , "mbenes@suse.cz" , "rostedt@goodmis.org" , "mhiramat@kernel.org" , "daniel@iogearbox.net" , "andrii@kernel.org" , "bpf@vger.kernel.org" , "llvm@lists.linux.dev" Subject: RE: [PATCH v4 00/45] x86: Kernel IBT Thread-Topic: [PATCH v4 00/45] x86: Kernel IBT Thread-Index: AQHYNF3uCfkzaUw3o020v7uo0T//Qqy4V9+w Date: Thu, 10 Mar 2022 09:22:59 +0000 Message-ID: <184d593713ca4e289ddbd7590819eddc@AcuMS.aculab.com> References: <20220308153011.021123062@infradead.org> <20220308200052.rpr4vkxppnxguirg@ast-mbp.dhcp.thefacebook.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra > Sent: 10 March 2022 09:05 > > On Wed, Mar 09, 2022 at 04:30:28PM -0800, Nick Desaulniers wrote: > > > I observed the following error when building with > > CONFIG_LTO_CLANG_FULL=y enabled: > > > > ld.lld: error: ld-temp.o :7:2: symbol 'ibt_selftest_ip' is > > already defined > > ibt_selftest_ip: > > ^ > > > > Seems to come from > > commit a802350ba65a ("x86/ibt: Add IBT feature, MSR and #CP handling") > > > > Commenting out the label in the inline asm, I then observed: > > vmlinux.o: warning: objtool: identify_cpu()+0x6d0: sibling call from > > callable instruction with modified stack frame > > vmlinux.o: warning: objtool: identify_cpu()+0x6e0: stack state > > mismatch: cfa1=4+64 cfa2=4+8 > > These seemed to disappear when I kept CONFIG_LTO_CLANG_FULL=y but then > > disabled CONFIG_X86_KERNEL_IBT. (perhaps due to the way I hacked out > > the ibt_selftest_ip label). > > Urgh.. I'm thikning this is a clang bug :/ > > The code in question is: > > > void ibt_selftest_ip(void); /* code label defined in asm below */ > > DEFINE_IDTENTRY_ERRORCODE(exc_control_protection) > { > /* ... */ > > if (unlikely(regs->ip == (unsigned long)ibt_selftest_ip)) { > regs->ax = 0; > return; > } > > /* ... */ > } > > bool ibt_selftest(void) > { > unsigned long ret; > > asm (" lea ibt_selftest_ip(%%rip), %%rax\n\t" > ANNOTATE_RETPOLINE_SAFE > " jmp *%%rax\n\t" > "ibt_selftest_ip:\n\t" > UNWIND_HINT_FUNC > ANNOTATE_NOENDBR > " nop\n\t" > > : "=a" (ret) : : "memory"); > > return !ret; > } > > There is only a single definition of that symbol, the one in the asm. > The other is a declaration, which is used in the exception handler to > compare against regs->ip. LTO has probably inlined it twice. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)