aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLinaro Packagers <linaro-pkg@lists.launchpad.net>2013-08-02 06:39:45 +0000
committerFathi Boudra <fathi.boudra@linaro.org>2013-08-05 10:19:57 +0300
commit3ba5745389cb428bf0f99fdde92ed3876ca5e5c8 (patch)
tree06dc0389b02c64ce9cb23cad85382745c0d6177c /scripts
parentc3565b8703553405641c76a4c40961473d051edd (diff)
parent86342dcc9b73eac8310b9dc5fd1356bbfa5b9c8e (diff)
Imported Debian patch 1.5.0-2013.06+git74+20130802+ef1b0ae-3linaroraring1HEADmaster
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/kvm/vmxcap26
-rw-r--r--scripts/make_device_config.sh6
-rwxr-xr-xscripts/tracetool.py4
-rw-r--r--scripts/tracetool/backend/__init__.py16
-rw-r--r--scripts/tracetool/backend/dtrace.py3
-rw-r--r--scripts/tracetool/backend/events.py23
-rw-r--r--scripts/tracetool/backend/ftrace.py54
-rw-r--r--scripts/tracetool/backend/simple.py22
-rw-r--r--scripts/tracetool/backend/stderr.py28
-rw-r--r--scripts/tracetool/backend/ust.py3
-rw-r--r--scripts/tracetool/format/events_c.py39
-rw-r--r--scripts/tracetool/format/events_h.py50
-rw-r--r--scripts/tracetool/format/h.py9
13 files changed, 235 insertions, 48 deletions
diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
index 0b23f77..c90eda4 100755
--- a/scripts/kvm/vmxcap
+++ b/scripts/kvm/vmxcap
@@ -27,9 +27,9 @@ MSR_IA32_VMX_VMFUNC = 0x491
class msr(object):
def __init__(self):
try:
- self.f = file('/dev/cpu/0/msr')
+ self.f = open('/dev/cpu/0/msr', 'r', 0)
except:
- self.f = file('/dev/msr0')
+ self.f = open('/dev/msr0', 'r', 0)
def read(self, index, default = None):
import struct
self.f.seek(index)
@@ -96,6 +96,19 @@ class Misc(object):
print ' %-40s %s' % (self.bits[bits], fmt(v))
controls = [
+ Misc(
+ name = 'Basic VMX Information',
+ bits = {
+ (0, 31): 'Revision',
+ (32,44): 'VMCS size',
+ 48: 'VMCS restricted to 32 bit addresses',
+ 49: 'Dual-monitor support',
+ (50, 53): 'VMCS memory type',
+ 54: 'INS/OUTS instruction information',
+ 55: 'IA32_VMX_TRUE_*_CTLS support',
+ },
+ msr = MSR_IA32_VMX_BASIC,
+ ),
Control(
name = 'pin-based controls',
bits = {
@@ -103,6 +116,7 @@ controls = [
3: 'NMI exiting',
5: 'Virtual NMIs',
6: 'Activate VMX-preemption timer',
+ 7: 'Process posted interrupts',
},
cap_msr = MSR_IA32_VMX_PINBASED_CTLS,
true_cap_msr = MSR_IA32_VMX_TRUE_PINBASED_CTLS,
@@ -143,15 +157,19 @@ controls = [
0: 'Virtualize APIC accesses',
1: 'Enable EPT',
2: 'Descriptor-table exiting',
+ 3: 'Enable RDTSCP',
4: 'Virtualize x2APIC mode',
5: 'Enable VPID',
6: 'WBINVD exiting',
7: 'Unrestricted guest',
+ 8: 'APIC register emulation',
9: 'Virtual interrupt delivery',
10: 'PAUSE-loop exiting',
11: 'RDRAND exiting',
12: 'Enable INVPCID',
13: 'Enable VM functions',
+ 14: 'VMCS shadowing',
+ 18: 'EPT-violation #VE'
},
cap_msr = MSR_IA32_VMX_PROCBASED_CTLS2,
),
@@ -196,10 +214,12 @@ controls = [
6: 'HLT activity state',
7: 'Shutdown activity state',
8: 'Wait-for-SIPI activity state',
+ 15: 'IA32_SMBASE support',
(16,24): 'Number of CR3-target values',
(25,27): 'MSR-load/store count recommenation',
28: 'IA32_SMM_MONITOR_CTL[2] can be set to 1',
- (32,62): 'MSEG revision identifier',
+ 29: 'VMWRITE to VM-exit information fields',
+ (32,63): 'MSEG revision identifier',
},
msr = MSR_IA32_VMX_MISC_CTLS,
),
diff --git a/scripts/make_device_config.sh b/scripts/make_device_config.sh
index 0778fe2..7242707 100644
--- a/scripts/make_device_config.sh
+++ b/scripts/make_device_config.sh
@@ -3,7 +3,7 @@
# files from include directives.
dest=$1.tmp
-dep=$1.d
+dep=`dirname $1`-`basename $1`.d
src=$2
src_dir=`dirname $src`
all_includes=
@@ -18,11 +18,11 @@ process_includes () {
f=$src
while [ -n "$f" ] ; do
- f=`tr -d '\r' < $f | awk '/^include / {printf "'$src_dir'/%s", $2}'`
+ f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'`
[ $? = 0 ] || exit 1
all_includes="$all_includes $f"
done
process_includes $src > $dest
cat $src $all_includes | grep -v '^include' > $dest
-echo "`basename $1`: $all_includes" > $dep
+echo "$1: $all_includes" > $dep
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index c003cf6..a79ec0f 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -90,8 +90,8 @@ def main(args):
arg_format = arg
elif opt == "--list-backends":
- backends = tracetool.backend.get_list()
- out(", ".join([ b for b,_ in backends ]))
+ public_backends = tracetool.backend.get_list(only_public = True)
+ out(", ".join([ b for b,_ in public_backends ]))
sys.exit(0)
elif opt == "--check-backend":
check_backend = True
diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
index be43472..f0314ee 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -17,6 +17,16 @@ considered its short description.
All backends must generate their contents through the 'tracetool.out' routine.
+Backend attributes
+------------------
+
+========= ====================================================================
+Attribute Description
+========= ====================================================================
+PUBLIC If exists and is set to 'True', the backend is considered "public".
+========= ====================================================================
+
+
Backend functions
-----------------
@@ -42,7 +52,7 @@ import os
import tracetool
-def get_list():
+def get_list(only_public = False):
"""Get a list of (name, description) pairs."""
res = [("nop", "Tracing disabled.")]
modnames = []
@@ -57,6 +67,10 @@ def get_list():
continue
module = module[1]
+ public = getattr(module, "PUBLIC", False)
+ if only_public and not public:
+ continue
+
doc = module.__doc__
if doc is None:
doc = ""
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index ad5eb3b..e31bc79 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -16,6 +16,9 @@ __email__ = "stefanha@linux.vnet.ibm.com"
from tracetool import out
+PUBLIC = True
+
+
PROBEPREFIX = None
def _probeprefix():
diff --git a/scripts/tracetool/backend/events.py b/scripts/tracetool/backend/events.py
new file mode 100644
index 0000000..5afce3e
--- /dev/null
+++ b/scripts/tracetool/backend/events.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Generic event description.
+
+This is a dummy backend to establish appropriate frontend/backend compatibility
+checks.
+"""
+
+__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__license__ = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__ = "stefanha@linux.vnet.ibm.com"
+
+
+def events_h(events):
+ pass
+
+def events_c(events):
+ pass
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
new file mode 100644
index 0000000..888c361
--- /dev/null
+++ b/scripts/tracetool/backend/ftrace.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Ftrace built-in backend.
+"""
+
+__author__ = "Eiichi Tsukata <eiichi.tsukata.xh@hitachi.com>"
+__copyright__ = "Copyright (C) 2013 Hitachi, Ltd."
+__license__ = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__ = "stefanha@redhat.com"
+
+
+from tracetool import out
+
+
+PUBLIC = True
+
+
+def c(events):
+ pass
+
+def h(events):
+ out('#include "trace/ftrace.h"',
+ '#include "trace/control.h"',
+ '',
+ )
+
+ for e in events:
+ argnames = ", ".join(e.args.names())
+ if len(e.args) > 0:
+ argnames = ", " + argnames
+
+ out('static inline void trace_%(name)s(%(args)s)',
+ '{',
+ ' char ftrace_buf[MAX_TRACE_STRLEN];',
+ ' int unused __attribute__ ((unused));',
+ ' int trlen;',
+ ' bool _state = trace_event_get_state(%(event_id)s);',
+ ' if (_state) {',
+ ' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
+ ' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
+ ' trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
+ ' unused = write(trace_marker_fd, ftrace_buf, trlen);',
+ ' }',
+ '}',
+ name = e.name,
+ args = e.args,
+ event_id = "TRACE_" + e.name.upper(),
+ fmt = e.fmt.rstrip("\n"),
+ argnames = argnames,
+ )
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index e4b4a7f..37ef599 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -15,6 +15,10 @@ __email__ = "stefanha@linux.vnet.ibm.com"
from tracetool import out
+
+PUBLIC = True
+
+
def is_string(arg):
strtype = ('const char*', 'char*', 'const char *', 'char *')
if arg.lstrip().startswith(strtype):
@@ -24,17 +28,10 @@ def is_string(arg):
def c(events):
out('#include "trace.h"',
+ '#include "trace/control.h"',
'#include "trace/simple.h"',
'',
- 'TraceEvent trace_list[] = {')
-
- for e in events:
- out('{.tp_name = "%(name)s", .state=0},',
- name = e.name,
- )
-
- out('};',
- '')
+ )
for num, event in enumerate(events):
out('void trace_%(name)s(%(args)s)',
@@ -59,7 +56,9 @@ def c(events):
out('',
- ' if (!trace_list[%(event_id)s].state) {',
+ ' TraceEvent *eventp = trace_event_id(%(event_id)s);',
+ ' bool _state = trace_event_get_state_dynamic(eventp);',
+ ' if (!_state) {',
' return;',
' }',
'',
@@ -102,6 +101,3 @@ def h(events):
name = event.name,
args = event.args,
)
- out('')
- out('#define NR_TRACE_EVENTS %d' % len(events))
- out('extern TraceEvent trace_list[NR_TRACE_EVENTS];')
diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py
index 917fde7..6f93dbd 100644
--- a/scripts/tracetool/backend/stderr.py
+++ b/scripts/tracetool/backend/stderr.py
@@ -16,41 +16,33 @@ __email__ = "stefanha@linux.vnet.ibm.com"
from tracetool import out
-def c(events):
- out('#include "trace.h"',
- '',
- 'TraceEvent trace_list[] = {')
+PUBLIC = True
- for e in events:
- out('{.tp_name = "%(name)s", .state=0},',
- name = e.name,
- )
- out('};')
+def c(events):
+ pass
def h(events):
out('#include <stdio.h>',
- '#include "trace/stderr.h"',
+ '#include "trace/control.h"',
'',
- 'extern TraceEvent trace_list[];')
+ )
- for num, e in enumerate(events):
+ for e in events:
argnames = ", ".join(e.args.names())
if len(e.args) > 0:
argnames = ", " + argnames
out('static inline void trace_%(name)s(%(args)s)',
'{',
- ' if (trace_list[%(event_num)s].state != 0) {',
+ ' bool _state = trace_event_get_state(%(event_id)s);',
+ ' if (_state) {',
' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
' }',
'}',
name = e.name,
args = e.args,
- event_num = num,
- fmt = e.fmt,
+ event_id = "TRACE_" + e.name.upper(),
+ fmt = e.fmt.rstrip("\n"),
argnames = argnames,
)
-
- out('',
- '#define NR_TRACE_EVENTS %d' % len(events))
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index 31a2ff0..ea36995 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -16,6 +16,9 @@ __email__ = "stefanha@linux.vnet.ibm.com"
from tracetool import out
+PUBLIC = True
+
+
def c(events):
out('#include <ust/marker.h>',
'#undef mutex_lock',
diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py
new file mode 100644
index 0000000..d670ec8
--- /dev/null
+++ b/scripts/tracetool/format/events_c.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Generate .c for event description.
+"""
+
+__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__license__ = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__ = "stefanha@linux.vnet.ibm.com"
+
+
+from tracetool import out
+
+
+def begin(events):
+ out('/* This file is autogenerated by tracetool, do not edit. */',
+ '',
+ '#include "trace.h"',
+ '#include "trace/generated-events.h"',
+ '#include "trace/control.h"',
+ '',
+ )
+
+ out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
+
+ for e in events:
+ out(' { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s, .dstate = 0 },',
+ id = "TRACE_" + e.name.upper(),
+ name = e.name,
+ sstate = "TRACE_%s_ENABLED" % e.name.upper(),
+ )
+
+ out('};',
+ '',
+ )
diff --git a/scripts/tracetool/format/events_h.py b/scripts/tracetool/format/events_h.py
new file mode 100644
index 0000000..d30ccea
--- /dev/null
+++ b/scripts/tracetool/format/events_h.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Generate .h for event description.
+"""
+
+__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__license__ = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__ = "stefanha@linux.vnet.ibm.com"
+
+
+from tracetool import out
+
+
+def begin(events):
+ out('/* This file is autogenerated by tracetool, do not edit. */',
+ '',
+ '#ifndef TRACE__GENERATED_EVENTS_H',
+ '#define TRACE__GENERATED_EVENTS_H',
+ '',
+ '#include <stdbool.h>',
+ ''
+ )
+
+ # event identifiers
+ out('typedef enum {')
+
+ for e in events:
+ out(' TRACE_%s,' % e.name.upper())
+
+ out(' TRACE_EVENT_COUNT',
+ '} TraceEventID;',
+ )
+
+ # static state
+ for e in events:
+ if 'disable' in e.properties:
+ enabled = 0
+ else:
+ enabled = 1
+ out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
+
+ out('#include "trace/event-internal.h"',
+ '',
+ '#endif /* TRACE__GENERATED_EVENTS_H */',
+ )
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index 9a58de1..93132fc 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -25,14 +25,7 @@ def begin(events):
'#include "qemu-common.h"')
def end(events):
- for e in events:
- if "disable" in e.properties:
- enabled = 0
- else:
- enabled = 1
- out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
- out('',
- '#endif /* TRACE__GENERATED_TRACERS_H */')
+ out('#endif /* TRACE__GENERATED_TRACERS_H */')
def nop(events):
for e in events: