Skip to content

Commit e37a75a

Browse files
anadavbonzini
authored andcommitted
KVM: x86: Emulator ignores LDTR/TR extended base on LLDT/LTR
The current implementation ignores the LDTR/TR base high 32-bits on long-mode. As a result the loaded segment descriptor may be incorrect. Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 7fe864d commit e37a75a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/x86/kvm/emulate.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
14221422
ulong desc_addr;
14231423
int ret;
14241424
u16 dummy;
1425+
u32 base3 = 0;
14251426

14261427
memset(&seg_desc, 0, sizeof seg_desc);
14271428

@@ -1538,9 +1539,14 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
15381539
ret = write_segment_descriptor(ctxt, selector, &seg_desc);
15391540
if (ret != X86EMUL_CONTINUE)
15401541
return ret;
1542+
} else if (ctxt->mode == X86EMUL_MODE_PROT64) {
1543+
ret = ctxt->ops->read_std(ctxt, desc_addr+8, &base3,
1544+
sizeof(base3), &ctxt->exception);
1545+
if (ret != X86EMUL_CONTINUE)
1546+
return ret;
15411547
}
15421548
load:
1543-
ctxt->ops->set_segment(ctxt, selector, &seg_desc, 0, seg);
1549+
ctxt->ops->set_segment(ctxt, selector, &seg_desc, base3, seg);
15441550
return X86EMUL_CONTINUE;
15451551
exception:
15461552
emulate_exception(ctxt, err_vec, err_code, true);

0 commit comments

Comments
 (0)