Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86E4C7A for ; Thu, 10 Mar 2022 09:23:03 +0000 (UTC) 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] Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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: quoted-printable From: Peter Zijlstra > Sent: 10 March 2022 09:05 >=20 > On Wed, Mar 09, 2022 at 04:30:28PM -0800, Nick Desaulniers wrote: >=20 > > I observed the following error when building with > > CONFIG_LTO_CLANG_FULL=3Dy 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=3D4+64 cfa2=3D4+8 > > These seemed to disappear when I kept CONFIG_LTO_CLANG_FULL=3Dy but the= n > > disabled CONFIG_X86_KERNEL_IBT. (perhaps due to the way I hacked out > > the ibt_selftest_ip label). >=20 > Urgh.. I'm thikning this is a clang bug :/ >=20 > The code in question is: >=20 >=20 > void ibt_selftest_ip(void); /* code label defined in asm below */ >=20 > DEFINE_IDTENTRY_ERRORCODE(exc_control_protection) > { > =09/* ... */ >=20 > =09if (unlikely(regs->ip =3D=3D (unsigned long)ibt_selftest_ip)) { > =09=09regs->ax =3D 0; > =09=09return; > =09} >=20 > =09/* ... */ > } >=20 > bool ibt_selftest(void) > { > =09unsigned long ret; >=20 > =09asm ("=09lea ibt_selftest_ip(%%rip), %%rax\n\t" > =09 ANNOTATE_RETPOLINE_SAFE > =09 "=09jmp *%%rax\n\t" > =09 "ibt_selftest_ip:\n\t" > =09 UNWIND_HINT_FUNC > =09 ANNOTATE_NOENDBR > =09 "=09nop\n\t" >=20 > =09 : "=3Da" (ret) : : "memory"); >=20 > =09return !ret; > } >=20 > 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. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)