This patch add intercept checks into the KVM instruction emulator to check for the 8 instructions that access the descriptor table addresses. Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx> --- arch/x86/kvm/emulate.c | 13 +++++++++++-- arch/x86/kvm/svm.c | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 0719954..505348f 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2370,8 +2370,17 @@ static struct opcode group5[] = { D(SrcMem | ModRM | Stack), N, }; +static struct opcode group6[] = { + DI(ModRM, sldt), + DI(ModRM, str), + DI(ModRM | Priv, lldt), + DI(ModRM | Priv, ltr), + N, N, N, N, +}; + static struct group_dual group7 = { { - N, N, DI(ModRM | SrcMem | Priv, lgdt), DI(ModRM | SrcMem | Priv, lidt), + DI(ModRM | DstMem | Priv, sgdt), DI(ModRM | DstMem | Priv, sidt), + DI(ModRM | SrcMem | Priv, lgdt), DI(ModRM | SrcMem | Priv, lidt), DI(SrcNone | ModRM | DstMem | Mov, smsw), N, DI(SrcMem16 | ModRM | Mov | Priv, lmsw), DI(SrcMem | ModRM | ByteOp | Priv | NoAccess, invlpg), @@ -2502,7 +2511,7 @@ static struct opcode opcode_table[256] = { static struct opcode twobyte_table[256] = { /* 0x00 - 0x0F */ - N, GD(0, &group7), N, N, + G(0, group6), GD(0, &group7), N, N, N, D(ImplicitOps | VendorSpecific), DI(ImplicitOps | Priv, clts), N, DI(ImplicitOps | Priv, invd), DI(ImplicitOps | Priv, wbinvd), N, N, N, D(ImplicitOps | ModRM), N, N, diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 25d7460..faa959e 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3874,6 +3874,10 @@ static void svm_fpu_deactivate(struct kvm_vcpu *vcpu) #define POST_EX(exit) { .exit_code = (exit), \ .stage = x86_icpt_post_except, \ .valid = true } +#define POST_MEM(exit) { .exit_code = (exit), \ + .stage = x86_icpt_post_memaccess, \ + .valid = true } + static struct __x86_intercept { u32 exit_code; @@ -3887,9 +3891,18 @@ static struct __x86_intercept { [x86_intercept_smsw] = POST_EX(SVM_EXIT_READ_CR0), [x86_intercept_dr_read] = POST_EX(SVM_EXIT_READ_DR0), [x86_intercept_dr_write] = POST_EX(SVM_EXIT_WRITE_DR0), + [x86_intercept_sldt] = POST_MEM(SVM_EXIT_LDTR_READ), + [x86_intercept_str] = POST_MEM(SVM_EXIT_TR_READ), + [x86_intercept_lldt] = POST_MEM(SVM_EXIT_LDTR_WRITE), + [x86_intercept_ltr] = POST_MEM(SVM_EXIT_TR_WRITE), + [x86_intercept_sgdt] = POST_MEM(SVM_EXIT_GDTR_READ), + [x86_intercept_sidt] = POST_MEM(SVM_EXIT_IDTR_READ), + [x86_intercept_lgdt] = POST_MEM(SVM_EXIT_GDTR_WRITE), + [x86_intercept_lidt] = POST_MEM(SVM_EXIT_IDTR_WRITE), }; #undef POST_EX +#undef POST_MEM static int svm_check_intercept(struct kvm_vcpu *vcpu, struct x86_instruction_info *info, -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html