[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 23/26] target/arm: Add PAuth system registers
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 23/26] target/arm: Add PAuth system registers |
Date: |
Fri, 7 Dec 2018 04:36:28 -0600 |
Signed-off-by: Richard Henderson <address@hidden>
---
target/arm/helper.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index c73525f813..f466c174e6 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -5071,6 +5071,66 @@ static CPAccessResult access_lor_other(CPUARMState *env,
return access_lor_ns(env);
}
+#ifdef TARGET_AARCH64
+static CPAccessResult access_pauth(CPUARMState *env, const ARMCPRegInfo *ri,
+ bool isread)
+{
+ int el = arm_current_el(env);
+
+ if (el < 2 && (arm_hcr_el2_eff(env) & HCR_APK)) {
+ return CP_ACCESS_TRAP_EL2;
+ }
+ if (el < 3 && (env->cp15.scr_el3 & SCR_APK)) {
+ return CP_ACCESS_TRAP_EL3;
+ }
+ return CP_ACCESS_OK;
+}
+
+static const ARMCPRegInfo pauth_reginfo[] = {
+ { .name = "APDAKEYLOW_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 0,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apda_key[0]) },
+ { .name = "APDAKEYHI_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 1,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apda_key[1]) },
+ { .name = "APDBKEYLOW_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 2,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apdb_key[0]) },
+ { .name = "APDBKEYHI_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 3,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apdb_key[1]) },
+ { .name = "APGAKEYLOW_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 0,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apia_key[0]) },
+ { .name = "APGAKEYHI_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 1,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apia_key[1]) },
+ { .name = "APIAKEYLOW_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 0,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apia_key[0]) },
+ { .name = "APIAKEYHI_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 1,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apia_key[1]) },
+ { .name = "APIBKEYLOW_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 2,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apib_key[0]) },
+ { .name = "APIBKEYHI_EL1", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3,
+ .access = PL1_RW, .accessfn = access_pauth,
+ .fieldoffset = offsetof(CPUARMState, apib_key[1]) },
+ REGINFO_SENTINEL
+};
+#endif
+
void register_cp_regs_for_features(ARMCPU *cpu)
{
/* Register all the coprocessor registers based on feature bits */
@@ -5855,6 +5915,12 @@ void register_cp_regs_for_features(ARMCPU *cpu)
define_one_arm_cp_reg(cpu, &zcr_el3_reginfo);
}
}
+
+#ifdef TARGET_AARCH64
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
+ define_arm_cp_regs(cpu, pauth_reginfo);
+ }
+#endif
}
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
--
2.17.2
- Re: [Qemu-devel] [PATCH 17/26] target/arm: Reuse aa64_va_parameters for setting tbflags, (continued)
- [Qemu-devel] [PATCH 18/26] target/arm: Export aa64_va_parameters to internals.h, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 19/26] target/arm: Implement pauth_strip, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 20/26] target/arm: Implement pauth_auth, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 16/26] target/arm: Create ARMVAParameters and helpers, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 21/26] target/arm: Implement pauth_addpac, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 22/26] target/arm: Implement pauth_computepac, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 23/26] target/arm: Add PAuth system registers,
Richard Henderson <=
- [Qemu-devel] [PATCH 24/26] target/arm: Enable PAuth for user-only -cpu max, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 25/26] target/arm: Enable PAuth for user-only, part 2, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 26/26] target/arm: Tidy TBI handling in gen_a64_set_pc, Richard Henderson, 2018/12/07