Skip to content

Commit 2eedcac

Browse files
anadavbonzini
authored andcommitted
KVM: x86: Loading segments on 64-bit mode may be wrong
The current emulator implementation ignores the high 32 bits of the base in long-mode. During segment load from the LDT, the base of the LDT is calculated incorrectly and may cause the wrong segment to be loaded. Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent e37a75a commit 2eedcac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/kvm/emulate.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,17 +1358,19 @@ static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt,
13581358
u16 selector, struct desc_ptr *dt)
13591359
{
13601360
const struct x86_emulate_ops *ops = ctxt->ops;
1361+
u32 base3 = 0;
13611362

13621363
if (selector & 1 << 2) {
13631364
struct desc_struct desc;
13641365
u16 sel;
13651366

13661367
memset (dt, 0, sizeof *dt);
1367-
if (!ops->get_segment(ctxt, &sel, &desc, NULL, VCPU_SREG_LDTR))
1368+
if (!ops->get_segment(ctxt, &sel, &desc, &base3,
1369+
VCPU_SREG_LDTR))
13681370
return;
13691371

13701372
dt->size = desc_limit_scaled(&desc); /* what if limit > 65535? */
1371-
dt->address = get_desc_base(&desc);
1373+
dt->address = get_desc_base(&desc) | ((u64)base3 << 32);
13721374
} else
13731375
ops->get_gdt(ctxt, dt);
13741376
}

0 commit comments

Comments
 (0)