Skip to contentSkip to conversation

x86/emul: Fix the decoding of segment overrides in 64bit mode

PATCH In review Andrew Cooper 2 participants 2 messages Feb 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/emul: Fix the decoding of segment overrides in 64bit mode

Explicit segment overides other than %fs and %gs are documented as ignored by both Intel and AMD.

In practice, this means that:

* Explicit uses of %ss don't actually yield #SS[0] for non-canonical memory references.
* Explicit uses of %{e,c,d}s don't override %rbp/%rsp-based memory references to yield #GP[0] for non-canonical memory references.

---
CC: Jan Beulich <[email protected]>

I've got 3/4's of an XTF test for this, but not enough time to get it finished in any reasable period. I noticed the issue originally when getting some unexpected results from VMX_INSTRUCTION_INFO in some unrelated nested virt work.

---
 xen/arch/x86/x86_emulate/x86_emulate.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/x86_emulate/x86_emulate.c +4 -0
index d192280..85383ea 100644
@@ -2505,6 +2505,10 @@ x86_decode(
     }
  done_prefixes:
 
+    /* %{e,c,s,d}s overrides are ignored in 64bit mode. */
+    if ( mode_64bit() && override_seg < x86_seg_fs )
+        override_seg = x86_seg_none;
+
     if ( rex_prefix & REX_W )
         op_bytes = 8;
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.02.18 at 15:41, <[email protected]> wrote:

Explicit segment overides other than %fs and %gs are documented as ignored by both Intel and AMD.

Quoted 8 lines

In practice, this means that:

* Explicit uses of %ss don't actually yield #SS[0] for non-canonical memory references.
* Explicit uses of %{e,c,d}s don't override %rbp/%rsp-based memory references to yield #GP[0] for non-canonical memory references.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel