Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp143226lqe; Thu, 4 Apr 2024 02:11:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQhZj+kkdztOsJ4ZZzNfQc453ijScOIjp6H7+2ZIuAm2S47EjmW3S9noyvwRe+hJUnt5SBRSQWeey3KxpmiIT1KNpdseYqf74YKyPfEA== X-Google-Smtp-Source: AGHT+IENpQeKse8w6mzbwYraRQGROEMr95hK4vg9aozgoysvZwO2uPJ36vR5AXs4S4/hEBJc9e+q X-Received: by 2002:a05:6a20:6a1c:b0:1a3:50fb:4f7c with SMTP id p28-20020a056a206a1c00b001a350fb4f7cmr2386683pzk.29.1712221910424; Thu, 04 Apr 2024 02:11:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712221910; cv=pass; d=google.com; s=arc-20160816; b=ZtXXspwRceP1B6MxP15+6cZI1ckn5JRSkgDS/5KHSf9N/JZtNGrQJ4ZtOpoJM+7vEw a5FUQ+BgIey8Z6iKNe20ubLwgBI6o3Jop+jU6rkr+NC1dUOmPd67rt4ziSzsiK+6XPLi 9rYs8SQppg8YOygzR1yX4oHNu2VLZDdU5FIeGtHpTUSbypLehrP+8SPmaKJeMQ4yJi+C OSCG1OLDCsdMM9HtMjOdkxDd3UxLU0w9Ikaw0RjE7w0HNZgL+2bH481LlWAxkVPrJyFY 77JyXgBypN86434GXsbUk0TwL39HPell3YcTfmc7PYcIcc5NMs9W62dN80g6aIz17OMe 23Uw== ARC-Message-Signature: i=2; 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=MsAoNUXTpwWBhnhoA004f/Vlu//19mS2FvY1h0r1Auw=; fh=VkDCFrTpHMCUYrPLh08uQPxBKQ790ZHA1U+NXVA+Hfs=; b=eS6h4jBYGYPTSMz0ZLJ4n3uDvTjhwewZpYQlH9FZihOwOIx6xlOZ7HOYFWq3qDeGJn lAf2ZEhJSDFbxHS8c0fzGJsq+MEBIWytgfGTJ+o5DLmrfHJ4XA1Eg+XjrnUy6NhL8uj7 rEB8+OnvEYLVNnfmlPCvpvKOt0oXEBmkPPonKDXIpdcujrg9gjB77K4XPSLcikGOC7XR A2c9/7aWWpwvEx7nDrKO/5vLPmpUJLHW4fLXrW8hfKGtNNZNxZJMbPL5C4+obT0zGzqP XtbO6AatthGf1lhW+4GJg7+APDXEb9fCNoJbfo76i1WoMYS2oEdHSbuR266CaZmGfRrv 8ynQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EOQbvgel; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-131155-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m9-20020a170902f64900b001e2b0e6247dsi753815plg.415.2024.04.04.02.11.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 02:11:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131155-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EOQbvgel; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-131155-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131155-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 152ED287D15 for ; Thu, 4 Apr 2024 09:11:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 857F47602B; Thu, 4 Apr 2024 09:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EOQbvgel"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Us1zLD3Q" 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 322727441C; Thu, 4 Apr 2024 09:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712221881; cv=none; b=oWIKT96NqNl3C1CIgCiIt8WR2E6OQQu2s4W9vvaDDQ1KE5ESOHWq28AGUHST+wToMXU8WiApVqS0kAZPQ6MPR6MB73bWWLxtDsEdpNNRxqPzbmAOX0gmQEwZ1tlkOBt2fA6Rn0T/nSCeYNJ9c6VDX0rqNTGvdPf5spVA4SRPys8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712221881; c=relaxed/simple; bh=1AVxcRcxQ+8gsWxFQV2c52Cxbze4tk12vFx+32U8s70=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=pAAI0SmMz2sjd5f65NhAWVKCjD++MGdi4WWC5BVoQRGDUKTcfGILIEx0/KGJ1FJjsgYLldMLwyZWbWpGyPcpMfOOzr9pyapoi2J5Ka60I8E6y/sWTRiSfiWJBshKeVRxw1e4u9frF2fmqX9Ici+DjtTopj1NC/QaB0XYzbnSaIc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EOQbvgel; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Us1zLD3Q; arc=none smtp.client-ip=193.142.43.55 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: Thu, 04 Apr 2024 09:11:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712221878; 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=MsAoNUXTpwWBhnhoA004f/Vlu//19mS2FvY1h0r1Auw=; b=EOQbvgelgbOsJJfS7iNFOuGzhmX6J7y4/vBO0LMHViJVsGuIHO58EdwMEZru3ZwEYXUZr5 No4WUAtp+28smEF3vLCp2JIST/gAjEE50iE7G6bJzl8gnnkoVX+4gDhubdj1pWxafOfHOO DikFOz8FL3Bqd4RgHSWapIHr628rTA7O78Rh7FscCyzkal7iqFNw4m2o7tK2MVptfPImfe uZnZo9a0oq+u9q5qhrm66fFkeIHSmmyXXk/I4UTLuVnuky2rvNkhJlVCK5lZkx8bdmexIC j7uUtR+nkjSUGrQoGTqdf+M0XS5nR5Av2qwN1xgmDtGhqWCG1bWrA49Dehkuzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712221878; 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=MsAoNUXTpwWBhnhoA004f/Vlu//19mS2FvY1h0r1Auw=; b=Us1zLD3Qjp8WoIjIo9xEYfH8Pw/djHkk/9MXZZJCmEpqsp/t9pWrC1Pe4CixRVf1ddvvNk 26iSQ3C9w/4DpPBw== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/alternatives] x86/alternatives: Catch late X86_FEATURE modifiers Cc: "Borislav Petkov (AMD)" , Srikanth Aithal , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240327154317.29909-3-bp@alien8.de> References: <20240327154317.29909-3-bp@alien8.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171222187750.10875.4089921606500177665.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/alternatives branch of tip: Commit-ID: 97784e52f18fe6e0d6516ded8ecd3cec722ce9cc Gitweb: https://git.kernel.org/tip/97784e52f18fe6e0d6516ded8ecd3cec722ce9cc Author: Borislav Petkov (AMD) AuthorDate: Wed, 27 Mar 2024 16:43:14 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 03 Apr 2024 20:03:24 +02:00 x86/alternatives: Catch late X86_FEATURE modifiers After alternatives have been patched, changes to the X86_FEATURE flags won't take effect and could potentially even be wrong. Warn about it. This is something which has been long overdue. Signed-off-by: Borislav Petkov (AMD) Tested-by: Srikanth Aithal Link: https://lore.kernel.org/r/20240327154317.29909-3-bp@alien8.de --- arch/x86/include/asm/cpufeature.h | 8 ++++++-- arch/x86/kernel/cpu/cpuid-deps.c | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 7103ba1..e5d8880 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -148,8 +148,12 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; extern void setup_clear_cpu_cap(unsigned int bit); extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); -#define setup_force_cpu_cap(bit) do { \ - set_cpu_cap(&boot_cpu_data, bit); \ +#define setup_force_cpu_cap(bit) do { \ + \ + if (!boot_cpu_has(bit)) \ + WARN_ON(alternatives_patched); \ + \ + set_cpu_cap(&boot_cpu_data, bit); \ set_bit(bit, (unsigned long *)cpu_caps_set); \ } while (0) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c index b717420..5dd427c 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -114,6 +114,9 @@ static void do_clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int feature) if (WARN_ON(feature >= MAX_FEATURE_BITS)) return; + if (boot_cpu_has(feature)) + WARN_ON(alternatives_patched); + clear_feature(c, feature); /* Collect all features to disable, handling dependencies */