From patchwork Tue Jan 30 10:59:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 19663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1133828dyb; Tue, 30 Jan 2024 03:00:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEm4omwd7/E8jFojAI1F2ZJLtf0bxRsJvjlb0WuOdFxr1aCY3aVAKg5rlTkM1BLrHQ3uTna X-Received: by 2002:a05:6214:1d2a:b0:686:2ff1:8de2 with SMTP id f10-20020a0562141d2a00b006862ff18de2mr8450919qvd.41.1706612450493; Tue, 30 Jan 2024 03:00:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706612450; cv=pass; d=google.com; s=arc-20160816; b=CARuRslsJlL7NJE7apngsfNVl99Uzx1YGLi7mamGGSkRnRUqvFLSnQclJ2HM3iZ3gs 47CHZHE0TdEPPzZP4EYT9UUDynRpqos7UdIkT39RGaM+Vv5IHKs141MhBnr0od/2ewT0 zuWgeD51o1xzFi+C/iIa66GMyaOtAZSrmhKxwBQJVKfJCyNnuEvWoMkZCnSN8LlUQN88 NwefYJAeUMUTLshuPskWMmEMDUdF0ZjYaAWFVRxxVZxowdpnj0C0nEooD0aipx5ZxUz2 CNKNaIwYNT5fofyiPIL51bSX+3F+WyPPOdfPMsc3p+QFMwhtTM6Tw0xcbj9DOiA2UATt fpzw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=5VEK1Zxhspczzm1C3es62bjKQovEEfT1Dvk7+/ofv6w=; fh=gL8iKWYz+5Gj006D9LUvWYS+TWLN0CkoSVsKmJTYNn0=; b=i+Wa3W2d/n/iDyA/9cnWCldZeE6cP8xwl33/PIf2/LknyeLEeLgdF/hCFpzOBjd8m/ Qmc736KPI7H7eXXHx8d7Wc74LaVmKSM1wZLl5/QL3Ttxozhb5j+I2AJy+es5RSjyW/in FpFE4pJy/uhap+jv1ePFdVx5/gCJNgrTW/7CjK5cWcrjAV0plrD23L9XLeQ17Ng25spf YtqiJrsWSFxFc4eI5i60sEtkHKQUlWAImb1iow3olepnq4DARa4Gk4NtUIHbzngc+IH8 VCcoODNw/3odYyAO+UqnpYsBtsR8SiyEU2e9QlCQv16WLIq/PFaiYnt3DTCAodi5yog1 UEjQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=kl530pN3; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-44442-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44442-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fq7-20020a056214258700b00681995460b8si9564706qvb.545.2024.01.30.03.00.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 03:00:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44442-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=kl530pN3; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-44442-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44442-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6D5781C26C14 for ; Tue, 30 Jan 2024 11:00:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3DFA66B5C; Tue, 30 Jan 2024 11:00:01 +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="kl530pN3" 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 9670C66B2E for ; Tue, 30 Jan 2024 10:59:56 +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=1706612398; cv=none; b=o+BxgoYHRvrSY8ZA56waGjU99RiOfbgLINCpphAByfSe2XQCYBPjPSSUB56fldEwr+aRRZBrVJqIw5DFXk8NBvWZr567lwC8NMVeJpONphWZrWLXIGI1jIuSNl7d1zscsDbIaURXVB1lrFMJeCXuTb1kxce8p8GFQctwqOYR3mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706612398; c=relaxed/simple; bh=udOcytbH7mtJOTHt3bS5t9BxYLH3RKUDDy+XlX13Mlw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oayd7ejAEMtqUUZRbpLx3YJCUwNepQTxzXlZMqXAyHGXhrOOo1i+vXWo1XycZXrc5XlQeOTI7UWJYjDSOIPDo8JbLMWH4+XGfzqYjzfQtqtHASv57hHTgjx/G+uy7vx0jiyFyz5T34egRBRZn9cnqYQE1F4YqMXt+6VtKVLCeyY= 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=kl530pN3 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 338D840E01BB; Tue, 30 Jan 2024 10:59:54 +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 WRxMG2SDOxr0; Tue, 30 Jan 2024 10:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1706612391; bh=S0KbFF8EBNAGRRPAs/FZoki99W6fAqfJea+07pwpvKA=; h=From:To:Cc:Subject:Date:From; b=kl530pN3uUblU+FKbX/ueEozkYtTk6WKYK1w8YlwikXGKiTloBTHAXTwQabNUZg+D qW2SxJ7JxTXJuTZANhmQqHqAeYSTnUQJNJIGxxGMwn0sw4OkhbTCyWeKgirLw4Oyyh ptFqgXcf+uflEqaJiWriRjjpujV0x31ZkBTKBugm89JZhBdyYBj/YaB5+Uq1vHxiwJ a0u4k9M0LerSZQ0NfyFueodTMh5Gn1/ZsC53NkbhFOBrj+qr+S+7ssM1cmqdCm8C0E aJc2nYXDgK5i/yhtIBwl15A2f1DiAsSq9OHOzrim8VFTDyHlqKKd3IYbMeWP9Z8feI EYOEOnTPU8kSJGd8u3CIy8AlYJOqdMkm0rvGTGWKm93gF/P0fiBM+VGgdLPzk9eu9y IoWcLxXFFp6Foyb9gLzl/UPa6i5vxIDmgJKfC/cjvGrctk6iC3fI+0Sdz5wgyxAJqN ZxJui0cOLV36kG6WsRGLH2uDwQOhogct2Uh3obd6NSdSC3FzZiqzDiTcop2fkji24V XSC/bmMQOxKsfgnaZwUJQhYuI1dhf1nayhVeY6svlNroLxFsTFqtS5kiKF53BrNQlk 0b7bPj4tQfSdjyJ7ff8Zig7ibpeNnsuTiHMTUio2z6uxq4e252Ih3qfYuULxl8I7zK ieo3Q3ORKqcoF+sUtTxcSy8Y= 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 31A0240E00C5; Tue, 30 Jan 2024 10:59:48 +0000 (UTC) From: Borislav Petkov To: X86 ML Cc: Paul Gortmaker , LKML Subject: [PATCH 0/4] x86/alternatives: Do NOPs optimization on a temporary buffer Date: Tue, 30 Jan 2024 11:59:37 +0100 Message-ID: <20240130105941.19707-1-bp@alien8.de> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789512856769029248 X-GMAIL-MSGID: 1789512856769029248 From: "Borislav Petkov (AMD)" Hi, here's a small set which sprang out from my reacting to the fact that NOPs optimization in the alternatives code needs to happen on a temporary buffer like the other alternative operations - not in-place and cause all kinds of fun. The result is this, which makes the alternatives code simpler and it is a net win, size-wise: 1 file changed, 50 insertions(+), 72 deletions(-) Constructive feedback is always welcome! Thx. Borislav Petkov (AMD) (4): x86/alternatives: Use a temporary buffer when optimizing NOPs x86/alternatives: Get rid of __optimize_nops() x86/alternatives: Optimize optimize_nops() x86/alternatives: Sort local vars in apply_alternatives() arch/x86/kernel/alternative.c | 122 ++++++++++++++-------------------- 1 file changed, 50 insertions(+), 72 deletions(-)