* [PATCH] KVM: x86: Do not return soft events in vcpu_events
@ 2010-02-14 10:20 Jan Kiszka
2010-02-14 10:25 ` Gleb Natapov
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2010-02-14 10:20 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Gleb Natapov
From: Jan Kiszka <jan.kiszka@siemens.com>
Based on Gleb's suggestion: To avoid that user space migrates a pending
software exception or interrupt, mask them out on KVM_GET_VCPU_EVENTS.
Without this, user space would try to reinject them, and we would have
to reconstruct the proper instruction length for VMX event injection.
Now the pending event will be reinjected via executing the triggering
instruction again.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
arch/x86/kvm/x86.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 86b739f..50d1d2a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2121,14 +2121,17 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
{
vcpu_load(vcpu);
- events->exception.injected = vcpu->arch.exception.pending;
+ events->exception.injected =
+ vcpu->arch.exception.pending &&
+ !kvm_exception_is_soft(vcpu->arch.exception.nr);
events->exception.nr = vcpu->arch.exception.nr;
events->exception.has_error_code = vcpu->arch.exception.has_error_code;
events->exception.error_code = vcpu->arch.exception.error_code;
- events->interrupt.injected = vcpu->arch.interrupt.pending;
+ events->interrupt.injected =
+ vcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft;
events->interrupt.nr = vcpu->arch.interrupt.nr;
- events->interrupt.soft = vcpu->arch.interrupt.soft;
+ events->interrupt.soft = 0;
events->nmi.injected = vcpu->arch.nmi_injected;
events->nmi.pending = vcpu->arch.nmi_pending;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] KVM: x86: Do not return soft events in vcpu_events
2010-02-14 10:20 [PATCH] KVM: x86: Do not return soft events in vcpu_events Jan Kiszka
@ 2010-02-14 10:25 ` Gleb Natapov
0 siblings, 0 replies; 2+ messages in thread
From: Gleb Natapov @ 2010-02-14 10:25 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm
On Sun, Feb 14, 2010 at 11:20:44AM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Based on Gleb's suggestion: To avoid that user space migrates a pending
> software exception or interrupt, mask them out on KVM_GET_VCPU_EVENTS.
> Without this, user space would try to reinject them, and we would have
> to reconstruct the proper instruction length for VMX event injection.
> Now the pending event will be reinjected via executing the triggering
> instruction again.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Looks good to me.
> ---
> arch/x86/kvm/x86.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 86b739f..50d1d2a 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2121,14 +2121,17 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
> {
> vcpu_load(vcpu);
>
> - events->exception.injected = vcpu->arch.exception.pending;
> + events->exception.injected =
> + vcpu->arch.exception.pending &&
> + !kvm_exception_is_soft(vcpu->arch.exception.nr);
> events->exception.nr = vcpu->arch.exception.nr;
> events->exception.has_error_code = vcpu->arch.exception.has_error_code;
> events->exception.error_code = vcpu->arch.exception.error_code;
>
> - events->interrupt.injected = vcpu->arch.interrupt.pending;
> + events->interrupt.injected =
> + vcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft;
> events->interrupt.nr = vcpu->arch.interrupt.nr;
> - events->interrupt.soft = vcpu->arch.interrupt.soft;
> + events->interrupt.soft = 0;
>
> events->nmi.injected = vcpu->arch.nmi_injected;
> events->nmi.pending = vcpu->arch.nmi_pending;
--
Gleb.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-14 10:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-14 10:20 [PATCH] KVM: x86: Do not return soft events in vcpu_events Jan Kiszka
2010-02-14 10:25 ` Gleb Natapov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox