Segment limits are verified in real mode, not just protected mode.

Signed-off-by: Avi Kivity <[email protected]>
---
 arch/x86/kvm/emulate.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 7281ff8..67da0ac 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -632,8 +632,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);
@@ -663,7 +661,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 */
-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to