diff mbox series

[3/9] x86emul: drop regs field from emulator state structure

Message ID cf5580db-3573-ec73-9e59-61aee337b2c6@suse.com (mailing list archive)
State Superseded
Headers show
Series x86emul: misc additions | expand

Commit Message

Jan Beulich April 4, 2023, 2:51 p.m. UTC
For an unclear reason 0552a8cfda43 ("x86emul: track only rIP in emulator
state") converted the original struct cpu_user_regs instance to a
pointer, rather than dropping the field altogether: The pointer merely
aliases the one in the context structure.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper April 6, 2023, 3:34 p.m. UTC | #1
On 04/04/2023 3:51 pm, Jan Beulich wrote:
> For an unclear reason 0552a8cfda43 ("x86emul: track only rIP in emulator
> state") converted the original struct cpu_user_regs instance to a
> pointer, rather than dropping the field altogether: The pointer merely
> aliases the one in the context structure.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -1013,7 +1013,6 @@  int x86emul_decode(struct x86_emulate_st
     s->ea.type = OP_NONE;
     s->ea.mem.seg = x86_seg_ds;
     s->ea.reg = PTR_POISON;
-    s->regs = ctxt->regs;
     s->ip = ctxt->regs->r(ip);
 
     s->op_bytes = def_op_bytes = ad_bytes = def_ad_bytes =
@@ -1129,7 +1128,7 @@  int x86emul_decode(struct x86_emulate_st
             default:
                 BUG(); /* Shouldn't be possible. */
             case 2:
-                if ( s->regs->eflags & X86_EFLAGS_VM )
+                if ( ctxt->regs->eflags & X86_EFLAGS_VM )
                     break;
                 /* fall through */
             case 4:
@@ -1458,33 +1457,33 @@  int x86emul_decode(struct x86_emulate_st
             switch ( s->modrm_rm )
             {
             case 0:
-                s->ea.mem.off = s->regs->bx + s->regs->si;
+                s->ea.mem.off = ctxt->regs->bx + ctxt->regs->si;
                 break;
             case 1:
-                s->ea.mem.off = s->regs->bx + s->regs->di;
+                s->ea.mem.off = ctxt->regs->bx + ctxt->regs->di;
                 break;
             case 2:
                 s->ea.mem.seg = x86_seg_ss;
-                s->ea.mem.off = s->regs->bp + s->regs->si;
+                s->ea.mem.off = ctxt->regs->bp + ctxt->regs->si;
                 break;
             case 3:
                 s->ea.mem.seg = x86_seg_ss;
-                s->ea.mem.off = s->regs->bp + s->regs->di;
+                s->ea.mem.off = ctxt->regs->bp + ctxt->regs->di;
                 break;
             case 4:
-                s->ea.mem.off = s->regs->si;
+                s->ea.mem.off = ctxt->regs->si;
                 break;
             case 5:
-                s->ea.mem.off = s->regs->di;
+                s->ea.mem.off = ctxt->regs->di;
                 break;
             case 6:
                 if ( s->modrm_mod == 0 )
                     break;
                 s->ea.mem.seg = x86_seg_ss;
-                s->ea.mem.off = s->regs->bp;
+                s->ea.mem.off = ctxt->regs->bp;
                 break;
             case 7:
-                s->ea.mem.off = s->regs->bx;
+                s->ea.mem.off = ctxt->regs->bx;
                 break;
             }
             switch ( s->modrm_mod )
@@ -1517,7 +1516,7 @@  int x86emul_decode(struct x86_emulate_st
                                      !s->evex.RX) << 4;
                 else if ( s->sib_index != 4 )
                 {
-                    s->ea.mem.off = *decode_gpr(s->regs, s->sib_index);
+                    s->ea.mem.off = *decode_gpr(ctxt->regs, s->sib_index);
                     s->ea.mem.off <<= s->sib_scale;
                 }
                 if ( (s->modrm_mod == 0) && ((sib_base & 7) == 5) )
@@ -1525,7 +1524,7 @@  int x86emul_decode(struct x86_emulate_st
                 else if ( sib_base == 4 )
                 {
                     s->ea.mem.seg  = x86_seg_ss;
-                    s->ea.mem.off += s->regs->r(sp);
+                    s->ea.mem.off += ctxt->regs->r(sp);
                     if ( !s->ext && (b == 0x8f) )
                         /* POP <rm> computes its EA post increment. */
                         s->ea.mem.off += ((mode_64bit() && (s->op_bytes == 4))
@@ -1534,16 +1533,16 @@  int x86emul_decode(struct x86_emulate_st
                 else if ( sib_base == 5 )
                 {
                     s->ea.mem.seg  = x86_seg_ss;
-                    s->ea.mem.off += s->regs->r(bp);
+                    s->ea.mem.off += ctxt->regs->r(bp);
                 }
                 else
-                    s->ea.mem.off += *decode_gpr(s->regs, sib_base);
+                    s->ea.mem.off += *decode_gpr(ctxt->regs, sib_base);
             }
             else
             {
                 generate_exception_if(d & vSIB, X86_EXC_UD);
                 s->modrm_rm |= (s->rex_prefix & 1) << 3;
-                s->ea.mem.off = *decode_gpr(s->regs, s->modrm_rm);
+                s->ea.mem.off = *decode_gpr(ctxt->regs, s->modrm_rm);
                 if ( (s->modrm_rm == 5) && (s->modrm_mod != 0) )
                     s->ea.mem.seg = x86_seg_ss;
             }
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -321,7 +321,6 @@  struct x86_emulate_state {
 #define imm2 ea.orig_val
 
     unsigned long ip;
-    struct cpu_user_regs *regs;
 
 #ifndef NDEBUG
     /*