lkml.org 
[lkml]   [2014]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/7] KVM: x86: Function for determining exception type
Date
New function for determining the x86 exception type: fault, abort, trap, etc.
This function is used by the next patch for setting rflags.rf upon faults.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
arch/x86/kvm/x86.c | 35 +++++++++++++++++++++++++++++++++++
arch/x86/kvm/x86.h | 9 +++++++++
2 files changed, 44 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f750b69..c2aa58e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -311,6 +311,41 @@ static int exception_class(int vector)
return EXCPT_BENIGN;
}

+int kvm_exception_type(unsigned int nr)
+{
+ switch (nr) {
+ case DE_VECTOR:
+ case BR_VECTOR:
+ case UD_VECTOR:
+ case NM_VECTOR:
+ case TS_VECTOR:
+ case NP_VECTOR:
+ case SS_VECTOR:
+ case GP_VECTOR:
+ case PF_VECTOR:
+ case MF_VECTOR:
+ case AC_VECTOR:
+ case XM_VECTOR:
+ case VE_VECTOR:
+ return EXCPT_FAULT;
+ case DB_VECTOR:
+ return EXCPT_FAULT_OR_TRAP;
+ case BP_VECTOR:
+ case OF_VECTOR:
+ return EXCPT_TRAP;
+ case DF_VECTOR:
+ case MC_VECTOR:
+ return EXCPT_ABORT;
+ case 15:
+ case 21 ... 31:
+ return EXCPT_RESERVED;
+ default:
+ break;
+ }
+ return EXCPT_INTERRUPT;
+}
+EXPORT_SYMBOL_GPL(kvm_exception_type);
+
static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
unsigned nr, bool has_error, u32 error_code,
bool reinject)
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 306a1b7..b413181 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -151,6 +151,15 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,

#define KVM_SUPPORTED_XCR0 (XSTATE_FP | XSTATE_SSE | XSTATE_YMM \
| XSTATE_BNDREGS | XSTATE_BNDCSR)
+
+#define EXCPT_FAULT 0
+#define EXCPT_TRAP 1
+#define EXCPT_FAULT_OR_TRAP 2
+#define EXCPT_ABORT 3
+#define EXCPT_RESERVED 4
+#define EXCPT_INTERRUPT 5
+int kvm_exception_type(unsigned int nr);
+
extern u64 host_xcr0;

extern u64 kvm_supported_xcr0(void);
--
1.9.1


\
 
 \ /
  Last update: 2014-07-21 14:21    [W:0.202 / U:1.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site