Skip to content

Commit

Permalink
KVM: x86 emulator: Check segment limits in real mode too
Browse files Browse the repository at this point in the history
Segment limits are verified in real mode, not just protected mode.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Avi Kivity authored and Marcelo Tosatti committed Aug 27, 2012
1 parent 03ebebe commit a562518
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arch/x86/kvm/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,

la = seg_base(ctxt, addr.seg) + addr.ea;
switch (ctxt->mode) {
case X86EMUL_MODE_REAL:
break;
case X86EMUL_MODE_PROT64:
if (((signed long)la << 16) >> 16 != la)
return emulate_gp(ctxt, 0);
Expand Down Expand Up @@ -699,7 +697,10 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
goto bad;
}
cpl = ctxt->ops->cpl(ctxt);
rpl = sel & 3;
if (ctxt->mode == X86EMUL_MODE_REAL)
rpl = 0;
else
rpl = sel & 3;
cpl = max(cpl, rpl);
if (!(desc.type & 8)) {
/* data segment */
Expand Down

0 comments on commit a562518

Please sign in to comment.