aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2011-04-04 06:39:27 -0400
committerAvi Kivity <avi@redhat.com>2011-05-11 07:57:01 -0400
commit8a76d7f25f8f24fc5a328c8e15e4a7313cf141b9 (patch)
tree7adadd7663b006d75563c457c6b7c5f91a4d16d2 /arch/x86/include
parent8ea7d6aef84e278fcb121acff1bd4c3edaa95b8b (diff)
KVM: x86: Add x86 callback for intercept check
This patch adds a callback into kvm_x86_ops so that svm and vmx code can do intercept checks on emulated instructions. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/include')
-rw-r--r--arch/x86/include/asm/kvm_emulate.h22
-rw-r--r--arch/x86/include/asm/kvm_host.h7
2 files changed, 27 insertions, 2 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index cab841a034f..eb7033cefe8 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -26,6 +26,24 @@ struct x86_exception {
26}; 26};
27 27
28/* 28/*
29 * This struct is used to carry enough information from the instruction
30 * decoder to main KVM so that a decision can be made whether the
31 * instruction needs to be intercepted or not.
32 */
33struct x86_instruction_info {
34 u8 intercept; /* which intercept */
35 u8 rep_prefix; /* rep prefix? */
36 u8 modrm_mod; /* mod part of modrm */
37 u8 modrm_reg; /* index of register used */
38 u8 modrm_rm; /* rm part of modrm */
39 u64 src_val; /* value of source operand */
40 u8 src_bytes; /* size of source operand */
41 u8 dst_bytes; /* size of destination operand */
42 u8 ad_bytes; /* size of src/dst address */
43 u64 next_rip; /* rip following the instruction */
44};
45
46/*
29 * x86_emulate_ops: 47 * x86_emulate_ops:
30 * 48 *
31 * These operations represent the instruction emulator's interface to memory. 49 * These operations represent the instruction emulator's interface to memory.
@@ -163,8 +181,8 @@ struct x86_emulate_ops {
163 int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata); 181 int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata);
164 void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */ 182 void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */
165 void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */ 183 void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */
166 int (*intercept)(struct x86_emulate_ctxt *ctxt, 184 int (*intercept)(struct kvm_vcpu *vcpu,
167 enum x86_intercept intercept, 185 struct x86_instruction_info *info,
168 enum x86_intercept_stage stage); 186 enum x86_intercept_stage stage);
169}; 187};
170 188
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e820c6339b8..038562c222e 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -505,6 +505,8 @@ struct kvm_vcpu_stat {
505 u32 nmi_injections; 505 u32 nmi_injections;
506}; 506};
507 507
508struct x86_instruction_info;
509
508struct kvm_x86_ops { 510struct kvm_x86_ops {
509 int (*cpu_has_kvm_support)(void); /* __init */ 511 int (*cpu_has_kvm_support)(void); /* __init */
510 int (*disabled_by_bios)(void); /* __init */ 512 int (*disabled_by_bios)(void); /* __init */
@@ -592,6 +594,11 @@ struct kvm_x86_ops {
592 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset); 594 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset);
593 595
594 void (*get_exit_info)(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2); 596 void (*get_exit_info)(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2);
597
598 int (*check_intercept)(struct kvm_vcpu *vcpu,
599 struct x86_instruction_info *info,
600 enum x86_intercept_stage stage);
601
595 const struct trace_print_flags *exit_reasons_str; 602 const struct trace_print_flags *exit_reasons_str;
596}; 603};
597 604