From patchwork Fri Jun 9 07:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 105340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp781111vqr; Fri, 9 Jun 2023 00:58:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bMDf+0SJj4F7mYcp3sESZ7G0NGEasajv4d2moYmrGkdLqKdsLdvG6jjqB7aVX+QMOkPxE X-Received: by 2002:a17:903:2290:b0:1af:e295:ad56 with SMTP id b16-20020a170903229000b001afe295ad56mr714762plh.49.1686297512991; Fri, 09 Jun 2023 00:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297512; cv=none; d=google.com; s=arc-20160816; b=WcjVj7biXz1z0Av1BcoJSHXOZyHTf+lwIH8Khcc+fJilLC1jHoaIK3WnpVkiQAaUL+ teb7s6//vBSUzwe45fUWp+cxt7m27PvJs8OR3RnVGiZOwzgKiozRAlerjIg7NglyxEQF 9QBTXxwKNxlDqCB/AQo5bPcc/x6GNN2E4F29qqKaaSKTuvbSTIWOVMTi/oF8hO1OCwEn r5IujtDmEtR49z0AHrzorPzETkr5rbFGi957+Y23JMUz5xQIrBdnaUIJP859PSSEj5Pe VZsNMGVFfyFP99utbPaO9GsMDefZWTF3f6UsQMUU4OTLJmDQ2Ao9UxqoBt5ec9cXFVYg pr7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=+4vOWr9voQDkbobHqEG1up9eGMDw9BioboJbbB7D1RQ=; b=fZ43kwlYIuqeHkDb/EdktL9/cqHi6mMhDQ8eeyPtUGhtbBbU2yoTL0j7ERLM3AL8ts UI9jmgY7f+sIQtsVU4BxfN8+8/T8QJfTh/7gTr7r7OOuOuce9Aa3MecudVlo12ljS6Zz zl4LsjYadprZpu0NMfmxYyEVVDRv9bbrKuwAX0YtYV6vWQcVD5T+pcgPwV4x6mxDvVr7 wuYr+aqcTsgFYjIwR4NKCk81uooVNkW1NYfLfs6dKnHLz3NQg/zXlV81cZY81RPO4wJV yGkBKwMeg5r2X8CwHHydcGe3hhJAM8a7Semry60t4vhLUdul//eipoO/TANLcodYh35x GD3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hdUQjlae; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Y89Jo8Rm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a170902eccb00b001ac47a1578asi2474079plh.232.2023.06.09.00.58.20; Fri, 09 Jun 2023 00:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hdUQjlae; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Y89Jo8Rm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239476AbjFIHtn (ORCPT + 99 others); Fri, 9 Jun 2023 03:49:43 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749493243846275584?= X-GMAIL-MSGID: =?utf-8?q?1768211101046392196?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: 4a03aa34432abe0703abf232f31fc5e2ed8256f6 Gitweb: https://git.kernel.org/tip/4a03aa34432abe0703abf232f31fc5e2ed8256f6 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 = (unsigned char *)native_write_cr4; for (i = 0; i < MOV_CR4_DEPTH; i++) to read something like: for (insn = (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-ass.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 = (unsigned char *)native_write_cr4; + OPTIMIZER_HIDE_VAR(insn); for (i = 0; i < MOV_CR4_DEPTH; i++) { /* mov %rdi, %cr4 */ if (insn[i] == 0x0f && insn[i+1] == 0x22 && insn[i+2] == 0xe7)