Skip to contentSkip to conversation

x86/emul: Fix the emulation of invlpga

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/emul: Fix the emulation of invlpga

The instruction requires EFER.SVME set to be usable in the first place.

Furthermore, the emulation doesn't handle ASIDs, so avoid giving the impression that they work. Permit ASID 0 which is reserved for non-root mode (in which case the instruction is identical to invlpg), but raise #UD for any other ASID.

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

---
 xen/arch/x86/x86_emulate/x86_emulate.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
xen/arch/x86/x86_emulate/x86_emulate.c +8 -1
index f22f821..9f18567 100644
@@ -5121,8 +5121,15 @@ x86_emulate(
             break;
 
         case 0xdf: /* invlpga */
-            generate_exception_if(!in_protmode(ctxt, ops), EXC_UD);
+            fail_if(!ops->read_msr);
+            if ( (rc = ops->read_msr(MSR_EFER,
+                                     &msr_val, ctxt)) != X86EMUL_OKAY )
+                goto done;
+            /* Finding SVME set implies vcpu_has_svm(). */
+            generate_exception_if(!(msr_val & EFER_SVME) ||
+                                  !in_protmode(ctxt, ops), EXC_UD);
             generate_exception_if(!mode_ring0(), EXC_GP, 0);
+            generate_exception_if(regs->ecx, EXC_UD); /* TODO: Support ASIDs. */
             fail_if(ops->invlpg == NULL);
             if ( (rc = ops->invlpg(x86_seg_none, truncate_ea(_regs.r(ax)),
                                    ctxt)) )
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 9 lines
Quoted 1 line
Quoted 1 line · On 05.02.18 at 11:38, <[email protected]> wrote:

The instruction requires EFER.SVME set to be usable in the first place.

Furthermore, the emulation doesn't handle ASIDs, so avoid giving the impression that they work. Permit ASID 0 which is reserved for non-root mode (in which case the instruction is identical to invlpg), but raise #UD for any other ASID.

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