* [PATCH] VMX: fix realmode emulation SReg handling
@ 2016-10-28 15:24 Jan Beulich
2016-10-28 15:29 ` Andrew Cooper
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2016-10-28 15:24 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Kevin Tian, Wei Liu, Jun Nakajima
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
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@suse.com>
--- 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++ )
vmx_get_segment_register(v, s, ®[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, ®[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]);
[-- Attachment #2: VMX-SReg-numbers-changed.patch --]
[-- Type: text/plain, Size: 1446 bytes --]
VMX: fix realmode emulation SReg handling
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@suse.com>
--- 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++ )
vmx_get_segment_register(v, s, ®[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, ®[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]);
[-- Attachment #3: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] VMX: fix realmode emulation SReg handling
2016-10-28 15:24 [PATCH] VMX: fix realmode emulation SReg handling Jan Beulich
@ 2016-10-28 15:29 ` Andrew Cooper
2016-10-28 15:31 ` Wei Liu
2016-10-28 16:09 ` Jan Beulich
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2016-10-28 15:29 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Kevin Tian, Wei Liu, Jun Nakajima
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@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> 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, ®[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, ®[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@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] VMX: fix realmode emulation SReg handling
2016-10-28 15:29 ` Andrew Cooper
@ 2016-10-28 15:31 ` Wei Liu
2016-10-28 16:09 ` Jan Beulich
1 sibling, 0 replies; 4+ messages in thread
From: Wei Liu @ 2016-10-28 15:31 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Kevin Tian, Wei Liu, Jun Nakajima, Jan Beulich
On Fri, Oct 28, 2016 at 04:29:24PM +0100, Andrew Cooper wrote:
> 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@suse.com>
>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] VMX: fix realmode emulation SReg handling
2016-10-28 15:29 ` Andrew Cooper
2016-10-28 15:31 ` Wei Liu
@ 2016-10-28 16:09 ` Jan Beulich
1 sibling, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2016-10-28 16:09 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Kevin Tian, Wei Liu, Jun Nakajima
>>> On 28.10.16 at 17:29, <andrew.cooper3@citrix.com> wrote:
> On 28/10/16 16:24, Jan Beulich wrote:
>> --- 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 ; ?
How did I not notice them?
> 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?
Done both. v2 coming after another smoke test.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-28 16:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-28 15:24 [PATCH] VMX: fix realmode emulation SReg handling Jan Beulich
2016-10-28 15:29 ` Andrew Cooper
2016-10-28 15:31 ` Wei Liu
2016-10-28 16:09 ` Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.