On Thu, 13 Feb 2014, deoxyt2 wrote:
> To day I wished install OBSD55 snapshot, buy I can't run this in 
> VirtualBox.
> 
> http://deoxyt2.livejournal.com/54715.html

The faulting instruction is a rdmsr() from calibrate_cyclecounter_ctr(), 
which indicates that VirtualBox doesn't support Invariant TSC.  We 
currently expect Invariant TSC support to be present if the CPU is a new 
enough model, without testing whether the ITSC bit is set in 
cpuid(0x80000007)'s return.  That works on all real hardware, so it's only 
VMs which pick and choose extension support which are a problem, emulating 
a CPU that doesn't exist.

Diff below adds the cpuid() test, and aligns i386 with amd64 by enabling 
ITSC support on AMD cpus.  Does it help your VirtualBox setup?


Philip


Index: i386/i386/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.531
diff -u -p -r1.531 machdep.c
--- i386/i386/machdep.c 5 Jan 2014 20:23:57 -0000       1.531
+++ i386/i386/machdep.c 13 Feb 2014 21:30:58 -0000
@@ -1855,15 +1855,18 @@ identifycpu(struct cpu_info *ci)
                /* Has TSC, check if it's constant */
                switch (vendor) {
                case CPUVENDOR_INTEL:
-                       if ((ci->ci_family == 0x0f && ci->ci_model >= 0x03) ||
-                           (ci->ci_family == 0x06 && ci->ci_model >= 0x0e)) {
+                       if ((i386_cpuid_edxapmi & CPUIDEDX_ITSC) &&
+                           ((ci->ci_family == 0x0f && ci->ci_model >= 0x03) ||
+                           (ci->ci_family == 0x06 && ci->ci_model >= 0x0e)))
                                ci->ci_flags |= CPUF_CONST_TSC;
-                       }
                        break;
                case CPUVENDOR_VIA:
-                       if (ci->ci_model >= 0x0f) {
+                       if (ci->ci_model >= 0x0f)
+                               ci->ci_flags |= CPUF_CONST_TSC;
+                       break;
+               case CPUVENDOR_AMD:
+                       if (i386_cpuid_edxapmi & CPUIDEDX_ITSC)
                                ci->ci_flags |= CPUF_CONST_TSC;
-                       }
                        break;
                }
                calibrate_cyclecounter();
Index: amd64/amd64/identcpu.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/identcpu.c,v
retrieving revision 1.52
diff -u -p -r1.52 identcpu.c
--- amd64/amd64/identcpu.c      19 Nov 2013 04:12:17 -0000      1.52
+++ amd64/amd64/identcpu.c      13 Feb 2014 21:30:58 -0000
@@ -440,8 +440,9 @@ identifycpu(struct cpu_info *ci)
        if (ci->ci_feature_flags && ci->ci_feature_flags & CPUID_TSC) {
                /* Has TSC, check if it's constant */
                if (!strcmp(cpu_vendor, "GenuineIntel")) {
-                       if ((ci->ci_family == 0x0f && ci->ci_model >= 0x03) ||
-                           (ci->ci_family == 0x06 && ci->ci_model >= 0x0e)) {
+                       if ((cpu_apmi_edx & CPUIDEDX_ITSC) &&
+                           ((ci->ci_family == 0x0f && ci->ci_model >= 0x03) ||
+                           (ci->ci_family == 0x06 && ci->ci_model >= 0x0e))) {
                                ci->ci_flags |= CPUF_CONST_TSC;
                        }
                } else if (!strcmp(cpu_vendor, "CentaurHauls")) {

Reply via email to