Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2128045lqe; Tue, 9 Apr 2024 10:12:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXg7b9Tvx1grrAMPbSBReB48vWiW7D4HxWcWTjetonl6DFq+sKCnwc1n2Tw69zCzpKc4MNDAKTkIfVeqwZxRwcPNBmK/oDedFsL1kNRMA== X-Google-Smtp-Source: AGHT+IHn9cFHNLfgorr31Rrhiux5pGkLA+VqmHKxH06gz1O4mGiWhhW0TZ6qVRn0xJeKoASXoy8G X-Received: by 2002:a05:6214:226b:b0:69b:1fd0:e903 with SMTP id gs11-20020a056214226b00b0069b1fd0e903mr171856qvb.58.1712682752762; Tue, 09 Apr 2024 10:12:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712682752; cv=pass; d=google.com; s=arc-20160816; b=vlqiDZPICTsmXjsB6chnZZW54yMuHyjboYQc/oSjkYO3iSB15VAgQEwRBpn2qt5E8v g8662lospGIwLy3UiSYsOj8CkqJkoPzSziWse6PNlVpRubszgP5s6lF+qONYhxGHV1F7 FNtPMUT9PxSVxwpEvM+wiy8l/JVGd+MyWaeESzQWite3VMx1AcvNhtfCchKY/Emix5td JOep8DLRanhTNp8VZQjGk0wepQqviQJrNGbZcuC0k9eqhrOPqDYtLile7tLIMCom7LuP AeTBHzqw+/sdcWcGJXXw+HGXfHBPi4RpGsb/iqWoerj1zncz4jjZAN/niNmJCTIn705a kv3Q== 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=SYQWJatz/tGYxKhDty9VBTDs+ZeurAA5CNoJu77a3Ks=; fh=iQj9pVMWMYYJnq+hMBQaOz6KdlwYYonhoOh6YTZ9UWE=; b=ZzLUCc1cvzTdQ9tox8sNeKnNb/8Lc1GRxDuqJ+gG0GQeWx0uFYw6pGc4pEsDcw91+H HxUI0scLMOh99U0NfSyxTL81jdvkUQzj7eDaMLi8xJjBvH/cUOVLVmpRZePsNTXlQbnG y/6JkfJS7EiZq8Lr+DCktUjo19mfu99hT7mlmUPa7Xkriw756uIrItHSejTEA4PuBshq 69veH64dNJe54IZgD1cZ7DelOhzksUSo/eIK7ejIBdcIHrEA4iPa8NtQJZl5zjXe7FLJ WxL5kGJ48x1myoF0FPsF1QjBgKreZQr446mm+9PJBPhFRggUqpCBCa/34EHg7tRK6YoX fOIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Al8mFl4S; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=G0h6Mfc5; 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-137377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ec19-20020ad44e73000000b006993d749e56si10594592qvb.571.2024.04.09.10.12.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 10:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Al8mFl4S; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=G0h6Mfc5; 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-137377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137377-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1BDAA1C209CD for ; Tue, 9 Apr 2024 17:12:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92A11156670; Tue, 9 Apr 2024 17:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Al8mFl4S"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="G0h6Mfc5" 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 03526156220; Tue, 9 Apr 2024 17:11:34 +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=1712682696; cv=none; b=ZJuHP9FiEB2y72waSss5vyIsPlFU5fPIEEXx7xkV0bDsuIatTqn1pbCLQkj+RRh4csOo1pYXmsy6KFrUQdU8kMLfHSoLnA88e8+vYl0tvZkGeADdcJVbqThzrf7KApkP15KryVmsmMlwyESIcA18OP17vCJRRxnvPMJPEnJ/pUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712682696; c=relaxed/simple; bh=SBwp4FIi+xGSX6fUSbg/722dbayUuOp7g15zVEiHioA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=u1oZtqQcnL8lAcBN8BaL26XHvTdQhlOqYzgcZ2a2F7bj18JwjWRoDwcl7Giu4lloia/AW2+eHy05urpJmxOrIo4VcrK6bA6kezm3pbpunyM60iKi7i9FuqWdV23HLQbexHNp7wpLwf/wqmHrybIX4pxrpZjhjBXCB7Hdtk2Lo7E= 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=Al8mFl4S; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=G0h6Mfc5; 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: Tue, 09 Apr 2024 17:11:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712682693; 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=SYQWJatz/tGYxKhDty9VBTDs+ZeurAA5CNoJu77a3Ks=; b=Al8mFl4Ss/0ECD9JuUjeqUDc+99Sy90LLLoS53yxX/sTdUcZiKFfaOyW3a6v/TGg8qnmVO 3p8qleL00BwWv4hH2MT+u1Z8EhHQFYeIf4k7NxqkP0FlmPc2v+BKYt89+EVCjgpywvGHWD Mq/tXG+Kmqvw/kAFvlmCsVK9o9w5ghHJ+0wru2qJTL0UMedBcf4GE4r7iscM+zVdjvzPoC D56ikrQfnhu9Wfb4BUA5VXiVkXFEFwEAeiFO79UfoJpCA5YAPP7LG7MtWqTMqFudSX7RJ+ 3Uty5hPvND/5LSfUWWZvwJaRbjtIc6vuYtEZLhX6MK72R5qJb8CGF996MmFT9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712682693; 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=SYQWJatz/tGYxKhDty9VBTDs+ZeurAA5CNoJu77a3Ks=; b=G0h6Mfc5N+0kDvHD8qMwa1Qqe0tniB8f652h5uNlJA7V9pUxrccofS79xEoCZJVBIGgj+W AoD+TMEO1SwB5VAw== 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)" , Ingo Molnar , 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: <171268269269.10875.17747775043118568657.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: ee8962082a4413dba1a1b3d3d23490c5221f3b8a Gitweb: https://git.kernel.org/tip/ee8962082a4413dba1a1b3d3d23490c5221f3b8a Author: Borislav Petkov (AMD) AuthorDate: Wed, 27 Mar 2024 16:43:14 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 09 Apr 2024 18:03:53 +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) Signed-off-by: Ingo Molnar 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 686e92d..f07687d 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -150,8 +150,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 */