All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86emul: ignore most segment bases for 64-bit mode in is_aligned()
@ 2016-12-14 15:29 Jan Beulich
  2016-12-14 16:49 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-12-14 15:29 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

ops->read_segment() will report whatever is actually there in the
register, so we need to actively distinguish ES/CS/SS/DS from FS/GS.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1642,12 +1642,17 @@ static bool is_aligned(enum x86_segment
     /* Expecting powers of two only. */
     ASSERT(!(size & (size - 1)));
 
-    /* No alignment checking when we have no way to read segment data. */
-    if ( !ops->read_segment )
-        return true;
+    if ( mode_64bit() && seg < x86_seg_fs )
+        memset(&reg, 0, sizeof(reg));
+    else
+    {
+        /* No alignment checking when we have no way to read segment data. */
+        if ( !ops->read_segment )
+            return true;
 
-    if ( ops->read_segment(seg, &reg, ctxt) != X86EMUL_OKAY )
-        return false;
+        if ( ops->read_segment(seg, &reg, ctxt) != X86EMUL_OKAY )
+            return false;
+    }
 
     return !((reg.base + offs) & (size - 1));
 }




[-- Attachment #2: x86emul-64bit-is_aligned.patch --]
[-- Type: text/plain, Size: 1126 bytes --]

x86emul: ignore most segment bases for 64-bit mode in is_aligned()

ops->read_segment() will report whatever is actually there in the
register, so we need to actively distinguish ES/CS/SS/DS from FS/GS.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1642,12 +1642,17 @@ static bool is_aligned(enum x86_segment
     /* Expecting powers of two only. */
     ASSERT(!(size & (size - 1)));
 
-    /* No alignment checking when we have no way to read segment data. */
-    if ( !ops->read_segment )
-        return true;
+    if ( mode_64bit() && seg < x86_seg_fs )
+        memset(&reg, 0, sizeof(reg));
+    else
+    {
+        /* No alignment checking when we have no way to read segment data. */
+        if ( !ops->read_segment )
+            return true;
 
-    if ( ops->read_segment(seg, &reg, ctxt) != X86EMUL_OKAY )
-        return false;
+        if ( ops->read_segment(seg, &reg, ctxt) != X86EMUL_OKAY )
+            return false;
+    }
 
     return !((reg.base + offs) & (size - 1));
 }

[-- 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] 2+ messages in thread

* Re: [PATCH] x86emul: ignore most segment bases for 64-bit mode in is_aligned()
  2016-12-14 15:29 [PATCH] x86emul: ignore most segment bases for 64-bit mode in is_aligned() Jan Beulich
@ 2016-12-14 16:49 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2016-12-14 16:49 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 14/12/16 15:29, Jan Beulich wrote:
> ops->read_segment() will report whatever is actually there in the
> register, so we need to actively distinguish ES/CS/SS/DS from FS/GS.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-14 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 15:29 [PATCH] x86emul: ignore most segment bases for 64-bit mode in is_aligned() Jan Beulich
2016-12-14 16:49 ` Andrew Cooper

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.