diff options
author | Avi Kivity <avi@redhat.com> | 2012-08-21 10:07:04 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-08-27 19:02:20 -0400 |
commit | 03ebebeb1ff5d1d6209fd8df4ffc9204df82bd55 (patch) | |
tree | 47af40344c5f609e34acbc9136fe5c04b2893282 /arch/x86/kvm | |
parent | e2a610d7fc3e285af8061ff071761752255d95f6 (diff) |
KVM: x86 emulator: Leave segment limit and attributs alone in real mode
When loading a segment in real mode, only the base and selector must
be modified. The limit needs to be left alone, otherwise big real mode
users will hit a #GP due to limit checking (currently this is suppressed
because we don't check limits in real mode).
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/emulate.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 5e27ba532613..f8b27cd2a6cb 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1388,19 +1388,15 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt, | |||
1388 | bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */ | 1388 | bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */ |
1389 | ulong desc_addr; | 1389 | ulong desc_addr; |
1390 | int ret; | 1390 | int ret; |
1391 | u16 dummy; | ||
1391 | 1392 | ||
1392 | memset(&seg_desc, 0, sizeof seg_desc); | 1393 | memset(&seg_desc, 0, sizeof seg_desc); |
1393 | 1394 | ||
1394 | if ((seg <= VCPU_SREG_GS && ctxt->mode == X86EMUL_MODE_VM86) | 1395 | if ((seg <= VCPU_SREG_GS && ctxt->mode == X86EMUL_MODE_VM86) |
1395 | || ctxt->mode == X86EMUL_MODE_REAL) { | 1396 | || ctxt->mode == X86EMUL_MODE_REAL) { |
1396 | /* set real mode segment descriptor */ | 1397 | /* set real mode segment descriptor */ |
1398 | ctxt->ops->get_segment(ctxt, &dummy, &seg_desc, NULL, seg); | ||
1397 | set_desc_base(&seg_desc, selector << 4); | 1399 | set_desc_base(&seg_desc, selector << 4); |
1398 | set_desc_limit(&seg_desc, 0xffff); | ||
1399 | seg_desc.type = 3; | ||
1400 | seg_desc.p = 1; | ||
1401 | seg_desc.s = 1; | ||
1402 | if (ctxt->mode == X86EMUL_MODE_VM86) | ||
1403 | seg_desc.dpl = 3; | ||
1404 | goto load; | 1400 | goto load; |
1405 | } | 1401 | } |
1406 | 1402 | ||