diff mbox

[3/5] Don't #VMEXIT(INTR) if we still have event_inj waiting

Message ID 1253278832-31803-4-git-send-email-agraf@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Graf Sept. 18, 2009, 1 p.m. UTC
Real hardware would first process the event_inj field and then notify the
host that an interrupt is waiting.

Let's do the same and just not EXIT_INTR if we have an event pending for the
L2 guest.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/x86/kvm/svm.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Joerg Roedel Sept. 23, 2009, 1:39 a.m. UTC | #1
On Fri, Sep 18, 2009 at 03:00:30PM +0200, Alexander Graf wrote:
> Real hardware would first process the event_inj field and then notify the
> host that an interrupt is waiting.

Does it really? I couldn't find this in the SVM spec.

> Let's do the same and just not EXIT_INTR if we have an event pending for the
> L2 guest.

Anyway. I think this case is handled good enough with patch 5/5. This
patch, to be complete must also enable single-steping to exit again
after the first instruction of the exception handler has ran to inject
the interrupt. But that would make the whole thing rather compĺicated.

> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/x86/kvm/svm.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 61efd13..28fcbd0 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1401,6 +1401,10 @@ static inline int nested_svm_intr(struct vcpu_svm *svm)
>  	if (!(svm->vcpu.arch.hflags & HF_HIF_MASK))
>  		return 0;
>  
> +	/* We can't EXIT_INTR when we still have an event to inject */
> +	if (svm->vmcb->control.event_inj)
> +		return 1;
> +
>  	svm->vmcb->control.exit_code = SVM_EXIT_INTR;
>  
>  	if (nested_svm_exit_handled(svm)) {
> -- 
> 1.6.0.2
> 
> --
> 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
--
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
Alexander Graf Sept. 23, 2009, 8:09 a.m. UTC | #2
Am 22.09.2009 um 18:39 schrieb Joerg Roedel <joro@8bytes.org>:

> On Fri, Sep 18, 2009 at 03:00:30PM +0200, Alexander Graf wrote:
>> Real hardware would first process the event_inj field and then  
>> notify the
>> host that an interrupt is waiting.
>
> Does it really? I couldn't find this in the SVM spec.

I didn't see it in the spec either, but that's what I saw real  
hardware do which is supported by the exit_info validity check in svm.c

>
>> Let's do the same and just not EXIT_INTR if we have an event  
>> pending for the
>> L2 guest.
>
> Anyway. I think this case is handled good enough with patch 5/5. This
> patch, to be complete must also enable single-steping to exit again
> after the first instruction of the exception handler has ran to inject
> the interrupt. But that would make the whole thing rather compĺicate 
> d.

The NMI injection path has logic for that, but for now it shouldn't  
hurt - we'll get an interrupt sooner or later.

>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>> arch/x86/kvm/svm.c |    4 ++++
>> 1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index 61efd13..28fcbd0 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -1401,6 +1401,10 @@ static inline int nested_svm_intr(struct  
>> vcpu_svm *svm)
>>    if (!(svm->vcpu.arch.hflags & HF_HIF_MASK))
>>        return 0;
>>
>> +    /* We can't EXIT_INTR when we still have an event to inject */
>> +    if (svm->vmcb->control.event_inj)
>> +        return 1;
>> +
>>    svm->vmcb->control.exit_code = SVM_EXIT_INTR;
>>
>>    if (nested_svm_exit_handled(svm)) {
>> -- 
>> 1.6.0.2
>>
>> --
>> 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
--
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/svm.c b/arch/x86/kvm/svm.c
index 61efd13..28fcbd0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1401,6 +1401,10 @@  static inline int nested_svm_intr(struct vcpu_svm *svm)
 	if (!(svm->vcpu.arch.hflags & HF_HIF_MASK))
 		return 0;
 
+	/* We can't EXIT_INTR when we still have an event to inject */
+	if (svm->vmcb->control.event_inj)
+		return 1;
+
 	svm->vmcb->control.exit_code = SVM_EXIT_INTR;
 
 	if (nested_svm_exit_handled(svm)) {