From 8796fe40dd30cd9ffd3c958906471715c923b341 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 3 Aug 2020 17:55:03 +0100 Subject: target/arm: Fix AddPAC error indication The definition of top_bit used in this function is one higher than that used in the Arm ARM psuedo-code, which put the error indication at top_bit - 1 at the wrong place, which meant that it wasn't visible to Auth. Fixing the definition of top_bit requires more changes, because its most common use is for the count of bits in top_bit:bot_bit, which would then need to be computed as top_bit - bot_bit + 1. For now, prefer the minimal fix to the error indication alone. Fixes: 63ff0ca94cb Reported-by: Derrick McKee Signed-off-by: Richard Henderson Message-id: 20200728195706.11087-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell [PMM: added comment about the divergence from the pseudocode] Signed-off-by: Peter Maydell --- target/arm/pauth_helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'target') diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index b909630317..6dbab03768 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -300,7 +300,11 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, */ test = sextract64(ptr, bot_bit, top_bit - bot_bit); if (test != 0 && test != -1) { - pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); + /* + * Note that our top_bit is one greater than the pseudocode's + * version, hence "- 2" here. + */ + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); } /* -- cgit v1.2.3