Skip to contentSkip to conversation

x86emul: SYSRET must change CPL

PATCH In review Jan Beulich 2 participants 2 messages Apr 16, 2020 – Apr 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86emul: SYSRET must change CPL

The special AMD behavior of leaving SS mostly alone wasn't really
complete: We need to adjust CPL aka SS.DPL.

xen/arch/x86/x86_emulate/x86_emulate.c +2 -0
@@ -6022,6 +6022,8 @@ x86_emulate(
 
             /* There's explicitly no RPL adjustment here. */
             sreg.sel = (msr_val >> 48) + 8;
+            /* But DPL needs adjustment, for the new CPL to be correct. */
+            sreg.dpl = 3;
         }
 
 #ifdef __x86_64__
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jan Beulich

The special AMD behavior of leaving SS mostly alone wasn't really
complete: We need to adjust CPL aka SS.DPL.

Oops.

Quoted 12 lines
xen/arch/x86/x86_emulate/x86_emulate.c +2 -0
@@ -6022,6 +6022,8 @@ x86_emulate(
 
             /* There's explicitly no RPL adjustment here. */
             sreg.sel = (msr_val >> 48) + 8;
+            /* But DPL needs adjustment, for the new CPL to be correct. */
+            sreg.dpl = 3;
         }
 
 #ifdef __x86_64__