Commit d64567f6 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

arm64: use PSR_AA32 definitions

Some code cares about the SPSR_ELx format for exceptions taken from
AArch32 to inspect or manipulate the SPSR_ELx value, which is already in
the SPSR_ELx format, and not in the AArch32 PSR format.

To separate these from cases where we care about the AArch32 PSR format,
migrate these cases to use the PSR_AA32_* definitions rather than
COMPAT_PSR_*.

There should be no functional change as a result of this patch.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 76fc52bd
...@@ -182,12 +182,12 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc, ...@@ -182,12 +182,12 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp) unsigned long sp)
{ {
start_thread_common(regs, pc); start_thread_common(regs, pc);
regs->pstate = COMPAT_PSR_MODE_USR; regs->pstate = PSR_AA32_MODE_USR;
if (pc & 1) if (pc & 1)
regs->pstate |= COMPAT_PSR_T_BIT; regs->pstate |= PSR_AA32_T_BIT;
#ifdef __AARCH64EB__ #ifdef __AARCH64EB__
regs->pstate |= COMPAT_PSR_E_BIT; regs->pstate |= PSR_AA32_E_BIT;
#endif #endif
regs->compat_sp = sp; regs->compat_sp = sp;
......
...@@ -211,7 +211,7 @@ static inline void forget_syscall(struct pt_regs *regs) ...@@ -211,7 +211,7 @@ static inline void forget_syscall(struct pt_regs *regs)
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
#define compat_thumb_mode(regs) \ #define compat_thumb_mode(regs) \
(((regs)->pstate & COMPAT_PSR_T_BIT)) (((regs)->pstate & PSR_AA32_T_BIT))
#else #else
#define compat_thumb_mode(regs) (0) #define compat_thumb_mode(regs) (0)
#endif #endif
......
...@@ -441,8 +441,8 @@ static struct undef_hook swp_hooks[] = { ...@@ -441,8 +441,8 @@ static struct undef_hook swp_hooks[] = {
{ {
.instr_mask = 0x0fb00ff0, .instr_mask = 0x0fb00ff0,
.instr_val = 0x01000090, .instr_val = 0x01000090,
.pstate_mask = COMPAT_PSR_MODE_MASK, .pstate_mask = PSR_AA32_MODE_MASK,
.pstate_val = COMPAT_PSR_MODE_USR, .pstate_val = PSR_AA32_MODE_USR,
.fn = swp_handler .fn = swp_handler
}, },
{ } { }
...@@ -521,15 +521,15 @@ static struct undef_hook cp15_barrier_hooks[] = { ...@@ -521,15 +521,15 @@ static struct undef_hook cp15_barrier_hooks[] = {
{ {
.instr_mask = 0x0fff0fdf, .instr_mask = 0x0fff0fdf,
.instr_val = 0x0e070f9a, .instr_val = 0x0e070f9a,
.pstate_mask = COMPAT_PSR_MODE_MASK, .pstate_mask = PSR_AA32_MODE_MASK,
.pstate_val = COMPAT_PSR_MODE_USR, .pstate_val = PSR_AA32_MODE_USR,
.fn = cp15barrier_handler, .fn = cp15barrier_handler,
}, },
{ {
.instr_mask = 0x0fff0fff, .instr_mask = 0x0fff0fff,
.instr_val = 0x0e070f95, .instr_val = 0x0e070f95,
.pstate_mask = COMPAT_PSR_MODE_MASK, .pstate_mask = PSR_AA32_MODE_MASK,
.pstate_val = COMPAT_PSR_MODE_USR, .pstate_val = PSR_AA32_MODE_USR,
.fn = cp15barrier_handler, .fn = cp15barrier_handler,
}, },
{ } { }
...@@ -562,10 +562,10 @@ static int compat_setend_handler(struct pt_regs *regs, u32 big_endian) ...@@ -562,10 +562,10 @@ static int compat_setend_handler(struct pt_regs *regs, u32 big_endian)
if (big_endian) { if (big_endian) {
insn = "setend be"; insn = "setend be";
regs->pstate |= COMPAT_PSR_E_BIT; regs->pstate |= PSR_AA32_E_BIT;
} else { } else {
insn = "setend le"; insn = "setend le";
regs->pstate &= ~COMPAT_PSR_E_BIT; regs->pstate &= ~PSR_AA32_E_BIT;
} }
trace_instruction_emulation(insn, regs->pc); trace_instruction_emulation(insn, regs->pc);
...@@ -593,16 +593,16 @@ static struct undef_hook setend_hooks[] = { ...@@ -593,16 +593,16 @@ static struct undef_hook setend_hooks[] = {
{ {
.instr_mask = 0xfffffdff, .instr_mask = 0xfffffdff,
.instr_val = 0xf1010000, .instr_val = 0xf1010000,
.pstate_mask = COMPAT_PSR_MODE_MASK, .pstate_mask = PSR_AA32_MODE_MASK,
.pstate_val = COMPAT_PSR_MODE_USR, .pstate_val = PSR_AA32_MODE_USR,
.fn = a32_setend_handler, .fn = a32_setend_handler,
}, },
{ {
/* Thumb mode */ /* Thumb mode */
.instr_mask = 0x0000fff7, .instr_mask = 0x0000fff7,
.instr_val = 0x0000b650, .instr_val = 0x0000b650,
.pstate_mask = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_MASK), .pstate_mask = (PSR_AA32_T_BIT | PSR_AA32_MODE_MASK),
.pstate_val = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_USR), .pstate_val = (PSR_AA32_T_BIT | PSR_AA32_MODE_USR),
.fn = t16_setend_handler, .fn = t16_setend_handler,
}, },
{} {}
......
...@@ -1723,7 +1723,7 @@ static int emulate_mrs(struct pt_regs *regs, u32 insn) ...@@ -1723,7 +1723,7 @@ static int emulate_mrs(struct pt_regs *regs, u32 insn)
static struct undef_hook mrs_hook = { static struct undef_hook mrs_hook = {
.instr_mask = 0xfff00000, .instr_mask = 0xfff00000,
.instr_val = 0xd5300000, .instr_val = 0xd5300000,
.pstate_mask = COMPAT_PSR_MODE_MASK, .pstate_mask = PSR_AA32_MODE_MASK,
.pstate_val = PSR_MODE_EL0t, .pstate_val = PSR_MODE_EL0t,
.fn = emulate_mrs, .fn = emulate_mrs,
}; };
......
...@@ -177,16 +177,16 @@ static void print_pstate(struct pt_regs *regs) ...@@ -177,16 +177,16 @@ static void print_pstate(struct pt_regs *regs)
if (compat_user_mode(regs)) { if (compat_user_mode(regs)) {
printk("pstate: %08llx (%c%c%c%c %c %s %s %c%c%c)\n", printk("pstate: %08llx (%c%c%c%c %c %s %s %c%c%c)\n",
pstate, pstate,
pstate & COMPAT_PSR_N_BIT ? 'N' : 'n', pstate & PSR_AA32_N_BIT ? 'N' : 'n',
pstate & COMPAT_PSR_Z_BIT ? 'Z' : 'z', pstate & PSR_AA32_Z_BIT ? 'Z' : 'z',
pstate & COMPAT_PSR_C_BIT ? 'C' : 'c', pstate & PSR_AA32_C_BIT ? 'C' : 'c',
pstate & COMPAT_PSR_V_BIT ? 'V' : 'v', pstate & PSR_AA32_V_BIT ? 'V' : 'v',
pstate & COMPAT_PSR_Q_BIT ? 'Q' : 'q', pstate & PSR_AA32_Q_BIT ? 'Q' : 'q',
pstate & COMPAT_PSR_T_BIT ? "T32" : "A32", pstate & PSR_AA32_T_BIT ? "T32" : "A32",
pstate & COMPAT_PSR_E_BIT ? "BE" : "LE", pstate & PSR_AA32_E_BIT ? "BE" : "LE",
pstate & COMPAT_PSR_A_BIT ? 'A' : 'a', pstate & PSR_AA32_A_BIT ? 'A' : 'a',
pstate & COMPAT_PSR_I_BIT ? 'I' : 'i', pstate & PSR_AA32_I_BIT ? 'I' : 'i',
pstate & COMPAT_PSR_F_BIT ? 'F' : 'f'); pstate & PSR_AA32_F_BIT ? 'F' : 'f');
} else { } else {
printk("pstate: %08llx (%c%c%c%c %c%c%c%c %cPAN %cUAO)\n", printk("pstate: %08llx (%c%c%c%c %c%c%c%c %cPAN %cUAO)\n",
pstate, pstate,
......
...@@ -1681,15 +1681,15 @@ static int valid_compat_regs(struct user_pt_regs *regs) ...@@ -1681,15 +1681,15 @@ static int valid_compat_regs(struct user_pt_regs *regs)
if (!system_supports_mixed_endian_el0()) { if (!system_supports_mixed_endian_el0()) {
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
regs->pstate |= COMPAT_PSR_E_BIT; regs->pstate |= PSR_AA32_E_BIT;
else else
regs->pstate &= ~COMPAT_PSR_E_BIT; regs->pstate &= ~PSR_AA32_E_BIT;
} }
if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) && if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) &&
(regs->pstate & COMPAT_PSR_A_BIT) == 0 && (regs->pstate & PSR_AA32_A_BIT) == 0 &&
(regs->pstate & COMPAT_PSR_I_BIT) == 0 && (regs->pstate & PSR_AA32_I_BIT) == 0 &&
(regs->pstate & COMPAT_PSR_F_BIT) == 0) { (regs->pstate & PSR_AA32_F_BIT) == 0) {
return 1; return 1;
} }
...@@ -1697,11 +1697,11 @@ static int valid_compat_regs(struct user_pt_regs *regs) ...@@ -1697,11 +1697,11 @@ static int valid_compat_regs(struct user_pt_regs *regs)
* Force PSR to a valid 32-bit EL0t, preserving the same bits as * Force PSR to a valid 32-bit EL0t, preserving the same bits as
* arch/arm. * arch/arm.
*/ */
regs->pstate &= COMPAT_PSR_N_BIT | COMPAT_PSR_Z_BIT | regs->pstate &= PSR_AA32_N_BIT | PSR_AA32_Z_BIT |
COMPAT_PSR_C_BIT | COMPAT_PSR_V_BIT | PSR_AA32_C_BIT | PSR_AA32_V_BIT |
COMPAT_PSR_Q_BIT | COMPAT_PSR_IT_MASK | PSR_AA32_Q_BIT | PSR_AA32_IT_MASK |
COMPAT_PSR_GE_MASK | COMPAT_PSR_E_BIT | PSR_AA32_GE_MASK | PSR_AA32_E_BIT |
COMPAT_PSR_T_BIT; PSR_AA32_T_BIT;
regs->pstate |= PSR_MODE32_BIT; regs->pstate |= PSR_MODE32_BIT;
return 0; return 0;
......
...@@ -375,22 +375,22 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka, ...@@ -375,22 +375,22 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
{ {
compat_ulong_t handler = ptr_to_compat(ka->sa.sa_handler); compat_ulong_t handler = ptr_to_compat(ka->sa.sa_handler);
compat_ulong_t retcode; compat_ulong_t retcode;
compat_ulong_t spsr = regs->pstate & ~(PSR_f | COMPAT_PSR_E_BIT); compat_ulong_t spsr = regs->pstate & ~(PSR_f | PSR_AA32_E_BIT);
int thumb; int thumb;
/* Check if the handler is written for ARM or Thumb */ /* Check if the handler is written for ARM or Thumb */
thumb = handler & 1; thumb = handler & 1;
if (thumb) if (thumb)
spsr |= COMPAT_PSR_T_BIT; spsr |= PSR_AA32_T_BIT;
else else
spsr &= ~COMPAT_PSR_T_BIT; spsr &= ~PSR_AA32_T_BIT;
/* The IT state must be cleared for both ARM and Thumb-2 */ /* The IT state must be cleared for both ARM and Thumb-2 */
spsr &= ~COMPAT_PSR_IT_MASK; spsr &= ~PSR_AA32_IT_MASK;
/* Restore the original endianness */ /* Restore the original endianness */
spsr |= COMPAT_PSR_ENDSTATE; spsr |= PSR_AA32_ENDSTATE;
if (ka->sa.sa_flags & SA_RESTORER) { if (ka->sa.sa_flags & SA_RESTORER) {
retcode = ptr_to_compat(ka->sa.sa_restorer); retcode = ptr_to_compat(ka->sa.sa_restorer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment