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

[xen master] x86/emul: Simplify segment override prefix decoding



commit 489a46c1775fdc0474261418dffef0e048848c82
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Dec 28 18:41:30 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Apr 18 20:43:11 2024 +0100

    x86/emul: Simplify segment override prefix decoding
    
    x86_seg_* uses architectural encodings.  Therefore, we can fold the prefix
    handling cases together and derive the segment from the prefix byte itself.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/x86_emulate/decode.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/decode.c 
b/xen/arch/x86/x86_emulate/decode.c
index de836068fd..ee4cbdc000 100644
--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -1043,17 +1043,12 @@ int x86emul_decode(struct x86_emulate_state *s,
         case 0x67: /* address-size override */
             ad_bytes = def_ad_bytes ^ (mode_64bit() ? 12 : 6);
             break;
-        case 0x2e: /* CS override / ignored in 64-bit mode */
+        case 0x26: /* ES override */
+        case 0x2e: /* CS override */
+        case 0x36: /* SS override */
+        case 0x3e: /* DS override, all ignored in 64-bit mode */
             if ( !mode_64bit() )
-                override_seg = x86_seg_cs;
-            break;
-        case 0x3e: /* DS override / ignored in 64-bit mode */
-            if ( !mode_64bit() )
-                override_seg = x86_seg_ds;
-            break;
-        case 0x26: /* ES override / ignored in 64-bit mode */
-            if ( !mode_64bit() )
-                override_seg = x86_seg_es;
+                override_seg = (b >> 3) & 3;
             break;
         case 0x64: /* FS override */
             override_seg = x86_seg_fs;
@@ -1061,10 +1056,6 @@ int x86emul_decode(struct x86_emulate_state *s,
         case 0x65: /* GS override */
             override_seg = x86_seg_gs;
             break;
-        case 0x36: /* SS override / ignored in 64-bit mode */
-            if ( !mode_64bit() )
-                override_seg = x86_seg_ss;
-            break;
         case 0xf0: /* LOCK */
             s->lock_prefix = true;
             break;
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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