]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86/emul: Adjust put_fpu()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 30 Dec 2024 16:31:46 +0000 (16:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Jan 2025 14:19:10 +0000 (14:19 +0000)
The use of regs->?s here is buggy in almost all cases.  For HVM guests,
they're poison from hvm_sanitize_regs_fields(), and for PV guests the data
segment selectors are stale from the last context switch.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
I'm honestly not sure what this path is doing here.  The only user of FPU
emulation is HVM guests, which has working read_segment().

xen/arch/x86/x86_emulate/x86_emulate.c

index b89d4401339b7dc6c6a25cd78fc8bf035d6a0aa2..1502425cac1825043f57fac78c39358a606f2a7a 100644 (file)
@@ -450,19 +450,10 @@ static void put_fpu(
             if ( ops->read_segment &&
                  ops->read_segment(state->ea.mem.seg, &sreg,
                                    ctxt) == X86EMUL_OKAY )
+            {
                 aux.ds = sreg.sel;
-            else
-                switch ( state->ea.mem.seg )
-                {
-                case x86_seg_cs: aux.ds = ctxt->regs->cs; break;
-                case x86_seg_ds: aux.ds = ctxt->regs->ds; break;
-                case x86_seg_es: aux.ds = ctxt->regs->es; break;
-                case x86_seg_fs: aux.ds = ctxt->regs->fs; break;
-                case x86_seg_gs: aux.ds = ctxt->regs->gs; break;
-                case x86_seg_ss: aux.ds = ctxt->regs->ss; break;
-                default:         ASSERT_UNREACHABLE();    break;
-                }
-            aux.dval = true;
+                aux.dval = true;
+            }
         }
         ops->put_fpu(ctxt, X86EMUL_FPU_none, &aux);
     }