aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,