]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86emul: support SWAPGS
authorJan Beulich <jbeulich@suse.com>
Tue, 6 Mar 2018 15:44:03 +0000 (16:44 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 6 Mar 2018 15:44:03 +0000 (16:44 +0100)
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/x86_emulate/x86_emulate.c

index 95b792aad3de9b1f9e2bebaf688ec5d5f8608df4..49b157d8cf51264b8cd7358e6212a415ab2c3364 100644 (file)
@@ -5019,6 +5019,28 @@ x86_emulate(
                 goto done;
             break;
 
+        case 0xf8: /* swapgs */
+            generate_exception_if(!mode_64bit(), EXC_UD);
+            generate_exception_if(!mode_ring0(), EXC_GP, 0);
+            fail_if(!ops->read_segment || !ops->read_msr ||
+                    !ops->write_segment || !ops->write_msr);
+            if ( (rc = ops->read_segment(x86_seg_gs, &sreg,
+                                         ctxt)) != X86EMUL_OKAY ||
+                 (rc = ops->read_msr(MSR_SHADOW_GS_BASE, &msr_val,
+                                     ctxt)) != X86EMUL_OKAY ||
+                 (rc = ops->write_msr(MSR_SHADOW_GS_BASE, sreg.base,
+                                      ctxt)) != X86EMUL_OKAY )
+                goto done;
+            sreg.base = msr_val;
+            if ( (rc = ops->write_segment(x86_seg_gs, &sreg,
+                                          ctxt)) != X86EMUL_OKAY )
+            {
+                /* Best effort unwind (i.e. no error checking). */
+                ops->write_msr(MSR_SHADOW_GS_BASE, msr_val, ctxt);
+                goto done;
+            }
+            break;
+
         case 0xf9: /* rdtscp */
             fail_if(ops->read_msr == NULL);
             if ( (rc = ops->read_msr(MSR_TSC_AUX,