@samitouri / QOSamiQemu / commits / c8ea175900

linux-user/arm/nwfpe: Replace user_registers with current_cpu

Use the thread-local variable current_cpu instead of a global variable to access the general registers. This also means we don't need to pass env to EmulateAll. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Helge Deller <deller@gmx.de>

Richard Henderson committed Apr 14, 2026 at 09:02 UTC c8ea1759009a248cf331b275854d8b272e0f7d8a
3 files changed +9 -25
linux-user/arm/cpu_loop.c
+1 -1
@@ -215,7 +215,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is_thumb)
215 static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode)
216 {
217 TaskState *ts = get_task_state(env_cpu(env));
218 - int rc = EmulateAll(opcode, &ts->fpa, env);
218 + int rc = EmulateAll(opcode, &ts->fpa);
219 int raise, enabled;
220
221 if (rc == 0) {
linux-user/arm/nwfpe/fpa11.c
+1 -8
@@ -30,7 +30,6 @@
30
31
32 FPA11* qemufpa = NULL;
33 -CPUARMState* user_registers;
33
34 /* Reset the FPA11 chip. Called to initialize and reset the emulator. */
35 void resetFPA11(void)
@@ -156,7 +155,7 @@ void SetRoundingPrecision(const unsigned int opcode)
155
156 /* Emulate the instruction in the opcode. */
157 /* ??? This is not thread safe. */
159 -unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)
158 +unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa)
159 {
160 unsigned int nRc = 0;
161 // unsigned long flags;
@@ -173,12 +172,6 @@ unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)
172 }
173
174 qemufpa=qfpa;
176 - user_registers=qregs;
177 -
178 -#if 0
179 - fprintf(stderr,"emulating FP insn 0x%08x, PC=0x%08x\n",
180 - opcode, qregs[ARM_REG_PC]);
181 -#endif
175 fpa11 = GET_FPA11();
176
177 if (fpa11->initflag == 0) /* good place for __builtin_expect */
linux-user/arm/nwfpe/fpa11.h
+7 -16
@@ -25,15 +25,6 @@
25
26 #define GET_FPA11() (qemufpa)
27
28 -/*
29 - * The processes registers are always at the very top of the 8K
30 - * stack+task struct. Use the same method as 'current' uses to
31 - * reach them.
32 - */
33 -extern CPUARMState *user_registers;
34 -
35 -#define GET_USERREG() (user_registers)
36 -
28 /* Need task_struct */
29 //#include <linux/sched.h>
30
@@ -91,25 +82,25 @@ void SetRoundingPrecision(const unsigned int);
82
83 static inline unsigned int readRegister(unsigned int reg)
84 {
94 - return (user_registers->regs[(reg)]);
85 + CPUARMState *env = cpu_env(current_cpu);
86 + return env->regs[reg];
87 }
88
89 static inline void writeRegister(unsigned int x, unsigned int y)
90 {
99 -#if 0
100 - printf("writing %d to r%d\n",y,x);
101 -#endif
102 - user_registers->regs[(x)]=(y);
91 + CPUARMState *env = cpu_env(current_cpu);
92 + env->regs[x] = y;
93 }
94
95 static inline void writeConditionCodes(unsigned int x)
96 {
107 - cpsr_write(user_registers, x, CPSR_NZCV, CPSRWriteByInstr);
97 + CPUARMState *env = cpu_env(current_cpu);
98 + cpsr_write(env, x, CPSR_NZCV, CPSRWriteByInstr);
99 }
100
101 #define ARM_REG_PC 15
102
112 -unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs);
103 +unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa);
104
105 unsigned int EmulateCPDO(const unsigned int);
106 unsigned int EmulateCPDT(const unsigned int);