diff mbox

[v2,1/5] KVM: nVMX: Fix injection of PENDING_INTERRUPT and NMI_WINDOW exits to L1

Message ID dc3b74709bcc4163ec3b6276f482d0400ecec290.1363429383.git.jan.kiszka@web.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka March 16, 2013, 10:23 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Check if the interrupt or NMI window exit is for L1 by testing if it has
the corresponding controls enabled. This is required when we allow
direct injection from L0 to L2

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/x86/kvm/vmx.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

Comments

Gleb Natapov March 17, 2013, 1:47 p.m. UTC | #1
On Sat, Mar 16, 2013 at 11:23:15AM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Check if the interrupt or NMI window exit is for L1 by testing if it has
> the corresponding controls enabled. This is required when we allow
> direct injection from L0 to L2
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>

> ---
>  arch/x86/kvm/vmx.c |    9 ++-------
>  1 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index ad978a6..126d047 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -6111,14 +6111,9 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
>  	case EXIT_REASON_TRIPLE_FAULT:
>  		return 1;
>  	case EXIT_REASON_PENDING_INTERRUPT:
> +		return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING);
>  	case EXIT_REASON_NMI_WINDOW:
> -		/*
> -		 * prepare_vmcs02() set the CPU_BASED_VIRTUAL_INTR_PENDING bit
> -		 * (aka Interrupt Window Exiting) only when L1 turned it on,
> -		 * so if we got a PENDING_INTERRUPT exit, this must be for L1.
> -		 * Same for NMI Window Exiting.
> -		 */
> -		return 1;
> +		return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING);
>  	case EXIT_REASON_TASK_SWITCH:
>  		return 1;
>  	case EXIT_REASON_CPUID:
> -- 
> 1.7.3.4

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

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad978a6..126d047 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6111,14 +6111,9 @@  static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
 	case EXIT_REASON_TRIPLE_FAULT:
 		return 1;
 	case EXIT_REASON_PENDING_INTERRUPT:
+		return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING);
 	case EXIT_REASON_NMI_WINDOW:
-		/*
-		 * prepare_vmcs02() set the CPU_BASED_VIRTUAL_INTR_PENDING bit
-		 * (aka Interrupt Window Exiting) only when L1 turned it on,
-		 * so if we got a PENDING_INTERRUPT exit, this must be for L1.
-		 * Same for NMI Window Exiting.
-		 */
-		return 1;
+		return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING);
 	case EXIT_REASON_TASK_SWITCH:
 		return 1;
 	case EXIT_REASON_CPUID: