mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: mingo@elte.hu, hpa@zytor.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org
Subject: [PATCH] [7/7] Add generic clearcpuid=... option
Date: Fri, 18 Jan 2008 18:27:23 +0100 (CET)	[thread overview]
Message-ID: <20080118172723.B604B14AAE@wotan.suse.de> (raw)
In-Reply-To: <20080118627.198787000@suse.de>


Add a generic option to clear any cpuid bit. I added it because it was
very easy to add with the new generic cpuid disable bitmap and perhaps
it will be useful in the future.

Signed-off-by: Andi Kleen <ak@suse.de>

---
 Documentation/kernel-parameters.txt |   13 +++++++++++++
 arch/x86/kernel/cpu/common.c        |   11 +++++++++++
 arch/x86/kernel/setup_64.c          |   11 +++++++++++
 3 files changed, 35 insertions(+)

Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -572,6 +572,17 @@ void __cpuinit print_cpu_info(struct cpu
 		printk("\n");
 }
 
+static __init int setup_disablecpuid(char *arg)
+{
+	int bit;
+	if (get_option(&arg, &bit) && bit < NCAPINTS*32)
+		setup_clear_cpu_cap(bit);
+	else
+		return 0;
+	return 1;
+}
+__setup("clearcpuid=", setup_disablecpuid);
+
 cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
 
 /* This is hacky. :)
Index: linux/arch/x86/kernel/setup_64.c
===================================================================
--- linux.orig/arch/x86/kernel/setup_64.c
+++ linux/arch/x86/kernel/setup_64.c
@@ -1060,6 +1060,17 @@ void __cpuinit print_cpu_info(struct cpu
 		printk(KERN_CONT "\n");
 }
 
+static __init int setup_disablecpuid(char *arg)
+{
+	int bit;
+	if (get_option(&arg, &bit) && bit < NCAPINTS*32)
+		setup_clear_cpu_cap(bit);
+	else
+		return 0;
+	return 1;
+}
+__setup("clearcpuid=", setup_disablecpuid);
+
 /*
  *	Get CPU information for use by the procfs.
  */
Index: linux/Documentation/kernel-parameters.txt
===================================================================
--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -408,6 +408,19 @@ and is between 256 and 4096 characters. 
 			[SPARC64] tick
 			[X86-64] hpet,tsc
 
+	clearcpuid=BITNUM [X86]
+			Disable CPUID feature X for the kernel. See
+			include/asm-x86/cpufeature.h for the valid bit numbers.
+			Note the Linux specific bits are not necessarily
+			stable over kernel options, but the vendor specific
+			ones should be.
+			Also note that user programs calling CPUID directly
+			or using the feature without checking anything
+			will still see it. This just prevents it from
+			being used by the kernel or shown in /proc/cpuinfo.
+			Also note the kernel might malfunction if you disable
+			some critical bits.
+
 	code_bytes	[IA32/X86_64] How many bytes of object code to print
 			in an oops report.
 			Range: 0 - 8192

      parent reply	other threads:[~2008-01-18 17:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18 17:27 [PATCH] [0/7] Add noclflush option and related cleanup Andi Kleen
2008-01-18 17:27 ` [PATCH] [1/7] Add frame work to disable CPUID bits on the command line Andi Kleen
2008-01-18 17:27 ` [PATCH] [2/7] Convert some existing cpuid disable options to new generic bitmap Andi Kleen
2008-01-18 17:27 ` [PATCH] [3/7] Don't disable RDTSC in userland for 32bit notsc Andi Kleen
2008-01-18 17:27 ` [PATCH] [4/7] Convert TSC disabling to generic cpuid disable bitmap Andi Kleen
2008-01-19 18:15   ` Ian Campbell
2008-01-19 18:57     ` Andi Kleen
2008-01-19 22:29       ` Ian Campbell
2008-01-19 18:18   ` Ian Campbell
2008-01-18 17:27 ` [PATCH] [5/7] Remove CONFIG_X86_TSC for 32bit Andi Kleen
2008-01-18 21:05   ` [PATCH] [5/7] Remove CONFIG_X86_TSC for 32bit II Andi Kleen
2008-01-18 22:06     ` Ingo Molnar
2008-01-18 17:27 ` [PATCH] [6/7] Add noclflush option Andi Kleen
2008-01-18 17:27 ` Andi Kleen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080118172723.B604B14AAE@wotan.suse.de \
    --to=ak@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®