Skip to contentSkip to conversation

x86emul: simplify prefix handling for VMFUNC

PATCH Superseded Jan Beulich 2 participants 3 messages Sep 5, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86emul: simplify prefix handling for VMFUNC

LOCK prefixes get dealt with elsewhere and 66, F2, and F3 can all be checked for in one go by looking at vex.pfx.

xen/arch/x86/x86_emulate/x86_emulate.c +2 -2
@@ -3942,8 +3942,8 @@ x86_emulate(
             goto rdtsc;
         }
         case 0xd4: /* vmfunc */
-            generate_exception_if(lock_prefix | rep_prefix() | (vex.pfx == vex_66),
-                                  EXC_UD, -1);
+            if ( vex.pfx )
+                break;
             fail_if(ops->vmfunc == NULL);
             if ( (rc = ops->vmfunc(ctxt) != X86EMUL_OKAY) )
                 goto done;

x86emul: simplify prefix handling for VMFUNC

LOCK prefixes get dealt with elsewhere and 66, F2, and F3 can all be checked for in one go by looking at vex.pfx.

xen/arch/x86/x86_emulate/x86_emulate.c +2 -2
@@ -3942,8 +3942,8 @@ x86_emulate(
             goto rdtsc;
         }
         case 0xd4: /* vmfunc */
-            generate_exception_if(lock_prefix | rep_prefix() | (vex.pfx == vex_66),
-                                  EXC_UD, -1);
+            if ( vex.pfx )
+                break;
             fail_if(ops->vmfunc == NULL);
             if ( (rc = ops->vmfunc(ctxt) != X86EMUL_OKAY) )
                 goto done;

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

#1 lore raw
Quoted 4 lines · Jan Beulich

LOCK prefixes get dealt with elsewhere and 66, F2, and F3 can all be checked for in one go by looking at vex.pfx.

As far as subsuming the checks goes, this is fine. However, is the code actually correct? The manual makes no indication that the use of these prefixes is prohibited.

~Andrew

Quoted 7 lines

xen/arch/x86/x86_emulate/x86_emulate.c x86_emulate( · line 3949

Quoted 10 lines
xen/arch/x86/x86_emulate/x86_emulate.c +2 -2
@@ -3942,8 +3942,8 @@ x86_emulate(
             goto rdtsc;
         }
         case 0xd4: /* vmfunc */
-            generate_exception_if(lock_prefix | rep_prefix() | (vex.pfx == vex_66),
-                                  EXC_UD, -1);
+            if ( vex.pfx )
+                break;
             fail_if(ops->vmfunc == NULL);
             if ( (rc = ops->vmfunc(ctxt) != X86EMUL_OKAY) )
                 goto done;

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

#2 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 05.09.16 at 11:52, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich

LOCK prefixes get dealt with elsewhere and 66, F2, and F3 can all be checked for in one go by looking at vex.pfx.

As far as subsuming the checks goes, this is fine. However, is the code actually correct? The manual makes no indication that the use of these prefixes is prohibited.

Hmm, indeed (and I probably should have checked). Looking at e.g. XEND and XTEST (which is how I came here) I wonder though whether the manual is wrong. Let's see if we can get this figured out. Ravi, Paul: Said checks originate from commit a1b1572833 ("VMX: add VMFUNC leaf 0 (EPTP switching) to emulator"). Can you please clarify whether they got added in error, or whether you have knowledge the SDM doesn't expose?

Thanks, Jan

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