linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tuukka Toivonen <tutoivon@mail.student.oulu.fi>
To: linux-kernel@vger.kernel.org
Subject: patch: enabling RDPMC: bit 8 in CR4 (PCE)
Date: Thu, 18 Jan 2001 17:38:20 +0200	[thread overview]
Message-ID: <Pine.SGI.4.21.0101181735430.3651579-100000@paju.oulu.fi> (raw)

This patch enables performance counters if RDTSC is not disabled (ie. it
assumes user wants to enable RDPMC if he wants to enable RDTSC too).

It is against 2.4.0.

To save me from typing, I'll quote Intel IA-32 manuals:

"PCE    Performance-Monitoring Counter Enable (bit 8 of CR4). Enables
execution of the RDPMC instruction for programs or procedures running at
any protection level when set; RDPMC instruction can be executed only at
protection level 0 when clear."

"The RDPMC instruction was introduced into the IA-32 architecture with the
Pentium Pro processor and the Pentium processor with MMX technology."

I suppose that if the CPU has MMX, then it's ok to write 1 in PCE
bit. This should be valid for Intel CPUs, but it's certainly possible that
there are non-Intel CPUs that have MMX but not RDPMC. However, I'd guess
that writing 1 to PCE bit doesn't do any harm.

Security considerations: same as with RDTSC, I guess?

Tested on AMD Athlon 800 MHz.

Please keep me on the CC list, because majordomo doesn't allow me to
subscribe to the mailing list.

Request: has anyone links to using MSRs on Linux? It seems that three
persons have done work on MSR support: Stephen Meyer, Peter Anvin and
Richard Gooch. From Richard's pages I found some user-space libraries, but
they don't seem to work with current kernels?

--- linux-2.4.0/include/asm-i386/processor.h	Tue Jan 16 15:00:57 2001
+++ linux-2.4.0-tt/include/asm-i386/processor.h	Thu Jan 18 16:39:39 2001
@@ -88,6 +88,7 @@
 #define cpu_has_fxsr	(test_bit(X86_FEATURE_FXSR, boot_cpu_data.x86_capability))
 #define cpu_has_xmm	(test_bit(X86_FEATURE_XMM,  boot_cpu_data.x86_capability))
 #define cpu_has_fpu	(test_bit(X86_FEATURE_FPU,  boot_cpu_data.x86_capability))
+#define cpu_has_mmx	(test_bit(X86_FEATURE_MMX,  boot_cpu_data.x86_capability))
 
 extern char ignore_irq13;
 
--- linux-2.4.0/arch/i386/kernel/setup.c	Sun Dec 31 20:26:18 2000
+++ linux-2.4.0-tt/arch/i386/kernel/setup.c	Thu Jan 18 16:57:51 2001
@@ -2215,6 +2215,14 @@
 
 	if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
 		clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
+	if (cpu_has_mmx	/* Suppose that if CPU has MMX, it also has PCE */
+#ifndef CONFIG_X86_TSC
+		&& !tsc_disable	/* Don't enable RDPMC if TSC is disabled */
+#endif	
+	) {
+		printk("Enabling performance monitoring counters...\n");
+		set_in_cr4(X86_CR4_PCE);
+	}
 #ifndef CONFIG_X86_TSC
 	if (tsc_disable && cpu_has_tsc) {
 		printk("Disabling TSC...\n");


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

             reply	other threads:[~2001-01-18 15:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-18 15:38 Tuukka Toivonen [this message]
2001-01-18 16:14 ` patch: enabling RDPMC: bit 8 in CR4 (PCE) Maciej W. Rozycki

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=Pine.SGI.4.21.0101181735430.3651579-100000@paju.oulu.fi \
    --to=tutoivon@mail.student.oulu.fi \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).