Skip to content

Commit d64567f

Browse files
mrutland-armwildea01
authored andcommitted
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: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 76fc52b commit d64567f

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

arch/arm64/include/asm/processor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
182182
unsigned long sp)
183183
{
184184
start_thread_common(regs, pc);
185-
regs->pstate = COMPAT_PSR_MODE_USR;
185+
regs->pstate = PSR_AA32_MODE_USR;
186186
if (pc & 1)
187-
regs->pstate |= COMPAT_PSR_T_BIT;
187+
regs->pstate |= PSR_AA32_T_BIT;
188188

189189
#ifdef __AARCH64EB__
190-
regs->pstate |= COMPAT_PSR_E_BIT;
190+
regs->pstate |= PSR_AA32_E_BIT;
191191
#endif
192192

193193
regs->compat_sp = sp;

arch/arm64/include/asm/ptrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static inline void forget_syscall(struct pt_regs *regs)
211211

212212
#ifdef CONFIG_COMPAT
213213
#define compat_thumb_mode(regs) \
214-
(((regs)->pstate & COMPAT_PSR_T_BIT))
214+
(((regs)->pstate & PSR_AA32_T_BIT))
215215
#else
216216
#define compat_thumb_mode(regs) (0)
217217
#endif

arch/arm64/kernel/armv8_deprecated.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ static struct undef_hook swp_hooks[] = {
441441
{
442442
.instr_mask = 0x0fb00ff0,
443443
.instr_val = 0x01000090,
444-
.pstate_mask = COMPAT_PSR_MODE_MASK,
445-
.pstate_val = COMPAT_PSR_MODE_USR,
444+
.pstate_mask = PSR_AA32_MODE_MASK,
445+
.pstate_val = PSR_AA32_MODE_USR,
446446
.fn = swp_handler
447447
},
448448
{ }
@@ -521,15 +521,15 @@ static struct undef_hook cp15_barrier_hooks[] = {
521521
{
522522
.instr_mask = 0x0fff0fdf,
523523
.instr_val = 0x0e070f9a,
524-
.pstate_mask = COMPAT_PSR_MODE_MASK,
525-
.pstate_val = COMPAT_PSR_MODE_USR,
524+
.pstate_mask = PSR_AA32_MODE_MASK,
525+
.pstate_val = PSR_AA32_MODE_USR,
526526
.fn = cp15barrier_handler,
527527
},
528528
{
529529
.instr_mask = 0x0fff0fff,
530530
.instr_val = 0x0e070f95,
531-
.pstate_mask = COMPAT_PSR_MODE_MASK,
532-
.pstate_val = COMPAT_PSR_MODE_USR,
531+
.pstate_mask = PSR_AA32_MODE_MASK,
532+
.pstate_val = PSR_AA32_MODE_USR,
533533
.fn = cp15barrier_handler,
534534
},
535535
{ }
@@ -562,10 +562,10 @@ static int compat_setend_handler(struct pt_regs *regs, u32 big_endian)
562562

563563
if (big_endian) {
564564
insn = "setend be";
565-
regs->pstate |= COMPAT_PSR_E_BIT;
565+
regs->pstate |= PSR_AA32_E_BIT;
566566
} else {
567567
insn = "setend le";
568-
regs->pstate &= ~COMPAT_PSR_E_BIT;
568+
regs->pstate &= ~PSR_AA32_E_BIT;
569569
}
570570

571571
trace_instruction_emulation(insn, regs->pc);
@@ -593,16 +593,16 @@ static struct undef_hook setend_hooks[] = {
593593
{
594594
.instr_mask = 0xfffffdff,
595595
.instr_val = 0xf1010000,
596-
.pstate_mask = COMPAT_PSR_MODE_MASK,
597-
.pstate_val = COMPAT_PSR_MODE_USR,
596+
.pstate_mask = PSR_AA32_MODE_MASK,
597+
.pstate_val = PSR_AA32_MODE_USR,
598598
.fn = a32_setend_handler,
599599
},
600600
{
601601
/* Thumb mode */
602602
.instr_mask = 0x0000fff7,
603603
.instr_val = 0x0000b650,
604-
.pstate_mask = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_MASK),
605-
.pstate_val = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_USR),
604+
.pstate_mask = (PSR_AA32_T_BIT | PSR_AA32_MODE_MASK),
605+
.pstate_val = (PSR_AA32_T_BIT | PSR_AA32_MODE_USR),
606606
.fn = t16_setend_handler,
607607
},
608608
{}

arch/arm64/kernel/cpufeature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ static int emulate_mrs(struct pt_regs *regs, u32 insn)
17231723
static struct undef_hook mrs_hook = {
17241724
.instr_mask = 0xfff00000,
17251725
.instr_val = 0xd5300000,
1726-
.pstate_mask = COMPAT_PSR_MODE_MASK,
1726+
.pstate_mask = PSR_AA32_MODE_MASK,
17271727
.pstate_val = PSR_MODE_EL0t,
17281728
.fn = emulate_mrs,
17291729
};

arch/arm64/kernel/process.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,16 @@ static void print_pstate(struct pt_regs *regs)
177177
if (compat_user_mode(regs)) {
178178
printk("pstate: %08llx (%c%c%c%c %c %s %s %c%c%c)\n",
179179
pstate,
180-
pstate & COMPAT_PSR_N_BIT ? 'N' : 'n',
181-
pstate & COMPAT_PSR_Z_BIT ? 'Z' : 'z',
182-
pstate & COMPAT_PSR_C_BIT ? 'C' : 'c',
183-
pstate & COMPAT_PSR_V_BIT ? 'V' : 'v',
184-
pstate & COMPAT_PSR_Q_BIT ? 'Q' : 'q',
185-
pstate & COMPAT_PSR_T_BIT ? "T32" : "A32",
186-
pstate & COMPAT_PSR_E_BIT ? "BE" : "LE",
187-
pstate & COMPAT_PSR_A_BIT ? 'A' : 'a',
188-
pstate & COMPAT_PSR_I_BIT ? 'I' : 'i',
189-
pstate & COMPAT_PSR_F_BIT ? 'F' : 'f');
180+
pstate & PSR_AA32_N_BIT ? 'N' : 'n',
181+
pstate & PSR_AA32_Z_BIT ? 'Z' : 'z',
182+
pstate & PSR_AA32_C_BIT ? 'C' : 'c',
183+
pstate & PSR_AA32_V_BIT ? 'V' : 'v',
184+
pstate & PSR_AA32_Q_BIT ? 'Q' : 'q',
185+
pstate & PSR_AA32_T_BIT ? "T32" : "A32",
186+
pstate & PSR_AA32_E_BIT ? "BE" : "LE",
187+
pstate & PSR_AA32_A_BIT ? 'A' : 'a',
188+
pstate & PSR_AA32_I_BIT ? 'I' : 'i',
189+
pstate & PSR_AA32_F_BIT ? 'F' : 'f');
190190
} else {
191191
printk("pstate: %08llx (%c%c%c%c %c%c%c%c %cPAN %cUAO)\n",
192192
pstate,

arch/arm64/kernel/ptrace.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,27 +1681,27 @@ static int valid_compat_regs(struct user_pt_regs *regs)
16811681

16821682
if (!system_supports_mixed_endian_el0()) {
16831683
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
1684-
regs->pstate |= COMPAT_PSR_E_BIT;
1684+
regs->pstate |= PSR_AA32_E_BIT;
16851685
else
1686-
regs->pstate &= ~COMPAT_PSR_E_BIT;
1686+
regs->pstate &= ~PSR_AA32_E_BIT;
16871687
}
16881688

16891689
if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) &&
1690-
(regs->pstate & COMPAT_PSR_A_BIT) == 0 &&
1691-
(regs->pstate & COMPAT_PSR_I_BIT) == 0 &&
1692-
(regs->pstate & COMPAT_PSR_F_BIT) == 0) {
1690+
(regs->pstate & PSR_AA32_A_BIT) == 0 &&
1691+
(regs->pstate & PSR_AA32_I_BIT) == 0 &&
1692+
(regs->pstate & PSR_AA32_F_BIT) == 0) {
16931693
return 1;
16941694
}
16951695

16961696
/*
16971697
* Force PSR to a valid 32-bit EL0t, preserving the same bits as
16981698
* arch/arm.
16991699
*/
1700-
regs->pstate &= COMPAT_PSR_N_BIT | COMPAT_PSR_Z_BIT |
1701-
COMPAT_PSR_C_BIT | COMPAT_PSR_V_BIT |
1702-
COMPAT_PSR_Q_BIT | COMPAT_PSR_IT_MASK |
1703-
COMPAT_PSR_GE_MASK | COMPAT_PSR_E_BIT |
1704-
COMPAT_PSR_T_BIT;
1700+
regs->pstate &= PSR_AA32_N_BIT | PSR_AA32_Z_BIT |
1701+
PSR_AA32_C_BIT | PSR_AA32_V_BIT |
1702+
PSR_AA32_Q_BIT | PSR_AA32_IT_MASK |
1703+
PSR_AA32_GE_MASK | PSR_AA32_E_BIT |
1704+
PSR_AA32_T_BIT;
17051705
regs->pstate |= PSR_MODE32_BIT;
17061706

17071707
return 0;

arch/arm64/kernel/signal32.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,22 +375,22 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
375375
{
376376
compat_ulong_t handler = ptr_to_compat(ka->sa.sa_handler);
377377
compat_ulong_t retcode;
378-
compat_ulong_t spsr = regs->pstate & ~(PSR_f | COMPAT_PSR_E_BIT);
378+
compat_ulong_t spsr = regs->pstate & ~(PSR_f | PSR_AA32_E_BIT);
379379
int thumb;
380380

381381
/* Check if the handler is written for ARM or Thumb */
382382
thumb = handler & 1;
383383

384384
if (thumb)
385-
spsr |= COMPAT_PSR_T_BIT;
385+
spsr |= PSR_AA32_T_BIT;
386386
else
387-
spsr &= ~COMPAT_PSR_T_BIT;
387+
spsr &= ~PSR_AA32_T_BIT;
388388

389389
/* The IT state must be cleared for both ARM and Thumb-2 */
390-
spsr &= ~COMPAT_PSR_IT_MASK;
390+
spsr &= ~PSR_AA32_IT_MASK;
391391

392392
/* Restore the original endianness */
393-
spsr |= COMPAT_PSR_ENDSTATE;
393+
spsr |= PSR_AA32_ENDSTATE;
394394

395395
if (ka->sa.sa_flags & SA_RESTORER) {
396396
retcode = ptr_to_compat(ka->sa.sa_restorer);

0 commit comments

Comments
 (0)