From mboxrd@z Thu Jan 1 00:00:00 1970 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 A6BC11DAC9C for ; Wed, 29 Jan 2025 15:37:36 +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=1738165058; cv=none; b=rkia53Y3eAL3VN+wu0TtzN8qsm7IyCQbIm6c7rk7j9UHdRS7whlWAATSFxfsVwnRqtfmBqds8gJVZTZsrH0bfC6pa6rWVurZMx+77+DUM3SFeaL/Ey8LV5gKmStDfc5nisb13phiyd4xb1ESm9vPke8Uj/3WmU/2qB9gB3NYG1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738165058; c=relaxed/simple; bh=kT+0ZaFnzojzncwz83ZbSFndFMpHLGrjkc+LBrqGIwQ=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ujyiC1K077eD4Wnspv8DCqITUZ33fmOQo8XQQGT0BY/kpF+mVoyMzwaplhNkpX/npM+TvqhLPPrReZ3pYIfTokrAdQ/I4dd8Ja7mUcC6olDNe3J45+IJqJI56kzgBdGCAhI1x/pAMqMt74hVjp17/PvQceryVqYYcLETNx6I/ps= 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=AIyeORkS; 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="AIyeORkS" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4388eee7073so4269215e9.0 for ; Wed, 29 Jan 2025 07:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738165055; x=1738769855; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Lt6MMM7vthZjz1QNsRCKcBXabbBVErsDVZyifD1EqTM=; b=AIyeORkS+lC7Nl/oegh79yF2v3O46Fw1dKT5mTQaqEWyQsowBX117ARVDZgTWmIe84 ZwjPnDik60U2AU0w2bo6jefrkxxC/0Fd0RHeYYL8gkiTzvtToqyxnciJ+e9+O0WA9isp jgbQhRp7piVt3sXPF+0yrSHxsIwo+lQoLO7HcyPxwUkPvRm7IQME+3JeSPjN0wdEnucp 0Yqq/gScYfakj0hYRuoUOWTwQOGJaJS/pfAHmyMHuvXCBKHWrP/gnsPgjwp2VUOLFBVf RSJ1yx1D+ckf/264fZuZSb7ZElNxDykB75QtxJk1IljE57k0YioH/jWQ8a+GWRdtjEcw PIRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738165055; x=1738769855; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Lt6MMM7vthZjz1QNsRCKcBXabbBVErsDVZyifD1EqTM=; b=ibOMr2tnTNXg8JLoN0/ngc3qkx2LQ8ur5VeH2HtHGpOtXu1K2Dvk1Llnrk1sy+LesS 7XQTA3KuUodXyBXNTO+0qh+NjasFMEera82agZ9/Uga1aROKAI6c+bnM2mV12yCxuBt2 yA/2hYgz3Nz+TwiQlGcwAw2bZY2VK+n8yJ/YiV+ZXLfx3B5T7oS1loQMJA3pGPJF3s6s PniLLdZaaW8Wce9sJvDtYDTvTYuYoZS25ogqGYXC7Q60VBb/2+YgoxTLoj6B+NJ395nq OMt+GlTUwxipgQ9W4/lk8hGsJ9KFARcaluQfiERE4U5T3inS2a6fURjJyXAipLZfAx2z ETWg== X-Forwarded-Encrypted: i=1; AJvYcCWK1KVbcqFjZIF1Tydy+LYhsEqkHQrNUGqq9CC80Wffa1wDWI/03qMgrC3wriIz2mlFluWJF8QhIgwYYfQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0hqOM6OlYyXXU1Hpcn2u/kXGeICruJ8WMAK086s4risBN6fDQ ra+C5v9/a39ArNR1GD3Ev75NAJ50FtLXi4KYPK87v39ybgFLJ4CVjaUy7cA5D0+KOj2omonjIJV ZG4QcSPY15A== X-Google-Smtp-Source: AGHT+IEK9zY4V3xSywXIG+0GpovPa1OiGoyTT8PEhTBIxicJqNGO5Q5P6xI4RQ1OsQhNbOzjUxF2tCfksJbwzA== X-Received: from wmhp6.prod.google.com ([2002:a05:600c:4186:b0:435:4bd2:1dcd]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4917:b0:435:edb0:5d27 with SMTP id 5b1f17b1804b1-438d5967d97mr73958475e9.9.1738165055016; Wed, 29 Jan 2025 07:37:35 -0800 (PST) Date: Wed, 29 Jan 2025 15:35:38 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: b4 0.15-dev Message-ID: <20250129-force-cpu-bug-v2-0-5637b337b443@google.com> Subject: [PATCH RESEND v2 0/3] x86/cpu: Add facility to force-enable CPU caps and bugs From: Brendan Jackman To: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" For testing, development, and experimentation, add the ability to force the kernel to behave as if the CPU has a bug, even if it doesn't, using a command-line param. Also do this in general for CPU flags, since: - The infrastructure is the same so there is almost no extra implementation complexity. - While setting random CPU flags is certain to break the kernel in mysterious and horrifying ways, this is not dramatically worse than setting CPU bugs. Although CPU bug mitigations don't have any very obvious ways to break the system if run on the wrong hardware, it's still very much an unsupported configuration, even beyond the security concern implied breaking mitigation logic. Since a taint and scary docs are necessary regardless, supporting arbitrary CPU flags doesn't add significant maintenance/support burden either. Signed-off-by: Brendan Jackman --- Changes in v2: - Switched from a bugs-only force_cpu_bug= to a more general setcpuid=. - Made it taint the kernel. - Made docs sound scarier. - Spellchecked and avoided new usage of personal pronouns. - Link to v1: https://lore.kernel.org/r/20241119-force-cpu-bug-v1-1-2aa31c6c1ccf@google.com --- Brendan Jackman (3): x86/cpu: Create helper to parse clearcpuid param x86/cpu: Add setcpuid cmdline param x86/cpu: Enable modifying bug flags with {clear,set}puid arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/common.c | 139 +++++++++++++++++++++++--------------- 2 files changed, 87 insertions(+), 53 deletions(-) --- base-commit: eabcdba3ad4098460a376538df2ae36500223c1e change-id: 20241119-force-cpu-bug-94a08ab0239f Best regards, -- Brendan Jackman