target/arm: Inform helpers whether a PAC instruction is 'combined'
An instruction is a 'combined' Pointer Authentication instruction if it does something in addition to PAC -- for instance, branching to or loading an address from the authenticated pointer. Knowing whether a PAC operation is 'combined' is needed to implement FEAT_FPACCOMBINE. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20230829232335.965414-9-richard.henderson@linaro.org Message-Id: <20230609172324.982888-7-aaron@os.amperecomputing.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
c7c807f6dd
commit
28b9dcb74b
@ -90,9 +90,13 @@ DEF_HELPER_FLAGS_3(pacda, TCG_CALL_NO_WG, i64, env, i64, i64)
|
|||||||
DEF_HELPER_FLAGS_3(pacdb, TCG_CALL_NO_WG, i64, env, i64, i64)
|
DEF_HELPER_FLAGS_3(pacdb, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
DEF_HELPER_FLAGS_3(pacga, TCG_CALL_NO_WG, i64, env, i64, i64)
|
DEF_HELPER_FLAGS_3(pacga, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
DEF_HELPER_FLAGS_3(autia, TCG_CALL_NO_WG, i64, env, i64, i64)
|
DEF_HELPER_FLAGS_3(autia, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
|
DEF_HELPER_FLAGS_3(autia_combined, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
DEF_HELPER_FLAGS_3(autib, TCG_CALL_NO_WG, i64, env, i64, i64)
|
DEF_HELPER_FLAGS_3(autib, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
|
DEF_HELPER_FLAGS_3(autib_combined, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64)
|
DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
|
DEF_HELPER_FLAGS_3(autda_combined, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64)
|
DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
|
DEF_HELPER_FLAGS_3(autdb_combined, TCG_CALL_NO_WG, i64, env, i64, i64)
|
||||||
DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64)
|
DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64)
|
||||||
DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64)
|
DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64)
|
||||||
|
|
||||||
|
@ -397,7 +397,8 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
|
static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
|
||||||
ARMPACKey *key, bool data, int keynumber)
|
ARMPACKey *key, bool data, int keynumber,
|
||||||
|
uintptr_t ra, bool is_combined)
|
||||||
{
|
{
|
||||||
ARMCPU *cpu = env_archcpu(env);
|
ARMCPU *cpu = env_archcpu(env);
|
||||||
ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
|
ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
|
||||||
@ -519,44 +520,88 @@ uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y)
|
|||||||
return pac & 0xffffffff00000000ull;
|
return pac & 0xffffffff00000000ull;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y)
|
static uint64_t pauth_autia(CPUARMState *env, uint64_t x, uint64_t y,
|
||||||
|
uintptr_t ra, bool is_combined)
|
||||||
{
|
{
|
||||||
int el = arm_current_el(env);
|
int el = arm_current_el(env);
|
||||||
if (!pauth_key_enabled(env, el, SCTLR_EnIA)) {
|
if (!pauth_key_enabled(env, el, SCTLR_EnIA)) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
pauth_check_trap(env, el, GETPC());
|
pauth_check_trap(env, el, ra);
|
||||||
return pauth_auth(env, x, y, &env->keys.apia, false, 0);
|
return pauth_auth(env, x, y, &env->keys.apia, false, 0, ra, is_combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y)
|
uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autia(env, x, y, GETPC(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t HELPER(autia_combined)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autia(env, x, y, GETPC(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t pauth_autib(CPUARMState *env, uint64_t x, uint64_t y,
|
||||||
|
uintptr_t ra, bool is_combined)
|
||||||
{
|
{
|
||||||
int el = arm_current_el(env);
|
int el = arm_current_el(env);
|
||||||
if (!pauth_key_enabled(env, el, SCTLR_EnIB)) {
|
if (!pauth_key_enabled(env, el, SCTLR_EnIB)) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
pauth_check_trap(env, el, GETPC());
|
pauth_check_trap(env, el, ra);
|
||||||
return pauth_auth(env, x, y, &env->keys.apib, false, 1);
|
return pauth_auth(env, x, y, &env->keys.apib, false, 1, ra, is_combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y)
|
uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autib(env, x, y, GETPC(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t HELPER(autib_combined)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autib(env, x, y, GETPC(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t pauth_autda(CPUARMState *env, uint64_t x, uint64_t y,
|
||||||
|
uintptr_t ra, bool is_combined)
|
||||||
{
|
{
|
||||||
int el = arm_current_el(env);
|
int el = arm_current_el(env);
|
||||||
if (!pauth_key_enabled(env, el, SCTLR_EnDA)) {
|
if (!pauth_key_enabled(env, el, SCTLR_EnDA)) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
pauth_check_trap(env, el, GETPC());
|
pauth_check_trap(env, el, ra);
|
||||||
return pauth_auth(env, x, y, &env->keys.apda, true, 0);
|
return pauth_auth(env, x, y, &env->keys.apda, true, 0, ra, is_combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y)
|
uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autda(env, x, y, GETPC(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t HELPER(autda_combined)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autda(env, x, y, GETPC(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t pauth_autdb(CPUARMState *env, uint64_t x, uint64_t y,
|
||||||
|
uintptr_t ra, bool is_combined)
|
||||||
{
|
{
|
||||||
int el = arm_current_el(env);
|
int el = arm_current_el(env);
|
||||||
if (!pauth_key_enabled(env, el, SCTLR_EnDB)) {
|
if (!pauth_key_enabled(env, el, SCTLR_EnDB)) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
pauth_check_trap(env, el, GETPC());
|
pauth_check_trap(env, el, ra);
|
||||||
return pauth_auth(env, x, y, &env->keys.apdb, true, 1);
|
return pauth_auth(env, x, y, &env->keys.apdb, true, 1, ra, is_combined);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autdb(env, x, y, GETPC(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t HELPER(autdb_combined)(CPUARMState *env, uint64_t x, uint64_t y)
|
||||||
|
{
|
||||||
|
return pauth_autdb(env, x, y, GETPC(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(xpaci)(CPUARMState *env, uint64_t a)
|
uint64_t HELPER(xpaci)(CPUARMState *env, uint64_t a)
|
||||||
|
@ -1530,9 +1530,9 @@ static TCGv_i64 auth_branch_target(DisasContext *s, TCGv_i64 dst,
|
|||||||
|
|
||||||
truedst = tcg_temp_new_i64();
|
truedst = tcg_temp_new_i64();
|
||||||
if (use_key_a) {
|
if (use_key_a) {
|
||||||
gen_helper_autia(truedst, cpu_env, dst, modifier);
|
gen_helper_autia_combined(truedst, cpu_env, dst, modifier);
|
||||||
} else {
|
} else {
|
||||||
gen_helper_autib(truedst, cpu_env, dst, modifier);
|
gen_helper_autib_combined(truedst, cpu_env, dst, modifier);
|
||||||
}
|
}
|
||||||
return truedst;
|
return truedst;
|
||||||
}
|
}
|
||||||
@ -3352,10 +3352,10 @@ static bool trans_LDRA(DisasContext *s, arg_LDRA *a)
|
|||||||
|
|
||||||
if (s->pauth_active) {
|
if (s->pauth_active) {
|
||||||
if (!a->m) {
|
if (!a->m) {
|
||||||
gen_helper_autda(dirty_addr, cpu_env, dirty_addr,
|
gen_helper_autda_combined(dirty_addr, cpu_env, dirty_addr,
|
||||||
tcg_constant_i64(0));
|
tcg_constant_i64(0));
|
||||||
} else {
|
} else {
|
||||||
gen_helper_autdb(dirty_addr, cpu_env, dirty_addr,
|
gen_helper_autdb_combined(dirty_addr, cpu_env, dirty_addr,
|
||||||
tcg_constant_i64(0));
|
tcg_constant_i64(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user