All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c
@ 2013-07-04  7:03 Arthur Chunqi Li
  2013-07-04  7:03 ` [PATCH v2 2/2] KVM : Set success rflags when emulate VMXON/VMXOFF in nested virt Arthur Chunqi Li
  2013-07-04  9:47 ` [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Gleb Natapov
  0 siblings, 2 replies; 4+ messages in thread
From: Arthur Chunqi Li @ 2013-07-04  7:03 UTC (permalink / raw)
  To: kvm; +Cc: gleb, pbonzini, jan.kiszka, Arthur Chunqi Li

Move nested_vmx_succeed/nested_vmx_failInvalid/nested_vmx_failValid
ahead of handle_vmon to eliminate double declaration in the same
file

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
---
 arch/x86/kvm/vmx.c |   83 +++++++++++++++++++++++++---------------------------
 1 file changed, 40 insertions(+), 43 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 260a919..1764b13 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5551,8 +5551,47 @@ static void nested_free_all_saved_vmcss(struct vcpu_vmx *vmx)
 		free_loaded_vmcs(&vmx->vmcs01);
 }
 
+/*
+ * The following 3 functions, nested_vmx_succeed()/failValid()/failInvalid(),
+ * set the success or error code of an emulated VMX instruction, as specified
+ * by Vol 2B, VMX Instruction Reference, "Conventions".
+ */
+static void nested_vmx_succeed(struct kvm_vcpu *vcpu)
+{
+	vmx_set_rflags(vcpu, vmx_get_rflags(vcpu)
+			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
+			    X86_EFLAGS_ZF | X86_EFLAGS_SF | X86_EFLAGS_OF));
+}
+
+static void nested_vmx_failInvalid(struct kvm_vcpu *vcpu)
+{
+	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
+			& ~(X86_EFLAGS_PF | X86_EFLAGS_AF | X86_EFLAGS_ZF |
+			    X86_EFLAGS_SF | X86_EFLAGS_OF))
+			| X86_EFLAGS_CF);
+}
+
 static void nested_vmx_failValid(struct kvm_vcpu *vcpu,
-				 u32 vm_instruction_error);
+					u32 vm_instruction_error)
+{
+	if (to_vmx(vcpu)->nested.current_vmptr == -1ull) {
+		/*
+		 * failValid writes the error number to the current VMCS, which
+		 * can't be done there isn't a current VMCS.
+		 */
+		nested_vmx_failInvalid(vcpu);
+		return;
+	}
+	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
+			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
+			    X86_EFLAGS_SF | X86_EFLAGS_OF))
+			| X86_EFLAGS_ZF);
+	get_vmcs12(vcpu)->vm_instruction_error = vm_instruction_error;
+	/*
+	 * We don't need to force a shadow sync because
+	 * VM_INSTRUCTION_ERROR is not shadowed
+	 */
+}
 
 /*
  * Emulate the VMXON instruction.
@@ -5752,48 +5791,6 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu,
 	return 0;
 }
 
-/*
- * The following 3 functions, nested_vmx_succeed()/failValid()/failInvalid(),
- * set the success or error code of an emulated VMX instruction, as specified
- * by Vol 2B, VMX Instruction Reference, "Conventions".
- */
-static void nested_vmx_succeed(struct kvm_vcpu *vcpu)
-{
-	vmx_set_rflags(vcpu, vmx_get_rflags(vcpu)
-			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
-			    X86_EFLAGS_ZF | X86_EFLAGS_SF | X86_EFLAGS_OF));
-}
-
-static void nested_vmx_failInvalid(struct kvm_vcpu *vcpu)
-{
-	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
-			& ~(X86_EFLAGS_PF | X86_EFLAGS_AF | X86_EFLAGS_ZF |
-			    X86_EFLAGS_SF | X86_EFLAGS_OF))
-			| X86_EFLAGS_CF);
-}
-
-static void nested_vmx_failValid(struct kvm_vcpu *vcpu,
-					u32 vm_instruction_error)
-{
-	if (to_vmx(vcpu)->nested.current_vmptr == -1ull) {
-		/*
-		 * failValid writes the error number to the current VMCS, which
-		 * can't be done there isn't a current VMCS.
-		 */
-		nested_vmx_failInvalid(vcpu);
-		return;
-	}
-	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
-			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
-			    X86_EFLAGS_SF | X86_EFLAGS_OF))
-			| X86_EFLAGS_ZF);
-	get_vmcs12(vcpu)->vm_instruction_error = vm_instruction_error;
-	/*
-	 * We don't need to force a shadow sync because
-	 * VM_INSTRUCTION_ERROR is not shadowed
-	 */
-}
-
 /* Emulate the VMCLEAR instruction */
 static int handle_vmclear(struct kvm_vcpu *vcpu)
 {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] KVM : Set success rflags when emulate VMXON/VMXOFF in nested virt
  2013-07-04  7:03 [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Arthur Chunqi Li
@ 2013-07-04  7:03 ` Arthur Chunqi Li
  2013-07-04  9:47 ` [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Gleb Natapov
  1 sibling, 0 replies; 4+ messages in thread
From: Arthur Chunqi Li @ 2013-07-04  7:03 UTC (permalink / raw)
  To: kvm; +Cc: gleb, pbonzini, jan.kiszka, Arthur Chunqi Li

Set rflags after successfully emulateing VMXON/VMXOFF in VMX.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
---
 arch/x86/kvm/vmx.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1764b13..423bc411 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5651,6 +5651,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
 	vmx->nested.vmxon = true;
 
 	skip_emulated_instruction(vcpu);
+	nested_vmx_succeed(vcpu);
 	return 1;
 }
 
@@ -5735,6 +5736,7 @@ static int handle_vmoff(struct kvm_vcpu *vcpu)
 		return 1;
 	free_nested(to_vmx(vcpu));
 	skip_emulated_instruction(vcpu);
+	nested_vmx_succeed(vcpu);
 	return 1;
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c
  2013-07-04  7:03 [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Arthur Chunqi Li
  2013-07-04  7:03 ` [PATCH v2 2/2] KVM : Set success rflags when emulate VMXON/VMXOFF in nested virt Arthur Chunqi Li
@ 2013-07-04  9:47 ` Gleb Natapov
  2013-07-04 11:11   ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2013-07-04  9:47 UTC (permalink / raw)
  To: Arthur Chunqi Li; +Cc: kvm, pbonzini, jan.kiszka

Please add prefix VMX for vmx patches (or nVMX for nested) on a subject line
in the future. Like this:
KVM: nVMX: Change location of 3 functions in vmx.c.

No need to resend.

Otherwise both patches looks good to me.

On Thu, Jul 04, 2013 at 03:03:32PM +0800, Arthur Chunqi Li wrote:
> Move nested_vmx_succeed/nested_vmx_failInvalid/nested_vmx_failValid
> ahead of handle_vmon to eliminate double declaration in the same
> file
> 
> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
> ---
>  arch/x86/kvm/vmx.c |   83 +++++++++++++++++++++++++---------------------------
>  1 file changed, 40 insertions(+), 43 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 260a919..1764b13 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -5551,8 +5551,47 @@ static void nested_free_all_saved_vmcss(struct vcpu_vmx *vmx)
>  		free_loaded_vmcs(&vmx->vmcs01);
>  }
>  
> +/*
> + * The following 3 functions, nested_vmx_succeed()/failValid()/failInvalid(),
> + * set the success or error code of an emulated VMX instruction, as specified
> + * by Vol 2B, VMX Instruction Reference, "Conventions".
> + */
> +static void nested_vmx_succeed(struct kvm_vcpu *vcpu)
> +{
> +	vmx_set_rflags(vcpu, vmx_get_rflags(vcpu)
> +			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
> +			    X86_EFLAGS_ZF | X86_EFLAGS_SF | X86_EFLAGS_OF));
> +}
> +
> +static void nested_vmx_failInvalid(struct kvm_vcpu *vcpu)
> +{
> +	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
> +			& ~(X86_EFLAGS_PF | X86_EFLAGS_AF | X86_EFLAGS_ZF |
> +			    X86_EFLAGS_SF | X86_EFLAGS_OF))
> +			| X86_EFLAGS_CF);
> +}
> +
>  static void nested_vmx_failValid(struct kvm_vcpu *vcpu,
> -				 u32 vm_instruction_error);
> +					u32 vm_instruction_error)
> +{
> +	if (to_vmx(vcpu)->nested.current_vmptr == -1ull) {
> +		/*
> +		 * failValid writes the error number to the current VMCS, which
> +		 * can't be done there isn't a current VMCS.
> +		 */
> +		nested_vmx_failInvalid(vcpu);
> +		return;
> +	}
> +	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
> +			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
> +			    X86_EFLAGS_SF | X86_EFLAGS_OF))
> +			| X86_EFLAGS_ZF);
> +	get_vmcs12(vcpu)->vm_instruction_error = vm_instruction_error;
> +	/*
> +	 * We don't need to force a shadow sync because
> +	 * VM_INSTRUCTION_ERROR is not shadowed
> +	 */
> +}
>  
>  /*
>   * Emulate the VMXON instruction.
> @@ -5752,48 +5791,6 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu,
>  	return 0;
>  }
>  
> -/*
> - * The following 3 functions, nested_vmx_succeed()/failValid()/failInvalid(),
> - * set the success or error code of an emulated VMX instruction, as specified
> - * by Vol 2B, VMX Instruction Reference, "Conventions".
> - */
> -static void nested_vmx_succeed(struct kvm_vcpu *vcpu)
> -{
> -	vmx_set_rflags(vcpu, vmx_get_rflags(vcpu)
> -			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
> -			    X86_EFLAGS_ZF | X86_EFLAGS_SF | X86_EFLAGS_OF));
> -}
> -
> -static void nested_vmx_failInvalid(struct kvm_vcpu *vcpu)
> -{
> -	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
> -			& ~(X86_EFLAGS_PF | X86_EFLAGS_AF | X86_EFLAGS_ZF |
> -			    X86_EFLAGS_SF | X86_EFLAGS_OF))
> -			| X86_EFLAGS_CF);
> -}
> -
> -static void nested_vmx_failValid(struct kvm_vcpu *vcpu,
> -					u32 vm_instruction_error)
> -{
> -	if (to_vmx(vcpu)->nested.current_vmptr == -1ull) {
> -		/*
> -		 * failValid writes the error number to the current VMCS, which
> -		 * can't be done there isn't a current VMCS.
> -		 */
> -		nested_vmx_failInvalid(vcpu);
> -		return;
> -	}
> -	vmx_set_rflags(vcpu, (vmx_get_rflags(vcpu)
> -			& ~(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF |
> -			    X86_EFLAGS_SF | X86_EFLAGS_OF))
> -			| X86_EFLAGS_ZF);
> -	get_vmcs12(vcpu)->vm_instruction_error = vm_instruction_error;
> -	/*
> -	 * We don't need to force a shadow sync because
> -	 * VM_INSTRUCTION_ERROR is not shadowed
> -	 */
> -}
> -
>  /* Emulate the VMCLEAR instruction */
>  static int handle_vmclear(struct kvm_vcpu *vcpu)
>  {
> -- 
> 1.7.9.5

--
			Gleb.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c
  2013-07-04  9:47 ` [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Gleb Natapov
@ 2013-07-04 11:11   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-07-04 11:11 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: Arthur Chunqi Li, kvm, jan.kiszka

Il 04/07/2013 11:47, Gleb Natapov ha scritto:
> Please add prefix VMX for vmx patches (or nVMX for nested) on a subject line
> in the future. Like this:
> KVM: nVMX: Change location of 3 functions in vmx.c.
> 
> No need to resend.
> 
> Otherwise both patches looks good to me.

Applied to kvm/queue.

Also, next time please add a "cover letter" with subject [PATCH 0/2].
"git format-patch --cover-letter" can create a template for you.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-04 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04  7:03 [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Arthur Chunqi Li
2013-07-04  7:03 ` [PATCH v2 2/2] KVM : Set success rflags when emulate VMXON/VMXOFF in nested virt Arthur Chunqi Li
2013-07-04  9:47 ` [PATCH v2 1/2] KVM : Change location of 3 functions in vmx.c Gleb Natapov
2013-07-04 11:11   ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.