aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Amit <namit@cs.technion.ac.il>2014-06-02 11:34:05 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-06-18 11:46:16 -0400
commit2eedcac8a97cef43c9c5236398fc8c9d0fd9cc0c (patch)
tree8cb8d3ed13da28adb72edb2013d5f81c0d445c81
parente37a75a13cdae5deaa2ea2cbf8d55b5dd08638b6 (diff)
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 <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/emulate.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 136088fb038b..7e4a45cab400 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1358,17 +1358,19 @@ static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt,
1358 u16 selector, struct desc_ptr *dt) 1358 u16 selector, struct desc_ptr *dt)
1359{ 1359{
1360 const struct x86_emulate_ops *ops = ctxt->ops; 1360 const struct x86_emulate_ops *ops = ctxt->ops;
1361 u32 base3 = 0;
1361 1362
1362 if (selector & 1 << 2) { 1363 if (selector & 1 << 2) {
1363 struct desc_struct desc; 1364 struct desc_struct desc;
1364 u16 sel; 1365 u16 sel;
1365 1366
1366 memset (dt, 0, sizeof *dt); 1367 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))
1368 return; 1370 return;
1369 1371
1370 dt->size = desc_limit_scaled(&desc); /* what if limit > 65535? */ 1372 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);
1372 } else 1374 } else
1373 ops->get_gdt(ctxt, dt); 1375 ops->get_gdt(ctxt, dt);
1374} 1376}