[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/26] target/arm: Implement pauth_auth
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 20/26] target/arm: Implement pauth_auth |
Date: |
Fri, 7 Dec 2018 04:36:25 -0600 |
This is not really functional yet, because the crypto is not yet
implemented. This, however follows the Auth pseudo function.
Signed-off-by: Richard Henderson <address@hidden>
---
target/arm/helper-a64.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
index 8860704720..2c14a71f03 100644
--- a/target/arm/helper-a64.c
+++ b/target/arm/helper-a64.c
@@ -1081,7 +1081,26 @@ static uint64_t pauth_original_ptr(uint64_t ptr,
ARMVAParameters param)
static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
uint64_t *key, bool data, int keynumber)
{
- g_assert_not_reached(); /* FIXME */
+ ARMMMUIdx mmu_idx = arm_mmu_idx(env);
+ ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data);
+ int bot_bit, top_bit;
+ uint64_t pac, orig_ptr, test;
+
+ orig_ptr = pauth_original_ptr(ptr, param);
+ pac = pauth_computepac(orig_ptr, modifier, key[1], key[0]);
+ bot_bit = 64 - param.tsz;
+ top_bit = 64 - 8 * param.tbi;
+
+ test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1);
+ if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) {
+ int error_code = (keynumber << 1) | (keynumber ^ 1);
+ if (param.tbi) {
+ return deposit64(ptr, 53, 2, error_code);
+ } else {
+ return deposit64(ptr, 61, 2, error_code);
+ }
+ }
+ return orig_ptr;
}
static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data)
--
2.17.2
- [Qemu-devel] [PATCH 12/26] target/arm: Decode PAuth within disas_uncond_b_reg, (continued)
- [Qemu-devel] [PATCH 12/26] target/arm: Decode PAuth within disas_uncond_b_reg, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 14/26] target/arm: Move cpu_mmu_index out of line, Richard Henderson, 2018/12/07
- [Qemu-devel] [PATCH 17/26] target/arm: Reuse aa64_va_parameters for setting tbflags, Richard Henderson, 2018/12/07
- [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 <=
- [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, 2018/12/07
- [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