[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] VMX: fix realmode emulation SReg handling



On 28/10/16 16:24, Jan Beulich wrote:
> Commit 0888d36bb2 ("x86/emul: Correct the decoding of SReg3 operands")
> overlooked three places where x86_seg_cs was assumed to be zero.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>   Sorry for
breaking this (especially as I had mentally noted to do something with
these loops).

>
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1499,18 +1499,18 @@ static void vmx_update_guest_cr(struct v
>              /* Entering or leaving real mode: adjust the segment registers.
>               * Need to read them all either way, as realmode reads can update
>               * the saved values we'll use when returning to prot mode. */
> -            for ( s = x86_seg_cs ; s <= x86_seg_tr ; s++ )
> +            for ( s = 0; s <= x86_seg_tr ; s++ )

As you are changing these lines, mind dropping the space between tr and ; ?

Alternatively, swapping x86_seg_tr for ARRAY_SIZE(reg) so the indices
never get out of sync?

Finally, perhaps an extra BUILD_BUG_ON(x86_seg_tr != x86_seg_gs + 1), to
cover the expectation of this bit of code?

>                  vmx_get_segment_register(v, s, &reg[s]);
>              v->arch.hvm_vmx.vmx_realmode = realmode;
>              
>              if ( realmode )
>              {
> -                for ( s = x86_seg_cs ; s <= x86_seg_tr ; s++ )
> +                for ( s = 0; s <= x86_seg_tr ; s++ )
>                      vmx_set_segment_register(v, s, &reg[s]);
>              }
>              else 
>              {
> -                for ( s = x86_seg_cs ; s <= x86_seg_tr ; s++ ) 
> +                for ( s = 0; s <= x86_seg_tr ; s++ )
>                      if ( !(v->arch.hvm_vmx.vm86_segment_mask & (1<<s)) )
>                          vmx_set_segment_register(
>                              v, s, &v->arch.hvm_vmx.vm86_saved_seg[s]);
>
>
>


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.