NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
port-amd64/47967: DTrace does not work while running under QEMU
>Number: 47967
>Category: port-amd64
>Synopsis: tsc_freq is 0 when running under QEMU so DTrace crashes at load
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: port-amd64-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jun 26 17:35:00 +0000 2013
>Originator: Jeff Rizzo
>Release: NetBSD 6.99.22
>Organization:
>Environment:
System: NetBSD slash.lan 6.99.22 NetBSD 6.99.22 (DTRACE) #37: Sat Jun 22
16:37:43 PDT 2013
riz%slash.lan@localhost:/build/obj/sys/arch/amd64/compile/DTRACE amd64
Architecture: x86_64
Machine: amd64
>Description:
QEMU does not implement MSR_TSC, so reads there with rdmsr() always
return 0, which breaks cpu_counter_serializing(), and in turn
breaks DTrace under QEMU.
Things work ok if cpu_counter_serializing() is made to use
cpu_counter() when running under QEMU.
>How-To-Repeat:
Install system built with MKDTRACE=yes under QEMU, and
try to "modload dtrace". Boom.
>Fix:
This patch makes things work for me, though I'm not convinced it's
entirely correct:
Index: sys/arch/x86/x86/identcpu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/identcpu.c,v
retrieving revision 1.32
diff -u -r1.32 identcpu.c
--- sys/arch/x86/x86/identcpu.c 16 Jun 2012 17:30:19 -0000 1.32
+++ sys/arch/x86/x86/identcpu.c 26 Jun 2013 16:08:01 -0000
@@ -563,6 +563,17 @@
}
static void
+cpu_probe_qemu(struct cpu_info *ci)
+{
+ if (memcmp("QEMU Virtual CPU", cpu_brand_string, 16) != 0)
+ return;
+
+ /* if QEMU does not implement MSR_TSC, disable the TSC */
+ ci->ci_feat_val[0] &= ~CPUID_MSR;
+ cpu_feature[0] &= ~CPUID_MSR;
+}
+
+static void
cpu_probe_vortex86(struct cpu_info *ci)
{
#define PCI_MODE1_ADDRESS_REG 0x0cf8
@@ -709,6 +720,7 @@
cpu_probe_c3(ci);
cpu_probe_geode(ci);
cpu_probe_vortex86(ci);
+ cpu_probe_qemu(ci);
x86_cpu_topology(ci);
>Unformatted:
Home |
Main Index |
Thread Index |
Old Index