From: Nadav Amit <namit@cs.technion.ac.il>
To: pbonzini@redhat.com
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, gleb@kernel.org, linux-kernel@vger.kernel.org,
Nadav Amit <namit@cs.technion.ac.il>
Subject: [PATCH 2/7] KVM: x86: Function for determining exception type
Date: Mon, 21 Jul 2014 14:37:25 +0300 [thread overview]
Message-ID: <1405942650-22589-3-git-send-email-namit@cs.technion.ac.il> (raw)
In-Reply-To: <1405942650-22589-1-git-send-email-namit@cs.technion.ac.il>
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
next prev parent reply other threads:[~2014-07-21 11:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-21 11:37 [PATCH 0/7] KVM: x86: Additional rflags.rf fixes Nadav Amit
2014-07-21 11:37 ` [PATCH 1/7] KVM: x86: Defining missing x86 vectors Nadav Amit
2014-07-21 11:37 ` Nadav Amit [this message]
2014-07-21 12:18 ` [PATCH 2/7] KVM: x86: Function for determining exception type Paolo Bonzini
2014-07-21 21:30 ` Nadav Amit
2014-07-22 8:08 ` Paolo Bonzini
2014-07-21 11:37 ` [PATCH 3/7] KVM: x86: Clearing rflags.rf upon skipped emulated instruction Nadav Amit
2014-07-21 11:37 ` [PATCH 4/7] KVM: vmx: set rflags.rf during fault injection Nadav Amit
2014-07-21 12:05 ` Paolo Bonzini
2014-07-21 11:37 ` [PATCH 5/7] KVM: x86: popf emulation should not change RF Nadav Amit
2014-07-21 11:37 ` [PATCH 6/7] KVM: x86: Clear rflags.rf on emulated instructions Nadav Amit
2014-07-21 11:37 ` [PATCH 7/7] KVM: x86: Cleanup of rflags.rf cleaning Nadav Amit
2014-07-21 11:39 ` [PATCH kvm-unit-tests 0/3] x86: Test rflags.rf clearing/setting Nadav Amit
2014-07-21 11:39 ` [PATCH kvm-unit-tests 1/3] x86: Check rflags.rf is cleared after emulation Nadav Amit
2014-07-21 11:39 ` [PATCH kvm-unit-tests 2/3] x86: Test rflags.rf is set upon faults Nadav Amit
2014-07-21 12:24 ` Paolo Bonzini
2014-07-21 11:39 ` [PATCH kvm-unit-tests 3/3] x86: Check RFLAGS.RF on interrupt during REP-str Nadav Amit
2014-07-21 12:25 ` [PATCH kvm-unit-tests 0/3] x86: Test rflags.rf clearing/setting Paolo Bonzini
2014-07-24 11:55 ` [PATCH kvm-unit-tests] x86: Test rflags.rf is set upon faults Nadav Amit
2014-07-24 12:09 ` Paolo Bonzini
2014-07-21 12:19 ` [PATCH 0/7] KVM: x86: Additional rflags.rf fixes Paolo Bonzini
2014-07-21 12:28 ` Nadav Amit
2014-07-21 12:31 ` Paolo Bonzini
2014-07-24 11:51 ` [PATCH 0/2] KVM: x86: Missing " Nadav Amit
2014-07-24 11:51 ` [PATCH 1/2] KVM: x86: Setting rflags.rf during rep-string emulation Nadav Amit
2014-07-24 11:51 ` [PATCH 2/2] KVM: x86: set rflags.rf during fault injection Nadav Amit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405942650-22589-3-git-send-email-namit@cs.technion.ac.il \
--to=namit@cs.technion.ac.il \
--cc=gleb@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®