Why is PCE not set in CR4?

Sergey DoubleF Zaharchenko doublef at tele-kom.ru
Tue Sep 30 06:47:03 PDT 2003


On Tue, 30 Sep 2003 00:18:19 +0200 Shill <devnull at kma.eu.org> probably wrote:

> Hello all,
> 
> I've been playing with my Athlon's timestamp counter for a while,
> and I would like to experiment with the performance-monitoring
> counters now.
> 
> I can execute the RDTSC instruction from ring 3 because the TSD
> (TimeStamp Disable) bit in CR4 (Control Register 4) is cleared.
> 
> However, I am not allowed to use the RDPMC instruction from ring 3
> because the PCE (Performance-monitoring Counters Enable) bit is not set.

You can do it with /dev/perfmon. man 4 perfmon.

> Is there a reason (security? performance? other?) why FreeBSD does
> not set PCE at boot time?
>
> On a related subject, is there a way for a kernel module to catch a
> general-protection fault caused by an application trying to execute
> RDMSR or WRMSR, and have the kernel module execute the instruction
> for the application? Or is it cleaner to register two new system
> calls to achieve the same thing?

That would (probably) require adding superuser-configurable permissions
to read/write to a specific MSR, as some of them are critical. I doubt
it's worth creating extra device nodes, and I wonder if there's a
"cleaner" way to do that. 

-- 
DoubleF
The simpler the instruction, e.g. "press here", the
more difficult it will be to open the package.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030930/739f1d4e/attachment.bin


More information about the freebsd-questions mailing list