Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp943974rdb; Tue, 30 Jan 2024 03:32:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYksgNb0HOezQTfXErQsht5M4ArwYsTUXsNOT/a+SnT2dgIz4PoK8qqOjUHX7r6X0p+x8b X-Received: by 2002:a05:6358:5919:b0:178:75cb:18dc with SMTP id g25-20020a056358591900b0017875cb18dcmr3566800rwf.10.1706614321389; Tue, 30 Jan 2024 03:32:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706614321; cv=pass; d=google.com; s=arc-20160816; b=Jj+WhQ3Oh3/Mv0BUJjsZLZL7ij5ZMhe72CWd4GIhciQiRUeEyeYdSRCQx7QqyMF081 nHCu+xejQ9M9yaiYepL1rhNMUYwbbQV7yZI5K88YsNRzOjEM1t4L7VlPdEGbcr/C1XIv lazqrxoJlw98NiYhUmolVtjjo8AlN/jwagPrA0Yll7AHSWqKOf35jZrKq8suQwPfSrgE FBsv8+vVCvd4bMamwCPCf0UPWlnJBrutBWWYANJhyYVWjjTM2v0pAF3li+oLlOHPhYZO 8jMajme2UZOIoxRkRvTeqNn+MljKbPVaS7iUhShxnwbrOtrCkMZrUIHWCMcKf7xcHJx6 ROAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1kMLFDn6HFypUek5nuT7XCSQHyO5gXydItUseUqPOVM=; fh=gL8iKWYz+5Gj006D9LUvWYS+TWLN0CkoSVsKmJTYNn0=; b=TCg+IV+IwT1lYC+1SOjB0VjcntPtthLsezv3Jig+LPUYB0EAbKcFEaB42I7aibhYXX m4to+bGTHrVyxT+qCMhkm+7Ozm13aJ6i1v3kW09GHF5a2FskayLsIpO8/kHLk02YtDPD rCrsfgAZQtKONADkiLZbZHyOxVzI6L6DhjSyKLPxmbnohwd5NDfM/DOaVK8a9Bd3y4g5 ZDA6AK5aJaoMGTJVFNlMcocBdHsn6uT3b4AXwPTj6LxiQkyK8PJFj/qn/7LTctyf8N+7 zyfM7FZl8+8AOfguHyRR5jkWQ2Q4jmq3BIorFNy6qSyFGt7azS7mfHPP0fmToGOuEaPM W/CA== ARC-Authentication-Results: i=2; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=OTjnlGn6; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-44445-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44445-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y6-20020a633206000000b005cf5895bfa6si7445212pgy.814.2024.01.30.03.32.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 03:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44445-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=OTjnlGn6; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-44445-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44445-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9F61FB2182A for ; Tue, 30 Jan 2024 11:01:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 527A767A08; Tue, 30 Jan 2024 11:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="OTjnlGn6" Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 CDB59679FD for ; Tue, 30 Jan 2024 11:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706612412; cv=none; b=HRHc1AOuXSDS66+Z4peOyu0SPsHRTQ8GXowLeD/5e/n2HNzIOcCWqNJTELF4gR1K3O95sRVocc53rxMNGpIwZGjoVCkFJZB3awF5isGz4UPyCd+wVOMtNAgu6kG3GXTwpksRObmV+MbyMGYAlDzwfmxe2eZYPraIFt1AnoWNZzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706612412; c=relaxed/simple; bh=jgeafpJI+MYDNRoPvXNTdDfiHQEnLFcoETk5RR++mSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cD58jd7RfoI5IKPLJo7avPkl9jF11CHcaugnrZ6LNLpj54vxmrZukwy7vTS7NPX4L9d9WLjjZGO9eIJ4XViQRmkWevL0kXjUzteGVo6ExepDrgMJJrZdCSOTITGDKWt2ZkZof2gwYzS+JnkmxT/qpB8oXHhwoD5/8jNo3azgyNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=fail (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=OTjnlGn6 reason="signature verification failed"; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id DE99840E01FE; Tue, 30 Jan 2024 11:00:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=fail (4096-bit key) reason="fail (body has been altered)" header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id km_ryPGWyPCV; Tue, 30 Jan 2024 11:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1706612406; bh=njqwLfrv56leHkX+AonJAZ0qg8TBI+C0ajpxz+Cn0Oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OTjnlGn6LgS9QuS49oeJ51uVOHhFXrZOzFkMxaJc5FTZQUM24RJpzByIImRZrdi0x Kp2+1i8t7mAruSVfSzPb690CUJlhdcs0PytNvnek5izutBVARqUTr9MFO1DY9t9RGx +ZZwfdjnAMnzDCcioulTTZlnYSJ/coCMeLjFOTjtxNVnZ0iRCfTsZMSIt35DMeYmm9 fXQE/HHPm1irE+ccxrGeKAZMo1O4Yr65tfwXWjPq6geTE4HTI3vr6Ma7zoZNmIsoqT xLCFrDXpy5SuZlNKNgBVk8Yn16ccb42OeYZsss/J4TEdDvqGR5ue7oICVvUTvFiFbF /JHxZaEqNYU39PUHzb7mLaaOoONCHxYXYv5ijYtlyYzsQAp6Srwbu080o4VwBR30Sh 4Hys7u3OV/Ua4IILMgTSSSFcA+u92rKeCTNGHJ01C/QfR5IIJjK6r5ps4uGVQDZGUC 1KCg4RoWOpkiqMafjgFIHWqmEL1NIRqrCBG/SOO1W8+EUTVtgdCi/eg6p+Rx3x8M8I OMINe6Uev0RagiBQ4WGdhhptBaNEv80IeOucy/5psVL05+ysZD/4RORE5wQ8cookqb 8TZIkv69YgilpOIzZ0YeT3Q662yAeneeLhnWqIRfIs3ALBgHVyl/zFjFgf6ih84Lik CVZJWoo4SLSZNQyLEN/Rq1/A= Received: from zn.tnic (pd953033e.dip0.t-ipconnect.de [217.83.3.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 867C840E0177; Tue, 30 Jan 2024 11:00:03 +0000 (UTC) From: Borislav Petkov To: X86 ML Cc: Paul Gortmaker , LKML Subject: [PATCH 3/4] x86/alternatives: Optimize optimize_nops() Date: Tue, 30 Jan 2024 11:59:40 +0100 Message-ID: <20240130105941.19707-4-bp@alien8.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130105941.19707-1-bp@alien8.de> References: <20240130105941.19707-1-bp@alien8.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: "Borislav Petkov (AMD)" Return early if NOPs have already been optimized. Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/alternative.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.= c index 2dd1c7fe0949..68ee46c379c1 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -233,6 +233,10 @@ static void __init_or_module noinline optimize_nops(= const u8 * const instr, u8 * if (insn_is_nop(&insn)) { int nop =3D i; =20 + /* Has the NOP already been optimized? */ + if (i + insn.length =3D=3D len) + return; + next =3D skip_nops(buf, next, len); =20 add_nop(buf + nop, next - nop); --=20 2.43.0