[kvm-devel] Britney spears likes it huge

2008-03-13 Thread Satya Packer
My manhood is huge, even my buddies are in awe. Everybody wants to know where 
they can purchase this – and I’m reluctant to tell


http://www.Prompteeni.com/
Britney spears likes it huge-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source binary into qemu

2008-03-13 Thread Jerone Young
On Wed, 2008-03-12 at 21:42 -0500, Hollis Blanchard wrote:
 On Tue, 2008-03-11 at 23:50 -0500, Jerone Young wrote:
  # HG changeset patch
  # User Jerone Young [EMAIL PROTECTED]
  # Date 1205296680 18000
  # Branch merge
  # Node ID 9c15709640cd55bf6f782d6856423363312493bb
  # Parent  48651677b7d05254d6acf03551bfea05cef8aa47
  Add PPC 440EP bamboo board device tree source  binary into qemu
  
  This patch places the bamboo device tree for the PPC 440EP bamboo
  board into the pc-bios directory of the qemu source. This also adds a
  rule into the pc-bios/Makefile to build device tree files.
  
  Signed-off-by: Jerone Young [EMAIL PROTECTED]
  
  diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile
  --- a/qemu/pc-bios/Makefile
  +++ b/qemu/pc-bios/Makefile
  @@ -12,6 +12,9 @@ all: $(TARGETS)
   %.o: %.S
  $(CC) $(DEFINES) -c -o $@ $
  
  +%.dtb: %.dts 
  +   dtc -O dtb -I dts -o $@ $ 
  +
   clean:
  -   rm -f $(TARGETS) *.o *~
  +   rm -f $(TARGETS) *.o *~ *.dtb
  
  diff --git a/qemu/pc-bios/bamboo.dts b/qemu/pc-bios/bamboo.dts
  new file mode 100644
  --- /dev/null
  +++ b/qemu/pc-bios/bamboo.dts
  @@ -0,0 +1,310 @@
  +/*
  + * Device Tree Source for AMCC Bamboo
  + *
  + * Copyright (c) 2006, 2007 IBM Corp.
  + * Josh Boyer [EMAIL PROTECTED]
  + *
  + * FIXME: Draft only!
 
 Might as well remove this. In its place, add a little blurb explaining
 how this file is used, and how qemu modifies the binary device tree at
 runtime.
 
  + * This file is licensed under the terms of the GNU General Public
  + * License version 2.  This program is licensed as is without
  + * any warranty of any kind, whether express or implied.
  + */
  +
  +/ {
  +   #address-cells = 2;
  +   #size-cells = 1;
  +   model = amcc,bamboo;
  +   compatible = amcc,bamboo;
  +   dcr-parent = /cpus/[EMAIL PROTECTED];
  +
  +   aliases {
  +/* ethernet0 = EMAC0;  */
  +/* ethernet1 = EMAC1;  *
  +   serial0 = UART0;
  +   serial1 = UART1;   
  +/* serial2 = UART2;*/
  +/* serial3 = UART3;*/
  +   };
 
 Please just remove all the stuff you've commented out.


Ok mainly just commented out stuff so that if we later wanted to have it
(for what ever reason), it could just be uncommented.

 
  +   cpus {
  +   #address-cells = 1;
  +   #size-cells = 0;
  +
  +   [EMAIL PROTECTED] {
  +   device_type = cpu;
  +   model = PowerPC,440EP;
  +   reg = 0;
  +   clock-frequency = 1fca0550; /* Filled in by zImage */
  +   timebase-frequency = 017d7840; /* Filled in by zImage 
  */
  +   i-cache-line-size = 20;
  +   d-cache-line-size = 20;
  +   i-cache-size = 8000;
  +   d-cache-size = 8000;
  +   dcr-controller;
  +   dcr-access-method = native;
  +   };
  +   };
  +   memory {
  +   device_type = memory;
  +   reg = 0 0 900; /* Filled in by zImage */
  +   };
 
 Also remove all references to zImage.

I can. Though this helped me to determine which variables that need to
be filled in. I'll still have it in some places till I have the code to
fill them in.

 
  +   UIC0: interrupt-controller0 {
  +   compatible = ibm,uic-440ep,ibm,uic;
  +   interrupt-controller;
  +   cell-index = 0;
  +   dcr-reg = 0c0 009;
  +   #address-cells = 0;
  +   #size-cells = 0;
  +   #interrupt-cells = 2;
  +   };
  +/*
  +   UIC1: interrupt-controller1 {
  +   compatible = ibm,uic-440ep,ibm,uic;
  +   interrupt-controller;
  +   cell-index = 1;
  +   dcr-reg = 0d0 009;
  +   #address-cells = 0;
  +   #size-cells = 0;
  +   #interrupt-cells = 2;
  +   interrupts = 1e 4 1f 4; 
  +   interrupt-parent = UIC0;
  +   };
  +*/
 
 Is it difficult to add UIC1 to our 440EP init code?

I'll leave this commented. But will have to try adding once bigger
issues are taken care of.

 
  +
  +   PCI0: [EMAIL PROTECTED] {
  +   device_type = pci;
  +   #interrupt-cells = 1;
  +   #size-cells = 2;
  +   #address-cells = 3;
  +   compatible = ibm,plb440ep-pci, ibm,plb-pci;
  +   primary;
  +   reg = 0 eec0 8 /* Config space access */
  +  0 eed0 4 /* IACK */
  +  0 eed0 4 /* Special cycle */
  +  0 ef40 40;  /* Internal registers */
  +
  +   /* Outbound ranges, one memory and one IO,
  +* later cannot be changed. Chip supports a second
  +* IO range but we don't use it for now
  +*/
  +   ranges = 0200 0 a000 0 a000 0 2000
  +  

Re: [kvm-devel] [PATCH] shrinker support for the mmu cache

2008-03-13 Thread Marcelo Tosatti
On Thu, Mar 13, 2008 at 01:23:23AM +0200, Izik Eidus wrote:
 Marcelo Tosatti wrote:
 On Wed, Mar 12, 2008 at 08:13:41PM +0200, Izik Eidus wrote:
   
 this patch simply register the mmu cache with the shrinker.
 
 
 Hi Izik,
   
 Hello Marcelo,
 
 Nice.
 
 I think you want some sort of aging mechanism here. 
 
 well it is long time in the todo list to do some kind of lru for the 
 shadow mmu pages
 right now it recycle pages in a random way...
 
 Walk through all
 translations of a shadow page clearing the referenced bit of all
 mappings it holds (and moving pages with any accessed translation to the
 head of the list).
   
 ok, i think i will just add a function named sort_accessed_mmu_pages,
 that will just put to the top of the list the pages pointed by the ptes 
 that werent accessed
 and used it when i shrink, and when pages get recycled
 
 this what you meant right?

By top I suppose you mean end. So yes, right.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation change uboot loader for PPC bamboo board model

2008-03-13 Thread Jerone Young
On Wed, 2008-03-12 at 21:53 -0500, Hollis Blanchard wrote:
 You've misspelled licence several times in this patch.

Got them. More of one error propagating through cut  paste.
 
 On Tue, 2008-03-11 at 23:50 -0500, Jerone Young wrote:
  # HG changeset patch
  # User Jerone Young [EMAIL PROTECTED]
  # Date 1205296680 18000
  # Branch merge
  # Node ID 50fddb23a4c19ec6f359a4dd39e98712eb6bcaeb
  # Parent  9c15709640cd55bf6f782d6856423363312493bb
  Add dynamic device tree manipulation  change uboot loader for PPC
  bamboo board model
  
  This patch adds code to dynamically manipulate the device tree when
  loaded into memory. This allows us to finally have the ability to
  manipulate the kernel command line  initrd from the qemu command
  line. This will also let us setup different settings for the board.
  
  This patch also now uses new uboot loader uboot_loader_l() to load
  kernel image.
 
 So the load_uboot() part should be a separate patch, right?
 
  Signed-off-by: Jerone Young [EMAIL PROTECTED]
  
  diff --git a/qemu/Makefile.target b/qemu/Makefile.target
  --- a/qemu/Makefile.target
  +++ b/qemu/Makefile.target
  @@ -615,7 +615,7 @@ OBJS+= unin_pci.o ppc_chrp.o
   OBJS+= unin_pci.o ppc_chrp.o
   # PowerPC 4xx boards
   OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
  -OBJS+= ppc440.o ppc440_bamboo.o
  +OBJS+= ppc440.o ppc440_bamboo.o ppc_device_tree_support.o
   endif
   ifeq ($(TARGET_BASE_ARCH), mips)
   OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
  diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
  --- a/qemu/hw/ppc440_bamboo.c
  +++ b/qemu/hw/ppc440_bamboo.c
  @@ -8,11 +8,12 @@
*
*/
  
  +#include config.h
   #include ppc440.h
  +#include qemu-kvm.h
  +#include ppc_device_tree_support.h
  
  -#define KERNEL_LOAD_ADDR 0x40 /* uboot loader puts kernel at 4MB */
  -
  -#include qemu-kvm.h
  +#define BINARY_DEVICE_TREE_FILE bamboo.dtb
  
   /* PPC 440 refrence demo board
*
  @@ -26,14 +27,22 @@ void bamboo_init(ram_addr_t ram_size, in
  const char *initrd_filename,
  const char *cpu_model)
   {
  +   char buf[1024]; 
  target_phys_addr_t ram_bases[2], ram_sizes[2];
  qemu_irq *pic;
  CPUState *env;
  -   target_ulong ep;
  +   target_ulong ep=0;
  +   target_ulong la=0;
  int is_linux=1; /* Will assume allways is Linux for now */
  -   long kernel_size=0;
  +   target_long kernel_size=0;
  target_ulong initrd_base=0;
  -   target_ulong initrd_size=0;
  +   target_long initrd_size=0;
  +   target_ulong dt_base=0;
  +   void *fdt;
  +   int ret;
  +
  +   uint32_t cpu_freq;
  +   uint32_t timebase_freq;
  
  printf(%s: START\n, __func__);
  
  @@ -78,18 +87,23 @@ void bamboo_init(ram_addr_t ram_size, in
  
  /* load kernel with uboot loader */
  printf(%s: load kernel\n, __func__);
  -   kernel_size = load_uboot(kernel_filename, ep, is_linux);
  +   load_uboot_l(kernel_filename, ep, la, kernel_size, is_linux);
  if (kernel_size  0) {
  fprintf(stderr, qemu: could not load kernel '%s'\n,
  kernel_filename);
  exit(1);
  }
  +   printf(kernel is at guest address: 0x%lx\n, (unsigned long)la);
  
  /* load initrd */
  if (initrd_filename) {
  -   initrd_base = kernel_size + KERNEL_LOAD_ADDR;
  +   initrd_base = kernel_size + la;
  +   printf(%s: load initrd\n, __func__);
  initrd_size = load_image(initrd_filename,
  phys_ram_base + initrd_base);
  +
  +   printf(initrd is at guest address: 0x%lx\n, 
  +   (unsigned long) initrd_base);
  
  if (initrd_size  0) {
  fprintf(stderr,
  @@ -99,17 +113,58 @@ void bamboo_init(ram_addr_t ram_size, in
  }
  }
  
  +#ifdef CONFIG_LIBFDT
  +   /* get variable for device tree */
  +   cpu_freq = get_proc_dt_prop_cpu_clock_freq();
  +   timebase_freq = get_proc_dt_prop_cpu_timebase_freq();
  +
  +   /* load binary device tree into qemu (not guest memory) */
  +   printf(%s: load device tree file\n, __func__);
  +   
  +   snprintf(buf, sizeof(buf), %s/%s, bios_dir, 
  +   BINARY_DEVICE_TREE_FILE);
  +
  +   /* set base for device tree that will be in guest memory */ 
  +   if (initrd_base)
  +   dt_base = initrd_base + initrd_size;
  +   else
  +   dt_base = kernel_size + la;
  +
  +   fdt = load_device_tree(buf, (phys_ram_base + dt_base));
  +   if (fdt == NULL) {
  +   printf(Loading device tree failed!\n);
  +   exit(1);
  +   }
  +
  +   printf(device tree address is at guest address: 0x%lx\n, 
  +   (unsigned long) dt_base);
  +
  +   /* manipulate device tree in memory */
  +   set_dt_cpu_0_clock_freq_prop(fdt, cpu_freq);
  +   set_dt_cpu_0_timebase_prop(fdt, timebase_freq);
  +
  +   set_dt_initrd_start_prop(fdt, initrd_base);
  +   set_dt_initrd_end_prop(fdt, 

[kvm-devel] [PATCH RFC 0/4]Porting Xentrace to kvm

2008-03-13 Thread Liu, Eric E
Hi,
The following patches port xentrace to kvm which is useful for
performance tuning and debugging.

It is designed to allow debugging traces of kvm to be generated on
Up/Smp machines. Each trace entry is outputted in a trace ring buffer
for per cpu which is mapped to userspace, and the userspace tools can
analyze the data according to some formats definitions.

Since we already have had debugfs_entries and some other kernel debug
mechanism to use, does this kvmtrace make sense? Any comment is
welcomed. 

--Eric (Liu, Feng)

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH RFC 4/4]Porting Xentrace to kvm

2008-03-13 Thread Liu, Eric E
From 2e16085ad8b4ecfe7e053a627a86dc24bbe04315 Mon Sep 17 00:00:00 2001
From: Feng(Eric) Liu [EMAIL PROTECTED]
Date: Fri, 14 Mar 2008 18:19:46 -0400
Subject: [PATCH] kvm: kvmtrace_format prarses the trace data outputted
by kvmtrace in binary format, and reformats it according
to the rules in the file format of definitions.

Signed-off-by: Feng(Eric) Liu [EMAIL PROTECTED]
---
 user/formats |   28 +++
 user/kvmtrace_format |  212
++
 2 files changed, 240 insertions(+), 0 deletions(-)
 create mode 100644 user/formats
 create mode 100755 user/kvmtrace_format

diff --git a/user/formats b/user/formats
new file mode 100644
index 000..e3b8812
--- /dev/null
+++ b/user/formats
@@ -0,0 +1,28 @@
+0x  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  unknown
(0x%(event)016x)  [ 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x ]
+
+0x0001f001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  lost_records
0x%(1)08x
+0x0001f002  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  wrap_buffer
0x%(1)08x
+0x0001f003  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  cpu_change
0x%(1)08x
+
+0x00021001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMENTRY [ vcpu:pid
= 0x%(1)08x ]
+0x00021002  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMEXIT  [ vcpu:pid
= 0x%(1)08x, exitcode = 0x%(2)08x, rip  = 0x%(3)08x ]
+0x00022001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  PAGE_FAULT  [ vcpu:pid
= 0x%(1)08x, errorcode = 0x%(2)08x, virt = 0x%(3)08x ]
+0x00022002  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  INJ_VIRQ[ vcpu:pid
= 0x%(1)08x, vector = 0x%(2)02x ]
+0x00022003  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  REINJ_VIRQ  [ vcpu:pid
= 0x%(1)08x, vector = 0x%(2)02x ]
+0x00022004  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  IO_READ [ vcpu:pid
= 0x%(1)08x, port = 0x%(2)04x, size = %(3)d ]
+0x00022005  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  IO_WRITE[ vcpu:pid
= 0x%(1)08x, port = 0x%(2)04x, size = %(3)d ]
+0x00022006  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  CR_READ [ vcpu:pid
= 0x%(1)08x, CR# = %(2)d, value = 0x%(3)08x ]
+0x00022007  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  CR_WRITE[ vcpu:pid
= 0x%(1)08x, CR# = %(2)d, value = 0x%(3)08x ]
+0x00022008  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  DR_READ [ vcpu:pid
= 0x%(1)08x ]
+0x00022009  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  DR_WRITE[ vcpu:pid
= 0x%(1)08x ]
+0x0002200A  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  MSR_READ[ vcpu:pid
= 0x%(1)08x, MSR# = 0x%(2)08x, value = 0x%(3)08x ]
+0x0002200B  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  MSR_WRITE   [ vcpu:pid
= 0x%(1)08x, MSR# = 0x%(2)08x, value = 0x%(3)08x ]
+0x0002200C  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  CPUID   [ vcpu:pid
= 0x%(1)08x, func = 0x%(2)08x, eax:ebx = 0x%(3)016x, ecx:edx =
0x%(4)016x ]
+0x0002200D  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  INTR[ vcpu:pid
= 0x%(1)08x, vector = 0x%(2)02x ]
+0x0002200E  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  NMI [ vcpu:pid
= 0x%(1)08x ]
+0x0002200F  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  SMI [ vcpu:pid
= 0x%(1)08x ]
+0x00022010  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMMCALL [ vcpu:pid
= 0x%(1)08x, func = 0x%(2)08x ]
+0x00022011  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  HLT [ vcpu:pid
= 0x%(1)08x ]
+0x00022012  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  INVLPG  [ vcpu:pid
= 0x%(1)08x, virt = 0x%(2)08x, invlpga = %(3)d, asid = 0x%(4)02x ]
+0x00022013  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  CLTS[ vcpu:pid
= 0x%(1)08x ]
+0x00022014  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  LMSW[ vcpu:pid
= 0x%(1)08x, value = 0x%(2)08x ]
diff --git a/user/kvmtrace_format b/user/kvmtrace_format
new file mode 100755
index 000..caa5b4e
--- /dev/null
+++ b/user/kvmtrace_format
@@ -0,0 +1,212 @@
+#!/usr/bin/env python
+
+# by Mark Williamson, (C) 2004 Intel Research Cambridge
+
+# Program for reformatting trace buffer output according to
user-supplied rules
+
+import re, sys, string, signal, struct, os, getopt
+
+def usage():
+print  sys.stderr, \
+  Usage:  + sys.argv[0] +  defs-file
+  Parses trace data in binary format, as output by kvmtrace and
+  reformats it according to the rules in a file of definitions.
The
+  rules in this file should have the format ({ and } show
grouping
+  and are not part of the syntax):
+
+  {event_id}{whitespace}{text format string}
+
+  The textual format string may include format specifiers, such
as:
+%(cpu)d, %(tsc)d, %(event)d, %(1)d, %(2)d, %(3)d, %(4)d,
%(5)d
+  [ the 'd' format specifier outputs in decimal, alternatively
'x'
+will output in hexadecimal and 'o' will output in octal ]
+
+  Which correspond to the CPU number, event ID, timestamp
counter and
+  the 5 data fields from the trace record.  There should be one
such
+  rule for each type of event.
+  
+  Depending on your system and the volume of trace buffer data,
+  this script may not be able to keep up with the output of
kvmtrace
+  if it is piped directly.  In these 

[kvm-devel] [PATCH RFC 3/4]Porting Xentrace to kvm

2008-03-13 Thread Liu, Eric E
From df6e45936dd43be14441f5e9ec19a130325d4341 Mon Sep 17 00:00:00 2001
From: Feng (Eric) Liu [EMAIL PROTECTED]
Date: Sat, 15 Mar 2008 04:53:53 -0400
Subject: [PATCH] kvm: Add a tool kvmtrace for collecting binary data
from
trace buffer. It can get the buffer virtual address and
the size in page for per cpu by the argument of ioctl
KVM_ENABLE_TRACE. It also can set the trace buffer size
for per cpu, but only can set one time in a module cycle.

Signed-off-by: Feng (Eric) Liu [EMAIL PROTECTED]
---
 kernel/Kbuild  |2 +-
 user/Makefile  |5 +-
 user/config-x86-common.mak |4 +-
 user/kvmtrace.c|  397

 4 files changed, 404 insertions(+), 4 deletions(-)
 create mode 100644 user/kvmtrace.c

diff --git a/kernel/Kbuild b/kernel/Kbuild
index 014cc17..5fc3101 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,6 +1,6 @@
 EXTRA_CFLAGS := -I$(src)/include -include
$(src)/external-module-compat.h
 obj-m := kvm.o kvm-intel.o kvm-amd.o
-kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o anon_inodes.o irq.o
i8259.o \
+kvm-objs := kvm_main.o kvm_trace.o x86.o mmu.o x86_emulate.o
anon_inodes.o irq.o i8259.o \
 lapic.o ioapic.o preempt.o i8254.o
 kvm-intel-objs := vmx.o vmx-debug.o
 kvm-amd-objs := svm.o
diff --git a/user/Makefile b/user/Makefile
index 225a435..ff2192d 100644
--- a/user/Makefile
+++ b/user/Makefile
@@ -31,6 +31,9 @@ CXXFLAGS = $(autodepend-flags)
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
+kvmtrace: $(kvmtrace_objs)
+   $(CC) $(CFLAGS) $^ -o $@
+
 kvmctl: LDFLAGS += -pthread -lrt
 
 kvmctl: $(kvmctl_objs)
@@ -42,4 +45,4 @@ kvmctl: $(kvmctl_objs)
 -include .*.d
 
 clean: arch_clean
-   $(RM) kvmctl *.o *.a .*.d
+   $(RM) kvmctl kvmtrace *.o *.a .*.d
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
index 8cfdd45..4c90fe6 100644
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -1,9 +1,9 @@
 #This is a make file with common rules for both x86  x86-64
 
-all: kvmctl test_cases
+all: kvmctl kvmtrace test_cases
 
 kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
-
+kvmtrace_objs= kvmtrace.o
 balloon_ctl: balloon_ctl.o
 
 FLATLIBS = $(TEST_DIR)/libcflat.a $(libgcc)
diff --git a/user/kvmtrace.c b/user/kvmtrace.c
new file mode 100644
index 000..1a05205
--- /dev/null
+++ b/user/kvmtrace.c
@@ -0,0 +1,397 @@
+/*
+ * Tool for collecting trace buffer data from kvm-trace.
+ *
+ * Copyright (C) 2004 by Intel Research Cambridge
+ *
+ * Author: Mark Williamson, [EMAIL PROTECTED]
+ * Author: Eric Liu, [EMAIL PROTECTED]
+ * Date:   February 2008
+ */
+
+#include time.h
+#include stdlib.h
+#include stdio.h
+#include sys/mman.h
+#include sys/stat.h
+#include sys/types.h
+#include fcntl.h
+#include unistd.h
+#include errno.h
+#include signal.h
+#include inttypes.h
+#include string.h
+#include getopt.h
+#include assert.h
+#include sys/ioctl.h
+
+#ifndef __user
+#define __user /* temporary, until installed via make headers_install
*/
+#endif
+#include linux/kvm.h
+
+#if defined(__i386__)
+#define mb()  __asm__ __volatile__ ( lock; addl $0,0(%%esp) : : :
memory )
+#define rmb() __asm__ __volatile__ ( lock; addl $0,0(%%esp) : : :
memory )
+#define wmb() __asm__ __volatile__ (  : : : memory)
+#elif defined(__x86_64__)
+#define mb()  __asm__ __volatile__ ( mfence : : : memory)
+#define rmb() __asm__ __volatile__ ( lfence : : : memory)
+#define wmb() __asm__ __volatile__ (  : : : memory)
+#elif defined(__ia64__)
+#define mb()   __asm__ __volatile__ (mf ::: memory)
+#define rmb()  __asm__ __volatile__ (mf ::: memory)
+#define wmb()  __asm__ __volatile__ (mf ::: memory)
+#endif
+
+#define PERROR(_m, _a...)   \
+do {\
+int __saved_errno = errno;  \
+fprintf(stderr, ERROR:  _m  (%d = %s)\n , ## _a ,   \
+__saved_errno, strerror(__saved_errno));\
+errno = __saved_errno;  \
+} while (0)
+
+#define POLL_SLEEP_MILLIS 100
+#define DEFAULT_TBUF_SIZE 20
+
+#define BITS_PER_LONG 32
+#define KVM_TRC_EXTRA_SHIFT 28
+#define KVM_TRC_CPU_CHG (KVM_TRC_GEN + 3)
+
+typedef struct settings_st {
+char *outfile;
+struct timespec poll_sleep;
+uint32_t cpu_mask;
+unsigned long tbuf_pages;
+uint8_t discard:1;
+} settings_t;
+
+static settings_t opts;
+static int interrupted = 0;
+
+static void close_handler(int signal)
+{
+interrupted = 1;
+}
+
+static void sigalrm_handler(int signal)
+{
+}
+
+static int cpu_in_mask(unsigned cpu, uint32_t cpu_mask)
+{
+   return ((1U  (cpu % BITS_PER_LONG))  cpu_mask) != 0;
+}
+
+static struct timespec millis_to_timespec(unsigned long millis)
+{
+struct timespec spec;
+
+spec.tv_sec = millis / 1000;
+spec.tv_nsec = (millis % 1000) * 1000;
+
+return spec;
+}
+
+static void write_buffer(unsigned int cpu, unsigned char 

[kvm-devel] [PATCH RFC 1/4]Porting Xentrace to kvm

2008-03-13 Thread Liu, Eric E

From 0d7f1ee470fe907e00ac6246bfa11e5322bc64fb Mon Sep 17 00:00:00 2001
From: Feng (Eric) Liu [EMAIL PROTECTED]
Date: Sat, 15 Mar 2008 06:07:33 -0400
Subject: [PATCH] KVM: Add some trace entries in current code, when the
KVM_TRACE
compilation option is enabled, it outputs the data info thrace
buffer. Define some interfaces for userspace tools to use the
buffer and analyze the trace data.

Signed-off-by: Feng (Eric) Liu [EMAIL PROTECTED]
---
 arch/x86/kvm/Kconfig   |7 ++
 arch/x86/kvm/Makefile  |2 +-
 arch/x86/kvm/vmx.c |   21 +-
 arch/x86/kvm/x86.c |   21 +++
 include/asm-x86/kvm.h  |   20 ++
 include/asm-x86/kvm_host.h |   47

 include/linux/kvm.h|   46
+++
 include/linux/kvm_host.h   |6 +
 virt/kvm/kvm_main.c|   22 
 9 files changed, 189 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 41962e7..9fa53be 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -36,6 +36,13 @@ config KVM
 
  If unsure, say N.
 
+config KVM_TRACE
+   bool KVM trace support
+   depends on KVM
+   default n 
+   ---help---
+ Say yes here to enable KVM trace support
+
 config KVM_INTEL
tristate KVM for Intel processors support
depends on KVM
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 4d0c22e..db5dfa9 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module
 #
 
-common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o)
+common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o kvm_trace.o
ioapic.o)
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm
 
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9951ec9..55f22ad 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1793,6 +1793,8 @@ out:
 static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
+   KVMTRACE_1D(INJ_VIRQ, vcpu, 0,
+   irq | INTR_TYPE_SOFT_INTR | INTR_INFO_VALID_MASK);
 
if (vcpu-arch.rmode.active) {
vmx-rmode.irq.pending = true;
@@ -1944,6 +1946,7 @@ static int handle_exception(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
if (is_page_fault(intr_info)) {
cr2 = vmcs_readl(EXIT_QUALIFICATION);
+   KVMTRACE_2D(PAGE_FAULT, vcpu, 0, error_code, cr2);
return kvm_mmu_page_fault(vcpu, cr2, error_code);
}
 
@@ -1972,6 +1975,7 @@ static int handle_external_interrupt(struct
kvm_vcpu *vcpu,
 struct kvm_run *kvm_run)
 {
++vcpu-stat.irq_exits;
+   KVMTRACE_1D(INTR, vcpu, 0, vmcs_read32(VM_EXIT_INTR_INFO));
return 1;
 }
 
@@ -2029,6 +2033,7 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run)
reg = (exit_qualification  8)  15;
switch ((exit_qualification  4)  3) {
case 0: /* mov to cr */
+   KVMTRACE_2D(CR_WRITE, vcpu, 0, cr,
vcpu-arch.regs[reg]);
switch (cr) {
case 0:
vcpu_load_rsp_rip(vcpu);
@@ -2061,6 +2066,7 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run)
vcpu-arch.cr0 = ~X86_CR0_TS;
vmcs_writel(CR0_READ_SHADOW, vcpu-arch.cr0);
vmx_fpu_activate(vcpu);
+   KVMTRACE_0D(CLTS, vcpu, 0);
skip_emulated_instruction(vcpu);
return 1;
case 1: /*mov from cr*/
@@ -2069,12 +2075,14 @@ static int handle_cr(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
vcpu_load_rsp_rip(vcpu);
vcpu-arch.regs[reg] = vcpu-arch.cr3;
vcpu_put_rsp_rip(vcpu);
+   KVMTRACE_2D(CR_READ, vcpu, 0, cr,
vcpu-arch.regs[reg]);
skip_emulated_instruction(vcpu);
return 1;
case 8:
vcpu_load_rsp_rip(vcpu);
vcpu-arch.regs[reg] = kvm_get_cr8(vcpu);
vcpu_put_rsp_rip(vcpu);
+   KVMTRACE_2D(CR_READ, vcpu, 0, cr,
vcpu-arch.regs[reg]);
skip_emulated_instruction(vcpu);
return 1;
}
@@ -2120,6 +2128,7 @@ static int handle_dr(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run)
val = 0;
}
vcpu-arch.regs[reg] = val;
+   KVMTRACE_2D(DR_READ, vcpu, 0, dr, val);
} else {
/* mov to dr */
}
@@ -2144,6 +2153,8 @@ static int handle_rdmsr(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
return 1;
  

[kvm-devel] [PATCH RFC 2/4]Porting Xentrace to kvm

2008-03-13 Thread Liu, Eric E

From 1fd1215cc56a52109d6df1a2302b391511d3d91b Mon Sep 17 00:00:00 2001
From: Feng(Eric) Liu [EMAIL PROTECTED]
Date: Sat, 15 Mar 2008 08:09:24 -0400
Subject: [PATCH] KVM: Porting xentrace to kvm. The trace data is
outputted
into the trace buffer managed as ring buffer for per cpu,
and the userspace tool can get the mapped virtual address
of the buffer to access it.

Signed-off-by: Feng(Eric) Liu [EMAIL PROTECTED]
---
 virt/kvm/kvm_trace.c |  353
++
 1 files changed, 353 insertions(+), 0 deletions(-)
 create mode 100644 virt/kvm/kvm_trace.c

diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
new file mode 100644
index 000..ebb132c
--- /dev/null
+++ b/virt/kvm/kvm_trace.c
@@ -0,0 +1,353 @@
+/*
+ * kvm Trace Buffer
+ *
+ * it is designed to allow debugging traces of kvm to be generated
+ * on UP / SMP machines.  Each trace entry is timestamped so that it's
+ * possible to reconstruct a chronological record of trace events.
+ * The code is based on Xen.
+ *
+ * Copyright (C) 2004 by Intel Research Cambridge
+ *
+ * Authors: Mark Williamson, [EMAIL PROTECTED]
+ *  Rob Gardner, [EMAIL PROTECTED]
+ *  Eric Liu, [EMAIL PROTECTED]
+ *
+ * Date:Feb 2008
+ *
+ */
+
+#include linux/mman.h
+#include linux/pagemap.h
+#include linux/module.h
+#include asm/percpu.h
+#include asm/system.h
+#include asm/io.h
+
+#include linux/kvm_host.h
+
+#define KVM_LOST_REC_SIZE8
+#define KVM_TRC_EVENT_SIZE   4
+#define KVM_TRC_TSC_SIZE 8
+
+int kvm_trace_enable_flag __read_mostly;
+EXPORT_SYMBOL_GPL(kvm_trace_enable_flag);
+
+static struct task_struct *kvm_trace_cons_task;
+static struct kvm_trace_info kvm_cur_tinfo;
+static unsigned long kvm_tbuf_size;
+static unsigned long kvm_pcpu_tdata_size;
+static unsigned long kvm_trace_rawbuf;
+
+static DEFINE_PER_CPU(struct kvm_trace_buf *, t_bufs);
+static DEFINE_PER_CPU(unsigned long, lost_records);
+
+/* High water mark for trace buffers; */
+static int t_buf_highwater;
+
+int kvm_enable_trace_buf(struct kvm_trace_info *t_info)
+{
+   int   i;
+   unsigned long addr;
+   unsigned long size;
+   structkvm_trace_buf *buf;
+   unsigned long pcpu_size;
+
+   t_info-ncpus = num_online_cpus();
+
+   /*
+* Trace buffer cannot be resized, if it has
+* already been set in this module cycle.
+*/
+   if (kvm_cur_tinfo.pcpu_pages) {
+   if (t_info-ncpus  kvm_cur_tinfo.ncpus)
+   t_info-ncpus = kvm_cur_tinfo.ncpus;
+   t_info-pcpu_pages = kvm_cur_tinfo.pcpu_pages;
+   return 0;
+   }
+
+   pcpu_size = t_info-pcpu_pages * PAGE_SIZE;
+   if (pcpu_size == 0)
+   return -EINVAL;
+
+   size = kvm_tbuf_size = t_info-ncpus * pcpu_size;
+   kvm_trace_rawbuf = __get_free_pages(GFP_KERNEL | __GFP_ZERO,
+   get_order(size));
+
+   if (!kvm_trace_rawbuf)
+   return -ENOMEM;
+
+   addr = kvm_trace_rawbuf;
+   while ((long)size  0) {
+   SetPageReserved(virt_to_page((void *)addr));
+   addr += PAGE_SIZE;
+   size -= PAGE_SIZE;
+   }
+
+   for_each_online_cpu(i) {
+   buf = per_cpu(t_bufs, i) =
+   (struct kvm_trace_buf *)(kvm_trace_rawbuf + i *
pcpu_size);
+   buf-cons = buf-prod = 0;
+   }
+
+   kvm_cur_tinfo.pcpu_pages = t_info-pcpu_pages;
+   kvm_cur_tinfo.ncpus = t_info-ncpus;
+   kvm_pcpu_tdata_size = pcpu_size - sizeof(struct kvm_trace_buf);
+   t_buf_highwater = kvm_pcpu_tdata_size  1; /* 50% high water */
+
+   return 0;
+}
+
+unsigned long kvm_mmap_trace_buf(void)
+{
+   unsigned long vaddr;
+
+   down_write(current-mm-mmap_sem);
+   vaddr = do_mmap(NULL, 0, kvm_tbuf_size, PROT_READ | PROT_WRITE,
+   MAP_SHARED | MAP_ANONYMOUS, 0);
+   if (vaddr) {
+   unsigned long page;
+   struct vm_area_struct *vma = find_vma(current-mm,
vaddr);
+
+   if (!vma) {
+   up_write(current-mm-mmap_sem);
+   return 0;
+   }
+
+   page = virt_to_phys((void *)kvm_trace_rawbuf);
+   if (remap_pfn_range(vma, vaddr, page  PAGE_SHIFT,
+   kvm_tbuf_size, PAGE_SHARED))
+   vaddr = 0;
+   }
+   up_write(current-mm-mmap_sem);
+
+   return vaddr;
+}
+
+static void free_kvmtrace_buf(void)
+{
+   unsigned long addr = kvm_trace_rawbuf;
+   unsigned long size = kvm_tbuf_size;
+
+   if (!addr)
+   return;
+
+   while ((long)size  0) {
+   ClearPageReserved(virt_to_page((void *)addr));
+   free_page(addr);
+   addr += PAGE_SIZE;
+   size -= PAGE_SIZE;
+   }
+}
+
+int kvm_unmmap_trace_buf(void)
+{
+   int ret;
+
+