From nobody Sun Feb 8 18:18:58 2026 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 317A5214A77 for ; Mon, 3 Mar 2025 15:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741016777; cv=none; b=Hwjz2qSnNNqeIVpT72cHq1minXVOaC7/KsRI3NHC+yVhwfKY61vQIcAbdBe6c2uS6H62yUXF2buONgqmI3FDDqG/Kdoenx98Uk7N92azIQ61bivSFivu0rSmThaJRMHnltOYbmpqlabO6c2qc40QMuU/WeyzTxV/I9I+zMJtWEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741016777; c=relaxed/simple; bh=uRHVXOOGkSa8hfRoeSoSU7knCA1aK8LLB9UbK1oC8A0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=A44b1aOtXI8sCNaihrvoivyd4X+6lB4VJINf3Zbr+nEp/Ls3AiAfsesMJwrZkJonFTyQeoy4YU5uO8QYIeEcS8ZWqdj62mi4OZEGTW5mwXy8jHiHindvUIH6vU43g7mScJ4776klLnKKX3C6IbqMmGOnwEkEStPBL5Tcj1fvtBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bWcq469t; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bWcq469t" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-390f365274dso1213808f8f.0 for ; Mon, 03 Mar 2025 07:46:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741016773; x=1741621573; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1977++wS9Q+/5+3vqWvLo8Ngdbsn/3d3T1ml+Hsnu5c=; b=bWcq469t1TBkuFPDygWX3dbkS46TC8h06wuTnUhqi/5qMO1yjquMhHOnY2vHQIunNe GU3NaIEFFi+sFJVw2r5X0UwZikiBg2nc56e0SbivA1ebKrJ7m7IY1cVcZ+X5TrkyyJBy Bdodl3VnHBiGQqBph0liA+Us7F9Refiol0lIF6PEqi1Jp8fdN8LKv756BUyd/CSfFgo2 EKhWurS1Z5OhW9sHcw/RI4EP+I7+7BPWeSp5icJFsa7x494osH7tD3vxR9AREjEk8dM/ 36Id01lR9T7VWyW8LE7YaHeqbW2xCXzTZ1kh/y0dKB2MN6D1W0SFsTDEZIspcb91zkEg EyUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741016773; x=1741621573; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1977++wS9Q+/5+3vqWvLo8Ngdbsn/3d3T1ml+Hsnu5c=; b=XuuNwNSlZqOgg5i4l62nkfu6OVP+NSogJXAc60vuF9VssLMWEBrG5zkqRDMFsG5EA9 gKS2Lrxk7xkZAISHQwt/IdWlIe4PtUp/fCImZDBBzYWkQQPOovraBxJRdiu+KuSMDMLI s2/NWGrjnBh0Mfxwo5uN+sG6e95EBb/J5CPO1TnaLBY90JUce6D+B16bhSbpf0QFNMbI ElhtVl/2XZXh2qDCwimogetY+NMrfbCE82VcEtfLbcsQMLI734a+uPKlhktab94hRShI gCHSyR5pw4UJL0zldMyH/r1gGh3quYdLZTS01Ka4refQF4G9lW4yIgdOblj4cmwHPrmi q71Q== X-Gm-Message-State: AOJu0YyPzZT+eAgGKbkPXenALygzp01+1/lkLK7V4Er78I5QsyQf7Tw8 cqer24E/F+AD2w8gBUfKOFm1G03EuOl1LMWQkZhExGteILpjee77LkqwV8K78uXeWEU5TOy2N0Y UBZV2JmMvQQ== X-Google-Smtp-Source: AGHT+IGVzP5CppYQAZHhrUVqzcIc+Ul5dt40Y0wJtWUm8nf69LMknegdfM1RvsAVRhlPsLe2P5UJqYd+gHUj5g== X-Received: from wmqe20.prod.google.com ([2002:a05:600c:4e54:b0:43b:c7e5:66e0]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1787:b0:390:df83:1f22 with SMTP id ffacd0b85a97d-390e18d20ddmr14728105f8f.25.1741016773525; Mon, 03 Mar 2025 07:46:13 -0800 (PST) Date: Mon, 03 Mar 2025 15:45:37 +0000 In-Reply-To: <20250303-setcpuid-taint-louder-v1-0-8d255032cb4c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250303-setcpuid-taint-louder-v1-0-8d255032cb4c@google.com> X-Mailer: b4 0.15-dev Message-ID: <20250303-setcpuid-taint-louder-v1-1-8d255032cb4c@google.com> Subject: [PATCH 1/3] x86/cpu: Remove some macros about feature names From: Brendan Jackman To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable These macros used to abstract over CONFIG_X86_FEATURE_NAMES, but that was removed in commit 7583e8fbdc49 ("x86/cpu: Remove X86_FEATURE_NAMES"). Now they are just unnecessary indirection, remove them. Signed-off-by: Brendan Jackman Acked-by: Borislav Petkov (AMD) --- arch/x86/include/asm/cpufeature.h | 5 ----- arch/x86/kernel/cpu/common.c | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufe= ature.h index de88f9b4fa3bfa7477bbdf7c5efe9582e1b87b4f..7937823ded89d08e1928ad6ca60= ed8d76c65387d 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -38,13 +38,8 @@ enum cpuid_leafs NR_CPUID_WORDS, }; =20 -#define X86_CAP_FMT_NUM "%d:%d" -#define x86_cap_flag_num(flag) ((flag) >> 5), ((flag) & 31) - extern const char * const x86_cap_flags[NCAPINTS*32]; extern const char * const x86_power_flags[32]; -#define X86_CAP_FMT "%s" -#define x86_cap_flag(flag) x86_cap_flags[flag] =20 /* * In order to save room, we index into this array by doing diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 0f32b6ffbf04f5394e15b50188c7d32943b0b111..b5fdaa6fd4c4ff7701009a0443f= f57332503bc77 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -667,8 +667,8 @@ static void filter_cpuid_features(struct cpuinfo_x86 *c= , bool warn) if (!warn) continue; =20 - pr_warn("CPU: CPU feature " X86_CAP_FMT " disabled, no CPUID level 0x%x\= n", - x86_cap_flag(df->feature), df->level); + pr_warn("CPU: CPU feature %s disabled, no CPUID level 0x%x\n", + x86_cap_flags[df->feature], df->level); } } =20 @@ -1502,9 +1502,9 @@ static inline void parse_set_clear_cpuid(char *arg, b= ool set) =20 /* empty-string, i.e., ""-defined feature flags */ if (!x86_cap_flags[bit]) - pr_cont(" " X86_CAP_FMT_NUM, x86_cap_flag_num(bit)); + pr_cont(" %d:%d", bit >> 5, bit & 31); else - pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit)); + pr_cont(" %s", x86_cap_flags[bit]); =20 if (set) setup_force_cpu_cap(bit); @@ -1523,9 +1523,9 @@ static inline void parse_set_clear_cpuid(char *arg, b= ool set) const char *flag; =20 if (bit < 32 * NCAPINTS) - flag =3D x86_cap_flag(bit); + flag =3D x86_cap_flags[bit]; else - flag =3D x86_bug_flag(bit - (32 * NCAPINTS)); + flag =3D x86_bug_flags[bit - (32 * NCAPINTS)]; =20 if (!flag) continue; --=20 2.48.1.711.g2feabab25a-goog From nobody Sun Feb 8 18:18:58 2026 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CAE7214A89 for ; Mon, 3 Mar 2025 15:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741016778; cv=none; b=soxEF2JfO2ds2acrgSAO7mgdrI43Sg2+LOjdk07TFgaH0voU47HoxeLTpxn7JPVgAcDR7F0nqZ3jOE5FaMtXN0fByh8pFxkN5BWfB2rwukP8H64Ge3m2Y5g2MZfej2H4eQTV0NugesWVvb3qH8eXRpMx7lLlJnJm11Zcutj24pU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741016778; c=relaxed/simple; bh=S70MGT7WeSA7tjkqhDaEgU+jdWjSqastK3E10iIj4g0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=b68e9SKRwys0+Wzx+Zd503XsXhikiVPdP6aLphO9ndAxKEG/J3TeKl+qsAA8E+yP37Q5n1xUdVlMDewpVuyxF9sasHU8MZ3sHOj2RX261FyAvRj5VWRWMfCCQZ/eaeei0Vdh5Um+LGd9CQxNFtn2p0wLP0lSxcB/lCJyNGT8uEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GY3aUJVR; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GY3aUJVR" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-390e27150dbso4341217f8f.3 for ; Mon, 03 Mar 2025 07:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741016775; x=1741621575; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=P49Y5v+BDqKqasSAEFoZNR9dcrLWq08OXY3NI7AD0ak=; b=GY3aUJVRU9/BrlLGxK1Ow+NIsSQ1Le/eaUAriGDtJHSEVHCFN0AKKD0oJIVRLJ+1jZ WU7T6wtl2HM4lRWcB+lzueaXdUsc2QOPv1hCqkl9auS+bwbWhQBRqSnp1/dMWK4U5rlF qQFZl/32h7kigrS/MF06G85kMd0QDUPqQemldtToQc8KTiiZNHwNgdPvx6rBu7UinJC7 LmRpv2t/F5gmlLn42+nRSj7KGCP29qTWf7u4onMMrrZ26hrb9m78afvABWtK3jUS2roP fS+/dvGxRZknR4USARP//BIazk+wSp3h1/DaMuPTQeQYerr3chpEKSBaac7iIxAGYsar Awpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741016775; x=1741621575; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P49Y5v+BDqKqasSAEFoZNR9dcrLWq08OXY3NI7AD0ak=; b=VNvP003JBx8DE1eS8LCmyHoWh0I61eHEItdEfX8zsK+UzJ5fKUMHFpBnIQFUVT9ciF dQTePnqwnpsrLl8/E1rmyvKrJSjq6qEnQzqI498zc0N1/Tn5HFAwZ++L5GhZ7U9b8o5P +TSUV4FDMF9geaLdUMWA59IPnUrqQs2bP8xuVcmxR1qZx3F177oGlxDv1OBB/3cNh7qV Q93zDfFI4OHVN5Jd+LrjmqqvDddvETqeSPyU2gkG0UkK6gKAt0xbaHhH9bglm4nBfX73 oh+T2bYN/QPjF6yMNAzfbmW5UahQLapvTZDv/0vx9VqSCtHYqOYxfUin6FYcicKDM0Xl nEww== X-Gm-Message-State: AOJu0YyFl7azphQBsGhkqXqlTUNcWjrGIUIMcRYlWj6IagYgJW/pXknA MqrtbOrJPkHhEowEjeuqoC2Cat+GZ0T9/MwetpcjKLmXIwm327CcvyDEnHtBHa8cOrsM6KpkBv2 IkalnamJjPA== X-Google-Smtp-Source: AGHT+IEecm+RqoKWOA5gCS6PAN2M5jdRufGHjF3Gxbp8Fea8R1wBqK7KvCYM9/yX62yXN6ISEMmvG/wOOPLd+A== X-Received: from wmbjh12.prod.google.com ([2002:a05:600c:a08c:b0:43b:b2de:9bf4]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:598f:0:b0:390:f902:f961 with SMTP id ffacd0b85a97d-390f902fa79mr6803977f8f.45.1741016775619; Mon, 03 Mar 2025 07:46:15 -0800 (PST) Date: Mon, 03 Mar 2025 15:45:38 +0000 In-Reply-To: <20250303-setcpuid-taint-louder-v1-0-8d255032cb4c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250303-setcpuid-taint-louder-v1-0-8d255032cb4c@google.com> X-Mailer: b4 0.15-dev Message-ID: <20250303-setcpuid-taint-louder-v1-2-8d255032cb4c@google.com> Subject: [PATCH 2/3] x86/cpu: Warn louder about {set,clear}cpuid From: Brendan Jackman To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Commit 814165e9fd1f6 ("x86/cpu: Add the 'setcpuid=3D' boot parameter") recently expanded the user's ability to break their system horribly by overriding effective CPU flags. This was reflected with updates to the documentation to try and make people aware that this is dangerous. To further reduce the risk of users mistaking this for a "real feature", and try to help them figure out why their kernel is tainted if they do use it: - Upgrade the existing printk to pr_warn, to help ensure kernel logs reflect what changes are in effect. - Print an extra warning that tries to be as dramatic as possible, while also highlighting the fact that it tainted the kernel. Suggested-by: Ingo Molnar Signed-off-by: Brendan Jackman Acked-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/common.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index b5fdaa6fd4c4ff7701009a0443ff57332503bc77..c1ced31f976d970efd24d6c9e4a= c77cbff3371b9 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1479,12 +1479,12 @@ static void detect_nopl(void) #endif } =20 -static inline void parse_set_clear_cpuid(char *arg, bool set) +static inline bool parse_set_clear_cpuid(char *arg, bool set) { char *opt; int taint =3D 0; =20 - pr_info("%s CPUID bits:", set ? "Force-enabling" : "Clearing"); + pr_warn("%s CPUID bits:", set ? "Force-enabling" : "Clearing"); =20 while (arg) { bool found __maybe_unused =3D false; @@ -1547,10 +1547,9 @@ static inline void parse_set_clear_cpuid(char *arg, = bool set) pr_cont(" (unknown: %s)", opt); } =20 - if (taint) - add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); - pr_cont("\n"); + + return taint; } =20 =20 @@ -1560,6 +1559,7 @@ static inline void parse_set_clear_cpuid(char *arg, b= ool set) */ static void __init cpu_parse_early_param(void) { + bool cpuid_taint =3D false; char arg[128]; int arglen; =20 @@ -1594,11 +1594,16 @@ static void __init cpu_parse_early_param(void) =20 arglen =3D cmdline_find_option(boot_command_line, "clearcpuid", arg, size= of(arg)); if (arglen > 0) - parse_set_clear_cpuid(arg, false); + cpuid_taint |=3D parse_set_clear_cpuid(arg, false); =20 arglen =3D cmdline_find_option(boot_command_line, "setcpuid", arg, sizeof= (arg)); if (arglen > 0) - parse_set_clear_cpuid(arg, true); + cpuid_taint |=3D parse_set_clear_cpuid(arg, true); + + if (cpuid_taint) { + pr_warn("!!! setcpuid=3D/clearcpuid=3D in use, this is for TESTING ONLY,= may break things horribly. Tainting kernel.\n"); + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); + } } =20 /* --=20 2.48.1.711.g2feabab25a-goog From nobody Sun Feb 8 18:18:58 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4030D21505C for ; Mon, 3 Mar 2025 15:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741016782; cv=none; b=l3SGQVFCQyTIG+6nE5YLDzb/0fX8JiTXgSWvCgS8ozuI1/ld1PocfzTvRD+joke8YzaGrYoij1WEPDo/5Z2xa5hGUu8RWs/fwXHa6Wd6SlkVxR35ZB2Z0D7WaYcDhoOANzpqO9dkBJ+rKQ/+h1tAIPNZkOD3CUcR2jYbLYzqi3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741016782; c=relaxed/simple; bh=xZbG9+LargulmZD5V8VthUDEt6YSputXK3s15FU9+zY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BxsCXR0Kpm2eWdlox3zqINyo0GBtTt/rtxRlIxgWm3FoEW+s6zL65dnwVjXx90F/fJ0OIVuePRiBwyi94FqWw8+wLiY2scbyM2ql6scZFV4+fzOZchZg5dJOyRnYJrLe8uceXFllDAtbrCux7wurjbb1recv4dzWWUuFstkGlsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=n+CNwudK; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="n+CNwudK" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4398ed35b10so20577805e9.1 for ; Mon, 03 Mar 2025 07:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741016777; x=1741621577; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=m5VafYnlfGJvqMjKGIihikKtNMHAvBXWGf3PBF9dZwk=; b=n+CNwudKozlZbT6oiHJG+0oHweXrMIE8o1c4Kul4CVLaXWOHS27K9/nn4o9J4R2cHL gmc6DnkJrFdw1vBD5BIy7tXI76q8lGKXeUkVcRjEi7Pp5hXKct3b8A/OQ9mRpB256NUj hRWPatMYOLQXP/nAHl+6Ye1q7qxPDKUEnz8p94SNrYr39oBT+ZMqvl4FaRhlAkkNlzXG x4hS8BaN11TO9BdjA+hgR/JyholaylH4H3LwNVfuI7sWcKvS1qCzEP4kS1fBzvMmn//h FXdYzwQkfasrLZxsJXzx40ZrQS/dHbpY52erK1NmJvgyM4o9qMGFK40QHY6ZYd8r+PZf lepw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741016777; x=1741621577; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m5VafYnlfGJvqMjKGIihikKtNMHAvBXWGf3PBF9dZwk=; b=dIEAgRVzQ9CJCgbnKX5QZfydvPAPpJ9bnu0RhcjX8uiJBStJgBk7hrIELEuUAdKD+W iOEsmlPMELK1Sn7F5fm52AsMp2yndk74nKIOIdQM52AuwHlb/niNqlDrxMO9UGv3gIlZ qOBHXWlTXWJc7MhlZ+9xOYAg7jIR0psBP7hY9BrnueIcxJlShUfW8eAmoDs5PTjWRrfq mI5If8qTiH9ZS9r8NHr9EtVvUQbKwquDfam6C6Bq8gnl2HTqedJUMkfDzfTOJvjyTxQe 5V0TISPDHs2Pl8lBJDaC81VMTJvI5idAQonpfiu6scVxMG71O271bjiChfmwMINN8VIW 7dIg== X-Gm-Message-State: AOJu0YxybluWR42/gFFFXaQBlVs3t7pTVmRiCoSbn/jrjr/t+7aLcyli kwlRxUNSkxQId5f78HCHowTte0HeP5uhLEZN0gjnlQdKpWTSqCZnPwsHrKH3VfEX6HXJYh9LT66 1Vz90qLbpbQ== X-Google-Smtp-Source: AGHT+IE3N2oxEHJ5LswDOjLZnmd7mp9zhpcr2Z2YcRShTrfqCv8jdoD7g0qBBoBARJd31RAi+IyGCvu8ellqWA== X-Received: from wmbfl18.prod.google.com ([2002:a05:600c:b92:b0:43b:c967:2f53]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1d0b:b0:43b:c5a3:2e1a with SMTP id 5b1f17b1804b1-43bc5a32fd2mr21349525e9.2.1741016777647; Mon, 03 Mar 2025 07:46:17 -0800 (PST) Date: Mon, 03 Mar 2025 15:45:39 +0000 In-Reply-To: <20250303-setcpuid-taint-louder-v1-0-8d255032cb4c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250303-setcpuid-taint-louder-v1-0-8d255032cb4c@google.com> X-Mailer: b4 0.15-dev Message-ID: <20250303-setcpuid-taint-louder-v1-3-8d255032cb4c@google.com> Subject: [PATCH 3/3] x86/cpu: Log CPU flag cmdline hacks more verbosely From: Brendan Jackman To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, Brendan Jackman , Peter Zijlstra Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Since using these options is very dangerous, make details as visible as possible: - Instead of a single message for each of the cmdline options, print a separate pr_warn() for each individual flag. - Say explicitly whether the flag is a "feature" or a "bug". Suggested-by: Peter Zijlstra Signed-off-by: Brendan Jackman Acked-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/common.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c1ced31f976d970efd24d6c9e4ac77cbff3371b9..8eba9ca9c216127ce1a6d630e7f= 67130520137b4 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1484,8 +1484,6 @@ static inline bool parse_set_clear_cpuid(char *arg, b= ool set) char *opt; int taint =3D 0; =20 - pr_warn("%s CPUID bits:", set ? "Force-enabling" : "Clearing"); - while (arg) { bool found __maybe_unused =3D false; unsigned int bit; @@ -1500,16 +1498,19 @@ static inline bool parse_set_clear_cpuid(char *arg,= bool set) if (!kstrtouint(opt, 10, &bit)) { if (bit < NCAPINTS * 32) { =20 + if (set) { + pr_warn("setcpuid: force-enabling CPU feature flag:"); + setup_force_cpu_cap(bit); + } else { + pr_warn("clearcpuid: force-disabling CPU feature flag:"); + setup_clear_cpu_cap(bit); + } /* empty-string, i.e., ""-defined feature flags */ if (!x86_cap_flags[bit]) - pr_cont(" %d:%d", bit >> 5, bit & 31); + pr_cont(" %d:%d\n", bit >> 5, bit & 31); else - pr_cont(" %s", x86_cap_flags[bit]); + pr_cont(" %s\n", x86_cap_flags[bit]); =20 - if (set) - setup_force_cpu_cap(bit); - else - setup_clear_cpu_cap(bit); taint++; } /* @@ -1521,11 +1522,15 @@ static inline bool parse_set_clear_cpuid(char *arg,= bool set) =20 for (bit =3D 0; bit < 32 * (NCAPINTS + NBUGINTS); bit++) { const char *flag; + const char *kind; =20 - if (bit < 32 * NCAPINTS) + if (bit < 32 * NCAPINTS) { flag =3D x86_cap_flags[bit]; - else + kind =3D "feature"; + } else { + kind =3D "bug"; flag =3D x86_bug_flags[bit - (32 * NCAPINTS)]; + } =20 if (!flag) continue; @@ -1533,22 +1538,24 @@ static inline bool parse_set_clear_cpuid(char *arg,= bool set) if (strcmp(flag, opt)) continue; =20 - pr_cont(" %s", opt); - if (set) + if (set) { + pr_warn("setcpuid: force-enabling CPU %s flag: %s\n", + kind, flag); setup_force_cpu_cap(bit); - else + } else { + pr_warn("clearcpuid: force-disabling CPU %s flag: %s\n", + kind, flag); setup_clear_cpu_cap(bit); + } taint++; found =3D true; break; } =20 if (!found) - pr_cont(" (unknown: %s)", opt); + pr_warn("%s: unknown CPU flag: %s", set ? "setcpuid" : "clearcpuid", op= t); } =20 - pr_cont("\n"); - return taint; } =20 --=20 2.48.1.711.g2feabab25a-goog