aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorNadav Amit <namit@cs.technion.ac.il>2014-07-24 07:51:24 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-24 08:04:01 -0400
commitd6e8c8545651b05a86c5b9d29d2fe11ad4cbb9aa (patch)
treedc4fd4b0fae7abdcece4bcd76102253d23c3159b /arch/x86/kvm
parentb9a1ecb909e8f772934cc4bf1f164124c9fbb0d0 (diff)
KVM: x86: set rflags.rf during fault injection
x86 does not automatically set rflags.rf during event injection. This patch does partial job, setting rflags.rf upon fault injection. It does not handle the setting of RF upon interrupt injection on rep-string instruction. Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/x86.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 08c48a3c7c3a..439f96bf424d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -311,6 +311,31 @@ static int exception_class(int vector)
311 return EXCPT_BENIGN; 311 return EXCPT_BENIGN;
312} 312}
313 313
314#define EXCPT_FAULT 0
315#define EXCPT_TRAP 1
316#define EXCPT_ABORT 2
317#define EXCPT_INTERRUPT 3
318
319static int exception_type(int vector)
320{
321 unsigned int mask;
322
323 if (WARN_ON(vector > 31 || vector == NMI_VECTOR))
324 return EXCPT_INTERRUPT;
325
326 mask = 1 << vector;
327
328 /* #DB is trap, as instruction watchpoints are handled elsewhere */
329 if (mask & ((1 << DB_VECTOR) | (1 << BP_VECTOR) | (1 << OF_VECTOR)))
330 return EXCPT_TRAP;
331
332 if (mask & ((1 << DF_VECTOR) | (1 << MC_VECTOR)))
333 return EXCPT_ABORT;
334
335 /* Reserved exceptions will result in fault */
336 return EXCPT_FAULT;
337}
338
314static void kvm_multiple_exception(struct kvm_vcpu *vcpu, 339static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
315 unsigned nr, bool has_error, u32 error_code, 340 unsigned nr, bool has_error, u32 error_code,
316 bool reinject) 341 bool reinject)
@@ -5893,6 +5918,11 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
5893 trace_kvm_inj_exception(vcpu->arch.exception.nr, 5918 trace_kvm_inj_exception(vcpu->arch.exception.nr,
5894 vcpu->arch.exception.has_error_code, 5919 vcpu->arch.exception.has_error_code,
5895 vcpu->arch.exception.error_code); 5920 vcpu->arch.exception.error_code);
5921
5922 if (exception_type(vcpu->arch.exception.nr) == EXCPT_FAULT)
5923 __kvm_set_rflags(vcpu, kvm_get_rflags(vcpu) |
5924 X86_EFLAGS_RF);
5925
5896 kvm_x86_ops->queue_exception(vcpu, vcpu->arch.exception.nr, 5926 kvm_x86_ops->queue_exception(vcpu, vcpu->arch.exception.nr,
5897 vcpu->arch.exception.has_error_code, 5927 vcpu->arch.exception.has_error_code,
5898 vcpu->arch.exception.error_code, 5928 vcpu->arch.exception.error_code,