From patchwork Sat Dec 16 12:58:51 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: 179844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp202832dyi; Sat, 16 Dec 2023 04:59:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV/xqC+yj6au9+dMlRHNDT/J1rVrg/lsqpK55E9SXh1pO9eOrRc1TH+BD8NnC1Uy3P2Tnw X-Received: by 2002:a17:906:51a:b0:a19:a1ba:8ce3 with SMTP id j26-20020a170906051a00b00a19a1ba8ce3mr5629151eja.129.1702731581322; Sat, 16 Dec 2023 04:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702731581; cv=none; d=google.com; s=arc-20160816; b=SEMB9jm72V/d5D2LcFJIvi0ODtRe/PFScRpuUdnDtX6NJ+1SQwQ9M1obqr7o+3uNwl xTfQofFfVDAOuERS57x9mSJvWtNSmRssu7JH1R5Umtmnyf6cLP/+XKfshrQTjLw8Jv6E J8uwM00FaDSFqkLWw8nVdLii/AmbJDHQ/ZXEQ1XpkIdWZCq6c0G0Fvp5pnBMEjD6T6y+ pYlLY/q59AqawU/rq8p0D9UAN9tSXyAGxfDDyt3JaE0oh4yYwh/mceY3aB2nIVoyslzZ 9KBldmEdBV5/telY7ored5/VFZ7NBnJpF0hqhlAWo4F7Al9oqsZBkU4LiVEAHo7TLC1g 2/Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=anal0gKvCrGV42YD75/clg9vkB6MDtNjy8h56W2p3PQ=; fh=TYRbYw0Yd/QH22WpEl82IDcaJRWHnfu9Dnp+wwJSS/0=; b=hKv2KrPwjSTOT1o5OtCuzG1g7NRCuxXZykHPTjqrRBq42AeiRAypuHnUXb+0uxmTTU X6o0ZXX9rhgTopBOb55pI8WHGiSAmbyuCf9+K2jHJHp/+Tvd3PEc7IGpunGJMZCs/LZF +2NOWI+4uzsZNxOS3jrXT6OpyOx2FBq6ym2P7XGv+Hsy8duQQ6PjMPRCoorzwXzspOyb /ykjFCPL/+TrZY4+fMvC290GgOFuXHbjxAIUl7CoOaVs2JFNmZjP4kCV0Xgp/ZBGLUnS bvcFa+zjvtgDLaujwHfSts61n4YEz3RcjKf/gcs804DgzfFlkMQLWDIU5b4iXSyMXxRH Qh8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=D8G7Gs5C; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1e3LxO2b; spf=pass (google.com: domain of linux-kernel+bounces-2189-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2189-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p12-20020a1709060e8c00b00a1d30e0d22csi7863707ejf.123.2023.12.16.04.59.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 04:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2189-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=D8G7Gs5C; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1e3LxO2b; spf=pass (google.com: domain of linux-kernel+bounces-2189-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2189-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.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 am.mirrors.kernel.org (Postfix) with ESMTPS id EA0891F23B4C for ; Sat, 16 Dec 2023 12:59:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC2672E63A; Sat, 16 Dec 2023 12:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="D8G7Gs5C"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1e3LxO2b" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A82D518EB7; Sat, 16 Dec 2023 12:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Sat, 16 Dec 2023 12:58:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702731532; 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=anal0gKvCrGV42YD75/clg9vkB6MDtNjy8h56W2p3PQ=; b=D8G7Gs5C8gU6AHoiYGs3G1YTToFJ+tVgZK4jDaw20+H/C6PTuxzki+2sFGHIkuDHiU8/2r 0HiJb3TKeQ8Tndpp3jyw9mUdN9Qv1Hhq4UP8cEnk3f3OOO6dqWSAjlXQubQ1dj1F9z5tuj 09Cj2M7PUhC5XTgP+AHCzR7+0mIeJumuFcC6pq6xbot/DmQDeQEQ1F0XcFLPVWscXBDowo xe+nkeHSnW60wzSjZSnX4Ykd+EPFs6TS3Qm1j4aDWonjfmeeYH2Ax5tLGWzkmZBMyGilzc mUrmt3R+jtBYo8ldl4LE2CiEdpHxKKMtErnx0/SKsxYLTG40R4nA3XXi6Np1sQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702731532; 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=anal0gKvCrGV42YD75/clg9vkB6MDtNjy8h56W2p3PQ=; b=1e3LxO2bYh4tr7rOHq+BFaJ+rQceGMayRtQL/AVtQcxEUH+yN3tvpy/UYJAeiFQ57BWosb 7CWQvuKR3eNpiNBg== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/alternatives: Sync core before enabling interrupts Cc: Thomas Gleixner , "Borislav Petkov (AMD)" , "Peter Zijlstra (Intel)" , , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170273153128.398.15915411825430136039.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785443470301386792 X-GMAIL-MSGID: 1785443470301386792 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 3ea1704a92967834bf0e64ca1205db4680d04048 Gitweb: https://git.kernel.org/tip/3ea1704a92967834bf0e64ca1205db4680d04048 Author: Thomas Gleixner AuthorDate: Thu, 07 Dec 2023 20:49:24 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 15 Dec 2023 19:34:42 +01:00 x86/alternatives: Sync core before enabling interrupts text_poke_early() does: local_irq_save(flags); memcpy(addr, opcode, len); local_irq_restore(flags); sync_core(); That's not really correct because the synchronization should happen before interrupts are re-enabled to ensure that a pending interrupt observes the complete update of the opcodes. It's not entirely clear whether the interrupt entry provides enough serialization already, but moving the sync_core() invocation into interrupt disabled region does no harm and is obviously correct. Fixes: 6fffacb30349 ("x86/alternatives, jumplabel: Use text_poke_early() before mm_init()") Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Acked-by: Peter Zijlstra (Intel) Cc: Link: https://lore.kernel.org/r/ZT6narvE%2BLxX%2B7Be@windriver.com --- arch/x86/kernel/alternative.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 73be393..fd44739 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -1685,8 +1685,8 @@ void __init_or_module text_poke_early(void *addr, const void *opcode, } else { local_irq_save(flags); memcpy(addr, opcode, len); - local_irq_restore(flags); sync_core(); + local_irq_restore(flags); /* * Could also do a CLFLUSH here to speed up CPU recovery; but