NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/39458: coretemp(4): don't attach on systems that don't provide useful data

>Number:         39458
>Category:       kern
>Synopsis:       coretemp(4): don't attach on systems that don't provide useful 
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 04 11:30:00 +0000 2008
>Originator:     Juan RP
>Release:        Latest
NetBSD vmware-netbsd 4.99.72 NetBSD 4.99.72 (MASTER) #7: Thu Sep  4 12:24:59 
CEST 2008  juan@vmware-netbsd:/usr/src/sys/arch/i386/compile/MASTER i386
coretemp(4) assumes that a newer CPU will provide correct data for the
MSR_THERM_STATUS MSR even if the MSR doesn't provide useful data.

On VMWare the host CPU is emulated on the VM, but the MSRs don't provide
useful info for the coretemp(4) driver to be useful, therefore it shouldn't be 
attached on them.

The following patch tests if MSR_THERM_STATUS has the thermal reading bit 
enabled and therefore is able to provide correct data.

This avoids attaching the driver on VMWare, qemu and others.

Index: coretemp.c
RCS file: /cvsroot/src/sys/arch/x86/x86/coretemp.c,v
retrieving revision 1.10
diff -b -u -p -r1.10 coretemp.c
--- coretemp.c  11 May 2008 14:39:49 -0000      1.10
+++ coretemp.c  4 Sep 2008 10:27:49 -0000
@@ -118,6 +118,15 @@ coretemp_register(struct cpu_info *ci)
                        sc->sc_tjmax = 85;
+       /* 
+        * Check if the MSR contains thermal reading valid bit, this
+        * avoid false positives on systems that fake up a compatible
+        * CPU that doesn't have access to these MSRs; such as VMWare.
+        */
+       msr = rdmsr(MSR_THERM_STATUS);
+       if ((msr & __BIT(31)) == 0)
+               goto bad;
        sc->sc_ci = ci;

Home | Main Index | Thread Index | Old Index