Re: [PATCH] kvmppc_init_timing_stats: fix sleep with interrupts disabled

2010-10-04 Thread Christian Ehrhardt


On 10/01/2010 12:07 AM, Alexander Graf wrote:


On 30.09.2010, at 21:28, Scott Wood wrote:


It is not legal to call mutex_lock() with interrupts disabled.
This will assert with debug checks enabled.

If there's a real need to disable interrupts here, it could be done
after the mutex is acquired -- but I don't see why it's needed at all.


Christian, IIRC this code is yours. Any comments?


Yes, It should be save to drop the irq_disable.
IIRC it was without the lock in early stages of development (pre 
upstream git, so you can't see it) which had some obvious races.
But the lock makes it mutually exclusive per vcpu and should ensure it 
isn't running - by that it should be fine.


Reviewed-by: Christian Ehrhardt 


Alex



Signed-off-by: Scott Wood
---
arch/powerpc/kvm/timing.c |2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c
index 46fa04f..a021f58 100644
--- a/arch/powerpc/kvm/timing.c
+++ b/arch/powerpc/kvm/timing.c
@@ -35,7 +35,6 @@ void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu)
int i;

/* pause guest execution to avoid concurrent updates */
-   local_irq_disable();
mutex_lock(&vcpu->mutex);

vcpu->arch.last_exit_type = 0xDEAD;
@@ -51,7 +50,6 @@ void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu)
vcpu->arch.timing_last_enter.tv64 = 0;

mutex_unlock(&vcpu->mutex);
-   local_irq_enable();
}

static void add_exit_timing(struct kvm_vcpu *vcpu, u64 duration, int type)
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




--

Grüsse / regards, Christian Ehrhardt
IBM Linux Technology Center, System z Linux Performance
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [PATCH] qemu: report issues causing the kvm probe to fail v2

2008-12-15 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt 
# Date 1229347014 -3600
# Node ID c754b8806d756a19c57fc3b3e317bbe3c147d5ec
# Parent  f7dc67cd9b74c5d7ad322686e58325f879d93468
[PATCH] qemu: report issues causing the kvm probe to fail v2

From: Christian Ehrhardt 

*update to v2*
It now reports all "error:" statements from gcc behind the KVM no status.
As the status line now is a big larger I also found that "kvm support" is
reported twice, so I removed one duplicate. Finally there was also one check
in configure_kvm that did not use "" guards when runnign test on $kvm which
could fail now that it might contain more than just yes/no - I added
apostrophs to prevent that.

I ran into the issue of a failign KVM Probe of the qemu configure script three
times this week always needing "set -x", inserting an exit, masking the cleanup
trap and compiling the c file by hand until I knew what the reason is. I think
we could make easier for developers and end users.
Therefore this patch keeps the qemu style configure output which is a list of
"$Feature $Status", but extend the "no" result like "KVM Support no" with some
more information.

There might be a lot of things going wrong with that probe and I don't want
to handle all of them, but if it is one of the known checks e.g. for
KVM_API_VERSION then we could grep/awk that out and report it. The patch
reports in case of a known case in the style
"KVM support no - (Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS)"

In case more than one #error is triggered it creates a comma separated list in
those brackets and in case it is something else than an #error it just reports
plain old "no".

I sent a similar patch matching qemu upstream version of this file to
qemu-de...@nongnu.org to keep both in sync as much as possible.

Signed-off-by: Christian Ehrhardt 
---

[diffstat]
 configure |   22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

[diff]

diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -1037,12 +1037,14 @@ if test "$kvm" = "yes" ; then
 if test "$kvm" = "yes" ; then
 cat > $TMPC <
-#if !defined(KVM_API_VERSION) || \
-KVM_API_VERSION < 12 || \
-KVM_API_VERSION > 12 || \
-!defined(KVM_CAP_USER_MEMORY) || \
-!defined(KVM_CAP_SET_TSS_ADDR)
+#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
 #error Invalid KVM version
+#endif
+#if !defined(KVM_CAP_USER_MEMORY)
+#error Missing KVM capability KVM_CAP_USER_MEMORY
+#endif
+#if !defined(KVM_CAP_SET_TSS_ADDR)
+#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
 #endif
 int main(void) { return 0; }
 EOF
@@ -1055,7 +1057,12 @@ EOF
   2>/dev/null ; then
 :
   else
-kvm="no"
+kvmprobeerr=`$cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC 2>&1 
| grep "error: " | awk --field-separator "error: " '{if (NR>1) printf(", "); 
printf("%s",$2);}'`
+if test "$kvmprobeerr" != "" ; then
+  kvm="no - (${kvmprobeerr})"
+else
+  kvm="no"
+fi
   fi
 fi
 
@@ -1201,7 +1208,6 @@ if test -n "$sparc_cpu"; then
 echo "Target Sparc Arch $sparc_cpu"
 fi
 echo "kqemu support $kqemu"
-echo "kvm support   $kvm"
 echo "CPU emulation $cpu_emulation"
 if test $cpu = "powerpc"; then
 echo "libfdt support$device_tree_support"
@@ -1638,7 +1644,7 @@ disable_cpu_emulation() {
 }
 
 configure_kvm() {
-  if test $kvm = "yes" -a "$target_softmmu" = "yes" -a \
+  if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
   \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" 
= "powerpc" \); then
 echo "#define USE_KVM 1" >> $config_h
 echo "USE_KVM=1" >> $config_mak
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [PATCH] kvm-userspace: ppc: fix compatfd build decision v2

2008-12-15 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt 
# Date 1229345133 -3600
# Node ID b48b9d560f80037ab4e12eae128022622c7ccb34
# Parent  4b0ad05490115e4c6f31d2419c0e5b628040f90b
[PATCH] kvm-userspace: ppc: fix compatfd build decision v2

From: Christian Ehrhardt 

qemu-kvm.c uses qemu_eventfd/qemu_signalfd. The code of compatfd takes care
if CONFIG_eventfd/CONFIG_signalfd is really enabled. But currently compatfd
is not build if --disable-aio is set which leads to undefined references
when linking.

Since compatfd.c takes care of configs being set we can savely build it in
all cases dropping the ifdef completely. This allows powerpc but also all
other archs to build in case --disable-aio is set.

Signed-off-by: Christian Ehrhardt 
---

[diffstat]
 Makefile|5 +
 Makefile.target |6 +-
 2 files changed, 2 insertions(+), 9 deletions(-)

[diff]

diff --git a/qemu/Makefile b/qemu/Makefile
--- a/qemu/Makefile
+++ b/qemu/Makefile
@@ -51,7 +51,7 @@ BLOCK_OBJS+=block-cow.o block-qcow.o aes
 BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
 BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
 BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o
-BLOCK_OBJS+=nbd.o block.o aio.o
+BLOCK_OBJS+=nbd.o block.o aio.o compatfd.o
 
 ifdef CONFIG_WIN32
 BLOCK_OBJS += block-raw-win32.o
@@ -59,9 +59,6 @@ BLOCK_OBJS += block-raw-posix.o
 BLOCK_OBJS += block-raw-posix.o
 endif
 
-ifdef CONFIG_AIO
-BLOCK_OBJS += compatfd.o
-endif
 
 ##
 # libqemu_common.a: Target independent part of system emulation. The
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -646,6 +646,7 @@ OBJS=vl.o osdep.o monitor.o pci.o loader
 OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o
 OBJS+=fw_cfg.o
 OBJS+=net.o
+OBJS+=compatfd.o
 ifdef CONFIG_KVM
 OBJS+=kvm.o kvm-all.o
 endif
@@ -654,11 +655,6 @@ else
 else
 OBJS+=block-raw-posix.o
 endif
-
-ifdef CONFIG_AIO
-OBJS+=compatfd.o
-endif
-
 LIBS+=-lz
 ifdef CONFIG_ALSA
 LIBS += -lasound
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1 of 6] [PATCH] kvm-userspace: ppc: fix compatfd build decision

2008-12-15 Thread Christian Ehrhardt

Avi Kivity wrote:


qemu-kvm.c uses qemu_eventfd/qemu_signalfd. The code of compatfd 
takes care
if CONFIG_eventfd/CONFIG_signalfd is really enabled. But currently 
compatfd is
not build if --disable-aio is set. This patch lets compatfd.c build 
if USE_KVM
is set to allow qemu-kvm to be linked in all cases (with/without 
--disable-aio)
  


This breaks x86, so I dropped it.


On the other Hand x86 it is broken atm too.
If you compile current upstream for x86 with --disable-aio you'll get 
this too:

 ibqemu.a(qemu-kvm.o): In function `kvm_main_loop':
 
/home/paelzer/Desktop/KVM/ppc_port/kvm-userspace-ppc.hg-testbuild/qemu/qemu-kvm.c:565: 
undefined reference to `qemu_eventfd'
 
/home/paelzer/Desktop/KVM/ppc_port/kvm-userspace-ppc.hg-testbuild/qemu/qemu-kvm.c:580: 
undefined reference to `qemu_signalfd'

 collect2: ld returned 1 exit status

Which was exactly what I had with power :-/

I checked for the error you reported Avi, and the problem seems to be 
that  USE_KVM was not set even if KVM support is enabled (weird?).
However looking at this more in detail I realized that I don't have to 
care about USE_KVM in this csae. As I mentioned before compatfd.c takes 
care if CONFIG_signalfd/CONFIG_eventfd are set. Therefore we can savely 
remove the makefile guard completely and just always build compatfd.c.


This updated patch works for x86&powerpc with/without --disable-aio in 
my tests.

It should appear on the list shortly.

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [PATCH] kvm-userspace: gdb: fix new gdb function types

2008-12-12 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt 
# Date 1229085659 -3600
# Node ID 37967a80a2757505488685aac135681945e6da91
# Parent  f0ed33f14658fe91a14ec02501cb42d26e32f01f
[PATCH] kvm-userspace: gdb: fix new gdb function types

From: Christian Ehrhardt 

The types changed in the header but not in the powerpc and ia64 implementation.
This patch fix that build error by changing the stubs to the right prototype.

Signed-off-by: Christian Ehrhardt 
---

[diffstat]
 qemu-kvm-ia64.c|6 --
 qemu-kvm-powerpc.c |6 --
 2 files changed, 8 insertions(+), 4 deletions(-)

[diff]

diff --git a/qemu/qemu-kvm-ia64.c b/qemu/qemu-kvm-ia64.c
--- a/qemu/qemu-kvm-ia64.c
+++ b/qemu/qemu-kvm-ia64.c
@@ -65,12 +65,14 @@ void kvm_arch_update_regs_for_sipi(CPUSt
 {
 }
 
-int kvm_arch_insert_sw_breakpoint(struct kvm_sw_breakpoint *bp)
+int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
+  struct kvm_sw_breakpoint *bp)
 {
 return -EINVAL;
 }
 
-int kvm_arch_remove_sw_breakpoint(struct kvm_sw_breakpoint *bp)
+int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
+  struct kvm_sw_breakpoint *bp)
 {
 return -EINVAL;
 }
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -223,12 +223,14 @@ void kvm_arch_cpu_reset(CPUState *env)
 {
 }
 
-int kvm_arch_insert_sw_breakpoint(struct kvm_sw_breakpoint *bp)
+int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
+  struct kvm_sw_breakpoint *bp)
 {
 return -EINVAL;
 }
 
-int kvm_arch_remove_sw_breakpoint(struct kvm_sw_breakpoint *bp)
+int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
+  struct kvm_sw_breakpoint *bp)
 {
 return -EINVAL;
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

2008-12-12 Thread Christian Ehrhardt

Hollis Blanchard wrote:

On Thu, 2008-12-11 at 17:05 +0100, Jan Kiszka wrote:
  

Hollis Blanchard wrote:


On Thu, 2008-12-11 at 13:53 +0100, Christian Ehrhardt wrote:
  

This is v2 as version one had a type in it occured when splitting patches.
Mercurial somehow lost my changes to the patch description explaining 
that, but the patch is right this way.


Christian Ehrhardt wrote:


# HG changeset patch
# User Christian Ehrhardt 

# Date 1228999833 -3600
# Node ID dc1466c9077ab162f4637fffee1869f26be02299
# Parent  4c07fe2a56c7653a9113e05bb08c2de9aec210ce
[PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

From: Hollis Blanchard 

Add basic KVM PowerPC support to qemu's gdbstub introducing a kvm ppc style
mmu implementation that uses the kvm_translate ioctl.
This also requires to save the kvm registers prior to the 'm' gdb operations.

Signed-off-by: Hollis Blanchard 

Signed-off-by: Christian Ehrhardt 

  

Let's *not* apply this to kvm-userspace. We will submit this to qemu,
and once we work out the right solution there it will be merged
naturally.

  

I don't oversee yet what you want to push upstream, but in case it's the
gdbstub support for kvm (including ppc bits): please note that I plan to
push the new interface once it is merged into kvm-userspace, avoiding to
spread the current, limited one as far as possible.

BTW, would be great if you could have a look / provide patches for ppc
to support the new interface already. I am open for feedback,
specifically regarding its suitability beyond x86.



I've been meaning to do this for a while, sorry. We'll take a look soon.

  

Hi Jan,
I saw that you already had that env->s->g_cpu fix, so if you change all that
anyway it might really be better to test/extend your patches for powerpc 
now.


If it is ok for you I would submit my patches that apply on top of yours to
you and cc the kvm list. But as Hollis mentioned I would prefer go for qemu
upstream first and then assist Avi in merging it into kvm-userspace because
this is the natural direction patches flow atm (and if you need to change it
multiple times until you get qemu acceptance you would have to extensivly
patch both projects to match again).

As my code in that case depend on your patches it would be nice if you could
put them into your series once you are happy with it.

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

2008-12-11 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt <[EMAIL PROTECTED]>
# Date 1228999833 -3600
# Node ID dc1466c9077ab162f4637fffee1869f26be02299
# Parent  4c07fe2a56c7653a9113e05bb08c2de9aec210ce
[PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

From: Hollis Blanchard <[EMAIL PROTECTED]>

Add basic KVM PowerPC support to qemu's gdbstub introducing a kvm ppc style
mmu implementation that uses the kvm_translate ioctl.
This also requires to save the kvm registers prior to the 'm' gdb operations.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 gdbstub.c   |2 ++
 hw/ppc440_bamboo.c  |1 +
 qemu-kvm-powerpc.c  |   28 
 target-ppc/cpu.h|2 ++
 target-ppc/helper.c |4 
 target-ppc/translate_init.c |5 +
 6 files changed, 42 insertions(+)

[diff]

diff --git a/qemu/gdbstub.c b/qemu/gdbstub.c
--- a/qemu/gdbstub.c
+++ b/qemu/gdbstub.c
@@ -1374,6 +1374,7 @@ static int gdb_handle_packet(GDBState *s
 if (*p == ',')
 p++;
 len = strtoull(p, NULL, 16);
+kvm_save_registers(s->g_cpu);
 if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 0) != 0) {
 put_packet (s, "E14");
 } else {
@@ -1389,6 +1390,7 @@ static int gdb_handle_packet(GDBState *s
 if (*p == ':')
 p++;
 hextomem(mem_buf, p, len);
+kvm_save_registers(s->g_cpu);
 if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 1) != 0)
 put_packet(s, "E14");
 else
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
@@ -99,6 +99,7 @@ void bamboo_init(ram_addr_t ram_size, in
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
+   env->mmu_model = POWERPC_MMU_KVM;
 
/* call init */
printf("Calling function ppc440_init\n");
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -102,6 +102,7 @@ void kvm_arch_save_regs(CPUState *env)
 
 env->spr[SPR_SRR0] = regs.srr0;
 env->spr[SPR_SRR1] = regs.srr1;
+env->spr[SPR_BOOKE_PID] = regs.pid;
 
 env->spr[SPR_SPRG0] = regs.sprg0;
 env->spr[SPR_SPRG1] = regs.sprg1;
@@ -219,6 +220,33 @@ int handle_powerpc_dcr_write(int vcpu, u
 return 0; /* XXX ignore failed DCR ops */
 }
 
+int mmukvm_get_physical_address(CPUState *env, mmu_ctx_t *ctx,
+target_ulong eaddr, int rw, int access_type)
+{
+struct kvm_translation tr;
+uint64_t pid;
+uint64_t as;
+int r;
+
+pid = env->spr[SPR_BOOKE_PID];
+
+if (access_type == ACCESS_CODE)
+as = env->msr & msr_ir;
+else
+as = env->msr & msr_dr;
+
+tr.linear_address = as << 40 | pid << 32 | eaddr;
+r = kvm_translate(kvm_context, env->cpu_index, &tr);
+if (r == -1)
+return r;
+
+if (!tr.valid)
+return -EFAULT;
+
+ctx->raddr = tr.physical_address;
+return 0;
+}
+
 void kvm_arch_cpu_reset(CPUState *env)
 {
 }
diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -98,6 +98,8 @@ enum powerpc_mmu_t {
 POWERPC_MMU_BOOKE_FSL  = 0x0009,
 /* PowerPC 601 MMU model (specific BATs format)*/
 POWERPC_MMU_601= 0x000A,
+/* KVM managing the MMU state  */
+POWERPC_MMU_KVM= 0x000B,
 #if defined(TARGET_PPC64)
 #define POWERPC_MMU_64   0x0001
 /* 64 bits PowerPC MMU */
diff --git a/qemu/target-ppc/helper.c b/qemu/target-ppc/helper.c
--- a/qemu/target-ppc/helper.c
+++ b/qemu/target-ppc/helper.c
@@ -1429,6 +1429,10 @@ int get_physical_address (CPUState *env,
 fprintf(logfile, "%s\n", __func__);
 }
 #endif
+
+if (env->mmu_model == POWERPC_MMU_KVM)
+return mmukvm_get_physical_address(env, ctx, eaddr, rw, access_type);
+
 if ((access_type == ACCESS_CODE && msr_ir == 0) ||
 (access_type != ACCESS_CODE && msr_dr == 0)) {
 /* No address translation */
diff --git a/qemu/target-ppc/translate_init.c b/qemu/target-ppc/translate_init.c
--- a/qemu/target-ppc/translate_init.c
+++ b/qemu/target-ppc/translate_init.c
@@ -9273,6 +9273,11 @@ int cpu_ppc_register_internal (CPUPPCSta
 case POWERPC_MMU_601:
 mmu_model = "PowerPC 601";
 break;
+#ifdef KVM
+case POWERPC_MMU_KVM:
+mmu_model = "PowerPC KVM";
+break;
+#endif
 #if defined (TARGET_PPC64)
 case POWERPC_MMU

Re: [PATCH] [PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

2008-12-11 Thread Christian Ehrhardt

This is v2 as version one had a type in it occured when splitting patches.
Mercurial somehow lost my changes to the patch description explaining 
that, but the patch is right this way.


Christian Ehrhardt wrote:

# HG changeset patch
# User Christian Ehrhardt <[EMAIL PROTECTED]>
# Date 1228999833 -3600
# Node ID dc1466c9077ab162f4637fffee1869f26be02299
# Parent  4c07fe2a56c7653a9113e05bb08c2de9aec210ce
[PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

From: Hollis Blanchard <[EMAIL PROTECTED]>

Add basic KVM PowerPC support to qemu's gdbstub introducing a kvm ppc style
mmu implementation that uses the kvm_translate ioctl.
This also requires to save the kvm registers prior to the 'm' gdb operations.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 gdbstub.c   |2 ++
 hw/ppc440_bamboo.c  |1 +
 qemu-kvm-powerpc.c  |   28 
 target-ppc/cpu.h|2 ++
 target-ppc/helper.c |4 
 target-ppc/translate_init.c |5 +
 6 files changed, 42 insertions(+)

[diff]

diff --git a/qemu/gdbstub.c b/qemu/gdbstub.c
--- a/qemu/gdbstub.c
+++ b/qemu/gdbstub.c
@@ -1374,6 +1374,7 @@ static int gdb_handle_packet(GDBState *s
 if (*p == ',')
 p++;
 len = strtoull(p, NULL, 16);
+kvm_save_registers(s->g_cpu);
 if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 0) != 0) {
 put_packet (s, "E14");
 } else {
@@ -1389,6 +1390,7 @@ static int gdb_handle_packet(GDBState *s
 if (*p == ':')
 p++;
 hextomem(mem_buf, p, len);
+kvm_save_registers(s->g_cpu);
 if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 1) != 0)
 put_packet(s, "E14");
 else
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
@@ -99,6 +99,7 @@ void bamboo_init(ram_addr_t ram_size, in
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
+   env->mmu_model = POWERPC_MMU_KVM;

/* call init */
printf("Calling function ppc440_init\n");
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -102,6 +102,7 @@ void kvm_arch_save_regs(CPUState *env)

 env->spr[SPR_SRR0] = regs.srr0;
 env->spr[SPR_SRR1] = regs.srr1;
+env->spr[SPR_BOOKE_PID] = regs.pid;

 env->spr[SPR_SPRG0] = regs.sprg0;
 env->spr[SPR_SPRG1] = regs.sprg1;
@@ -219,6 +220,33 @@ int handle_powerpc_dcr_write(int vcpu, u
 return 0; /* XXX ignore failed DCR ops */
 }

+int mmukvm_get_physical_address(CPUState *env, mmu_ctx_t *ctx,
+target_ulong eaddr, int rw, int access_type)
+{
+struct kvm_translation tr;
+uint64_t pid;
+uint64_t as;
+int r;
+
+pid = env->spr[SPR_BOOKE_PID];
+
+if (access_type == ACCESS_CODE)
+as = env->msr & msr_ir;
+else
+as = env->msr & msr_dr;
+
+tr.linear_address = as << 40 | pid << 32 | eaddr;
+r = kvm_translate(kvm_context, env->cpu_index, &tr);
+if (r == -1)
+return r;
+
+if (!tr.valid)
+return -EFAULT;
+
+ctx->raddr = tr.physical_address;
+return 0;
+}
+
 void kvm_arch_cpu_reset(CPUState *env)
 {
 }
diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -98,6 +98,8 @@ enum powerpc_mmu_t {
 POWERPC_MMU_BOOKE_FSL  = 0x0009,
 /* PowerPC 601 MMU model (specific BATs format)*/
 POWERPC_MMU_601= 0x000A,
+/* KVM managing the MMU state  */
+POWERPC_MMU_KVM= 0x000B,
 #if defined(TARGET_PPC64)
 #define POWERPC_MMU_64   0x0001
 /* 64 bits PowerPC MMU */
diff --git a/qemu/target-ppc/helper.c b/qemu/target-ppc/helper.c
--- a/qemu/target-ppc/helper.c
+++ b/qemu/target-ppc/helper.c
@@ -1429,6 +1429,10 @@ int get_physical_address (CPUState *env,
 fprintf(logfile, "%s\n", __func__);
 }
 #endif
+
+if (env->mmu_model == POWERPC_MMU_KVM)
+return mmukvm_get_physical_address(env, ctx, eaddr, rw, access_type);
+
 if ((access_type == ACCESS_CODE && msr_ir == 0) ||
 (access_type != ACCESS_CODE && msr_dr == 0)) {
 /* No address translation */
diff --git a/qemu/target-ppc/translate_init.c b/qemu/target-ppc/translate_init.c
--- a/qemu/target-ppc/translate_init.c
+++ b/qemu/target-ppc/translate_init.c
@@ -9273,6 +9273,11 @@ int cpu_ppc_register_internal (CPUPPCSta
 case POWERPC_MMU_601:
 mmu_model = "

[PATCH 3 of 3] [PATCH] kvm-userspace: fix gdbstub kvm integration

2008-12-11 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt <[EMAIL PROTECTED]>
# Date 1228989958 -3600
# Node ID f80fb35de91fe69dae889c70948c9a53212ee444
# Parent  6f228c807ad0b239b7342d2974debfc66418d784
[PATCH] kvm-userspace: fix gdbstub kvm integration

From: Christian Ehrhardt <[EMAIL PROTECTED]>

Some recent qemu upstream merges brought in a new concept to not use "env" as
current cpu in gdb_handle_packet anymore. But the kvm calls still do, this
leads to SIGDEV's as env is not initialized when calling the functions like
kvm_save_registers.

Insted there is now a gdbstate structure holding current cpu for
step/continue and "other" ops splitted.

This patch changes the kvm_save_registers calls to use the right CPUState
variable for the kvm calls in gdb_handle_packet.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 gdbstub.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

[diff]

diff --git a/qemu/gdbstub.c b/qemu/gdbstub.c
--- a/qemu/gdbstub.c
+++ b/qemu/gdbstub.c
@@ -1348,7 +1348,7 @@ static int gdb_handle_packet(GDBState *s
 }
 break;
 case 'g':
-kvm_save_registers(env);
+kvm_save_registers(s->g_cpu);
 len = 0;
 for (addr = 0; addr < num_g_regs; addr++) {
 reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr);
@@ -1366,7 +1366,7 @@ static int gdb_handle_packet(GDBState *s
 len -= reg_size;
 registers += reg_size;
 }
-kvm_load_registers(env);
+kvm_load_registers(s->g_cpu);
 put_packet(s, "OK");
 break;
 case 'm':
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1 of 3] [PATCH] kvm-userspace: ppc: Add kvm_translate wrapper

2008-12-11 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt <[EMAIL PROTECTED]>
# Date 1228924564 -3600
# Node ID 38846cef16e56c681da1ddc179e248972c8b2ff9
# Parent  705d874ff7a24484eaa15ed75a748c4e1a70c2ef
[PATCH] kvm-userspace: ppc: Add kvm_translate wrapper

From: Hollis Blanchard <[EMAIL PROTECTED]>

Add kvm_translate() wrapper used to get mmu translations from userspace.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 libkvm.c |5 +
 libkvm.h |2 ++
 2 files changed, 7 insertions(+)

[diff]

diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -987,6 +987,11 @@ int kvm_guest_debug(kvm_context_t kvm, i
return ioctl(kvm->vcpu_fd[vcpu], KVM_DEBUG_GUEST, dbg);
 }
 
+int kvm_translate(kvm_context_t kvm, int vcpu, struct kvm_translation *tr)
+{
+   return ioctl(kvm->vcpu_fd[vcpu], KVM_TRANSLATE, tr);
+}
+
 int kvm_set_signal_mask(kvm_context_t kvm, int vcpu, const sigset_t *sigset)
 {
struct kvm_signal_mask *sigmask;
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -639,6 +639,8 @@ int kvm_set_pit(kvm_context_t kvm, struc
 int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s);
 #endif
 
+int kvm_translate(kvm_context_t kvm, int vcpu, struct kvm_translation *tr);
+
 #endif
 
 #ifdef KVM_CAP_VAPIC
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2 of 3] [PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

2008-12-11 Thread Christian Ehrhardt
# HG changeset patch
# User Christian Ehrhardt <[EMAIL PROTECTED]>
# Date 1228989956 -3600
# Node ID 6f228c807ad0b239b7342d2974debfc66418d784
# Parent  38846cef16e56c681da1ddc179e248972c8b2ff9
[PATCH] qemu: ppc: kvm-userspace: KVM PowerPC support for qemu gdbstub

From: Hollis Blanchard <[EMAIL PROTECTED]>

Add basic KVM PowerPC support to qemu's gdbstub introducing a kvm ppc style
mmu implementation that uses the kvm_translate ioctl.
This also requires to save the kvm registers prior to the 'm' gdb operations.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 gdbstub.c   |2 ++
 hw/ppc440_bamboo.c  |1 +
 qemu-kvm-powerpc.c  |   28 
 target-ppc/cpu.h|2 ++
 target-ppc/helper.c |4 
 target-ppc/translate_init.c |5 +
 6 files changed, 42 insertions(+)

[diff]

diff --git a/qemu/gdbstub.c b/qemu/gdbstub.c
--- a/qemu/gdbstub.c
+++ b/qemu/gdbstub.c
@@ -1374,6 +1374,7 @@ static int gdb_handle_packet(GDBState *s
 if (*p == ',')
 p++;
 len = strtoull(p, NULL, 16);
+kvm_save_registers(s->g_cpu);
 if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 0) != 0) {
 put_packet (s, "E14");
 } else {
@@ -1389,6 +1390,7 @@ static int gdb_handle_packet(GDBState *s
 if (*p == ':')
 p++;
 hextomem(mem_buf, p, len);
+kvm_save_registers(s->gcpu);
 if (cpu_memory_rw_debug(s->g_cpu, addr, mem_buf, len, 1) != 0)
 put_packet(s, "E14");
 else
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
@@ -99,6 +99,7 @@ void bamboo_init(ram_addr_t ram_size, in
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
+   env->mmu_model = POWERPC_MMU_KVM;
 
/* call init */
printf("Calling function ppc440_init\n");
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -102,6 +102,7 @@ void kvm_arch_save_regs(CPUState *env)
 
 env->spr[SPR_SRR0] = regs.srr0;
 env->spr[SPR_SRR1] = regs.srr1;
+env->spr[SPR_BOOKE_PID] = regs.pid;
 
 env->spr[SPR_SPRG0] = regs.sprg0;
 env->spr[SPR_SPRG1] = regs.sprg1;
@@ -219,6 +220,33 @@ int handle_powerpc_dcr_write(int vcpu, u
 return 0; /* XXX ignore failed DCR ops */
 }
 
+int mmukvm_get_physical_address(CPUState *env, mmu_ctx_t *ctx,
+target_ulong eaddr, int rw, int access_type)
+{
+struct kvm_translation tr;
+uint64_t pid;
+uint64_t as;
+int r;
+
+pid = env->spr[SPR_BOOKE_PID];
+
+if (access_type == ACCESS_CODE)
+as = env->msr & msr_ir;
+else
+as = env->msr & msr_dr;
+
+tr.linear_address = as << 40 | pid << 32 | eaddr;
+r = kvm_translate(kvm_context, env->cpu_index, &tr);
+if (r == -1)
+return r;
+
+if (!tr.valid)
+return -EFAULT;
+
+ctx->raddr = tr.physical_address;
+return 0;
+}
+
 void kvm_arch_cpu_reset(CPUState *env)
 {
 }
diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -98,6 +98,8 @@ enum powerpc_mmu_t {
 POWERPC_MMU_BOOKE_FSL  = 0x0009,
 /* PowerPC 601 MMU model (specific BATs format)*/
 POWERPC_MMU_601= 0x000A,
+/* KVM managing the MMU state  */
+POWERPC_MMU_KVM= 0x000B,
 #if defined(TARGET_PPC64)
 #define POWERPC_MMU_64   0x0001
 /* 64 bits PowerPC MMU */
diff --git a/qemu/target-ppc/helper.c b/qemu/target-ppc/helper.c
--- a/qemu/target-ppc/helper.c
+++ b/qemu/target-ppc/helper.c
@@ -1429,6 +1429,10 @@ int get_physical_address (CPUState *env,
 fprintf(logfile, "%s\n", __func__);
 }
 #endif
+
+if (env->mmu_model == POWERPC_MMU_KVM)
+return mmukvm_get_physical_address(env, ctx, eaddr, rw, access_type);
+
 if ((access_type == ACCESS_CODE && msr_ir == 0) ||
 (access_type != ACCESS_CODE && msr_dr == 0)) {
 /* No address translation */
diff --git a/qemu/target-ppc/translate_init.c b/qemu/target-ppc/translate_init.c
--- a/qemu/target-ppc/translate_init.c
+++ b/qemu/target-ppc/translate_init.c
@@ -9273,6 +9273,11 @@ int cpu_ppc_register_internal (CPUPPCSta
 case POWERPC_MMU_601:
 mmu_model = "PowerPC 601";
 break;
+#ifdef KVM
+case POWERPC_MMU_KVM:
+mmu_model = "PowerPC KVM";
+break;
+#endif
 #if defined (TARGET_PPC64)
 case POWERPC_MMU

[PATCH 0 of 3] update gdbstub support

2008-12-11 Thread Christian Ehrhardt
This patch series updates the gdbstub support for kvm.
Patch 1&2 introduce basic powerpc support while patch 3 fixes gdbstub generic
code that was broken in a qemu merge.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


kvm-userspace requires kvm capable kernel headers in default search path of the compiler

2008-12-10 Thread Christian Ehrhardt

Hi everyone,
while running a test when updating kvm-userspace for powerpc I found 
that the current kvm userspace requires kvm kernel headers in the 
default search path of the used compilers.
I used to update and build in the same kvm-userspace directory for a 
while and this one had an old stale kernel/include directory which 
fulfilled all the requirements.
While testing my current patch series on a new git clone of 
kvm-userspace I wondered why this doesn't work anymore (it worked in my 
old directory which also had the updated current source).


I switched to x86 to verify that issue there and I found that eventually 
the issue is in the kvm detection "KVM Probe" part of the qemu 
configuration in kvm-userspace. It failed not finding kvm headers.
  gcc -m32 -o /tmp/qemu-conf--21885-  
-I/home/paelzer/Desktop/kvm-userspace/kernel/include 
/tmp/qemu-conf--21885-.c
  /tmp/qemu-conf--21885-.c:1:23: error: linux/kvm.h: No such file or 
directory

  /tmp/qemu-conf--21885-.c:3:2: error: #error Invalid KVM version

Looking at the include paths it is worth to note that a current git 
clone of kvm-userspace has no kernel/include directory anymore. A few 
questions later to some other kvm developers I found that there headers 
can be found, but in the default search path of the compiler e.g. 
/usr/include. In my environment with an older gcc cross compiler for 
powerpc and no up to date linux headers installed for x86 both 
architectures failed.


The Solution to that can be done in several ways:
a) we decide that kvm-userspace needs up-to-date kernel headers 
installed. And modify the KVM Probe at least to tell the user about this 
possible reason when failing instead of silently switching to "KVM 
support no".
b) if the user already provide a --kerneldir option to specify where the 
right includes can be found we should give those configure checks a 
chance to really reach that. Atm it adds the kernel/include path of the 
kvm-userspace tree which doesn't exist anymore (except as stale old dir 
in a lot of source trees out there).
c) I overlooked something and there is an even better or trivial 
approach :-)


Since this could be solved several very different ways I think its worth 
a discussion.
As I prefer b) I attached a simple patch example how this could look 
like :-).


--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

diff --git a/configure b/configure
index 63f956c..f772bae 100755
--- a/configure
+++ b/configure
@@ -3,6 +3,7 @@
 prefix=/usr/local
 kernelsourcedir=
 kerneldir=/lib/modules/$(uname -r)/build
+qemu_kerneldir=
 cc=gcc
 ld=ld
 objcopy=objcopy
@@ -56,6 +57,7 @@ while [[ "$1" = -* ]]; do
 	;;
 	--kerneldir)
 	kerneldir="$arg"
+	qemu_kerneldir="$arg"
 	;;
 	--with-patched-kernel)
 	want_module=
@@ -84,9 +86,12 @@ while [[ "$1" = -* ]]; do
 esac
 done
 
-
-#set kenel directory
+#set libkvm kernel directory
 libkvm_kerneldir=$(readlink -f kernel)
+# use libkvm_kerneldir for qemu if no kerneldir option was set
+if test "$qemu_kerneldir" = "" ; then
+qemu_kerneldir=$libkvm_kerneldir
+fi
 
 case $arch in
 i?86*|x86_64*)
@@ -123,7 +128,7 @@ fi
 --disable-gcc-check \
 --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
 --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
---kerneldir="$libkvm_kerneldir" \
+--kerneldir="$qemu_kerneldir" \
 --prefix="$prefix" \
 ${cross_prefix:+"--cross-prefix=$cross_prefix"} \
 ${cross_prefix:+"--cpu=$arch"} "[EMAIL PROTECTED]"


[PATCH] [PATCH] kvm: powerpc: fix some whitespaces in kvm_ppc.h

2008-11-12 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Fix some whitespaces in kvm_ppc.h

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]

[diff]

diff --git a/arch/powerpc/include/asm/kvm_ppc.h 
b/arch/powerpc/include/asm/kvm_ppc.h
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -30,10 +30,10 @@
 #include 
 
 enum emulation_result {
-   EMULATE_DONE, /* no further processing */
-   EMULATE_DO_MMIO,  /* kvm_run filled with MMIO request */
-   EMULATE_DO_DCR,   /* kvm_run filled with DCR request */
-   EMULATE_FAIL, /* can't emulate this instruction */
+   EMULATE_DONE,   /* no further processing */
+   EMULATE_DO_MMIO,/* kvm_run filled with MMIO request */
+   EMULATE_DO_DCR, /* kvm_run filled with DCR request */
+   EMULATE_FAIL,   /* can't emulate this instruction */
 };
 
 extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvm: powerpc: add exit timing statistics v5

2008-11-12 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update to v5*
- add exittiming.c to diff content
- prefix all exit timing functions with kvmppc to prevent name collisions (was
  already done for some of the functions, now its consequently done for all of
  them)
- renamed header & c-file and relocated the header from asm to arch/powerpc/kvm
- changed the empty define function stubs to empty static inlines
- removed unrelated whitespace change and leftover of atomic vm_id
- changed debugs filename to lower case and fewer underscores
- updated the Kconfig text

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

An awk script printing the data in a more narrow layout can be found on our
wiki pages about the exit timing topic.
(http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)
Here is a sample output how the results look like.
processing file timing_boot.log
sum of time 8309940
 typecount  min  max  sum  avg   
stddev %
MMIO: 9402   44 1997  1697610 180.5584  
155.768 20.43
 DCR:  680   41   9932096  47.2000
7.008  0.39
  SIGNAL:1   98   98   98  98.
0.000  0.00
ITLBREAL:  9268   14 7810   8.4341
0.658  0.09
ITLBVIRT: 3595   18  20276185  21.1919
4.954  0.92
DTLBREAL:  9508   16 8891   9.3589
1.427  0.11
DTLBVIRT: 6695   18  282   156727  23.4096   
13.781  1.89
 SYSCALL: 18016   5911372   6.3143
2.575  0.14
 ISI:  11668  764   6.5862
0.588  0.01
 DSI:   4367  292   6.7907
0.407  0.00
EMULINST:652477   96   484081   7.4192
1.818  5.83
   EMUL_WAIT:  801  659 9200  37217894646.4282 
1687.218 44.79
  EMUL_WRTEE:668067   86   540053   8.0839
1.895  6.50
  EMUL_MTSPR:134158   62   111358   8.3010
2.583  1.34
  EMUL_MFSPR: 76358   6162772   8.2216
1.921  0.76
  EMUL_MTMSR: 56788   5945704   8.0493
1.434  0.55
  EMUL_MFMSR:328537   67   267603   8.1455
1.875  3.22
  EMUL_TLBSX:  3549   60 3745  10.5791
3.919  0.05
  EMUL_TLBWE: 64039  11299522  15.5430
7.668  1.20
EMUL_RFI: 95157   5771420   7.5060
2.108  0.86
 DEC:  290   49  16115786  54.4345
9.708  0.19
  EXTINT:7   74   75  522  74.5714
0.495  0.01
 TIMEINGUEST:   2332130 3954   893740   3.8323   
65.837 10.76

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 include/asm/kvm_host.h |   56 ++
 kernel/asm-offsets.c   |   11 ++
 kvm/44x_emulate.c  |   11 +-
 kvm/44x_tlb.c  |3
 kvm/Kconfig|   11 ++
 kvm/Makefile   |1
 kvm/booke.c|   36 --
 kvm/booke.h|5
 kvm/booke_interrupts.S |   24 
 kvm/emulate.c  |4
 kvm/powerpc.c  |8 +
 kvm/timing.c   |  262 +
 kvm/timing.h   |  102 +++
 13 files changed, 516 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -71,6 +71,49 @@ struct kvmppc_44x_tlbe {
u32 word2;
 };
 
+enum kvm_exit_types {
+   MMIO_EXITS,
+   DCR_EXITS,
+   SIGNAL_EXITS,
+   ITLB_REAL_MISS_EXITS,
+   ITLB_VIRT_MISS_EXITS,
+   DTLB_REAL_MISS_EXITS,
+   

Re: [PATCH] kvm: powerpc: add exit timing statistics v4

2008-11-12 Thread Christian Ehrhardt

Hollis Blanchard wrote:

On Tue, 2008-11-11 at 16:43 +0100, Christian Ehrhardt wrote:
  

From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update to v4*
- EMUL_CORE no longer had more than wrtee emulation, therefore it now accounts
  for WRTEE in the output and set_exit_type calls are in the wrtee handlers to
  let any residual core op be counted as EMULINST"

*update to v3*
- ensure build time optimization when calling exit accouting functions using
  build time bug / constant check
- migrate most of the exit timing code from powerpc.c and
  kvm_timing_stats.h to a separate exittiming.c file
- renamed a lot of constants used to better fit generic/core specific code
- added an accidenially removed optimization comment
- use pid of userspace process instead of an own atomic count to identify a vm
- changed loop labels in tul/tbu loops (booke_interrupt.S) to anonymous 1/1b
- removed the indirection of additional EMULATE_*_DONE types. Instead now
  the exit timing supports "accounting" an exit which consists of set type and
  increase kvm_stat counters. But also provides both sub-tasks as separate
  functions. Using that emulation now sets a default EMUL_INST type that can
  be overwritten by detailed subcategories (set_exit_type). Accouting for
  kvm_stat is done with account_exit_stat for all emulinst exits together on
  top level (as it was before).

*update to v2*
The update fixes accounting for sets to MSR[WE] which should not be accoutned
as instruction emulation. While adding that and analyzing the data it became
obvious that several types of emulations hould be accounted separately.
I'm not yet really happy with adding all these EMULATE_*_DONE types but I had
no better idea to not break flood the code with account calls and split
account/set_type. The issue is that emulation is also called e.g. for some mmio
paths and therefore the accouting should not be called inside emulation, but on
the returning path that can now evaluate the different kind of emulations done.
This is not yet finished, and posted as RFC only.

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).



You forgot to include exittiming.c in this patch. Since I can't build
it, I might as well tell you the additional changes I was going to
make... :)
  
sigh - I hate missing such things. I should include a check via hg 
status for ? files with a .c/.h type  in my hg email :-/

I'll resubmit the patch as v5 including the changes you describe here

  * Prefix all the functions in kvm_timing_stats.h to begin with
"kvmppc_". (I really like to keep the layering as clear as
possible.) I don't think we need to add "booke" in there, since
a hypothetical kvmppc 970 implementation could use the same
function names, just a different set of exit types. 
  
very reasonable, and as some sort of advocacy I wanted to mention that I 
already did that with some of the functions.

But yes I should be consequent and do this for all of them.

  * Rename kvm_timing_stats.h. Does that need to go in the asm
directory btw? If so, call it kvm_timing.h; if not, please put
it inside arch/powerpc/kvm, and name it timing.h.
  

done
  * Rename exittiming.c to match whatever you name the header. 
  

done

  * Use empty static functions instead of empty macros in
kvm_timing.h. (I'm not the only one who doesn't like macros; see
http://lwn.net/Articles/306045/) 
  
I had no precedence 'til now and just used what I see most in code and 
that where defines :-)

But it makes sense.
Btw - I would even change it if only you wouldn't like macros :-P

  * I know it's just leftovers from previous iterations of this
patch, but drop the whitespace changes to include/asm/kvm_ppc.h
(and send as a separate patch if you like).
  

at least the whitespace fix is correct ;-)
I'll submit it in a separate patch
  * Remove vm_id from kvm_arch (you just missed this one spot :). 
  

done

  * I don't like the debugfs file names you've chosen, but I'm not

[PATCH] kvm: powerpc: add exit timing statistics v4

2008-11-11 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update to v4*
- EMUL_CORE no longer had more than wrtee emulation, therefore it now accounts
  for WRTEE in the output and set_exit_type calls are in the wrtee handlers to
  let any residual core op be counted as EMULINST"

*update to v3*
- ensure build time optimization when calling exit accouting functions using
  build time bug / constant check
- migrate most of the exit timing code from powerpc.c and
  kvm_timing_stats.h to a separate exittiming.c file
- renamed a lot of constants used to better fit generic/core specific code
- added an accidenially removed optimization comment
- use pid of userspace process instead of an own atomic count to identify a vm
- changed loop labels in tul/tbu loops (booke_interrupt.S) to anonymous 1/1b
- removed the indirection of additional EMULATE_*_DONE types. Instead now
  the exit timing supports "accounting" an exit which consists of set type and
  increase kvm_stat counters. But also provides both sub-tasks as separate
  functions. Using that emulation now sets a default EMUL_INST type that can
  be overwritten by detailed subcategories (set_exit_type). Accouting for
  kvm_stat is done with account_exit_stat for all emulinst exits together on
  top level (as it was before).

*update to v2*
The update fixes accounting for sets to MSR[WE] which should not be accoutned
as instruction emulation. While adding that and analyzing the data it became
obvious that several types of emulations hould be accounted separately.
I'm not yet really happy with adding all these EMULATE_*_DONE types but I had
no better idea to not break flood the code with account calls and split
account/set_type. The issue is that emulation is also called e.g. for some mmio
paths and therefore the accouting should not be called inside emulation, but on
the returning path that can now evaluate the different kind of emulations done.
This is not yet finished, and posted as RFC only.

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

* another update in v3*
An updated awk script printing the data in a more narrow layout can be found
on our wiki pages about the exit timing topic.
(http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)
Here is a sample output how the results look like.
processing file timing_boot.log
sum of time 8309940
 typecount  min  max  sum  avg   
stddev %
MMIO: 9402   44 1997  1697610 180.5584  
155.768 20.43
 DCR:  680   41   9932096  47.2000
7.008  0.39
  SIGNAL:1   98   98   98  98.
0.000  0.00
ITLBREAL:  9268   14 7810   8.4341
0.658  0.09
ITLBVIRT: 3595   18  20276185  21.1919
4.954  0.92
DTLBREAL:  9508   16 8891   9.3589
1.427  0.11
DTLBVIRT: 6695   18  282   156727  23.4096   
13.781  1.89
 SYSCALL: 18016   5911372   6.3143
2.575  0.14
 ISI:  11668  764   6.5862
0.588  0.01
 DSI:   4367  292   6.7907
0.407  0.00
EMULINST:652477   96   484081   7.4192
1.818  5.83
   EMUL_WAIT:  801  659 9200  37217894646.4282 
1687.218 44.79
  EMUL_WRTEE:668067   86   540053   8.0839
1.895  6.50
  EMUL_MTSPR:134158   62   111358   8.3010
2.583  1.34
  EMUL_MFSPR: 76358   6162772   8.2216
1.921  0.76
  EMUL_MTMSR: 56788   5945704   8.0493
1.434  0.55
  EMUL_MFMSR:328537   67   267603   8.1455
1.875  3.22
  EMUL_TLBSX:  3549   60 3745  10.5791
3.919  0.05
  EMUL_TLBWE: 64039  11299522  15.5430
7.66

[PATCH] kvm: powerpc: add exit timing statistics v3

2008-11-11 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update to v3*
- ensure build time optimization when calling exit accouting functions using
  build time bug / constant check
- migrate most of the exit timing code from powerpc.c and
  kvm_timing_stats.h to a separate exittiming.c file
- renamed a lot of constants used to better fit generic/core specific code
- added an accidenially removed optimization comment
- use pid of userspace process instead of an own atomic count to identify a vm
- changed loop labels in tul/tbu loops (booke_interrupt.S) to anonymous 1/1b
- removed the indirection of additional EMULATE_*_DONE types. Instead now
  the exit timing supports "accounting" an exit which consists of set type and
  increase kvm_stat counters. But also provides both sub-tasks as separate
  functions. Using that emulation now sets a default EMUL_INST type that can
  be overwritten by detailed subcategories (set_exit_type). Accouting for
  kvm_stat is done with account_exit_stat for all emulinst exits together on
  top level (as it was before).

*update to v2*
The update fixes accounting for sets to MSR[WE] which should not be accoutned
as instruction emulation. While adding that and analyzing the data it became
obvious that several types of emulations hould be accounted separately.
I'm not yet really happy with adding all these EMULATE_*_DONE types but I had
no better idea to not break flood the code with account calls and split
account/set_type. The issue is that emulation is also called e.g. for some mmio
paths and therefore the accouting should not be called inside emulation, but on
the returning path that can now evaluate the different kind of emulations done.
This is not yet finished, and posted as RFC only.

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

* another update in v3*
An updated awk script printing the data in a more narrow layout can be found
on our wiki pages about the exit timing topic.
(http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)
Here is a sample output how the results look like.
processing file timing_boot.log
sum of time 8309940
 typecount  min  max  sum  avg   
stddev %
MMIO: 9402   44 1997  1697610 180.5584  
155.768 20.43
 DCR:  680   41   9932096  47.2000
7.008  0.39
  SIGNAL:1   98   98   98  98.
0.000  0.00
ITLBREAL:  9268   14 7810   8.4341
0.658  0.09
ITLBVIRT: 3595   18  20276185  21.1919
4.954  0.92
DTLBREAL:  9508   16 8891   9.3589
1.427  0.11
DTLBVIRT: 6695   18  282   156727  23.4096   
13.781  1.89
 SYSCALL: 18016   5911372   6.3143
2.575  0.14
 ISI:  11668  764   6.5862
0.588  0.01
 DSI:   4367  292   6.7907
0.407  0.00
EMULINST:652477   96   484081   7.4192
1.818  5.83
   EMUL_WAIT:  801  659 9200  37217894646.4282 
1687.218 44.79
   EMUL_CORE:668067   86   540053   8.0839
1.895  6.50
  EMUL_MTSPR:134158   62   111358   8.3010
2.583  1.34
  EMUL_MFSPR: 76358   6162772   8.2216
1.921  0.76
  EMUL_MTMSR: 56788   5945704   8.0493
1.434  0.55
  EMUL_MFMSR:328537   67   267603   8.1455
1.875  3.22
  EMUL_TLBSX:  3549   60 3745  10.5791
3.919  0.05
  EMUL_TLBWE: 64039  11299522  15.5430
7.668  1.20
EMUL_RFI: 95157   5771420   7.5060
2.108  0.86
 DEC:  290   49  16115786  54.4345
9.708  0.19
  EXTINT:7   74   75 

Re: [PATCH] kvm: powerpc: add exit timing statistics v3

2008-11-11 Thread Christian Ehrhardt
And btw -  the wiki page is updated with new versions of the exittimings 
using all of our new memory management improvements.
The page now also has some extended descriptions about the simple 
workloads used, holds the current version of the postprocessing script etc.


Christian Ehrhardt wrote:

From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update to v3*
- ensure build time optimization when calling exit accouting functions using
  build time bug / constant check
- migrate most of the exit timing code from powerpc.c and
  kvm_timing_stats.h to a separate exittiming.c file
- renamed a lot of constants used to better fit generic/core specific code
- added an accidenially removed optimization comment
- use pid of userspace process instead of an own atomic count to identify a vm
- changed loop labels in tul/tbu loops (booke_interrupt.S) to anonymous 1/1b
- removed the indirection of additional EMULATE_*_DONE types. Instead now
  the exit timing supports "accounting" an exit which consists of set type and
  increase kvm_stat counters. But also provides both sub-tasks as separate
  functions. Using that emulation now sets a default EMUL_INST type that can
  be overwritten by detailed subcategories (set_exit_type). Accouting for
  kvm_stat is done with account_exit_stat for all emulinst exits together on
  top level (as it was before).

*update to v2*
The update fixes accounting for sets to MSR[WE] which should not be accoutned
as instruction emulation. While adding that and analyzing the data it became
obvious that several types of emulations hould be accounted separately.
I'm not yet really happy with adding all these EMULATE_*_DONE types but I had
no better idea to not break flood the code with account calls and split
account/set_type. The issue is that emulation is also called e.g. for some mmio
paths and therefore the accouting should not be called inside emulation, but on
the returning path that can now evaluate the different kind of emulations done.
This is not yet finished, and posted as RFC only.

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

* another update in v3*
An updated awk script printing the data in a more narrow layout can be found
on our wiki pages about the exit timing topic.
(http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)
Here is a sample output how the results look like.
processing file timing_boot.log
sum of time 8309940
 typecount  min  max  sum  avg   
stddev %
MMIO: 9402   44 1997  1697610 180.5584  
155.768 20.43
 DCR:  680   41   9932096  47.2000
7.008  0.39
  SIGNAL:1   98   98   98  98.
0.000  0.00
ITLBREAL:  9268   14 7810   8.4341
0.658  0.09
ITLBVIRT: 3595   18  20276185  21.1919
4.954  0.92
DTLBREAL:  9508   16 8891   9.3589
1.427  0.11
DTLBVIRT: 6695   18  282   156727  23.4096   
13.781  1.89
 SYSCALL: 18016   5911372   6.3143
2.575  0.14
 ISI:  11668  764   6.5862
0.588  0.01
 DSI:   4367  292   6.7907
0.407  0.00
EMULINST:652477   96   484081   7.4192
1.818  5.83
   EMUL_WAIT:  801  659 9200  37217894646.4282 
1687.218 44.79
   EMUL_CORE:668067   86   540053   8.0839
1.895  6.50
  EMUL_MTSPR:134158   62   111358   8.3010
2.583  1.34
  EMUL_MFSPR: 76358   6162772   8.2216
1.921  0.76
  EMUL_MTMSR: 56788   5945704   8.0493
1.434  0.55
  EMUL_MFMSR:328537   67   267603   8.1455
1.875  3.22
  EMUL_TLBSX:  3549   60 3745  10.5791
3.919  0.05
  EMUL_TLBWE:  

[PATCH] kvm: powerpc: add exit timing statistics v3

2008-11-11 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update to v3*
- ensure build time optimization when calling exit accouting functions using
  build time bug / constant check
- migrate most of the exit timing code from powerpc.c and
  kvm_timing_stats.h to a separate exittiming.c file
- renamed a lot of constants used to better fit generic/core specific code
- added an accidenially removed optimization comment
- use pid of userspace process instead of an own atomic count to identify a vm
- changed loop labels in tul/tbu loops (booke_interrupt.S) to anonymous 1/1b
- removed the indirection of additional EMULATE_*_DONE types. Instead now
  the exit timing supports "accounting" an exit which consists of set type and
  increase kvm_stat counters. But also provides both sub-tasks as separate
  functions. Using that emulation now sets a default EMUL_INST type that can
  be overwritten by detailed subcategories (set_exit_type). Accouting for
  kvm_stat is done with account_exit_stat for all emulinst exits together on
  top level (as it was before).

*update to v2*
The update fixes accounting for sets to MSR[WE] which should not be accoutned
as instruction emulation. While adding that and analyzing the data it became
obvious that several types of emulations hould be accounted separately.
I'm not yet really happy with adding all these EMULATE_*_DONE types but I had
no better idea to not break flood the code with account calls and split
account/set_type. The issue is that emulation is also called e.g. for some mmio
paths and therefore the accouting should not be called inside emulation, but on
the returning path that can now evaluate the different kind of emulations done.
This is not yet finished, and posted as RFC only.

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

* another update in v3*
An updated awk script printing the data in a more narrow layout can be found
on our wiki pages about the exit timing topic.
(http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)
Here is a sample output how the results look like.
processing file timing_boot.log
sum of time 8309940
 typecount  min  max  sum  avg   
stddev %
MMIO: 9402   44 1997  1697610 180.5584  
155.768 20.43
 DCR:  680   41   9932096  47.2000
7.008  0.39
  SIGNAL:1   98   98   98  98.
0.000  0.00
ITLBREAL:  9268   14 7810   8.4341
0.658  0.09
ITLBVIRT: 3595   18  20276185  21.1919
4.954  0.92
DTLBREAL:  9508   16 8891   9.3589
1.427  0.11
DTLBVIRT: 6695   18  282   156727  23.4096   
13.781  1.89
 SYSCALL: 18016   5911372   6.3143
2.575  0.14
 ISI:  11668  764   6.5862
0.588  0.01
 DSI:   4367  292   6.7907
0.407  0.00
EMULINST:652477   96   484081   7.4192
1.818  5.83
   EMUL_WAIT:  801  659 9200  37217894646.4282 
1687.218 44.79
   EMUL_CORE:668067   86   540053   8.0839
1.895  6.50
  EMUL_MTSPR:134158   62   111358   8.3010
2.583  1.34
  EMUL_MFSPR: 76358   6162772   8.2216
1.921  0.76
  EMUL_MTMSR: 56788   5945704   8.0493
1.434  0.55
  EMUL_MFMSR:328537   67   267603   8.1455
1.875  3.22
  EMUL_TLBSX:  3549   60 3745  10.5791
3.919  0.05
  EMUL_TLBWE: 64039  11299522  15.5430
7.668  1.20
EMUL_RFI: 95157   5771420   7.5060
2.108  0.86
 DEC:  290   49  16115786  54.4345
9.708  0.19
  EXTINT:7   74   75 

[PATCH] kvm: powerpc: add exit timing statistics v2

2008-11-10 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*resend with header file in diff*

*update to v2*
The update fixes accounting for sets to MSR[WE] which should not be accoutned
as instruction emulation. While adding that and analyzing the data it became
obvious that several types of emulations hould be accounted separately.
I'm not yet really happy with adding all these EMULATE_*_DONE types but I had
no better idea to not break flood the code with account calls and split
account/set_type. The issue is that emulation is also called e.g. for some mmio
paths and therefore the accouting should not be called inside emulation, but on
the returning path that can now evaluate the different kind of emulations done.
This is not yet finished, and posted as RFC only.

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

Here is a sample output (after postprocessing with the awk script I'll post in 
reply to this patch) how the results look like.
sum of time 27504898
MMIO: count824 min 51 max555 sum
75825 sum_quad  9232871 avg  92.0206 stddev   52.318 %  
0.28
 DCR: count140 min 44 max 92 sum
 6746 sum_quad   327658 avg  48.1857 stddev4.307 %  
0.02
  SIGNAL: count  2 min309 max993 sum
 1302 sum_quad  1081530 avg 651. stddev  342.000 %  
0.00
ITLBREAL: count293 min 11 max 14 sum
 3515 sum_quad42175 avg  11.9966 stddev0.155 %  
0.01
ITLBVIRT: count 113822 min 20 max338 sum  
2595412 sum_quad 60256824 avg  22.8024 stddev3.074 
%  9.44
DTLBREAL: count242 min 11 max 14 sum
 2908 sum_quad34974 avg  12.0165 stddev0.352 %  
0.01
DTLBVIRT: count  66687 min 21 max329 sum  
1530048 sum_quad 35434926 avg  22.9437 stddev2.224 
%  5.56
 SYSCALL: count 72 min  9 max 10 sum
  649 sum_quad 5851 avg   9.0139 stddev0.117 %  
0.00
 ISI: count 56 min  9 max 10 sum
  506 sum_quad 4574 avg   9.0357 stddev0.186 %  
0.00
 DSI: count 49 min  9 max 10 sum
  448 sum_quad 4102 avg   9.1429 stddev0.350 %  
0.00
EMULINST: count 211220 min  7 max   7700 sum  
3292984 sum_quad   5797023806 avg  15.5903 stddev  164.931 
% 11.97
 DEC: count   6582 min 49 max322 sum   
367567 sum_quad 22996737 avg  55.8443 stddev   19.373 % 
 1.34
  EXTINT: count  4 min 79 max513 sum
  797 sum_quad   290423 avg 199.2500 stddev  181.398 %  
0.00
 TIMEINGUEST: count 33 min  0 max   3952 sum 
19626191 sum_quad  61148587807 avg  49.0663 stddev  387.900 
% 71.36

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 include/asm/kvm_host.h |   56 
 include/asm/kvm_ppc.h  |   16 +++-
 kernel/asm-offsets.c   |   11 +++
 kvm/44x_emulate.c  |   12 ++-
 kvm/44x_tlb.c  |4 -
 kvm/Kconfig|9 ++
 kvm/booke.c|   74 +++--
 kvm/booke.h|7 +-
 kvm/booke_interrupts.S |   24 ++
 kvm/powerpc.c  |  169 -
 10 files changed, 348 insertions(+), 34 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -71,7 +71,50 @@ struct kvmppc_44x_tlbe {
u32 word2;
 };
 
+enum kvm_exit_types {
+   MMI

[PATCH] kvm: powerpc: add exit timing statistics

2008-11-10 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Other existing kvm statistics are either just counters (kvm_stat) reported for
kvm generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

Here is a sample output (after postprocessing with the awk script I'll post in 
reply to this patch) how the results look like.
sum of time 27504898
MMIO: count824 min 51 max555 sum
75825 sum_quad  9232871 avg  92.0206 stddev   52.318 %  
0.28
 DCR: count140 min 44 max 92 sum
 6746 sum_quad   327658 avg  48.1857 stddev4.307 %  
0.02
  SIGNAL: count  2 min309 max993 sum
 1302 sum_quad  1081530 avg 651. stddev  342.000 %  
0.00
ITLBREAL: count293 min 11 max 14 sum
 3515 sum_quad42175 avg  11.9966 stddev0.155 %  
0.01
ITLBVIRT: count 113822 min 20 max338 sum  
2595412 sum_quad 60256824 avg  22.8024 stddev3.074 
%  9.44
DTLBREAL: count242 min 11 max 14 sum
 2908 sum_quad34974 avg  12.0165 stddev0.352 %  
0.01
DTLBVIRT: count  66687 min 21 max329 sum  
1530048 sum_quad 35434926 avg  22.9437 stddev2.224 
%  5.56
 SYSCALL: count 72 min  9 max 10 sum
  649 sum_quad 5851 avg   9.0139 stddev0.117 %  
0.00
 ISI: count 56 min  9 max 10 sum
  506 sum_quad 4574 avg   9.0357 stddev0.186 %  
0.00
 DSI: count 49 min  9 max 10 sum
  448 sum_quad 4102 avg   9.1429 stddev0.350 %  
0.00
EMULINST: count 211220 min  7 max   7700 sum  
3292984 sum_quad   5797023806 avg  15.5903 stddev  164.931 
% 11.97
 DEC: count   6582 min 49 max322 sum   
367567 sum_quad 22996737 avg  55.8443 stddev   19.373 % 
 1.34
  EXTINT: count  4 min 79 max513 sum
  797 sum_quad   290423 avg 199.2500 stddev  181.398 %  
0.00
 TIMEINGUEST: count 33 min  0 max   3952 sum 
19626191 sum_quad  61148587807 avg  49.0663 stddev  387.900 
% 71.36

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/include/asm/kvm_host.h |   49 
 arch/powerpc/include/asm/kvm_timing_stats.h |  168 
 arch/powerpc/include/asm/mmu-44x.h  |1
 arch/powerpc/kernel/asm-offsets.c   |   11 +
 arch/powerpc/kvm/Kconfig|9 +
 arch/powerpc/kvm/booke.c|   35 +++--
 arch/powerpc/kvm/booke.h|7 +
 arch/powerpc/kvm/booke_interrupts.S |   24 
 arch/powerpc/kvm/powerpc.c  |  162 ++-

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -71,7 +71,50 @@
u32 word2;
 };
 
+enum kvm_exit_types {
+   MMIO_EXITS,
+   DCR_EXITS,
+   SIGNAL_EXITS,
+   ITLB_REAL_MISS_EXITS,
+   ITLB_VIRT_MISS_EXITS,
+   DTLB_REAL_MISS_EXITS,
+   DTLB_VIRT_MISS_EXITS,
+   SYSCALL_EXITS,
+   ISI_EXITS,
+   DSI_EXITS,
+   EMULATED_INST_EXITS,
+   EMULATED_MTMSRWE_EXITS,
+   EMULATED_COREOP_EXITS,
+   EMULATED_COREMTSPR_EXITS,
+   EMULATED_COREMFSPR_EXITS,
+   EMULATED_COREMTMSR_EXITS,
+   EMULATED_TLBSX_EXITS,
+   EMULATED_TLBWE_EXITS,
+   EMULATED_RFI_EXITS,
+   DEC_EXITS,
+   EXT_INTR_EXITS,
+   HALT_WAKEUP,
+   USR_PR_INST,
+   FP_UNAVAIL,
+   DEBUG_EXITS,
+   TIMEINGUEST,
+   __NUMBER_OF_KVM_EXI

Re: [PATCH] [mq]: fix-kvm-init.diff

2008-11-10 Thread Christian Ehrhardt

sorry - this should actually have some description ...
I'll resend it with one as soon as I find the issue why it is missing

Ehrhardt Christian wrote:

diff --git a/qemu/target-ppc/helper.c b/qemu/target-ppc/helper.c
--- a/qemu/target-ppc/helper.c
+++ b/qemu/target-ppc/helper.c
@@ -2959,10 +2959,8 @@
 env->cpu_model_str = cpu_model;
 cpu_ppc_register_internal(env, def);
 cpu_ppc_reset(env);
-#ifdef USE_KVM
 if (kvm_enabled())
-   kvm_init_new_ap(env->cpu_index, env);
-#endif
+   kvm_init_vcpu(env);
 return env;
 }

  



--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [mq]: fix-kvm-init.diff

2008-11-10 Thread Ehrhardt Christian
diff --git a/qemu/target-ppc/helper.c b/qemu/target-ppc/helper.c
--- a/qemu/target-ppc/helper.c
+++ b/qemu/target-ppc/helper.c
@@ -2959,10 +2959,8 @@
 env->cpu_model_str = cpu_model;
 cpu_ppc_register_internal(env, def);
 cpu_ppc_reset(env);
-#ifdef USE_KVM
 if (kvm_enabled())
-   kvm_init_new_ap(env->cpu_index, env);
-#endif
+   kvm_init_vcpu(env);
 return env;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Exit timing - results online

2008-11-10 Thread Christian Ehrhardt

Hollis Blanchard wrote:

On Thu, 2008-11-06 at 12:25 +0100, Christian Ehrhardt wrote:
  

Hi,
I just added the following page to our wiki based online documentation 
to show some numbers on kvmppc as of today.

You can find that page at thew wiki entry:
  PowerPC_Exittimings 
<http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings> - an overview of 
workload dependent overhead on non hardware assisted powerpc virtualization

  (http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)



Very interesting; thanks for putting these numbers together Christian.

I'm interested by the instruction emulation, which shows up as the
highest cost in every workload. That suggests that even small
improvements to the emulation path, such as using a better lookup than
nested switch statements, could have a significant effect on throughput.

It's also interesting that the average is really close to the minimum,
but the standard deviation is huge. That suggests that the vast majority
of exits take the minimum amount of time, but a few exits take a *ton*
of time. Looking through the set of instructions we emulate on 440, it
looks like the only even slightly sophisticated ones are rfi, tlbwe, and
tlbsx...

  
Yeah I extended my patch a bit to now account several different 
subcategories of the emulation.
One issue was that a idling guest setting MSR[WE] came via the emulation 
path and recorded all the time a kvm_block waited until there was work 
for the cpu.


I updated the numbers on the wiki page on Friday.

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Exit timing - results online

2008-11-06 Thread Christian Ehrhardt

Hi,
I just added the following page to our wiki based online documentation 
to show some numbers on kvmppc as of today.

You can find that page at thew wiki entry:
 PowerPC_Exittimings 
<http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings> - an overview of 
workload dependent overhead on non hardware assisted powerpc virtualization

 (http://kvm.qumranet.com/kvmwiki/PowerPC_Exittimings)

Currently this page covers a brief introduction, workload description, 
exit timings and an example of paravirtualization improvement.


There is no "interpretation" of that data on the page yet.
I think I add some explanations and theories why you can see which 
effect there once I chatted with a few involved people.

I welcome everyone to discuss with us on the list about that too.

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [PATCH] kvm: powerpc: add exit timing statistics

2008-11-04 Thread Christian Ehrhardt
This patch reports the square sum in addition to the classic sum/count 
(+min/max) to allow more details statistical post processing.
That way you can process average, % of whole duration and using the 
square sum also the standard deviation.


A simple way to get these numbers with awk is:

#!/bin/bash
echo "processing file ${1}"
sumsum=`awk 'BEGIN { csum=0; sumsum=0; count=0}{ csum=csum+$3; count++; 
sumsum = sumsum+$9;}END { printf("%s\n", sumsum)}' $1`

echo "sum of time ${sumsum}"
awk '!/count  0/ { printf("%s",$0); printf(" avg %16.4lf stddev 
%12.3lf %% %5.2f\n",$9/$3, sqrt($11/$3-(($9/$3)*($9/$3))), 
($9/('$sumsum'/100))); }' $1


This runs awk twice, because for % of overall time you need the sum the 
durations and I personally don't like all those "rewind hacks" for awk.


Ehrhardt Christian wrote:

From: Christian Ehrhardt <[EMAIL PROTECTED]>

Other existing kvm stats are either just counters (kvm_stat) reported for kvm
generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

Here is a sample output (after postprocessing with the awk script I'll post in 
reply to this patch) how the results look like.
sum of time 27504898
MMIO: count824 min 51 max555 sum
75825 sum_quad  9232871 avg  92.0206 stddev   52.318 %  
0.28
 DCR: count140 min 44 max 92 sum
 6746 sum_quad   327658 avg  48.1857 stddev4.307 %  
0.02
  SIGNAL: count  2 min309 max993 sum
 1302 sum_quad  1081530 avg 651. stddev  342.000 %  
0.00
ITLBREAL: count293 min 11 max 14 sum
 3515 sum_quad42175 avg  11.9966 stddev0.155 %  
0.01
ITLBVIRT: count 113822 min 20 max338 sum  
2595412 sum_quad 60256824 avg  22.8024 stddev3.074 
%  9.44
DTLBREAL: count242 min 11 max 14 sum
 2908 sum_quad34974 avg  12.0165 stddev0.352 %  
0.01
DTLBVIRT: count  66687 min 21 max329 sum  
1530048 sum_quad 35434926 avg  22.9437 stddev2.224 
%  5.56
 SYSCALL: count 72 min  9 max 10 sum
  649 sum_quad 5851 avg   9.0139 stddev0.117 %  
0.00
 ISI: count 56 min  9 max 10 sum
  506 sum_quad 4574 avg   9.0357 stddev0.186 %  
0.00
 DSI: count 49 min  9 max 10 sum
  448 sum_quad 4102 avg   9.1429 stddev0.350 %  
0.00
EMULINST: count 211220 min  7 max   7700 sum  
3292984 sum_quad   5797023806 avg  15.5903 stddev  164.931 
% 11.97
 DEC: count   6582 min 49 max322 sum   
367567 sum_quad 22996737 avg  55.8443 stddev   19.373 % 
 1.34
  EXTINT: count  4 min 79 max513 sum
  797 sum_quad   290423 avg 199.2500 stddev  181.398 %  
0.00
 TIMEINGUEST: count 33 min  0 max   3952 sum 
19626191 sum_quad  61148587807 avg  49.0663 stddev  387.900 
% 71.36

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/include/asm/kvm_host.h |   49 
 arch/powerpc/include/asm/kvm_timing_stats.h |  142 
 arch/powerpc/include/asm/mmu-44x.h  |1
 arch/powerpc/kernel/asm-offsets.c   |   11 +
 arch/powerpc/kvm/Kconfig|9 +
 arch/powerpc/kvm/booke.c|   35 +++---
 arch/powerpc/kvm/booke.h|7 +
 arch/powerpc/kvm/booke_interrupts.S |   24 
 arch/powerpc/kvm/powerpc.c  |  163 +++-
 9 files changed, 4

[PATCH] [PATCH] kvm: powerpc: add exit timing statistics

2008-11-04 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Other existing kvm stats are either just counters (kvm_stat) reported for kvm
generally or trace based aproaches like kvm_trace.
For kvm on powerpc we had the need to track the timings of the different exit
types. While this could be achieved parsing data created with a kvm_trace
extension this adds too muhc overhead (at least on embedded powerpc) slowing
down the workloads we wanted to measure.

Therefore this patch adds a in kernel exit timing statistic to the powerpc kvm
code. These statistic is available per vm&vcpu under the kvm debugfs directory.
As this statistic is low, but still some overhead it can be enabled via a
.config entry and should be off by default.

Since this patch touched all powerpc kvm_stat code anyway this code is now
merged and simpliefied together with the exit timing statistic code (still
working with exit timing disabled in .config).

Here is a sample output (after postprocessing with the awk script I'll post in 
reply to this patch) how the results look like.
sum of time 27504898
MMIO: count824 min 51 max555 sum
75825 sum_quad  9232871 avg  92.0206 stddev   52.318 %  
0.28
 DCR: count140 min 44 max 92 sum
 6746 sum_quad   327658 avg  48.1857 stddev4.307 %  
0.02
  SIGNAL: count  2 min309 max993 sum
 1302 sum_quad  1081530 avg 651. stddev  342.000 %  
0.00
ITLBREAL: count293 min 11 max 14 sum
 3515 sum_quad42175 avg  11.9966 stddev0.155 %  
0.01
ITLBVIRT: count 113822 min 20 max338 sum  
2595412 sum_quad 60256824 avg  22.8024 stddev3.074 
%  9.44
DTLBREAL: count242 min 11 max 14 sum
 2908 sum_quad34974 avg  12.0165 stddev0.352 %  
0.01
DTLBVIRT: count  66687 min 21 max329 sum  
1530048 sum_quad 35434926 avg  22.9437 stddev2.224 
%  5.56
 SYSCALL: count 72 min  9 max 10 sum
  649 sum_quad 5851 avg   9.0139 stddev0.117 %  
0.00
 ISI: count 56 min  9 max 10 sum
  506 sum_quad 4574 avg   9.0357 stddev0.186 %  
0.00
 DSI: count 49 min  9 max 10 sum
  448 sum_quad 4102 avg   9.1429 stddev0.350 %  
0.00
EMULINST: count 211220 min  7 max   7700 sum  
3292984 sum_quad   5797023806 avg  15.5903 stddev  164.931 
% 11.97
 DEC: count   6582 min 49 max322 sum   
367567 sum_quad 22996737 avg  55.8443 stddev   19.373 % 
 1.34
  EXTINT: count  4 min 79 max513 sum
  797 sum_quad   290423 avg 199.2500 stddev  181.398 %  
0.00
 TIMEINGUEST: count 33 min  0 max   3952 sum 
19626191 sum_quad  61148587807 avg  49.0663 stddev  387.900 
% 71.36

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/include/asm/kvm_host.h |   49 
 arch/powerpc/include/asm/kvm_timing_stats.h |  142 
 arch/powerpc/include/asm/mmu-44x.h  |1
 arch/powerpc/kernel/asm-offsets.c   |   11 +
 arch/powerpc/kvm/Kconfig|9 +
 arch/powerpc/kvm/booke.c|   35 +++---
 arch/powerpc/kvm/booke.h|7 +
 arch/powerpc/kvm/booke_interrupts.S |   24 
 arch/powerpc/kvm/powerpc.c  |  163 +++-
 9 files changed, 425 insertions(+), 16 deletions(-)

[diff]

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -71,7 +71,43 @@
u32 word2;
 };
 
+enum kvm_exit_types {
+   MMIO_EXITS,
+   DCR_EXITS,
+   SIGNAL_EXITS,
+   ITLB_REAL_MISS_EXITS,
+   ITLB_VIRT_MISS_EXITS,
+   DTLB_REAL_MISS_EXITS,
+   DTLB_VIRT_MISS_EXITS,
+   SYSCALL_EXITS,
+   ISI_EXITS,
+   DSI_EXITS,
+   EMULATED_INST_EXITS,
+   EMULATED_MTMSRWE_EXITS,
+   DEC_EXITS,
+   EXT_INTR_EXITS,
+   HALT_WAKEUP,
+   USR_PR_INST,
+   FP_UNAVAIL,
+   DEBUG_EXITS,
+   TIMEINGUEST,
+   __NUMBER_OF_KVM_EXIT_TYPES
+};
+
+#ifdef CONFIG_KVM_BOOKE_EXIT_TIMING
+/* allow access to big endian 32bit upper/lower parts and 64bit var */
+typedef union {
+   u64

[PATCH] kvm-userspace: add ibm archs to unifdef header

2008-11-03 Thread Ehrhardt Christian
This adds powerpc to the unifdef header avi introduced.
I think s390 should work the same way and is needed as they have libkvm already.
Christian/Carsten could you ack that after a quick test if it is working?

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 unifdef.h |   12 
 1 file changed, 12 insertions(+)

[diff]

diff --git a/kernel/unifdef.h b/kernel/unifdef.h
--- a/kernel/unifdef.h
+++ b/kernel/unifdef.h
@@ -25,4 +25,16 @@
 #endif
 #endif
 
+#ifdef __PPC__
+#ifndef CONFIG_PPC
+#define CONFIG_PPC 1
 #endif
+#endif
+
+#ifdef __s390__
+#ifndef CONFIG_S390
+#define CONFIG_S390 1
+#endif
+#endif
+
+#endif
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvm-userspace: move x86 specific calls introduced by device assignement to x86 files

2008-11-03 Thread Ehrhardt Christian
The device asignment patches added the x86 specific ioperm in qemu-kvm.
This patch moves
  qemu-kvm.c:kvm_do_ioperm()
to
  qemu-kvm-x86.c:kvm_arch_do_ioperm()
The patch also changes the qemu-kvm header and the includes according to that.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 qemu-kvm-x86.c |7 +++
 qemu-kvm.c |   11 +++
 qemu-kvm.h |3 +++
 3 files changed, 13 insertions(+), 8 deletions(-)

[diff]

diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
--- a/qemu/qemu-kvm-x86.c
+++ b/qemu/qemu-kvm-x86.c
@@ -11,6 +11,7 @@
 
 #include 
 #include "hw/hw.h"
+#include 
 
 #include "qemu-kvm.h"
 #include 
@@ -717,3 +718,9 @@
}
 }
 }
+
+void kvm_arch_do_ioperm(void *_data)
+{
+struct ioperm_data *data = _data;
+ioperm(data->start_port, data->num, data->turn_on);
+}
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #define bool _Bool
 #define false 0
@@ -1049,14 +1048,10 @@
 return kvm_unregister_coalesced_mmio(kvm_context, addr, size);
 }
 
-static void kvm_do_ioperm(void *_data)
-{
-struct ioperm_data *data = _data;
-ioperm(data->start_port, data->num, data->turn_on);
-}
-
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
 void kvm_ioperm(CPUState *env, void *data)
 {
 if (kvm_enabled() && qemu_system_ready)
-   on_vcpu(env, kvm_do_ioperm, data);
+   on_vcpu(env, kvm_arch_do_ioperm, data);
 }
+#endif
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -93,7 +93,10 @@
 
 void qemu_kvm_system_reset_request(void);
 
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
 void kvm_ioperm(CPUState *env, void *data);
+void kvm_arch_do_ioperm(void *_data);
+#endif
 
 #ifdef TARGET_PPC
 int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0 of 7] kvm-userspace: support multiple processors in the same architecture

2008-10-30 Thread Christian Ehrhardt

Hollis Blanchard wrote:

These patches allow the kvmctl bits (including testcases and libcflat) to be
built for multiple processor types within the same architecture (e.g. 440 and
e500). This is important because PowerPC supervisor mode can contain
significant differences between processors (it's user mode that's more or less
identical).

For example, the data in a TLB entry and how to manipulate the TLB
are a major difference between 440 and e500, which is critical here because
libcflat must create its own mappings and so must know which method to use.

Some of the complexity comes from user/Makefile *not* using the top-level
config.mak, so we have to add some of the same logic to both configure scripts
to generate both config.mak files.

Too much makefile logic depends on ARCH containing only the architecture
name, so it was simpler to create and export a separate PROCESSOR variable.

-Hollis
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Unfortunately there is too often no "really nice" way to do Makefile 
magic :-)

I know you started with the arch-platform-os-compiler after our discussion,
but I like the $PROCESSOR solution for our *powerpc* Makefiles too.
And a good catch with that AR usage in patch 7.

(full series)
Acked-by: Christian Ehrhardt <[EMAIL PROTECTED]>

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03 of 10] [PATCH] user: ppc: better error reporting in load_file

2008-10-29 Thread Christian Ehrhardt

Avi Kivity wrote:

Ehrhardt Christian wrote:

From: Hollis Blanchard <[EMAIL PROTECTED]>

Fancy description.
  


Ahem.


Sorry that is my patch template description :-/
A proper description header should be:

Subject: [PATCH] user: ppc: better error reporting in load_file

From: Hollis Blanchard <[EMAIL PROTECTED]>

This patch adds a better error reporting for powerpc testcases.
It prints the bytes read in load_file so far until an error occured.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
main-ppc.c |3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

[diff]

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [PATCH] qemu: ppc: xer access prototypes no more used & implemented

2008-10-28 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Revision 5500 of the qemu repository removed all code using
ppc_load_xer & ppc_store_xer as well as their implementation.

Another patch fixes it's usage in kvm-userspace for powerpc, but I think
that header can now be cleaned up, therefore this patch to qemu-devel.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 cpu.h |2 --
 1 file changed, 2 deletions(-)

[diff]

diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -725,8 +725,6 @@
 #endif
 void do_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
-target_ulong ppc_load_xer (CPUPPCState *env);
-void ppc_store_xer (CPUPPCState *env, target_ulong value);
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
 
 void cpu_ppc_reset (void *opaque);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05 of 10] [PATCH] libcflat: ppc: add timebase accessor

2008-10-28 Thread Ehrhardt Christian
Provide a timebase accessor for ppc testcases.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>

[diffstat]
 config-powerpc-44x.mak  |3 ++-
 test/lib/powerpc/44x/timebase.S |   28 
 test/lib/powerpc/44x/timebase.h |   25 +
 3 files changed, 55 insertions(+), 1 deletion(-)

[diff]

diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak
--- a/user/config-powerpc-44x.mak
+++ b/user/config-powerpc-44x.mak
@@ -5,7 +5,8 @@
 
 cflatobjs += \
test/lib/powerpc/44x/map.o \
-   test/lib/powerpc/44x/tlbwe.o
+   test/lib/powerpc/44x/tlbwe.o \
+   test/lib/powerpc/44x/timebase.o
 
 simpletests += \
test/powerpc/44x/tlbsx.bin \
diff --git a/user/test/lib/powerpc/44x/timebase.S 
b/user/test/lib/powerpc/44x/timebase.S
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/timebase.S
@@ -0,0 +1,28 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <[EMAIL PROTECTED]>
+ */
+
+/* unsigned long long mftb(void); */
+.global mftb
+mftb:
+   mftbu   r5
+   mftbl   r4
+   mftbu   r3
+   cmpwr3, r5
+   bne mftb
+   blr
diff --git a/user/test/lib/powerpc/44x/timebase.h 
b/user/test/lib/powerpc/44x/timebase.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/timebase.h
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <[EMAIL PROTECTED]>
+ */
+
+#ifndef __TIMEBASE_H__
+#define __TIMEBASE_H__
+
+unsigned long long mftb(void);
+
+#endif /* __TIMEBASE_H__ */
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04 of 10] [PATCH] user: ppc: implement PowerPC 44x libcflat

2008-10-28 Thread Ehrhardt Christian
From: Hollis Blanchard <[EMAIL PROTECTED]>

- Create a 44x-specific makefile.
- Reorganize PowerPC makefiles to separate "simple" tests from those which
  link with libcflat.
- Create a minimal libcflat testcase (which just exits).

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 config-powerpc-44x.mak   |   14 +++
 config-powerpc.mak   |   46 ++
 test/lib/powerpc/44x/map.c   |   51 +++
 test/lib/powerpc/44x/tlbwe.S |   29 
 test/lib/powerpc/io.c|   35 +
 test/powerpc/cstart.S|   38 
 test/powerpc/exit.c  |   23 +++
 7 files changed, 221 insertions(+), 15 deletions(-)

[diff]

diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak
new file mode 100644
--- /dev/null
+++ b/user/config-powerpc-44x.mak
@@ -0,0 +1,14 @@
+
+
+# for some reason binutils hates tlbsx unless we say we're 405  :(
+CFLAGS += -Wa,-m405 -I test/lib/powerpc/44x
+
+cflatobjs += \
+   test/lib/powerpc/44x/map.o \
+   test/lib/powerpc/44x/tlbwe.o
+
+simpletests += \
+   test/powerpc/44x/tlbsx.bin \
+   test/powerpc/44x/tlbwe_16KB.bin \
+   test/powerpc/44x/tlbwe_hole.bin \
+   test/powerpc/44x/tlbwe.bin
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,26 +1,42 @@
+platform := 44x
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
-# for some reaons binutils hates tlbsx unless we say we're 405  :(
-CFLAGS += -Wa,-mregnames,-m405
+CFLAGS += -Wa,-mregnames -I test/lib
 
-%.bin: %.o
-   $(OBJCOPY) -O binary $^ $@
+cstart := test/powerpc/cstart.o
 
-testobjs := \
-   io.bin \
-   spin.bin \
-   sprg.bin \
-   44x/tlbsx.bin \
-   44x/tlbwe_16KB.bin \
-   44x/tlbwe_hole.bin \
-   44x/tlbwe.bin
+cflatobjs += \
+   test/lib/powerpc/io.o
 
-tests := $(addprefix test/powerpc/, $(testobjs))
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding
 
-all: kvmtrace kvmctl $(tests)
+# these tests do not use libcflat
+simpletests := \
+   test/powerpc/spin.bin \
+   test/powerpc/io.bin \
+   test/powerpc/sprg.bin
+
+# theses tests use cstart.o, libcflat, and libgcc
+tests := \
+   test/powerpc/exit.bin
+
+include config-powerpc-$(platform).mak
+
+
+all: kvmtrace kvmctl $(libcflat) $(simpletests) $(tests)
+
+$(simpletests): %.bin: %.o
+   $(CC) -nostdlib $^ -Wl,-T,flat.lds -o $@
+
+$(tests): %.bin: $(cstart) %.o $(libcflat)
+   $(CC) -nostdlib $^ $(libgcc) -Wl,-T,flat.lds -o $@
 
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-   rm -f $(tests)
+   $(RM) $(simpletests) $(tests) $(cstart)
+   $(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests))
+   $(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests))
diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/map.c
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <[EMAIL PROTECTED]>
+ */
+
+#include "libcflat.h"
+
+#define TLB_SIZE 64
+
+extern void tlbwe(unsigned int index,
+ unsigned char tid,
+ unsigned int word0,
+ unsigned int word1,
+ unsigned int word2);
+
+unsigned int next_free_index;
+
+#define PAGE_SHIFT 12
+#define PAGE_MASK (~((1<= TLB_SIZE)
+   panic("TLB overflow");
+
+   w0 = (vaddr & PAGE_MASK) | V;
+   w1 = paddr & PAGE_MASK;
+   w2 = 0x3;
+
+   tlbwe(next_free_index, 0, w0, w1, w2);
+}
diff --git a/user/test/lib/powerpc/44x/tlbwe.S 
b/user/test/lib/powerpc/44x/tlbwe.S
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/tlbwe.S
@@ -0,0 +1,29 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope tha

[PATCH 10 of 10] [PATCH] kvm-userspace: ppc: fix initial ppc memory setup

2008-10-28 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

The old memory initialization code was broken for all cases not fitting in one
ram stick. This patch fixes the ram_stick calculation, now sets the proper
base adresses per stick and removes the old workaround.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 ppc440.c|   12 +---
 ppc440.h|8 ++--
 ppc440_bamboo.c |   30 --
 3 files changed, 31 insertions(+), 19 deletions(-)

[diff]

diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c
--- a/qemu/hw/ppc440.c
+++ b/qemu/hw/ppc440.c
@@ -3,6 +3,7 @@
  *
  * Copyright 2007 IBM Corporation.
  * Authors: Jerone Young <[EMAIL PROTECTED]>
+ * Christian Ehrhardt <[EMAIL PROTECTED]>
  *
  * This work is licensed under the GNU GPL license version 2 or later.
  *
@@ -24,15 +25,15 @@
 
 
 void ppc440ep_init(CPUState *env,
-   target_phys_addr_t ram_bases[2],
-   target_phys_addr_t ram_sizes[2],
+   target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS],
+   target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS],
+   int nbanks,
qemu_irq **picp,
ppc4xx_pci_t **pcip,
int do_init)
 {
ppc4xx_mmio_t *mmio;
qemu_irq *pic, *irqs;
-   ram_addr_t offset;
ppc4xx_pci_t *pci;
int i;
 
@@ -55,10 +56,7 @@
/* SDRAM controller */
printf("trying to setup sdram controller\n");
/* XXX 440EP's ECC interrupts are on UIC1 */
-   ppc405_sdram_init(env, pic[14], 2, ram_bases, ram_sizes, do_init);
-   offset = 0;
-   for (i = 0; i < 2; i++)
-   offset += ram_sizes[i];
+   ppc405_sdram_init(env, pic[14], nbanks, ram_bases, ram_sizes, do_init);
 
/* PCI */
pci = ppc4xx_pci_init(env, pic,
diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h
--- a/qemu/hw/ppc440.h
+++ b/qemu/hw/ppc440.h
@@ -3,6 +3,7 @@
  *
  * Copyright 2007 IBM Corporation.
  * Authors: Jerone Young <[EMAIL PROTECTED]>
+ * Christian Ehrhardt <[EMAIL PROTECTED]>
  *
  * This work is licensed under the GNU GPL licence version 2 or later
  *
@@ -20,9 +21,12 @@
 #include "exec-all.h"
 #include "boards.h"
 
+#define PPC440_MAX_RAM_SLOTS 4
+
 void ppc440ep_init(CPUState *env,
-   target_phys_addr_t ram_bases[2],
-   target_phys_addr_t ram_sizes[2],
+   target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS],
+   target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS],
+   int nbanks,
qemu_irq **picp,
ppc4xx_pci_t **pcip,
int do_init);
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
@@ -2,7 +2,9 @@
  * Qemu PowerPC 440 board emualtion
  *
  * Copyright 2007 IBM Corporation.
- * Authors: Jerone Young <[EMAIL PROTECTED]>
+ * Authors:
+ * Jerone Young <[EMAIL PROTECTED]>
+ * Christian Ehrhardt <[EMAIL PROTECTED]>
  *
  * This work is licensed under the GNU GPL license version 2 or later.
  *
@@ -30,7 +32,8 @@
const char *cpu_model)
 {
char *buf=NULL;
-   target_phys_addr_t ram_bases[4], ram_sizes[4];
+   target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS];
+   target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS];
NICInfo *nd;
qemu_irq *pic;
ppc4xx_pci_t *pci;
@@ -46,6 +49,8 @@
int ret;
int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20,
32<<20, 16<<20, 8<<20 }; /* in bytes */
+   int nbanks = 0; /* number of used memory banks */
+   int next_bank_offset = 0;
ram_addr_t tmp_ram_size;
int i=0, k=0;
uint32_t cpu_freq;
@@ -55,15 +60,22 @@
printf("%s: START\n", __func__);
 
/* Setup Memory */
-   printf("Ram size passed is: %i MB\n",
-   bytes_to_mb((int)ram_size));
+   if (ram_size < 8<<20) {
+   printf("ERROR: ram size too small (min 8mb)\n");
+   exit(1);
+   } else
+   printf("Ram size passed is: %i MB\n",
+   bytes_to_mb((int)ram_size));
 
tmp_ram_size = ram_size;
 
-   for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) {
-   for (k=0; k < 
(sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) {
+   for (i = 0; i < PPC440_MAX_RAM_SLOTS; i++) {
+   for (k = 0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) {
if ((tmp_ram_size/ram_stick_sizes[k]) > 0) {
ram_sizes[i] = ram_stick_sizes[k];
+   ram_bases[i] = next_bank_offset;
+  

[PATCH 08 of 10] [PATCH] qemu: ppc: if not a uImage, try to load kernel as ELF

2008-10-28 Thread Ehrhardt Christian
From: Hollis Blanchard <[EMAIL PROTECTED]>

This allows qemu to load "bare metal" ELF kernels, useful for standalone
benchmarks and testcases.

We could/should also load the specified file as a flat binary, if both uImage
and ELF loaders fail. (See hw/arm_boot.c.)

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 ppc440_bamboo.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

[diff]

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
@@ -35,8 +35,8 @@
qemu_irq *pic;
ppc4xx_pci_t *pci;
CPUState *env;
-   target_ulong ep=0;
-   target_ulong la=0;
+   uint64_t ep=0;
+   uint64_t la=0;
int is_linux=1; /* Will assume allways is Linux for now */
target_long kernel_size=0;
target_ulong initrd_base=0;
@@ -97,6 +97,9 @@
/* load kernel with uboot loader */
printf("%s: load kernel\n", __func__);
ret = load_uimage(kernel_filename, &ep, &la, &kernel_size, &is_linux);
+   if (ret < 0)
+   ret = load_elf(kernel_filename, 0, &ep, &la, NULL);
+
if (ret < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02 of 10] [PATCH] user: ppc: fix threading bugs in main-ppc.c

2008-10-28 Thread Ehrhardt Christian
From: Hollis Blanchard <[EMAIL PROTECTED]>

- call io_table_register() before any vcpus have started
- wait for all vcpus to exit before exiting the parent thread

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 main-ppc.c |   32 
 1 file changed, 12 insertions(+), 20 deletions(-)

[diff]

diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -51,7 +51,7 @@
 struct io_table mmio_table;
 
 static int ncpus = 1;
-static sem_t init_sem;
+static sem_t exited_sem;
 static __thread int vcpu;
 static sigset_t kernel_sigmask;
 static sigset_t ipi_sigmask;
@@ -220,16 +220,8 @@
asm volatile ("sync; isync");
 }
 
-static void init_vcpu(int n, unsigned long entry)
+static void init_vcpu(int n)
 {
-   /* XXX must set initial TLB state and stack
-   struct kvm_regs regs = {
-   .pc = entry,
-   };
-
-   kvm_set_regs(kvm, 0, ®s);
-   */
-
sigemptyset(&ipi_sigmask);
sigaddset(&ipi_sigmask, IPI_SIGNAL);
sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL);
@@ -237,7 +229,6 @@
vcpus[n].tid = gettid();
vcpu = n;
kvm_set_signal_mask(kvm, n, &kernel_sigmask);
-   sem_post(&init_sem);
 }
 
 static void *do_create_vcpu(void *_n)
@@ -245,8 +236,9 @@
int n = (long)_n;
 
kvm_create_vcpu(kvm, n);
-   init_vcpu(n, 0x0);
+   init_vcpu(n);
kvm_run(kvm, n);
+   sem_post(&exited_sem);
return NULL;
 }
 
@@ -368,14 +360,14 @@
len = load_file(vm_mem, argv[optind], 1);
sync_caches(vm_mem, len);
 
-   sem_init(&init_sem, 0, 0);
-   init_vcpu(0, 0x0);
-   for (i = 1; i < ncpus; ++i)
-   start_vcpu(i);
-   for (i = 0; i < ncpus; ++i)
-   sem_wait(&init_sem);
-
io_table_register(&mmio_table, 0xf000, 64, mmio_handler, NULL);
 
-   return kvm_run(kvm, 0);
+   sem_init(&exited_sem, 0, 0);
+   for (i = 0; i < ncpus; ++i)
+   start_vcpu(i);
+   /* Wait for all vcpus to exit. */
+   for (i = 0; i < ncpus; ++i)
+   sem_wait(&exited_sem);
+
+   return 0;
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07 of 10] [PATCH] qemu: ppc: define maximum SMP limit as 1 for Bamboo

2008-10-28 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Fix for qemu runtime error. Full error message:
Number of SMP cpus requested (1), exceeds max cpus supported by machine 
`bamboo' (0)

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
---

[diffstat]
 ppc440_bamboo.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

[diff]

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
@@ -202,7 +202,8 @@
 }
 
 QEMUMachine bamboo_machine = {
-   "bamboo",
-   "bamboo",
-   bamboo_init,
+   .name = "bamboo",
+   .desc = "bamboo",
+   .init = bamboo_init,
+   .max_cpus = 1,
 };
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06 of 10] [PATCH] user: ppc: add stub nmi handler

2008-10-28 Thread Ehrhardt Christian
From: Hollis Blanchard <[EMAIL PROTECTED]>

Adding a nmi stub handler for user/main-ppc.c

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 main-ppc.c |6 ++
 1 file changed, 6 insertions(+)

[diff]

diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -83,6 +83,11 @@
 }
 
 static int test_try_push_interrupts(void *opaque)
+{
+   return 0;
+}
+
+static int test_try_push_nmi(void *opaque)
 {
return 0;
 }
@@ -175,6 +180,7 @@
.halt= test_halt,
.io_window = test_io_window,
.try_push_interrupts = test_try_push_interrupts,
+   .try_push_nmi = test_try_push_nmi,
.post_kvm_run = test_post_kvm_run,
.pre_kvm_run = test_pre_kvm_run,
.powerpc_dcr_read = test_dcr_read,
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03 of 10] [PATCH] user: ppc: better error reporting in load_file

2008-10-28 Thread Ehrhardt Christian
From: Hollis Blanchard <[EMAIL PROTECTED]>

Fancy description.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 main-ppc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

[diff]

diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -183,7 +183,7 @@
 
 static unsigned long load_file(void *mem, const char *fname, int inval_icache)
 {
-   int r;
+   ssize_t r;
int fd;
unsigned long bytes = 0;
 
@@ -200,6 +200,7 @@
 
if (r == -1) {
perror("read");
+   printf("read %d bytes\n", bytes);
exit(1);
}
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09 of 10] [PATCH] kvm: external module: Treat NONARCH_CONFIG as a list

2008-10-28 Thread Ehrhardt Christian
From: Hollis Blanchard <[EMAIL PROTECTED]

As discussed on the list the unifdef changes break powerpc (and more ?). A fix
is to treat NONARCH_CONFIG as a list instead of a single item.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 Makefile |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

[diff]

diff --git a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -25,8 +25,9 @@
gawk -v version=$(version) -f $(ARCH_DIR)/hack-module.awk $1.orig \
| sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
+unifdef_uflags = $(foreach arch, $(NONARCH_CONFIG), -UCONFIG_$(arch))
 unifdef = mv $1 $1.orig && \
- unifdef -DCONFIG_$(ARCH_CONFIG) -UCONFIG_$(NONARCH_CONFIG) $1.orig > 
$1; \
+ unifdef -DCONFIG_$(ARCH_CONFIG) $(unifdef_uflags) $1.orig > $1; \
   [ $$? -le 2 ] && rm $1.orig
 
 hack = $(call _hack,$T/$(strip $1))
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00 of 10] kvm-userspace: ppc: userspace fixes for powerpc

2008-10-28 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This is a set of various fixes in kvm-userspace for powerpc. This time without
the split between user/* and the rest and without the qemu patch (sent
separate to qemu-devel now).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>

b/kernel/Makefile  |3 +
b/qemu/hw/ppc440.c |   12 +++
b/qemu/hw/ppc440.h |8 +++--
b/qemu/hw/ppc440_bamboo.c  |7 ++--
b/qemu/qemu-kvm-powerpc.c  |4 +-
b/user/config-powerpc-44x.mak  |   14 +
b/user/config-powerpc.mak  |   46 -
b/user/main-ppc.c  |   32 +++-
b/user/test/lib/powerpc/44x/map.c  |   51 +
b/user/test/lib/powerpc/44x/timebase.S |   28 ++
b/user/test/lib/powerpc/44x/timebase.h |   25 
b/user/test/lib/powerpc/44x/tlbwe.S|   29 ++
b/user/test/lib/powerpc/io.c   |   35 ++
b/user/test/powerpc/cstart.S   |   38 
b/user/test/powerpc/exit.c |   23 ++
qemu/hw/ppc440_bamboo.c|   36 +++
user/config-powerpc-44x.mak|3 +
user/main-ppc.c|9 +
18 files changed, 339 insertions(+), 64 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01 of 10] [PATCH] kvm-userspace: powerpc: fix env->xer access

2008-10-28 Thread Ehrhardt Christian
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Since qemu revision 5500 which was merged with the last qemu merge env->xer
is accessed directly.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 qemu-kvm-powerpc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

[diff]

diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -57,7 +57,7 @@
 
 regs.ctr = env->ctr;
 regs.lr  = env->lr;
-regs.xer = ppc_load_xer(env);
+regs.xer = env->xer;
 regs.msr = env->msr;
 
 regs.srr0 = env->spr[SPR_SRR0];
@@ -93,7 +93,7 @@
 
 env->ctr =regs.ctr;
 env->lr = regs.lr;
-ppc_store_xer(env,regs.xer);
+env->xer = regs.xer;
 env->msr = regs.msr;
 /* calculate hflags based on the current msr using the ppc qemu helper */
 hreg_compute_hflags(env);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc

2008-10-28 Thread Christian Ehrhardt
Ok I should have send these two series with some minutes in between to 
not intermix them :-/

Additionally I have the wrong header in this one it should be [0/5] :-/++

Overall it is a patch series of three patches for powerpc kvm-userspace, 
a five patch series for kvm-suerspace/user/ and a single patch I just 
submitted while cleaning our userspace repo to get the missing things 
upstream.


Avi, let me know if I confused you and I'll send them once again with 
some time in between to order them easier.


[EMAIL PROTECTED] wrote:

From: Christian Ehrhardt <[EMAIL PROTECTED]>

This is a set of fixes for the powerpc tests kvm-userspace/user.

Patch 1&2 fix main-ppc.c while patch 3 introduces libcflat for powerpc.
Further on patch 4 provides a timebase accessor for the ppc testcases (not
used yet) and patch 5 finally adds a stub nmi handler to main-ppc.c.

[patches in series]
[PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c
[PATCH 2/5] user: ppc: better error reporting in load_file
[PATCH 3/5] user: ppc: implement PowerPC 44x libcflat
[PATCH 4/5] libcflat: ppc: add timebase accessor
[PATCH 5/5] user: ppc: add stub nmi handler

---
[diffstat]
 b/user/config-powerpc-44x.mak  |   14 +
 b/user/config-powerpc.mak  |   46 -
 b/user/main-ppc.c  |   32 +++-
 b/user/test/lib/powerpc/44x/map.c  |   51 +
 b/user/test/lib/powerpc/44x/timebase.S |   28 ++
 b/user/test/lib/powerpc/44x/timebase.h |   25 
 b/user/test/lib/powerpc/44x/tlbwe.S|   29 ++
 b/user/test/lib/powerpc/io.c   |   35 ++
 b/user/test/powerpc/cstart.S   |   38 
 b/user/test/powerpc/exit.c |   23 ++
 user/config-powerpc-44x.mak|3 +
 user/main-ppc.c|9 +
 12 files changed, 296 insertions(+), 37 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  



--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] kvm-userspace: ppc: fix initial ppc memory setup

2008-10-28 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

The old memory initialization code was broken for all cases not fitting in one
ram stick. This patch fixes the ram_stick calculation, now sets the proper
base adresses per stick and removes the old workaround.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 ppc440.c|   12 +---
 ppc440.h|8 ++--
 ppc440_bamboo.c |   30 --
 3 files changed, 31 insertions(+), 19 deletions(-)

[diff]

diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c
--- a/qemu/hw/ppc440.c
+++ b/qemu/hw/ppc440.c
@@ -3,6 +3,7 @@
  *
  * Copyright 2007 IBM Corporation.
  * Authors: Jerone Young <[EMAIL PROTECTED]>
+ * Christian Ehrhardt <[EMAIL PROTECTED]>
  *
  * This work is licensed under the GNU GPL license version 2 or later.
  *
@@ -24,15 +25,15 @@
 
 
 void ppc440ep_init(CPUState *env,
-   target_phys_addr_t ram_bases[2],
-   target_phys_addr_t ram_sizes[2],
+   target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS],
+   target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS],
+   int nbanks,
qemu_irq **picp,
ppc4xx_pci_t **pcip,
int do_init)
 {
ppc4xx_mmio_t *mmio;
qemu_irq *pic, *irqs;
-   ram_addr_t offset;
ppc4xx_pci_t *pci;
int i;
 
@@ -55,10 +56,7 @@
/* SDRAM controller */
printf("trying to setup sdram controller\n");
/* XXX 440EP's ECC interrupts are on UIC1 */
-   ppc405_sdram_init(env, pic[14], 2, ram_bases, ram_sizes, do_init);
-   offset = 0;
-   for (i = 0; i < 2; i++)
-   offset += ram_sizes[i];
+   ppc405_sdram_init(env, pic[14], nbanks, ram_bases, ram_sizes, do_init);
 
/* PCI */
pci = ppc4xx_pci_init(env, pic,
diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h
--- a/qemu/hw/ppc440.h
+++ b/qemu/hw/ppc440.h
@@ -3,6 +3,7 @@
  *
  * Copyright 2007 IBM Corporation.
  * Authors: Jerone Young <[EMAIL PROTECTED]>
+ * Christian Ehrhardt <[EMAIL PROTECTED]>
  *
  * This work is licensed under the GNU GPL licence version 2 or later
  *
@@ -20,9 +21,12 @@
 #include "exec-all.h"
 #include "boards.h"
 
+#define PPC440_MAX_RAM_SLOTS 4
+
 void ppc440ep_init(CPUState *env,
-   target_phys_addr_t ram_bases[2],
-   target_phys_addr_t ram_sizes[2],
+   target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS],
+   target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS],
+   int nbanks,
qemu_irq **picp,
ppc4xx_pci_t **pcip,
int do_init);
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
@@ -2,7 +2,9 @@
  * Qemu PowerPC 440 board emualtion
  *
  * Copyright 2007 IBM Corporation.
- * Authors: Jerone Young <[EMAIL PROTECTED]>
+ * Authors:
+ * Jerone Young <[EMAIL PROTECTED]>
+ * Christian Ehrhardt <[EMAIL PROTECTED]>
  *
  * This work is licensed under the GNU GPL license version 2 or later.
  *
@@ -30,7 +32,8 @@
const char *cpu_model)
 {
char *buf=NULL;
-   target_phys_addr_t ram_bases[4], ram_sizes[4];
+   target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS];
+   target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS];
NICInfo *nd;
qemu_irq *pic;
ppc4xx_pci_t *pci;
@@ -46,6 +49,8 @@
int ret;
int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20,
32<<20, 16<<20, 8<<20 }; /* in bytes */
+   int nbanks = 0; /* number of used memory banks */
+   int next_bank_offset = 0;
ram_addr_t tmp_ram_size;
int i=0, k=0;
uint32_t cpu_freq;
@@ -55,15 +60,22 @@
printf("%s: START\n", __func__);
 
/* Setup Memory */
-   printf("Ram size passed is: %i MB\n",
-   bytes_to_mb((int)ram_size));
+   if (ram_size < 8<<20) {
+   printf("ERROR: ram size too small (min 8mb)\n");
+   exit(1);
+   } else
+   printf("Ram size passed is: %i MB\n",
+   bytes_to_mb((int)ram_size));
 
tmp_ram_size = ram_size;
 
-   for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) {
-   for (k=0; k < 
(sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) {
+   for (i = 0; i < PPC440_MAX_RAM_SLOTS; i++) {
+   for (k = 0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) {
if ((tmp_ram_size/ram_stick_sizes[k]) > 0) {
ram_sizes[i] = ram_stick_sizes[k];
+   ram_bases[i] = next_bank_offset;
+  

[PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc

2008-10-28 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This is a set of various functional fixes in kvm-userspace for powerpc.

Patch 1 fullfils the requirement to provide a max smp cpu in the machine
 struct, without that value qemu denies to run the guest (cpu 1 > maxcpu 0)

Patch 2 is a intermediate fix to allow ppc (and hopefully all others to
 build) until we changed the unifdef to sed'ing files as avi suggested.
 Until then it would be nice if that patch could fix the build issues for
 all of us in the unifdef style.

Patch3 is a rework of the powerpc 440 guest memory initialization. I looked
 at it because the -m option did not work sometimes but it came up that the
 memory setup is broken and only running due to a workaround.

qemu-devel is on cc for patch 1/3

[patches in series]
[PATCH 1/3] qemu: ppc: define maximum SMP limit as 1 for Bamboo
[PATCH 2/3] kvm: external module: Treat NONARCH_CONFIG as a list
[PATCH 3/3] kvm-userspace: ppc: fix initial ppc memory setup

---
[diffstat]
 b/kernel/Makefile |3 ++-
 b/qemu/hw/ppc440.c|   12 +---
 b/qemu/hw/ppc440.h|8 ++--
 b/qemu/hw/ppc440_bamboo.c |7 ---
 qemu/hw/ppc440_bamboo.c   |   30 --
 5 files changed, 37 insertions(+), 23 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] qemu: ppc: if not a uImage, try to load kernel as ELF

2008-10-28 Thread ehrhardt
From: Hollis Blanchard <[EMAIL PROTECTED]>

This allows qemu to load "bare metal" ELF kernels, useful for standalone
benchmarks and testcases.

We could/should also load the specified file as a flat binary, if both uImage
and ELF loaders fail. (See hw/arm_boot.c.)

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 ppc440_bamboo.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

[diff]
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
@@ -35,8 +35,8 @@ void bamboo_init(ram_addr_t ram_size, in
qemu_irq *pic;
ppc4xx_pci_t *pci;
CPUState *env;
-   target_ulong ep=0;
-   target_ulong la=0;
+   uint64_t ep=0;
+   uint64_t la=0;
int is_linux=1; /* Will assume allways is Linux for now */
target_long kernel_size=0;
target_ulong initrd_base=0;
@@ -98,6 +98,9 @@ void bamboo_init(ram_addr_t ram_size, in
/* load kernel with uboot loader */
printf("%s: load kernel\n", __func__);
ret = load_uimage(kernel_filename, &ep, &la, &kernel_size, &is_linux);
+   if (ret < 0)
+   ret = load_elf(kernel_filename, 0, &ep, &la, NULL);
+
if (ret < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c

2008-10-28 Thread ehrhardt
From: Hollis Blanchard <[EMAIL PROTECTED]>

- call io_table_register() before any vcpus have started
- wait for all vcpus to exit before exiting the parent thread

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 main-ppc.c |   32 
 1 file changed, 12 insertions(+), 20 deletions(-)

[diff]
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -51,7 +51,7 @@ struct io_table mmio_table;
 struct io_table mmio_table;
 
 static int ncpus = 1;
-static sem_t init_sem;
+static sem_t exited_sem;
 static __thread int vcpu;
 static sigset_t kernel_sigmask;
 static sigset_t ipi_sigmask;
@@ -220,16 +220,8 @@ void sync_caches(void *mem, unsigned lon
asm volatile ("sync; isync");
 }
 
-static void init_vcpu(int n, unsigned long entry)
+static void init_vcpu(int n)
 {
-   /* XXX must set initial TLB state and stack
-   struct kvm_regs regs = {
-   .pc = entry,
-   };
-
-   kvm_set_regs(kvm, 0, ®s);
-   */
-
sigemptyset(&ipi_sigmask);
sigaddset(&ipi_sigmask, IPI_SIGNAL);
sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL);
@@ -237,7 +229,6 @@ static void init_vcpu(int n, unsigned lo
vcpus[n].tid = gettid();
vcpu = n;
kvm_set_signal_mask(kvm, n, &kernel_sigmask);
-   sem_post(&init_sem);
 }
 
 static void *do_create_vcpu(void *_n)
@@ -245,8 +236,9 @@ static void *do_create_vcpu(void *_n)
int n = (long)_n;
 
kvm_create_vcpu(kvm, n);
-   init_vcpu(n, 0x0);
+   init_vcpu(n);
kvm_run(kvm, n);
+   sem_post(&exited_sem);
return NULL;
 }
 
@@ -368,14 +360,14 @@ int main(int argc, char **argv)
len = load_file(vm_mem, argv[optind], 1);
sync_caches(vm_mem, len);
 
-   sem_init(&init_sem, 0, 0);
-   init_vcpu(0, 0x0);
-   for (i = 1; i < ncpus; ++i)
-   start_vcpu(i);
-   for (i = 0; i < ncpus; ++i)
-   sem_wait(&init_sem);
-
io_table_register(&mmio_table, 0xf000, 64, mmio_handler, NULL);
 
-   return kvm_run(kvm, 0);
+   sem_init(&exited_sem, 0, 0);
+   for (i = 0; i < ncpus; ++i)
+   start_vcpu(i);
+   /* Wait for all vcpus to exit. */
+   for (i = 0; i < ncpus; ++i)
+   sem_wait(&exited_sem);
+
+   return 0;
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc

2008-10-28 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This is a set of fixes for the powerpc tests kvm-userspace/user.

Patch 1&2 fix main-ppc.c while patch 3 introduces libcflat for powerpc.
Further on patch 4 provides a timebase accessor for the ppc testcases (not
used yet) and patch 5 finally adds a stub nmi handler to main-ppc.c.

[patches in series]
[PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c
[PATCH 2/5] user: ppc: better error reporting in load_file
[PATCH 3/5] user: ppc: implement PowerPC 44x libcflat
[PATCH 4/5] libcflat: ppc: add timebase accessor
[PATCH 5/5] user: ppc: add stub nmi handler

---
[diffstat]
 b/user/config-powerpc-44x.mak  |   14 +
 b/user/config-powerpc.mak  |   46 -
 b/user/main-ppc.c  |   32 +++-
 b/user/test/lib/powerpc/44x/map.c  |   51 +
 b/user/test/lib/powerpc/44x/timebase.S |   28 ++
 b/user/test/lib/powerpc/44x/timebase.h |   25 
 b/user/test/lib/powerpc/44x/tlbwe.S|   29 ++
 b/user/test/lib/powerpc/io.c   |   35 ++
 b/user/test/powerpc/cstart.S   |   38 
 b/user/test/powerpc/exit.c |   23 ++
 user/config-powerpc-44x.mak|3 +
 user/main-ppc.c|9 +
 12 files changed, 296 insertions(+), 37 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] libcflat: ppc: add timebase accessor

2008-10-28 Thread ehrhardt
Provide a timebase accessor for ppc testcases.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>

[diffstat]
 config-powerpc-44x.mak  |3 ++-
 test/lib/powerpc/44x/timebase.S |   28 
 test/lib/powerpc/44x/timebase.h |   25 +
 3 files changed, 55 insertions(+), 1 deletion(-)

[diff]
diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak
--- a/user/config-powerpc-44x.mak
+++ b/user/config-powerpc-44x.mak
@@ -5,7 +5,8 @@
 
 cflatobjs += \
test/lib/powerpc/44x/map.o \
-   test/lib/powerpc/44x/tlbwe.o
+   test/lib/powerpc/44x/tlbwe.o \
+   test/lib/powerpc/44x/timebase.o
 
 simpletests += \
test/powerpc/44x/tlbsx.bin \
diff --git a/user/test/lib/powerpc/44x/timebase.S 
b/user/test/lib/powerpc/44x/timebase.S
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/timebase.S
@@ -0,0 +1,28 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <[EMAIL PROTECTED]>
+ */
+
+/* unsigned long long mftb(void); */
+.global mftb
+mftb:
+   mftbu   r5
+   mftbl   r4
+   mftbu   r3
+   cmpwr3, r5
+   bne mftb
+   blr
diff --git a/user/test/lib/powerpc/44x/timebase.h 
b/user/test/lib/powerpc/44x/timebase.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/timebase.h
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <[EMAIL PROTECTED]>
+ */
+
+#ifndef __TIMEBASE_H__
+#define __TIMEBASE_H__
+
+unsigned long long mftb(void);
+
+#endif /* __TIMEBASE_H__ */
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] user: ppc: better error reporting in load_file

2008-10-28 Thread ehrhardt
From: Hollis Blanchard <[EMAIL PROTECTED]>

Fancy description.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 main-ppc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

[diff]
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -183,7 +183,7 @@ static struct kvm_callbacks test_callbac
 
 static unsigned long load_file(void *mem, const char *fname, int inval_icache)
 {
-   int r;
+   ssize_t r;
int fd;
unsigned long bytes = 0;
 
@@ -200,6 +200,7 @@ static unsigned long load_file(void *mem
 
if (r == -1) {
perror("read");
+   printf("read %d bytes\n", bytes);
exit(1);
}
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] user: ppc: add stub nmi handler

2008-10-28 Thread ehrhardt
From: Hollis Blanchard <[EMAIL PROTECTED]>

Adding a nmi stub handler for user/main-ppc.c. We already pushed a stub
for qemu but not for the test suite in the user dir.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 main-ppc.c |6 ++
 1 file changed, 6 insertions(+)

[diff]
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -83,6 +83,11 @@ static int test_io_window(void *opaque)
 }
 
 static int test_try_push_interrupts(void *opaque)
+{
+   return 0;
+}
+
+static int test_try_push_nmi(void *opaque)
 {
return 0;
 }
@@ -175,6 +180,7 @@ static struct kvm_callbacks test_callbac
.halt= test_halt,
.io_window = test_io_window,
.try_push_interrupts = test_try_push_interrupts,
+   .try_push_nmi = test_try_push_nmi,
.post_kvm_run = test_post_kvm_run,
.pre_kvm_run = test_pre_kvm_run,
.powerpc_dcr_read = test_dcr_read,
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] user: ppc: implement PowerPC 44x libcflat

2008-10-28 Thread ehrhardt
From: Hollis Blanchard <[EMAIL PROTECTED]>

- Create a 44x-specific makefile.
- Reorganize PowerPC makefiles to separate "simple" tests from those which
  link with libcflat.
- Create a minimal libcflat testcase (which just exits).

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 config-powerpc-44x.mak   |   14 +++
 config-powerpc.mak   |   46 ++
 test/lib/powerpc/44x/map.c   |   51 +++
 test/lib/powerpc/44x/tlbwe.S |   29 
 test/lib/powerpc/io.c|   35 +
 test/powerpc/cstart.S|   38 
 test/powerpc/exit.c  |   23 +++
 7 files changed, 221 insertions(+), 15 deletions(-)

[diff]

diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak
new file mode 100644
--- /dev/null
+++ b/user/config-powerpc-44x.mak
@@ -0,0 +1,14 @@
+
+
+# for some reason binutils hates tlbsx unless we say we're 405  :(
+CFLAGS += -Wa,-m405 -I test/lib/powerpc/44x
+
+cflatobjs += \
+   test/lib/powerpc/44x/map.o \
+   test/lib/powerpc/44x/tlbwe.o
+
+simpletests += \
+   test/powerpc/44x/tlbsx.bin \
+   test/powerpc/44x/tlbwe_16KB.bin \
+   test/powerpc/44x/tlbwe_hole.bin \
+   test/powerpc/44x/tlbwe.bin
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,26 +1,42 @@
+platform := 44x
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
-# for some reaons binutils hates tlbsx unless we say we're 405  :(
-CFLAGS += -Wa,-mregnames,-m405
+CFLAGS += -Wa,-mregnames -I test/lib
 
-%.bin: %.o
-   $(OBJCOPY) -O binary $^ $@
+cstart := test/powerpc/cstart.o
 
-testobjs := \
-   io.bin \
-   spin.bin \
-   sprg.bin \
-   44x/tlbsx.bin \
-   44x/tlbwe_16KB.bin \
-   44x/tlbwe_hole.bin \
-   44x/tlbwe.bin
+cflatobjs += \
+   test/lib/powerpc/io.o
 
-tests := $(addprefix test/powerpc/, $(testobjs))
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding
 
-all: kvmtrace kvmctl $(tests)
+# these tests do not use libcflat
+simpletests := \
+   test/powerpc/spin.bin \
+   test/powerpc/io.bin \
+   test/powerpc/sprg.bin
+
+# theses tests use cstart.o, libcflat, and libgcc
+tests := \
+   test/powerpc/exit.bin
+
+include config-powerpc-$(platform).mak
+
+
+all: kvmtrace kvmctl $(libcflat) $(simpletests) $(tests)
+
+$(simpletests): %.bin: %.o
+   $(CC) -nostdlib $^ -Wl,-T,flat.lds -o $@
+
+$(tests): %.bin: $(cstart) %.o $(libcflat)
+   $(CC) -nostdlib $^ $(libgcc) -Wl,-T,flat.lds -o $@
 
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-   rm -f $(tests)
+   $(RM) $(simpletests) $(tests) $(cstart)
+   $(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests))
+   $(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests))
diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/map.c
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <[EMAIL PROTECTED]>
+ */
+
+#include "libcflat.h"
+
+#define TLB_SIZE 64
+
+extern void tlbwe(unsigned int index,
+ unsigned char tid,
+ unsigned int word0,
+ unsigned int word1,
+ unsigned int word2);
+
+unsigned int next_free_index;
+
+#define PAGE_SHIFT 12
+#define PAGE_MASK (~((1<= TLB_SIZE)
+   panic("TLB overflow");
+
+   w0 = (vaddr & PAGE_MASK) | V;
+   w1 = paddr & PAGE_MASK;
+   w2 = 0x3;
+
+   tlbwe(next_free_index, 0, w0, w1, w2);
+}
diff --git a/user/test/lib/powerpc/44x/tlbwe.S 
b/user/test/lib/powerpc/44x/tlbwe.S
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/tlbwe.S
@@ -0,0 +1,29 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope tha

[PATCH 2/3] kvm: external module: Treat NONARCH_CONFIG as a list

2008-10-28 Thread ehrhardt
From: Hollis Blanchard <[EMAIL PROTECTED]>

As discussed on the list the unifdef changes break powerpc (and more ?). A fix
is to treat NONARCH_CONFIG as a list instead of a single item.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 Makefile |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

[diff]
diff --git a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -25,8 +25,9 @@
gawk -v version=$(version) -f $(ARCH_DIR)/hack-module.awk $1.orig \
| sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
+unifdef_uflags = $(foreach arch, $(NONARCH_CONFIG), -UCONFIG_$(arch))
 unifdef = mv $1 $1.orig && \
- unifdef -DCONFIG_$(ARCH_CONFIG) -UCONFIG_$(NONARCH_CONFIG) $1.orig > 
$1; \
+ unifdef -DCONFIG_$(ARCH_CONFIG) $(unifdef_uflags) $1.orig > $1; \
   [ $$? -le 2 ] && rm $1.orig
 
 hack = $(call _hack,$T/$(strip $1))
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] qemu: ppc: define maximum SMP limit as 1 for Bamboo

2008-10-28 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Fix for qemu runtime error. Full error message:
Number of SMP cpus requested (1), exceeds max cpus supported by machine 
`bamboo' (0)

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
---

[diffstat]
 ppc440_bamboo.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

[diff]
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
@@ -203,7 +203,8 @@ void bamboo_init(ram_addr_t ram_size, in
 }

 QEMUMachine bamboo_machine = {
-   "bamboo",
-   "bamboo",
-   bamboo_init,
+   .name = "bamboo",
+   .desc = "bamboo",
+   .init = bamboo_init,
+   .max_cpus = 1,
 };
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm: external module: fix unifdef problem

2008-10-27 Thread Christian Ehrhardt

Hi Avi,
Hollis and I discussed how to continue on that.
Atm the upstream code is broken for powerpc and your response is too 
vague for me to extend our patch in some way.
So which way should we go? Will you apply (or should I resubmit ?) 
Hollis patch for now to fix upstream for powerpc. And we/you extend it 
later or what else would you prefer?


Avi Kivity wrote:

Hollis Blanchard wrote:

Guys, I don't mind if you add new things that aren't enabled for other
architectures, but please try to be a little more careful about breaking
us.

This patch results in the following on PowerPC:
mv $i $i.orig && unifdef -DCONFIG_POWERPC -UCONFIG_X86 IA64
$i.orig > $i; [ $? -le 2 ] && rm $i.orig; done
unifdef: can only do one file

  


Aw.


Here's my proposed fix:

kvm: external module: Treat NONARCH_CONFIG as a list, not a single item.

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>

diff --git a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -25,8 +25,9 @@ _hack = mv $1 $1.orig && \
 gawk -v version=$(version) -f $(ARCH_DIR)/hack-module.awk $1.orig \
 | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
+unifdef_uflags = $(foreach arch, $(NONARCH_CONFIG), -UCONFIG_$(arch))
  


$(patsubst ...), or even $(NONARCH_CONFIG:%=-UCONFIG_%)

But I think NONARCH_CONFIG needs to be adjusted as well.




--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1 of 3] user: ppc: add stub nmi handler

2008-10-27 Thread Christian Ehrhardt
Further checks later - it was in our repo with a different name not 
upstream.

I'll submit it together with the rest of the backlog we have in our queue.

Christian Ehrhardt wrote:

I already wrote and brought that one upstream.
It is in the repo as kvmppc-add-kvm_arch_try_push_nmi.diff and as of 
today I guard it with "+upstream"


Hollis Blanchard wrote:

# HG changeset patch
# User Hollis Blanchard <[EMAIL PROTECTED]>
# Date 1224281124 18000
# Node ID eed92f318ffa8a2e036a5bd9727f45c59dda5b12
# Parent  1ad6978ab8a1d0278126b9dd315745842d746986
user: ppc: add stub nmi handler

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>

diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -83,6 +83,11 @@ static int test_io_window(void *opaque)
 }

 static int test_try_push_interrupts(void *opaque)
+{
+return 0;
+}
+
+static int test_try_push_nmi(void *opaque)
 {
 return 0;
 }
@@ -175,6 +180,7 @@ static struct kvm_callbacks test_callbac
 .halt= test_halt,
 .io_window = test_io_window,
 .try_push_interrupts = test_try_push_interrupts,
+.try_push_nmi = test_try_push_nmi,
 .post_kvm_run = test_post_kvm_run,
 .pre_kvm_run = test_pre_kvm_run,
 .powerpc_dcr_read = test_dcr_read,
  






--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0 of 3] userspace updates

2008-10-27 Thread Christian Ehrhardt

Hollis Blanchard wrote:

[Resend to correct address.]
A couple fixes and one functional improvement for the userspace repo.
Christian, will you take care of merging these and sending our userspace patch
backlog to Avi?

-Hollis
  

Yes I'll do that
Patch 1 is already upstream, patch 2 is fine as we discussed about it on 
Wednesday and I test patch 3 atm.
I also updated and checked the patch out of the discussion for the 
unifdef issue and prepared all the test-ppc-* patches to be submitted.


hmmm maybe we can also submit the current state of translate&gdb - it's 
not fully featured but should work right ?


--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1 of 3] user: ppc: add stub nmi handler

2008-10-27 Thread Christian Ehrhardt

I already wrote and brought that one upstream.
It is in the repo as kvmppc-add-kvm_arch_try_push_nmi.diff and as of 
today I guard it with "+upstream"


Hollis Blanchard wrote:

# HG changeset patch
# User Hollis Blanchard <[EMAIL PROTECTED]>
# Date 1224281124 18000
# Node ID eed92f318ffa8a2e036a5bd9727f45c59dda5b12
# Parent  1ad6978ab8a1d0278126b9dd315745842d746986
user: ppc: add stub nmi handler

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>

diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -83,6 +83,11 @@ static int test_io_window(void *opaque)
 }

 static int test_try_push_interrupts(void *opaque)
+{
+   return 0;
+}
+
+static int test_try_push_nmi(void *opaque)
 {
return 0;
 }
@@ -175,6 +180,7 @@ static struct kvm_callbacks test_callbac
.halt= test_halt,
.io_window = test_io_window,
.try_push_interrupts = test_try_push_interrupts,
+   .try_push_nmi = test_try_push_nmi,
.post_kvm_run = test_post_kvm_run,
.pre_kvm_run = test_pre_kvm_run,
.powerpc_dcr_read = test_dcr_read,
  



--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Patch to increase the number of tlb entries a guest uses

2008-10-20 Thread Christian Ehrhardt

Hi Scott,
I just discussed with Hollis about shadow tlb management in the 
hypervisor and he mentioned that you already have a patch that lets the 
guest use more tlb entries than it would have on bare metal hardware and 
therefore allow to handle more tlb misses in the host because the shadow 
tlb already holds that information.


It would be nice if you could provide me and the kvmppc community that 
patch, because I wanted to modify our tlb handling a bit. If it would be 
easy enough I would like to test that with a different number of guest 
tlb entries too to see how big the impact of such a change would be to 
our shadow tlb management.



--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvmppc: comply with requirement for kvm_arch_try_push_nmi

2008-10-17 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Since a recent patch all architetcures need a kvm_arch_try_push_nmi function.
Powerpc has no direct nmi equivalent, so this patch fixes only build for
powerpc by adding an empty stub.
If powerpc later wants to support the nmi monitor command somehow the function
can still be extended.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 qemu-kvm-powerpc.c |8 
 1 file changed, 8 insertions(+)

[diff]
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -190,6 +190,14 @@
 return 0;
 }
 
+int kvm_arch_try_push_nmi(void *opaque)
+{
+   /* no nmi irq, so discard that call for now and return success.
+* This might later get mapped to something on powerpc too if we want
+*  to support the nmi monitor command somwhow */
+   return 0;
+}
+
 void kvm_arch_update_regs_for_sipi(CPUState *env)
 {
 printf("%s: no kvm-powerpc multi processor support yet!\n", __func__);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvmppc: add detailed exit timing statistic v2

2008-10-15 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Since relay based statistic approaches slow us down to much in some scenarios
this patch adds a configurable exit timing statistic.
It is powerpc only and holds timing stats of exit/reenter per exit type read
via debugfs.

updates in v2:
 * moved statistic code to a separate header
 * changed code to be at least basically multi cpu/guest safe
 * reworked old noop stubs used if exit timing is not configured
 * combined kvm-stat based accounting with this (less code in our main code 
flow)
 * drop internal debug print_exit_timing and it's callers
 * changed access from sysrq to debugfs using seq_file
 * introduced per vm & per vcpu debugfs reports
 * a lot of renaming/cleaning

The issue behind this patch is that trace based approaches generate too much
overhead in our hot path, while the existng kvm_stat interface is not able to
report per vm/vcpu (or would become unusable by the high number of files I
would need). Therefore this path uses the elso existing seq_file helpers to
extend the data presented in the %debugfs%/kvm directory.

This emerged from a debug patch I once created. I reworked and polished it to
allow it to be applied to our powerpc upstrema code, but it can't deny it's
heritage so this patch v2 is my rfc to see if/how I could/should do different.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/kernel/asm-offsets.c  |   11 ++
 arch/powerpc/kvm/Kconfig   |9 ++
 arch/powerpc/kvm/booke_guest.c |   39 +
 arch/powerpc/kvm/booke_interrupts.S|   24 +
 arch/powerpc/kvm/powerpc.c |   93 ++
 include/asm-powerpc/kvm_host.h |   50 
 include/asm-powerpc/kvm_timing_stats.h |  136 +
 7 files changed, 347 insertions(+), 15 deletions(-)

[diff]

diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -348,5 +348,16 @@
DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
 #endif
 
+#ifdef CONFIG_KVM_BOOKE_EXIT_TIMING
+   DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu,
+   arch.timing_exit.tv32.tbu));
+   DEFINE(VCPU_TIMING_EXIT_TBL, offsetof(struct kvm_vcpu,
+   arch.timing_exit.tv32.tbl));
+   DEFINE(VCPU_TIMING_LAST_ENTER_TBU, offsetof(struct kvm_vcpu,
+   arch.timing_last_enter.tv32.tbu));
+   DEFINE(VCPU_TIMING_LAST_ENTER_TBL, offsetof(struct kvm_vcpu,
+   arch.timing_last_enter.tv32.tbl));
+#endif
+
return 0;
 }
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -37,6 +37,15 @@
  Provides host support for KVM on Book E PowerPC processors. Currently
  this works on 440 processors only.
 
+config KVM_BOOKE_EXIT_TIMING
+   bool "Trace detailed exit Timing"
+   depends on KVM_BOOKE_HOST
+   ---help---
+ Inserts code to trace timestamps for every exit/enter cycle. A per 
vcpu
+ report is available in debugfs kvm/VM_###/VPCU_###_exit_timing.
+ The overhead is relatively small, however it is not recommended for
+ production environments.
+
 config KVM_TRACE
bool "KVM trace support"
depends on KVM && MARKERS && SYSFS
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "44x_tlb.h"
 
@@ -228,6 +229,9 @@
enum emulation_result er;
int r = RESUME_HOST;
 
+   /* update before a new last_exit_type is rewritten */
+   update_timing_stats(vcpu);
+
local_irq_enable();
 
run->exit_reason = KVM_EXIT_UNKNOWN;
@@ -241,7 +245,7 @@
break;
 
case BOOKE_INTERRUPT_EXTERNAL:
-   vcpu->stat.ext_intr_exits++;
+   account_exit(vcpu, EXT_INTR_EXITS);
if (need_resched())
cond_resched();
r = RESUME_GUEST;
@@ -256,7 +260,7 @@
 * we do reschedule the host will fault over it. Perhaps we
 * should politely restore the host's entries to minimize
 * misses before ceding control. */
-   vcpu->stat.dec_exits++;
+   account_exit(vcpu, DEC_EXITS);
if (need_resched())
cond_resched();
r = RESUME_GUEST;
@@ -269,6 +273,7 @@
vcpu->arch.esr = vcpu->arch.fault_esr;
  

[PATCH 3/3] kvmppc: optimize find first bit

2008-10-13 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Since we use a unsigned long here anyway we can use the optimized __ffs.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 booke_guest.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -180,7 +180,7 @@
unsigned int prio;
u32 mask;
 
-   prio = find_first_bit(pending, BITS_PER_BYTE * sizeof(*pending));
+   prio = __ffs(*pending);
while (prio <= BOOKE_MAX_INTERRUPT) {
if (kvmppc_can_deliver_interrupt_by_prio(vcpu, prio, &mask)) {
kvmppc_clear_exception_by_prio(pending, prio);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] kvmppc: optimize kvm stat handling

2008-10-13 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Currently we use an unneicessary if&switch to detect some cases.
To be honest we don't need the ligh_exits counter anyway, because we can
calculate it out of others. Sum_exits can also be calculated, so we can
remove that too.
MMIO, DCR  and INTR can be counted on other places without these
additional control structures (The INTR case was never hit anyway).

The handling of BOOKE_INTERRUPT_EXTERNAL/BOOKE_INTERRUPT_DECREMENTER is
similar, but we can avoid the additional if when copying 3 lines of code.
I thought about a goto there to prevent duplicate lines, but rewriting three
lines should be better style than a goto cross switch/case statements (its
also not enough code to justify a new inline function).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 booke_guest.c |   32 +---
 1 file changed, 9 insertions(+), 23 deletions(-)

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -34,11 +34,9 @@
 #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
 
 struct kvm_stats_debugfs_item debugfs_entries[] = {
-   { "exits",  VCPU_STAT(sum_exits) },
{ "mmio",   VCPU_STAT(mmio_exits) },
{ "dcr",VCPU_STAT(dcr_exits) },
{ "sig",VCPU_STAT(signal_exits) },
-   { "light",  VCPU_STAT(light_exits) },
{ "itlb_r", VCPU_STAT(itlb_real_miss_exits) },
{ "itlb_v", VCPU_STAT(itlb_virt_miss_exits) },
{ "dtlb_r", VCPU_STAT(dtlb_real_miss_exits) },
@@ -220,6 +218,12 @@
break;
 
case BOOKE_INTERRUPT_EXTERNAL:
+   vcpu->stat.ext_intr_exits++;
+   if (need_resched())
+   cond_resched();
+   r = RESUME_GUEST;
+   break;
+
case BOOKE_INTERRUPT_DECREMENTER:
/* Since we switched IVPR back to the host's value, the host
 * handled this interrupt the moment we enabled interrupts.
@@ -229,12 +233,9 @@
 * we do reschedule the host will fault over it. Perhaps we
 * should politely restore the host's entries to minimize
 * misses before ceding control. */
+   vcpu->stat.dec_exits++;
if (need_resched())
cond_resched();
-   if (exit_nr == BOOKE_INTERRUPT_DECREMENTER)
-   vcpu->stat.dec_exits++;
-   else
-   vcpu->stat.ext_intr_exits++;
r = RESUME_GUEST;
break;
 
@@ -258,6 +259,7 @@
break;
case EMULATE_DO_DCR:
run->exit_reason = KVM_EXIT_DCR;
+   vcpu->stat.dcr_exits++;
r = RESUME_HOST;
break;
case EMULATE_FAIL:
@@ -336,6 +338,7 @@
/* Guest has mapped and accessed a page which is not
 * actually RAM. */
r = kvmppc_emulate_mmio(run, vcpu);
+   vcpu->stat.mmio_exits++;
}
 
break;
@@ -403,8 +406,6 @@
 
kvmppc_check_and_deliver_interrupts(vcpu);
 
-   /* Do some exit accounting. */
-   vcpu->stat.sum_exits++;
if (!(r & RESUME_HOST)) {
/* To avoid clobbering exit_reason, only check for signals if
 * we aren't already exiting to userspace for some other
@@ -412,22 +413,7 @@
if (signal_pending(current)) {
run->exit_reason = KVM_EXIT_INTR;
r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
-
vcpu->stat.signal_exits++;
-   } else {
-   vcpu->stat.light_exits++;
-   }
-   } else {
-   switch (run->exit_reason) {
-   case KVM_EXIT_MMIO:
-   vcpu->stat.mmio_exits++;
-   break;
-   case KVM_EXIT_DCR:
-   vcpu->stat.dcr_exits++;
-   break;
-   case KVM_EXIT_INTR:
-   vcpu->stat.signal_exits++;
-   break;
}
}
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] kvmppc: optimize path run on every exit

2008-10-13 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

updates in v2:
 * exception_priority back to char to save space (=>cache lines)
 * rebased to apply pre pvmem & exit timing patches
 * moved PRIO constants from kvm_asm.h to kvm_ppc.h
 * replaced 16x4byte interrupt_mask by single u32

A small patch series of optimizations out of our discussions and my
experiments this week.
All patches improve the generic path executed for every exit we take,
therefore even a littel improvement can help a lot.

I would be happy if we could apply those soon. I'll continue looking into the
TLB stuff eating ~30% of our time. But since that might take a while I would be
happy if these three patches could be applied now (and relieve me, by not
having to keep them in sync).

Comments welcome, especially since exits still feel too long (current
assumption cache or tlb issues). See my other mails about exit timing on
kvm-ppc@vger.kernel.org

[patches in series]
Subject: [PATCH 1/3] kvmppc: optimize irq delivery path
Subject: [PATCH 2/3] kvmppc: optimize kvm stat handling
Subject: [PATCH 3/3] kvmppc: optimize find first bit

---
[diffstat]
 arch/powerpc/kvm/booke_guest.c   |  187 ++-
 b/arch/powerpc/kvm/booke_guest.c |2
 b/arch/powerpc/kvm/emulate.c |  128 --
 b/arch/powerpc/kvm/powerpc.c |5 -
 b/include/asm-powerpc/kvm_ppc.h  |   25 -
 5 files changed, 191 insertions(+), 156 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] kvmppc: optimize irq delivery path

2008-10-13 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

In kvmppc_deliver_interrupt is just one case left in the switch and it is a
rare one (less than 8%) when looking at the exit numbers. Therefore we can
at least drop the switch/case and if an if. I inserted an unlikely too, but
that's open for discussion.

In kvmppc_can_deliver_interrupt all frequent cases are in the default case.
I know compilers are smart but we can make it easier for them. By writing
down all options and removing the default case combined with the fact that
ithe values are constants 0..15 should allow the compiler to write an easy
jump table.
Modifying kvmppc_can_deliver_interrupt pointed me to the fact that gcc seems
to be unable to reduce priority_exception[x] to a build time constant.
Therefore I changed the usage of the translation arrays in the interrupt
delivery path completely. It is now using priority without translation to irq
on the full irq delivery path.
To be able to do that ivpr regs are stored by their priority now.

Additionally the decision made in kvmppc_can_deliver_interrupt is already
sufficient to get the value of interrupt_msr_mask[x]. Therefore we can replace
the 16x4byte array used here with a single 4byte variable (might still be one
miss, but the chance to find this in cache should be better than the right
entry of the whole array).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/kvm/booke_guest.c |  153 -
 arch/powerpc/kvm/emulate.c |  128 +-
 arch/powerpc/kvm/powerpc.c |5 -
 include/asm-powerpc/kvm_ppc.h  |   25 +-
 4 files changed, 180 insertions(+), 131 deletions(-)

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -53,63 +53,24 @@
{ NULL }
 };
 
-static const u32 interrupt_msr_mask[16] = {
-   [BOOKE_INTERRUPT_CRITICAL]  = MSR_ME,
-   [BOOKE_INTERRUPT_MACHINE_CHECK] = 0,
-   [BOOKE_INTERRUPT_DATA_STORAGE]  = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_INST_STORAGE]  = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_EXTERNAL]  = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_ALIGNMENT] = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_PROGRAM]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_FP_UNAVAIL]= MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_SYSCALL]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_AP_UNAVAIL]= MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_DECREMENTER]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_FIT]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_WATCHDOG]  = MSR_ME,
-   [BOOKE_INTERRUPT_DTLB_MISS] = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_ITLB_MISS] = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_DEBUG] = MSR_ME,
+const unsigned char exception_priority[] = {
+   [BOOKE_INTERRUPT_DATA_STORAGE] = BOOKE_IRQPRIO_DATA_STORAGE,
+   [BOOKE_INTERRUPT_INST_STORAGE] = BOOKE_IRQPRIO_INST_STORAGE,
+   [BOOKE_INTERRUPT_ALIGNMENT] = BOOKE_IRQPRIO_ALIGNMENT,
+   [BOOKE_INTERRUPT_PROGRAM] = BOOKE_IRQPRIO_PROGRAM,
+   [BOOKE_INTERRUPT_FP_UNAVAIL] = BOOKE_IRQPRIO_FP_UNAVAIL,
+   [BOOKE_INTERRUPT_SYSCALL] = BOOKE_IRQPRIO_SYSCALL,
+   [BOOKE_INTERRUPT_AP_UNAVAIL] = BOOKE_IRQPRIO_AP_UNAVAIL,
+   [BOOKE_INTERRUPT_DTLB_MISS] = BOOKE_IRQPRIO_DTLB_MISS,
+   [BOOKE_INTERRUPT_ITLB_MISS] = BOOKE_IRQPRIO_ITLB_MISS,
+   [BOOKE_INTERRUPT_MACHINE_CHECK] = BOOKE_IRQPRIO_MACHINE_CHECK,
+   [BOOKE_INTERRUPT_DEBUG] = BOOKE_IRQPRIO_DEBUG,
+   [BOOKE_INTERRUPT_CRITICAL] = BOOKE_IRQPRIO_CRITICAL,
+   [BOOKE_INTERRUPT_WATCHDOG] = BOOKE_IRQPRIO_WATCHDOG,
+   [BOOKE_INTERRUPT_EXTERNAL] = BOOKE_IRQPRIO_EXTERNAL,
+   [BOOKE_INTERRUPT_FIT] = BOOKE_IRQPRIO_FIT,
+   [BOOKE_INTERRUPT_DECREMENTER] = BOOKE_IRQPRIO_DECREMENTER,
 };
-
-const unsigned char exception_priority[] = {
-   [BOOKE_INTERRUPT_DATA_STORAGE] = 0,
-   [BOOKE_INTERRUPT_INST_STORAGE] = 1,
-   [BOOKE_INTERRUPT_ALIGNMENT] = 2,
-   [BOOKE_INTERRUPT_PROGRAM] = 3,
-   [BOOKE_INTERRUPT_FP_UNAVAIL] = 4,
-   [BOOKE_INTERRUPT_SYSCALL] = 5,
-   [BOOKE_INTERRUPT_AP_UNAVAIL] = 6,
-   [BOOKE_INTERRUPT_DTLB_MISS] = 7,
-   [BOOKE_INTERRUPT_ITLB_MISS] = 8,
-   [BOOKE_INTERRUPT_MACHINE_CHECK] = 9,
-   [BOOKE_INTERRUPT_DEBUG] = 10,
-   [BOOKE_INTERRUPT_CRITICAL] = 11,
-   [BOOKE_INTERRUPT_WATCHDOG] = 12,
-   [BOOKE_INTERRUPT_EXTERNAL] = 13,
-   [BOOKE_INTERRUPT_FIT] = 14,
-   [BOOKE_INTERRUPT_DECREMENTER] = 15,
-};
-
-const unsigned char priority_exception[] = {
-   BOOKE_INTERRUPT_DATA_STORAGE,
-   BOOKE_INTERRUPT_INST_STORAGE,
-   BOOKE_INTERRUPT_ALIGNMENT,
-   BOOKE_INTERRUPT_PROGRAM,
-   BOOKE_INTERRUPT_FP_UNAVAIL,
-   BOOKE_INTERRUPT_SYSCALL,
-   BOOKE_INT

Re: [PATCH 1/3] kvmppc: optimize irq delivery path

2008-10-12 Thread Christian Ehrhardt

Hollis Blanchard wrote:

On Fri, 2008-10-10 at 12:59 +0200, [EMAIL PROTECTED] wrote:
  

From: Christian Ehrhardt <[EMAIL PROTECTED]>

In kvmppc_deliver_interrupt is just one case left in the switch and it is a
rare one (less than 8%) when looking at the exit numbers. Therefore we can
at least drop the switch/case and if an if. I inserted an unlikely too, but
that's open for discussion.

In kvmppc_can_deliver_interrupt all frequent cases are in the default case.
I know compilers are smart but we can make it easier for them. By writing
down all options and removing the default case combined with the fact that
ithe values are constants 0..15 should allow the compiler to write an easy
jump table.
Modifying kvmppc_can_deliver_interrupt pointed me to the fact that gcc seems
to be unable to reduce priority_exception[x] to a build time constant.
Therefore I changed the usage of the translation arrays in the interrupt
delivery path completely. It is now using priority without translation to irq
on the full irq delivery path.
To be able to do that ivpr regs are stored by their priority now.



I like this, but a few notes:

Why did you convert exception_priority[] to int? AFAICS it still only
holds values 0-15, and using chars would shrink it from 2 32-byte
cachelines (3 unaligned) to half of one.
  
Your right, I changed it while modifying the code to match the type used 
to call functions for a test and forgot to revert it.

Will be changed in v2.

It looks like you applied this on top of the pvmem patches. I guess the
performance benefit is significant enough to apply those, but I'll have
to find the patches again.
  

I can rebase them to bring them in pre pvmem, no need you do that work.
This also fixed the dependencies to e.g. the exit timing patches.

Applying pv patches too would be nice, we can talk this week about that 
more in detail (if/when/how to do it).

I think the IVOR emulation has gotten wide enough that you can add some
newlines.
  
I need to run checkpatch once more on the current version anyway - I 
just wanted to put that out for discussion on friday, thats why I missed 
those 80+ lines :-/

AFAICS the *_PRIO constants aren't used in assembly, so do they need to
go into kvm_asm.h?
  
I wanted to place them near the non _PRIO irq constants, not needed for 
the code but nice to understand the code.
But your right, officially I think they should stay in asm/kvm_ppc.h - I 
can relocate them in v2 of the patches.


--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] kvmppc: optimize kvm stat handling

2008-10-10 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Currently we use an unneicessary if&switch to detect some cases.
To be honest we don't need the ligh_exits counter anyway, because we can
calculate it out of others. Sum_exits can also be calculated, so we can
remove that too. 
MMIO, DCR  and INTR can be counted on other places without these
additional control structures (The INTR case was never hit anyway).

The handling of BOOKE_INTERRUPT_EXTERNAL/BOOKE_INTERRUPT_DECREMENTER is
similar, but we can avoid the additional if when copying 3 lines of code.
I thought about a goto there to prevent duplicate lines, but rewriting three
lines should be better style than a goto cross switch/case statements (its
also not enough code to justify a new inline function).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 booke_guest.c |   40 
 1 file changed, 12 insertions(+), 28 deletions(-)

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -36,11 +36,9 @@
 #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
 
 struct kvm_stats_debugfs_item debugfs_entries[] = {
-   { "exits",  VCPU_STAT(sum_exits) },
{ "mmio",   VCPU_STAT(mmio_exits) },
{ "dcr",VCPU_STAT(dcr_exits) },
{ "sig",VCPU_STAT(signal_exits) },
-   { "light",  VCPU_STAT(light_exits) },
{ "itlb_r", VCPU_STAT(itlb_real_miss_exits) },
{ "itlb_v", VCPU_STAT(itlb_virt_miss_exits) },
{ "dtlb_r", VCPU_STAT(dtlb_real_miss_exits) },
@@ -270,7 +268,16 @@
break;
 
case BOOKE_INTERRUPT_EXTERNAL:
+   vcpu->stat.ext_intr_exits++;
+   set_last_exit_type(EXT_INTR_EXITS);
+   if (need_resched())
+   cond_resched();
+   r = RESUME_GUEST;
+   break;
+
case BOOKE_INTERRUPT_DECREMENTER:
+   vcpu->stat.dec_exits++;
+   set_last_exit_type(DEC_EXITS);
/* Since we switched IVPR back to the host's value, the host
 * handled this interrupt the moment we enabled interrupts.
 * Now we just offer it a chance to reschedule the guest. */
@@ -281,13 +288,6 @@
 * misses before ceding control. */
if (need_resched())
cond_resched();
-   if (exit_nr == BOOKE_INTERRUPT_DECREMENTER) {
-   vcpu->stat.dec_exits++;
-   set_last_exit_type(DEC_EXITS);
-   } else {
-   vcpu->stat.ext_intr_exits++;
-   set_last_exit_type(EXT_INTR_EXITS);
-   }
r = RESUME_GUEST;
break;
 
@@ -313,6 +313,7 @@
break;
case EMULATE_DO_DCR:
run->exit_reason = KVM_EXIT_DCR;
+   vcpu->stat.dcr_exits++;
set_last_exit_type(DCR_EXITS);
r = RESUME_HOST;
break;
@@ -415,6 +416,7 @@
 * actually RAM. */
r = kvmppc_emulate_mmio(run, vcpu);
set_last_exit_type(MMIO_EXITS);
+   vcpu->stat.mmio_exits++;
}
 
break;
@@ -485,8 +487,6 @@
 
kvmppc_check_and_deliver_interrupts(vcpu);
 
-   /* Do some exit accounting. */
-   vcpu->stat.sum_exits++;
if (!(r & RESUME_HOST)) {
/* To avoid clobbering exit_reason, only check for signals if
 * we aren't already exiting to userspace for some other
@@ -494,24 +494,8 @@
if (signal_pending(current)) {
run->exit_reason = KVM_EXIT_INTR;
r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
-
+   set_last_exit_type(SIGNAL_EXITS);
vcpu->stat.signal_exits++;
-   set_last_exit_type(SIGNAL_EXITS);
-   } else {
-   vcpu->stat.light_exits++;
-   }
-   } else {
-   switch (run->exit_reason) {
-   case KVM_EXIT_MMIO:
-   vcpu->stat.mmio_exits++;
-   break;
-   case KVM_EXIT_DCR:
-   vcpu->stat.dcr_exits++;
-   break;
-   case KVM_EXIT_INTR:
-   vcpu->stat.signal_exits++;
-   set_last_exit_type(SIGNAL_EXITS);
-   break;
}
}
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] kvmppc: optimize irq delivery path

2008-10-10 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

In kvmppc_deliver_interrupt is just one case left in the switch and it is a
rare one (less than 8%) when looking at the exit numbers. Therefore we can
at least drop the switch/case and if an if. I inserted an unlikely too, but
that's open for discussion.

In kvmppc_can_deliver_interrupt all frequent cases are in the default case.
I know compilers are smart but we can make it easier for them. By writing
down all options and removing the default case combined with the fact that
ithe values are constants 0..15 should allow the compiler to write an easy
jump table.
Modifying kvmppc_can_deliver_interrupt pointed me to the fact that gcc seems
to be unable to reduce priority_exception[x] to a build time constant.
Therefore I changed the usage of the translation arrays in the interrupt
delivery path completely. It is now using priority without translation to irq
on the full irq delivery path.
To be able to do that ivpr regs are stored by their priority now.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/kvm/booke_guest.c |  144 +
 arch/powerpc/kvm/emulate.c |   64 +-
 arch/powerpc/kvm/powerpc.c |5 -
 include/asm-powerpc/kvm_asm.h  |   18 +
 include/asm-powerpc/kvm_ppc.h  |9 +-
 5 files changed, 117 insertions(+), 123 deletions(-)

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -73,62 +73,42 @@
 #endif
 
 static const u32 interrupt_msr_mask[16] = {
-   [BOOKE_INTERRUPT_CRITICAL]  = MSR_ME,
-   [BOOKE_INTERRUPT_MACHINE_CHECK] = 0,
-   [BOOKE_INTERRUPT_DATA_STORAGE]  = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_INST_STORAGE]  = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_EXTERNAL]  = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_ALIGNMENT] = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_PROGRAM]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_FP_UNAVAIL]= MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_SYSCALL]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_AP_UNAVAIL]= MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_DECREMENTER]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_FIT]   = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_WATCHDOG]  = MSR_ME,
-   [BOOKE_INTERRUPT_DTLB_MISS] = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_ITLB_MISS] = MSR_CE|MSR_ME|MSR_DE,
-   [BOOKE_INTERRUPT_DEBUG] = MSR_ME,
+   [BOOKE_INTERRUPT_PRIO_CRITICAL]  = MSR_ME,
+   [BOOKE_INTERRUPT_PRIO_MACHINE_CHECK] = 0,
+   [BOOKE_INTERRUPT_PRIO_DATA_STORAGE]  = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_INST_STORAGE]  = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_EXTERNAL]  = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_ALIGNMENT] = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_PROGRAM]   = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_FP_UNAVAIL]= MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_SYSCALL]   = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_AP_UNAVAIL]= MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_DECREMENTER]   = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_FIT]   = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_WATCHDOG]  = MSR_ME,
+   [BOOKE_INTERRUPT_PRIO_DTLB_MISS] = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_ITLB_MISS] = MSR_CE|MSR_ME|MSR_DE,
+   [BOOKE_INTERRUPT_PRIO_DEBUG] = MSR_ME,
 };
 
-const unsigned char exception_priority[] = {
-   [BOOKE_INTERRUPT_DATA_STORAGE] = 0,
-   [BOOKE_INTERRUPT_INST_STORAGE] = 1,
-   [BOOKE_INTERRUPT_ALIGNMENT] = 2,
-   [BOOKE_INTERRUPT_PROGRAM] = 3,
-   [BOOKE_INTERRUPT_FP_UNAVAIL] = 4,
-   [BOOKE_INTERRUPT_SYSCALL] = 5,
-   [BOOKE_INTERRUPT_AP_UNAVAIL] = 6,
-   [BOOKE_INTERRUPT_DTLB_MISS] = 7,
-   [BOOKE_INTERRUPT_ITLB_MISS] = 8,
-   [BOOKE_INTERRUPT_MACHINE_CHECK] = 9,
-   [BOOKE_INTERRUPT_DEBUG] = 10,
-   [BOOKE_INTERRUPT_CRITICAL] = 11,
-   [BOOKE_INTERRUPT_WATCHDOG] = 12,
-   [BOOKE_INTERRUPT_EXTERNAL] = 13,
-   [BOOKE_INTERRUPT_FIT] = 14,
-   [BOOKE_INTERRUPT_DECREMENTER] = 15,
+const unsigned int exception_priority[] = {
+   [BOOKE_INTERRUPT_DATA_STORAGE] = BOOKE_INTERRUPT_PRIO_DATA_STORAGE,
+   [BOOKE_INTERRUPT_INST_STORAGE] = BOOKE_INTERRUPT_PRIO_INST_STORAGE,
+   [BOOKE_INTERRUPT_ALIGNMENT] = BOOKE_INTERRUPT_PRIO_ALIGNMENT,
+   [BOOKE_INTERRUPT_PROGRAM] = BOOKE_INTERRUPT_PRIO_PROGRAM,
+   [BOOKE_INTERRUPT_FP_UNAVAIL] = BOOKE_INTERRUPT_PRIO_FP_UNAVAIL,
+   [BOOKE_INTERRUPT_SYSCALL] = BOOKE_INTERRUPT_PRIO_SYSCALL,
+   [BOOKE_INTERRUPT_AP_UNAVAIL] = BOOKE_INTERRUPT_PRIO_AP_UNAVAIL,
+   [BOOKE_INTERRUPT_DTLB_MISS] = BOOKE_INTERRU

[PATCH 3/3] kvmppc: optimize find first bit

2008-10-10 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Since we use a unsigned long here anyway we can use the optimized __ffs.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -227,7 +227,7 @@
unsigned long *pending = &vcpu->arch.pending_exceptions;
unsigned int priority;
 
-   priority = find_first_bit(pending, BITS_PER_BYTE * sizeof(*pending));
+   priority = __ffs(*pending);
while (priority <= BOOKE_MAX_INTERRUPT) {
if (kvmppc_can_deliver_interrupt_by_prio(vcpu, priority)) {
kvmppc_clear_exception_by_prio(pending, priority);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] kvmppc: optimize path run on every exit

2008-10-10 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

A small patch series of optimizations out of our discussions and my
experiments this week.
All patches improve the generic path executed for every exit we take,
therefore even a littel improvement can help a lot.

I would be happy if we could apply those soon. I'll continue looking into the
TLB stuff eating ~30% of our time. But since that might take a while I would be
happy if these three patches could be applied now (and relieve me, by not
having to keep them in sync).

Comments welcome, especially since exits still feel too long (current
assumption cache or tlb issues). See my other mails about exit timing on
kvm-ppc@vger.kernel.org

[patches in series]
Subject: [PATCH 1/3] kvmppc: optimize irq delivery path
Subject: [PATCH 2/3] kvmppc: optimize kvm stat handling
Subject: [PATCH 3/3] kvmppc: optimize find first bit

---
[diffstat]
 arch/powerpc/kvm/booke_guest.c   |  184 +++
 b/arch/powerpc/kvm/booke_guest.c |2
 b/arch/powerpc/kvm/emulate.c |   64 ++---
 b/arch/powerpc/kvm/powerpc.c |5 -
 b/include/asm-powerpc/kvm_asm.h  |   18 +++
 b/include/asm-powerpc/kvm_ppc.h  |9 -
 6 files changed, 130 insertions(+), 152 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


exit timing analysis - optimizations v1

2008-10-10 Thread Christian Ehrhardt
  1534 
sum  2952467 avg 292.1788 stddev  295.933 %  2.04
   DCR count   5428 min 40 max209 
sum   246168 avg  45.3515 stddev6.758 %  0.17
SIGNAL count695 min 65 max   3755 
sum89767 avg 129.1612 stddev  314.421 %  0.06
  ITLBREAL count  80045 min 13 max108 
sum  1063127 avg  13.2816 stddev2.338 %  0.73
  ITLBVIRT count1000585 min 21 max 264827 
sum 24300596 avg  24.2864 stddev  264.753 % 16.78
  DTLBREAL count  91206 min 13 max 69 
sum  1285214 avg  14.0913 stddev2.225 %  0.89
  DTLBVIRT count 977434 min 21 max   1446 
sum 24007008 avg  24.5613 stddev4.426 % 16.58
   SYSCALL count  10460 min 11 max 55 
sum   116447 avg  11.1326 stddev1.929 %  0.08
   ISI count  11724 min 11 max 61 
sum   130007 avg  11.0890 stddev1.929 %  0.09
   DSI count  20737 min 11 max 57 
sum   230009 avg  11.0917 stddev1.914 %  0.16
  EMULINST count5683356 min 11 max   3778 
sum 79339467 avg  13.9600 stddev   50.275 % 54.78
   DEC count  13079 min 50 max826 
sum   732712 avg  56.0220 stddev   22.382 %  0.51
EXTINT count 55 min 30 max   1478 
sum10996 avg 199.9273 stddev  238.150 %  0.01
FP_UNAVAIL count280 min 11 max 53 
sum 3163 avg  11.2964 stddev3.495 %  0.00
TIMEINGUEST count7905189 min  0 max   3688 
sum 10330742 avg   1.3068 stddev8.970 %  7.13
csum   15810378   
sumsum 144837890 => ~2:24 runtime
  
sumavg   7241894


PV:
  MMIO count  12505 min 46 max   3087 
sum  3693782 avg 295.3844 stddev  260.788 %  4.01
   DCR count   5595 min 40 max706 
sum   273578 avg  48.8969 stddev   31.305 %  0.30
SIGNAL count654 min 65 max   4132 
sum   300027 avg 458.7569 stddev  571.130 %  0.33
  ITLBREAL count  71711 min 13 max104 
sum   943053 avg  13.1507 stddev2.360 %  1.02
  ITLBVIRT count 750649 min 21 max   1503 
sum 18178245 avg  24.2167 stddev7.335 % 19.71
  DTLBREAL count  83356 min 13 max102 
sum  1146242 avg  13.7512 stddev2.406 %  1.24
DTLBPV count  30086 min 20 max237 
sum   653556 avg  21.7229 stddev4.639 %  0.71
  DTLBVIRT count 772811 min 21 max713 
sum 19079477 avg  24.6884 stddev6.593 % 20.69
   SYSCALL count   7647 min 11 max 57 
sum84821 avg  11.0921 stddev1.897 %  0.09
 HCALL count  1 min 19 max 19 
sum   19 avg  19. stddev0.000 %  0.00
   ISI count   9895 min 11 max 73 
sum   109667 avg  11.0831 stddev1.904 %  0.12
   DSI count  17974 min 10 max 57 
sum   199504 avg  11.0996 stddev2.046 %  0.22
  EMULINST count2567245 min 11 max   4212 
sum 40501314 avg  15.7762 stddev   65.673 % 43.92
   DEC count   7488 min 51 max641 
sum   426813 avg  56.9996 stddev   23.893 %  0.46
EXTINT count   2215 min 31 max   1677 
sum   297495 avg 134.3093 stddev  116.219 %  0.32
FP_UNAVAIL count258 min 11 max 11 
sum 2838 avg  11. stddev0.000 %  0.00
TIMEINGUEST count4340090 min  0 max   3850 
sum  6316079 avg   1.4553 stddev   12.599 %  6.85
csum8680180   
sumsum  92206510 => ~1:32 runtime
  
sumavg   4610325


--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: exit timing analysis v1 - comments&discussions welcome

2008-10-10 Thread Christian Ehrhardt


Hollis Blanchard wrote:

Also, it looks like we use the generic find_first_bit(). That may be
more expensive than we'd like. However, since
vcpu->arch.pending_exceptions is a single long (not an arbitrary sized
bitfield), we should be able to use ffs() instead, which has an
optimized PowerPC implementation. That might help a lot.

We might even be able to replace find_next_bit() too, by shifting a mask
over each loop, but I don't think we'll have to, since I expect the
common case to be we can deliver the first pending exception. (Worth
checking? :)
  

FFS for first one is working fine.
To check if modifying the following Find next bit to mask&__ffs I did 
some quick accounting and it seems not to be worth.


On the exits casued by external interrupts we hit "find next bit" in 
~50% of the cases (MMIO, DCR, DEC, EXITINT).
But on all the frequent cases like DTLVVIRT, ITLBVIRT and EMULINST we 
are at ~2.75%.

Therefore it should be ok to keep the generic find_next_bit there.

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: exit timing analysis v1 - comments&discussions welcome

2008-10-09 Thread Christian Ehrhardt
Ok, looking at clear&deliver in detail I made some minor changes, but 
eventually it has no single point to improve.
Most of the time of the 14% in clear%deliver is lost in 
kvmppc_mmu_priv_switch (~8%), the rest spread evenly among the code - 
nothing obvious (maybe some cache misses though).


This code has to be touched anyway when going for a change in the 
guest/host (shadow)TLB management.


Christian Ehrhardt wrote:
I modified the code according to your comments and my ideas, the new 
values are shown in column impISF (irq delivery, Stat, FindFirstBit)


I changed some code of the statistic updating and the interrupt 
delivery and got this:

base - impirq (d3) - impstat (d5) - impboth  - impISF
a)  12.57% -  11.13% -  12.05%  -  11.03% - 12.28%  exit, 
saving guest state (booke_interrupt.S)
b)   7.37% -   9.38% -   8.69%  -   8.07% - 10.13%  reaching 
kvmppc_handle_exit
c)   7.38% -   7.20% -   7.49%  -   9.78% -  7.85%  syscall 
exit is checked and a interrupt is queued using kvmppc_queue_exception
d1)  2.49% -   3.39% -   2.56%  -   3.30% -  3.70%  some 
checks for all exits
d2)  8.84% -   8.56% -   9.28%  -   8.31% -  6.07%  finding 
first bit in kvmppc_check_and_deliver_interrupts
d3)  6.53% -   5.25% -   6.63%  -   5.10% -  4.27%  
can_deliver in kvmppc_check_and_deliver_interrupts
d4) 13.66% -  15.37% -  14.12%  -  14.92% - 13.96%  
clear&deliver exception in kvmppc_check_and_deliver_interrupts
d5)  3.65% -   4.57% -   2.68%  -   4.41% -  3.77%  updating 
kvm_stat statistics
e)   6.55% -   6.30% -   6.30%  -   5.89% -  6.74%  returning 
from kvmppc_handle_exit to booke_interrupt.S
f1) 30.90% -  28.78% -  30.16%  -  29.16% - 31.19%  restoring 
guest tlb
f2)  4.81% -   4.77% -   5.06%  -   4.66% -  5.17%  restoring 
guest state ([s]regs)


We all see the measurement inaccuracy, but the last columns look good 
at the improved sections d2, d3 and d4.
I'll remove these detailed tracing soon and make a larger test hoping 
that this will not have the inaccuracy.
But for now I still wonder about the ~14% for clear&deliver - that 
should just not be "that" much.
It should be worth to look into that section once again more in detail 
first.


Christian Ehrhardt wrote:

Hollis Blanchard wrote:

On Wed, 2008-10-08 at 15:49 +0200, Christian Ehrhardt wrote:
 
Wondering about that 30.5% for postprocessing and 
kvmppc_check_and_deliver_interrupts I quickly checked that in 
detail - part d is now divided in 4 subparts.
I also looked at the return to guest path if the expected part 
(restoring tlb) is really the main time eater there. The result 
shows clearly that it is.


more detailed breakdown:
a)  10.94%  - exit, saving guest state (booke_interrupt.S)
b)   8.12% - reaching kvmppc_handle_exit
c)   7.59%  - syscall exit is checked and a interrupt is queued 
using kvmppc_queue_exception

d1)  3.33%  - some checks for all exits
d2)  8.29% - finding first bit in kvmppc_check_and_deliver_interrupts
d3) 17.20% - can_deliver/clear&deliver exception in 
kvmppc_check_and_deliver_interrupts

d4)  4.47% - updating kvm_stat statistics
e)   6.13% - returning from kvmppc_handle_exit to booke_interrupt.S
f1) 29.18% - restoring guest tlb
f2)  4.69% - restoring guest state ([s]regs)

These fractions are % of our ~12µs syscall exit.
=> restoring tlb on each reenter = 4µs constant overhead
=> looking a bit into irq delivery and other constant things like 
kvm_stat updating




...
 

Now I go for the TLB replacement in f1.



Hang on... does d3 make sense to you? It doesn't to me, and if 
there's a

bug there it will be easier to fix than rewriting the TLB code. :)
  

I did not give up improving that part too :-)

I think your core runs at 667MHz, right? So that's 1.5 ns/cycle. 17.20%
of 12µs is 2064ns, or about 1300 cycles. (Check my math.)
  

I get the same results. 1% ~ 80 cycles.

Now when I look at kvmppc_core_deliver_interrupts(), I'm not sure where
that time is going. We're assuming the first_first_bit() loop usually
executes once, for syscall. Does it actually execute more than that? I
don't expect any of kvmppc_can_deliver_interrupt(),
kvmppc_booke_clear_exception(), or kvmppc_booke_deliver_interrupt() to
take lots of time.
  
You can see below that I already had a more detailed breakdown in my 
old mail:

[...]
d2)  8.84% -   8.56% -   9.28%  -   8.31% finding first bit 
in kvmppc_check_and_deliver_interrupts
d3)  6.53% -   5.25% -   6.63%  -   5.10% can_deliver in 
kvmppc_check_and_deliver_interrupts
d4) 13.66% -  15.37% -  14.12%  -  14.92% clear&deliver 
exception in kvmppc_check_and_deliver_interrupts

[...]
Could it be cache effects? exception_priority[] and 
priority_exception[]
are 16 bytes each, and our L1 cacheline is 32 bytes, so they should 
both

fit into one... except they're not aligned.
  
I would 

Re: exit timing analysis v1 - comments&discussions welcome

2008-10-09 Thread Christian Ehrhardt
I modified the code according to your comments and my ideas, the new 
values are shown in column impISF (irq delivery, Stat, FindFirstBit)


I changed some code of the statistic updating and the interrupt delivery 
and got this:

base - impirq (d3) - impstat (d5) - impboth  - impISF
a)  12.57% -  11.13% -  12.05%  -  11.03% - 12.28%  exit, saving 
guest state (booke_interrupt.S)
b)   7.37% -   9.38% -   8.69%  -   8.07% - 10.13%  reaching 
kvmppc_handle_exit
c)   7.38% -   7.20% -   7.49%  -   9.78% -  7.85%  syscall exit 
is checked and a interrupt is queued using kvmppc_queue_exception
d1)  2.49% -   3.39% -   2.56%  -   3.30% -  3.70%  some checks 
for all exits
d2)  8.84% -   8.56% -   9.28%  -   8.31% -  6.07%  finding 
first bit in kvmppc_check_and_deliver_interrupts
d3)  6.53% -   5.25% -   6.63%  -   5.10% -  4.27%  can_deliver 
in kvmppc_check_and_deliver_interrupts
d4) 13.66% -  15.37% -  14.12%  -  14.92% - 13.96%  
clear&deliver exception in kvmppc_check_and_deliver_interrupts
d5)  3.65% -   4.57% -   2.68%  -   4.41% -  3.77%  updating 
kvm_stat statistics
e)   6.55% -   6.30% -   6.30%  -   5.89% -  6.74%  returning 
from kvmppc_handle_exit to booke_interrupt.S
f1) 30.90% -  28.78% -  30.16%  -  29.16% - 31.19%  restoring 
guest tlb
f2)  4.81% -   4.77% -   5.06%  -   4.66% -  5.17%  restoring 
guest state ([s]regs)


We all see the measurement inaccuracy, but the last columns look good at 
the improved sections d2, d3 and d4.
I'll remove these detailed tracing soon and make a larger test hoping 
that this will not have the inaccuracy.
But for now I still wonder about the ~14% for clear&deliver - that 
should just not be "that" much.
It should be worth to look into that section once again more in detail 
first.


Christian Ehrhardt wrote:

Hollis Blanchard wrote:

On Wed, 2008-10-08 at 15:49 +0200, Christian Ehrhardt wrote:
 
Wondering about that 30.5% for postprocessing and 
kvmppc_check_and_deliver_interrupts I quickly checked that in detail 
- part d is now divided in 4 subparts.
I also looked at the return to guest path if the expected part 
(restoring tlb) is really the main time eater there. The result 
shows clearly that it is.


more detailed breakdown:
a)  10.94%  - exit, saving guest state (booke_interrupt.S)
b)   8.12% - reaching kvmppc_handle_exit
c)   7.59%  - syscall exit is checked and a interrupt is queued 
using kvmppc_queue_exception

d1)  3.33%  - some checks for all exits
d2)  8.29% - finding first bit in kvmppc_check_and_deliver_interrupts
d3) 17.20% - can_deliver/clear&deliver exception in 
kvmppc_check_and_deliver_interrupts

d4)  4.47% - updating kvm_stat statistics
e)   6.13% - returning from kvmppc_handle_exit to booke_interrupt.S
f1) 29.18% - restoring guest tlb
f2)  4.69% - restoring guest state ([s]regs)

These fractions are % of our ~12µs syscall exit.
=> restoring tlb on each reenter = 4µs constant overhead
=> looking a bit into irq delivery and other constant things like 
kvm_stat updating




...
 

Now I go for the TLB replacement in f1.



Hang on... does d3 make sense to you? It doesn't to me, and if there's a
bug there it will be easier to fix than rewriting the TLB code. :)
  

I did not give up improving that part too :-)

I think your core runs at 667MHz, right? So that's 1.5 ns/cycle. 17.20%
of 12µs is 2064ns, or about 1300 cycles. (Check my math.)
  

I get the same results. 1% ~ 80 cycles.

Now when I look at kvmppc_core_deliver_interrupts(), I'm not sure where
that time is going. We're assuming the first_first_bit() loop usually
executes once, for syscall. Does it actually execute more than that? I
don't expect any of kvmppc_can_deliver_interrupt(),
kvmppc_booke_clear_exception(), or kvmppc_booke_deliver_interrupt() to
take lots of time.
  
You can see below that I already had a more detailed breakdown in my 
old mail:

[...]
d2)  8.84% -   8.56% -   9.28%  -   8.31% finding first bit in 
kvmppc_check_and_deliver_interrupts
d3)  6.53% -   5.25% -   6.63%  -   5.10% can_deliver in 
kvmppc_check_and_deliver_interrupts
d4) 13.66% -  15.37% -  14.12%  -  14.92% clear&deliver 
exception in kvmppc_check_and_deliver_interrupts

[...]

Could it be cache effects? exception_priority[] and priority_exception[]
are 16 bytes each, and our L1 cacheline is 32 bytes, so they should both
fit into one... except they're not aligned.
  
I would be so happy if I would have hardware performance counters like 
cache misses :-)

Also, it looks like we use the generic find_first_bit(). That may be
more expensive than we'd like. However, since
vcpu->arch.pending_exceptions is a single long (not an arbitrary sized
bitfield), we should be able to use ffs() instead, which has an
optimized PowerPC implementation. That might help a lot.
  

good idea.
I'll check this

Re: exit timing analysis v1 - comments&discussions welcome

2008-10-09 Thread Christian Ehrhardt

Hollis Blanchard wrote:

On Wed, 2008-10-08 at 15:49 +0200, Christian Ehrhardt wrote:
  
Wondering about that 30.5% for postprocessing and 
kvmppc_check_and_deliver_interrupts I quickly checked that in detail - 
part d is now divided in 4 subparts.
I also looked at the return to guest path if the expected part 
(restoring tlb) is really the main time eater there. The result shows 
clearly that it is.


more detailed breakdown:
a)  10.94%  - exit, saving guest state (booke_interrupt.S)
b)   8.12% - reaching kvmppc_handle_exit
c)   7.59%  - syscall exit is checked and a interrupt is queued using 
kvmppc_queue_exception

d1)  3.33%  - some checks for all exits
d2)  8.29% - finding first bit in kvmppc_check_and_deliver_interrupts
d3) 17.20% - can_deliver/clear&deliver exception in 
kvmppc_check_and_deliver_interrupts

d4)  4.47% - updating kvm_stat statistics
e)   6.13% - returning from kvmppc_handle_exit to booke_interrupt.S
f1) 29.18% - restoring guest tlb
f2)  4.69% - restoring guest state ([s]regs)

These fractions are % of our ~12µs syscall exit.
=> restoring tlb on each reenter = 4µs constant overhead
=> looking a bit into irq delivery and other constant things like 
kvm_stat updating




...
  

Now I go for the TLB replacement in f1.



Hang on... does d3 make sense to you? It doesn't to me, and if there's a
bug there it will be easier to fix than rewriting the TLB code. :)
  

I did not give up improving that part too :-)

I think your core runs at 667MHz, right? So that's 1.5 ns/cycle. 17.20%
of 12µs is 2064ns, or about 1300 cycles. (Check my math.)
  

I get the same results. 1% ~ 80 cycles.

Now when I look at kvmppc_core_deliver_interrupts(), I'm not sure where
that time is going. We're assuming the first_first_bit() loop usually
executes once, for syscall. Does it actually execute more than that? I
don't expect any of kvmppc_can_deliver_interrupt(),
kvmppc_booke_clear_exception(), or kvmppc_booke_deliver_interrupt() to
take lots of time.
  
You can see below that I already had a more detailed breakdown in my old 
mail:

[...]
d2)  8.84% -   8.56% -   9.28%  -   8.31% finding first bit in 
kvmppc_check_and_deliver_interrupts
d3)  6.53% -   5.25% -   6.63%  -   5.10% can_deliver in 
kvmppc_check_and_deliver_interrupts
d4) 13.66% -  15.37% -  14.12%  -  14.92% clear&deliver 
exception in kvmppc_check_and_deliver_interrupts

[...]

Could it be cache effects? exception_priority[] and priority_exception[]
are 16 bytes each, and our L1 cacheline is 32 bytes, so they should both
fit into one... except they're not aligned.
  
I would be so happy if I would have hardware performance counters like 
cache misses :-)

Also, it looks like we use the generic find_first_bit(). That may be
more expensive than we'd like. However, since
vcpu->arch.pending_exceptions is a single long (not an arbitrary sized
bitfield), we should be able to use ffs() instead, which has an
optimized PowerPC implementation. That might help a lot.
  

good idea.
I'll check this and some other small improvements I have in mind.


We might even be able to replace find_next_bit() too, by shifting a mask
over each loop, but I don't think we'll have to, since I expect the
common case to be we can deliver the first pending exception. (Worth
checking? :)
  
I'm not sure. It's surely worth checking how often that second 
find_next_bit is called.

If that number is far too small it's not worth.

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: exit timing analysis v1 - comments&discussions welcome

2008-10-08 Thread Christian Ehrhardt
Wondering about that 30.5% for postprocessing and 
kvmppc_check_and_deliver_interrupts I quickly checked that in detail - 
part d is now divided in 4 subparts.
I also looked at the return to guest path if the expected part 
(restoring tlb) is really the main time eater there. The result shows 
clearly that it is.


more detailed breakdown:
a)  10.94%  - exit, saving guest state (booke_interrupt.S)
b)   8.12% - reaching kvmppc_handle_exit
c)   7.59%  - syscall exit is checked and a interrupt is queued using 
kvmppc_queue_exception

d1)  3.33%  - some checks for all exits
d2)  8.29% - finding first bit in kvmppc_check_and_deliver_interrupts
d3) 17.20% - can_deliver/clear&deliver exception in 
kvmppc_check_and_deliver_interrupts

d4)  4.47% - updating kvm_stat statistics
e)   6.13% - returning from kvmppc_handle_exit to booke_interrupt.S
f1) 29.18% - restoring guest tlb
f2)  4.69% - restoring guest state ([s]regs)

These fractions are % of our ~12µs syscall exit.
=> restoring tlb on each reenter = 4µs constant overhead
=> looking a bit into irq delivery and other constant things like 
kvm_stat updating


---
I changed some code of the statistic updating and the interrupt delivery 
and got this:

 base - impirq (d3) - impstat (d5) - impboth
a)  12.57% -  11.13% -  12.05%  -  11.03% exit, saving guest 
state (booke_interrupt.S)
b)   7.37% -   9.38% -   8.69%  -   8.07% reaching 
kvmppc_handle_exit
c)   7.38% -   7.20% -   7.49%  -   9.78%  syscall exit is 
checked and a interrupt is queued using kvmppc_queue_exception

d1)  2.49% -   3.39% -   2.56%  -   3.30% some checks for all exits
d2)  8.84% -   8.56% -   9.28%  -   8.31% finding first bit in 
kvmppc_check_and_deliver_interrupts
d3)  6.53% -   5.25% -   6.63%  -   5.10% can_deliver in 
kvmppc_check_and_deliver_interrupts
d4) 13.66% -  15.37% -  14.12%  -  14.92% clear&deliver 
exception in kvmppc_check_and_deliver_interrupts
d5)  3.65% -   4.57% -   2.68%  -   4.41% updating kvm_stat 
statistics
e)   6.55% -   6.30% -   6.30%  -   5.89% returning from 
kvmppc_handle_exit to booke_interrupt.S

f1) 30.90% -  28.78% -  30.16%  -  29.16% restoring guest tlb
f2)  4.81% -   4.77% -   5.06%  -   4.66% restoring guest state 
([s]regs)


Well the improvements (if existant) are too close to the measuring 
inaccuracy. Therefore I can't make any assumptions right now, but the 
patches seem at least to work.
I will test them soon with a longer testcase and a bit measureing 
overhead reduced to avoid some inaccuracy.


The patch to our kvm_stat counters would make sense for style reasons 
alone, so it is worth to try it :-)


Now I go for the TLB replacement in f1.
Christian

Christian Ehrhardt wrote:
As intended I separated the time of one of our exits into it's 
segments to see where we loose the constant base time.
I looked at the syscall exit which is pretty fast and does not deviate 
very much.


A little tracing and debugging later I can now show the rough 
breakdown where the time is spent for that exit:


avg time spent in the segments I checked:
a) 11.5%  - exit, saving guest state (booke_interrupt.S)
b) 8.5% - reaching kvmppc_handle_exit
c) 10%  - syscall exit is checked and a interrupt is queued using 
kvmppc_queue_exception
d) 30.5%  - postprocessing for all exits = 
kvmppc_check_and_deliver_interrupts and updating some statistics

e) 5.5% - returning from kvmppc_handle_exit to booke_interrupt.S
f) 34%  - restoring guest state tlb/regs (booke_interrupt.S)

Ok, looking at these numbers I think we have two areas to check in 
detail.
- On one hand the post processing part (d) actually should not take 
that much time.
- On the other hand we might be able to improve the last segment by 
chanign our tlb management (Liu made a suggestion on the list two 
weeks ago)


When thinking about this breakdown while having the complete timing in 
mind (see below) shows us that the average time spent for one of our 
most frequent exit is near the minimum duration (EMUL). This means if 
we can reduce some of the constant overehad this might really help us 
in those frequent and hot paths (also birt tlb misses will benefit 
from that).


I continue on that and keep you all updated.
Christian

Christian Ehrhardt wrote:
Today I refactored my code in a way that it might eventually get 
upstream.
That means I removed some debug blocks, made it configurable and 
print output only on request per sysrq.
Feel free to review that code now, otherwise wait for my separate rfc 
post that will follow ~next week.


Additionally I realized in a discussion that my host system was still 
configured in demo mode (X11+xfce, dhcpd, avahi, ... running in host).
I took some updated numbers without all those background activities - 
testacase again boot, login, ls, kill.


I intend to the irq path in detail as suggested and first of all I'll 
try to get some timing of the &q

Re: exit timing analysis v1 - comments&discussions welcome

2008-10-07 Thread Christian Ehrhardt
As intended I separated the time of one of our exits into it's segments 
to see where we loose the constant base time.
I looked at the syscall exit which is pretty fast and does not deviate 
very much.


A little tracing and debugging later I can now show the rough breakdown 
where the time is spent for that exit:


avg time spent in the segments I checked:
a) 11.5%  - exit, saving guest state (booke_interrupt.S)
b) 8.5% - reaching kvmppc_handle_exit
c) 10%  - syscall exit is checked and a interrupt is queued using 
kvmppc_queue_exception
d) 30.5%  - postprocessing for all exits = 
kvmppc_check_and_deliver_interrupts and updating some statistics

e) 5.5% - returning from kvmppc_handle_exit to booke_interrupt.S
f) 34%  - restoring guest state tlb/regs (booke_interrupt.S)

Ok, looking at these numbers I think we have two areas to check in detail.
- On one hand the post processing part (d) actually should not take that 
much time.
- On the other hand we might be able to improve the last segment by 
chanign our tlb management (Liu made a suggestion on the list two weeks ago)


When thinking about this breakdown while having the complete timing in 
mind (see below) shows us that the average time spent for one of our 
most frequent exit is near the minimum duration (EMUL). This means if we 
can reduce some of the constant overehad this might really help us in 
those frequent and hot paths (also birt tlb misses will benefit from that).


I continue on that and keep you all updated.
Christian

Christian Ehrhardt wrote:
Today I refactored my code in a way that it might eventually get 
upstream.
That means I removed some debug blocks, made it configurable and print 
output only on request per sysrq.
Feel free to review that code now, otherwise wait for my separate rfc 
post that will follow ~next week.


Additionally I realized in a discussion that my host system was still 
configured in demo mode (X11+xfce, dhcpd, avahi, ... running in host).
I took some updated numbers without all those background activities - 
testacase again boot, login, ls, kill.


I intend to the irq path in detail as suggested and first of all I'll 
try to get some timing of the "segments" of such a call.
This should show us where we loose our "constant base time" and give 
me some hints when looking at it in detail.


FYI - new numbers without high background load (monospace recommended):
NOPV:
   MMIO count  10105 min 46 max   1534 
sum  2952467 avg 292.1788 stddev  295.933 %  2.04
DCR count   5428 min 40 max209 
sum   246168 avg  45.3515 stddev6.758 %  0.17
 SIGNAL count695 min 65 max   3755 
sum89767 avg 129.1612 stddev  314.421 %  0.06
   ITLBREAL count  80045 min 13 max108 
sum  1063127 avg  13.2816 stddev2.338 %  0.73
   ITLBVIRT count1000585 min 21 max 264827 
sum 24300596 avg  24.2864 stddev  264.753 % 16.78
   DTLBREAL count  91206 min 13 max 69 
sum  1285214 avg  14.0913 stddev2.225 %  0.89
   DTLBVIRT count 977434 min 21 max   1446 
sum 24007008 avg  24.5613 stddev4.426 % 16.58
SYSCALL count  10460 min 11 max 55 
sum   116447 avg  11.1326 stddev1.929 %  0.08
ISI count  11724 min 11 max 61 
sum   130007 avg  11.0890 stddev1.929 %  0.09
DSI count  20737 min 11 max 57 
sum   230009 avg  11.0917 stddev1.914 %  0.16
   EMULINST count5683356 min 11 max   3778 
sum 79339467 avg  13.9600 stddev   50.275 % 54.78
DEC count  13079 min 50 max826 
sum   732712 avg  56.0220 stddev   22.382 %  0.51
 EXTINT count 55 min 30 max   1478 
sum10996 avg 199.9273 stddev  238.150 %  0.01
 FP_UNAVAIL count280 min 11 max 53 
sum 3163 avg  11.2964 stddev3.495 %  0.00
TIMEINGUEST count7905189 min  0 max   3688 
sum 10330742 avg   1.3068 stddev8.970 %  7.13
 csum   15810378   
sumsum 144837890 => ~2:24 runtime
   
sumavg   7241894


PV:
   MMIO count  12505 min 46 max   3087 
sum  3693782 avg 295.3844 stddev  260.788 %  4.01
DCR count   5595 min 40 max706 
sum   273578 avg  48.8969 stddev   31.305 %  0.30
 SIGNAL count654 min 65 max   4132 
sum   300027 avg

[PATCH] kvmppc: fix set regs to take care of msr change implications

2008-10-02 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

When changing some msr bits e.g. problem state we need to take special
care of that. We call the function in our mtmsr emulation (not needed for
wrtee[i]), but we don't call kvmppc_set_msr if we change msr via set_regs
ioctl.
It's a corner case we never hit so far, but I assume it should be
kvmppc_set_msr in our arch set regs function (I found it because it is also
a corner case when using pv support which would miss the update otherwise).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 booke_guest.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[diff]
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -584,7 +580,7 @@
vcpu->arch.ctr = regs->ctr;
vcpu->arch.lr = regs->lr;
vcpu->arch.xer = regs->xer;
-   vcpu->arch.msr = regs->msr;
+   kvmppc_set_msr(vcpu, regs->msr);
vcpu->arch.srr0 = regs->srr0;
vcpu->arch.srr1 = regs->srr1;
vcpu->arch.sprg0 = regs->sprg0;

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: exit timing analysis v1 - comments&discussions welcome

2008-10-02 Thread Christian Ehrhardt
 2215 min 31 max   1677 
sum   297495 avg 134.3093 stddev  116.219 %  0.32
 FP_UNAVAIL count258 min 11 max 11 
sum 2838 avg  11. stddev0.000 %  0.00
TIMEINGUEST count4340090 min  0 max   3850 
sum  6316079 avg   1.4553 stddev   12.599 %  6.85
 csum8680180   
sumsum  92206510 => ~1:32 runtime
   
sumavg   4610325


Hollis Blanchard wrote:

On Thu, 2008-09-25 at 17:32 +0800, Liu Yu-B13201 wrote:

On Wed, 2008-09-24 at 11:24 +0200, Christian Ehrhardt wrote:
 count  min max 
sumavgstddev time%
EMULINST 6,423,699   12 247,582  
91,732,705

14.2804   241.200 45.36
ITLBVIRT 1,777,242   21 264,257  
47,116,557

26.5111   286.040 23.30
DTLBVIRT 1,544,241   22 263,947  
41,765,447

27.0459   218.997 20.65

(The max here is of course when the guest was de-scheduled in favor of
another host process.)

I think it's interesting that the min instruction emulation time is 12
usecs. In fact, our "null" exits where we do almost no 
processing (ISI,

DSI, syscall) are 11 usecs, which suggests we have a problem with
interrupt handler overhead (for all exit types).


Will you consider about moving tlb manipulation out of entering path?
Examining the modify array may cost some time.


Yes, definitely.

That's about the only thing I can see in the 440 interrupt path that
might take significant time. Unfortunately we can't profile that code
because we have no performance counters, so finding the problem will
require some experimentation.



--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -348,5 +348,12 @@
 	DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
 #endif
 
+#ifdef CONFIG_KVM_BOOKE_EXIT_TIMING
+	DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu, arch.timing_exit.tv32.tbu));
+	DEFINE(VCPU_TIMING_EXIT_TBL, offsetof(struct kvm_vcpu, arch.timing_exit.tv32.tbl));
+	DEFINE(VCPU_TIMING_LAST_ENTER_TBU, offsetof(struct kvm_vcpu, arch.timing_last_enter.tv32.tbu));
+	DEFINE(VCPU_TIMING_LAST_ENTER_TBL, offsetof(struct kvm_vcpu, arch.timing_last_enter.tv32.tbl));
+#endif
+
 	return 0;
 }
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -37,6 +37,14 @@
 	  Provides host support for KVM on Book E PowerPC processors. Currently
 	  this works on 440 processors only.
 
+config KVM_BOOKE_EXIT_TIMING
+	bool "Trace detailed exit Timing"
+	depends on KVM_BOOKE_HOST
+	---help---
+	  Inserts code to trace timestamps for every exit/enter cycle. A report
+	  can be triggered using debugfs entry TODO.
+	  This adds overhead, it's not recommended for production environments.
+
 config KVM_TRACE
 	bool "KVM trace support"
 	depends on KVM && MARKERS && SYSFS
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -56,6 +56,21 @@
 	{ "halt_wakeup", VCPU_STAT(halt_wakeup) },
 	{ NULL }
 };
+
+#ifdef CONFIG_KVM_BOOKE_EXIT_TIMING
+u32 last_exit_type;
+u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_sum_quad_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_last_exit;
+struct sysrq_key_op trigger_print_exit_timing_op = {
+.handler= print_exit_timing_handler,
+.help_msg   = "Print KVm PowerPC exit timings",
+.action_msg = "Printing KVM PowerPC exit timings",
+};
+#endif
 
 static const u32 interrupt_msr_mask[16] = {
 	[BOOKE_INTERRUPT_CRITICAL]  = MSR_ME,
@@ -261,6 +276,9 @@
 	enum emulation_result er;
 	int r = RESUME_HOST;
 
+	/* update before a new last_exit_type is written */
+	update_exit_timing(&(vcpu->arch));
+
 	local_irq_enable();
 
 	run->exit_reason = KVM_EXIT_UNKNOWN;
@@ -285,10 +303,13 @@
 		 * misses before ceding control. */
 		if (need_resched())
 			cond_resched();
-		if (exit_nr == BOOKE_INTERRUPT_DECREMENTER)
+		if (exit_nr == BOOKE_INTERRUPT_DECREMENTER) {
 			vcpu->stat.dec_exits++;
-		else
+			set_last_exit_type(DEC_EXITS);
+		} else {
 			vcpu->stat.ext_intr_exits++;
+			set_last_exit_type(EXT_INTR_EXITS);
+		}
 		r = RESUME_GUEST;
 		break;
 
@@ -299,6 +320,7 @@
 			vcpu->ar

Re: [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2

2008-10-01 Thread Christian Ehrhardt

malc wrote:

On Tue, 30 Sep 2008, [EMAIL PROTECTED] wrote:


From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update*
further debugging according to some requests revealed that 
ARCH_CFLAGS does
not contain all CFLAGS that might be needed, especially those 
supplied via
extra-cflags. Therefore people supplying things via extra-cflags 
instead of an

environment variable might have had issues.


This part i don't get, there are few more checks before/after 
hostlongbits where no CFLAGS are added to the $cc argument list. What

makes hostlongbits selection "special"? Do people specify -m32/-m64 via
--extra-cflags?

it was there to ensure availability of the needed include paths to reach 
wordsize.h.
But Hollis approach is much simpler, better and more reliable so never 
mind :-)




A recent kvm merge with qemu brought code for 64bit power that broke 
cross

compilation. The issue is caused by configure trying to execute target
architecture binaries where configure is executed.


Yes, i never thought about cross-compilation, my bad.

np, now it's fixed - thanks for quickly applying it.



I tried to change that detection so that it works with&without cross
compilation with only a small change and especially without an addtional
configure command line switch. Including the bits/wordsize.h header a 
platform

usually can check its wordsize and by doing that configure can check the
hostlongbits without executing the binary. Instead it now stops after
preprocessing stage which resolved the __WORDSIZE constant and retrieves
that value.

I don't like my new check style, but it is at least less broken than 
before.

Another approach that was suggested was that qemu might end up needing
something like asm-offsets in the kernel to manage architecture sizes 
etc.

Comments and other approaches welcome.



I think Hollis Blanchard's method is sound,

Thank you for bringing this up.




--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2

2008-09-30 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update*
further debugging according to some requests revealed that ARCH_CFLAGS does
not contain all CFLAGS that might be needed, especially those supplied via
extra-cflags. Therefore people supplying things via extra-cflags instead of an
environment variable might have had issues.

A recent kvm merge with qemu brought code for 64bit power that broke cross
compilation. The issue is caused by configure trying to execute target
architecture binaries where configure is executed.

I tried to change that detection so that it works with&without cross
compilation with only a small change and especially without an addtional
configure command line switch. Including the bits/wordsize.h header a platform
usually can check its wordsize and by doing that configure can check the
hostlongbits without executing the binary. Instead it now stops after
preprocessing stage which resolved the __WORDSIZE constant and retrieves
that value.

I don't like my new check style, but it is at least less broken than before.
Another approach that was suggested was that qemu might end up needing
something like asm-offsets in the kernel to manage architecture sizes etc.
Comments and other approaches welcome.
 
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 configure |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

[diff]

diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -685,14 +685,15 @@
 # ppc specific hostlongbits selection
 if test "$cpu" = "powerpc" ; then
 cat > $TMPC <
+__WORDSIZE
 EOF
 
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
-$TMPE
-case $? in
-4) hostlongbits="32";;
-8) hostlongbits="64";;
+if $cc $ARCH_CFLAGS $CFLAGS -E -o $TMPE.E $TMPC 2> /dev/null; then
+wordsize=`tail -n 1 ${TMPE}.E`
+case $wordsize in
+32) hostlongbits="32";;
+64) hostlongbits="64";;
 *) echo "Couldn't determine bits per long value"; exit 1;;
 esac
 else
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] kvm-userspace: kvmppc: fix file header in libkvm-powerpc.c v2

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

It came up in the review of the s390 libkvm code that we have some
broken headers too.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 libkvm-powerpc.c |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

[diff]
diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -1,10 +1,7 @@
 /*
- * This header is for functions & variables that will ONLY be
- * used inside libkvm for x86.
- * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
- * WITHIN LIBKVM.
- *
- * derived from libkvm.c
+ * This file contains the powerpc specific implementation for the 
+ * architecture dependent functions defined in kvm-common.h and
+ * libkvm.h
  *
  * Copyright (C) 2006 Qumranet, Inc.
  *
@@ -12,11 +9,10 @@
  *  Avi Kivity   <[EMAIL PROTECTED]>
  *  Yaniv Kamay  <[EMAIL PROTECTED]>
  *
- * Copyright 2007 IBM Corporation.
- * Added by & Authors:
+ * Copyright IBM Corp. 2007,2008
+ * Authors:
  * Jerone Young <[EMAIL PROTECTED]>
  * Christian Ehrhardt <[EMAIL PROTECTED]>
- *
  *
  * This work is licensed under the GNU LGPL license, version 2.
  */
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] kvm-userspace: kvmppc: fix building userspace for powerpc

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Last submission missed the right 3/3 tag so I resend it to be recognized.

Commit 2d5737d8 added the requirement for an $arch/Makefile.pre in the
kernel subdirectory. This patch adds a stub for powerpc.
Additionally now a file kernel/$arch/hack-module.awk is needed and a simple
version for ppc is added for that one too.
In the root Makefile ia64 patch 030253bf added ia64 with a comma which should
break both architectures because filter works without. The patch removes that
comma.
The commit 76ff90aa fixed the dependency to DEPLIBS, but the definition of the
libfdt dependency lacks the right path (../libfdt/).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 Makefile   |2 +-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 qemu/Makefile.target   |2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)

[diff]

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@
 ifneq '$(filter $(ARCH), i386 x86_64)' ''
 qemu: extboot
 endif
-ifneq '$(filter $(ARCH), powerpc, ia64)' ''
+ifneq '$(filter $(ARCH), powerpc ia64)' ''
 qemu: libfdt
 endif
 user: libkvm
diff --git a/kernel/powerpc/Makefile.pre b/kernel/powerpc/Makefile.pre
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/Makefile.pre
@@ -0,0 +1,1 @@
+prerequisite:
diff --git a/kernel/powerpc/hack-module.awk b/kernel/powerpc/hack-module.awk
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/hack-module.awk
@@ -0,0 +1,5 @@
+/MODULE_AUTHOR/ {
+printf("MODULE_INFO(version, \"%s\");\n", version)
+}
+
+{ print }
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -579,7 +579,7 @@
 
 ifdef CONFIG_LIBFDT
 LIBS += -lfdt
-DEPLIBS += libfdt.a
+DEPLIBS += ../libfdt/libfdt.a
 endif
 
 # SCSI layer
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

A recent kvm merge with qemu brought code for 64bit power that broke cross
compilation. The issue is caused by configure trying to execute target
architecture binaries where configure is executed.

I tried to change that detection so that it works with&without cross
compilation with only a small change and especially without an addtional
configure command line switch. Including the bits/wordsize.h header a platform
usually can check its wordsize and by doing that configure can check the
hostlongbits without executing the binary. Instead it now stops after
preprocessing stage which resolved the __WORDSIZE constant and retrieves
that value.

I don't like my new check style, but it is at least less broken than before.
Another approach that was suggested was that qemu might end up needing
something like asm-offsets in the kernel to manage architecture sizes etc.
Comments and other approaches welcome.
 
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 configure |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

[diff]

diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -685,14 +685,15 @@
 # ppc specific hostlongbits selection
 if test "$cpu" = "powerpc" ; then
 cat > $TMPC <
+__WORDSIZE
 EOF
 
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
-$TMPE
-case $? in
-4) hostlongbits="32";;
-8) hostlongbits="64";;
+if $cc $ARCH_CFLAGS -E -o $TMPE.E $TMPC 2> /dev/null; then
+wordsize=`tail -n 1 ${TMPE}.E`
+case $wordsize in
+32) hostlongbits="32";;
+64) hostlongbits="64";;
 *) echo "Couldn't determine bits per long value"; exit 1;;
 esac
 else
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] kvm-userspace: kvmppc: fix build for ppc v2

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

*update
Short after resending v1 I realized that I forgot to put Avi and
[EMAIL PROTECTED] (for 2/3) on cc. I also updated the header text in 1/3 a
bit and verified my hostlongbits proposal on recent cross toolchain versions
because there was a question about that.

Updating and testing kvm-userspace for ppc after a too long time brought up
some issues fixed in this series.

The patches are small and their description should be comprehendible. Due to
the fact that most of the issues where build time issues I also started to
discuss about/establish some kind of automated build test for us that should
allow us to find such things faster.
Let me know if qumranet has such a process for x86 already and I should help
you to include powerpc.

[patches in series]
[PATCH 1/3] kvm-userspace: kvmppc: fix file header in libkvm-powerpc.c
[PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross 
compiling
[PATCH 3/3] kvm-userspace: kvmppc: fix building userspace for powerpc

---
[diffstat]
 Makefile   |3 ++-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 libkvm/libkvm-powerpc.c|   14 +-
 qemu/Makefile.target   |2 +-
 qemu/configure |   13 +++--
 6 files changed, 21 insertions(+), 17 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3][RESEND] kvm-userspace: kvmppc: fix build for ppc

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

* I got neither pro/con comments nor an accepted message -> resend

Updating and testing kvm-userspace for ppc after a too long time brought up
some issues fixed in this series.

The patches are small and their description should be comprehendible. Due to
the fact that most of the issues where build time issues I also started to
discuss about/establish some kind of automated build test for us that should
allow us to find such things faster.
Let me know if qumranet has such a process for x86 already and I should help
you to include powerpc.

[patches in series]
[PATCH 1/3] kvm-userspace: kvmppc: fix file header in libkvm-powerpc.c
[PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross 
compiling
[PATCH 3/3] kvm-userspace: kvmppc: fix building userspace for powerpc

---
[diffstat]
 Makefile   |3 ++-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 libkvm/libkvm-powerpc.c|   14 +-
 qemu/Makefile.target   |2 +-
 qemu/configure |   13 +++--
 6 files changed, 21 insertions(+), 17 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3][RESEND] kvm-userspace: kvmppc: fix file header in libkvm-powerpc.c

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

It came up in the review of the s390 libkvm code that we have some
broken headers too.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 libkvm-powerpc.c |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

[diff]
diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -1,10 +1,7 @@
 /*
- * This header is for functions & variables that will ONLY be
- * used inside libkvm for x86.
- * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
- * WITHIN LIBKVM.
- *
- * derived from libkvm.c
+ * This file contains the powerpc specific implementation for the 
+ * architecture dependent functions defined in kvm-common.h and
+ * libkvm.h
  *
  * Copyright (C) 2006 Qumranet, Inc.
  *
@@ -12,11 +9,10 @@
  *  Avi Kivity   <[EMAIL PROTECTED]>
  *  Yaniv Kamay  <[EMAIL PROTECTED]>
  *
- * Copyright 2007 IBM Corporation.
- * Added by & Authors:
+ * Copyright IBM Corp. 2007,2008
+ * Added by:
  * Jerone Young <[EMAIL PROTECTED]>
  * Christian Ehrhardt <[EMAIL PROTECTED]>
- *
  *
  * This work is licensed under the GNU LGPL license, version 2.
  */
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3][RESEND] kvm-userspace: kvmppc: fix building userspace for powerpc

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Last submission missed the right 3/3 tag so I resend it to be recognized.

Commit 2d5737d8 added the requirement for an $arch/Makefile.pre in the
kernel subdirectory. This patch adds a stub for powerpc.
Additionally now a file kernel/$arch/hack-module.awk is needed and a simple
version for ppc is added for that one too.
In the root Makefile ia64 patch 030253bf added ia64 with a comma which should
break both architectures because filter works without. The patch removes that
comma.
The commit 76ff90aa fixed the dependency to DEPLIBS, but the definition of the
libfdt dependency lacks the right path (../libfdt/).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 Makefile   |2 +-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 qemu/Makefile.target   |2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)

[diff]

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@
 ifneq '$(filter $(ARCH), i386 x86_64)' ''
 qemu: extboot
 endif
-ifneq '$(filter $(ARCH), powerpc, ia64)' ''
+ifneq '$(filter $(ARCH), powerpc ia64)' ''
 qemu: libfdt
 endif
 user: libkvm
diff --git a/kernel/powerpc/Makefile.pre b/kernel/powerpc/Makefile.pre
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/Makefile.pre
@@ -0,0 +1,1 @@
+prerequisite:
diff --git a/kernel/powerpc/hack-module.awk b/kernel/powerpc/hack-module.awk
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/hack-module.awk
@@ -0,0 +1,5 @@
+/MODULE_AUTHOR/ {
+printf("MODULE_INFO(version, \"%s\");\n", version)
+}
+
+{ print }
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -579,7 +579,7 @@
 
 ifdef CONFIG_LIBFDT
 LIBS += -lfdt
-DEPLIBS += libfdt.a
+DEPLIBS += ../libfdt/libfdt.a
 endif
 
 # SCSI layer
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3][RESEND] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling

2008-09-29 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

The kvm merge with qemu brought code for 64bit power that broke cross
compilation. The issue is caused by configure trying to execute target
architecture binaries where configure is executed.

I tried to change that detection so that it works with&without cross
compilation with only a small change and especially without an addtional
configure command line switch. Including the bits/wordsize.h header a platform
usually can check its wordsize and by doing that configure can check the
hostlongbits without executing the binary. Instead it now stops after
preprocessing stage which resolved the __WORDSIZE constant and retrieves
that value.

I don't like that check style, but it is at least less broken than before.
Comments and other approaches welcome.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 configure |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

[diff]

diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -685,14 +685,15 @@
 # ppc specific hostlongbits selection
 if test "$cpu" = "powerpc" ; then
 cat > $TMPC <
+__WORDSIZE
 EOF
 
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
-$TMPE
-case $? in
-4) hostlongbits="32";;
-8) hostlongbits="64";;
+if $cc $ARCH_CFLAGS -E -o $TMPE.E $TMPC 2> /dev/null; then
+wordsize=`tail -n 1 ${TMPE}.E`
+case $wordsize in
+32) hostlongbits="32";;
+64) hostlongbits="64";;
 *) echo "Couldn't determine bits per long value"; exit 1;;
 esac
 else
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


exit timing analysis v1 - comments&discussions welcome

2008-09-24 Thread Christian Ehrhardt
   11,582   11  66 128,625
11.1056 2.133  0.09
SYSCALL10,052   11  59 120,597
11.9973 2.415  0.09
 FP_UNAVAIL   295   11  12   3,247
11.0068 0.082  0.00
  HCALL 1   19  19  19
19. 0.000  0.00

*never hit USR_PR_INST, HALT, DEBUG


--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -346,6 +346,11 @@
 	DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst));
 	DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
 	DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
+
+	DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu, arch.timing_exit.tv32.tbu));
+	DEFINE(VCPU_TIMING_EXIT_TBL, offsetof(struct kvm_vcpu, arch.timing_exit.tv32.tbl));
+	DEFINE(VCPU_TIMING_LAST_ENTER_TBU, offsetof(struct kvm_vcpu, arch.timing_last_enter.tv32.tbu));
+	DEFINE(VCPU_TIMING_LAST_ENTER_TBL, offsetof(struct kvm_vcpu, arch.timing_last_enter.tv32.tbl));
 #endif
 
 	return 0;
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -56,6 +56,14 @@
 	{ "halt_wakeup", VCPU_STAT(halt_wakeup) },
 	{ NULL }
 };
+
+u32 last_exit_type;
+u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_sum_quad_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES];
+u64 timing_last_exit;
 
 static const u32 interrupt_msr_mask[16] = {
 	[BOOKE_INTERRUPT_CRITICAL]  = MSR_ME,
@@ -261,6 +269,9 @@
 	enum emulation_result er;
 	int r = RESUME_HOST;
 
+	/* update before a new last_exit_type is written */
+	update_exit_timing(&(vcpu->arch));
+
 	local_irq_enable();
 
 	run->exit_reason = KVM_EXIT_UNKNOWN;
@@ -285,10 +296,13 @@
 		 * misses before ceding control. */
 		if (need_resched())
 			cond_resched();
-		if (exit_nr == BOOKE_INTERRUPT_DECREMENTER)
+		if (exit_nr == BOOKE_INTERRUPT_DECREMENTER) {
 			vcpu->stat.dec_exits++;
-		else
+			set_last_exit_type(DEC_EXITS);
+		} else {
 			vcpu->stat.ext_intr_exits++;
+			set_last_exit_type(EXT_INTR_EXITS);
+		}
 		r = RESUME_GUEST;
 		break;
 
@@ -299,6 +313,7 @@
 			vcpu->arch.esr = vcpu->arch.fault_esr;
 			kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_PROGRAM);
 			r = RESUME_GUEST;
+			set_last_exit_type(USR_PR_INST);
 			break;
 		}
 
@@ -308,10 +323,12 @@
 			/* Future optimization: only reload non-volatiles if
 			 * they were actually modified by emulation. */
 			vcpu->stat.emulated_inst_exits++;
+			set_last_exit_type(EMULATED_INST_EXITS);
 			r = RESUME_GUEST_NV;
 			break;
 		case EMULATE_DO_DCR:
 			run->exit_reason = KVM_EXIT_DCR;
+			set_last_exit_type(DCR_EXITS);
 			r = RESUME_HOST;
 			break;
 		case EMULATE_FAIL:
@@ -331,6 +348,7 @@
 
 	case BOOKE_INTERRUPT_FP_UNAVAIL:
 		kvmppc_queue_exception(vcpu, exit_nr);
+		set_last_exit_type(FP_UNAVAIL);
 		r = RESUME_GUEST;
 		break;
 
@@ -339,6 +357,7 @@
 		vcpu->arch.esr = vcpu->arch.fault_esr;
 		kvmppc_queue_exception(vcpu, exit_nr);
 		vcpu->stat.dsi_exits++;
+		set_last_exit_type(DSI_EXITS);
 		r = RESUME_GUEST;
 		break;
 
@@ -346,6 +365,7 @@
 		vcpu->arch.esr = vcpu->arch.fault_esr;
 		kvmppc_queue_exception(vcpu, exit_nr);
 		vcpu->stat.isi_exits++;
+		set_last_exit_type(ISI_EXITS);
 		r = RESUME_GUEST;
 		break;
 
@@ -353,9 +373,11 @@
 		if (vcpu->arch.last_inst == KVM_HYPERCALL_BIN) {
 			kvmppc_do_hypercall(vcpu);
 			vcpu->stat.hcall_exits++;
+			set_last_exit_type(HCALL_EXITS);
 		} else {
 			kvmppc_queue_exception(vcpu, exit_nr);
 			vcpu->stat.syscall_exits++;
+			set_last_exit_type(SYSCALL_EXITS);
 		}
 		r = RESUME_GUEST;
 		break;
@@ -370,6 +392,7 @@
 			 vcpu->arch.pvmem_gpaddr >> KVM_PPCPV_MAGIC_PAGE_SHIFT,
 			 0, KVM_PPCPV_MAGIC_PAGE_FLAGS);
 			vcpu->stat.dtlb_pvmem_miss_exits++;
+			set_last_exit_type(DTLB_PVMEM_MISS_EXITS);
 			r = RESUME_GUEST;
 			break;
 		}
@@ -382,6 +405,7 @@
 			vcpu->arch.dear = vcpu->arch.fault_dear;
 			vcpu->arch.esr = vcpu->arch.fault_esr;
 			vcpu->stat.dtlb_real_miss_exits++;
+			set_last_exit_type(DTLB_REAL_MISS_EXITS);
 			r = RESUME_GUEST;
 			break;
 		}
@@ -399,11 +423,13 @@
 			kvmppc_mmu_map(vcpu, eaddr, gfn, gtlbe->tid,
 			   gtlbe->word2);
 			vcpu->stat.dtlb_virt_miss_exits++;
+			set_last_exit_type(DTLB_VIRT_MISS_EXITS);
 			r = RESUME_GUEST;
 		} else {
 			/* Guest has mapped and accessed a page which is not
 			 * actually RAM. */
 			r = kvmppc_emulate_mmio(r

[PATCH 3/3] kvm-userspace: kvmppc: fix building userspace for powerpc

2008-09-16 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Last submission missed the right 3/3 tag so I resend it to be recognized.

Commit 2d5737d8 added the requirement for an $arch/Makefile.pre in the
kernel subdirectory. This patch adds a stub for powerpc.
Additionally now a file kernel/$arch/hack-module.awk is needed and a simple
version for ppc is added for that one too.
In the root Makefile ia64 patch 030253bf added ia64 with a comma which should
break both architectures because filter works without. The patch removes that
comma.
The commit 76ff90aa fixed the dependency to DEPLIBS, but the definition of the
libfdt dependency lacks the right path (../libfdt/).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 Makefile   |2 +-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 qemu/Makefile.target   |2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)

[diff]

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@
 ifneq '$(filter $(ARCH), i386 x86_64)' ''
 qemu: extboot
 endif
-ifneq '$(filter $(ARCH), powerpc, ia64)' ''
+ifneq '$(filter $(ARCH), powerpc ia64)' ''
 qemu: libfdt
 endif
 user: libkvm
diff --git a/kernel/powerpc/Makefile.pre b/kernel/powerpc/Makefile.pre
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/Makefile.pre
@@ -0,0 +1,1 @@
+prerequisite:
diff --git a/kernel/powerpc/hack-module.awk b/kernel/powerpc/hack-module.awk
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/hack-module.awk
@@ -0,0 +1,5 @@
+/MODULE_AUTHOR/ {
+printf("MODULE_INFO(version, \"%s\");\n", version)
+}
+
+{ print }
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -579,7 +579,7 @@
 
 ifdef CONFIG_LIBFDT
 LIBS += -lfdt
-DEPLIBS += libfdt.a
+DEPLIBS += ../libfdt/libfdt.a
 endif
 
 # SCSI layer
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvm-userspace: kvmppc: fix building userspace for powerpc

2008-09-16 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Commit 2d5737d8 added the requirement for an $arch/Makefile.pre in the
kernel subdirectory. This patch adds a stub for powerpc.
Additionally now a file kernel/$arch/hack-module.awk is needed and a simple
version for ppc is added for that one too.
In the root Makefile ia64 patch 030253bf added ia64 with a comma which should
break both architectures because filter works without. The patch removes that
comma.
The commit 76ff90aa fixed the dependency to DEPLIBS, but the definition of the
libfdt dependency lacks the right path (../libfdt/).

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 Makefile   |2 +-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 qemu/Makefile.target   |2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)

[diff]

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@
 ifneq '$(filter $(ARCH), i386 x86_64)' ''
 qemu: extboot
 endif
-ifneq '$(filter $(ARCH), powerpc, ia64)' ''
+ifneq '$(filter $(ARCH), powerpc ia64)' ''
 qemu: libfdt
 endif
 user: libkvm
diff --git a/kernel/powerpc/Makefile.pre b/kernel/powerpc/Makefile.pre
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/Makefile.pre
@@ -0,0 +1,1 @@
+prerequisite:
diff --git a/kernel/powerpc/hack-module.awk b/kernel/powerpc/hack-module.awk
new file mode 100644
--- /dev/null
+++ b/kernel/powerpc/hack-module.awk
@@ -0,0 +1,5 @@
+/MODULE_AUTHOR/ {
+printf("MODULE_INFO(version, \"%s\");\n", version)
+}
+
+{ print }
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -579,7 +579,7 @@
 
 ifdef CONFIG_LIBFDT
 LIBS += -lfdt
-DEPLIBS += libfdt.a
+DEPLIBS += ../libfdt/libfdt.a
 endif
 
 # SCSI layer
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling

2008-09-16 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

The kvm merge with qemu brought code for 64bit power that broke cross
compilation. The issue is caused by configure trying to execute target
architecture binaries where configure is executed.

I tried to change that detection so that it works with&without cross
compilation with only a small change and especially without an addtional
configure command line switch. Including the bits/wordsize.h header a platform
usually can check its wordsize and by doing that configure can check the
hostlongbits without executing the binary. Instead it now stops after
preprocessing stage which resolved the __WORDSIZE constant and retrieves
that value.

I don't like that check style, but it is at least less broken than before.
Comments and other approaches welcome.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 configure |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

[diff]

diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -685,14 +685,15 @@
 # ppc specific hostlongbits selection
 if test "$cpu" = "powerpc" ; then
 cat > $TMPC <
+__WORDSIZE
 EOF
 
-if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
-$TMPE
-case $? in
-4) hostlongbits="32";;
-8) hostlongbits="64";;
+if $cc $ARCH_CFLAGS -E -o $TMPE.E $TMPC 2> /dev/null; then
+wordsize=`tail -n 1 ${TMPE}.E`
+case $wordsize in
+32) hostlongbits="32";;
+64) hostlongbits="64";;
 *) echo "Couldn't determine bits per long value"; exit 1;;
 esac
 else
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] kvm-userspace: kvmppc: fix file header in libkvm-powerpc.c

2008-09-16 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

It came up in the review of the s390 libkvm code that we have some
broken headers too.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 libkvm-powerpc.c |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

[diff]
diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -1,10 +1,7 @@
 /*
- * This header is for functions & variables that will ONLY be
- * used inside libkvm for x86.
- * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
- * WITHIN LIBKVM.
- *
- * derived from libkvm.c
+ * This file contains the powerpc specific implementation for the 
+ * architecture dependent functions defined in kvm-common.h and
+ * libkvm.h
  *
  * Copyright (C) 2006 Qumranet, Inc.
  *
@@ -12,11 +9,10 @@
  *  Avi Kivity   <[EMAIL PROTECTED]>
  *  Yaniv Kamay  <[EMAIL PROTECTED]>
  *
- * Copyright 2007 IBM Corporation.
- * Added by & Authors:
+ * Copyright IBM Corp. 2007,2008
+ * Added by:
  * Jerone Young <[EMAIL PROTECTED]>
  * Christian Ehrhardt <[EMAIL PROTECTED]>
- *
  *
  * This work is licensed under the GNU LGPL license, version 2.
  */
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] kvm-userspace: kvmppc: fix build for ppc

2008-09-16 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Updating and testing kvm-userspace for ppc after a too long time brought up
some issues fixed in this series.

The patches are small and their description should be comprehendible. Due to
the fact that most of the issues where build time issues I also started to
discuss about/establish some kind of automated build test for us that should
allow us to find such things faster.
let me know if qumranet has such a process for x86 already and I should help
you to include ppc.

[patches in series]
[PATCH 1/3] kvm-userspace: kvmppc: fix file header in libkvm-powerpc.c
[PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross 
compiling
[PATCH 3/3] kvm-userspace: kvmppc: fix building userspace for powerpc

---
[diffstat]
 Makefile   |3 ++-
 kernel/powerpc/Makefile.pre|1 +
 kernel/powerpc/hack-module.awk |5 +
 libkvm/libkvm-powerpc.c|   14 +-
 qemu/Makefile.target   |2 +-
 qemu/configure |   13 +++--
 6 files changed, 21 insertions(+), 17 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] kvmppc: rewrite guest code - dear, esr, srr0, srr1

2008-09-15 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Interrupt delivery is usually followed by several exits to fetch e.g. dear,
esr, srr0, srr1. To easen that this patch adds guest code rewriting using the
magic page mechanism for these four special purpose registers.
This patch rewrites reads and writes to this registers and also the kvm code
in the interrupt delivery/ rfi path that writes/reads those.
Since this patch is touching the dump_tlb and dump_vcpu functions it is fixing
all the missing printk KERN_* levels avoiding checkpatch noise.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 arch/powerpc/kvm/booke_guest.c |   43 
 arch/powerpc/kvm/emulate.c |  107 +
 include/asm-powerpc/kvm_para.h |4 +
 3 files changed, 134 insertions(+), 20 deletions(-)

[diff]

diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -120,14 +120,14 @@
struct tlbe *tlbe;
int i;
 
-   printk("vcpu %d TLB dump:\n", vcpu->vcpu_id);
-   printk("| %2s | %3s | %8s | %8s | %8s |\n",
+   printk(KERN_ERR"vcpu %d TLB dump:\n", vcpu->vcpu_id);
+   printk(KERN_ERR"| %2s | %3s | %8s | %8s | %8s |\n",
"nr", "tid", "word0", "word1", "word2");
 
for (i = 0; i < PPC44x_TLB_SIZE; i++) {
tlbe = &vcpu->arch.guest_tlb[i];
if (tlbe->word0 & PPC44x_TLB_VALID)
-   printk(" G%2d |  %02X | %08X | %08X | %08X |\n",
+   printk(KERN_ERR" G%2d | %02X | %08X | %08X | %08X |\n",
   i, tlbe->tid, tlbe->word0, tlbe->word1,
   tlbe->word2);
}
@@ -135,7 +135,7 @@
for (i = 0; i < PPC44x_TLB_SIZE; i++) {
tlbe = &vcpu->arch.shadow_tlb[i];
if (tlbe->word0 & PPC44x_TLB_VALID)
-   printk(" S%2d | %02X | %08X | %08X | %08X |\n",
+   printk(KERN_ERR" S%2d | %02X | %08X | %08X | %08X |\n",
   i, tlbe->tid, tlbe->word0, tlbe->word1,
   tlbe->word2);
}
@@ -146,18 +146,28 @@
 {
int i;
 
-   printk("pc:   %08x msr:  %08x\n", vcpu->arch.pc, vcpu->arch.msr);
-   printk("lr:   %08x ctr:  %08x\n", vcpu->arch.lr, vcpu->arch.ctr);
-   printk("srr0: %08x srr1: %08x\n", vcpu->arch.srr0, vcpu->arch.srr1);
+   printk(KERN_ERR"pc:   %08x msr:  %08x\n",
+   vcpu->arch.pc, vcpu->arch.msr);
+   printk(KERN_ERR"lr:   %08x ctr:  %08x\n",
+   vcpu->arch.lr, vcpu->arch.ctr);
+   printk(KERN_ERR"srr0: %08x srr1: %08x\n",
+   vcpu->arch.srr0, vcpu->arch.srr1);
 
printk("exceptions: %08lx\n", vcpu->arch.pending_exceptions);
 
for (i = 0; i < 32; i += 4) {
-   printk("gpr%02d: %08x %08x %08x %08x\n", i,
+   printk(KERN_ERR"gpr%02d: %08x %08x %08x %08x\n", i,
   vcpu->arch.gpr[i],
   vcpu->arch.gpr[i+1],
   vcpu->arch.gpr[i+2],
   vcpu->arch.gpr[i+3]);
+   }
+
+   if (kvmppc_has_pvmem(vcpu)) {
+   printk(KERN_ERR"vcpu has pvmem enabled\n");
+   printk(KERN_ERR"srr0: %08x srr1: %08x (PVMEM)\n",
+   kvmppc_get_pvreg(vcpu, KVM_PPCPV_OFFSET_SRR0),
+   kvmppc_get_pvreg(vcpu, KVM_PPCPV_OFFSET_SRR1));
}
 }
 
@@ -203,8 +213,17 @@
break;
}
 
-   vcpu->arch.srr0 = vcpu->arch.pc;
-   vcpu->arch.srr1 = vcpu->arch.msr;
+   if (kvmppc_has_pvmem(vcpu)) {
+   kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_SRR0, vcpu->arch.pc);
+   kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_SRR1, vcpu->arch.msr);
+   /* only modified on interrupt delivery path */
+   kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_DEAR, vcpu->arch.dear);
+   kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_ESR, vcpu->arch.esr);
+   } else {
+   vcpu->arch.srr0 = vcpu->arch.pc;
+   vcpu->arch.srr1 = vcpu->arch.msr;
+   }
+
vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[interrupt];
kvmppc_set_msr(vcpu, vcpu->arch.msr & interrupt_msr_mask[interrupt]);
 }
@@ -549,6 +568,8 @@
regs->sprg1 = kvmppc_get_pvreg(vcpu, KVM_PPCPV_OFFSET_SPRG1);
regs->sprg2 = kvmppc_get_pvr

[PATCH 0/3][RFC] kvmppc: paravirtualization interface - guest part v3

2008-09-15 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Version 3 updates:
- guest hypercall infrastructure is now generic (in epapr_hcalls.h)
  while the kvm specific functions stay in kvm_para.h
- the hypercalls now use beat style ABI
- dropped the guest coop patch changing wrteei to wrtee (now mfmsr is
  rewritten avoiding side effects and a lot of corner cases. Additionally this
  does not need any guest cooperation to be effective)

This patch series implements a paravirtualization interface using:
- the device tree mechanism to pass hypervisor informations to the guest
- hypercalls for guest->host calls
- an example exploiter of that interface (magic page)

The device tree format used here (=base for the discussions on
embedded-hypervisor) is the following.
- A node "hypervisor" to show the general availability of some hypervisor data
- flags for features like the example "feature,pv-magicpage"
  setting 1 = available, everything else = unavailable
- Some features might need to pass more data and can use an entry in the
  device tree like the example of "data,pv-magicpage-size"

The host side of these patches can be found on kvm-ppc@vger.kernel.org

I hope that eventually this guest patch series (that is modifying the ppc boot
process and adding e.g. new ppc fixmaps could go upstream (when discussed
and agreed somewhen) via linuxppc-dev, while the kvm host part will go via
kvm (Avi Kivity).

[patches in series]
[PATCH 1/3] kvmppc: read device tree hypervisor node infrastructure
[PATCH 2/3] kvmppc: add hypercall infrastructure - guest part
[PATCH 3/3] kvmppc: magic page paravirtualization - guest part

---
[diffstat]
 arch/powerpc/kernel/kvm.c|   53 +++
 b/arch/powerpc/kernel/Makefile   |2 +
 b/arch/powerpc/kernel/kvm.c  |   30 +
 b/arch/powerpc/kernel/setup_32.c |3 +
 b/arch/powerpc/platforms/44x/Kconfig |7 
 b/include/asm-powerpc/epapr_hcalls.h |   59 +++
 b/include/asm-powerpc/fixmap.h   |   10 +
 b/include/asm-powerpc/kvm_para.h |   43 +++--
 include/asm-powerpc/kvm_para.h   |   26 +++
 9 files changed, 229 insertions(+), 4 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/6][RFC] kvmppc: paravirtualization interface - host part v3

2008-09-15 Thread ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Version 3 updates:
- fixed adress release at a kunmap_atomic call
- removed style issues (whitespace/indent)
- all checks to test if pvmem is currently available now use the wrappers
  kvmppc_has_pvmem or kvmppc_is_pvmem
- folded some changes in a better order to prevent multiple trivial patches
  for the same code sections
- the hypercall ABI is now implemented in beat style
- the rewrite of wrtee is dropped, instead mfmsr is rewritten. This saves more
  exits on non cooperating guests and for now rmeoving the need for guest coop
  patches (less invasive).
- separated and removed some changes unrelated to paravirtualization to
  streamline this series
- changed mapping of guest memory to call gfn_to_page without mm locks held
  (upstream code just changed)
- instruction rewriting is now done after emulation guarded by an unlikely()
  which should save a lot of runtime complexity (adding some extra code though):
  a) in non pv case this is now just an if (unlikely(x))  that is never true
  b) in pv case the rewrite function does not need to be called for every
 emulation - only for those that are rewritable (which additionally don't
 occur anymore after being rewritten once).

This patch series implements the host part of an paravirtualization interface
using:
- the device tree mechanism to pass hypervisor informations to the guest
  (kvm-userspace) 
- hypercalls backend for guest->host calls
- an example exploiter of that interface (magic page) that uses that for
  binary rewriting saving guest exits by avoiding privileged instructions

The device tree format used here (=base for the discussions on
embedded-hypervisor) is the following.
- A node "hypervisor" to show the general availability of some hypervisor data
- flags for features like the example "feature,pv-magicpage"
  setting 1 = available, everything else = unavailable
- Some features might need to pass more data and can use an entry in the
  device tree like the example of "data,pv-magicpage-size"

If the guest wants that pv support it has to allocate the requested size of
memory (aligned to the tlb entry size rounded up => e.g. 4000 bytes 4k
aligned, 4096 bytes 4k aligned, 4097 bytes 16k aligned and so on).

The speedup with both patch queues applied is around 40% dependent on what the
guest is doing (measured with boot times and some simple tasks). The raw saving
of exits about ~50-60% as you can see in the kvm stat exit counters.

[patches in series]
[PATCH 1/6] kvmppc: add hypercall infrastructure - host part
[PATCH 2/6] kvmppc: magic page hypercall - host part
[PATCH 3/6] kvmppc: rewrite guest code - sprg0-3
[PATCH 4/6] kvmppc: rewrite guest code - dear, esr, srr0, srr1
[PATCH 5/6] kvmppc: rewrite guest code - mfmsr
[PATCH 6/6] kvmppc: kvm-userspace: device tree modification for magic page

---
[diffstat]
kernel:
 arch/powerpc/kvm/booke_guest.c|   70 -
 arch/powerpc/kvm/emulate.c|  415 --
 b/arch/powerpc/kvm/booke_guest.c  |   11
 b/arch/powerpc/kvm/booke_interrupts.S |9
 b/arch/powerpc/kvm/emulate.c  |   16 +
 b/arch/powerpc/kvm/powerpc.c  |   20 +
 b/include/asm-powerpc/kvm_host.h  |1
 b/include/asm-powerpc/kvm_para.h  |4
 b/include/asm-powerpc/kvm_ppc.h   |3
 b/include/linux/kvm.h |5
 include/asm-powerpc/kvm_host.h|5
 include/asm-powerpc/kvm_para.h|   54 
kvm-userspace:
 b/libkvm/libkvm-powerpc.c |6
 b/libkvm/libkvm.h |4
 b/qemu/hw/device_tree.c   |   10
 b/qemu/hw/device_tree.h   |1
 b/qemu/hw/ppc440_bamboo.c |   18 +
 b/qemu/qemu-kvm-powerpc.c |5
 b/qemu/qemu-kvm.h |1
 19 files changed, 625 insertions(+), 33 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >