diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2011-04-04 12:39:27 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-11 07:57:01 -0400 |
commit | 8a76d7f25f8f24fc5a328c8e15e4a7313cf141b9 (patch) | |
tree | 7adadd7663b006d75563c457c6b7c5f91a4d16d2 /arch/x86/kvm | |
parent | 8ea7d6aef84e278fcb121acff1bd4c3edaa95b8b (diff) | |
download | op-kernel-dev-8a76d7f25f8f24fc5a328c8e15e4a7313cf141b9.zip op-kernel-dev-8a76d7f25f8f24fc5a328c8e15e4a7313cf141b9.tar.gz |
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/kvm')
-rw-r--r-- | arch/x86/kvm/emulate.c | 32 | ||||
-rw-r--r-- | arch/x86/kvm/svm.c | 9 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 9 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 6 |
4 files changed, 47 insertions, 9 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 3f32a66..e3e96ea 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -408,6 +408,26 @@ struct gprefix { (_eip) += (_size); \ }) +static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt, + enum x86_intercept intercept, + enum x86_intercept_stage stage) +{ + struct x86_instruction_info info = { + .intercept = intercept, + .rep_prefix = ctxt->decode.rep_prefix, + .modrm_mod = ctxt->decode.modrm_mod, + .modrm_reg = ctxt->decode.modrm_reg, + .modrm_rm = ctxt->decode.modrm_rm, + .src_val = ctxt->decode.src.val64, + .src_bytes = ctxt->decode.src.bytes, + .dst_bytes = ctxt->decode.dst.bytes, + .ad_bytes = ctxt->decode.ad_bytes, + .next_rip = ctxt->eip, + }; + + return ctxt->ops->intercept(ctxt->vcpu, &info, stage); +} + static inline unsigned long ad_mask(struct decode_cache *c) { return (1UL << (c->ad_bytes << 3)) - 1; @@ -3132,8 +3152,8 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) } if (unlikely(ctxt->guest_mode) && c->intercept) { - rc = ops->intercept(ctxt, c->intercept, - X86_ICPT_PRE_EXCEPT); + rc = emulator_check_intercept(ctxt, c->intercept, + X86_ICPT_PRE_EXCEPT); if (rc != X86EMUL_CONTINUE) goto done; } @@ -3158,8 +3178,8 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) } if (unlikely(ctxt->guest_mode) && c->intercept) { - rc = ops->intercept(ctxt, c->intercept, - X86_ICPT_POST_EXCEPT); + rc = emulator_check_intercept(ctxt, c->intercept, + X86_ICPT_POST_EXCEPT); if (rc != X86EMUL_CONTINUE) goto done; } @@ -3203,8 +3223,8 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) special_insn: if (unlikely(ctxt->guest_mode) && c->intercept) { - rc = ops->intercept(ctxt, c->intercept, - X86_ICPT_POST_MEMACCESS); + rc = emulator_check_intercept(ctxt, c->intercept, + X86_ICPT_POST_MEMACCESS); if (rc != X86EMUL_CONTINUE) goto done; } diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index cb43e98..798ebe6 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3868,6 +3868,13 @@ static void svm_fpu_deactivate(struct kvm_vcpu *vcpu) update_cr0_intercept(svm); } +static int svm_check_intercept(struct kvm_vcpu *vcpu, + struct x86_instruction_info *info, + enum x86_intercept_stage stage) +{ + return X86EMUL_CONTINUE; +} + static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled, @@ -3953,6 +3960,8 @@ static struct kvm_x86_ops svm_x86_ops = { .adjust_tsc_offset = svm_adjust_tsc_offset, .set_tdp_cr3 = set_tdp_cr3, + + .check_intercept = svm_check_intercept, }; static int __init svm_init(void) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 2b99ae7..3dfefe3 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4409,6 +4409,13 @@ static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) { } +static int vmx_check_intercept(struct kvm_vcpu *vcpu, + struct x86_instruction_info *info, + enum x86_intercept_stage stage) +{ + return X86EMUL_CONTINUE; +} + static struct kvm_x86_ops vmx_x86_ops = { .cpu_has_kvm_support = cpu_has_kvm_support, .disabled_by_bios = vmx_disabled_by_bios, @@ -4494,6 +4501,8 @@ static struct kvm_x86_ops vmx_x86_ops = { .adjust_tsc_offset = vmx_adjust_tsc_offset, .set_tdp_cr3 = vmx_set_cr3, + + .check_intercept = vmx_check_intercept, }; static int __init vmx_init(void) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 99bed74..eebe546 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4297,11 +4297,11 @@ static void emulator_put_fpu(struct x86_emulate_ctxt *ctxt) preempt_enable(); } -static int emulator_intercept(struct x86_emulate_ctxt *ctxt, - enum x86_intercept intercept, +static int emulator_intercept(struct kvm_vcpu *vcpu, + struct x86_instruction_info *info, enum x86_intercept_stage stage) { - return X86EMUL_CONTINUE; + return kvm_x86_ops->check_intercept(vcpu, info, stage); } static struct x86_emulate_ops emulate_ops = { |