Re: [kvm-devel] What kernel options do I need to properly enable virtio net driver

2008-04-22 Thread Christian Ehrhardt
Jerone Young wrote:
> virtio net device does not appear to show itself in the guest. I'm
> curious of what options I may be missing. Here is my config
> 
> CONFIG_VIRTIO_NET=y
[..]
> CONFIG_VIRTUALIZATION=y
> CONFIG_KVM=y
> CONFIG_KVM_BOOKE_HOST=y
> CONFIG_VIRTIO=y
> CONFIG_VIRTIO_RING=y
> CONFIG_VIRTIO_PCI=y 

That should be enough in .config, but be aware that you need the proper qemu 
command line like 
  "-net nic,model=virtio,macaddr=00:00:00:00:00:AA -net tap"
as well as a /etc/qemu-ifup script (I sent one for our purpose to kvm-ppc-devel 
a while ago)
+ you need some tools installed e.g. brctl
and you need to create /dev/net/tun in the host because we have no dynamic /dev.

If you have done all that already and it is still not working you should 
continue with anthonys
suggestion and send what lspci shows you. If you want to be complete use "lspci 
-vvvx"
And maybe it is worth to add debug to the kernel command line of the guest and 
attach a full dmesg
to the same response too, just in case someone might want to look at driver 
messages.

-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] [PATCH 1/5]Add some trace markers and exposeinterfaces in kernel for tracing

2008-04-17 Thread Christian Ehrhardt
Liu, Eric E wrote:
> Hollis Blanchard wrote:
>> On Wednesday 16 April 2008 01:45:34 Liu, Eric E wrote:
[...]
>> Actually... we could have kvmtrace itself insert the metadata, so
>> there would be no chance of it being overwritten in the kernel
>> buffers. The header could be written in tip_open_output(), and update
>> fs_size accordingly. 
>>
> Yes, let kvmtrace insert the metadata is more reasonable.
> 

I wanted to note that the kvmtrace tool should, but not need to know everything 
about the data format.
I think of e.g. changing kernel implementations that change endianess or even 
flags we don't yet know, but we might need in the future.

What about adding another debugfs entry the kernel can use to expose the 
"kvmtrace-metadata" defined by the kernel implementation.
The kvmtrace tool could then use that to build up the record by using one entry 
for kernel defined metadata and another to add any metadata that would be 
defined by kvmtrace tool itself.

what about that one:
struct metadata {
u32 kmagic; /* stores kernel defined metadata read from debugfs 
entry */
u32 umagic; /* stores userspace tool defined metadata */
u32 extra;  /* it is redundant, only use to fit into record. */
} 

That should give us the flexibility to keep the format if we get more metadata 
requirements in the future.

-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 4 of 4] [KVM POWERPC] PowerPC 440 KVM implementation

2008-04-17 Thread Christian Ehrhardt

Avi Kivity wrote:

Avi Kivity wrote:

Hollis Blanchard wrote:

+config KVM
+ tristate "Kernel-based Virtual Machine (KVM) support"
+ depends on EXPERIMENTAL
+ select PREEMPT_NOTIFIERS
+ select ANON_INODES
+ ---help---
+ Support hosting virtualized guest machines. You will also
+ need to select one or more of the processor modules below.
+
+ This module provides access to the hardware capabilities through
+ a character device node named /dev/kvm.
+
+ To compile this as a module, choose M here: the module
+ will be called kvm.
+
+ If unsure, say N.


In my ignorance, I set KVM=m on a non-44x build, which then failed. 
This needs either to depend on 44x, or to be fixed to compile.


Setting 44x, I get

AS [M] arch/powerpc/kvm/booke_interrupts.o
arch/powerpc/kvm/booke_interrupts.S: Assembler messages:
arch/powerpc/kvm/booke_interrupts.S:351: Error: unsupported relocation 
against VCPU_HOST_TLB
arch/powerpc/kvm/booke_interrupts.S:352: Error: unsupported relocation 
against VCPU_SHADOW_TLB


Afaik we just don't support building kvm as module atm. So a simple and fast 
solution would be to change the Kconfig options from tristate to bool.
Additionally we still have some cross references between the code build on the two 
used symbols (KVM&KVM_BOOKE_HOST) which means that we need to ensure that if 
KVM if configured for powerpc we also select exactly one host implementation. To do 
so I changed the second option to a choice field which eventually has always 
selected one suboption.

To ensure that the only existent suboption we have atm can be selected we need the 
smallest commonality as dependency at the KVM config option which atm put "depends 
44x" there.
We can change that once we support modules and/or separate selections.

A patch for that is attached, but I would like to wait for Hollis comments on 
that before you apply that.


So further Kconfig restrictions are needed, or perhaps a patch. .config 
attached.




[...]

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
--- arch/powerpc/kvm/Kconfig.save	2008-04-17 15:21:54.0 +0200
+++ arch/powerpc/kvm/Kconfig	2008-04-17 15:58:52.0 +0200
@@ -15,8 +15,8 @@
 if VIRTUALIZATION
 
 config KVM
-	tristate "Kernel-based Virtual Machine (KVM) support"
-	depends on EXPERIMENTAL
+	bool "Kernel-based Virtual Machine (KVM) support"
+	depends on EXPERIMENTAL && 44x
 	select PREEMPT_NOTIFIERS
 	select ANON_INODES
 	---help---
@@ -31,13 +31,22 @@
 
 	  If unsure, say N.
 
+choice
+	prompt "KVM host PowerPC processor support"
+	depends on KVM && 44x
+	default KVM_BOOKE_HOST
+	help
+	  This option sets the Kind of PowerPC processor to virtualize.
+
 config KVM_BOOKE_HOST
-	tristate "KVM host support for Book E PowerPC processors"
+	bool "Book E"
 	depends on KVM && 44x
 	---help---
 	  Provides host support for KVM on Book E PowerPC processors. Currently
 	  this works on 440 processors only.
 
+endchoice
+
 source drivers/virtio/Kconfig
 
 endif # VIRTUALIZATION
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] virtio-net working on PowerPC KVM

2008-03-30 Thread Christian Ehrhardt
Avi Kivity wrote:
> Hollis Blanchard wrote:
>> I'm pleased to report that we now have working network support in the
>> guest, via the virtio-net driver. In fact, we can use NFS for the
>> guest's root filesystem. :) Boot log attached.
>>
>>   
> 
> Congrats!
> 
>> The bad news is that it's very slow, but the good news is that it's nice
>> to be improving performance rather than debugging mysterious
>> crashes... ;)
>>
>> With this milestone reached, in the near future I intend to start
>> sending patches to Avi and linuxppc-dev for review, hopefully for
>> inclusion in 2.6.26. However, I do want to see if we can improve the
>> performance a little bit first...
>>   
> 
> Low virtio net performance may be due to the virtio net host timer.  
> What's your guest/host ping latency?

I would be happy about 0.25ms atm :-). The current ping latency to the Host or 
other PC's is around 7-8ms (native sys is ~0.15ms).
We are investigating performance improvements in general and also some changes 
in the setup e.g. booting from virtio-block as alternative for some speedup.

> Even if you have a good hrtimer implementation, I think you'll see 
> 0.25ms latency, and that may be enough to slow down nfs.  Unfortunately 
> virtio is tuned for throughput at this time (it should be easy to 
> disable the timer when we detect the queue is usually empty).
> 


-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] script for watching kvm_stat

2008-03-17 Thread Christian Ehrhardt

I added the kvm_stat support to ppc to watch my guest while executing e.g. to check 
things like "what does my guest do when I see nothing" ;-)
To be able to do that I also needed a script that reports in a iostat/vmstat 
like style, because of that I wrote a small shell script.
Additionally my colleague Christian Bornträger had the need for a top style 
output and wrote a script for that need.
I attached both to help everyone experimenting with kvm_stat.

They are just small helpers and might still contain issues, feel free to 
comment, correct, whatever ;-)

--

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
#!/bin/bash

kvmstatdir="/sys/kernel/debug/kvm"
duration=2
summode="no"
lph=20
line=-1
if [ $summode = "no" ]
then
declare -a values
counter=0
for i in `ls $kvmstatdir`
do
values[$counter]=0
counter=`expr $counter + 1`
done
fi

kvmstat_header() {
for i in `ls $kvmstatdir`
do
printf "|%16s " $i
done
printf "|\n"
}

USAGE="Usage: `basename $0` [-d arg] [-l arg] [-hs]"
while getopts hvsd:l: OPT; do
case "$OPT" in
h)  echo $USAGE
echo "d - sleep between reported lines"
echo "l - number of lines betweeen headers"
echo "s - summary mode (default is difference since last print)"
exit 0
;;
v)  echo "`basename $0` version 0.1"
exit 0
;;
d)  duration=$OPTARG
;;
l)  lph=$OPTARG
;;
s)  summode="yes"
;;
\?) # getopts issues an error message
echo $USAGE >&2
exit 1
;;
esac
done

while true
do
line=`expr $line + 1`
line=`expr $line % $lph`
if [ $line -eq "0" ]
then
kvmstat_header
fi

counter=0
for i in `ls $kvmstatdir`
do
val=`cat $kvmstatdir/$i`
if [ $summode = "no" ]
then
cval=$val;
val=`expr $cval - ${values[$counter]}`
values[$counter]=$cval
counter=`expr $counter + 1` 
fi
printf "|%16d " $val
done
printf "|\n"

sleep $duration
done
#!/bin/bash
watch --differences -n 1 " kvmtop_once | sort -n -r"
#!/bin/bash
cd /sys/kernel/debug/kvm
for d in *
do
cat $d | tr -d \\n
echo -e :\\t $d

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


Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Add print for PowerPC qemu for failed DCR read/writes

2008-02-06 Thread Christian Ehrhardt
hi Jerone,
I think this is good for debugging to find unsupported hardware, but it should 
not be enabled by default (you could get a printf storm if a guest workload 
does stupid things). Maybe qemu has some debug/verbose options you can use.
And additionally it would be useful for the dcr_write patch to print the value 
it tried to write.
I also don't know if we really need that caps-locked in the output.

Jerone Young wrote:
> # HG changeset patch
> # User Jerone Young <[EMAIL PROTECTED]>
> # Date 1202249136 21600
> # Node ID 4bbbf98ebf05ef77dbb68e2131b3bc0764767c99
> # Parent  f8cab6a29bf3f34f1cbf4d1e6d7bd21809fd4184
> Add print for PowerPC qemu for failed DCR read/writes
> 
> This patch adds a print to notify of failed reads and rights. Currently
> we will still ignore them (until development is fully done). But this makes
> them easier to spot.
> 
> Signed-off-by: Jerone Young <[EMAIL PROTECTED]>
> 
> 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
> @@ -178,13 +178,17 @@ int handle_powerpc_dcr_read(int vcpu, ui
>  int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data)
>  {
>  CPUState *env = cpu_single_env;
> -ppc_dcr_read(env->dcr_env, dcrn, data);
> +if (ppc_dcr_read(env->dcr_env, dcrn, data) < 0)
> +printf("DCR FAILED on READ at 0x%x\n", dcrn);
> + 
>  return 0; /* XXX ignore failed DCR ops */
>  }
> 
>  int handle_powerpc_dcr_write(int vcpu, uint32_t dcrn, uint32_t data)
>  {
>  CPUState *env = cpu_single_env;
> -ppc_dcr_write(env->dcr_env, dcrn, data);
> +if (ppc_dcr_write(env->dcr_env, dcrn, data) < 0)
> +printf("DCR FAILED on WRITE at 0x%x\n", dcrn);
just a suggestion

printf("%s - failed writing 0x%x @ 0x%x\n", dcrn, data);

> +
>  return 0; /* XXX ignore failed DCR ops */
>  }
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> kvm-ppc-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel


-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

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


Re: [kvm-devel] [PATCH 3 of 3] [POWERPC] Implement an ioctl that creates a vcpu of a particular type

2008-02-05 Thread Christian Ehrhardt
Hollis Blanchard wrote:
> The ioctl accepts a core name as input and calls kvm_vm_ioctl_create_vcpu()
> with the corresponding "guest operations" structure. That structure, which
> will be extended with additional core-specific function pointers, is saved 
> into
> the new vcpu by kvm_arch_vcpu_create().
> 
> Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
> 
[..]
> +static struct kvmppc_core_spec kvmppc_supported_guests[] = {
> + {
> + .name = "ppc440",
> + .vcpu_size = sizeof(struct kvm_vcpu),

Just for clarification, here you want to add other configuration settings you 
want to imply with the set of the cpu core right ?
E.g. we have discussed the pvr initialization on kvm-powerpc-devel and #kvm, do 
you intend to define the ppv440-pvr we want to set here in this struct?

[...]

> +
> + if (type.typelen > 32) {
> + r = -E2BIG;
> + goto out;
> + }
> +
> + coretype = vmalloc(type.typelen);
> + if (!coretype) {
> + r = -ENOMEM;
> + goto out;
> + }

If I don't overlook something we could use strnlen here instead of type.typelen 
and not trust userspace in any way (which is always good) that it passes us a 
good value.


> + if (copy_from_user(coretype, type.type, type.typelen)) {
> + r = -EFAULT;
> + goto out_free;
> + }
> + coretype[type.typelen-1] = '\0';
> +

Alltogether I like your patch even if I would have done details very different 
(and worse) and the main question about all that I wanted to point out is in 
your [0/3] mail:
"... is this approach acceptable?"
And if not what what would be alternative suggestions to pass information 
needed for vcpu_create?

> +struct kvm_vcpu_create_type {
> + __u32 id;
> + __u32 typelen;
> + char type[0];
> +};

This should work for other architectures too. While we need to specify cpu 
cores here others might specify something completely different with the same 
interface.
So kvm_vcpu_create_type might be misleading while something like 
kvm_vcpu_create_info might be more generic.
Just to get some background - do anyone else see the need to specify a detail 
on vcpu_create for their implementation in future ?



Finally I wanted to add something more to think about while we discuss this 
interface. The approach itself looks good to me, but it might somewhen need an 
extension we should discuss and decide by now.
Think of the following situation:
a) In two years we might have some generic features which are part of the 
shared vcpu struct and we would need to specify sometihng for these features on 
vcpu_create
b) At the same time we would still have our need to specify arch dependent 
information on vcpu create.
Because the KVM_CREATE_VCPU_TYPE ioctl implies a vcpu create, we would need to 
set up these new stuff prior to that create in another new call. I think it 
might be much better if we would think now of how to specify multiple things in 
this extended vcpu_create.

This might either be done by removing the implicit vcpu creation for a workflow 
like that:
  1. set generic feature a enabled
  2. set generic feature b disabled
  3. set arch specific core type to foo
  4. create_vcpu (using all that)
Or on the other Hand we might think of a encapsulated or chained information 
that allows us to pass a variable number of settings with KVM_CREATE_VCPU_TYPE.

-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

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


[kvm-devel] [PATCH][RESEND] add more regs to kvm_show_regs for powerpc

2008-01-17 Thread Christian Ehrhardt
Resend ppc patches neither rejected, commented nor accepted yet

Subject: [PATCH][RESEND] add more regs to kvm_show_regs for powerpc 
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This adds some registers useful for guest debugging to the powerpc code for
kvm_show_regs in libkvm.

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

 libkvm-powerpc.c |4 
 1 files changed, 4 insertions(+)

diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
index e4385c3..064730a 100644
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -67,6 +67,10 @@ void kvm_show_regs(kvm_context_t kvm, int vcpu)
if (kvm_get_regs(kvm, vcpu, ®s))
return;
 
+   fprintf(stderr,"guest vcpu #%d\n", vcpu);
+   fprintf(stderr,"pc:   %08x msr:  %08x\n", regs.pc, regs.msr);
+   fprintf(stderr,"lr:   %08x ctr:  %08x\n", regs.lr, regs.ctr);
+   fprintf(stderr,"srr0: %08x srr1: %08x\n", regs.srr0, regs.srr1);
for (i=0; i<32; i+=4)
{
fprintf(stderr, "gpr%02d: %08x %08x %08x %08x\n", i,

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


[kvm-devel] [PATCH][RESEND] portability: add CONFIG_KVM_HAS_PIO around pio_data

2008-01-17 Thread Christian Ehrhardt
Carsten asked for the same on s390 which brings me to resend ppc patches
neither rejected, commented nor accepted yet

Subject: [PATCH][RESEND] portability: add CONFIG_KVM_HAS_PIO around pio_data 
From: Hollis Blanchard <[EMAIL PROTECTED]>

Define and use CONFIG_KVM_HAS_PIO so that non-x86 don't need pio_data
in kvm_arch_vcpu.

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

 arch/x86/kvm/Kconfig |5 +
 virt/kvm/kvm_main.c  |2 ++
 2 files changed, 7 insertions(+)

diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 4086080..e31ac6e 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -33,9 +33,13 @@ config KVM
 
  If unsure, say N.
 
+config KVM_HAS_PIO
+   bool
+
 config KVM_INTEL
tristate "KVM for Intel processors support"
depends on KVM
+   select KVM_HAS_PIO
---help---
  Provides support for KVM on Intel processors equipped with the VT
  extensions.
@@ -43,6 +47,7 @@ config KVM_INTEL
 config KVM_AMD
tristate "KVM for AMD processors support"
depends on KVM
+   select KVM_HAS_PIO
---help---
  Provides support for KVM on AMD processors equipped with the AMD-V
  (SVM) extensions.
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4295623..f6e4232 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -677,8 +677,10 @@ static int kvm_vcpu_fault(struct vm_area_struct *vma, 
struct vm_fault *vmf)
 
if (vmf->pgoff == 0)
page = virt_to_page(vcpu->run);
+#ifdef CONFIG_KVM_HAS_PIO
else if (vmf->pgoff == KVM_PIO_PAGE_OFFSET)
page = virt_to_page(vcpu->arch.pio_data);
+#endif /* CONFIG_KVM_HAS_PIO */
else
return VM_FAULT_SIGBUS;
get_page(page);

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


[kvm-devel] [PATCH] add more regs to kvm_show_regs for powerpc

2008-01-17 Thread Christian Ehrhardt
Subject: [PATCH] add more regs to kvm_show_regs for powerpc 
From: Hollis Blanchard <[EMAIL PROTECTED]>
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This make "extra pages" allocation only apply to x86.
IA64 already had an exclusion and so does ppc. This patch switches the
default to no extra pages and lets I386 and X86_64 get it's 3 extra pages
as needed.

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

diff --git a/qemu/vl.c b/qemu/vl.c
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -9313,10 +9313,10 @@ int main(int argc, char **argv)
 
 #if USE_KVM
 /* Initialize kvm */
-#ifdef TARGET_IA64
+#if defined(TARGET_I386) || defined(TARGET_X86_64)
+#define KVM_EXTRA_PAGES 3
+#else
 #define KVM_EXTRA_PAGES 0
-#else
-#define KVM_EXTRA_PAGES 3
 #endif
 if (kvm_allowed) {
phys_ram_size += KVM_EXTRA_PAGES * TARGET_PAGE_SIZE;

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


[kvm-devel] [PATCH] ensure 4kB page alignment for embedded powerpc when using kvm

2008-01-17 Thread Christian Ehrhardt
Subject: [PATCH] ensure 4kB page alignment for embedded powerpc when using kvm 
From: Hollis Blanchard <[EMAIL PROTECTED]>
From: Christian Ehrhardt <[EMAIL PROTECTED]>

We need 4kB aligned pages when using qemu together with kvm for embedded
powerpc. Qemu already had a similar issue when CONFIG_USER_ONLY was set
so this patch adds just one more condition to the existing ifdef.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
---
 cpu.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

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
@@ -50,9 +50,10 @@ typedef uint32_t ppc_gpr_t;
 /* Specific definitions for PowerPC embedded */
 /* BookE have 36 bits physical address space */
 #define TARGET_PHYS_ADDR_BITS 64
-#if defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_USER_ONLY) || defined(USE_KVM)
 /* It looks like a lot of Linux programs assume page size
  * is 4kB long. This is evil, but we have to deal with it...
+ * Also kvm for embedded powerpc needs (atm) 4kB aligned pages
  */
 #define TARGET_PAGE_BITS 12
 #else /* defined(CONFIG_USER_ONLY) */

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


[kvm-devel] [PATCH] add more regs to kvm_show_regs for powerpc

2008-01-16 Thread Christian Ehrhardt
Subject: [PATCH] add more regs to kvm_show_regs for powerpc 
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This adds some registers useful for guest debugging to the powerpc code for
kvm_show_regs in libkvm.

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

 libkvm-powerpc.c |4 
 1 files changed, 4 insertions(+)

diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -67,6 +67,10 @@ void kvm_show_regs(kvm_context_t kvm, in
if (kvm_get_regs(kvm, vcpu, ®s))
return;
 
+   fprintf(stderr,"guest vcpu #%d\n", vcpu);
+   fprintf(stderr,"pc:   %08x msr:  %08x\n", regs.pc, regs.msr);
+   fprintf(stderr,"lr:   %08x ctr:  %08x\n", regs.lr, regs.ctr);
+   fprintf(stderr,"srr0: %08x srr1: %08x\n", regs.srr0, regs.srr1);
for (i=0; i<32; i+=4)
{
fprintf(stderr, "gpr%02d: %08x %08x %08x %08x\n", i,

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


Re: [kvm-devel] [PATCH 0 of 2] A couple ifdefs

2008-01-16 Thread Christian Ehrhardt
Avi Kivity wrote:
> Hollis Blanchard wrote:
>> These small ifdefs are necessary for integration of the PowerPC port.
>>
>>   
> 
> Only patch 2 of 2 made it.
> 
As Hollis should be sleeping right now I resend 1/2 as it arrived on 
kvm-powerpc-devel
(I hope my mail-app keeps the format this time)

-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

original mail
---

# HG changeset patch
# User Hollis Blanchard <[EMAIL PROTECTED]>
# Date 1200434310 21600
# Node ID 7fa5947a2da8c0c7424ebdcfaebcae624d6cf015
# Parent  ee0c227fe3f6632f4b1b5fde3f7e05c8ea0a4378

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

---
2 files changed, 7 insertions(+)
arch/x86/kvm/Kconfig |5 +
virt/kvm/kvm_main.c  |2 ++


diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -33,9 +33,13 @@ config KVM

  If unsure, say N.

+config KVM_HAS_PIO
+   bool
+
 config KVM_INTEL
tristate "KVM for Intel processors support"
depends on KVM
+   select KVM_HAS_PIO
---help---
  Provides support for KVM on Intel processors equipped with the VT
  extensions.
@@ -43,6 +47,7 @@ config KVM_AMD
 config KVM_AMD
tristate "KVM for AMD processors support"
depends on KVM
+   select KVM_HAS_PIO
---help---
  Provides support for KVM on AMD processors equipped with the AMD-V
  (SVM) extensions.
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -677,8 +677,10 @@ static int kvm_vcpu_fault(struct vm_area

if (vmf->pgoff == 0)
page = virt_to_page(vcpu->run);
+#ifdef CONFIG_KVM_HAS_PIO
else if (vmf->pgoff == KVM_PIO_PAGE_OFFSET)
page = virt_to_page(vcpu->arch.pio_data);
+#endif /* CONFIG_KVM_HAS_PIO */
else
return VM_FAULT_SIGBUS;
get_page(page);



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


[kvm-devel] [PATCH][RESEND] fill kvm_callback with arch specific dcr_read/dcr_write callbacks v2

2008-01-14 Thread Christian Ehrhardt
Subject: [PATCH][RESEND] fill kvm_callback with arch specific 
dcr_read/dcr_write callbacks v2
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This Patch adds the callback assignment and handlers for powerpc_dcr_read
and ppc_dcr_write which are called from libkvm.
This is the part of the patch that changes already submitted code.
Changes in v2:
This is version has the needed changes to main-ppc.c function prototypes
merged as discussed.

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

 libkvm/libkvm-powerpc.c |8 
 libkvm/libkvm.h |4 ++--
 qemu/qemu-kvm.c |4 
 qemu/qemu-kvm.h |5 +
 user/main-ppc.c |4 ++--
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -31,11 +31,11 @@ int handle_dcr(struct kvm_run *run,  kvm
int ret = 0;
 
if (run->dcr.is_write)
-   ret = kvm->callbacks->powerpc_dcr_write(kvm,
-   run->dcr.dcrn,run->dcr.data);
+   ret = kvm->callbacks->powerpc_dcr_write(run->dcr.dcrn,
+   run->dcr.data);
else
-   ret = kvm->callbacks->powerpc_dcr_read(kvm,
-   run->dcr.dcrn, &(run->dcr.data));
+   ret = kvm->callbacks->powerpc_dcr_read(run->dcr.dcrn, 
+   &(run->dcr.data));
 
return ret;
 }
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -66,8 +66,8 @@ struct kvm_callbacks {
 int (*pre_kvm_run)(void *opaque, int vcpu);
 int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
 #if defined(__powerpc__)
-int (*powerpc_dcr_read)(kvm_context_t kvm, uint32_t dcrn, uint32_t *data);
-int (*powerpc_dcr_write)(kvm_context_t kvm, uint32_t dcrn, uint32_t data);
+int (*powerpc_dcr_read)(uint32_t dcrn, uint32_t *data);
+int (*powerpc_dcr_write)(uint32_t dcrn, uint32_t data);
 #endif
 };
 
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -533,6 +533,10 @@ static struct kvm_callbacks qemu_kvm_ops
 #ifdef TARGET_I386
 .tpr_access = handle_tpr_access,
 #endif
+#ifdef TARGET_PPC
+.powerpc_dcr_read = handle_powerpc_dcr_read,
+.powerpc_dcr_write = handle_powerpc_dcr_write,
+#endif
 };
 
 int kvm_qemu_init()
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -48,6 +48,11 @@ int handle_tpr_access(void *opaque, int 
 int handle_tpr_access(void *opaque, int vcpu,
 uint64_t rip, int is_write);
 
+#ifdef TARGET_PPC
+int handle_powerpc_dcr_read(uint32_t dcrn, uint32_t *data);
+int handle_powerpc_dcr_write(uint32_t dcrn, uint32_t data);
+#endif
+
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
 
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -106,14 +106,14 @@ static int test_mem_write(void *opaque, 
return 0;
 }
 
-static int test_dcr_read(kvm_context_t kvm, uint32_t dcrn, uint32_t *data)
+static int test_dcr_read(uint32_t dcrn, uint32_t *data)
 {
printf("%s: dcrn %04X\n", __func__, dcrn);
*data = 0;
return 0;
 }
 
-static int test_dcr_write(kvm_context_t kvm, uint32_t dcrn, uint32_t data)
+static int test_dcr_write(uint32_t dcrn, uint32_t data)
 {
printf("%s: dcrn %04X data %04X\n", __func__, dcrn, data);
return 0;

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] fill kvm_callback with arch specific dcr_read/dcr_write callbacks v2

2008-01-14 Thread Christian Ehrhardt
Avi Kivity wrote:
> Avi Kivity wrote:
>> Christian Ehrhardt wrote:
>>> Subject: [PATCH] fill kvm_callback with arch specific 
>>> dcr_read/dcr_write callbacks v2
>>> From: Christian Ehrhardt <[EMAIL PROTECTED]>
>>>
>>> This Patch adds the callback assignment and handlers for 
>>> powerpc_dcr_read
>>> and ppc_dcr_write which are called from libkvm.
>>> This is the part of the patch that changes already submitted code.
>>> Changes in v2:
>>> The function arguments of powerpc_dcr_read/write changed. Since 
>>> main-ppc.c
>>> is not yet upstream when you check out from kvm-userspace.git I 
>>> didn't see it.
>>> But Avi replied with "Applied all, thanks." to the three patches from
>>> 01/09/2008 bringing main-ppc.c into kvm-userspace this v2 patch 
>>> includes the
>>> needed code for that file too.
>>>   
>> Sorry, I forgot to push after applying.  I'll apply this incrementally.
>>
> 
> Or rather, please send a new patch.  I'd rather not risk mucking with 
> code I can't compile.

I wrote it a bit misleading, this patch is already the merge of both, so 
because version 1 is not in the repository you can just add this one which 
patches all referred issues at once.
I tested it - it still works and matches todays head of kvm-userspace.git.
To be sure I'll resubmit it so you don't need to go through your old mails.

-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] fill kvm_callback with arch specific dcr_read/dcr_write callbacks v2

2008-01-11 Thread Christian Ehrhardt
Subject: [PATCH] fill kvm_callback with arch specific dcr_read/dcr_write 
callbacks v2
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This Patch adds the callback assignment and handlers for powerpc_dcr_read
and ppc_dcr_write which are called from libkvm.
This is the part of the patch that changes already submitted code.
Changes in v2:
The function arguments of powerpc_dcr_read/write changed. Since main-ppc.c
is not yet upstream when you check out from kvm-userspace.git I didn't see it.
But Avi replied with "Applied all, thanks." to the three patches from
01/09/2008 bringing main-ppc.c into kvm-userspace this v2 patch includes the
needed code for that file too.

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

 libkvm/libkvm-powerpc.c |8 
 libkvm/libkvm.h |4 ++--
 qemu/qemu-kvm.c |4 
 qemu/qemu-kvm.h |5 +
 user/main-ppc.c |4 ++--
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -31,11 +31,11 @@ int handle_dcr(struct kvm_run *run,  kvm
int ret = 0;
 
if (run->dcr.is_write)
-   ret = kvm->callbacks->powerpc_dcr_write(kvm,
-   run->dcr.dcrn,run->dcr.data);
+   ret = kvm->callbacks->powerpc_dcr_write(run->dcr.dcrn,
+   run->dcr.data);
else
-   ret = kvm->callbacks->powerpc_dcr_read(kvm,
-   run->dcr.dcrn, &(run->dcr.data));
+   ret = kvm->callbacks->powerpc_dcr_read(run->dcr.dcrn, 
+   &(run->dcr.data));
 
return ret;
 }
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -66,8 +66,8 @@ struct kvm_callbacks {
 int (*pre_kvm_run)(void *opaque, int vcpu);
 int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
 #if defined(__powerpc__)
-int (*powerpc_dcr_read)(kvm_context_t kvm, uint32_t dcrn, uint32_t *data);
-int (*powerpc_dcr_write)(kvm_context_t kvm, uint32_t dcrn, uint32_t data);
+int (*powerpc_dcr_read)(uint32_t dcrn, uint32_t *data);
+int (*powerpc_dcr_write)(uint32_t dcrn, uint32_t data);
 #endif
 };
 
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -533,6 +533,10 @@ static struct kvm_callbacks qemu_kvm_ops
 #ifdef TARGET_I386
 .tpr_access = handle_tpr_access,
 #endif
+#ifdef TARGET_PPC
+.powerpc_dcr_read = handle_powerpc_dcr_read,
+.powerpc_dcr_write = handle_powerpc_dcr_write,
+#endif
 };
 
 int kvm_qemu_init()
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -48,6 +48,11 @@ int handle_tpr_access(void *opaque, int 
 int handle_tpr_access(void *opaque, int vcpu,
 uint64_t rip, int is_write);
 
+#ifdef TARGET_PPC
+int handle_powerpc_dcr_read(uint32_t dcrn, uint32_t *data);
+int handle_powerpc_dcr_write(uint32_t dcrn, uint32_t data);
+#endif
+
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
 
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -106,14 +106,14 @@ static int test_mem_write(void *opaque, 
return 0;
 }
 
-static int test_dcr_read(kvm_context_t kvm, uint32_t dcrn, uint32_t *data)
+static int test_dcr_read(uint32_t dcrn, uint32_t *data)
 {
printf("%s: dcrn %04X\n", __func__, dcrn);
*data = 0;
return 0;
 }
 
-static int test_dcr_write(kvm_context_t kvm, uint32_t dcrn, uint32_t data)
+static int test_dcr_write(uint32_t dcrn, uint32_t data)
 {
printf("%s: dcrn %04X data %04X\n", __func__, dcrn, data);
return 0;

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] fill kvm_callback with arch specific dcr_read/dcr_write callbacks

2008-01-11 Thread Christian Ehrhardt
Subject: [PATCH] fill kvm_callback with arch specific dcr_read/dcr_write 
callbacks
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This Patch adds the callback assignment and handlers for powerpc_dcr_read
and ppc_dcr_write which are called from libkvm.
This is the part of the patch that changes already submitted code while the
implementation will follow as one when kvm-userspace for ppc is finished, but
appyling this now will reduce the changes to non-ppc files later in the big
patch.

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

 libkvm/libkvm-powerpc.c |8 
 libkvm/libkvm.h |4 ++--
 qemu/qemu-kvm.c |4 
 qemu/qemu-kvm.h |5 +
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -31,11 +31,11 @@ int handle_dcr(struct kvm_run *run,  kvm
int ret = 0;
 
if (run->dcr.is_write)
-   ret = kvm->callbacks->powerpc_dcr_write(kvm,
-   run->dcr.dcrn,run->dcr.data);
+   ret = kvm->callbacks->powerpc_dcr_write(run->dcr.dcrn,
+   run->dcr.data);
else
-   ret = kvm->callbacks->powerpc_dcr_read(kvm,
-   run->dcr.dcrn, &(run->dcr.data));
+   ret = kvm->callbacks->powerpc_dcr_read(run->dcr.dcrn, 
+   &(run->dcr.data));
 
return ret;
 }
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -66,8 +66,8 @@ struct kvm_callbacks {
 int (*pre_kvm_run)(void *opaque, int vcpu);
 int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
 #if defined(__powerpc__)
-int (*powerpc_dcr_read)(kvm_context_t kvm, uint32_t dcrn, uint32_t *data);
-int (*powerpc_dcr_write)(kvm_context_t kvm, uint32_t dcrn, uint32_t data);
+int (*powerpc_dcr_read)(uint32_t dcrn, uint32_t *data);
+int (*powerpc_dcr_write)(uint32_t dcrn, uint32_t data);
 #endif
 };
 
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -533,6 +533,10 @@ static struct kvm_callbacks qemu_kvm_ops
 #ifdef TARGET_I386
 .tpr_access = handle_tpr_access,
 #endif
+#ifdef TARGET_PPC
+.powerpc_dcr_read = handle_powerpc_dcr_read,
+.powerpc_dcr_write = handle_powerpc_dcr_write,
+#endif
 };
 
 int kvm_qemu_init()
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -48,6 +48,11 @@ int handle_tpr_access(void *opaque, int 
 int handle_tpr_access(void *opaque, int vcpu,
 uint64_t rip, int is_write);
 
+#ifdef TARGET_PPC
+int handle_powerpc_dcr_read(uint32_t dcrn, uint32_t *data);
+int handle_powerpc_dcr_write(uint32_t dcrn, uint32_t data);
+#endif
+
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
 

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] portability: configure top level dependencies per architecture

2008-01-10 Thread Christian Ehrhardt
This includes the comments from Avi to "[PATCH] portability: add top level
config-$arch files v2". Putting the arch dependencies into if's saves us 4
config-$arch files which are not essential to fix the current issue.
Since this is copy&paste from Avis response to v2 I added him to the From list

changes to v2:
 - remove config-$arch files 
 - put arch dep in if's checking the arch to add more dependencies to a
   target directly in the top level Makefile

---

Subject: [PATCH] portability: configure top level dependencies per architecture 
From: Christian Ehrhardt <[EMAIL PROTECTED]>
From: Avi Kivity [EMAIL PROTECTED]

This allows per arch configuration for the top level Makefile of
kvm-userspace e.g. allowing to disable extboot for non x86 or disabling
kvmctl build until ported to an architecture.

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

 Makefile |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -7,14 +7,20 @@ rpmrelease = devel
 
 .PHONY: kernel user libkvm qemu bios vgabios extboot clean
 
-all: $(if $(WANT_MODULE), kernel) user libkvm qemu
+all: libkvm qemu
+ifneq '$(filter $(ARCH), x86_64 i386 ia64)' ''
+all: $(if $(WANT_MODULE), kernel) user
+endif
 
 kcmd = $(if $(WANT_MODULE),,@\#)
 
 qemu kernel user libkvm:
$(MAKE) -C $@
 
-qemu: libkvm extboot
+qemu: libkvm
+ifneq '$(filter $(ARCH), i386 x86_64)' ''
+qemu: extboot
+endif
 user: libkvm
 
 bios:

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 1/3] Add OBJCOPY to kvm-userspace/user/configure output

2008-01-09 Thread Christian Ehrhardt
Subject: [PATCH 1/3] Add OBJCOPY to kvm-userspace/user/configure output
From: Hollis Blanchard <[EMAIL PROTECTED]>
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Adds objectcopy to the configure script because it is needed for some kvmctl
implementations for a simple binary loader.

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

---
1 file changed, 2 insertions(+)
user/configure |2 ++

diff -r deef85d890df user/configure
--- a/user/configureWed Jan 09 13:29:39 2008 +0100
+++ b/user/configureWed Jan 09 13:35:00 2008 +0100
@@ -4,6 +4,7 @@ kerneldir=/lib/modules/$(uname -r)/build
 kerneldir=/lib/modules/$(uname -r)/build
 cc=gcc
 ld=ld
+objcopy=objcopy
 arch=`uname -m | sed -e s/i.86/i386/`
 cross_prefix=
 
@@ -63,4 +64,5 @@ ARCH=$arch
 ARCH=$arch
 CC=$cross_prefix$cc
 LD=$cross_prefix$ld
+OBJCOPY=$cross_prefix$objcopy
 EOF

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 2/3] Add PowerPC kvmctl harness and fix building the testcases

2008-01-09 Thread Christian Ehrhardt
Subject: [PATCH 2/3] Add PowerPC kvmctl harness and fix building the testcases
From: Hollis Blanchard <[EMAIL PROTECTED]>
From: Christian Ehrhardt <[EMAIL PROTECTED]>

These patches get the kvm-userspace/user/ test harness building and somewhat
working for PowerPC. For the moment it's just a simply binary loader (hence
the need for objcopy), but in the future it should be easy to add an ELF or
even uImage loader.
This patch version removed x86 pio,io_table,misc_io code and some unused
defines according to avi's comments.

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

---
 b/user/main-ppc.c   |  355 
 user/config-powerpc.mak |   30 ++--
 2 files changed, 376 insertions(+), 9 deletions(-)

diff -r f5bbfeaedb2c user/config-powerpc.mak
--- a/user/config-powerpc.mak   Wed Jan 09 13:35:00 2008 +0100
+++ b/user/config-powerpc.mak   Wed Jan 09 14:38:20 2008 +0100
@@ -1,14 +1,26 @@ TEST_DIR=test/powerpc
-TEST_DIR=test/powerpc
 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
 
-tests= $(TEST_DIR)/io.S \
-   $(TEST_DIR)/spin.S \
-   $(TEST_DIR)/sprg.S \
-   $(TEST_DIR)/44x/tlbsx.S \
-   $(TEST_DIR)/44x/tlbwe_16KB.S \
-   $(TEST_DIR)/44x/tlbwe_hole.S \
-   $(TEST_DIR)/44x/tlbwe.S
+%.bin: %.o
+   $(OBJCOPY) -O binary $^ $@
 
-kvmctl_objs = main.o ../libkvm/libkvm.a
+testobjs := \
+   io.bin \
+   spin.bin \
+   sprg.bin \
+   44x/tlbsx.bin \
+   44x/tlbwe_16KB.bin \
+   44x/tlbwe_hole.bin \
+   44x/tlbwe.bin
+
+tests := $(addprefix test/powerpc/, $(testobjs))
+
+all: kvmctl $(tests)
+
+kvmctl_objs = main-ppc.o ../libkvm/libkvm.a
+
+arch_clean:
+   rm -f $(tests)
diff -r f5bbfeaedb2c user/main-ppc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/user/main-ppc.c   Wed Jan 09 14:38:20 2008 +0100
@@ -0,0 +1,315 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ * Copyright IBM Corp. 2008
+ *
+ * Authors:
+ *
+ *  Avi Kivity <[EMAIL PROTECTED]>
+ *  Yaniv Kamay <[EMAIL PROTECTED]>
+ *  Hollis Blanchard <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#define _GNU_SOURCE
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int gettid(void)
+{
+   return syscall(__NR_gettid);
+}
+
+kvm_context_t kvm;
+
+#define IPI_SIGNAL (SIGRTMIN + 4)
+
+static int ncpus = 1;
+static sem_t init_sem;
+static __thread int vcpu;
+static sigset_t kernel_sigmask;
+static sigset_t ipi_sigmask;
+static uint64_t memory_size = 128 * 1024 * 1024;
+
+struct vcpu_info {
+   pid_t tid;
+};
+
+struct vcpu_info *vcpus;
+
+static int test_debug(void *opaque, int vcpu)
+{
+   printf("test_debug\n");
+   return 0;
+}
+
+static int test_halt(void *opaque, int vcpu)
+{
+   int n;
+
+   sigwait(&ipi_sigmask, &n);
+   return 0;
+}
+
+static int test_io_window(void *opaque)
+{
+   return 0;
+}
+
+static int test_try_push_interrupts(void *opaque)
+{
+   return 0;
+}
+
+static void test_post_kvm_run(void *opaque, int vcpu)
+{
+}
+
+static int test_pre_kvm_run(void *opaque, int vcpu)
+{
+   return 0;
+}
+
+static int test_mem_read(void *opaque, uint64_t addr, uint8_t *data, int len)
+{
+   printf("%s: addr %"PRIx64" len %d\n", __func__, addr, len);
+   memset(data, 0, len);
+   return 0;
+}
+
+static int test_mem_write(void *opaque, uint64_t addr, uint8_t *data, int len)
+{
+   printf("%s: addr %"PRIx64" len %d data %"PRIx64"\n",
+  __func__, addr, len, *(uint64_t *)data);
+   return 0;
+}
+
+static struct kvm_callbacks test_callbacks = {
+   .mmio_read   = test_mem_read,
+   .mmio_write  = test_mem_write,
+   .debug   = test_debug,
+   .halt= test_halt,
+   .io_window = test_io_window,
+   .try_push_interrupts = test_try_push_interrupts,
+   .post_kvm_run = test_post_kvm_run,
+   .pre_kvm_run = test_pre_kvm_run,
+};
+
+static unsigned long load_file(void *mem, const char *fname, int inval_icache)
+{
+   int r;
+   int fd;
+   unsigned long bytes = 0;
+
+   fd = open(fname, O_RDONLY);
+   if (fd == -1) {
+   perror("open");
+   exit(1);
+   }
+
+   while ((r = read(fd, mem, 4096)) != -1 && r != 0) {
+   mem += r;
+   bytes += r;
+   }
+
+   if (r == -1) {
+   perror("r

[kvm-devel] [PATCH 3/3] Add dcr read/write to the PowerPC kvmctl implementation

2008-01-09 Thread Christian Ehrhardt
Subject: [PATCH 3/3] Add dcr read/write to the PowerPC kvmctl implementation
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Adds simple functions to catch dcr access while executing testcases printing
information about that access when triggered.

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

---
 main-ppc.c |   15 +++
 1 files changed, 15 insertions(+)

diff -r d19893c744fa user/main-ppc.c
--- a/user/main-ppc.c   Wed Jan 09 14:06:38 2008 +0100
+++ b/user/main-ppc.c   Wed Jan 09 14:34:49 2008 +0100
@@ -146,6 +146,19 @@ static int test_mem_write(void *opaque, 
return 0;
 }
 
+static int test_dcr_read(kvm_context_t kvm, uint32_t dcrn, uint32_t *data)
+{
+   printf("%s: dcrn %04X\n", __func__, dcrn);
+   *data = 0;
+   return 0;
+}
+
+static int test_dcr_write(kvm_context_t kvm, uint32_t dcrn, uint32_t data)
+{
+   printf("%s: dcrn %04X data %04X\n", __func__, dcrn, data);
+   return 0;
+}
+
 static struct kvm_callbacks test_callbacks = {
.mmio_read   = test_mem_read,
.mmio_write  = test_mem_write,
@@ -155,6 +168,8 @@ static struct kvm_callbacks test_callbac
.try_push_interrupts = test_try_push_interrupts,
.post_kvm_run = test_post_kvm_run,
.pre_kvm_run = test_pre_kvm_run,
+   .powerpc_dcr_read = test_dcr_read,
+   .powerpc_dcr_write = test_dcr_write,
 };
 
 static unsigned long load_file(void *mem, const char *fname, int inval_icache)

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] portability: add top level config-$arch files v2

2008-01-09 Thread Christian Ehrhardt
This includes the comments from Jerone. Moving the targets back into the
Makefile e.g. easen things for people looking at the Makefile for the first
time and looking for targets. So here v2 of the patch.
changes to v1:
 - defining per arch targets via variables in config-$arch
 - removed that user is not build for ppc assuming Hollis patches
   are accepted sometime soon

---

Subject: [PATCH] portability: add top level config-$arch files v2
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This allows per arch configuration for the top level Makefile of
kvm-userspace e.g. allowing to disable extboot for non x86 or disabling
kvmctl build until ported to an architecture.
I'm aware that we now have already 8 config-$arch files in kvm-userspace
and this patch adds 4 more so maybe we need some kind of consolidation in
the future - comments and approaches to that are very welcome.

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

Makefile |5 +++--
 b/config-i386.mak|2 ++
 b/config-ia64.mak|2 ++
 b/config-powerpc.mak |3 +++
 b/config-x86_64.mak  |2 ++
 5 files changed, 12 insertions(+), 2 deletions(-)

diff -r d21fce8a6cd9 Makefile
--- a/Makefile  Wed Jan 09 10:49:03 2008 +0100
+++ b/Makefile  Wed Jan 09 12:33:26 2008 +0100
@@ -1,5 +1,6 @@
 
 include config.mak
+include config-$(ARCH).mak
 
 DESTDIR=
 
@@ -7,14 +8,14 @@ rpmrelease = devel
 
 .PHONY: kernel user libkvm qemu bios vgabios extboot clean
 
-all: $(if $(WANT_MODULE), kernel) user libkvm qemu
+all: $(ARCH_ALL_DEP)
 
 kcmd = $(if $(WANT_MODULE),,@\#)
 
 qemu kernel user libkvm:
$(MAKE) -C $@
 
-qemu: libkvm extboot
+qemu: $(ARCH_QEMU_DEP)
 user: libkvm
 
 bios:
diff -r d21fce8a6cd9 config-i386.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-i386.mak   Wed Jan 09 12:33:26 2008 +0100
@@ -0,0 +1,2 @@
+ARCH_ALL_DEP = $(if $(WANT_MODULE), kernel) user libkvm qemu
+ARCH_QEMU_DEP = libkvm extboot
diff -r d21fce8a6cd9 config-ia64.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-ia64.mak   Wed Jan 09 12:33:26 2008 +0100
@@ -0,0 +1,2 @@
+ARCH_ALL_DEP = $(if $(WANT_MODULE), kernel) user libkvm qemu
+ARCH_QEMU_DEP = libkvm extboot
diff -r d21fce8a6cd9 config-powerpc.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-powerpc.makWed Jan 09 12:33:26 2008 +0100
@@ -0,0 +1,3 @@
+ARCH_ALL_DEP = $(if $(WANT_MODULE), kernel) user libkvm qemu
+# extboot is x86 only
+ARCH_QEMU_DEP = libkvm
diff -r d21fce8a6cd9 config-x86_64.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-x86_64.mak Wed Jan 09 12:33:26 2008 +0100
@@ -0,0 +1,2 @@
+ARCH_ALL_DEP = $(if $(WANT_MODULE), kernel) user libkvm qemu
+ARCH_QEMU_DEP = libkvm extboot

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] portability: add top level config-$arch files

2008-01-08 Thread Christian Ehrhardt
Subject: [PATCH] portability: add top level config-$arch files
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This allows per arch configuration for the top level Makefile of
kvm-userspace e.g. allowing to disable extboot for non x86 or disabling
kvmctl build until ported to an architecture.
I'm aware that we now have already 8 config-$arch files in kvm-userspace
and this patch adds 4 more so maybe we need some kind of consolidation in
the future - comments and approaches to that are very welcome.

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

 Makefile |5 +
 b/config-i386.mak|2 ++
 b/config-ia64.mak|2 ++
 b/config-powerpc.mak |4 
 b/config-x86_64.mak  |2 ++
 5 files changed, 11 insertions(+), 4 deletions(-)

diff -r 958dc9839a95 Makefile
--- a/Makefile  Tue Jan 08 13:06:03 2008 +0100
+++ b/Makefile  Tue Jan 08 13:59:10 2008 +0100
@@ -1,5 +1,5 @@
-
 include config.mak
+include config-$(ARCH).mak
 
 DESTDIR=
 
@@ -7,14 +7,11 @@ rpmrelease = devel
 
 .PHONY: kernel user libkvm qemu bios vgabios extboot clean
 
-all: $(if $(WANT_MODULE), kernel) user libkvm qemu
-
 kcmd = $(if $(WANT_MODULE),,@\#)
 
 qemu kernel user libkvm:
$(MAKE) -C $@
 
-qemu: libkvm extboot
 user: libkvm
 
 bios:
diff -r 958dc9839a95 config-i386.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-i386.mak   Tue Jan 08 13:59:10 2008 +0100
@@ -0,0 +1,2 @@
+all: $(if $(WANT_MODULE), kernel) user libkvm qemu
+qemu: libkvm extboot
diff -r 958dc9839a95 config-ia64.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-ia64.mak   Tue Jan 08 13:59:10 2008 +0100
@@ -0,0 +1,2 @@
+all: $(if $(WANT_MODULE), kernel) user libkvm qemu
+qemu: libkvm extboot
diff -r 958dc9839a95 config-powerpc.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-powerpc.makTue Jan 08 13:59:10 2008 +0100
@@ -0,0 +1,4 @@
+# kvmctl (user) not yet ported to powerpc
+all: $(if $(WANT_MODULE), kernel) libkvm qemu
+# extboot is x86 only
+qemu: libkvm
diff -r 958dc9839a95 config-x86_64.mak
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/config-x86_64.mak Tue Jan 08 13:59:10 2008 +0100
@@ -0,0 +1,2 @@
+all: $(if $(WANT_MODULE), kernel) user libkvm qemu
+qemu: libkvm extboot

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] extboot: fix -fno-stack-protector usage

2008-01-08 Thread Christian Ehrhardt
Subject: [PATCH] extboot: fix -fno-stack-protector usage 
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Option -fno-stack-protector breaks kvm-userspace in environments without
stack-protector functionality. They fail with "unrecognized command line 
option" when compiling extboot.
This patch removes the fix -fno-stack-protector option and replaces it
with a detection that only adds -fno-stack-protector if the option is
supported by the used gcc.
The detection code is copied from kernel sources scripts/Kbuild.include.

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

 Makefile |   24 ++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/extboot/Makefile b/extboot/Makefile
index 1ea71a7..ab2dae7 100644
--- a/extboot/Makefile
+++ b/extboot/Makefile
@@ -1,7 +1,27 @@
 OBJCOPY=objcopy
 
-CFLAGS=-Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin \
-   -fno-stack-protector
+# from kernel sources - scripts/Kbuild.include
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e;  \
+   TMP="$(TMPOUT)..tmp";   \
+   if ($(1)) >/dev/null 2>&1;  \
+   then echo "$(2)";   \
+   else echo "$(3)";   \
+   fi; \
+   rm -f "$$TMP")
+
+# cc-option-yn
+# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+cc-option-yn = $(call try-run,\
+   $(CC) $(KBUILD_CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
+
+CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
+ifeq ($(call cc-option-yn,-fno-stack-protector),y)
+CFLAGS += -fno-stack-protector
+endif
 
 all: extboot.bin
 

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] portability: move kvm_fpu to asm-x86/kvm.h

2008-01-07 Thread Christian Ehrhardt
Subject: [PATCH] portability: move kvm_fpu to asm-x86/kvm.h
From: Christian Ehrhardt <[EMAIL PROTECTED]>

This patch moves kvm_fpu asm-x86/kvm.h to allow every architecture to
define an own representation used for KVM_GET_FPU/KVM_SET_FPU.

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

 asm-x86/kvm.h |   15 +++
 linux/kvm.h   |   17 -
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/include/asm-x86/kvm.h b/include/asm-x86/kvm.h
index 17afa81..7a71120 100644
--- a/include/asm-x86/kvm.h
+++ b/include/asm-x86/kvm.h
@@ -114,6 +114,21 @@ struct kvm_sregs {
__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
 };
 
+/* for KVM_GET_FPU and KVM_SET_FPU */
+struct kvm_fpu {
+   __u8  fpr[8][16];
+   __u16 fcw;
+   __u16 fsw;
+   __u8  ftwx;  /* in fxsave format */
+   __u8  pad1;
+   __u16 last_opcode;
+   __u64 last_ip;
+   __u64 last_dp;
+   __u8  xmm[16][16];
+   __u32 mxcsr;
+   __u32 pad2;
+};
+
 struct kvm_msr_entry {
__u32 index;
__u32 reserved;
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index b27a381..4de4fd2 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -142,23 +142,6 @@ struct kvm_run {
};
 };
 
-
-/* for KVM_GET_FPU and KVM_SET_FPU */
-struct kvm_fpu {
-   __u8  fpr[8][16];
-   __u16 fcw;
-   __u16 fsw;
-   __u8  ftwx;  /* in fxsave format */
-   __u8  pad1;
-   __u16 last_opcode;
-   __u64 last_ip;
-   __u64 last_dp;
-   __u8  xmm[16][16];
-   __u32 mxcsr;
-   __u32 pad2;
-};
-
-
 /* for KVM_TRANSLATE */
 struct kvm_translation {
/* in */

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH][UPDATE] kvm-userspace: simplify mmio callback

2007-12-18 Thread Christian Ehrhardt
Subject: [PATCH][UPDATE] kvm-userspace: simplify mmio callback
From: Christian Ehrhardt <[EMAIL PROTECTED]>

Merging the read[bwlq]/write[bwlq] callback callback pointers to 
mmio_read/write functions simplifies the callback interface.
On the qemu side it now uses the cpu_physical_memory_rw function.
Additonally this patch merges the RedHat 7.1 mmio workaround that
was spread to two code locations.

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

diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 93d7b6b..fd93f44 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -826,44 +826,17 @@ static int handle_mmio(kvm_context_t kvm, struct kvm_run 
*kvm_run)
 {
unsigned long addr = kvm_run->mmio.phys_addr;
void *data = kvm_run->mmio.data;
-   int r = -1;
 
-   /* hack: Red Hat 7.1 generates these wierd accesses. */
-   if (addr == 0xa && kvm_run->mmio.len == 3)
+   /* hack: Red Hat 7.1 generates these weird accesses. */
+   if ((addr > 0xa-4 && addr <= 0xa) && kvm_run->mmio.len == 3)
return 0;
 
-   if (kvm_run->mmio.is_write) {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->writeb(kvm->opaque, addr, *(uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->writew(kvm->opaque, addr, 
*(uint16_t *)data);
-   break;
-   case 4:
-   r = kvm->callbacks->writel(kvm->opaque, addr, 
*(uint32_t *)data);
-   break;
-   case 8:
-   r = kvm->callbacks->writeq(kvm->opaque, addr, 
*(uint64_t *)data);
-   break;
-   }
-   } else {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->readb(kvm->opaque, addr, (uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->readw(kvm->opaque, addr, (uint16_t 
*)data);
-   break;
-   case 4:
-   r = kvm->callbacks->readl(kvm->opaque, addr, (uint32_t 
*)data);
-   break;
-   case 8:
-   r = kvm->callbacks->readq(kvm->opaque, addr, (uint64_t 
*)data);
-   break;
-   }
-   }
-   return r;
+   if (kvm_run->mmio.is_write)
+   return kvm->callbacks->mmio_write(kvm->opaque, addr, data,
+   kvm_run->mmio.len);
+   else
+   return kvm->callbacks->mmio_read(kvm->opaque, addr, data,
+   kvm_run->mmio.len);
 }
 
 int handle_io_window(kvm_context_t kvm)
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 110912a..62407f5 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -45,22 +45,12 @@ struct kvm_callbacks {
 int (*outw)(void *opaque, uint16_t addr, uint16_t data);
/// For 32bit IO writes from the guest (Usually when executing 'outl')
 int (*outl)(void *opaque, uint16_t addr, uint32_t data);
-   /// For 8bit memory reads from unmapped memory (For MMIO devices)
-int (*readb)(void *opaque, uint64_t addr, uint8_t *data);
-   /// For 16bit memory reads from unmapped memory (For MMIO devices)
-int (*readw)(void *opaque, uint64_t addr, uint16_t *data);
-   /// For 32bit memory reads from unmapped memory (For MMIO devices)
-int (*readl)(void *opaque, uint64_t addr, uint32_t *data);
-   /// For 64bit memory reads from unmapped memory (For MMIO devices)
-int (*readq)(void *opaque, uint64_t addr, uint64_t *data);
-   /// For 8bit memory writes to unmapped memory (For MMIO devices)
-int (*writeb)(void *opaque, uint64_t addr, uint8_t data);
-   /// For 16bit memory writes to unmapped memory (For MMIO devices)
-int (*writew)(void *opaque, uint64_t addr, uint16_t data);
-   /// For 32bit memory writes to unmapped memory (For MMIO devices)
-int (*writel)(void *opaque, uint64_t addr, uint32_t data);
-   /// For 64bit memory writes to unmapped memory (For MMIO devices)
-int (*writeq)(void *opaque, uint64_t addr, uint64_t data);
+   /// generic memory reads to unmapped memory (For MMIO devices)
+int (*mmio_read)(void *opaque, uint64_t addr, uint8_t *data,
+   int len);
+   /// generic memory writes to unmapped memory (For MMIO devices)
+int (*mmio_write)(void *opaque, uint64_t addr, uint8_t *data,
+   int len);
 int (*debug)(void *opaque, int vcpu);
/*!
 * \brief Called when the VCPU issues an 'hlt' instruction.
diff --git a/qemu/qemu-kvm.c b/qemu/qem

[kvm-devel] [PATCH][UPDATE] kvm-userspace: sync icache for more architectures

2007-12-18 Thread Christian Ehrhardt
Subject: [PATCH][UPDATE] kvm-userspace: sync icache for more architectures
From: Christian Ehrhardt <[EMAIL PROTECTED]>

A ia64 patch introduced kvm_sync_icache within a ifdef __ia64__, but the 
concept of split caches is not bound to ia64. This patch replaces the the 
call to kvm_synch_icache by the flush_icache_range function
that is already available in qemu for ia64 and ppc (noop for x86). 
The call now depends on USE_KVM.

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

diff --git a/qemu/exec.c b/qemu/exec.c
index 8b6a2f6..7371cc7 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -35,6 +35,7 @@
 #include "cpu.h"
 #include "exec-all.h"
 #ifdef USE_KVM
+#include "dyngen.h"
 #include "qemu-kvm.h"
 #endif
 #if defined(CONFIG_USER_ONLY)
@@ -2600,8 +2601,10 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
 (0xff & ~CODE_DIRTY_FLAG);
 }
-#ifdef __ia64__
-   kvm_sync_icache((unsigned long)ptr, l);
+#ifdef USE_KVM
+   /* qemu doesn't execute guest code directly, but kvm does
+  therefore fluch instruction caches */
+   flush_icache_range((unsigned long)ptr, ((unsigned long)ptr)+l);
 #endif
 }
 } else {
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index 03df73d..cf76f35 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -273,17 +273,6 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
 #ifdef USE_KVM
 extern kvm_context_t kvm_context;
 extern int kvm_allowed;
-
-void kvm_sync_icache(unsigned long address, int len)
-{
-   int l;
-
-   for(l = 0; l < (len + 32); l += 32)
-   __ia64_fc(address + l);
-
-   ia64_sync_i();
-   ia64_srlz_i();
-}
 #endif
 
 static void main_cpu_reset(void *opaque)
diff --git a/qemu/target-ia64/cpu.h b/qemu/target-ia64/cpu.h
index 7349e94..be409c7 100644
--- a/qemu/target-ia64/cpu.h
+++ b/qemu/target-ia64/cpu.h
@@ -73,9 +73,4 @@ CPUState *cpu_ia64_init(void);
 
 #include "cpu-all.h"
 
-/* IA64 has seperate I/D cache, with coherence maintained by DMA controller.
- * So to emulate right behavior that guest OS is assumed, we need to flush
- * I/D cache here.
- */
-void kvm_sync_icache(unsigned long address, int len);
 #endif

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH][UPDATE] kvm-userspace: sync icache for morearchitectures

2007-12-18 Thread Christian Ehrhardt
Hollis Blanchard wrote:
> On Fri, 2007-12-14 at 10:07 +0100, Christian Ehrhardt wrote:
>> Hollis Blanchard wrote:
>>> A comment to explain why the icache needs flushing only in the KVM
>> case
>>> would be useful. Other than that I'm fine with it.
>>>
>>> Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
>> AFAIK Plain qemu does not directly execute guest code on the
>> processor,
>> so the icache is not an issue for it.
>> Qemu itself has the flush_icache_range function only as helper for the
>> dynamic code generation.
>> But we may now write executable guest code with our intercepted mmio
>> handling that is directly executed when switching back to the guest
>> context, therefore we need that invalidation in the kvm case.
>>
>> For the case that I'm overlooking something in plain qemu, so that it
>> might need it too I add [EMAIL PROTECTED] for comments from there,
>> but currently I think to have it in #ifdef USE_KVM is the right way.
>>
>>
>> P.S. Hollis did you mean you would like to see a comment in the code
>> where that call takes place?
> 
> Yes! Hopefully much shorter than this email... :-P
> 
comment added, rebased and resent together with a updated mmio
callback simplification patch - I hope I didn't overlook a response
to the mmio callback thread again this time ;-)

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] Current e500 kvm guest kernel booting log

2007-12-18 Thread Christian Ehrhardt

Hollis already pointed me to the mkasm-values patches which are the 
continuation of the mkasm-offset discussion on lkml Hollis last patch was based 
on.
As stated before by Xiantao and Hollis in this thread the mkasm-value patches 
are not yet accepted upstream, but may be useful for us.
Based on Hollis old mkasm-offsets patch, the further discussion on lkml and 
Xiantaos suggestion about the FORCE target I created a mkasm-values patch that 
now is at least able to do what we need for ppc and should fit the ia64 needs 
too.
We might use it internally until mkasm-values is accepted in any way or in a 
local form like ia64 that currently use their own script - let us at least use 
a common one together and mkasm-values may be a good base for that ;-)
The current patch is for discussion only because it won't fit git head of avi's 
tree - I need to rebase Hollis tree first and I'll send an update once I get 
around to do it.

The patch work to create, and re-generate asm-values.h as we need it and since now every 
architecture has its own arch/kvm&asm directory we can even keep the name 
"asm-values.h" the lkml patches expect. Because these preview patches are for 
discussion only I attach both to this mail instead of sending standard [patch][x/y] mails.

@Zhang Wai - afaik you use Hollis kvmppc development tree, you can just remove 
the old mkasm-offset patch and add these two to get the offset stuff to work 
for now

--

Grüsse / regards, 
Christian Ehrhardt


IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen

Registergericht: Amtsgericht Stuttgart, HRB 243294
diff -r 78da6ce942cc include/asm-generic/asm-values.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/include/asm-generic/asm-values.h  Mon Dec 17 13:38:19 2007 +0100
@@ -0,0 +1,7 @@
+#define DEFINE(sym, val) \
+   asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+
+#define BLANK() asm volatile("\n->" : : )
+
+#define OFFSET(sym, str, mem) \
+   DEFINE(sym, offsetof(struct str, mem));
diff -r 78da6ce942cc scripts/Makefile.asm
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/scripts/Makefile.asm  Tue Dec 18 10:36:48 2007 +0100
@@ -0,0 +1,29 @@
+# ==
+# Help generate definitions needed by assembly language modules.
+# ==
+
+include scripts/Kbuild.include
+
+ifndef asm-values_h
+asm-values := $(shell test -e $(srctree)/$(src)/asm-values.c && echo ok)
+ifneq ($(asm-values),)
+   asm-values_h := asm-values.h
+   asm-values   := asm-values.s
+endif
+endif
+
+always += $(asm-values_h)
+targets+= $(asm-values_h) $(asm-values)
+mkasm-values   := $(srctree)/scripts/mkasm-values.sh
+
+quiet_cmd_mkasm-values = GEN $@
+  cmd_mkasm-values = $(CONFIG_SHELL) $(mkasm-values) $< $@ $(2)
+
+quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
+  cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
+
+$(obj)/asm-values.h: $(obj)/asm-values.s
+   $(call cmd,mkasm-values,$(ASM_NS))
+
+$(obj)/%.s: $(src)/%.c
+   $(call if_changed_dep,cc_s_c)
diff -r 78da6ce942cc scripts/mkasm-values.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/scripts/mkasm-values.sh   Mon Dec 17 13:38:19 2007 +0100
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# Input file "*.s", made by Kbuild from a "*.c" source, where values of
+# interest are calculated, is processed in a suitable output header file.
+#
+# $1 - input filename;
+# $2 - output filename;
+# $3 - generate (private) file with given namespace (optional)
+
+set -e
+
+[ -z "$1" ] || [ -z "$2" ] && {
+   echo "$0:
+
+Two parameters needed. Exiting.
+"
+   exit 1
+}
+
+NS=`echo $3 | tr a-z A-Z`
+case $NS in
+   MIPS)
+SED_SCRIPT='
+/^@@@/{
+s|^@@@||;
+s| #.*$||;
+p;
+}' ;;
+   *)
+TAB="`printf '\t'`"
+SED_SCRIPT="
+/^->/{
+s|^->||;
+s|^\([^ ]*\) [\$#]*\([^ ]*\) \([^$TAB]*\).*|#define \1 \2$TAB/* \3 */|;
+p;
+}" ;;
+esac
+
+NS=__ASM_VALUES_${NS:=H}__
+
+exec 1>$2
+echo "\
+#if !defined($NS)
+#define $NS
+
+/*
+ * $2
+ * was generated from
+ * $1
+ */
+"
+sed -ne "$SED_SCRIPT" $1
+
+echo "
+#endif"
diff -r 1b4814a8e0ed drivers/kvm/Makefile
--- a/drivers/kvm/Makefile  Tue Dec 18 10:37:21 2007 +0100
+++ b/drivers/kvm/Makefile  Tue Dec 18 10:37:37 2007 +0100
@@ -14,7 +14,7 @@ kvm-amd-objs = svm.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
 
+include $(srctree)/scripts/Makefile.asm
+FORCE: $(obj)/asm-values.h
 kvm-powerpc-objs := powerpc.o ppc_emulate.o ppc_tlb.o ppc_4

Re: [kvm-devel] [PATCH][UPDATE] kvm-userspace: sync icache for morearchitectures

2007-12-14 Thread Christian Ehrhardt
Zhang, Xiantao wrote:
>Christian Ehrhardt wrote:
<[...]
>> @@ -2600,8 +2601,8 @@ void cpu_physical_memory_rw(target_phys_addr_t
>>  addr, uint8_t *buf, phys_ram_dirty[addr1 >>
>>  TARGET_PAGE_BITS] |= (0xff &
>>  ~CODE_DIRTY_FLAG); }
>> -#ifdef __ia64__
>> -kvm_sync_icache((unsigned long)ptr, l);
>> +#ifdef USE_KVM
>> +flush_icache_range((unsigned long)ptr, ((unsigned
> long)ptr)+l);
> 
> Are you sure ia64 implement this function for applications ? I didn't
> find it at my side, so I write it. 
What do you mean with "implement it for applications" ?
Take a look at dyngen.h - it starts with the comment "dyngen helpers" 
and contains a lot of static functions to use them where you need.
I don't see anything obvious that would prevent these functions from
being built and the file has no own include statements which may 
change that. Therefor the include "dyngen.h" in the USE_KVM case
should be enough to have this function available for
cpu_physical_memory_rw in exec.c where we need it.
[...]
> Xiantao

---

Hollis Blanchard wrote:
> A comment to explain why the icache needs flushing only in the KVM case
> would be useful. Other than that I'm fine with it.
> 
> Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
AFAIK Plain qemu does not directly execute guest code on the processor,
so the icache is not an issue for it.
Qemu itself has the flush_icache_range function only as helper for the
dynamic code generation.
But we may now write executable guest code with our intercepted mmio
handling that is directly executed when switching back to the guest
context, therefore we need that invalidation in the kvm case.

For the case that I'm overlooking something in plain qemu, so that it
might need it too I add [EMAIL PROTECTED] for comments from there,
but currently I think to have it in #ifdef USE_KVM is the right way.


P.S. Hollis did you mean you would like to see a comment in the code
where that call takes place?

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH][UPDATE] kvm-userspace: sync icache for more architectures

2007-12-13 Thread Christian Ehrhardt
Subject: [PATCH][UPDATE] kvm-userspace: sync icache for more architectures
From: Christian Ehrhardt <[EMAIL PROTECTED]>

A ia64 patch introduced kvm_sync_icache within a ifdef __ia64__, but the 
concept of split caches is not bound to ia64 and we would like to implement
it for ppc too.
The call to kvm_synch_icache is replaced by the flush_icache_range function
that is already available in qemu for ia64 and ppc (noop for x86). The call
now depends on USE_KVM.
This patch supersedes my old "[PATCH] kvm-userspace: kvm_sync_icache for more 
architectures" from this morning. 
The current ppc code around is not yet ready (it compiles & works for x86),
could someone please test&verify this patch for ia64?

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

diff --git a/qemu/exec.c b/qemu/exec.c
index cf14fdd..d2a8f5b 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -35,6 +35,7 @@
 #include "cpu.h"
 #include "exec-all.h"
 #ifdef USE_KVM
+#include "dyngen.h"
 #include "qemu-kvm.h"
 #endif
 #if defined(CONFIG_USER_ONLY)
@@ -2600,8 +2601,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
 (0xff & ~CODE_DIRTY_FLAG);
 }
-#ifdef __ia64__
-   kvm_sync_icache((unsigned long)ptr, l);
+#ifdef USE_KVM
+   flush_icache_range((unsigned long)ptr, ((unsigned long)ptr)+l);
 #endif
 }
 } else {
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index 957e831..8686c1e 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -105,17 +105,6 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
 #ifdef USE_KVM
 extern kvm_context_t kvm_context;
 extern int kvm_allowed;
-
-void kvm_sync_icache(unsigned long address, int len)
-{
-   int l;
-
-   for(l = 0; l < (len + 32); l += 32)
-   __ia64_fc(address + l);
-
-   ia64_sync_i();
-   ia64_srlz_i();
-}
 #endif
 
 static void main_cpu_reset(void *opaque)
diff --git a/qemu/target-ia64/cpu.h b/qemu/target-ia64/cpu.h
index 7349e94..be409c7 100644
--- a/qemu/target-ia64/cpu.h
+++ b/qemu/target-ia64/cpu.h
@@ -73,9 +73,4 @@ CPUState *cpu_ia64_init(void);
 
 #include "cpu-all.h"
 
-/* IA64 has seperate I/D cache, with coherence maintained by DMA controller.
- * So to emulate right behavior that guest OS is assumed, we need to flush
- * I/D cache here.
- */
-void kvm_sync_icache(unsigned long address, int len);
 #endif

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] kvm-userspace: kvm_sync_icache for more architectures

2007-12-13 Thread Christian Ehrhardt
Subject: [PATCH] kvm-userspace: kvm_sync_icache for more architectures
From: Christian Ehrhardt <[EMAIL PROTECTED]>

A ia64 patch introduced kvm_sync_icache within a ifdef __ia64__, but the concept
of split caches is not bound to ia64 and we would like to implement it for ppc 
too.
The call to kvm_synch_icache is now indirectly dependent to USE_KVM since 
normal 
qemu should not need that flush and the function naming kvm_* suggests that it
should be only used if USE_KVM is set.

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

---
 exec.c|2 +-
 target-ia64/cpu.h |3 +++
 target-ppc/cpu.h  |8 
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/qemu/exec.c b/qemu/exec.c
index cf14fdd..5b5bd77 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -2600,7 +2600,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
 (0xff & ~CODE_DIRTY_FLAG);
 }
-#ifdef __ia64__
+#ifdef defined(KVM_SPLIT_CACHE)
kvm_sync_icache((unsigned long)ptr, l);
 #endif
 }
diff --git a/qemu/target-ia64/cpu.h b/qemu/target-ia64/cpu.h
index 7349e94..0210be9 100644
--- a/qemu/target-ia64/cpu.h
+++ b/qemu/target-ia64/cpu.h
@@ -73,9 +73,12 @@ CPUState *cpu_ia64_init(void);
 
 #include "cpu-all.h"
 
+#ifdef USE_KVM
 /* IA64 has seperate I/D cache, with coherence maintained by DMA controller.
  * So to emulate right behavior that guest OS is assumed, we need to flush
  * I/D cache here.
  */
+#define KVM_SPLIT_CACHE
 void kvm_sync_icache(unsigned long address, int len);
+#endif /* USE_KVM */
 #endif
diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
index c4ae414..5ddf6e2 100644
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -1179,4 +1179,12 @@ enum {
 
 /*/
 
+#ifdef USE_KVM
+/* ppc has a seperate I/D cache, emulate the right behavior that the guest OS
+ * is assuming, therefore we need to flush I/D cache here.
+ * FIXME Implemented as noop here until qemu-kvm-ppc code is submitted.
+ */
+#define KVM_SPLIT_CACHE
+#define kvm_sync_icache(address, len)  do { } while (0)
+#endif /* USE_KVM */
 #endif /* !defined (__CPU_PPC_H__) */

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Subject: [PATCH] [1/1] simplify mmio read/write callback structure

2007-12-11 Thread Christian Ehrhardt

Subject: [PATCH] [1/1] simplify mmio read/write callback structure

From: Christian Ehrhardt <[EMAIL PROTECTED]>

Merging the read[bwlq]/write[bwlq] callback callback pointers to 
mmio_read/write functions simplifies the callback interface.

On the qemu side it now uses the cpu_physical_memory_rw function.
Additonally this patch merges the RedHat 7.1 mmio workaround that
was spread to two code locations.

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

[diffstat]
libkvm/libkvm.c |   40 
libkvm/libkvm.h |   19 ++---
qemu/qemu-kvm.c |   62 +++-
user/main.c |   52 ++
4 files changed, 19 insertions(+), 154 deletions(-)

[diff]
*Attached* 


--

Grüsse / regards, 
Christian Ehrhardt


IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen

Registergericht: Amtsgericht Stuttgart, HRB 243294
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 573a9ab..a2dea9b 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -771,44 +771,17 @@ static int handle_mmio(kvm_context_t kvm, struct kvm_run 
*kvm_run)
 {
unsigned long addr = kvm_run->mmio.phys_addr;
void *data = kvm_run->mmio.data;
-   int r = -1;
 
-   /* hack: Red Hat 7.1 generates these wierd accesses. */
-   if (addr == 0xa && kvm_run->mmio.len == 3)
+   /* hack: Red Hat 7.1 generates these weird accesses. */
+   if ((addr > 0xa-4 && addr <= 0xa) && kvm_run->mmio.len == 3)
return 0;
 
-   if (kvm_run->mmio.is_write) {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->writeb(kvm->opaque, addr, *(uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->writew(kvm->opaque, addr, 
*(uint16_t *)data);
-   break;
-   case 4:
-   r = kvm->callbacks->writel(kvm->opaque, addr, 
*(uint32_t *)data);
-   break;
-   case 8:
-   r = kvm->callbacks->writeq(kvm->opaque, addr, 
*(uint64_t *)data);
-   break;
-   }
-   } else {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->readb(kvm->opaque, addr, (uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->readw(kvm->opaque, addr, (uint16_t 
*)data);
-   break;
-   case 4:
-   r = kvm->callbacks->readl(kvm->opaque, addr, (uint32_t 
*)data);
-   break;
-   case 8:
-   r = kvm->callbacks->readq(kvm->opaque, addr, (uint64_t 
*)data);
-   break;
-   }
-   }
-   return r;
+   if (kvm_run->mmio.is_write)
+   return kvm->callbacks->mmio_write(kvm->opaque, addr, data,
+   kvm_run->mmio.len);
+   else
+   return kvm->callbacks->mmio_read(kvm->opaque, addr, data,
+   kvm_run->mmio.len);
 }
 
 int handle_io_window(kvm_context_t kvm)
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index ff260f4..129f260 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -45,22 +45,12 @@ struct kvm_callbacks {
 int (*outw)(void *opaque, uint16_t addr, uint16_t data);
/// For 32bit IO writes from the guest (Usually when executing 'outl')
 int (*outl)(void *opaque, uint16_t addr, uint32_t data);
-   /// For 8bit memory reads from unmapped memory (For MMIO devices)
-int (*readb)(void *opaque, uint64_t addr, uint8_t *data);
-   /// For 16bit memory reads from unmapped memory (For MMIO devices)
-int (*readw)(void *opaque, uint64_t addr, uint16_t *data);
-   /// For 32bit memory reads from unmapped memory (For MMIO devices)
-int (*readl)(void *opaque, uint64_t addr, uint32_t *data);
-   /// For 64bit memory reads from unmapped memory (For MMIO devices)
-int (*readq)(void *opaque, uint64_t addr, uint64_t *data);
-   /// For 8bit memory writes to unmapped memory (For MMIO devices)
-int (*writeb)(void *opaque, uint64_t addr, uint8_t data);
-   /// For 16bit memory writes to unmapped memory (For MMIO devices)
-int (*writew)(void *opaque, uint64_t addr, uint16_t data);
-   /// For 32bit memory writes to unmapped memory (For MMIO devices)
-int (*writel)(void *opaque, uint64_t addr, uint32_t

Re: [kvm-devel] [PATCH] RFC: simplify kvm-userspace to qemu-kvm callback structure

2007-12-11 Thread Christian Ehrhardt
Avi Kivity wrote:
> Christian Ehrhardt wrote:
>> Background:
>> In our ppc code for the demo we only needed a call to 
>> cpu_physical_memory_rw to handle all kind of mmio we needed. Looking 
>> at all the callback pointers for read/write mmio in kvm_callbacks I 
>> wondered if this can be simplified with cpu_physical_memory_rw for x86 
>> too. So I tested it today and it works fine on with kvm-svm on my 
>> opteron.
>> The only code that did not just redirect to another function was a 
>> workaround for a Redhat 7.1 issue, so I merged it in the central call 
>> making it easier to find and maintain (was split before) anyway.
>> If everyone agrees with it I will create a new patch also affecting 
>> the other implementations of this interface e.g. user/main.c and a 
>> rebased version of this one.
>> But maybe there was a reason to do it that split way with all the 
>> callback pointers that was not obvious to me, so please comment.
> 
> It may be worthwhile to unify all the reads into a single read, but read 
> and write are fundamentally different.  The fact that qemu implements it 
> in one function is a detail; libkvm aims to satisfy more than just qemu.
> 

That's fair - I thought too qemu-centric while the interface should be 
generic.
I changed the simplification patch to have separate read/write calls,
but not one per len. That still reduce the different callbacks for mmio
from eight to two pointers.
To have it clean I put the updated patch in a separate mail.

P.S. Sorry for overlooking your response and asking again.

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] [1/1] simplify kvm-userspace to qemu-kvm callback structure

2007-12-07 Thread Christian Ehrhardt

Subject: [PATCH] simplify read[bwlq]/write[bwlq] callback structure

From: Christian Ehrhardt <[EMAIL PROTECTED]>

Merging the read[bwlq]/write[bwlq] callback callback pointers to one 
mmio_rw function simplifies the callback interface (a lot of lines

in libkvm.c and main.c) and eventually uses the qemu copy frontend
function cpu_physical_memory_rw.

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

[diffstat]
libkvm/libkvm.c |   40 
libkvm/libkvm.h |   19 ++---
qemu/qemu-kvm.c |   62 +++-
user/main.c |   52 ++
4 files changed, 19 insertions(+), 154 deletions(-)

[diff]
*Attached*

--

Grüsse / regards, 
Christian Ehrhardt


IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen

Registergericht: Amtsgericht Stuttgart, HRB 243294
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 573a9ab..057706c 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -771,44 +771,14 @@ static int handle_mmio(kvm_context_t kvm, struct kvm_run 
*kvm_run)
 {
unsigned long addr = kvm_run->mmio.phys_addr;
void *data = kvm_run->mmio.data;
-   int r = -1;
 
-   /* hack: Red Hat 7.1 generates these wierd accesses. */
-   if (addr == 0xa && kvm_run->mmio.len == 3)
+   /* hack: Red Hat 7.1 generates these weird accesses. */
+   if ((addr > 0xa-4 && addr <= 0xa) && kvm_run->mmio.len == 3)
return 0;
 
-   if (kvm_run->mmio.is_write) {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->writeb(kvm->opaque, addr, *(uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->writew(kvm->opaque, addr, 
*(uint16_t *)data);
-   break;
-   case 4:
-   r = kvm->callbacks->writel(kvm->opaque, addr, 
*(uint32_t *)data);
-   break;
-   case 8:
-   r = kvm->callbacks->writeq(kvm->opaque, addr, 
*(uint64_t *)data);
-   break;
-   }
-   } else {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->readb(kvm->opaque, addr, (uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->readw(kvm->opaque, addr, (uint16_t 
*)data);
-   break;
-   case 4:
-   r = kvm->callbacks->readl(kvm->opaque, addr, (uint32_t 
*)data);
-   break;
-   case 8:
-   r = kvm->callbacks->readq(kvm->opaque, addr, (uint64_t 
*)data);
-   break;
-   }
-   }
-   return r;
+   return kvm->callbacks->mmio_rw(kvm->opaque, addr, data,
+   kvm_run->mmio.len,
+   kvm_run->mmio.is_write);
 }
 
 int handle_io_window(kvm_context_t kvm)
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index ff260f4..d44a364 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -45,22 +45,9 @@ struct kvm_callbacks {
 int (*outw)(void *opaque, uint16_t addr, uint16_t data);
/// For 32bit IO writes from the guest (Usually when executing 'outl')
 int (*outl)(void *opaque, uint16_t addr, uint32_t data);
-   /// For 8bit memory reads from unmapped memory (For MMIO devices)
-int (*readb)(void *opaque, uint64_t addr, uint8_t *data);
-   /// For 16bit memory reads from unmapped memory (For MMIO devices)
-int (*readw)(void *opaque, uint64_t addr, uint16_t *data);
-   /// For 32bit memory reads from unmapped memory (For MMIO devices)
-int (*readl)(void *opaque, uint64_t addr, uint32_t *data);
-   /// For 64bit memory reads from unmapped memory (For MMIO devices)
-int (*readq)(void *opaque, uint64_t addr, uint64_t *data);
-   /// For 8bit memory writes to unmapped memory (For MMIO devices)
-int (*writeb)(void *opaque, uint64_t addr, uint8_t data);
-   /// For 16bit memory writes to unmapped memory (For MMIO devices)
-int (*writew)(void *opaque, uint64_t addr, uint16_t data);
-   /// For 32bit memory writes to unmapped memory (For MMIO devices)
-int (*writel)(void *opaque, uint64_t addr, uint32_t data);
-   /// For 64bit memory writes to unmapped memory (For MMIO devices)
-int (*writeq)(void *opaque, uint64_t addr, uint64_t data);
+   /// generic memory writes to unmapped memory (Fo

[kvm-devel] [PATCH] [0/1] simplify kvm-userspace to qemu-kvm callback structure

2007-12-07 Thread Christian Ehrhardt
Well no response might mean that there is nothing to be said against this
simplification ;-)
Because of that I completed the patch (main.c as well) and corrected some
whitespace issues I had before.

Christian Ehrhardt wrote:
> Background:
> In our ppc code for the demo we only needed a call to 
> cpu_physical_memory_rw to handle all kind of mmio we needed. Looking at 
> all the callback pointers for read/write mmio in kvm_callbacks I 
> wondered if this can be simplified with cpu_physical_memory_rw for x86 
> too. So I tested it today and it works fine on with kvm-svm on my opteron.
> The only code that did not just redirect to another function was a 
> workaround for a Redhat 7.1 issue, so I merged it in the central call 
> making it easier to find and maintain (was split before) anyway.
> If everyone agrees with it I will create a new patch also affecting the 
> other implementations of this interface e.g. user/main.c and a rebased 
> version of this one.
> But maybe there was a reason to do it that split way with all the 
> callback pointers that was not obvious to me, so please comment.
> [...]

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] RFC: simplify kvm-userspace to qemu-kvm callback structure

2007-12-05 Thread Christian Ehrhardt

Background:
In our ppc code for the demo we only needed a call to cpu_physical_memory_rw to 
handle all kind of mmio we needed. Looking at all the callback pointers for 
read/write mmio in kvm_callbacks I wondered if this can be simplified with 
cpu_physical_memory_rw for x86 too. So I tested it today and it works fine on 
with kvm-svm on my opteron.
The only code that did not just redirect to another function was a workaround 
for a Redhat 7.1 issue, so I merged it in the central call making it easier to 
find and maintain (was split before) anyway.
If everyone agrees with it I will create a new patch also affecting the other 
implementations of this interface e.g. user/main.c and a rebased version of 
this one.
But maybe there was a reason to do it that split way with all the callback 
pointers that was not obvious to me, so please comment.

P.S. up to now I did not find such a single function in qemu to handle the 
normal I/O (non mm), but maybe there is more potential to slimline that 
callback stuff.

---

Subject: [PATCH] simplify kvm-userspace to qemu-kvm callback structure

From: Christian Ehrhardt <[EMAIL PROTECTED]>

Merging the kvm callback elements write[bwlq] and read[bwlq] into a single call
simplifying that interface.
Additionally this patch fixes a small typo and combines two workarounds for the
same issue in code the patch touches anyway.

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

[diffstat]
libkvm/libkvm.c |   40 
libkvm/libkvm.h |   19 ++---
qemu/qemu-kvm.c |   62 +++-
3 files changed, 12 insertions(+), 109 deletions(-)

[diff (also attached)]
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 573a9ab..057706c 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -771,44 +771,14 @@ static int handle_mmio(kvm_context_t kvm, struct kvm_run 
*kvm_run)
{
unsigned long addr = kvm_run->mmio.phys_addr;
void *data = kvm_run->mmio.data;
-   int r = -1;

-   /* hack: Red Hat 7.1 generates these wierd accesses. */
-   if (addr == 0xa && kvm_run->mmio.len == 3)
+   /* hack: Red Hat 7.1 generates these weird accesses. */
+   if ((addr > 0xa-4 && addr <= 0xa) && kvm_run->mmio.len == 3)
return 0;

-   if (kvm_run->mmio.is_write) {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->writeb(kvm->opaque, addr, *(uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->writew(kvm->opaque, addr, 
*(uint16_t *)data);
-   break;
-   case 4:
-   r = kvm->callbacks->writel(kvm->opaque, addr, 
*(uint32_t *)data);
-   break;
-   case 8:
-   r = kvm->callbacks->writeq(kvm->opaque, addr, 
*(uint64_t *)data);
-   break;
-   }
-   } else {
-   switch (kvm_run->mmio.len) {
-   case 1:
-   r = kvm->callbacks->readb(kvm->opaque, addr, (uint8_t 
*)data);
-   break;
-   case 2:
-   r = kvm->callbacks->readw(kvm->opaque, addr, (uint16_t 
*)data);
-   break;
-   case 4:
-   r = kvm->callbacks->readl(kvm->opaque, addr, (uint32_t 
*)data);
-   break;
-   case 8:
-   r = kvm->callbacks->readq(kvm->opaque, addr, (uint64_t 
*)data);
-   break;
-   }
-   }
-   return r;
+   return kvm->callbacks->mmio_rw(kvm->opaque, addr, data,
+   kvm_run->mmio.len,
+   kvm_run->mmio.is_write);
}

int handle_io_window(kvm_context_t kvm)
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index ff260f4..d44a364 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -45,22 +45,9 @@ struct kvm_callbacks {
int (*outw)(void *opaque, uint16_t addr, uint16_t data);
/// For 32bit IO writes from the guest (Usually when executing 'outl')
int (*outl)(void *opaque, uint16_t addr, uint32_t data);
-   /// For 8bit memory reads from unmapped memory (For MMIO devices)
-int (*readb)(void *opaque, uint64_t addr, uint8_t *data);
-   /// For 16bit memory reads from unmapped memory (For MMIO devices)
-int (*readw)(void *opaque, uint64_t addr, uint16_t *data);
-   /// For 32bit memory reads from unmapped memory (For MMIO devices)
-int (*readl)(void *opaque, uint64_t addr, uint32_t *data);
-   /// For 64bit memory reads from unmapped memory (For MMIO devices)
-int (*readq)(void *opaque, uint64_t addr, uint64_t *data

Re: [kvm-devel] [PATCH]0/2 Patches to furthure split kvm_init

2007-11-30 Thread Christian Ehrhardt
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> Avi Kivity wrote:
>>   
>>> Zhang, Xiantao wrote:
>>> 
>>>> Avi Kivity wrote:
>>>>
>>>>   
>>>>> Christian Ehrhardt wrote:
>>>>>
>>>>> 
>>>>>> Hi Xiantao,
>>>>>> it looks good to me to move kvm_vcpu_cache out to the x86 specific
>>>>>> code 
>>>>>>
>>>>>>   
>>>>> Why is that?  Do other archs not want kvm_vcpu_cache, or is it just
>>>>> the alignment? 
>>>>>
>>>>> 
>>>> At lease we didn't fall across the similar requirements about such
>>>> alignment issues in IA64. 
>>>>
>>>>   
>>> What I mean is, other archs do require kvm_vcpu_cache (without the
>>> alignment), so why move the code?  Just make the alignment arch
>>> dependent with a #define.
>>> 
>> I think IA64 TOTALLY doen't need this logic, so do the move:)
>>
>>   
> 
> Ah, I see.  It isn't just the alignment. How do you allocate kvm_vcpu, then?
> 
> 
> What about s390 and powerpc?  I imagine they don't have an alignment
> issue, but do they have a totally unique way of allocating vcpus as well?

On one hand we don't have "these" alignment issues, but on the other hand we 
have some complex offset logic to integrate structures and handler vectors&code 
(which need special alignment).
The major problem is that the our prototype currently only supports one vcpu 
per guest and therefore we didn't think a lot about e.g. kmem_cache for vcpu 
structures.
>From my current point of view we may be able to use a kmem_cache and be able 
>to do all sophisticated ppc stuff in an arch function filling the arch part of 
>vcpu, but that opinion may change when we look further into it while 
>implementing muli-vcpu support per guest.
Because of that I think atm your CONFIG_HAVE_SPECIAL_VCPU_ALLOC suggestion 
would be nice, with that we could do either way later without restructuring the 
generic code too much.

I added Hollis to the direct CC List, because this ppc code is his creation he 
might be able to give us a much clearer insight how ppc vcpu allocation in 
future might look like.

> Maybe we should just #ifndef CONFIG_IA64 (or #ifdef
> CONFIG_HAVE_SPECIAL_VCPU_ALLOC) this bit instead of duplicating it for
> s390 and ppc.
> 


-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] [2/2] merged_move_kvm_vpu_cache_to_x86

2007-11-29 Thread Christian Ehrhardt

Attached your patch 2/2 and my 3/2 merged.
As you said the renaming patch is not essential, but I prefer names as clear as 
possible which would be with renaming patch.
As 4/2 still applies after this merged one we can just let Avi apply whatever 
he likes from this series ;-)

Zhang, Xiantao wrote:

Thanks, sure to move it out. Maybe you can update my second patch
directly for Avi's easy maintenance. 

[...]

---

From: Zhang Xiantao <[EMAIL PROTECTED]>
From: Christian Ehrhardt <[EMAIL PROTECTED]>
Date: Thu, 29 Nov 2007 10:54:00 +0100
Subject: [PATCH] [2/2] merged_move_kvm_vpu_cache_to_x86

Moving kvm_vcpu_cache to x86.c, since only x86 platform will use to 
align the memory area for fx_save. To prevent misuse of these x86 structure 
in generic code the definition moved from kvm.h to x86.h.


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

[diffstat]
kvm.h  |4 ++--
kvm_main.c |   17 +
x86.c  |   19 ++-
x86.h  |1 +
4 files changed, 22 insertions(+), 19 deletions(-)

I'm not yet sure if my mailer now at last keeps the format to apply it later so 
I additionally attach it as file this time.
[diff]
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index be18620..6ff189f 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -112,7 +112,6 @@ struct kvm_mmu_page {
};

struct kvm_vcpu;
-extern struct kmem_cache *kvm_vcpu_cache;

/*
 * x86 supports 3 paging modes (4-level 64-bit, 3-level 64-bit, and 2-level
@@ -456,7 +455,8 @@ int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
struct kvm_debug_guest *dbg);
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);

-int kvm_arch_init(void *opaque);
+int kvm_arch_init(void *opaque, unsigned int vcpu_size,
+   struct module * module);
void kvm_arch_exit(void);

int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a6fbe6b..687ef98 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -56,9 +56,6 @@ LIST_HEAD(vm_list);

static cpumask_t cpus_hardware_enabled;

-struct kmem_cache *kvm_vcpu_cache;
-EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
-
static __read_mostly struct preempt_ops kvm_preempt_ops;

static struct dentry *debugfs_dir;
@@ -1338,7 +1335,7 @@ int kvm_init(void *opaque, unsigned int vcpu_size,

kvm_init_debug();

-   r = kvm_arch_init(opaque);
+   r = kvm_arch_init(opaque, vcpu_size, module);
if (r)
goto out_fail;

@@ -1375,15 +1372,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
if (r)
goto out_free_4;

-   /* A kmem cache lets us meet the alignment requirements of fx_save. */
-   kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
-  __alignof__(struct kvm_vcpu),
-  0, NULL);
-   if (!kvm_vcpu_cache) {
-   r = -ENOMEM;
-   goto out_free_5;
-   }
-
kvm_chardev_ops.owner = module;

r = misc_register(&kvm_dev);
@@ -1398,8 +1386,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
return 0;

out_free:
-   kmem_cache_destroy(kvm_vcpu_cache);
-out_free_5:
sysdev_unregister(&kvm_sysdev);
out_free_4:
sysdev_class_unregister(&kvm_sysdev_class);
@@ -1423,7 +1409,6 @@ EXPORT_SYMBOL_GPL(kvm_init);
void kvm_exit(void)
{
misc_deregister(&kvm_dev);
-   kmem_cache_destroy(kvm_vcpu_cache);
sysdev_unregister(&kvm_sysdev);
sysdev_class_unregister(&kvm_sysdev_class);
unregister_reboot_notifier(&kvm_reboot_notifier);
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index c70ac33..b8a1b52 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -48,6 +48,10 @@

struct kvm_x86_ops *kvm_x86_ops;

+struct kmem_cache *kvm_vcpu_cache;
+EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+
+
struct kvm_stats_debugfs_item debugfs_entries[] = {
{ "pf_fixed", VCPU_STAT(pf_fixed) },
{ "pf_guest", VCPU_STAT(pf_guest) },
@@ -1997,7 +2001,8 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct 
kvm_run *run, int in,
}
EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);

-int kvm_arch_init(void *opaque)
+int kvm_arch_init(void *opaque, unsigned int vcpu_size,
+   struct module *module)
{
int r;
struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
@@ -2006,6 +2011,15 @@ int kvm_arch_init(void *opaque)
if (r)
goto out_fail;

+   /* A kmem cache lets us meet the alignment requirements of fx_save. */
+   kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
+  __alignof__(struct kvm_vcpu),
+  0, NULL);
+   if (!kvm_vcpu_cache) {
+   

[kvm-devel] [PATCH] [4/2] rename_kvm_cpu_cache_x86

2007-11-29 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>
Date: Thu, 29 Nov 2007 10:54:00 +0100
Subject: [PATCH] [4/2] rename_kvm_cpu_cache_x86

Renamed the kvm_vcpu_cache structure to kvm_x86_vcpu_cache to make clear to 
anyone who see's that variable in the code in future that it's x86 only.
Equivalent to perl -p -i -e "s/kvm_vcpu_cache/kvm_x86_vcpu_cache/g" 
drivers/kvm/*

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

[diffstat]
 svm.c |6 +++---
 vmx.c |6 +++---
 x86.c |   12 ++--
 x86.h |2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

[diff]
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 928fb35..d12ff34 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -578,7 +578,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, 
unsigned int id)
struct page *page;
int err;
 
-   svm = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
+   svm = kmem_cache_zalloc(kvm_x86_vcpu_cache, GFP_KERNEL);
if (!svm) {
err = -ENOMEM;
goto out;
@@ -612,7 +612,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, 
unsigned int id)
 uninit:
kvm_vcpu_uninit(&svm->vcpu);
 free_svm:
-   kmem_cache_free(kvm_vcpu_cache, svm);
+   kmem_cache_free(kvm_x86_vcpu_cache, svm);
 out:
return ERR_PTR(err);
 }
@@ -623,7 +623,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu)
 
__free_page(pfn_to_page(svm->vmcb_pa >> PAGE_SHIFT));
kvm_vcpu_uninit(vcpu);
-   kmem_cache_free(kvm_vcpu_cache, svm);
+   kmem_cache_free(kvm_x86_vcpu_cache, svm);
 }
 
 static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 8e43feb..5c61cc2 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -2519,13 +2519,13 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
kfree(vmx->host_msrs);
kfree(vmx->guest_msrs);
kvm_vcpu_uninit(vcpu);
-   kmem_cache_free(kvm_vcpu_cache, vmx);
+   kmem_cache_free(kvm_x86_vcpu_cache, vmx);
 }
 
 static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 {
int err;
-   struct vcpu_vmx *vmx = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
+   struct vcpu_vmx *vmx = kmem_cache_zalloc(kvm_x86_vcpu_cache, 
GFP_KERNEL);
int cpu;
 
if (!vmx)
@@ -2570,7 +2570,7 @@ free_guest_msrs:
 uninit_vcpu:
kvm_vcpu_uninit(&vmx->vcpu);
 free_vcpu:
-   kmem_cache_free(kvm_vcpu_cache, vmx);
+   kmem_cache_free(kvm_x86_vcpu_cache, vmx);
return ERR_PTR(err);
 }
 
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index b8a1b52..47de514 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -48,8 +48,8 @@
 
 struct kvm_x86_ops *kvm_x86_ops;
 
-struct kmem_cache *kvm_vcpu_cache;
-EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+struct kmem_cache *kvm_x86_vcpu_cache;
+EXPORT_SYMBOL_GPL(kvm_x86_vcpu_cache);
 
 
 struct kvm_stats_debugfs_item debugfs_entries[] = {
@@ -2012,10 +2012,10 @@ int kvm_arch_init(void *opaque, unsigned int vcpu_size,
goto out_fail;
 
/* A kmem cache lets us meet the alignment requirements of fx_save. */
-   kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
+   kvm_x86_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size,
   __alignof__(struct kvm_vcpu),
   0, NULL);
-   if (!kvm_vcpu_cache) {
+   if (!kvm_x86_vcpu_cache) {
r = -ENOMEM;
goto out_free;
}
@@ -2044,7 +2044,7 @@ int kvm_arch_init(void *opaque, unsigned int vcpu_size,
return 0;
 
 out:
-   kmem_cache_destroy(kvm_vcpu_cache);
+   kmem_cache_destroy(kvm_x86_vcpu_cache);
 out_free:
kvm_mmu_module_exit();
 out_fail:
@@ -2055,7 +2055,7 @@ void kvm_arch_exit(void)
 {
kvm_x86_ops = NULL;
kvm_mmu_module_exit();
-   kmem_cache_destroy(kvm_vcpu_cache);
+   kmem_cache_destroy(kvm_x86_vcpu_cache);
 }
 
 int kvm_emulate_halt(struct kvm_vcpu *vcpu)
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 2080a65..da73280 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -224,7 +224,7 @@ struct kvm_x86_ops {
 };
 
 extern struct kvm_x86_ops *kvm_x86_ops;
-extern struct kmem_cache *kvm_vcpu_cache;
+extern struct kmem_cache *kvm_x86_vcpu_cache;
 
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);


-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by: The Future of Linux

[kvm-devel] [PATCH] [3/2] move_kvm_cpu_cache_to_x86_header

2007-11-29 Thread Christian Ehrhardt
From: Christian Ehrhardt <[EMAIL PROTECTED]>
Date: Thu, 29 Nov 2007 10:54:00 +0100
Subject: [PATCH] [3/2] move_kvm_cpu_cache_to_x86_header

To prevent misuse of these x86 structure in generic code the definition moved 
from kvm.h to x86.h.

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

[diffstat]
 kvm.h |1 -
 x86.h |1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

[diff]
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index b2545c8..6ff189f 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -112,7 +112,6 @@ struct kvm_mmu_page {
 };
 
 struct kvm_vcpu;
-extern struct kmem_cache *kvm_vcpu_cache;
 
 /*
  * x86 supports 3 paging modes (4-level 64-bit, 3-level 64-bit, and 2-level
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 78ab1e1..2080a65 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -224,6 +224,7 @@ struct kvm_x86_ops {
 };
 
 extern struct kvm_x86_ops *kvm_x86_ops;
+extern struct kmem_cache *kvm_vcpu_cache;
 
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);


-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH]0/2 Patches to furthure split kvm_init

2007-11-29 Thread Christian Ehrhardt
Hi Xiantao,
it looks good to me to move kvm_vcpu_cache out to the x86 specific code, but I 
wanted to suggest to go a bit further.
After your patch the structure kvm_vcpu_cache is only in x86/svm/vmx.c so we 
could prevent mistakes in two ways.
I send two extension patches which will fit on top of your 2 patch queue as 
suggestion and therefore call them 3/2 and 4/2.

[3/2] move_kvm_cpu_cache_to_x86_header
To prevent misuse of these x86 structure in generic code the definition moved 
from kvm.h to x86.h.

[4/2] rename_kvm_cpu_cache_x86
Renamed the kvm_vcpu_cache structure to kvm_x86_vcpu_cache to make clear to 
anyone who see's that variable in the code in future that it's x86 only.

Zhang, Xiantao wrote:
> [1/2] Fix missing bad_page free logic for possbile failures of kvm_init.
> [2/2] Moving kvm_vcpu_cache to x86.c, since it belongs to x86-specific
> part.
> 
> Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]>
> 
> -
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell.  From the desktop to the data center, Linux is going
> mainstream.  Let it simplify your IT future.
> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> ___
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel


-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] RFC/patch portability: split kvm_vm_ioctl

2007-10-15 Thread Christian Ehrhardt
Carsten Otte wrote:
> 
> Avi Kivity wrote:
>> We need to distinguish between x86 specific (only x86 has this) and s390
>> special (everyone has it except s390). In the latter case it should
>> still be in common code to avoid duplication, with a guard to disable
>> compilation on s390.
>>
>> KVM_SET_MEMORY_REGION is in theory applicable to non-s390 but I'd like
>> to deprecate it, so there's no point in implementing it on non-x86. The
>> rest are s390 special rather than x86 specific.
>>
>> As related previously, KVM_SET_USER_MEMORY_REGION should work for s390
>> (with an extra check for the guest phsyical start address).
> I thought about that all through the weekend. To me, it looks like I 
> want to eliminate "s390 special" as far as possible. In given case, 
> I'll follow Anthonys suggestion and support 
> KVM_SET_USER_MEMORY_REGION. KVM_SET_MEMORY_REGION will also go common, 
> and in case we're pushing the actual port before you deprecate that 
> call, we'll #ifdef CONFIG_ARCH_S390 around it.
> 
> As for the pic/apic part, I think it is x86 specific. Christian 
> Ehrhardt stated he believes ppc won't have that too.

At least not in that manner x86 has it atm (which would be  enough for
splitting it per arch), since I'm unsure in that topic I set Hollis on cc
who should know it better with his larger power experience.

> 
> Will create another patch on vm_ioctl that reflects this later today.
> 
> so long,
> Carsten
> 
> -
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> ___
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel


-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [Patch][RFC]Split kvm_vcpu to support new archs.

2007-10-12 Thread Christian Ehrhardt
Zhang, Xiantao wrote:
> --- /dev/null
> +++ b/drivers/kvm/kvm_arch.h
[...]
> +struct kvm_arch_vcpu{
> + 
> + u64 host_tsc;
> + 
> + unsigned long regs[NR_VCPU_REGS]; /* for rsp:
> vcpu_load_rsp_rip() */
> + unsigned long rip;  /* needs vcpu_load_rsp_rip() */
> +
> + unsigned long cr0;
> + unsigned long cr2;
> + unsigned long cr3;
> + unsigned long cr4;
> + unsigned long cr8;
> + u64 pdptrs[4]; /* pae */
> + u64 shadow_efer;
> + u64 apic_base;
> + struct kvm_lapic *apic;/* kernel irqchip context */
> +
> + u64 ia32_misc_enable_msr;
> +
> + 
> + struct i387_fxsave_struct host_fx_image;
> + struct i387_fxsave_struct guest_fx_image;
> + int fpu_active;
> + int guest_fpu_loaded;
> +
> + gva_t mmio_fault_cr2;
> + 
> + struct {
> + int active;
> + u8 save_iopl;
> + struct kvm_save_segment {
> + u16 selector;
> + unsigned long base;
> + u32 limit;
> + u32 ar;
> + } tr, es, ds, fs, gs;
> + } rmode;
[...]

As far as I can see without applying it, that split is ok for powerpc. I had a 
similar approach in my local patch queue too.
Minor differences in which elements of the structs are arch dependent or not 
can be changed in small patches later ;-)

But the file kvm_arch.h name confuses me a bit - I assume you had the coming 
asm split in mind where every architecture can define it's asm/kvm_arch.h.
Since we don't have that asm structure for kvm yet, the changes you made to 
kvm_arch.h may be better located at the x86.h atm.

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] RFC/patch: a very trivial patch towards portability V3

2007-10-11 Thread Christian Ehrhardt
To give a statement from other architectures I wanted to say that this patch is 
fine for the power port.
>From my view it is the small and easy-to-review flavor of the big patch series 
>I once sent to the list.
And because Carsten and I sit in the same office these patches are usually 
reviewed/discussed from the power perspective before they are submitted.
Applying these patches now (I expect that Carsten will submit more) will reduce 
the size of the patches that we eventually need integrate our architecture.

Grüsse / regards,
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

Carsten Otte wrote:
> Thanks to Avi's continued review, we've got even more common code this
> time: KVM_CHECK_EXTENSION ioctl is now completely handled in kvm_main.c
> instead of having arch callbacks to check extensions. The architectures
> are expected to setup a bit mask named KVM_ARCH_EXTENSIONS with
> information about capabilities they support. Possible valus for the bit
> masks are defined in drivers/kvm/kvm.h (KVM_ARCH_HAS_*), which rely on
> KVM_CAP_* definitions in include/linux/kvm.h.
> Function prototypes in drivers/kvm/kvm.h have been fixed: they have
> argument names now.
> 
> signed-off-by: Carsten Otte <[EMAIL PROTECTED]>
> ---
> Index: kvm/drivers/kvm/kvm.h
> ===
> --- kvm.orig/drivers/kvm/kvm.h2007-10-10 12:42:21.0 +0200
> +++ kvm/drivers/kvm/kvm.h 2007-10-10 17:00:12.0 +0200
> @@ -64,6 +64,12 @@
> 
>  #define KVM_PIO_PAGE_OFFSET 1
> 
> +#define KVM_ARCH_HAS_IRQCHIP  (1ull << KVM_CAP_IRQCHIP)
> +#define KVM_ARCH_HAS_HLT   (1ull << KVM_CAP_HLT)
> +#define KVM_ARCH_HAS_MMU_SHADOW_CACHE_CONTROL \ 
> +(1ull << KVM_CAP_MMU_SHADOW_CACHE_CONTROL)
> +#define KVM_ARCH_HAS_USER_MEMORY  (1ull << KVM_CAP_USER_MEMORY)
> +
>  /*
>   * vcpu->requests bit members
>   */
> @@ -653,6 +659,10 @@
> 
>  int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
> 
> +long kvm_arch_dev_ioctl(struct file *filp,
> + unsigned int ioctl, unsigned long arg);
> +__init void kvm_arch_init(void);
> +
>  static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
>u32 error_code)
>  {
> Index: kvm/drivers/kvm/Makefile
> ===
> --- kvm.orig/drivers/kvm/Makefile 2007-10-10 11:35:01.0 +0200
> +++ kvm/drivers/kvm/Makefile  2007-10-10 14:36:36.0 +0200
> @@ -2,7 +2,7 @@
>  # Makefile for Kernel-based Virtual Machine module
>  #
> 
> -kvm-objs := kvm_main.o mmu.o x86_emulate.o i8259.o irq.o lapic.o ioapic.o
> +kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o 
> ioapic.o
>  obj-$(CONFIG_KVM) += kvm.o
>  kvm-intel-objs = vmx.o
>  obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
> Index: kvm/drivers/kvm/kvm_main.c
> ===
> --- kvm.orig/drivers/kvm/kvm_main.c   2007-10-10 11:34:07.0 +0200
> +++ kvm/drivers/kvm/kvm_main.c2007-10-10 16:57:05.0 +0200
> @@ -16,6 +16,7 @@
>   */
> 
>  #include "kvm.h"
> +#include "x86.h"
>  #include "x86_emulate.h"
>  #include "segment_descriptor.h"
>  #include "irq.h"
> @@ -45,7 +46,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
> 
>  MODULE_AUTHOR("Qumranet");
> @@ -2518,43 +2518,6 @@
>  EXPORT_SYMBOL_GPL(kvm_get_cs_db_l_bits);
> 
>  /*
> - * List of msr numbers which we expose to userspace through KVM_GET_MSRS
> - * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST.
> - *
> - * This list is modified at module load time to reflect the
> - * capabilities of the host cpu.
> - */
> -static u32 msrs_to_save[] = {
> - MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
> - MSR_K6_STAR,
> -#ifdef CONFIG_X86_64
> - MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR,
> -#endif
> - MSR_IA32_TIME_STAMP_COUNTER,
> -};
> -
> -static unsigned num_msrs_to_save;
> -
> -static u32 emulated_msrs[] = {
> - MSR_IA32_MISC_ENABLE,
> -};
> -
> -static __init void kvm_init_msr_list(void)
> -{
> - u32 dummy[2];
> - unsigned i, j;
> -
> - for (i = j = 0; i < ARRAY_SIZE(msrs_to_save); i++) {
>

Re: [kvm-devel] [PATCH 1/5] Enable top level configure script for cross compile

2007-10-08 Thread Christian Ehrhardt
Hi,
I saw that you derive $target_cpu from arch as I know it from your older 
internal and external patches.
Now you added the configure command line option --target-cpu to allow to 
overwrite that $arch derived target.
a) do you have some use cases in mind where you need an overwritten target 
instead the one derived from $arch ?
b) if it is needed, please add a small description to the usage() output

Kind regards, 
Christian Ehrhardt

Jerone Young wrote:
> This patch adds cross compile capability to the top level configure
> script.
> 
> Signed-off-by: Jerone Young <[EMAIL PROTECTED]>
> 
> 
> 
> 
> diff -r f48e521e0add configure
> --- a/configure   Wed Oct 03 21:00:03 2007 -0500
> +++ b/configure   Thu Oct 04 14:59:16 2007 -0500
> @@ -5,13 +5,17 @@ want_module=1
>  want_module=1
>  qemu_cc=$(ls /usr/bin/gcc3* /usr/bin/gcc-3* 2>/dev/null | tail -n1)
>  disable_gcc_check=
> +cross_prefix=
> +arch=`uname -m`
> +target_cpu=
> 
>  usage() {
>  cat <<-EOF
>   Usage: $0 [options]
> 
>   Options include:
> -
> + --arch=ARCHarchitecture to compile for ($arch)
> + --cross-prefix=PREFIX  prefix for cross compiler
>   --prefix=PREFIXwhere to install things ($prefix)
>   --with-patched-kernel  don't use external module
>   --kerneldir=DIRkernel build directory ($kerneldir)
> @@ -53,6 +57,15 @@ while [[ "$1" = -* ]]; do
>   --disable-gcc-check)
>   disable_gcc_check=1
>   ;;
> + --arch)
> + arch="$arg"
> + ;;
> + --cross-prefix)
> + cross_prefix="$arg"
> +;;
> + --target-cpu)
> + target_cpu="$arg"
> + ;; 
>   --help)
>   usage
>   ;;
> @@ -62,7 +75,7 @@ while [[ "$1" = -* ]]; do
>  esac
>  done
> 
> -if [[ -z "$qemu_cc" ]]; then
> +if [[ -z "$qemu_cc" ]] && [[ -z "$cross_prefix" ]]; then
>  echo "$0: cannot locate gcc 3.x. please install it or specify with 
> --qemu-cc"
>  exit 1
>  fi
> @@ -72,29 +85,48 @@ if (( want_module )); then
>  libkvm_kerneldir=$(readlink -f kernel)
>  fi
> 
> -target_cpu() {
> -if [[ $(uname -m) = i?86 ]]; then
> - echo x86_64
> -else
> - uname -m
> +#if arch is an x86 arch set to i386
> +if [[ $arch = i?86 ]]; then
> +  arch="i386"
> +fi
> +
> +#see if using a cross compiler or not
> +compiler=
> +qemu_opts=
> +user_opts=
> +if [[ -z $cross_prefix ]]; then
> +qemu_opts+=" --cc=$qemu_cc"
> +user_opts+=" --cc=$qemu_cc"
> +else
> +qemu_opts+=" --cross-prefix=$cross_prefix"
> +user_opts+=" --cross-prefix=$cross_prefix"
> +fi
> +
> +#set parameters compiling
> +if [ "$arch" = "i386" -o "$arch" = "x86_64" ]; then
> +if [[ -z $target_cpu ]]; then
> +target_cpu="x86_64"
>  fi
> -}
> +qemu_opts+=" --enable-alsa"
> +fi
> 
> -(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir")
> -(cd qemu; ./configure --target-list=$(target_cpu)-softmmu --cc="$qemu_cc" \
> +#configure user dir
> +(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
> +  $user_opts --arch="$arch")
> +(cd qemu; ./configure --target-list=$target_cpu-softmmu \
>  --disable-kqemu --extra-cflags="-I $PWD/../user" \
>  --extra-ldflags="-L $PWD/../user" \
>  --enable-kvm --kernel-path="$libkvm_kerneldir" \
> ---enable-alsa \
>  ${disable_gcc_check:+"--disable-gcc-check"} \
> ---prefix="$prefix"
> +--prefix="$prefix" \
> +$qemu_opts --cpu="$arch"
>  )
> 
> 
> -
>  cat < config.mak
> +ARCH=$arch
>  PREFIX=$prefix
>  KERNELDIR=$kerneldir
>  WANT_MODULE=$want_module
> +CC=$cross_prefix$qemu_cc
>  EOF
> -
> 
> 
> 
> 
> -
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> 
> 
> 
> 

[kvm-devel] Any plans to rebase kvm to current qemu at the moment ?

2007-09-30 Thread Christian Ehrhardt
Hi,
while working on the embedded powerpc port for kvm we have a lot of 
dependencies on current qemu 0.9.0 code for ppc support. Internally we 
currently run with a modified qemu, but eventually strive for integration with 
kvm-userspace. Therefor I wanted to ask if there are already detailed plans (if 
any) regarding the re-base of kvm-userspace to the new qemu source?

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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


Re: [kvm-devel] how to get it as module ?

2007-09-02 Thread Christian Ehrhardt
Hollis Blanchard wrote:
> On Thu, 2007-08-30 at 13:25 +0200, Christian Ehrhardt wrote:
>   
>> Hi Hollis,
>> I saw (and somehow I remembered something similar) that you build in 
>> your code instead into a module. I assume that this has some 
>> dependencies to your offset magic.
>> As far as I played around with it I was not able to get it build as 
>> module in any way (the exceptions_44.s stuff) - please feel free to 
>> enlighten me or let yourself time and talk with me about it e.g. on Monday.
>> 
>
> I don't really care about building it as a loadable module at this
> point. I don't see why it wouldn't work though, so if you're having a
> problem you'll need to elaborate a little. What is the build error?
>   
You are right it's no hasty issue at the moment - but maybe we should 
disable the option to build as module until it's ready.
The build error when enabling module in config - Its the build process 
of exceptions_44x.S - may only need some Makefile changes:

make[2]: *** No rule to make target `drivers/kvm/exceptions_44x.c', 
needed by `drivers/kvm/exceptions_44x.o'.  Stop.
make[1]: *** [drivers/kvm] Error 2
make: *** [drivers] Error 2

I'll elaborate it in detail once I need it ;-)

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 2/5] Architecture independence layer - v1 - basic mechanism

2007-08-24 Thread Christian Ehrhardt
Laurent Vivier wrote:
> Christian Ehrhardt wrote:
>   
>> +config KVM_POWERPC_440
>> +tristate "KVM for embedded PowerPC 440 cores"
>> +depends on KVM && POWERPC
>> +---help---
>> +  Provides support for KVM on embedded PowerPC 440 cores
>> +
>> +config KVM_POWERPC_E500
>> +tristate "KVM for embedded PowerPC e500 cores"
>> +depends on KVM && POWERPC
>> +---help---
>> +  Provides support for KVM on embedded PowerPC e500 cores
>> 
>
> An off-the-topic question: is your implementation will be compatible with the
> PowerPC 7447A I have in my iBook G4 ?
>
> Laurent
>   
ATM no, this processor core is not in scope of our current work.

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 1/5] Architecture independence layer - v1 - x86 renaming

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

This patch just renames the current _arch namings to _x86 to ensure 
better readability when a real arch layer takes place

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---
 kvm.h |8 +-
 kvm_main.c|  156 
+-
 mmu.c |6 +-
 paging_tmpl.h |2
 svm.c |6 +-
 vmx.c |6 +-
 x86_emulate.c |4 -
 7 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 70231f3..a3dcc96 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -415,7 +415,7 @@ struct descriptor_table {
 unsigned long base;
 } __attribute__((packed));
 
-struct kvm_arch_ops {
+struct kvm_x86_ops {
 int (*cpu_has_kvm_support)(void);  /* __init */
 int (*disabled_by_bios)(void); /* __init */
 void (*hardware_enable)(void *dummy);  /* __init */
@@ -472,7 +472,7 @@ struct kvm_arch_ops {
 unsigned char *hypercall_addr);
 };
 
-extern struct kvm_arch_ops *kvm_arch_ops;
+extern struct kvm_x86_ops *kvm_x86_ops;
 
 /* The guest did something we don't support. */
 #define pr_unimpl(vcpu, fmt, ...)\
@@ -488,9 +488,9 @@ extern struct kvm_arch_ops *kvm_arch_ops;
 int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
 void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
 
-int kvm_init_arch(struct kvm_arch_ops *ops, unsigned int vcpu_size,
+int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
   struct module *module);
-void kvm_exit_arch(void);
+void kvm_exit_x86(void);
 
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f7ff231..64c2cc4 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -52,7 +52,7 @@ static LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kvm_arch_ops *kvm_arch_ops;
+struct kvm_x86_ops *kvm_x86_ops;
 struct kmem_cache *kvm_vcpu_cache;
 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
 
@@ -180,14 +180,14 @@ static void vcpu_load(struct kvm_vcpu *vcpu)
 mutex_lock(&vcpu->mutex);
 cpu = get_cpu();
 preempt_notifier_register(&vcpu->preempt_notifier);
-kvm_arch_ops->vcpu_load(vcpu, cpu);
+kvm_x86_ops->vcpu_load(vcpu, cpu);
 put_cpu();
 }
 
 static void vcpu_put(struct kvm_vcpu *vcpu)
 {
 preempt_disable();
-kvm_arch_ops->vcpu_put(vcpu);
+kvm_x86_ops->vcpu_put(vcpu);
 preempt_notifier_unregister(&vcpu->preempt_notifier);
 preempt_enable();
 mutex_unlock(&vcpu->mutex);
@@ -364,7 +364,7 @@ static void kvm_free_vcpus(struct kvm *kvm)
 kvm_unload_vcpu_mmu(kvm->vcpus[i]);
 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
 if (kvm->vcpus[i]) {
-kvm_arch_ops->vcpu_free(kvm->vcpus[i]);
+kvm_x86_ops->vcpu_free(kvm->vcpus[i]);
 kvm->vcpus[i] = NULL;
 }
 }
@@ -393,7 +393,7 @@ static int kvm_vm_release(struct inode *inode, 
struct file *filp)
 
 static void inject_gp(struct kvm_vcpu *vcpu)
 {
-kvm_arch_ops->inject_gp(vcpu, 0);
+kvm_x86_ops->inject_gp(vcpu, 0);
 }
 
 /*
@@ -468,7 +468,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 inject_gp(vcpu);
 return;
 }
-kvm_arch_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
+kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
 if (cs_l) {
 printk(KERN_DEBUG "set_cr0: #GP, start paging "
"in long mode while CS.L == 1\n");
@@ -487,7 +487,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 
 }
 
-kvm_arch_ops->set_cr0(vcpu, cr0);
+kvm_x86_ops->set_cr0(vcpu, cr0);
 vcpu->cr0 = cr0;
 
 mutex_lock(&vcpu->kvm->lock);
@@ -530,7 +530,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
 inject_gp(vcpu);
 return;
 }
-kvm_arch_ops->set_cr4(vcpu, cr4);
+kvm_x86_ops->set_cr4(vcpu, cr4);
 mutex_lock(&vcpu->kvm->lock);
 kvm_mmu_reset_context(vcpu);
 mutex_unlock(&vcpu->kvm->lock);
@@ -1048,7 +1048,7 @@ static int 
emulator_write_emulated_onepage(unsigned long addr,
 gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr);
 
 if (gpa == UNMAPPED_GVA) {
-kvm_arch_ops->inject_page_fault(vcpu, addr, 2);
+kvm_x86_ops->inject_page_fault(vcpu, addr, 2);
 return X86EMUL_PROPAGATE_FAULT;
 }
 
@@ -,7 +,7 @@ static int emulator_cmpxchg_emulated(unsigned long 
addr,
 
 static unsigned long get_segment_base(struct kvm_vcpu *vcpu, int seg)
 {
-return kvm_arch_ops->get_segment_base(vcpu, seg);
+return kvm_x86_ops->get_segment_base(vcpu, seg);
 }
 
 int emulate_invlpg(struct kvm_vcpu

[kvm-devel] [PATCH 4/5] Architecture independence layer - v1 - split_generic_x86_x86.c

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

Contains the insertion of the x86 arch code to x86.[ch] and some minor 
changes adopting this x86.c arch implementations to the new interface.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---
 x86.c | 1851 
++
 x86.h |   63 ++
 2 files changed, 1914 insertions(+)

diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 5c72fee..8660414 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -49,3 +49,1854 @@
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
 
+struct kvm_x86_ops *kvm_x86_ops;
+struct kmem_cache *kvm_vcpu_cache;
+EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+
+#define MAX_IO_MSRS 256
+
+#define CR0_RESERVED_BITS\
+(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
+  | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
+  | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
+#define CR4_RESERVED_BITS\
+(~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
+  | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE\
+  | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR\
+  | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
+
+#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
+#define EFER_RESERVED_BITS 0xf2fe
+
+#ifdef CONFIG_X86_64
+// LDT or TSS descriptor in the GDT. 16 bytes.
+struct segment_descriptor_64 {
+struct segment_descriptor s;
+u32 base_higher;
+u32 pad_zero;
+};
+
+#endif
+
+unsigned long segment_base(u16 selector)
+{
+struct descriptor_table gdt;
+struct segment_descriptor *d;
+unsigned long table_base;
+typedef unsigned long ul;
+unsigned long v;
+
+if (selector == 0)
+return 0;
+
+asm ("sgdt %0" : "=m"(gdt));
+table_base = gdt.base;
+
+if (selector & 4) {   /* from ldt */
+u16 ldt_selector;
+
+asm ("sldt %0" : "=g"(ldt_selector));
+table_base = segment_base(ldt_selector);
+}
+d = (struct segment_descriptor *)(table_base + (selector & ~7));
+v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24);
+#ifdef CONFIG_X86_64
+if (d->system == 0
+&& (d->type == 2 || d->type == 9 || d->type == 11))
+v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32;
+#endif
+return v;
+}
+EXPORT_SYMBOL_GPL(segment_base);
+
+void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
+{
+if (!vcpu->fpu_active || vcpu->guest_fpu_loaded)
+return;
+
+vcpu->guest_fpu_loaded = 1;
+fx_save(&vcpu->host_fx_image);
+fx_restore(&vcpu->guest_fx_image);
+}
+EXPORT_SYMBOL_GPL(kvm_load_guest_fpu);
+
+void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
+{
+if (!vcpu->guest_fpu_loaded)
+return;
+
+vcpu->guest_fpu_loaded = 0;
+fx_save(&vcpu->guest_fx_image);
+fx_restore(&vcpu->host_fx_image);
+}
+EXPORT_SYMBOL_GPL(kvm_put_guest_fpu);
+
+static void ack_flush(void *_completed)
+{
+atomic_t *completed = _completed;
+
+atomic_inc(completed);
+}
+
+void kvm_flush_remote_tlbs(struct kvm *kvm)
+{
+int i, cpu, needed;
+cpumask_t cpus;
+struct kvm_vcpu *vcpu;
+atomic_t completed;
+
+atomic_set(&completed, 0);
+cpus_clear(cpus);
+needed = 0;
+for (i = 0; i < KVM_MAX_VCPUS; ++i) {
+vcpu = kvm->vcpus[i];
+if (!vcpu)
+continue;
+if (test_and_set_bit(KVM_TLB_FLUSH, &vcpu->requests))
+continue;
+cpu = vcpu->cpu;
+if (cpu != -1 && cpu != raw_smp_processor_id())
+if (!cpu_isset(cpu, cpus)) {
+cpu_set(cpu, cpus);
+++needed;
+}
+}
+
+/*
+ * We really want smp_call_function_mask() here.  But that's not
+ * available, so ipi all cpus in parallel and wait for them
+ * to complete.
+ */
+for (cpu = first_cpu(cpus); cpu != NR_CPUS; cpu = next_cpu(cpu, cpus))
+smp_call_function_single(cpu, ack_flush, &completed, 1, 0);
+while (atomic_read(&completed) != needed) {
+cpu_relax();
+barrier();
+}
+}
+
+int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id)
+{
+struct page *page;
+int r;
+
+mutex_init(&vcpu->mutex);
+vcpu->cpu = -1;
+vcpu->mmu.root_hpa = INVALID_PAGE;
+vcpu->kvm = kvm;
+vcpu->vcpu_id = id;
+
+page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+if (!page) {
+r = -ENOMEM;
+goto fail;
+}
+vcpu->run = page_address(page);
+
+page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+if (!page) {
+r = -ENOMEM;
+goto fail_free_run;
+}
+vcpu->pio_data = page_address(page);
+
+r = kvm_mmu_cr

[kvm-devel] [PATCH 3/5] Architecture independence layer - v1 - split_generic_x86_move

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

This contains the deletions of x86 arch specific code done in kvm_main.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---
 kvm.h |   63 --
 kvm_main.c| 1431 
--
 mmu.c |2
 svm.c |1
 vmx.c |2
 x86_emulate.c |2
 6 files changed, 12 insertions(+), 1489 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a3dcc96..ff07e64 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -415,65 +415,6 @@ struct descriptor_table {
 unsigned long base;
 } __attribute__((packed));
 
-struct kvm_x86_ops {
-int (*cpu_has_kvm_support)(void);  /* __init */
-int (*disabled_by_bios)(void); /* __init */
-void (*hardware_enable)(void *dummy);  /* __init */
-void (*hardware_disable)(void *dummy);
-void (*check_processor_compatibility)(void *rtn);
-int (*hardware_setup)(void);   /* __init */
-void (*hardware_unsetup)(void);/* __exit */
-
-/* Create, but do not attach this VCPU */
-struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
-void (*vcpu_free)(struct kvm_vcpu *vcpu);
-
-void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu);
-void (*vcpu_put)(struct kvm_vcpu *vcpu);
-void (*vcpu_decache)(struct kvm_vcpu *vcpu);
-
-int (*set_guest_debug)(struct kvm_vcpu *vcpu,
-   struct kvm_debug_guest *dbg);
-int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata);
-int (*set_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
-u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg);
-void (*get_segment)(struct kvm_vcpu *vcpu,
-struct kvm_segment *var, int seg);
-void (*set_segment)(struct kvm_vcpu *vcpu,
-struct kvm_segment *var, int seg);
-void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
-void (*decache_cr4_guest_bits)(struct kvm_vcpu *vcpu);
-void (*set_cr0)(struct kvm_vcpu *vcpu, unsigned long cr0);
-void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
-void (*set_cr4)(struct kvm_vcpu *vcpu, unsigned long cr4);
-void (*set_efer)(struct kvm_vcpu *vcpu, u64 efer);
-void (*get_idt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-void (*set_idt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-void (*get_gdt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-void (*set_gdt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr);
-void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value,
-   int *exception);
-void (*cache_regs)(struct kvm_vcpu *vcpu);
-void (*decache_regs)(struct kvm_vcpu *vcpu);
-unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
-void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
-
-void (*invlpg)(struct kvm_vcpu *vcpu, gva_t addr);
-void (*tlb_flush)(struct kvm_vcpu *vcpu);
-void (*inject_page_fault)(struct kvm_vcpu *vcpu,
-  unsigned long addr, u32 err_code);
-
-void (*inject_gp)(struct kvm_vcpu *vcpu, unsigned err_code);
-
-int (*run)(struct kvm_vcpu *vcpu, struct kvm_run *run);
-void (*skip_emulated_instruction)(struct kvm_vcpu *vcpu);
-void (*patch_hypercall)(struct kvm_vcpu *vcpu,
-unsigned char *hypercall_addr);
-};
-
-extern struct kvm_x86_ops *kvm_x86_ops;
-
 /* The guest did something we don't support. */
 #define pr_unimpl(vcpu, fmt, ...)\
  do {\
@@ -488,10 +429,6 @@ extern struct kvm_x86_ops *kvm_x86_ops;
 int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
 void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
 
-int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
-  struct module *module);
-void kvm_exit_x86(void);
-
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
 
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 64c2cc4..6046665 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -16,33 +16,24 @@
  */
 
 #include "kvm.h"
-#include "x86_emulate.h"
-#include "segment_descriptor.h"
-
 #include 
+#include "kvm_arch.h"
+
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
+#include 
 
-#include 
-#include 
-#include 
 #include 
-#include 
 
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
@@ -391,234 +382,6 @@ static int kvm_vm_release(struct inode *inode, 
struct file *filp)
 return 0;
 }
 
-static void inject_gp(struct kvm_vcpu *vcpu)
-{
-kvm_x86_ops->inject_gp(vcpu, 0);
-}
-
-/*
- * Load the pae pdptrs.  Return true is they are all valid.
- */
-stat

[kvm-devel] [PATCH 5/5] Architecture independence layer - v1 - split_generic_x86_change

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

This contains the major changes done mostly in kvm_main.c to implement 
the generic handling of the ioctls with the mapping to arch functions as 
needed.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---
 kvm.h  |   20 ++
 kvm_arch.h |   34 
 kvm_main.c |  431 
+++--
 3 files changed, 104 insertions(+), 381 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index ff07e64..9bdb408 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -681,4 +681,24 @@ static inline u32 get_rdx_init_val(void)
 #define TSS_REDIRECTION_SIZE (256 / 8)
 #define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + 
TSS_IOPB_SIZE + 1)
 
+/* generic functions provided to arch module part by kvm_main code 
after split */
+extern __read_mostly struct preempt_ops kvm_preempt_ops;
+
+void kvm_destroy_vm(struct kvm *kvm);
+void kvm_free_physmem_slot(struct kvm_memory_slot *free,
+   struct kvm_memory_slot *dont);
+
+struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
+gpa_t addr);
+int complete_pio(struct kvm_vcpu *vcpu);
+
+__init void kvm_init_debug(void);
+void kvm_exit_debug(void);
+
+int kvm_init_generic(unsigned int vcpu_size, struct module *module);
+void kvm_exit_generic(void);
+
+void vcpu_load(struct kvm_vcpu *vcpu);
+void vcpu_put(struct kvm_vcpu *vcpu);
+
 #endif
diff --git a/drivers/kvm/kvm_arch.h b/drivers/kvm/kvm_arch.h
index 6658948..8e4759f 100644
--- a/drivers/kvm/kvm_arch.h
+++ b/drivers/kvm/kvm_arch.h
@@ -11,4 +11,38 @@
 
 #include 
 
+long kvm_arch_dev_ioctl(struct file *filp, unsigned int ioctl,
+unsigned long arg);
+void kvm_arch_free_vcpus(struct kvm *kvm);
+
+long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl,
+   unsigned long arg);
+struct kvm_vcpu* kvm_arch_vcpu_create(struct kvm *kvm, unsigned id);
+void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
+void kvm_arch_vcpu_decache(struct kvm_vcpu *vcpu);
+
+void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
+void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
+void kvm_arch_cache_regs(struct kvm_vcpu *vcpu);
+void kvm_arch_decache_regs(struct kvm_vcpu *vcpu);
+
+void kvm_arch_skip_emulated_instruction(struct kvm_vcpu *vcpu);
+void kvm_arch_inject_gp(struct kvm_vcpu *vcpu);
+
+long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl,
+ unsigned long arg);
+int kvm_arch_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
+int kvm_arch_vcpu_debug_guest(struct kvm_vcpu *vcpu,
+  struct kvm_debug_guest *dbg);
+int kvm_arch_vcpu_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
+int kvm_arch_vcpu_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
+
+void kvm_arch_hardware_enable(void *junk);
+void kvm_arch_hardware_disable(void *junk);
+
+__exit void kvm_arch_exit(void);
+__init int kvm_arch_init(void);
+
 #endif
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 6046665..b1e94e2 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -43,13 +43,11 @@ static LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kvm_x86_ops *kvm_x86_ops;
-struct kmem_cache *kvm_vcpu_cache;
-EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
 
-static __read_mostly struct preempt_ops kvm_preempt_ops;
+__read_mostly struct preempt_ops kvm_preempt_ops;
 
-#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
+static struct dentry *debugfs_dir;
 
 static struct kvm_stats_debugfs_item {
 const char *name;
@@ -73,209 +71,37 @@ static struct kvm_stats_debugfs_item {
 { NULL }
 };
 
-static struct dentry *debugfs_dir;
-
-#define MAX_IO_MSRS 256
-
-#define CR0_RESERVED_BITS\
-(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
-  | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
-  | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
-#define CR4_RESERVED_BITS\
-(~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
-  | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE\
-  | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR\
-  | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
-
-#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
-#define EFER_RESERVED_BITS 0xf2fe
-
-#ifdef CONFIG_X86_64
-// LDT or TSS descriptor in the GDT. 16 bytes.
-struct segment_descriptor_64 {
-struct segment_descriptor s;
-u32 base_higher;
-u32 pad_zero;
-};
-
-#endif
-
 static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
-   unsigned long arg);
-
-unsigned long segmen

[kvm-devel] [PATCH 2/5] Architecture independence layer - v1 - basic mechanism

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

This contains the basic mechanism introducing new files and 
Kconfig/Makefile changes

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---
 Kconfig|   20 
 Makefile   |   14 --
 kvm_arch.h |   14 ++
 x86.c  |   51 +++
 x86.h  |9 +
 5 files changed, 102 insertions(+), 6 deletions(-)

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 445c6e4..c971d81 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -3,14 +3,14 @@
 #
 menuconfig VIRTUALIZATION
 bool "Virtualization"
-depends on X86
+depends on X86 || POWERPC
 default y
 
 if VIRTUALIZATION
 
 config KVM
 tristate "Kernel-based Virtual Machine (KVM) support"
-depends on X86 && EXPERIMENTAL
+depends on EXPERIMENTAL
 select PREEMPT_NOTIFIERS
 select ANON_INODES
 ---help---
@@ -29,16 +29,28 @@ config KVM
 
 config KVM_INTEL
 tristate "KVM for Intel processors support"
-depends on KVM
+depends on KVM && X86
 ---help---
   Provides support for KVM on Intel processors equipped with the VT
   extensions.
 
 config KVM_AMD
 tristate "KVM for AMD processors support"
-depends on KVM
+depends on KVM && X86
 ---help---
   Provides support for KVM on AMD processors equipped with the AMD-V
   (SVM) extensions.
 
+config KVM_POWERPC_440
+tristate "KVM for embedded PowerPC 440 cores"
+depends on KVM && POWERPC
+---help---
+  Provides support for KVM on embedded PowerPC 440 cores
+
+config KVM_POWERPC_E500
+tristate "KVM for embedded PowerPC e500 cores"
+depends on KVM && POWERPC
+---help---
+  Provides support for KVM on embedded PowerPC e500 cores
+
 endif # VIRTUALIZATION
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index c0a789f..c18431b 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -2,9 +2,19 @@
 # Makefile for Kernel-based Virtual Machine module
 #
 
-kvm-objs := kvm_main.o mmu.o x86_emulate.o
-obj-$(CONFIG_KVM) += kvm.o
+kvm-objs := kvm_main.o
+
+ifeq ($(CONFIG_X86),y)
+kvm-objs += x86.o mmu.o x86_emulate.o
+
 kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
+endif
+
+ifeq ($(CONFIG_POWERPC),y)
+kvm-objs += powerpc.o
+endif
+
+obj-$(CONFIG_KVM) += kvm.o
diff --git a/drivers/kvm/kvm_arch.h b/drivers/kvm/kvm_arch.h
new file mode 100644
index 000..6658948
--- /dev/null
+++ b/drivers/kvm/kvm_arch.h
@@ -0,0 +1,14 @@
+#ifndef __KVM_ARCH_H
+#define __KVM_ARCH_H
+
+/*
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * This is the interface an arch module has to implement because this 
is what
+ * kvm_main gets linked against depending on arch selection.
+ */
+
+#include 
+
+#endif
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
new file mode 100644
index 000..5c72fee
--- /dev/null
+++ b/drivers/kvm/x86.c
@@ -0,0 +1,51 @@
+/*
+ * Kernel-based Virtual Machine driver for Linux
+ *
+ * This module enables machines with Intel VT-x extensions to run virtual
+ * machines without emulation or binary translation.
+ *
+ * Copyright (C) 2006 Qumranet, Inc.
+ *
+ * Authors:
+ *   Avi Kivity   <[EMAIL PROTECTED]>
+ *   Yaniv Kamay  <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include "kvm.h"
+#include "kvm_arch.h"
+#include "x86.h"
+#include "x86_emulate.h"
+#include "segment_descriptor.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("Qumranet");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
new file mode 100644
index 000..021385e
--- /dev/null
+++ b/drivers/kvm/x86.h
@@ -0,0 +1,9 @@
+#ifndef __KVM_X86_H
+#define __KVM_X86_H
+
+/*
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#endif

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


-
This SF.net email is sponsored by: Splunk Inc.
Still

[kvm-devel] [PATCH 0/5] Architecture independence layer - v1

2007-08-24 Thread Christian Ehrhardt
Hi,
this is the first update for my architecture independence patches moving 
the version number to v1.
The updates from v0 to v1 are:
- use the already defined CONFIG_arch symbols instead of new ones
- the x86 arch portion is now in x86.[ch]
- added singed by / diffstat / inline patch ... statements
- The huge patch #3 is now split up logically into three smaller patches 
for a better readability. Unfortunately I was not able to get this 
automatically done/smaller by any git magic, so I splitted #3 by hand. 
The majority of changes just move function X from file A to file B and 
thereby cause big patches. I extracted those portion to #3 & #4 to make 
#5 smaller and readable, because thats where the real changes take place.

This is the new layout:
-> #1 is still just a renaming patch for better readability (_arch -> _x86)
-> #2 still contains the basic mechanism introducing filenames and the 
Kconfig/Make changes
-> #3 is now "split_generic_x86_move" and covers all the simple function 
movement deletions of generic code in kvm_main as well as some minor 
changes e.g. header includes
-> #4 is now "split_generic_x86_x86.c" and contains all the insertions 
of the arch code into x86.[ch]
-> #5 is now "split_generic_x86_change" and this is where all the major 
changes take place to implement arch independence (fortunally this is 
also the smallest patch)

Avi strongly recommended to wait for the merge of the lapic branch, so 
I'll keep this low prio the next time to rebase it when lapic is merged.
Comments are welcome, even while waiting for these merge ;-)

-- 

Grüsse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 0/3] Architecture independence layer - v0

2007-08-22 Thread Christian Ehrhardt
Hello,
these three patches in v0 are be a base for discussion about an architecture
independence layer. It is part of an internal prototype we use to access 
the code
of our port as we develop it currently.
I know that a lot of things in the patches are still needing refining and
polishing, but it is enough to start the discussion about the basic 
mechanism
before I (or someone else) spend to much work working on such a layer.

The idea is, that x86 should always work however we split kvm internally to
generic/arch. The split in the current patches is done by gut feeling 
and will
improve by a) reviewing some functions more in detail, b) along the 
development
of our arch port and c) by your comments.

I know that the current kvm userspace is still very x86 centric and this 
will
(has to) change in the future, but we need an architecture mapping now 
to develop
our arch code. It should be adaptable to any userspace interface change 
that is coming.

Basics I used:
- Since architecture will not change at runtime I do not use a arch_ops 
structure
- Instead I used a hidden Kconfig value specifying the kvm architecture 
which then
  influence the make file to link together the generic and the arch 
specific part
  to one kvm module
- I split the code into kvm_main.c (generic) and kvm_x86.h/kvm_x86.c 
(arch portion)
- A new header kvm_arch.h specifies the interface the architecture has 
to implement
- The ioctl interfaces are implemented by the generic kvm_main.c in 
three ways
a) a completely generic function is covered by kvm_main.c completely
b) a completely arch dependent function is not covered in kvm_main.c - 
at the end
   each ioctl goes to a architecture mapping doing the rest of the ioctl 
not handled
   in the generic part e.g. in kvm_vcpu_ioctl:
default:
   r = kvm_arch_vcpu_ioctl(filp, ioctl, arg);
}
c) functions that have a significant amount of shared code are 
implemented by
   kvm_main.c using kvm_arch_* to implement the arch specific part. 
Either by just
   mapping the old *_ioctl_whatever to *_arch_whatever or by moving some 
more of the
   code out of the arch function up to the generic portion e.g.:
  case KVM_RUN:
r = -EINVAL;
if (arg)
goto out;
r = kvm_arch_vcpu_run(vcpu, vcpu->run);
break;
- there is still a lot of potential to move code up and down along these 
split, but
  thats it so far. I strive to improve that patch series until we are 
happy with it

The patch compiles and works without issues on my Opteron based machine 
here,
unfortunately I have no Intel base HW to test.
I look forward to every comment. Even if this approach may not be what 
we want in
the end, at least it starts the discussion how to do it :-)

Grüsse / Regards
Christian Ehrhardt

P.S. Still a todo and not (yet) covered in this patch proposal is the 
arch splitting of structures like vcpu to a generic and an arch part.

-- 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 1/3] Architecture independence layer - v0 - x86 renaming

2007-08-22 Thread Christian Ehrhardt

[Patch 1/3]
This is just a renaming patch converting _arch_ to _x86_ as I posted it 
last week.
It ensures a better readability by preventing two _arch interfaces in 
the code at the

same time.

--

Grüsse / regards, 
Christian Ehrhardt


IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen

Registergericht: Amtsgericht Stuttgart, HRB 243294

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 70231f3..a3dcc96 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -415,7 +415,7 @@ struct descriptor_table {
unsigned long base;
 } __attribute__((packed));
 
-struct kvm_arch_ops {
+struct kvm_x86_ops {
int (*cpu_has_kvm_support)(void);  /* __init */
int (*disabled_by_bios)(void); /* __init */
void (*hardware_enable)(void *dummy);  /* __init */
@@ -472,7 +472,7 @@ struct kvm_arch_ops {
unsigned char *hypercall_addr);
 };
 
-extern struct kvm_arch_ops *kvm_arch_ops;
+extern struct kvm_x86_ops *kvm_x86_ops;
 
 /* The guest did something we don't support. */
 #define pr_unimpl(vcpu, fmt, ...)  \
@@ -488,9 +488,9 @@ extern struct kvm_arch_ops *kvm_arch_ops;
 int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
 void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
 
-int kvm_init_arch(struct kvm_arch_ops *ops, unsigned int vcpu_size,
+int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
  struct module *module);
-void kvm_exit_arch(void);
+void kvm_exit_x86(void);
 
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f7ff231..64c2cc4 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -52,7 +52,7 @@ static LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kvm_arch_ops *kvm_arch_ops;
+struct kvm_x86_ops *kvm_x86_ops;
 struct kmem_cache *kvm_vcpu_cache;
 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
 
@@ -180,14 +180,14 @@ static void vcpu_load(struct kvm_vcpu *vcpu)
mutex_lock(&vcpu->mutex);
cpu = get_cpu();
preempt_notifier_register(&vcpu->preempt_notifier);
-   kvm_arch_ops->vcpu_load(vcpu, cpu);
+   kvm_x86_ops->vcpu_load(vcpu, cpu);
put_cpu();
 }
 
 static void vcpu_put(struct kvm_vcpu *vcpu)
 {
preempt_disable();
-   kvm_arch_ops->vcpu_put(vcpu);
+   kvm_x86_ops->vcpu_put(vcpu);
preempt_notifier_unregister(&vcpu->preempt_notifier);
preempt_enable();
mutex_unlock(&vcpu->mutex);
@@ -364,7 +364,7 @@ static void kvm_free_vcpus(struct kvm *kvm)
kvm_unload_vcpu_mmu(kvm->vcpus[i]);
for (i = 0; i < KVM_MAX_VCPUS; ++i) {
if (kvm->vcpus[i]) {
-   kvm_arch_ops->vcpu_free(kvm->vcpus[i]);
+   kvm_x86_ops->vcpu_free(kvm->vcpus[i]);
kvm->vcpus[i] = NULL;
}
}
@@ -393,7 +393,7 @@ static int kvm_vm_release(struct inode *inode, struct file 
*filp)
 
 static void inject_gp(struct kvm_vcpu *vcpu)
 {
-   kvm_arch_ops->inject_gp(vcpu, 0);
+   kvm_x86_ops->inject_gp(vcpu, 0);
 }
 
 /*
@@ -468,7 +468,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
inject_gp(vcpu);
return;
}
-   kvm_arch_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
+   kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
if (cs_l) {
printk(KERN_DEBUG "set_cr0: #GP, start paging "
   "in long mode while CS.L == 1\n");
@@ -487,7 +487,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 
}
 
-   kvm_arch_ops->set_cr0(vcpu, cr0);
+   kvm_x86_ops->set_cr0(vcpu, cr0);
vcpu->cr0 = cr0;
 
mutex_lock(&vcpu->kvm->lock);
@@ -530,7 +530,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
inject_gp(vcpu);
return;
}
-   kvm_arch_ops->set_cr4(vcpu, cr4);
+   kvm_x86_ops->set_cr4(vcpu, cr4);
mutex_lock(&vcpu->kvm->lock);
kvm_mmu_reset_context(vcpu);
mutex_unlock(&vcpu->kvm->lock);
@@ -1048,7 +1048,7 @@ static int emulator_write_emulated_onepage(unsigned long 
addr,
gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr);
 
if (gpa == UNMAPPED_GVA) {
-   kvm_arch_ops->inject_page_fault(vcpu, addr, 2);
+   kvm_x86_ops->inject_page_fault(vc

[kvm-devel] [PATCH 2/3] Architecture independence layer - v0 - basic mechanism

2007-08-22 Thread Christian Ehrhardt

[Patch 2/3]
This introduces the Kconfig & Makefile changes as well as creating the 
still empty body of kvm_x86.*


Related part from the 0/3 mail:
- Since architecture will not change at runtime I do not use a arch_ops 
structure
- Instead I used a hidden Kconfig value specifying the kvm architecture 
which then
 influence the make file to link together the generic and the arch 
specific part

 to one kvm module
- I split the code into kvm_main.c (generic) and kvm_x86.h/kvm_x86.c 
(arch portion)


--

Grüsse / regards, 
Christian Ehrhardt


IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen

Registergericht: Amtsgericht Stuttgart, HRB 243294

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 445c6e4..63ce7b0 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -3,14 +3,14 @@
 #
 menuconfig VIRTUALIZATION
bool "Virtualization"
-   depends on X86
+   depends on X86 || POWERPC
default y
 
 if VIRTUALIZATION
 
 config KVM
tristate "Kernel-based Virtual Machine (KVM) support"
-   depends on X86 && EXPERIMENTAL
+   depends on EXPERIMENTAL
select PREEMPT_NOTIFIERS
select ANON_INODES
---help---
@@ -27,18 +27,40 @@ config KVM
 
  If unsure, say N.
 
+config KVM_X86
+   bool
+
 config KVM_INTEL
tristate "KVM for Intel processors support"
-   depends on KVM
+   depends on KVM && X86
+   select KVM_X86
---help---
  Provides support for KVM on Intel processors equipped with the VT
  extensions.
 
 config KVM_AMD
tristate "KVM for AMD processors support"
-   depends on KVM
+   depends on KVM && X86
+   select KVM_X86
---help---
  Provides support for KVM on AMD processors equipped with the AMD-V
  (SVM) extensions.
 
+config KVM_EMBEDDED_POWERPC
+   bool
+
+config KVM_POWERPC_440
+   tristate "KVM for embedded PowerPC 440 cores"
+   depends on KVM && POWERPC
+   select KVM_EMBEDDED_POWERPC
+   ---help---
+ Provides support for KVM on embedded PowerPC 440 cores
+
+config KVM_POWERPC_E500
+   tristate "KVM for embedded PowerPC e500 cores"
+   depends on KVM && POWERPC
+   select KVM_EMBEDDED_POWERPC
+   ---help---
+ Provides support for KVM on embedded PowerPC e500 cores
+
 endif # VIRTUALIZATION
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index c0a789f..843fe08 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -2,9 +2,19 @@
 # Makefile for Kernel-based Virtual Machine module
 #
 
-kvm-objs := kvm_main.o mmu.o x86_emulate.o
-obj-$(CONFIG_KVM) += kvm.o
+kvm-objs := kvm_main.o
+
+ifeq ($(CONFIG_KVM_X86),y)
+kvm-objs += kvm_x86.o mmu.o x86_emulate.o
+
 kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
+endif
+
+ifeq ($(CONFIG_KVM_EMBEDDED_POWERPC),y)
+kvm-objs += kvm-powerpc.o
+endif
+
+obj-$(CONFIG_KVM) += kvm.o
diff --git a/drivers/kvm/kvm_arch.h b/drivers/kvm/kvm_arch.h
new file mode 100644
index 000..6658948
--- /dev/null
+++ b/drivers/kvm/kvm_arch.h
@@ -0,0 +1,14 @@
+#ifndef __KVM_ARCH_H
+#define __KVM_ARCH_H
+
+/*
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * This is the interface an arch module has to implement because this is what
+ * kvm_main gets linked against depending on arch selection.
+ */
+
+#include 
+
+#endif
diff --git a/drivers/kvm/kvm_x86.c b/drivers/kvm/kvm_x86.c
new file mode 100644
index 000..585f277
--- /dev/null
+++ b/drivers/kvm/kvm_x86.c
@@ -0,0 +1,51 @@
+/*
+ * Kernel-based Virtual Machine driver for Linux
+ *
+ * This module enables machines with Intel VT-x extensions to run virtual
+ * machines without emulation or binary translation.
+ *
+ * Copyright (C) 2006 Qumranet, Inc.
+ *
+ * Authors:
+ *   Avi Kivity   <[EMAIL PROTECTED]>
+ *   Yaniv Kamay  <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include "kvm.h"
+#include "kvm_arch.h"
+#include "kvm_x86.h"
+#include "x86_emulate.h"
+#include "segment_descriptor.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+MODULE_AUTHOR("Qumranet");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/kvm/kvm_x86.h b/drivers/kvm/kvm_x86.h
new f

[kvm-devel] [patch] Renaming kvm_arch in view of upcoming architecture ports

2007-08-15 Thread Christian Ehrhardt

Hi,
in view of the upcoming architecture ports, this is a little cleanup 
patch that renames the current "_arch" to "_x86"

e.g. kvm_arch_ops -> kvm_x86_ops

I discussed with some people about names like kvm_x86_arch_ops or 
kvm_subarch_ops, ... but at the end we thought that "arch" has a special 
meaning in linux and so it should be freed for the real architecture 
ports of kvm that show up slowly on the horizon (look at Tucson).
I want to invite everyone to comment about what may be a more 
appropriate name in order to find out what naming scheme the community 
wants.


I attached the patch to keep the usual form, but actually it is just 
what comes out executing the following:

 perl -p -i -e "s/_arch/_x86/g" drivers/kvm/*

--

Grüsse / regards, 
Christian Ehrhardt


IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen 
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen

Registergericht: Amtsgericht Stuttgart, HRB 243294

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 70231f3..a3dcc96 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -415,7 +415,7 @@ struct descriptor_table {
unsigned long base;
 } __attribute__((packed));
 
-struct kvm_arch_ops {
+struct kvm_x86_ops {
int (*cpu_has_kvm_support)(void);  /* __init */
int (*disabled_by_bios)(void); /* __init */
void (*hardware_enable)(void *dummy);  /* __init */
@@ -472,7 +472,7 @@ struct kvm_arch_ops {
unsigned char *hypercall_addr);
 };
 
-extern struct kvm_arch_ops *kvm_arch_ops;
+extern struct kvm_x86_ops *kvm_x86_ops;
 
 /* The guest did something we don't support. */
 #define pr_unimpl(vcpu, fmt, ...)  \
@@ -488,9 +488,9 @@ extern struct kvm_arch_ops *kvm_arch_ops;
 int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
 void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
 
-int kvm_init_arch(struct kvm_arch_ops *ops, unsigned int vcpu_size,
+int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
  struct module *module);
-void kvm_exit_arch(void);
+void kvm_exit_x86(void);
 
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f7ff231..64c2cc4 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -52,7 +52,7 @@ static LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kvm_arch_ops *kvm_arch_ops;
+struct kvm_x86_ops *kvm_x86_ops;
 struct kmem_cache *kvm_vcpu_cache;
 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
 
@@ -180,14 +180,14 @@ static void vcpu_load(struct kvm_vcpu *vcpu)
mutex_lock(&vcpu->mutex);
cpu = get_cpu();
preempt_notifier_register(&vcpu->preempt_notifier);
-   kvm_arch_ops->vcpu_load(vcpu, cpu);
+   kvm_x86_ops->vcpu_load(vcpu, cpu);
put_cpu();
 }
 
 static void vcpu_put(struct kvm_vcpu *vcpu)
 {
preempt_disable();
-   kvm_arch_ops->vcpu_put(vcpu);
+   kvm_x86_ops->vcpu_put(vcpu);
preempt_notifier_unregister(&vcpu->preempt_notifier);
preempt_enable();
mutex_unlock(&vcpu->mutex);
@@ -364,7 +364,7 @@ static void kvm_free_vcpus(struct kvm *kvm)
kvm_unload_vcpu_mmu(kvm->vcpus[i]);
for (i = 0; i < KVM_MAX_VCPUS; ++i) {
if (kvm->vcpus[i]) {
-   kvm_arch_ops->vcpu_free(kvm->vcpus[i]);
+   kvm_x86_ops->vcpu_free(kvm->vcpus[i]);
kvm->vcpus[i] = NULL;
}
}
@@ -393,7 +393,7 @@ static int kvm_vm_release(struct inode *inode, struct file 
*filp)
 
 static void inject_gp(struct kvm_vcpu *vcpu)
 {
-   kvm_arch_ops->inject_gp(vcpu, 0);
+   kvm_x86_ops->inject_gp(vcpu, 0);
 }
 
 /*
@@ -468,7 +468,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
inject_gp(vcpu);
return;
}
-   kvm_arch_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
+   kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
if (cs_l) {
printk(KERN_DEBUG "set_cr0: #GP, start paging "
   "in long mode while CS.L == 1\n");
@@ -487,7 +487,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 
}
 
-   kvm_arch_ops->set_cr0(vcpu, cr0);
+   kvm_x86_ops->set_cr0(vcpu, cr0);
vcpu->cr0 = cr0;
 
mutex_lock(&vcpu->kvm->lock);
@@ -530,7 +530,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)