* [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode
@ 2016-11-02 16:12 Jan Beulich
2016-11-02 17:42 ` Andrew Cooper
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2016-11-02 16:12 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Wei Liu
[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]
This affects not only the layout of the data (always 2+8 bytes), but
also the contents (no truncation to 24 bits occurs).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This will only apply cleanly on top of
https://lists.xenproject.org/archives/html/xen-devel/2016-11/msg00170.html.
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -4424,7 +4424,7 @@ x86_emulate(
fail_if(ops->read_segment == NULL);
if ( (rc = ops->read_segment(seg, &sreg, ctxt)) )
goto done;
- if ( op_bytes == 2 )
+ if ( !mode_64bit() && op_bytes == 2 )
sreg.base &= 0xffffff;
if ( (rc = ops->write(ea.mem.seg, ea.mem.off+0,
&sreg.limit, 2, ctxt)) ||
@@ -4447,7 +4447,7 @@ x86_emulate(
!is_canonical_address(base), EXC_GP, 0);
sreg.base = base;
sreg.limit = limit;
- if ( op_bytes == 2 )
+ if ( !mode_64bit() && op_bytes == 2 )
sreg.base &= 0xffffff;
if ( (rc = ops->write_segment(seg, &sreg, ctxt)) )
goto done;
[-- Attachment #2: x86emul-LxDT-SxDT-64bit.patch --]
[-- Type: text/plain, Size: 1292 bytes --]
x86emul: {L,S}{G,I}DT ignore operand size overrides in 64-bit mode
This affects not only the layout of the data (always 2+8 bytes), but
also the contents (no truncation to 24 bits occurs).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This will only apply cleanly on top of
https://lists.xenproject.org/archives/html/xen-devel/2016-11/msg00170.html.
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -4424,7 +4424,7 @@ x86_emulate(
fail_if(ops->read_segment == NULL);
if ( (rc = ops->read_segment(seg, &sreg, ctxt)) )
goto done;
- if ( op_bytes == 2 )
+ if ( !mode_64bit() && op_bytes == 2 )
sreg.base &= 0xffffff;
if ( (rc = ops->write(ea.mem.seg, ea.mem.off+0,
&sreg.limit, 2, ctxt)) ||
@@ -4447,7 +4447,7 @@ x86_emulate(
!is_canonical_address(base), EXC_GP, 0);
sreg.base = base;
sreg.limit = limit;
- if ( op_bytes == 2 )
+ if ( !mode_64bit() && op_bytes == 2 )
sreg.base &= 0xffffff;
if ( (rc = ops->write_segment(seg, &sreg, ctxt)) )
goto done;
[-- 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] 5+ messages in thread
* Re: [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode
2016-11-02 16:12 [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode Jan Beulich
@ 2016-11-02 17:42 ` Andrew Cooper
2016-11-03 8:06 ` Jan Beulich
2016-11-03 10:43 ` Wei Liu
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cooper @ 2016-11-02 17:42 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Wei Liu
On 02/11/16 16:12, Jan Beulich wrote:
> This affects not only the layout of the data (always 2+8 bytes), but
> also the contents (no truncation to 24 bits occurs).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although
wouldn't it be cleaner to set op_bytes = def_op_bytes, than to keep
referring back to mode_64()?
~Andrew
> ---
> This will only apply cleanly on top of
> https://lists.xenproject.org/archives/html/xen-devel/2016-11/msg00170.html.
>
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -4424,7 +4424,7 @@ x86_emulate(
> fail_if(ops->read_segment == NULL);
> if ( (rc = ops->read_segment(seg, &sreg, ctxt)) )
> goto done;
> - if ( op_bytes == 2 )
> + if ( !mode_64bit() && op_bytes == 2 )
> sreg.base &= 0xffffff;
> if ( (rc = ops->write(ea.mem.seg, ea.mem.off+0,
> &sreg.limit, 2, ctxt)) ||
> @@ -4447,7 +4447,7 @@ x86_emulate(
> !is_canonical_address(base), EXC_GP, 0);
> sreg.base = base;
> sreg.limit = limit;
> - if ( op_bytes == 2 )
> + if ( !mode_64bit() && op_bytes == 2 )
> sreg.base &= 0xffffff;
> if ( (rc = ops->write_segment(seg, &sreg, ctxt)) )
> goto done;
>
>
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode
2016-11-02 17:42 ` Andrew Cooper
@ 2016-11-03 8:06 ` Jan Beulich
2016-11-03 11:18 ` Andrew Cooper
2016-11-03 10:43 ` Wei Liu
1 sibling, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2016-11-03 8:06 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Wei Liu
>>> On 02.11.16 at 18:42, <andrew.cooper3@citrix.com> wrote:
> On 02/11/16 16:12, Jan Beulich wrote:
>> This affects not only the layout of the data (always 2+8 bytes), but
>> also the contents (no truncation to 24 bits occurs).
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although
> wouldn't it be cleaner to set op_bytes = def_op_bytes, than to keep
> referring back to mode_64()?
That would still mean
if ( mode_64bit() )
op_bytes = def_op_bytes;
and wouldn't eliminate the uses in the second ops->write() /
read_ulong() either.
What we could do in the S{G,I}DT case is
if ( mode_64bit() )
op_bytes = 8;
else if ( op_bytes == 2 )
{
sreg.base &= 0xffffff;
op_bytes = 4;
}
if ( (rc = ops->write(ea.mem.seg, ea.mem.off+0,
&sreg.limit, 2, ctxt)) ||
(rc = ops->write(ea.mem.seg, ea.mem.off+2,
&sreg.base, op_bytes, ctxt)) )
But the same can't be done in the L{G,I}DT case. Let me know.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode
2016-11-02 17:42 ` Andrew Cooper
2016-11-03 8:06 ` Jan Beulich
@ 2016-11-03 10:43 ` Wei Liu
1 sibling, 0 replies; 5+ messages in thread
From: Wei Liu @ 2016-11-03 10:43 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Wei Liu, Jan Beulich
On Wed, Nov 02, 2016 at 05:42:53PM +0000, Andrew Cooper wrote:
> On 02/11/16 16:12, Jan Beulich wrote:
> > This affects not only the layout of the data (always 2+8 bytes), but
> > also the contents (no truncation to 24 bits occurs).
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although
> wouldn't it be cleaner to set op_bytes = def_op_bytes, than to keep
> referring back to mode_64()?
>
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] 5+ messages in thread
* Re: [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode
2016-11-03 8:06 ` Jan Beulich
@ 2016-11-03 11:18 ` Andrew Cooper
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2016-11-03 11:18 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Wei Liu
On 03/11/16 08:06, Jan Beulich wrote:
>>>> On 02.11.16 at 18:42, <andrew.cooper3@citrix.com> wrote:
>> On 02/11/16 16:12, Jan Beulich wrote:
>>> This affects not only the layout of the data (always 2+8 bytes), but
>>> also the contents (no truncation to 24 bits occurs).
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although
>> wouldn't it be cleaner to set op_bytes = def_op_bytes, than to keep
>> referring back to mode_64()?
> That would still mean
>
> if ( mode_64bit() )
> op_bytes = def_op_bytes;
Oh true.
>
> and wouldn't eliminate the uses in the second ops->write() /
> read_ulong() either.
>
> What we could do in the S{G,I}DT case is
>
> if ( mode_64bit() )
> op_bytes = 8;
> else if ( op_bytes == 2 )
> {
> sreg.base &= 0xffffff;
> op_bytes = 4;
> }
> if ( (rc = ops->write(ea.mem.seg, ea.mem.off+0,
> &sreg.limit, 2, ctxt)) ||
> (rc = ops->write(ea.mem.seg, ea.mem.off+2,
> &sreg.base, op_bytes, ctxt)) )
>
> But the same can't be done in the L{G,I}DT case. Let me know.
This does look a little cleaner, even if it is only for the sgdt/sidt case.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-03 11:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-02 16:12 [PATCH] x86emul: {L, S}{G, I}DT ignore operand size overrides in 64-bit mode Jan Beulich
2016-11-02 17:42 ` Andrew Cooper
2016-11-03 8:06 ` Jan Beulich
2016-11-03 11:18 ` Andrew Cooper
2016-11-03 10:43 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).