mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
target/arm: Implement an IMPDEF pauth algorithm
Without hardware acceleration, a cryptographically strong algorithm is too expensive for pauth_computepac. Even with hardware accel, we are not currently expecting to link the linux-user binaries to any crypto libraries, and doing so would generally make the --static build fail. So choose XXH64 as a reasonably quick and decent hash. Tested-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210111235740.462469-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
f1fcb6851a
commit
283fc52ade
3 changed files with 131 additions and 9 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "exec/cpu_ldst.h"
|
||||
#include "exec/helper-proto.h"
|
||||
#include "tcg/tcg-gvec-desc.h"
|
||||
#include "qemu/xxhash.h"
|
||||
|
||||
|
||||
static uint64_t pac_cell_shuffle(uint64_t i)
|
||||
|
@ -207,8 +208,8 @@ static uint64_t tweak_inv_shuffle(uint64_t i)
|
|||
return o;
|
||||
}
|
||||
|
||||
static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,
|
||||
ARMPACKey key)
|
||||
static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier,
|
||||
ARMPACKey key)
|
||||
{
|
||||
static const uint64_t RC[5] = {
|
||||
0x0000000000000000ull,
|
||||
|
@ -272,6 +273,22 @@ static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,
|
|||
return workingval;
|
||||
}
|
||||
|
||||
static uint64_t pauth_computepac_impdef(uint64_t data, uint64_t modifier,
|
||||
ARMPACKey key)
|
||||
{
|
||||
return qemu_xxhash64_4(data, modifier, key.lo, key.hi);
|
||||
}
|
||||
|
||||
static uint64_t pauth_computepac(CPUARMState *env, uint64_t data,
|
||||
uint64_t modifier, ARMPACKey key)
|
||||
{
|
||||
if (cpu_isar_feature(aa64_pauth_arch, env_archcpu(env))) {
|
||||
return pauth_computepac_architected(data, modifier, key);
|
||||
} else {
|
||||
return pauth_computepac_impdef(data, modifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
|
||||
ARMPACKey *key, bool data)
|
||||
{
|
||||
|
@ -292,7 +309,7 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
|
|||
bot_bit = 64 - param.tsz;
|
||||
ext_ptr = deposit64(ptr, bot_bit, top_bit - bot_bit, ext);
|
||||
|
||||
pac = pauth_computepac(ext_ptr, modifier, *key);
|
||||
pac = pauth_computepac(env, ext_ptr, modifier, *key);
|
||||
|
||||
/*
|
||||
* Check if the ptr has good extension bits and corrupt the
|
||||
|
@ -341,7 +358,7 @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
|
|||
uint64_t pac, orig_ptr, test;
|
||||
|
||||
orig_ptr = pauth_original_ptr(ptr, param);
|
||||
pac = pauth_computepac(orig_ptr, modifier, *key);
|
||||
pac = pauth_computepac(env, orig_ptr, modifier, *key);
|
||||
bot_bit = 64 - param.tsz;
|
||||
top_bit = 64 - 8 * param.tbi;
|
||||
|
||||
|
@ -442,7 +459,7 @@ uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y)
|
|||
uint64_t pac;
|
||||
|
||||
pauth_check_trap(env, arm_current_el(env), GETPC());
|
||||
pac = pauth_computepac(x, y, env->keys.apga);
|
||||
pac = pauth_computepac(env, x, y, env->keys.apga);
|
||||
|
||||
return pac & 0xffffffff00000000ull;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue