Skip to content

Commit de5b55f

Browse files
bonzinigregkh
authored andcommitted
KVM: x86: fix conversion of addresses to linear in 32-bit protected mode
commit 0c1d77f upstream. Commit e8dd2d2 ("Silence compiler warning in arch/x86/kvm/emulate.c", 2015-09-06) broke boot of the Hurd. The bug is that the "default:" case actually could modify "la", but after the patch this change is not reflected in *linear. The bug is visible whenever a non-zero segment base causes the linear address to wrap around the 4GB mark. Fixes: e8dd2d2 Reported-by: Aurelien Jarno <[email protected]> Tested-by: Aurelien Jarno <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fc90441 commit de5b55f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kvm/emulate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,10 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
650650
u16 sel;
651651

652652
la = seg_base(ctxt, addr.seg) + addr.ea;
653-
*linear = la;
654653
*max_size = 0;
655654
switch (mode) {
656655
case X86EMUL_MODE_PROT64:
656+
*linear = la;
657657
if (is_noncanonical_address(la))
658658
goto bad;
659659

@@ -662,6 +662,7 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
662662
goto bad;
663663
break;
664664
default:
665+
*linear = la = (u32)la;
665666
usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL,
666667
addr.seg);
667668
if (!usable)
@@ -689,7 +690,6 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
689690
if (size > *max_size)
690691
goto bad;
691692
}
692-
la &= (u32)-1;
693693
break;
694694
}
695695
if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0))

0 commit comments

Comments
 (0)