[kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-05 Thread Avi Kivity
Changes since v3:

- detect msrs on host dynamically.  Avoids oopses on non-ia32e
  capable processors.
- web site: http://kvm.sourceforge.net
- slightly rediffed

Changes since v2:

- mailing list: kvm-devel@lists.sourceforge.net
  (http://lists.sourceforge.net/lists/listinfo/kvm-devel)
- applied code review comments
- fixed set_sregs() ioctl corrupting guest state if cr0.pe changed
  (a polite way of saying that loading a saved vm was broken)

---

The following patchset adds a driver for Intel's hardware
virtualization extensions to the x86 architecture.  The driver adds
a character device (/dev/kvm) that exposes the virtualization
capabilities to userspace.  Using this driver, a process can run a
virtual machine (a "guest") in a fully virtualized PC containing its
own virtual hard disks, network adapters, and display.

Using this driver, one can start multiple virtual machines on a host.
Each virtual machine is a process on the host; a virtual cpu is a thread
in that process.  kill(1), nice(1), top(1) work as expected.
   
In effect, the driver adds a third execution mode to the existing two:
we now have kernel mode, user mode, and guest mode.  Guest mode has its
own address space mapping guest physical memory (which is accessible to
user mode by mmap()ing /dev/kvm).  Guest mode has no access to any I/O
devices; any such access is intercepted and directed to user mode for
emulation.

The driver supports i386 and x86_64 hosts and guests.  All combinations
are allowed except x86_64 guest on i386 host.  For i386 guests and
hosts, both pae and non-pae paging modes are supported.

SMP hosts and UP guests are supported.  At the moment only Intel
hardware is supported, but AMD virtualization support is being worked on.

Performance currently is non-stellar due to the naive implementation
of the mmu virtualization, which throws away most of the shadow page
table entries every context switch.  We plan to address this in two ways:

- cache shadow page tables across tlv flushes
- wait until AMD and Intel release processors with nested page tables

Currently a virtual desktop is responsive but consumes a lot of CPU.
Under Windows I tried playing pinball and watching a few flash movies;
with a recent CPU one can hardly feel the virtualization.  Linux/X is
slower, probably due to X being in a separate process.

In addition to the driver, you need a slightly modified qemu to provide
I/O device emulation and the BIOS.

Caveats:

- The Windows install currently bluescreens due to a problem with the
  virtual APIC.  We are working on a fix.  A temporary workaround is to
  use an existing image or install through qemu
- Windows 64-bit does not work.  That's also true for qemu, so it's
  probably a problem with the device model.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-07 Thread Yinghai Lu
On 11/5/06, Avi Kivity <[EMAIL PROTECTED]> wrote:
> - Windows 64-bit does not work.  That's also true for qemu, so it's
>   probably a problem with the device model.

Windows 64bit could work as guest with qemu latest cvs version.

YH

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-07 Thread Avi Kivity
Yinghai Lu wrote:
> On 11/5/06, Avi Kivity <[EMAIL PROTECTED]> wrote:
>> - Windows 64-bit does not work.  That's also true for qemu, so it's
>>   probably a problem with the device model.
>
> Windows 64bit could work as guest with qemu latest cvs version.
>

That's good to know.  Once the next qemu version is released I'll merge 
it and re-test.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-07 Thread Andrew Morton
On Sun, 05 Nov 2006 22:27:45 +0200
Avi Kivity <[EMAIL PROTECTED]> wrote:

> The following patchset adds a driver for Intel's hardware
> virtualization extensions to the x86 architecture. 

kapow.

{standard input}: Assembler messages:
{standard input}:157: Error: no such instruction: `vmxon -20(%ebp)'
{standard input}:176: Error: no such instruction: `vmxoff'
{standard input}:191: Error: no such instruction: `vmread %eax,%eax'
{standard input}:403: Error: no such instruction: `vmwrite %edx,%eax'
{standard input}:409: Error: no such instruction: `vmread %eax,12(%esp)'
{standard input}:568: Error: no such instruction: `vmread %edx,%edx'
{standard input}:596: Error: no such instruction: `vmclear -12(%ebp)'
{standard input}:1885: Error: no such instruction: `vmread %eax,4(%esp)'
{standard input}:1908: Error: no such instruction: `vmread %edx,%edx'
{standard input}:1912: Error: no such instruction: `vmread %eax,%eax'
{standard input}:1919: Error: no such instruction: `vmread %eax,%edx'
{standard input}:1948: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2148: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2230: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2249: Error: no such instruction: `vmread %edx,%edx'
{standard input}:2253: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2259: Error: no such instruction: `vmread %edx,%edx'
{standard input}:2263: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2334: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2358: Error: no such instruction: `vmread %edx,%edx'
{standard input}:2362: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2368: Error: no such instruction: `vmread %edx,%edx'
{standard input}:2372: Error: no such instruction: `vmread %eax,%eax'
{standard input}:2425: Error: no such instruction: `vmread %edx,%edx'
etcetera.


That's gas 2.16.1.  I assume it needs some super-new binutils.

I'm not sure what to do about this.  What's the minimum version?

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-07 Thread Roland Dreier
 > That's gas 2.16.1.  I assume it needs some super-new binutils.
 > 
 > I'm not sure what to do about this.  What's the minimum version?

According to http://kvm.sourceforge.net/howto.html :
A recent enough binutils (>= 2.16.91.0.2) for vmx instruction support

 - R.

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-07 Thread Avi Kivity
Roland Dreier wrote:
>  > That's gas 2.16.1.  I assume it needs some super-new binutils.
>  > 
>  > I'm not sure what to do about this.  What's the minimum version?
>
> According to http://kvm.sourceforge.net/howto.html :
> A recent enough binutils (>= 2.16.91.0.2) for vmx instruction support
>   

Either that or a bunch of ugly .byte macros.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-07 Thread Andrew Morton
On Wed, 08 Nov 2006 09:14:50 +0200
Avi Kivity <[EMAIL PROTECTED]> wrote:

> Roland Dreier wrote:
> >  > That's gas 2.16.1.  I assume it needs some super-new binutils.
> >  > 
> >  > I'm not sure what to do about this.  What's the minimum version?
> >
> > According to http://kvm.sourceforge.net/howto.html :
> > A recent enough binutils (>= 2.16.91.0.2) for vmx instruction support
> >   
> 
> Either that or a bunch of ugly .byte macros.
> 

I think we could live with the binutils requirement as long as we can find
some automagic way of not breaking people's `make allmodconfig'.  Because
quite a lot of those people who do cross-compilation tend to use older
binutilses.

But I don't know how to do that.  We _could_ do a trick similar to the
`cc-version' make rule, and then use the new `as-version' to make the whole
kvm.o compile down to an empty .o file.  But that's pretty hacky.  Would
really prefer something at Kconfig-time, but we have no way of letting the
assembler version feed into the Kconfig system (nor do we want it, I
suspect).


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Avi Kivity
Andrew Morton wrote:
> On Wed, 08 Nov 2006 09:14:50 +0200
> Avi Kivity <[EMAIL PROTECTED]> wrote:
>
>   
>> Roland Dreier wrote:
>> 
>>>  > That's gas 2.16.1.  I assume it needs some super-new binutils.
>>>  > 
>>>  > I'm not sure what to do about this.  What's the minimum version?
>>>
>>> According to http://kvm.sourceforge.net/howto.html :
>>> A recent enough binutils (>= 2.16.91.0.2) for vmx instruction support
>>>   
>>>   
>> Either that or a bunch of ugly .byte macros.
>>
>> 
>
> I think we could live with the binutils requirement as long as we can find
> some automagic way of not breaking people's `make allmodconfig'.  Because
> quite a lot of those people who do cross-compilation tend to use older
> binutilses.
>   

These crosses are usually for $wierd target on x86 host, right?  But no 
one will compile kvm for non-x86:

depends on X86 && EXPERIMENTAL

> But I don't know how to do that.  We _could_ do a trick similar to the
> `cc-version' make rule, and then use the new `as-version' to make the whole
> kvm.o compile down to an empty .o file.  But that's pretty hacky.  

Not only hacky, it will confuse the regular user who gets a nonworking 
kvm.ko due to old binutils.


> Would
> really prefer something at Kconfig-time, but we have no way of letting the
> assembler version feed into the Kconfig system (nor do we want it, I
> suspect).
>   

config AS_VERSION
eval as --version | awk '{ ... }'

?

-- 
error compiling committee.c: too many arguments to function


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Andrew Morton
On Wed, 08 Nov 2006 10:07:15 +0200
Avi Kivity <[EMAIL PROTECTED]> wrote:

> Andrew Morton wrote:
> > On Wed, 08 Nov 2006 09:14:50 +0200
> > Avi Kivity <[EMAIL PROTECTED]> wrote:
> >
> >   
> >> Roland Dreier wrote:
> >> 
> >>>  > That's gas 2.16.1.  I assume it needs some super-new binutils.
> >>>  > 
> >>>  > I'm not sure what to do about this.  What's the minimum version?
> >>>
> >>> According to http://kvm.sourceforge.net/howto.html :
> >>> A recent enough binutils (>= 2.16.91.0.2) for vmx instruction support
> >>>   
> >>>   
> >> Either that or a bunch of ugly .byte macros.
> >>
> >> 
> >
> > I think we could live with the binutils requirement as long as we can find
> > some automagic way of not breaking people's `make allmodconfig'.  Because
> > quite a lot of those people who do cross-compilation tend to use older
> > binutilses.
> >   
> 
> These crosses are usually for $wierd target on x86 host, right?

Not necessarily.  If you're going to build kernels with distcc then you
need the same toolchain on all machines, so you probably build it with
crosstool.

Or if you want a consistent, tested, internally-maintained build
environment then you use a specific toolchain so your developers aren't
dependent on whatever their distro happened to put in /usr/bin

> 
> config AS_VERSION
> eval as --version | awk '{ ... }'
> 
> ?

It'd be more complex than that :(

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Arjan van de Ven

> 
> > Would
> > really prefer something at Kconfig-time, but we have no way of letting the
> > assembler version feed into the Kconfig system (nor do we want it, I
> > suspect).
> >   
> 
> config AS_VERSION
> eval as --version | awk '{ ... }'


config time is not possible (not to mention it's not that uncommon to
config on a different box than you compile). Makefile side is not that
hard; in fact what you'd need is a very small check similar to
scripts/gcc-x86_64-has-stack-protector.sh . While that checks a gcc
feature, checking the VMX operations via a C program with inline asm is
actually the most realistic test ANYWAY ...



-- 
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via 
http://www.linuxfirmwarekit.org


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Avi Kivity
Arjan van de Ven wrote:
>>> Would
>>> really prefer something at Kconfig-time, but we have no way of letting the
>>> assembler version feed into the Kconfig system (nor do we want it, I
>>> suspect).
>>>   
>>>   
>> config AS_VERSION
>> eval as --version | awk '{ ... }'
>> 
>
>
> config time is not possible (not to mention it's not that uncommon to
> config on a different box than you compile). 

If we add the 'eval' Kconfig keyword, it becomes possible, but I guess 
it isn't worth it if there are more users and anyway split 
configure/compile, as you note, breaks it.


> Makefile side is not that
> hard; in fact what you'd need is a very small check similar to
> scripts/gcc-x86_64-has-stack-protector.sh . While that checks a gcc
> feature, checking the VMX operations via a C program with inline asm is
> actually the most realistic test ANYWAY ...
>   

The problem with that is that the test comes too late: after we've 
configured.  Andrew wants to keep allmodconfig working, and for that we 
need to deselect CONFIG_KVM before compilation starts.

gcc.*protector.sh only affects the Makefile, not the configuration, AFAICT.

-- 
error compiling committee.c: too many arguments to function


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Arjan van de Ven

> 
> The problem with that is that the test comes too late: after we've 
> configured.  Andrew wants to keep allmodconfig working, and for that we 
> need to deselect CONFIG_KVM before compilation starts.

not really. You can also select to just not compile kvm at all *from the
Makefile*
> 
> gcc.*protector.sh only affects the Makefile, not the configuration, AFAICT.

but it is the Makefile that goes into the kvm directory and compiles
stuff!

yes it's ugly and not so elegant, but it's effective and you can warn
bigtime via nasty messages if you want ;)


-- 
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via 
http://www.linuxfirmwarekit.org


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Avi Kivity
Arjan van de Ven wrote:
>> The problem with that is that the test comes too late: after we've 
>> configured.  Andrew wants to keep allmodconfig working, and for that we 
>> need to deselect CONFIG_KVM before compilation starts.
>> 
>
> not really. You can also select to just not compile kvm at all *from the
> Makefile*
>   

Yes.  And then a real user (not an allmodconfig user) selects CONFIG_KVM 
and wonders where it went.

For users, we want it to fail fatally.  For allmodconfig, we want it to 
succeed but don't care about the output.


>> gcc.*protector.sh only affects the Makefile, not the configuration, AFAICT.
>> 
>
> but it is the Makefile that goes into the kvm directory and compiles
> stuff!
>
> yes it's ugly and not so elegant, but it's effective and you can warn
> bigtime via nasty messages if you want ;)
>   

We already have an ugly solution:

#define VMLAUNCH ".byte 0x0f, foo, bar"

etc.  We were looking for an elegant one.

-- 
error compiling committee.c: too many arguments to function


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 0/14] KVM: Kernel-based Virtual Machine (v4)

2006-11-08 Thread Roland Dreier
 > Either that or a bunch of ugly .byte macros.

After reading this thread, I have to say that this seems preferable to
relying on new-ish binutils.  Someday in the future we can fix it up
but I think too many people are still using old gas versions now.

You can hide the .byte crap in one place with #defines I think, so
it's not so bad.  We already do this for a few things in asm-i386 and
asm-x86_64 anyway.

 - R.

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel