* [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes
@ 2018-06-25 14:44 Mark Rutland
2018-06-25 14:44 ` [PATCH 1/7] arm64: add PSR_AA32_* definitions Mark Rutland
` (7 more replies)
0 siblings, 8 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
The SPSR_ELx format has diverged from the AArch32-native SPSR format since the
addition of DIT. Thus, we need to map between the two for certain compat
operations.
Also, when we added support for DIT, we forgot to account for this in
valid_user_regs(), causing PSTATE.DIT to be cleared upon sigreturn.
These patches (based on v4.18-rc2) fix those issues, cleaning up the COMPAT_PSR
definitions to try to avoid confusiong in future.
The COMPAT_PSR_ definitions are now used for the AArch32-native SPR format
(i.e. they are the compat userspace view), with PSR_AA32_ definitions used for
the AArch64 view of the PSR for AArch32 tasks.
Thanks,
Mark.
Mark Rutland (7):
arm64: add PSR_AA32_* definitions
arm64: don't zero DIT on signal return
arm64: compat: map SPSR_ELx<->PSR for signals
arm64: ptrace: map SPSR_ELx<->PSR for compat tasks
arm64: use PSR_AA32 definitions
kvm/arm: use PSR_AA32 definitions
arm64: remove unused COMPAT_PSR definitions
arch/arm/include/asm/kvm_emulate.h | 14 +++---
arch/arm64/include/asm/kvm_emulate.h | 10 ++---
arch/arm64/include/asm/processor.h | 6 +--
arch/arm64/include/asm/ptrace.h | 77 +++++++++++++++++++++-----------
arch/arm64/kernel/armv8_deprecated.c | 24 +++++-----
arch/arm64/kernel/cpufeature.c | 2 +-
arch/arm64/kernel/process.c | 20 ++++-----
arch/arm64/kernel/ptrace.c | 34 ++++++++------
arch/arm64/kernel/signal32.c | 18 +++++---
arch/arm64/kvm/guest.c | 14 +++---
arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +-
arch/arm64/kvm/regmap.c | 22 ++++-----
arch/arm64/kvm/reset.c | 4 +-
virt/kvm/arm/aarch32.c | 20 ++++-----
14 files changed, 152 insertions(+), 115 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/7] arm64: add PSR_AA32_* definitions
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-06-25 14:44 ` [PATCH 2/7] arm64: don't zero DIT on signal return Mark Rutland
` (6 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
The AArch32 CPSR/SPSR format is *almost* identical to the AArch64
SPSR_ELx format for exceptions taken from AArch32, but the two have
diverged with the addition of DIT, and we need to treat the two as
logically distinct.
This patch adds new definitions for the SPSR_ELx format for exceptions
taken from AArch32, with a consistent PSR_AA32_ prefix. The existing
COMPAT_PSR_ definitions will be used for the PSR format as seen from
AArch32.
Definitions of DIT are provided for both, and inline functions are
provided to map between the two formats. Note that for SPSR_ELx, the
(RES0) J bit has been re-allocated as the DIT bit.
Once users of the COMPAT_PSR definitions have been migrated over to the
PSR_AA32 definitions, the (majority of) the former will be removed, so
no efforts is made to avoid duplication until then.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoffer Dall <christoffer.dall@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Suzuki Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/ptrace.h | 57 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index 6069d66e0bc2..ee27468a1ba6 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -35,7 +35,37 @@
#define COMPAT_PTRACE_GETHBPREGS 29
#define COMPAT_PTRACE_SETHBPREGS 30
-/* AArch32 CPSR bits */
+/* SPSR_ELx bits for exceptions taken from AArch32 */
+#define PSR_AA32_MODE_MASK 0x0000001f
+#define PSR_AA32_MODE_USR 0x00000010
+#define PSR_AA32_MODE_FIQ 0x00000011
+#define PSR_AA32_MODE_IRQ 0x00000012
+#define PSR_AA32_MODE_SVC 0x00000013
+#define PSR_AA32_MODE_ABT 0x00000017
+#define PSR_AA32_MODE_HYP 0x0000001a
+#define PSR_AA32_MODE_UND 0x0000001b
+#define PSR_AA32_MODE_SYS 0x0000001f
+#define PSR_AA32_T_BIT 0x00000020
+#define PSR_AA32_F_BIT 0x00000040
+#define PSR_AA32_I_BIT 0x00000080
+#define PSR_AA32_A_BIT 0x00000100
+#define PSR_AA32_E_BIT 0x00000200
+#define PSR_AA32_DIT_BIT 0x01000000
+#define PSR_AA32_Q_BIT 0x08000000
+#define PSR_AA32_V_BIT 0x10000000
+#define PSR_AA32_C_BIT 0x20000000
+#define PSR_AA32_Z_BIT 0x40000000
+#define PSR_AA32_N_BIT 0x80000000
+#define PSR_AA32_IT_MASK 0x0600fc00 /* If-Then execution state mask */
+#define PSR_AA32_GE_MASK 0x000f0000
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define PSR_AA32_ENDSTATE PSR_AA32_E_BIT
+#else
+#define PSR_AA32_ENDSTATE 0
+#endif
+
+/* AArch32 CPSR bits, as seen in AArch32 */
#define COMPAT_PSR_MODE_MASK 0x0000001f
#define COMPAT_PSR_MODE_USR 0x00000010
#define COMPAT_PSR_MODE_FIQ 0x00000011
@@ -50,6 +80,7 @@
#define COMPAT_PSR_I_BIT 0x00000080
#define COMPAT_PSR_A_BIT 0x00000100
#define COMPAT_PSR_E_BIT 0x00000200
+#define COMPAT_PSR_DIT_BIT 0x00200000
#define COMPAT_PSR_J_BIT 0x01000000
#define COMPAT_PSR_Q_BIT 0x08000000
#define COMPAT_PSR_V_BIT 0x10000000
@@ -65,6 +96,30 @@
#define COMPAT_PSR_ENDSTATE 0
#endif
+static inline unsigned long compat_psr_to_pstate(const unsigned long psr)
+{
+ unsigned long pstate;
+
+ pstate = psr & ~COMPAT_PSR_DIT_BIT;
+
+ if (psr & COMPAT_PSR_DIT_BIT)
+ pstate |= PSR_AA32_DIT_BIT;
+
+ return pstate;
+}
+
+static inline unsigned long pstate_to_compat_psr(const unsigned long pstate)
+{
+ unsigned long psr;
+
+ psr = pstate & ~PSR_AA32_DIT_BIT;
+
+ if (pstate & PSR_AA32_DIT_BIT)
+ psr |= COMPAT_PSR_DIT_BIT;
+
+ return psr;
+}
+
/*
* These are 'magic' values for PTRACE_PEEKUSR that return info about where a
* process is located in memory.
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/7] arm64: don't zero DIT on signal return
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
2018-06-25 14:44 ` [PATCH 1/7] arm64: add PSR_AA32_* definitions Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-06-25 14:44 ` [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals Mark Rutland
` (5 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
Currently valid_user_regs() treats SPSR_ELx.DIT as a RES0 bit, causing
it to be zeroed upon exception return, rather than preserved. Thus, code
relying on DIT will not function as expected, and may expose an
unexpected timing sidechannel.
Let's remove DIT from the set of RES0 bits, such that it is preserved.
At the same time, the related comment is updated to better describe the
situation, and to take into account the most recent documentation of
SPSR_ELx, in ARM DDI 0487C.a.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Fixes: 7206dc93a58fb764 ("arm64: Expose Arm v8.4 features")
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/kernel/ptrace.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 5c338ce5a7fa..fff665988e21 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1659,15 +1659,19 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
}
/*
- * Bits which are always architecturally RES0 per ARM DDI 0487A.h
+ * SPSR_ELx bits which are always architecturally RES0 per ARM DDI 0487C.a
+ * We also take into account DIT (bit 24), which is not yet documented, and
+ * treat PAN and UAO as RES0 bits, as they are meaningless at EL0, and may be
+ * allocated an EL0 meaning in future.
* Userspace cannot use these until they have an architectural meaning.
+ * Note that this follows the SPSR_ELx format, not the AArch32 PSR format.
* We also reserve IL for the kernel; SS is handled dynamically.
*/
#define SPSR_EL1_AARCH64_RES0_BITS \
- (GENMASK_ULL(63,32) | GENMASK_ULL(27, 22) | GENMASK_ULL(20, 10) | \
- GENMASK_ULL(5, 5))
+ (GENMASK_ULL(63,32) | GENMASK_ULL(27, 25) | GENMASK_ULL(23, 22) | \
+ GENMASK_ULL(20, 10) | GENMASK_ULL(5, 5))
#define SPSR_EL1_AARCH32_RES0_BITS \
- (GENMASK_ULL(63,32) | GENMASK_ULL(24, 22) | GENMASK_ULL(20,20))
+ (GENMASK_ULL(63,32) | GENMASK_ULL(23, 22) | GENMASK_ULL(20,20))
static int valid_compat_regs(struct user_pt_regs *regs)
{
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
2018-06-25 14:44 ` [PATCH 1/7] arm64: add PSR_AA32_* definitions Mark Rutland
2018-06-25 14:44 ` [PATCH 2/7] arm64: don't zero DIT on signal return Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-06-25 16:15 ` Suzuki K Poulose
2018-06-25 14:44 ` [PATCH 4/7] arm64: ptrace: map SPSR_ELx<->PSR for compat tasks Mark Rutland
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
The SPSR_ELx format for exceptions taken from AArch32 differs from the
AArch32 PSR format. Thus, we must translate between the two when setting
up a compat sigframe, or restoring context from a compat sigframe.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Fixes: 7206dc93a58fb764 ("arm64: Expose Arm v8.4 features")
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/kernel/signal32.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index 77b91f478995..fa9fb782f077 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -243,6 +243,7 @@ static int compat_restore_sigframe(struct pt_regs *regs,
int err;
sigset_t set;
struct compat_aux_sigframe __user *aux;
+ unsigned long psr;
err = get_sigset_t(&set, &sf->uc.uc_sigmask);
if (err == 0) {
@@ -266,7 +267,9 @@ static int compat_restore_sigframe(struct pt_regs *regs,
__get_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err);
__get_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err);
__get_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err);
- __get_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err);
+ __get_user_error(psr, &sf->uc.uc_mcontext.arm_cpsr, err);
+
+ regs->pstate = compat_psr_to_pstate(regs->pstate);
/*
* Avoid compat_sys_sigreturn() restarting.
@@ -414,6 +417,7 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf,
struct pt_regs *regs, sigset_t *set)
{
struct compat_aux_sigframe __user *aux;
+ unsigned long psr = pstate_to_compat_psr(regs->pstate);
int err = 0;
__put_user_error(regs->regs[0], &sf->uc.uc_mcontext.arm_r0, err);
@@ -432,7 +436,7 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf,
__put_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err);
__put_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err);
__put_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err);
- __put_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err);
+ __put_user_error(psr, &sf->uc.uc_mcontext.arm_cpsr, err);
__put_user_error((compat_ulong_t)0, &sf->uc.uc_mcontext.trap_no, err);
/* set the compat FSR WnR */
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/7] arm64: ptrace: map SPSR_ELx<->PSR for compat tasks
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
` (2 preceding siblings ...)
2018-06-25 14:44 ` [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-06-25 14:44 ` [PATCH 5/7] arm64: use PSR_AA32 definitions Mark Rutland
` (3 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
The SPSR_ELx format for exceptions taken from AArch32 is slightly
different to the AArch32 PSR format.
Map between the two in the compat ptrace code.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Fixes: 7206dc93a58fb764 ("arm64: Expose Arm v8.4 features")
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/kernel/ptrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index fff665988e21..bc07e8ec062b 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1076,6 +1076,7 @@ static int compat_gpr_get(struct task_struct *target,
break;
case 16:
reg = task_pt_regs(target)->pstate;
+ reg = pstate_to_compat_psr(reg);
break;
case 17:
reg = task_pt_regs(target)->orig_x0;
@@ -1143,6 +1144,7 @@ static int compat_gpr_set(struct task_struct *target,
newregs.pc = reg;
break;
case 16:
+ reg = compat_psr_to_pstate(reg);
newregs.pstate = reg;
break;
case 17:
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/7] arm64: use PSR_AA32 definitions
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
` (3 preceding siblings ...)
2018-06-25 14:44 ` [PATCH 4/7] arm64: ptrace: map SPSR_ELx<->PSR for compat tasks Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-06-25 14:44 ` [PATCH 6/7] kvm/arm: " Mark Rutland
` (2 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
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 <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/processor.h | 6 +++---
arch/arm64/kernel/armv8_deprecated.c | 24 ++++++++++++------------
arch/arm64/kernel/cpufeature.c | 2 +-
arch/arm64/kernel/process.c | 20 ++++++++++----------
arch/arm64/kernel/ptrace.c | 20 ++++++++++----------
arch/arm64/kernel/signal32.c | 10 +++++-----
6 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index a73ae1e49200..e02612105d78 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -182,12 +182,12 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp)
{
start_thread_common(regs, pc);
- regs->pstate = COMPAT_PSR_MODE_USR;
+ regs->pstate = PSR_AA32_MODE_USR;
if (pc & 1)
- regs->pstate |= COMPAT_PSR_T_BIT;
+ regs->pstate |= PSR_AA32_T_BIT;
#ifdef __AARCH64EB__
- regs->pstate |= COMPAT_PSR_E_BIT;
+ regs->pstate |= PSR_AA32_E_BIT;
#endif
regs->compat_sp = sp;
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
index d4707abb2f16..d2c0938ccaec 100644
--- a/arch/arm64/kernel/armv8_deprecated.c
+++ b/arch/arm64/kernel/armv8_deprecated.c
@@ -441,8 +441,8 @@ static struct undef_hook swp_hooks[] = {
{
.instr_mask = 0x0fb00ff0,
.instr_val = 0x01000090,
- .pstate_mask = COMPAT_PSR_MODE_MASK,
- .pstate_val = COMPAT_PSR_MODE_USR,
+ .pstate_mask = PSR_AA32_MODE_MASK,
+ .pstate_val = PSR_AA32_MODE_USR,
.fn = swp_handler
},
{ }
@@ -521,15 +521,15 @@ static struct undef_hook cp15_barrier_hooks[] = {
{
.instr_mask = 0x0fff0fdf,
.instr_val = 0x0e070f9a,
- .pstate_mask = COMPAT_PSR_MODE_MASK,
- .pstate_val = COMPAT_PSR_MODE_USR,
+ .pstate_mask = PSR_AA32_MODE_MASK,
+ .pstate_val = PSR_AA32_MODE_USR,
.fn = cp15barrier_handler,
},
{
.instr_mask = 0x0fff0fff,
.instr_val = 0x0e070f95,
- .pstate_mask = COMPAT_PSR_MODE_MASK,
- .pstate_val = COMPAT_PSR_MODE_USR,
+ .pstate_mask = PSR_AA32_MODE_MASK,
+ .pstate_val = PSR_AA32_MODE_USR,
.fn = cp15barrier_handler,
},
{ }
@@ -562,10 +562,10 @@ static int compat_setend_handler(struct pt_regs *regs, u32 big_endian)
if (big_endian) {
insn = "setend be";
- regs->pstate |= COMPAT_PSR_E_BIT;
+ regs->pstate |= PSR_AA32_E_BIT;
} else {
insn = "setend le";
- regs->pstate &= ~COMPAT_PSR_E_BIT;
+ regs->pstate &= ~PSR_AA32_E_BIT;
}
trace_instruction_emulation(insn, regs->pc);
@@ -593,16 +593,16 @@ static struct undef_hook setend_hooks[] = {
{
.instr_mask = 0xfffffdff,
.instr_val = 0xf1010000,
- .pstate_mask = COMPAT_PSR_MODE_MASK,
- .pstate_val = COMPAT_PSR_MODE_USR,
+ .pstate_mask = PSR_AA32_MODE_MASK,
+ .pstate_val = PSR_AA32_MODE_USR,
.fn = a32_setend_handler,
},
{
/* Thumb mode */
.instr_mask = 0x0000fff7,
.instr_val = 0x0000b650,
- .pstate_mask = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_MASK),
- .pstate_val = (COMPAT_PSR_T_BIT | COMPAT_PSR_MODE_USR),
+ .pstate_mask = (PSR_AA32_T_BIT | PSR_AA32_MODE_MASK),
+ .pstate_val = (PSR_AA32_T_BIT | PSR_AA32_MODE_USR),
.fn = t16_setend_handler,
},
{}
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index f24892a40d2c..48d813defe5e 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1723,7 +1723,7 @@ static int emulate_mrs(struct pt_regs *regs, u32 insn)
static struct undef_hook mrs_hook = {
.instr_mask = 0xfff00000,
.instr_val = 0xd5300000,
- .pstate_mask = COMPAT_PSR_MODE_MASK,
+ .pstate_mask = PSR_AA32_MODE_MASK,
.pstate_val = PSR_MODE_EL0t,
.fn = emulate_mrs,
};
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index e10bc363f533..740b31f77ade 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -177,16 +177,16 @@ static void print_pstate(struct pt_regs *regs)
if (compat_user_mode(regs)) {
printk("pstate: %08llx (%c%c%c%c %c %s %s %c%c%c)\n",
pstate,
- pstate & COMPAT_PSR_N_BIT ? 'N' : 'n',
- pstate & COMPAT_PSR_Z_BIT ? 'Z' : 'z',
- pstate & COMPAT_PSR_C_BIT ? 'C' : 'c',
- pstate & COMPAT_PSR_V_BIT ? 'V' : 'v',
- pstate & COMPAT_PSR_Q_BIT ? 'Q' : 'q',
- pstate & COMPAT_PSR_T_BIT ? "T32" : "A32",
- pstate & COMPAT_PSR_E_BIT ? "BE" : "LE",
- pstate & COMPAT_PSR_A_BIT ? 'A' : 'a',
- pstate & COMPAT_PSR_I_BIT ? 'I' : 'i',
- pstate & COMPAT_PSR_F_BIT ? 'F' : 'f');
+ pstate & PSR_AA32_N_BIT ? 'N' : 'n',
+ pstate & PSR_AA32_Z_BIT ? 'Z' : 'z',
+ pstate & PSR_AA32_C_BIT ? 'C' : 'c',
+ pstate & PSR_AA32_V_BIT ? 'V' : 'v',
+ pstate & PSR_AA32_Q_BIT ? 'Q' : 'q',
+ pstate & PSR_AA32_T_BIT ? "T32" : "A32",
+ pstate & PSR_AA32_E_BIT ? "BE" : "LE",
+ pstate & PSR_AA32_A_BIT ? 'A' : 'a',
+ pstate & PSR_AA32_I_BIT ? 'I' : 'i',
+ pstate & PSR_AA32_F_BIT ? 'F' : 'f');
} else {
printk("pstate: %08llx (%c%c%c%c %c%c%c%c %cPAN %cUAO)\n",
pstate,
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index bc07e8ec062b..ee2677bdc41e 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1681,15 +1681,15 @@ static int valid_compat_regs(struct user_pt_regs *regs)
if (!system_supports_mixed_endian_el0()) {
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
- regs->pstate |= COMPAT_PSR_E_BIT;
+ regs->pstate |= PSR_AA32_E_BIT;
else
- regs->pstate &= ~COMPAT_PSR_E_BIT;
+ regs->pstate &= ~PSR_AA32_E_BIT;
}
if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) &&
- (regs->pstate & COMPAT_PSR_A_BIT) == 0 &&
- (regs->pstate & COMPAT_PSR_I_BIT) == 0 &&
- (regs->pstate & COMPAT_PSR_F_BIT) == 0) {
+ (regs->pstate & PSR_AA32_A_BIT) == 0 &&
+ (regs->pstate & PSR_AA32_I_BIT) == 0 &&
+ (regs->pstate & PSR_AA32_F_BIT) == 0) {
return 1;
}
@@ -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
* arch/arm.
*/
- regs->pstate &= COMPAT_PSR_N_BIT | COMPAT_PSR_Z_BIT |
- COMPAT_PSR_C_BIT | COMPAT_PSR_V_BIT |
- COMPAT_PSR_Q_BIT | COMPAT_PSR_IT_MASK |
- COMPAT_PSR_GE_MASK | COMPAT_PSR_E_BIT |
- COMPAT_PSR_T_BIT;
+ regs->pstate &= PSR_AA32_N_BIT | PSR_AA32_Z_BIT |
+ PSR_AA32_C_BIT | PSR_AA32_V_BIT |
+ PSR_AA32_Q_BIT | PSR_AA32_IT_MASK |
+ PSR_AA32_GE_MASK | PSR_AA32_E_BIT |
+ PSR_AA32_T_BIT;
regs->pstate |= PSR_MODE32_BIT;
return 0;
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index fa9fb782f077..9ff4f958c679 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -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 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;
/* Check if the handler is written for ARM or Thumb */
thumb = handler & 1;
if (thumb)
- spsr |= COMPAT_PSR_T_BIT;
+ spsr |= PSR_AA32_T_BIT;
else
- spsr &= ~COMPAT_PSR_T_BIT;
+ spsr &= ~PSR_AA32_T_BIT;
/* 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 */
- spsr |= COMPAT_PSR_ENDSTATE;
+ spsr |= PSR_AA32_ENDSTATE;
if (ka->sa.sa_flags & SA_RESTORER) {
retcode = ptr_to_compat(ka->sa.sa_restorer);
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/7] kvm/arm: use PSR_AA32 definitions
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
` (4 preceding siblings ...)
2018-06-25 14:44 ` [PATCH 5/7] arm64: use PSR_AA32 definitions Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-07-04 13:12 ` Will Deacon
2018-07-04 15:06 ` Christoffer Dall
2018-06-25 14:44 ` [PATCH 7/7] arm64: remove unused COMPAT_PSR definitions Mark Rutland
2018-07-04 17:33 ` [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Will Deacon
7 siblings, 2 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
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.
Note that arm64 KVM does not support a compat KVM API, and always uses
the SPSR_ELx format, even for AArch32 guests.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Christoffer Dall <christoffer.dall@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/include/asm/kvm_emulate.h | 14 +++++++-------
arch/arm64/include/asm/kvm_emulate.h | 10 +++++-----
arch/arm64/kvm/guest.c | 14 +++++++-------
arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +-
arch/arm64/kvm/regmap.c | 22 +++++++++++-----------
arch/arm64/kvm/reset.c | 4 ++--
virt/kvm/arm/aarch32.c | 20 ++++++++++----------
7 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
index 6493bd479ddc..fe2fb1ddd771 100644
--- a/arch/arm/include/asm/kvm_emulate.h
+++ b/arch/arm/include/asm/kvm_emulate.h
@@ -26,13 +26,13 @@
#include <asm/cputype.h>
/* arm64 compatibility macros */
-#define COMPAT_PSR_MODE_ABT ABT_MODE
-#define COMPAT_PSR_MODE_UND UND_MODE
-#define COMPAT_PSR_T_BIT PSR_T_BIT
-#define COMPAT_PSR_I_BIT PSR_I_BIT
-#define COMPAT_PSR_A_BIT PSR_A_BIT
-#define COMPAT_PSR_E_BIT PSR_E_BIT
-#define COMPAT_PSR_IT_MASK PSR_IT_MASK
+#define PSR_AA32_MODE_ABT ABT_MODE
+#define PSR_AA32_MODE_UND UND_MODE
+#define PSR_AA32_T_BIT PSR_T_BIT
+#define PSR_AA32_I_BIT PSR_I_BIT
+#define PSR_AA32_A_BIT PSR_A_BIT
+#define PSR_AA32_E_BIT PSR_E_BIT
+#define PSR_AA32_IT_MASK PSR_IT_MASK
unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num);
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index 1dab3a984608..0c97e45d1dc3 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -140,7 +140,7 @@ static inline void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr)
static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu)
{
- *vcpu_cpsr(vcpu) |= COMPAT_PSR_T_BIT;
+ *vcpu_cpsr(vcpu) |= PSR_AA32_T_BIT;
}
/*
@@ -190,8 +190,8 @@ static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu)
u32 mode;
if (vcpu_mode_is_32bit(vcpu)) {
- mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
- return mode > COMPAT_PSR_MODE_USR;
+ mode = *vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK;
+ return mode > PSR_AA32_MODE_USR;
}
mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
@@ -329,7 +329,7 @@ static inline unsigned long kvm_vcpu_get_mpidr_aff(struct kvm_vcpu *vcpu)
static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu)
{
if (vcpu_mode_is_32bit(vcpu)) {
- *vcpu_cpsr(vcpu) |= COMPAT_PSR_E_BIT;
+ *vcpu_cpsr(vcpu) |= PSR_AA32_E_BIT;
} else {
u64 sctlr = vcpu_read_sys_reg(vcpu, SCTLR_EL1);
sctlr |= (1 << 25);
@@ -340,7 +340,7 @@ static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu)
static inline bool kvm_vcpu_is_be(struct kvm_vcpu *vcpu)
{
if (vcpu_mode_is_32bit(vcpu))
- return !!(*vcpu_cpsr(vcpu) & COMPAT_PSR_E_BIT);
+ return !!(*vcpu_cpsr(vcpu) & PSR_AA32_E_BIT);
return !!(vcpu_read_sys_reg(vcpu, SCTLR_EL1) & (1 << 25));
}
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index 56a0260ceb11..cdd4d9d6d575 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -107,14 +107,14 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
}
if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) {
- u32 mode = (*(u32 *)valp) & COMPAT_PSR_MODE_MASK;
+ u32 mode = (*(u32 *)valp) & PSR_AA32_MODE_MASK;
switch (mode) {
- case COMPAT_PSR_MODE_USR:
- case COMPAT_PSR_MODE_FIQ:
- case COMPAT_PSR_MODE_IRQ:
- case COMPAT_PSR_MODE_SVC:
- case COMPAT_PSR_MODE_ABT:
- case COMPAT_PSR_MODE_UND:
+ case PSR_AA32_MODE_USR:
+ case PSR_AA32_MODE_FIQ:
+ case PSR_AA32_MODE_IRQ:
+ case PSR_AA32_MODE_SVC:
+ case PSR_AA32_MODE_ABT:
+ case PSR_AA32_MODE_UND:
case PSR_MODE_EL0t:
case PSR_MODE_EL1t:
case PSR_MODE_EL1h:
diff --git a/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c b/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
index 39be799d0417..215c7c0eb3b0 100644
--- a/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
+++ b/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
@@ -27,7 +27,7 @@
static bool __hyp_text __is_be(struct kvm_vcpu *vcpu)
{
if (vcpu_mode_is_32bit(vcpu))
- return !!(read_sysreg_el2(spsr) & COMPAT_PSR_E_BIT);
+ return !!(read_sysreg_el2(spsr) & PSR_AA32_E_BIT);
return !!(read_sysreg(SCTLR_EL1) & SCTLR_ELx_EE);
}
diff --git a/arch/arm64/kvm/regmap.c b/arch/arm64/kvm/regmap.c
index eefe403a2e63..7a5173ea2276 100644
--- a/arch/arm64/kvm/regmap.c
+++ b/arch/arm64/kvm/regmap.c
@@ -112,22 +112,22 @@ static const unsigned long vcpu_reg_offsets[VCPU_NR_MODES][16] = {
unsigned long *vcpu_reg32(const struct kvm_vcpu *vcpu, u8 reg_num)
{
unsigned long *reg_array = (unsigned long *)&vcpu->arch.ctxt.gp_regs.regs;
- unsigned long mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
+ unsigned long mode = *vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK;
switch (mode) {
- case COMPAT_PSR_MODE_USR ... COMPAT_PSR_MODE_SVC:
+ case PSR_AA32_MODE_USR ... PSR_AA32_MODE_SVC:
mode &= ~PSR_MODE32_BIT; /* 0 ... 3 */
break;
- case COMPAT_PSR_MODE_ABT:
+ case PSR_AA32_MODE_ABT:
mode = 4;
break;
- case COMPAT_PSR_MODE_UND:
+ case PSR_AA32_MODE_UND:
mode = 5;
break;
- case COMPAT_PSR_MODE_SYS:
+ case PSR_AA32_MODE_SYS:
mode = 0; /* SYS maps to USR */
break;
@@ -143,13 +143,13 @@ unsigned long *vcpu_reg32(const struct kvm_vcpu *vcpu, u8 reg_num)
*/
static int vcpu_spsr32_mode(const struct kvm_vcpu *vcpu)
{
- unsigned long mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
+ unsigned long mode = *vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK;
switch (mode) {
- case COMPAT_PSR_MODE_SVC: return KVM_SPSR_SVC;
- case COMPAT_PSR_MODE_ABT: return KVM_SPSR_ABT;
- case COMPAT_PSR_MODE_UND: return KVM_SPSR_UND;
- case COMPAT_PSR_MODE_IRQ: return KVM_SPSR_IRQ;
- case COMPAT_PSR_MODE_FIQ: return KVM_SPSR_FIQ;
+ case PSR_AA32_MODE_SVC: return KVM_SPSR_SVC;
+ case PSR_AA32_MODE_ABT: return KVM_SPSR_ABT;
+ case PSR_AA32_MODE_UND: return KVM_SPSR_UND;
+ case PSR_AA32_MODE_IRQ: return KVM_SPSR_IRQ;
+ case PSR_AA32_MODE_FIQ: return KVM_SPSR_FIQ;
default: BUG();
}
}
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index a74311beda35..4e4aedaf7ab7 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -42,8 +42,8 @@ static const struct kvm_regs default_regs_reset = {
};
static const struct kvm_regs default_regs_reset32 = {
- .regs.pstate = (COMPAT_PSR_MODE_SVC | COMPAT_PSR_A_BIT |
- COMPAT_PSR_I_BIT | COMPAT_PSR_F_BIT),
+ .regs.pstate = (PSR_AA32_MODE_SVC | PSR_AA32_A_BIT |
+ PSR_AA32_I_BIT | PSR_AA32_F_BIT),
};
static bool cpu_has_32bit_el1(void)
diff --git a/virt/kvm/arm/aarch32.c b/virt/kvm/arm/aarch32.c
index efc84cbe8277..5abbe9b3c652 100644
--- a/virt/kvm/arm/aarch32.c
+++ b/virt/kvm/arm/aarch32.c
@@ -108,9 +108,9 @@ static void __hyp_text kvm_adjust_itstate(struct kvm_vcpu *vcpu)
{
unsigned long itbits, cond;
unsigned long cpsr = *vcpu_cpsr(vcpu);
- bool is_arm = !(cpsr & COMPAT_PSR_T_BIT);
+ bool is_arm = !(cpsr & PSR_AA32_T_BIT);
- if (is_arm || !(cpsr & COMPAT_PSR_IT_MASK))
+ if (is_arm || !(cpsr & PSR_AA32_IT_MASK))
return;
cond = (cpsr & 0xe000) >> 13;
@@ -123,7 +123,7 @@ static void __hyp_text kvm_adjust_itstate(struct kvm_vcpu *vcpu)
else
itbits = (itbits << 1) & 0x1f;
- cpsr &= ~COMPAT_PSR_IT_MASK;
+ cpsr &= ~PSR_AA32_IT_MASK;
cpsr |= cond << 13;
cpsr |= (itbits & 0x1c) << (10 - 2);
cpsr |= (itbits & 0x3) << 25;
@@ -138,7 +138,7 @@ void __hyp_text kvm_skip_instr32(struct kvm_vcpu *vcpu, bool is_wide_instr)
{
bool is_thumb;
- is_thumb = !!(*vcpu_cpsr(vcpu) & COMPAT_PSR_T_BIT);
+ is_thumb = !!(*vcpu_cpsr(vcpu) & PSR_AA32_T_BIT);
if (is_thumb && !is_wide_instr)
*vcpu_pc(vcpu) += 2;
else
@@ -164,16 +164,16 @@ static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset)
{
unsigned long cpsr;
unsigned long new_spsr_value = *vcpu_cpsr(vcpu);
- bool is_thumb = (new_spsr_value & COMPAT_PSR_T_BIT);
+ bool is_thumb = (new_spsr_value & PSR_AA32_T_BIT);
u32 return_offset = return_offsets[vect_offset >> 2][is_thumb];
u32 sctlr = vcpu_cp15(vcpu, c1_SCTLR);
- cpsr = mode | COMPAT_PSR_I_BIT;
+ cpsr = mode | PSR_AA32_I_BIT;
if (sctlr & (1 << 30))
- cpsr |= COMPAT_PSR_T_BIT;
+ cpsr |= PSR_AA32_T_BIT;
if (sctlr & (1 << 25))
- cpsr |= COMPAT_PSR_E_BIT;
+ cpsr |= PSR_AA32_E_BIT;
*vcpu_cpsr(vcpu) = cpsr;
@@ -192,7 +192,7 @@ static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset)
void kvm_inject_undef32(struct kvm_vcpu *vcpu)
{
- prepare_fault32(vcpu, COMPAT_PSR_MODE_UND, 4);
+ prepare_fault32(vcpu, PSR_AA32_MODE_UND, 4);
}
/*
@@ -216,7 +216,7 @@ static void inject_abt32(struct kvm_vcpu *vcpu, bool is_pabt,
fsr = &vcpu_cp15(vcpu, c5_DFSR);
}
- prepare_fault32(vcpu, COMPAT_PSR_MODE_ABT | COMPAT_PSR_A_BIT, vect_offset);
+ prepare_fault32(vcpu, PSR_AA32_MODE_ABT | PSR_AA32_A_BIT, vect_offset);
*far = addr;
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 7/7] arm64: remove unused COMPAT_PSR definitions
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
` (5 preceding siblings ...)
2018-06-25 14:44 ` [PATCH 6/7] kvm/arm: " Mark Rutland
@ 2018-06-25 14:44 ` Mark Rutland
2018-07-04 17:33 ` [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Will Deacon
7 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 14:44 UTC (permalink / raw)
To: linux-arm-kernel
Now that users have been migrated to PSR_AA32, kill the unused
COMPAT_PSR definitions.
The only difference we need a definition for is COMPAT_PSR_DIT_BIT,
which differs from PSR_AA32_DIT_BIT.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/ptrace.h | 28 ----------------------------
1 file changed, 28 deletions(-)
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index ee27468a1ba6..550c64dd83cb 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -66,35 +66,7 @@
#endif
/* AArch32 CPSR bits, as seen in AArch32 */
-#define COMPAT_PSR_MODE_MASK 0x0000001f
-#define COMPAT_PSR_MODE_USR 0x00000010
-#define COMPAT_PSR_MODE_FIQ 0x00000011
-#define COMPAT_PSR_MODE_IRQ 0x00000012
-#define COMPAT_PSR_MODE_SVC 0x00000013
-#define COMPAT_PSR_MODE_ABT 0x00000017
-#define COMPAT_PSR_MODE_HYP 0x0000001a
-#define COMPAT_PSR_MODE_UND 0x0000001b
-#define COMPAT_PSR_MODE_SYS 0x0000001f
-#define COMPAT_PSR_T_BIT 0x00000020
-#define COMPAT_PSR_F_BIT 0x00000040
-#define COMPAT_PSR_I_BIT 0x00000080
-#define COMPAT_PSR_A_BIT 0x00000100
-#define COMPAT_PSR_E_BIT 0x00000200
#define COMPAT_PSR_DIT_BIT 0x00200000
-#define COMPAT_PSR_J_BIT 0x01000000
-#define COMPAT_PSR_Q_BIT 0x08000000
-#define COMPAT_PSR_V_BIT 0x10000000
-#define COMPAT_PSR_C_BIT 0x20000000
-#define COMPAT_PSR_Z_BIT 0x40000000
-#define COMPAT_PSR_N_BIT 0x80000000
-#define COMPAT_PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
-#define COMPAT_PSR_GE_MASK 0x000f0000
-
-#ifdef CONFIG_CPU_BIG_ENDIAN
-#define COMPAT_PSR_ENDSTATE COMPAT_PSR_E_BIT
-#else
-#define COMPAT_PSR_ENDSTATE 0
-#endif
static inline unsigned long compat_psr_to_pstate(const unsigned long psr)
{
--
2.11.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals
2018-06-25 14:44 ` [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals Mark Rutland
@ 2018-06-25 16:15 ` Suzuki K Poulose
2018-06-25 16:19 ` Mark Rutland
0 siblings, 1 reply; 16+ messages in thread
From: Suzuki K Poulose @ 2018-06-25 16:15 UTC (permalink / raw)
To: linux-arm-kernel
On 25/06/18 15:44, Mark Rutland wrote:
> The SPSR_ELx format for exceptions taken from AArch32 differs from the
> AArch32 PSR format. Thus, we must translate between the two when setting
> up a compat sigframe, or restoring context from a compat sigframe.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Fixes: 7206dc93a58fb764 ("arm64: Expose Arm v8.4 features")
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Suzuki Poulose <suzuki.poulose@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm64/kernel/signal32.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
> index 77b91f478995..fa9fb782f077 100644
> --- a/arch/arm64/kernel/signal32.c
> +++ b/arch/arm64/kernel/signal32.c
> @@ -243,6 +243,7 @@ static int compat_restore_sigframe(struct pt_regs *regs,
> int err;
> sigset_t set;
> struct compat_aux_sigframe __user *aux;
> + unsigned long psr;
>
> err = get_sigset_t(&set, &sf->uc.uc_sigmask);
> if (err == 0) {
> @@ -266,7 +267,9 @@ static int compat_restore_sigframe(struct pt_regs *regs,
> __get_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err);
> __get_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err);
> __get_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err);
> - __get_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err);
> + __get_user_error(psr, &sf->uc.uc_mcontext.arm_cpsr, err);
> +
> + regs->pstate = compat_psr_to_pstate(regs->pstate);
Did you mean
regs->pstate = compat_psr_to_pstate(psr)
above ?
Otherwise, looks good to me.
Suzuki
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals
2018-06-25 16:15 ` Suzuki K Poulose
@ 2018-06-25 16:19 ` Mark Rutland
0 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-06-25 16:19 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 25, 2018 at 05:15:06PM +0100, Suzuki K Poulose wrote:
> On 25/06/18 15:44, Mark Rutland wrote:
> > The SPSR_ELx format for exceptions taken from AArch32 differs from the
> > AArch32 PSR format. Thus, we must translate between the two when setting
> > up a compat sigframe, or restoring context from a compat sigframe.
> >
> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> > Fixes: 7206dc93a58fb764 ("arm64: Expose Arm v8.4 features")
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Suzuki Poulose <suzuki.poulose@arm.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > ---
> > arch/arm64/kernel/signal32.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
> > index 77b91f478995..fa9fb782f077 100644
> > --- a/arch/arm64/kernel/signal32.c
> > +++ b/arch/arm64/kernel/signal32.c
> > @@ -243,6 +243,7 @@ static int compat_restore_sigframe(struct pt_regs *regs,
> > int err;
> > sigset_t set;
> > struct compat_aux_sigframe __user *aux;
> > + unsigned long psr;
> > err = get_sigset_t(&set, &sf->uc.uc_sigmask);
> > if (err == 0) {
> > @@ -266,7 +267,9 @@ static int compat_restore_sigframe(struct pt_regs *regs,
> > __get_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err);
> > __get_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err);
> > __get_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err);
> > - __get_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err);
> > + __get_user_error(psr, &sf->uc.uc_mcontext.arm_cpsr, err);
> > +
> > + regs->pstate = compat_psr_to_pstate(regs->pstate);
>
> Did you mean
> regs->pstate = compat_psr_to_pstate(psr)
> above ?
Yes!
Thanks for spotting that; I've fixed that up locally.
Mark.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] kvm/arm: use PSR_AA32 definitions
2018-06-25 14:44 ` [PATCH 6/7] kvm/arm: " Mark Rutland
@ 2018-07-04 13:12 ` Will Deacon
2018-07-04 13:23 ` Marc Zyngier
2018-07-04 15:06 ` Christoffer Dall
1 sibling, 1 reply; 16+ messages in thread
From: Will Deacon @ 2018-07-04 13:12 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 25, 2018 at 03:44:20PM +0100, Mark Rutland wrote:
> 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.
>
> Note that arm64 KVM does not support a compat KVM API, and always uses
> the SPSR_ELx format, even for AArch32 guests.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Christoffer Dall <christoffer.dall@arm.com>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm/include/asm/kvm_emulate.h | 14 +++++++-------
> arch/arm64/include/asm/kvm_emulate.h | 10 +++++-----
> arch/arm64/kvm/guest.c | 14 +++++++-------
> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +-
> arch/arm64/kvm/regmap.c | 22 +++++++++++-----------
> arch/arm64/kvm/reset.c | 4 ++--
> virt/kvm/arm/aarch32.c | 20 ++++++++++----------
> 7 files changed, 43 insertions(+), 43 deletions(-)
I need an ack from the KVM maintainers before I can take this. I can also
put this series on a separate branch if necessary.
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] kvm/arm: use PSR_AA32 definitions
2018-07-04 13:12 ` Will Deacon
@ 2018-07-04 13:23 ` Marc Zyngier
2018-07-04 14:01 ` Will Deacon
0 siblings, 1 reply; 16+ messages in thread
From: Marc Zyngier @ 2018-07-04 13:23 UTC (permalink / raw)
To: linux-arm-kernel
On 04/07/18 14:12, Will Deacon wrote:
> On Mon, Jun 25, 2018 at 03:44:20PM +0100, Mark Rutland wrote:
>> 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.
>>
>> Note that arm64 KVM does not support a compat KVM API, and always uses
>> the SPSR_ELx format, even for AArch32 guests.
>>
>> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
>> Cc: Christoffer Dall <christoffer.dall@arm.com>
>> Cc: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> arch/arm/include/asm/kvm_emulate.h | 14 +++++++-------
>> arch/arm64/include/asm/kvm_emulate.h | 10 +++++-----
>> arch/arm64/kvm/guest.c | 14 +++++++-------
>> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +-
>> arch/arm64/kvm/regmap.c | 22 +++++++++++-----------
>> arch/arm64/kvm/reset.c | 4 ++--
>> virt/kvm/arm/aarch32.c | 20 ++++++++++----------
>> 7 files changed, 43 insertions(+), 43 deletions(-)
>
> I need an ack from the KVM maintainers before I can take this. I can also
> put this series on a separate branch if necessary.
Feel free to add my
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
I don't have much queued for KVM ATM, so there is no need for a separate
branch. Pending stuff shouldn't conflict (famous last word...).
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] kvm/arm: use PSR_AA32 definitions
2018-07-04 13:23 ` Marc Zyngier
@ 2018-07-04 14:01 ` Will Deacon
0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2018-07-04 14:01 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jul 04, 2018 at 02:23:05PM +0100, Marc Zyngier wrote:
> On 04/07/18 14:12, Will Deacon wrote:
> > On Mon, Jun 25, 2018 at 03:44:20PM +0100, Mark Rutland wrote:
> >> 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.
> >>
> >> Note that arm64 KVM does not support a compat KVM API, and always uses
> >> the SPSR_ELx format, even for AArch32 guests.
> >>
> >> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> >> Cc: Christoffer Dall <christoffer.dall@arm.com>
> >> Cc: Marc Zyngier <marc.zyngier@arm.com>
> >> ---
> >> arch/arm/include/asm/kvm_emulate.h | 14 +++++++-------
> >> arch/arm64/include/asm/kvm_emulate.h | 10 +++++-----
> >> arch/arm64/kvm/guest.c | 14 +++++++-------
> >> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +-
> >> arch/arm64/kvm/regmap.c | 22 +++++++++++-----------
> >> arch/arm64/kvm/reset.c | 4 ++--
> >> virt/kvm/arm/aarch32.c | 20 ++++++++++----------
> >> 7 files changed, 43 insertions(+), 43 deletions(-)
> >
> > I need an ack from the KVM maintainers before I can take this. I can also
> > put this series on a separate branch if necessary.
>
> Feel free to add my
>
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
>
> I don't have much queued for KVM ATM, so there is no need for a separate
> branch. Pending stuff shouldn't conflict (famous last word...).
Brill; thanks for the quick reply, Marc.
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] kvm/arm: use PSR_AA32 definitions
2018-06-25 14:44 ` [PATCH 6/7] kvm/arm: " Mark Rutland
2018-07-04 13:12 ` Will Deacon
@ 2018-07-04 15:06 ` Christoffer Dall
1 sibling, 0 replies; 16+ messages in thread
From: Christoffer Dall @ 2018-07-04 15:06 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 25, 2018 at 03:44:20PM +0100, Mark Rutland wrote:
> 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.
>
> Note that arm64 KVM does not support a compat KVM API, and always uses
> the SPSR_ELx format, even for AArch32 guests.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Christoffer Dall <christoffer.dall@arm.com>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@arm.com>
> ---
> arch/arm/include/asm/kvm_emulate.h | 14 +++++++-------
> arch/arm64/include/asm/kvm_emulate.h | 10 +++++-----
> arch/arm64/kvm/guest.c | 14 +++++++-------
> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +-
> arch/arm64/kvm/regmap.c | 22 +++++++++++-----------
> arch/arm64/kvm/reset.c | 4 ++--
> virt/kvm/arm/aarch32.c | 20 ++++++++++----------
> 7 files changed, 43 insertions(+), 43 deletions(-)
>
> diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
> index 6493bd479ddc..fe2fb1ddd771 100644
> --- a/arch/arm/include/asm/kvm_emulate.h
> +++ b/arch/arm/include/asm/kvm_emulate.h
> @@ -26,13 +26,13 @@
> #include <asm/cputype.h>
>
> /* arm64 compatibility macros */
> -#define COMPAT_PSR_MODE_ABT ABT_MODE
> -#define COMPAT_PSR_MODE_UND UND_MODE
> -#define COMPAT_PSR_T_BIT PSR_T_BIT
> -#define COMPAT_PSR_I_BIT PSR_I_BIT
> -#define COMPAT_PSR_A_BIT PSR_A_BIT
> -#define COMPAT_PSR_E_BIT PSR_E_BIT
> -#define COMPAT_PSR_IT_MASK PSR_IT_MASK
> +#define PSR_AA32_MODE_ABT ABT_MODE
> +#define PSR_AA32_MODE_UND UND_MODE
> +#define PSR_AA32_T_BIT PSR_T_BIT
> +#define PSR_AA32_I_BIT PSR_I_BIT
> +#define PSR_AA32_A_BIT PSR_A_BIT
> +#define PSR_AA32_E_BIT PSR_E_BIT
> +#define PSR_AA32_IT_MASK PSR_IT_MASK
>
> unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num);
>
> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
> index 1dab3a984608..0c97e45d1dc3 100644
> --- a/arch/arm64/include/asm/kvm_emulate.h
> +++ b/arch/arm64/include/asm/kvm_emulate.h
> @@ -140,7 +140,7 @@ static inline void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr)
>
> static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu)
> {
> - *vcpu_cpsr(vcpu) |= COMPAT_PSR_T_BIT;
> + *vcpu_cpsr(vcpu) |= PSR_AA32_T_BIT;
> }
>
> /*
> @@ -190,8 +190,8 @@ static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu)
> u32 mode;
>
> if (vcpu_mode_is_32bit(vcpu)) {
> - mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
> - return mode > COMPAT_PSR_MODE_USR;
> + mode = *vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK;
> + return mode > PSR_AA32_MODE_USR;
> }
>
> mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
> @@ -329,7 +329,7 @@ static inline unsigned long kvm_vcpu_get_mpidr_aff(struct kvm_vcpu *vcpu)
> static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu)
> {
> if (vcpu_mode_is_32bit(vcpu)) {
> - *vcpu_cpsr(vcpu) |= COMPAT_PSR_E_BIT;
> + *vcpu_cpsr(vcpu) |= PSR_AA32_E_BIT;
> } else {
> u64 sctlr = vcpu_read_sys_reg(vcpu, SCTLR_EL1);
> sctlr |= (1 << 25);
> @@ -340,7 +340,7 @@ static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu)
> static inline bool kvm_vcpu_is_be(struct kvm_vcpu *vcpu)
> {
> if (vcpu_mode_is_32bit(vcpu))
> - return !!(*vcpu_cpsr(vcpu) & COMPAT_PSR_E_BIT);
> + return !!(*vcpu_cpsr(vcpu) & PSR_AA32_E_BIT);
>
> return !!(vcpu_read_sys_reg(vcpu, SCTLR_EL1) & (1 << 25));
> }
> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> index 56a0260ceb11..cdd4d9d6d575 100644
> --- a/arch/arm64/kvm/guest.c
> +++ b/arch/arm64/kvm/guest.c
> @@ -107,14 +107,14 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> }
>
> if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) {
> - u32 mode = (*(u32 *)valp) & COMPAT_PSR_MODE_MASK;
> + u32 mode = (*(u32 *)valp) & PSR_AA32_MODE_MASK;
> switch (mode) {
> - case COMPAT_PSR_MODE_USR:
> - case COMPAT_PSR_MODE_FIQ:
> - case COMPAT_PSR_MODE_IRQ:
> - case COMPAT_PSR_MODE_SVC:
> - case COMPAT_PSR_MODE_ABT:
> - case COMPAT_PSR_MODE_UND:
> + case PSR_AA32_MODE_USR:
> + case PSR_AA32_MODE_FIQ:
> + case PSR_AA32_MODE_IRQ:
> + case PSR_AA32_MODE_SVC:
> + case PSR_AA32_MODE_ABT:
> + case PSR_AA32_MODE_UND:
> case PSR_MODE_EL0t:
> case PSR_MODE_EL1t:
> case PSR_MODE_EL1h:
> diff --git a/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c b/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
> index 39be799d0417..215c7c0eb3b0 100644
> --- a/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
> +++ b/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
> @@ -27,7 +27,7 @@
> static bool __hyp_text __is_be(struct kvm_vcpu *vcpu)
> {
> if (vcpu_mode_is_32bit(vcpu))
> - return !!(read_sysreg_el2(spsr) & COMPAT_PSR_E_BIT);
> + return !!(read_sysreg_el2(spsr) & PSR_AA32_E_BIT);
>
> return !!(read_sysreg(SCTLR_EL1) & SCTLR_ELx_EE);
> }
> diff --git a/arch/arm64/kvm/regmap.c b/arch/arm64/kvm/regmap.c
> index eefe403a2e63..7a5173ea2276 100644
> --- a/arch/arm64/kvm/regmap.c
> +++ b/arch/arm64/kvm/regmap.c
> @@ -112,22 +112,22 @@ static const unsigned long vcpu_reg_offsets[VCPU_NR_MODES][16] = {
> unsigned long *vcpu_reg32(const struct kvm_vcpu *vcpu, u8 reg_num)
> {
> unsigned long *reg_array = (unsigned long *)&vcpu->arch.ctxt.gp_regs.regs;
> - unsigned long mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
> + unsigned long mode = *vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK;
>
> switch (mode) {
> - case COMPAT_PSR_MODE_USR ... COMPAT_PSR_MODE_SVC:
> + case PSR_AA32_MODE_USR ... PSR_AA32_MODE_SVC:
> mode &= ~PSR_MODE32_BIT; /* 0 ... 3 */
> break;
>
> - case COMPAT_PSR_MODE_ABT:
> + case PSR_AA32_MODE_ABT:
> mode = 4;
> break;
>
> - case COMPAT_PSR_MODE_UND:
> + case PSR_AA32_MODE_UND:
> mode = 5;
> break;
>
> - case COMPAT_PSR_MODE_SYS:
> + case PSR_AA32_MODE_SYS:
> mode = 0; /* SYS maps to USR */
> break;
>
> @@ -143,13 +143,13 @@ unsigned long *vcpu_reg32(const struct kvm_vcpu *vcpu, u8 reg_num)
> */
> static int vcpu_spsr32_mode(const struct kvm_vcpu *vcpu)
> {
> - unsigned long mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
> + unsigned long mode = *vcpu_cpsr(vcpu) & PSR_AA32_MODE_MASK;
> switch (mode) {
> - case COMPAT_PSR_MODE_SVC: return KVM_SPSR_SVC;
> - case COMPAT_PSR_MODE_ABT: return KVM_SPSR_ABT;
> - case COMPAT_PSR_MODE_UND: return KVM_SPSR_UND;
> - case COMPAT_PSR_MODE_IRQ: return KVM_SPSR_IRQ;
> - case COMPAT_PSR_MODE_FIQ: return KVM_SPSR_FIQ;
> + case PSR_AA32_MODE_SVC: return KVM_SPSR_SVC;
> + case PSR_AA32_MODE_ABT: return KVM_SPSR_ABT;
> + case PSR_AA32_MODE_UND: return KVM_SPSR_UND;
> + case PSR_AA32_MODE_IRQ: return KVM_SPSR_IRQ;
> + case PSR_AA32_MODE_FIQ: return KVM_SPSR_FIQ;
> default: BUG();
> }
> }
> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> index a74311beda35..4e4aedaf7ab7 100644
> --- a/arch/arm64/kvm/reset.c
> +++ b/arch/arm64/kvm/reset.c
> @@ -42,8 +42,8 @@ static const struct kvm_regs default_regs_reset = {
> };
>
> static const struct kvm_regs default_regs_reset32 = {
> - .regs.pstate = (COMPAT_PSR_MODE_SVC | COMPAT_PSR_A_BIT |
> - COMPAT_PSR_I_BIT | COMPAT_PSR_F_BIT),
> + .regs.pstate = (PSR_AA32_MODE_SVC | PSR_AA32_A_BIT |
> + PSR_AA32_I_BIT | PSR_AA32_F_BIT),
> };
>
> static bool cpu_has_32bit_el1(void)
> diff --git a/virt/kvm/arm/aarch32.c b/virt/kvm/arm/aarch32.c
> index efc84cbe8277..5abbe9b3c652 100644
> --- a/virt/kvm/arm/aarch32.c
> +++ b/virt/kvm/arm/aarch32.c
> @@ -108,9 +108,9 @@ static void __hyp_text kvm_adjust_itstate(struct kvm_vcpu *vcpu)
> {
> unsigned long itbits, cond;
> unsigned long cpsr = *vcpu_cpsr(vcpu);
> - bool is_arm = !(cpsr & COMPAT_PSR_T_BIT);
> + bool is_arm = !(cpsr & PSR_AA32_T_BIT);
>
> - if (is_arm || !(cpsr & COMPAT_PSR_IT_MASK))
> + if (is_arm || !(cpsr & PSR_AA32_IT_MASK))
> return;
>
> cond = (cpsr & 0xe000) >> 13;
> @@ -123,7 +123,7 @@ static void __hyp_text kvm_adjust_itstate(struct kvm_vcpu *vcpu)
> else
> itbits = (itbits << 1) & 0x1f;
>
> - cpsr &= ~COMPAT_PSR_IT_MASK;
> + cpsr &= ~PSR_AA32_IT_MASK;
> cpsr |= cond << 13;
> cpsr |= (itbits & 0x1c) << (10 - 2);
> cpsr |= (itbits & 0x3) << 25;
> @@ -138,7 +138,7 @@ void __hyp_text kvm_skip_instr32(struct kvm_vcpu *vcpu, bool is_wide_instr)
> {
> bool is_thumb;
>
> - is_thumb = !!(*vcpu_cpsr(vcpu) & COMPAT_PSR_T_BIT);
> + is_thumb = !!(*vcpu_cpsr(vcpu) & PSR_AA32_T_BIT);
> if (is_thumb && !is_wide_instr)
> *vcpu_pc(vcpu) += 2;
> else
> @@ -164,16 +164,16 @@ static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset)
> {
> unsigned long cpsr;
> unsigned long new_spsr_value = *vcpu_cpsr(vcpu);
> - bool is_thumb = (new_spsr_value & COMPAT_PSR_T_BIT);
> + bool is_thumb = (new_spsr_value & PSR_AA32_T_BIT);
> u32 return_offset = return_offsets[vect_offset >> 2][is_thumb];
> u32 sctlr = vcpu_cp15(vcpu, c1_SCTLR);
>
> - cpsr = mode | COMPAT_PSR_I_BIT;
> + cpsr = mode | PSR_AA32_I_BIT;
>
> if (sctlr & (1 << 30))
> - cpsr |= COMPAT_PSR_T_BIT;
> + cpsr |= PSR_AA32_T_BIT;
> if (sctlr & (1 << 25))
> - cpsr |= COMPAT_PSR_E_BIT;
> + cpsr |= PSR_AA32_E_BIT;
>
> *vcpu_cpsr(vcpu) = cpsr;
>
> @@ -192,7 +192,7 @@ static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset)
>
> void kvm_inject_undef32(struct kvm_vcpu *vcpu)
> {
> - prepare_fault32(vcpu, COMPAT_PSR_MODE_UND, 4);
> + prepare_fault32(vcpu, PSR_AA32_MODE_UND, 4);
> }
>
> /*
> @@ -216,7 +216,7 @@ static void inject_abt32(struct kvm_vcpu *vcpu, bool is_pabt,
> fsr = &vcpu_cp15(vcpu, c5_DFSR);
> }
>
> - prepare_fault32(vcpu, COMPAT_PSR_MODE_ABT | COMPAT_PSR_A_BIT, vect_offset);
> + prepare_fault32(vcpu, PSR_AA32_MODE_ABT | PSR_AA32_A_BIT, vect_offset);
>
> *far = addr;
>
> --
> 2.11.0
>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
` (6 preceding siblings ...)
2018-06-25 14:44 ` [PATCH 7/7] arm64: remove unused COMPAT_PSR definitions Mark Rutland
@ 2018-07-04 17:33 ` Will Deacon
2018-07-05 12:08 ` Mark Rutland
7 siblings, 1 reply; 16+ messages in thread
From: Will Deacon @ 2018-07-04 17:33 UTC (permalink / raw)
To: linux-arm-kernel
Mark,
On Mon, Jun 25, 2018 at 03:44:14PM +0100, Mark Rutland wrote:
> The SPSR_ELx format has diverged from the AArch32-native SPSR format since the
> addition of DIT. Thus, we need to map between the two for certain compat
> operations.
>
> Also, when we added support for DIT, we forgot to account for this in
> valid_user_regs(), causing PSTATE.DIT to be cleared upon sigreturn.
>
> These patches (based on v4.18-rc2) fix those issues, cleaning up the COMPAT_PSR
> definitions to try to avoid confusiong in future.
>
> The COMPAT_PSR_ definitions are now used for the AArch32-native SPR format
> (i.e. they are the compat userspace view), with PSR_AA32_ definitions used for
> the AArch64 view of the PSR for AArch32 tasks.
I applied this, but it doesn't even build with defconfig :(
How much testing has this seen? I also get some other errors because code
is trying to refer to COMPAT definitions that you've removed. So I've dropped
all of this for now.
arch/arm64/include/asm/ptrace.h: Assembler messages:
arch/arm64/include/asm/ptrace.h:71: Error: unknown mnemonic `static' -- `static inline unsigned long compat_psr_to_pstate(const unsigned long psr)'
arch/arm64/include/asm/ptrace.h:72: Error: junk at end of line, first unrecognised character is `{'
arch/arm64/include/asm/ptrace.h:73: Error: unknown mnemonic `unsigned' -- `unsigned long pstate'
arch/arm64/include/asm/ptrace.h:77: Error: unknown mnemonic `if' -- `if (psr&0x00200000)'
arch/arm64/include/asm/ptrace.h:78: Error: unknown mnemonic `pstate' -- `pstate |=0x01000000'
arch/arm64/include/asm/ptrace.h:80: Error: unknown mnemonic `return' -- `return pstate'
arch/arm64/include/asm/ptrace.h:81: Error: junk at end of line, first unrecognised character is `}'
arch/arm64/include/asm/ptrace.h:83: Error: unknown mnemonic `static' -- `static inline unsigned long pstate_to_compat_psr(const unsigned long pstate)'
arch/arm64/include/asm/ptrace.h:84: Error: junk at end of line, first unrecognised character is `{'
arch/arm64/include/asm/ptrace.h:85: Error: unknown mnemonic `unsigned' -- `unsigned long psr'
arch/arm64/include/asm/ptrace.h:89: Error: unknown mnemonic `if' -- `if (pstate&0x01000000)'
arch/arm64/include/asm/ptrace.h:90: Error: unknown mnemonic `psr' -- `psr |=0x00200000'
arch/arm64/include/asm/ptrace.h:92: Error: unknown mnemonic `return' -- `return psr'
arch/arm64/include/asm/ptrace.h:93: Error: junk at end of line, first unrecognised character is `}'
/tmp/ccvDpb9g.s: Error: symbol definition loop encountered at `pstate'
/tmp/ccvDpb9g.s: Error: invalid operands (*GAS `expr' section* and *ABS* sections) for `&' when setting `psr'
/tmp/ccvDpb9g.s: Error: Invalid operation on symbol
/tmp/ccvDpb9g.s: Error: can't resolve value for symbol `pstate'
make[2]: *** [arch/arm64/crypto/sha1-ce-core.o] Error 1
Will
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes
2018-07-04 17:33 ` [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Will Deacon
@ 2018-07-05 12:08 ` Mark Rutland
0 siblings, 0 replies; 16+ messages in thread
From: Mark Rutland @ 2018-07-05 12:08 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jul 04, 2018 at 06:33:48PM +0100, Will Deacon wrote:
> Mark,
>
> On Mon, Jun 25, 2018 at 03:44:14PM +0100, Mark Rutland wrote:
> > The SPSR_ELx format has diverged from the AArch32-native SPSR format since the
> > addition of DIT. Thus, we need to map between the two for certain compat
> > operations.
> >
> > Also, when we added support for DIT, we forgot to account for this in
> > valid_user_regs(), causing PSTATE.DIT to be cleared upon sigreturn.
> >
> > These patches (based on v4.18-rc2) fix those issues, cleaning up the COMPAT_PSR
> > definitions to try to avoid confusiong in future.
> >
> > The COMPAT_PSR_ definitions are now used for the AArch32-native SPR format
> > (i.e. they are the compat userspace view), with PSR_AA32_ definitions used for
> > the AArch64 view of the PSR for AArch32 tasks.
>
> I applied this, but it doesn't even build with defconfig :(
>
> How much testing has this seen?
Quite evidently, none.
> I also get some other errors because code is trying to refer to COMPAT
> definitions that you've removed. So I've dropped all of this for now.
Understood.
I will fix these up, make sure that the resulting series builds cleanly
at every step, and send that out as a v2 shortly.
Sorry for this mess.
Mark.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2018-07-05 12:08 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25 14:44 [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Mark Rutland
2018-06-25 14:44 ` [PATCH 1/7] arm64: add PSR_AA32_* definitions Mark Rutland
2018-06-25 14:44 ` [PATCH 2/7] arm64: don't zero DIT on signal return Mark Rutland
2018-06-25 14:44 ` [PATCH 3/7] arm64: compat: map SPSR_ELx<->PSR for signals Mark Rutland
2018-06-25 16:15 ` Suzuki K Poulose
2018-06-25 16:19 ` Mark Rutland
2018-06-25 14:44 ` [PATCH 4/7] arm64: ptrace: map SPSR_ELx<->PSR for compat tasks Mark Rutland
2018-06-25 14:44 ` [PATCH 5/7] arm64: use PSR_AA32 definitions Mark Rutland
2018-06-25 14:44 ` [PATCH 6/7] kvm/arm: " Mark Rutland
2018-07-04 13:12 ` Will Deacon
2018-07-04 13:23 ` Marc Zyngier
2018-07-04 14:01 ` Will Deacon
2018-07-04 15:06 ` Christoffer Dall
2018-06-25 14:44 ` [PATCH 7/7] arm64: remove unused COMPAT_PSR definitions Mark Rutland
2018-07-04 17:33 ` [PATCH 0/7] arm64: PSR <-> SPSR_ELx mapping fixes Will Deacon
2018-07-05 12:08 ` Mark Rutland
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.