diff mbox series

[v3,16/39] target/m68k: Use env_cpu, env_archcpu

Message ID 20190508000641.19090-17-richard.henderson@linaro.org
State Superseded
Headers show
Series tcg: Move the softmmu tlb to CPUNegativeOffsetState | expand

Commit Message

Richard Henderson May 8, 2019, 12:06 a.m. UTC
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/m68k/target_cpu.h |  2 +-
 target/m68k/cpu.h            |  5 -----
 linux-user/m68k-sim.c        |  3 +--
 linux-user/m68k/cpu_loop.c   |  2 +-
 target/m68k/helper.c         | 33 ++++++++++++---------------------
 target/m68k/m68k-semi.c      |  4 ++--
 target/m68k/op_helper.c      | 12 ++++++------
 target/m68k/translate.c      |  4 +---
 8 files changed, 24 insertions(+), 41 deletions(-)

-- 
2.17.1

Comments

Alistair Francis May 9, 2019, 6:16 p.m. UTC | #1
On Tue, May 7, 2019 at 5:16 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Reviewed-by: Alistair Francis <alistair.francis@wdc.com>


Alistair

> ---

>  linux-user/m68k/target_cpu.h |  2 +-

>  target/m68k/cpu.h            |  5 -----

>  linux-user/m68k-sim.c        |  3 +--

>  linux-user/m68k/cpu_loop.c   |  2 +-

>  target/m68k/helper.c         | 33 ++++++++++++---------------------

>  target/m68k/m68k-semi.c      |  4 ++--

>  target/m68k/op_helper.c      | 12 ++++++------

>  target/m68k/translate.c      |  4 +---

>  8 files changed, 24 insertions(+), 41 deletions(-)

>

> diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h

> index 7a26f3c3fc..bc7446fbaf 100644

> --- a/linux-user/m68k/target_cpu.h

> +++ b/linux-user/m68k/target_cpu.h

> @@ -31,7 +31,7 @@ static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp)

>

>  static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls)

>  {

> -    CPUState *cs = CPU(m68k_env_get_cpu(env));

> +    CPUState *cs = env_cpu(env);

>      TaskState *ts = cs->opaque;

>

>      ts->tp_value = newtls;

> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h

> index 43ef30b7cb..f8d5a0819b 100644

> --- a/target/m68k/cpu.h

> +++ b/target/m68k/cpu.h

> @@ -163,11 +163,6 @@ struct M68kCPU {

>      CPUM68KState env;

>  };

>

> -static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)

> -{

> -    return container_of(env, M68kCPU, env);

> -}

> -

>  #define ENV_OFFSET offsetof(M68kCPU, env)

>

>  void m68k_cpu_do_interrupt(CPUState *cpu);

> diff --git a/linux-user/m68k-sim.c b/linux-user/m68k-sim.c

> index 34d332d8b1..9bc6ff3d3a 100644

> --- a/linux-user/m68k-sim.c

> +++ b/linux-user/m68k-sim.c

> @@ -91,7 +91,6 @@ static int translate_openflags(int flags)

>  #define ARG(x) tswap32(args[x])

>  void do_m68k_simcall(CPUM68KState *env, int nr)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

>      uint32_t *args;

>

>      args = (uint32_t *)(unsigned long)(env->aregs[7] + 4);

> @@ -159,6 +158,6 @@ void do_m68k_simcall(CPUM68KState *env, int nr)

>          check_err(env, lseek(ARG(0), (int32_t)ARG(1), ARG(2)));

>          break;

>      default:

> -        cpu_abort(CPU(cpu), "Unsupported m68k sim syscall %d\n", nr);

> +        cpu_abort(env_cpu(env), "Unsupported m68k sim syscall %d\n", nr);

>      }

>  }

> diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c

> index 42d8d841ea..f2c33057b3 100644

> --- a/linux-user/m68k/cpu_loop.c

> +++ b/linux-user/m68k/cpu_loop.c

> @@ -23,7 +23,7 @@

>

>  void cpu_loop(CPUM68KState *env)

>  {

> -    CPUState *cs = CPU(m68k_env_get_cpu(env));

> +    CPUState *cs = env_cpu(env);

>      int trapnr;

>      unsigned int n;

>      target_siginfo_t info;

> diff --git a/target/m68k/helper.c b/target/m68k/helper.c

> index d958a34959..6699f056a4 100644

> --- a/target/m68k/helper.c

> +++ b/target/m68k/helper.c

> @@ -168,8 +168,6 @@ void m68k_cpu_init_gdb(M68kCPU *cpu)

>

>  void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -

>      switch (reg) {

>      case M68K_CR_CACR:

>          env->cacr = val;

> @@ -186,7 +184,7 @@ void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)

>          break;

>      /* TODO: Implement control registers.  */

>      default:

> -        cpu_abort(CPU(cpu),

> +        cpu_abort(env_cpu(env),

>                    "Unimplemented control register write 0x%x = 0x%x\n",

>                    reg, val);

>      }

> @@ -194,8 +192,6 @@ void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)

>

>  void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -

>      switch (reg) {

>      /* MC680[1234]0 */

>      case M68K_CR_SFC:

> @@ -248,14 +244,13 @@ void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)

>          env->mmu.ttr[M68K_DTTR1] = val;

>          return;

>      }

> -    cpu_abort(CPU(cpu), "Unimplemented control register write 0x%x = 0x%x\n",

> +    cpu_abort(env_cpu(env),

> +              "Unimplemented control register write 0x%x = 0x%x\n",

>                reg, val);

>  }

>

>  uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -

>      switch (reg) {

>      /* MC680[1234]0 */

>      case M68K_CR_SFC:

> @@ -292,7 +287,7 @@ uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)

>      case M68K_CR_DTT1:

>          return env->mmu.ttr[M68K_DTTR1];

>      }

> -    cpu_abort(CPU(cpu), "Unimplemented control register read 0x%x\n",

> +    cpu_abort(env_cpu(env), "Unimplemented control register read 0x%x\n",

>                reg);

>  }

>

> @@ -401,8 +396,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)

>      uint32_t last_logical, last_physical;

>      int32_t size;

>      int last_attr = -1, attr = -1;

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -    CPUState *cs = CPU(cpu);

> +    CPUState *cs = env_cpu(env);

>

>      if (env->mmu.tcr & M68K_TCR_PAGE_8K) {

>          /* 8k page */

> @@ -635,8 +629,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,

>                                  int *prot, target_ulong address,

>                                  int access_type, target_ulong *page_size)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -    CPUState *cs = CPU(cpu);

> +    CPUState *cs = env_cpu(env);

>      uint32_t entry;

>      uint32_t next;

>      target_ulong page_mask;

> @@ -1128,7 +1121,7 @@ void HELPER(mac_set_flags)(CPUM68KState *env, uint32_t acc)

>          z = n;                                                             \

>          break;                                                             \

>      default:                                                               \

> -        cpu_abort(CPU(m68k_env_get_cpu(env)), "Bad CC_OP %d", op);         \

> +        cpu_abort(env_cpu(env), "Bad CC_OP %d", op);                       \

>      }                                                                      \

>  } while (0)

>

> @@ -1311,8 +1304,6 @@ void HELPER(set_mac_extu)(CPUM68KState *env, uint32_t val, uint32_t acc)

>  #if defined(CONFIG_SOFTMMU)

>  void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -    CPUState *cs = CPU(cpu);

>      hwaddr physical;

>      int access_type;

>      int prot;

> @@ -1337,7 +1328,7 @@ void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)

>      if (ret == 0) {

>          addr &= TARGET_PAGE_MASK;

>          physical += addr & (page_size - 1);

> -        tlb_set_page(cs, addr, physical,

> +        tlb_set_page(env_cpu(env), addr, physical,

>                       prot, access_type & ACCESS_SUPER ?

>                       MMU_KERNEL_IDX : MMU_USER_IDX, page_size);

>      }

> @@ -1345,18 +1336,18 @@ void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)

>

>  void HELPER(pflush)(CPUM68KState *env, uint32_t addr, uint32_t opmode)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> +    CPUState *cs = env_cpu(env);

>

>      switch (opmode) {

>      case 0: /* Flush page entry if not global */

>      case 1: /* Flush page entry */

> -        tlb_flush_page(CPU(cpu), addr);

> +        tlb_flush_page(cs, addr);

>          break;

>      case 2: /* Flush all except global entries */

> -        tlb_flush(CPU(cpu));

> +        tlb_flush(cs);

>          break;

>      case 3: /* Flush all entries */

> -        tlb_flush(CPU(cpu));

> +        tlb_flush(cs);

>          break;

>      }

>  }

> diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c

> index 1402145c8f..6716b93b5a 100644

> --- a/target/m68k/m68k-semi.c

> +++ b/target/m68k/m68k-semi.c

> @@ -421,7 +421,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)

>      case HOSTED_INIT_SIM:

>  #if defined(CONFIG_USER_ONLY)

>          {

> -        CPUState *cs = CPU(m68k_env_get_cpu(env));

> +        CPUState *cs = env_cpu(env);

>          TaskState *ts = cs->opaque;

>          /* Allocate the heap using sbrk.  */

>          if (!ts->heap_limit) {

> @@ -454,7 +454,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)

>  #endif

>          return;

>      default:

> -        cpu_abort(CPU(m68k_env_get_cpu(env)), "Unsupported semihosting syscall %d\n", nr);

> +        cpu_abort(env_cpu(env), "Unsupported semihosting syscall %d\n", nr);

>          result = 0;

>      }

>  failed:

> diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c

> index 13fcaa74ef..39aa9310e1 100644

> --- a/target/m68k/op_helper.c

> +++ b/target/m68k/op_helper.c

> @@ -211,7 +211,7 @@ static const char *m68k_exception_name(int index)

>

>  static void cf_interrupt_all(CPUM68KState *env, int is_hw)

>  {

> -    CPUState *cs = CPU(m68k_env_get_cpu(env));

> +    CPUState *cs = env_cpu(env);

>      uint32_t sp;

>      uint32_t sr;

>      uint32_t fmt;

> @@ -289,7 +289,7 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,

>  {

>      if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {

>          /*  all except 68000 */

> -        CPUState *cs = CPU(m68k_env_get_cpu(env));

> +        CPUState *cs = env_cpu(env);

>          switch (format) {

>          case 4:

>              *sp -= 4;

> @@ -314,7 +314,7 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,

>

>  static void m68k_interrupt_all(CPUM68KState *env, int is_hw)

>  {

> -    CPUState *cs = CPU(m68k_env_get_cpu(env));

> +    CPUState *cs = env_cpu(env);

>      uint32_t sp;

>      uint32_t retaddr;

>      uint32_t vector;

> @@ -526,7 +526,7 @@ bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request)

>

>  static void raise_exception_ra(CPUM68KState *env, int tt, uintptr_t raddr)

>  {

> -    CPUState *cs = CPU(m68k_env_get_cpu(env));

> +    CPUState *cs = env_cpu(env);

>

>      cs->exception_index = tt;

>      cpu_loop_exit_restore(cs, raddr);

> @@ -1056,7 +1056,7 @@ void HELPER(chk)(CPUM68KState *env, int32_t val, int32_t ub)

>      env->cc_c = 0 <= ub ? val < 0 || val > ub : val > ub && val < 0;

>

>      if (val < 0 || val > ub) {

> -        CPUState *cs = CPU(m68k_env_get_cpu(env));

> +        CPUState *cs = env_cpu(env);

>

>          /* Recover PC and CC_OP for the beginning of the insn.  */

>          cpu_restore_state(cs, GETPC(), true);

> @@ -1087,7 +1087,7 @@ void HELPER(chk2)(CPUM68KState *env, int32_t val, int32_t lb, int32_t ub)

>      env->cc_c = lb <= ub ? val < lb || val > ub : val > ub && val < lb;

>

>      if (env->cc_c) {

> -        CPUState *cs = CPU(m68k_env_get_cpu(env));

> +        CPUState *cs = env_cpu(env);

>

>          /* Recover PC and CC_OP for the beginning of the insn.  */

>          cpu_restore_state(cs, GETPC(), true);

> diff --git a/target/m68k/translate.c b/target/m68k/translate.c

> index 58596278c2..e206b5e78a 100644

> --- a/target/m68k/translate.c

> +++ b/target/m68k/translate.c

> @@ -4778,14 +4778,12 @@ DISAS_INSN(wddata)

>

>  DISAS_INSN(wdebug)

>  {

> -    M68kCPU *cpu = m68k_env_get_cpu(env);

> -

>      if (IS_USER(s)) {

>          gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);

>          return;

>      }

>      /* TODO: Implement wdebug.  */

> -    cpu_abort(CPU(cpu), "WDEBUG not implemented");

> +    cpu_abort(env_cpu(env), "WDEBUG not implemented");

>  }

>  #endif

>

> --

> 2.17.1

>

>
diff mbox series

Patch

diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h
index 7a26f3c3fc..bc7446fbaf 100644
--- a/linux-user/m68k/target_cpu.h
+++ b/linux-user/m68k/target_cpu.h
@@ -31,7 +31,7 @@  static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp)
 
 static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls)
 {
-    CPUState *cs = CPU(m68k_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
     TaskState *ts = cs->opaque;
 
     ts->tp_value = newtls;
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 43ef30b7cb..f8d5a0819b 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -163,11 +163,6 @@  struct M68kCPU {
     CPUM68KState env;
 };
 
-static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)
-{
-    return container_of(env, M68kCPU, env);
-}
-
 #define ENV_OFFSET offsetof(M68kCPU, env)
 
 void m68k_cpu_do_interrupt(CPUState *cpu);
diff --git a/linux-user/m68k-sim.c b/linux-user/m68k-sim.c
index 34d332d8b1..9bc6ff3d3a 100644
--- a/linux-user/m68k-sim.c
+++ b/linux-user/m68k-sim.c
@@ -91,7 +91,6 @@  static int translate_openflags(int flags)
 #define ARG(x) tswap32(args[x])
 void do_m68k_simcall(CPUM68KState *env, int nr)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
     uint32_t *args;
 
     args = (uint32_t *)(unsigned long)(env->aregs[7] + 4);
@@ -159,6 +158,6 @@  void do_m68k_simcall(CPUM68KState *env, int nr)
         check_err(env, lseek(ARG(0), (int32_t)ARG(1), ARG(2)));
         break;
     default:
-        cpu_abort(CPU(cpu), "Unsupported m68k sim syscall %d\n", nr);
+        cpu_abort(env_cpu(env), "Unsupported m68k sim syscall %d\n", nr);
     }
 }
diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c
index 42d8d841ea..f2c33057b3 100644
--- a/linux-user/m68k/cpu_loop.c
+++ b/linux-user/m68k/cpu_loop.c
@@ -23,7 +23,7 @@ 
 
 void cpu_loop(CPUM68KState *env)
 {
-    CPUState *cs = CPU(m68k_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
     int trapnr;
     unsigned int n;
     target_siginfo_t info;
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index d958a34959..6699f056a4 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -168,8 +168,6 @@  void m68k_cpu_init_gdb(M68kCPU *cpu)
 
 void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-
     switch (reg) {
     case M68K_CR_CACR:
         env->cacr = val;
@@ -186,7 +184,7 @@  void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)
         break;
     /* TODO: Implement control registers.  */
     default:
-        cpu_abort(CPU(cpu),
+        cpu_abort(env_cpu(env),
                   "Unimplemented control register write 0x%x = 0x%x\n",
                   reg, val);
     }
@@ -194,8 +192,6 @@  void HELPER(cf_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)
 
 void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-
     switch (reg) {
     /* MC680[1234]0 */
     case M68K_CR_SFC:
@@ -248,14 +244,13 @@  void HELPER(m68k_movec_to)(CPUM68KState *env, uint32_t reg, uint32_t val)
         env->mmu.ttr[M68K_DTTR1] = val;
         return;
     }
-    cpu_abort(CPU(cpu), "Unimplemented control register write 0x%x = 0x%x\n",
+    cpu_abort(env_cpu(env),
+              "Unimplemented control register write 0x%x = 0x%x\n",
               reg, val);
 }
 
 uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-
     switch (reg) {
     /* MC680[1234]0 */
     case M68K_CR_SFC:
@@ -292,7 +287,7 @@  uint32_t HELPER(m68k_movec_from)(CPUM68KState *env, uint32_t reg)
     case M68K_CR_DTT1:
         return env->mmu.ttr[M68K_DTTR1];
     }
-    cpu_abort(CPU(cpu), "Unimplemented control register read 0x%x\n",
+    cpu_abort(env_cpu(env), "Unimplemented control register read 0x%x\n",
               reg);
 }
 
@@ -401,8 +396,7 @@  static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)
     uint32_t last_logical, last_physical;
     int32_t size;
     int last_attr = -1, attr = -1;
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-    CPUState *cs = CPU(cpu);
+    CPUState *cs = env_cpu(env);
 
     if (env->mmu.tcr & M68K_TCR_PAGE_8K) {
         /* 8k page */
@@ -635,8 +629,7 @@  static int get_physical_address(CPUM68KState *env, hwaddr *physical,
                                 int *prot, target_ulong address,
                                 int access_type, target_ulong *page_size)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-    CPUState *cs = CPU(cpu);
+    CPUState *cs = env_cpu(env);
     uint32_t entry;
     uint32_t next;
     target_ulong page_mask;
@@ -1128,7 +1121,7 @@  void HELPER(mac_set_flags)(CPUM68KState *env, uint32_t acc)
         z = n;                                                             \
         break;                                                             \
     default:                                                               \
-        cpu_abort(CPU(m68k_env_get_cpu(env)), "Bad CC_OP %d", op);         \
+        cpu_abort(env_cpu(env), "Bad CC_OP %d", op);                       \
     }                                                                      \
 } while (0)
 
@@ -1311,8 +1304,6 @@  void HELPER(set_mac_extu)(CPUM68KState *env, uint32_t val, uint32_t acc)
 #if defined(CONFIG_SOFTMMU)
 void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-    CPUState *cs = CPU(cpu);
     hwaddr physical;
     int access_type;
     int prot;
@@ -1337,7 +1328,7 @@  void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)
     if (ret == 0) {
         addr &= TARGET_PAGE_MASK;
         physical += addr & (page_size - 1);
-        tlb_set_page(cs, addr, physical,
+        tlb_set_page(env_cpu(env), addr, physical,
                      prot, access_type & ACCESS_SUPER ?
                      MMU_KERNEL_IDX : MMU_USER_IDX, page_size);
     }
@@ -1345,18 +1336,18 @@  void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)
 
 void HELPER(pflush)(CPUM68KState *env, uint32_t addr, uint32_t opmode)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
+    CPUState *cs = env_cpu(env);
 
     switch (opmode) {
     case 0: /* Flush page entry if not global */
     case 1: /* Flush page entry */
-        tlb_flush_page(CPU(cpu), addr);
+        tlb_flush_page(cs, addr);
         break;
     case 2: /* Flush all except global entries */
-        tlb_flush(CPU(cpu));
+        tlb_flush(cs);
         break;
     case 3: /* Flush all entries */
-        tlb_flush(CPU(cpu));
+        tlb_flush(cs);
         break;
     }
 }
diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 1402145c8f..6716b93b5a 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -421,7 +421,7 @@  void do_m68k_semihosting(CPUM68KState *env, int nr)
     case HOSTED_INIT_SIM:
 #if defined(CONFIG_USER_ONLY)
         {
-        CPUState *cs = CPU(m68k_env_get_cpu(env));
+        CPUState *cs = env_cpu(env);
         TaskState *ts = cs->opaque;
         /* Allocate the heap using sbrk.  */
         if (!ts->heap_limit) {
@@ -454,7 +454,7 @@  void do_m68k_semihosting(CPUM68KState *env, int nr)
 #endif
         return;
     default:
-        cpu_abort(CPU(m68k_env_get_cpu(env)), "Unsupported semihosting syscall %d\n", nr);
+        cpu_abort(env_cpu(env), "Unsupported semihosting syscall %d\n", nr);
         result = 0;
     }
 failed:
diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c
index 13fcaa74ef..39aa9310e1 100644
--- a/target/m68k/op_helper.c
+++ b/target/m68k/op_helper.c
@@ -211,7 +211,7 @@  static const char *m68k_exception_name(int index)
 
 static void cf_interrupt_all(CPUM68KState *env, int is_hw)
 {
-    CPUState *cs = CPU(m68k_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
     uint32_t sp;
     uint32_t sr;
     uint32_t fmt;
@@ -289,7 +289,7 @@  static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
 {
     if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
         /*  all except 68000 */
-        CPUState *cs = CPU(m68k_env_get_cpu(env));
+        CPUState *cs = env_cpu(env);
         switch (format) {
         case 4:
             *sp -= 4;
@@ -314,7 +314,7 @@  static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
 
 static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
 {
-    CPUState *cs = CPU(m68k_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
     uint32_t sp;
     uint32_t retaddr;
     uint32_t vector;
@@ -526,7 +526,7 @@  bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 
 static void raise_exception_ra(CPUM68KState *env, int tt, uintptr_t raddr)
 {
-    CPUState *cs = CPU(m68k_env_get_cpu(env));
+    CPUState *cs = env_cpu(env);
 
     cs->exception_index = tt;
     cpu_loop_exit_restore(cs, raddr);
@@ -1056,7 +1056,7 @@  void HELPER(chk)(CPUM68KState *env, int32_t val, int32_t ub)
     env->cc_c = 0 <= ub ? val < 0 || val > ub : val > ub && val < 0;
 
     if (val < 0 || val > ub) {
-        CPUState *cs = CPU(m68k_env_get_cpu(env));
+        CPUState *cs = env_cpu(env);
 
         /* Recover PC and CC_OP for the beginning of the insn.  */
         cpu_restore_state(cs, GETPC(), true);
@@ -1087,7 +1087,7 @@  void HELPER(chk2)(CPUM68KState *env, int32_t val, int32_t lb, int32_t ub)
     env->cc_c = lb <= ub ? val < lb || val > ub : val > ub && val < lb;
 
     if (env->cc_c) {
-        CPUState *cs = CPU(m68k_env_get_cpu(env));
+        CPUState *cs = env_cpu(env);
 
         /* Recover PC and CC_OP for the beginning of the insn.  */
         cpu_restore_state(cs, GETPC(), true);
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 58596278c2..e206b5e78a 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -4778,14 +4778,12 @@  DISAS_INSN(wddata)
 
 DISAS_INSN(wdebug)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-
     if (IS_USER(s)) {
         gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
         return;
     }
     /* TODO: Implement wdebug.  */
-    cpu_abort(CPU(cpu), "WDEBUG not implemented");
+    cpu_abort(env_cpu(env), "WDEBUG not implemented");
 }
 #endif