From nobody Sun Feb 8 04:17:53 2026 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 31CF2C7EE37 for ; Fri, 9 Jun 2023 07:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239495AbjFIHto (ORCPT ); Fri, 9 Jun 2023 03:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239128AbjFIHrr (ORCPT ); Fri, 9 Jun 2023 03:47:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D33930D0; Fri, 9 Jun 2023 00:47:44 -0700 (PDT) Date: Fri, 09 Jun 2023 07:47:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686296863; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+4vOWr9voQDkbobHqEG1up9eGMDw9BioboJbbB7D1RQ=; b=hdUQjlaeNkTABcVJ4aGWE9aTYB8pFsFg2G+P38AvQ9/X4hi8LPfUHSiUljoJgW9PqG4VUC sDLkmbTLa64rZXASrSkz85ES4N4pMwPSDsrKqysDzDeJXcwz8Dbp4bSFD5lpXbG0tnY7kg 0mNt6n1NEneloZR/JcYI6TgUEK2IfW608GHAJtg0Mf7S9Pl0fr+TCTsFluY84iqk5HTtx/ jM32U84uozh2Vaqy1jp+qJc65NKwvF1wnBa1jvJjN1kCVOkC4Ds7ZmhVQPpzwi/FeWzryq GK4kIJGDKYEf2/y75uuHfTGuZOIQMR2fGyFvCCxzOMRKFJ0i+x/Hu8PjvdoFmQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686296863; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+4vOWr9voQDkbobHqEG1up9eGMDw9BioboJbbB7D1RQ=; b=Y89Jo8RmvRB2zfmEMkrwPOw17uW3wZyfkuFwDOEe4lk598ja9eC2V9FcRVs6MmXEKiNQhl derpQzREMx+sAcBQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] lkdtm: Avoid objtool/ibt warning Cc: kernel test robot , "Peter Zijlstra (Intel)" , Kees Cook , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <168629686249.404.5579713530746693171.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: 4a03aa34432abe0703abf232f31fc5e2ed8256f6 Gitweb: https://git.kernel.org/tip/4a03aa34432abe0703abf232f31fc5e2e= d8256f6 Author: Peter Zijlstra AuthorDate: Mon, 14 Nov 2022 16:23:45 +01:00 Committer: Josh Poimboeuf CommitterDate: Wed, 07 Jun 2023 09:27:11 -07:00 lkdtm: Avoid objtool/ibt warning For certain configs objtool will complain like: vmlinux.o: warning: objtool: lkdtm_UNSET_SMEP+0x1c3: relocation to !ENDBR= : native_write_cr4+0x41 What happens is that GCC optimizes the loop: insn =3D (unsigned char *)native_write_cr4; for (i =3D 0; i < MOV_CR4_DEPTH; i++) to read something like: for (insn =3D (unsigned char *)native_write_cr4; insn < (unsigned char *)native_write_cr4 + MOV_CR4_DEPTH; insn++) Which then obviously generates the text reference native_write_cr4+041. Since none of this is a fast path, simply confuse GCC enough to inhibit this optimization. Reported-by: kernel test robot Signed-off-by: Peter Zijlstra (Intel) Acked-by: Kees Cook Link: https://lore.kernel.org/r/Y3JdgbXRV0MNZ+9h@hirez.programming.kicks-as= s.net Signed-off-by: Josh Poimboeuf --- drivers/misc/lkdtm/bugs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c index 48821f4..92110cb 100644 --- a/drivers/misc/lkdtm/bugs.c +++ b/drivers/misc/lkdtm/bugs.c @@ -487,6 +487,7 @@ static void lkdtm_UNSET_SMEP(void) * the cr4 writing instruction. */ insn =3D (unsigned char *)native_write_cr4; + OPTIMIZER_HIDE_VAR(insn); for (i =3D 0; i < MOV_CR4_DEPTH; i++) { /* mov %rdi, %cr4 */ if (insn[i] =3D=3D 0x0f && insn[i+1] =3D=3D 0x22 && insn[i+2] =3D=3D 0xe= 7)