Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode V2

2010-12-01 Thread Nadav Har'El
On Mon, Nov 29, 2010, Joerg Roedel wrote about [PATCH 0/3] KVM: Introduce 
VCPU-wide notion of guest-mode V2:
 Hi Avi, Hi Marcelo,
 
 here is the re-spin I promised. The change to V1 are essentially the
 renames:
 
   kvm_vcpu_enter_gm - enter_guest_mode
   kvm_vcpu_leave_gm - leave_guest_mode
   kvm_vcpu_is_gm- is_guest_mode

I like this concept, and will be happy to change the nested VMX code to use
it as well.

One small thing: After the name change, it might not be obvious on first
sight that these functions refer to the state of the vcpu, not the state
of the actual CPU (which, if you think about it, is never in guest mode while
KVM code is running ;-)). I think that a short comment before the definition
of these functions might be useful - perhaps saying that they pertain to a
hypervisor running in the vcpu (i.e., nested virtualization).

Nadav.

-- 
Nadav Har'El|   Wednesday, Dec  1 2010, 24 Kislev 5771
n...@math.technion.ac.il |-
Phone +972-523-790466, ICQ 13349191 |How do you get holy water? Boil the hell
http://nadav.harel.org.il   |out of it.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode V2

2010-12-01 Thread Roedel, Joerg
On Wed, Dec 01, 2010 at 03:01:49AM -0500, Nadav Har'El wrote:
 On Mon, Nov 29, 2010, Joerg Roedel wrote about [PATCH 0/3] KVM: Introduce 
 VCPU-wide notion of guest-mode V2:
  Hi Avi, Hi Marcelo,
  
  here is the re-spin I promised. The change to V1 are essentially the
  renames:
  
  kvm_vcpu_enter_gm - enter_guest_mode
  kvm_vcpu_leave_gm - leave_guest_mode
  kvm_vcpu_is_gm- is_guest_mode
 
 I like this concept, and will be happy to change the nested VMX code to use
 it as well.
 
 One small thing: After the name change, it might not be obvious on first
 sight that these functions refer to the state of the vcpu, not the state
 of the actual CPU (which, if you think about it, is never in guest mode while
 KVM code is running ;-)). I think that a short comment before the definition
 of these functions might be useful - perhaps saying that they pertain to a
 hypervisor running in the vcpu (i.e., nested virtualization).

Yes, right. Thats a good thing. I sent a follow-on patch adding the
comments.

Btw, another idea which came up recently was to concentrate the actuall
vmexit emulation at a single point. Every code place which does the exit
directly today will be changed to only set a request-bit and the real
exit is then done later. Your code might already do this, I havn't
checked. In fact the idea is from the neste-VMX patchset for Xen :)
This would fit very well in the generic code because it already has
request-bit infrastructure. What do you think, can nested VMX also make
use of that too?

Joerg

-- 
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632

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


Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode V2

2010-12-01 Thread Nadav Har'El
On Wed, Dec 01, 2010, Roedel, Joerg wrote about Re: [PATCH 0/3] KVM: Introduce 
VCPU-wide notion of guest-mode V2:
 Btw, another idea which came up recently was to concentrate the actuall
 vmexit emulation at a single point. Every code place which does the exit
 directly today will be changed to only set a request-bit and the real
 exit is then done later. Your code might already do this, I havn't

In my current patches, there is single function nested_vmx_vmexit() which
emulates the exit (exits from L2 to L1), but it is called in several places,
the most significant are of course in vmx_handle_exit (when L1 asked an exit
on the given event), and vmx_interrupt_allowed (when we inject an interrupt
and L1 asked to exit on interrupts). This area of my code definitely needs
some reorganization, as Gleb pointed out in his review.

 This would fit very well in the generic code because it already has
 request-bit infrastructure. What do you think, can nested VMX also make
 use of that too?

Can you please say a few words why you'd want to move this nested-exit
request bit to x86.c? Do you want to move some of the exit logic to x86.c -
e.g., for the injection logic?

Nadav.

-- 
Nadav Har'El|   Wednesday, Dec  1 2010, 24 Kislev 5771
n...@math.technion.ac.il |-
Phone +972-523-790466, ICQ 13349191 |Fame: when your name is in everything but
http://nadav.harel.org.il   |the phone book.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode V2

2010-12-01 Thread Roedel, Joerg
On Wed, Dec 01, 2010 at 06:38:30AM -0500, Nadav Har'El wrote:

 Can you please say a few words why you'd want to move this nested-exit
 request bit to x86.c?

I don't want to move the actual exit-code itself into generic code. This
code is different between svm and vmx. I think we could implement a
call-back in kvm_x86_ops which is called when a vmexit is requested.
The benefit is that we have a single and well-defined place where we
emulate a vmexit.
SVM already as a similar mechanism internally because nested_svm_vmexit
may sleep and can't be called from certain places. Another reason is
that emulating a vmexit at a wrong plase may have side-effects (for
example when called from within the instruction emulator).
With a generic request-bit I can remove the SVM internal implementation
and nested vmx could use it too. I am certain you will need something
similar in nested-vmx too. 

 Do you want to move some of the exit logic to x86.c - e.g., for the
 injection logic?

Thats another and probably more complex topic. I need a better
understanding of (nested-)vmx before we discuss how this can be done.
But a vmexit-callback may be helpful there as well.

Joerg

-- 
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632

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


Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode V2

2010-12-01 Thread Marcelo Tosatti
On Mon, Nov 29, 2010 at 05:51:46PM +0100, Joerg Roedel wrote:
 Hi Avi, Hi Marcelo,
 
 here is the re-spin I promised. The change to V1 are essentially the
 renames:
 
   kvm_vcpu_enter_gm - enter_guest_mode
   kvm_vcpu_leave_gm - leave_guest_mode
   kvm_vcpu_is_gm- is_guest_mode
 
 No other changes are in this patch-set compared to V1.
 
 Regards,
   Joerg
 
  arch/x86/include/asm/kvm_host.h |1 +
  arch/x86/kvm/kvm_cache_regs.h   |   15 +
  arch/x86/kvm/svm.c  |   44 ++
  arch/x86/kvm/x86.c  |   14 ---
  4 files changed, 47 insertions(+), 27 deletions(-)
 
 Joerg Roedel (3):
   KVM: X86: Introduce generic guest-mode representation
   KVM: SVM: Make Use of the generic guest-mode functions
   KVM: X86: Don't report L2 emulation failures to user-space

Applied, thanks.

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


[PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode

2010-11-29 Thread Joerg Roedel
Hi Avi, Hi Marcelo,

this patch-set introduces a generic notion of guest-mode for VCPUs in
KVM. This is already useful as seen in patch 3/3. Nested-VMX also has a
guest-mode, so it will make sense for this code too.

Regards,

Joerg

As usual:

 arch/x86/include/asm/kvm_host.h |1 +
 arch/x86/kvm/kvm_cache_regs.h   |   15 +
 arch/x86/kvm/svm.c  |   44 ++
 arch/x86/kvm/x86.c  |   14 ---

Joerg Roedel (3):
  KVM: X86: Introduce generic guest-mode representation
  KVM: SVM: Make Use of the generic guest-mode functions
  KVM: X86: Don't report L2 emulation failures to user-space

 4 files changed, 47 insertions(+), 27 deletions(-)

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


Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode

2010-11-29 Thread Avi Kivity

On 11/29/2010 05:38 PM, Joerg Roedel wrote:

Hi Avi, Hi Marcelo,

this patch-set introduces a generic notion of guest-mode for VCPUs in
KVM. This is already useful as seen in patch 3/3. Nested-VMX also has a
guest-mode, so it will make sense for this code too.



Looks good, apart from the trivial comments on patch 1.

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

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


Re: [PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode

2010-11-29 Thread Roedel, Joerg
On Mon, Nov 29, 2010 at 11:10:59AM -0500, Avi Kivity wrote:
 On 11/29/2010 05:38 PM, Joerg Roedel wrote:
  Hi Avi, Hi Marcelo,
 
  this patch-set introduces a generic notion of guest-mode for VCPUs in
  KVM. This is already useful as seen in patch 3/3. Nested-VMX also has a
  guest-mode, so it will make sense for this code too.
 
 
 Looks good, apart from the trivial comments on patch 1.

Okay, I do a re-spin and fix this. Thanks for your comments.

Joerg

-- 
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632

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


[PATCH 0/3] KVM: Introduce VCPU-wide notion of guest-mode V2

2010-11-29 Thread Joerg Roedel
Hi Avi, Hi Marcelo,

here is the re-spin I promised. The change to V1 are essentially the
renames:

kvm_vcpu_enter_gm - enter_guest_mode
kvm_vcpu_leave_gm - leave_guest_mode
kvm_vcpu_is_gm- is_guest_mode

No other changes are in this patch-set compared to V1.

Regards,
Joerg

 arch/x86/include/asm/kvm_host.h |1 +
 arch/x86/kvm/kvm_cache_regs.h   |   15 +
 arch/x86/kvm/svm.c  |   44 ++
 arch/x86/kvm/x86.c  |   14 ---
 4 files changed, 47 insertions(+), 27 deletions(-)

Joerg Roedel (3):
  KVM: X86: Introduce generic guest-mode representation
  KVM: SVM: Make Use of the generic guest-mode functions
  KVM: X86: Don't report L2 emulation failures to user-space


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