From: Peter Maydell <peter.maydell@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
Aaron Lindsay <aaron@os.amperecomputing.com>
Subject: Re: [PATCH v4 3/9] target/arm: Add feature detection for FEAT_Pauth2 and extensions
Date: Tue, 29 Aug 2023 14:00:00 +0100 [thread overview]
Message-ID: <CAFEAcA9Wi-CU9uk_p4wze9OFQuHJdg_5zjYhOx2awsOOhNdA+A@mail.gmail.com> (raw)
In-Reply-To: <20230822042530.1026751-4-richard.henderson@linaro.org>
On Tue, 22 Aug 2023 at 05:27, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> From: Aaron Lindsay <aaron@os.amperecomputing.com>
>
> Rename isar_feature_aa64_pauth_arch to isar_feature_aa64_pauth_qarma5
> to distinguish the other architectural algorithm qarma3.
>
> Add ARMPauthFeature and isar_feature_pauth_feature to cover the
> other pauth conditions.
>
> Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com>
> Message-Id: <20230609172324.982888-3-aaron@os.amperecomputing.com>
> [rth: Add ARMPauthFeature and eliminate most other predicates]
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/arm/cpu.h | 49 +++++++++++++++++++++++++++++------
> target/arm/tcg/pauth_helper.c | 2 +-
> 2 files changed, 42 insertions(+), 9 deletions(-)
>
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index fbdbf2df7f..e9fe268453 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -3794,28 +3794,61 @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id)
> return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0;
> }
>
> +/*
> + * These are the values from APA/API/APA3.
> + *
> + * They must be compared '>=', except EPAC should use '=='.
> + * In the ARM pseudocode, EPAC is treated as not being implemented
> + * by larger values.
> + */
Yeah, but we use PauthFeat_EPAC in exactly one place and
deliberately in a way where it doesn't matter if we use >=...
(I think the pseudocode would be clearer if it was adjusted
to do the same, personally. This ID register field follows
the standard ID scheme which means that increasing values
are supersets, so the "only if equal" part is weird.)
> +typedef enum {
> + PauthFeat_None = 0,
> + PauthFeat_1 = 1,
> + PauthFeat_EPAC = 2,
> + PauthFeat_2 = 3,
> + PauthFeat_FPAC = 4,
> + PauthFeat_FPACCOMBINED = 5,
> +} ARMPauthFeature;
> +
> +static inline ARMPauthFeature
> +isar_feature_pauth_feature(const ARMISARegisters *id)
> +{
> + /*
> + * Architecturally, only one of {APA,API,APA3} may be active (non-zero)
> + * and the other two must be zero. Thus we may avoid conditionals.
> + */
> + return (FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) |
> + FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, API) |
> + FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3));
> +}
> +
> static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id)
> {
> /*
> * Return true if any form of pauth is enabled, as this
> * predicate controls migration of the 128-bit keys.
> */
> - return (id->id_aa64isar1 &
> - (FIELD_DP64(0, ID_AA64ISAR1, APA, 0xf) |
> - FIELD_DP64(0, ID_AA64ISAR1, API, 0xf) |
> - FIELD_DP64(0, ID_AA64ISAR1, GPA, 0xf) |
> - FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0;
> + return isar_feature_pauth_feature(id) != PauthFeat_None;
Having said "must be compared >=" you then use a != comparison here :-)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
next prev parent reply other threads:[~2023-08-29 13:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 4:25 [PATCH v4 0/9] Implement Most ARMv8.3 Pointer Authentication Features Richard Henderson
2023-08-22 4:25 ` [PATCH v4 1/9] tests/tcg/aarch64: Adjust pauth tests for FEAT_FPAC Richard Henderson
2023-08-29 12:52 ` Peter Maydell
2023-08-29 22:05 ` Richard Henderson
2023-08-22 4:25 ` [PATCH v4 2/9] target/arm: Add ID_AA64ISAR2_EL1 Richard Henderson
2023-08-22 6:14 ` Philippe Mathieu-Daudé
2023-08-22 4:25 ` [PATCH v4 3/9] target/arm: Add feature detection for FEAT_Pauth2 and extensions Richard Henderson
2023-08-29 13:00 ` Peter Maydell [this message]
2023-08-22 4:25 ` [PATCH v4 4/9] target/arm: Don't change pauth features when changing algorithm Richard Henderson
2023-08-29 13:05 ` Peter Maydell
2023-08-22 4:25 ` [PATCH v4 5/9] target/arm: Implement FEAT_PACQARMA3 Richard Henderson
2023-08-22 4:25 ` [PATCH v4 6/9] target/arm: Implement FEAT_EPAC Richard Henderson
2023-08-22 4:25 ` [PATCH v4 7/9] target/arm: Implement FEAT_Pauth2 Richard Henderson
2023-08-22 4:25 ` [PATCH v4 8/9] targer/arm: Inform helpers whether a PAC instruction is 'combined' Richard Henderson
2023-08-22 6:28 ` Philippe Mathieu-Daudé
2023-08-22 4:25 ` [PATCH v4 9/9] target/arm: Implement FEAT_FPAC and FEAT_FPACCOMBINE Richard Henderson
2023-08-22 9:40 ` [PATCH v4 0/9] Implement Most ARMv8.3 Pointer Authentication Features Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFEAcA9Wi-CU9uk_p4wze9OFQuHJdg_5zjYhOx2awsOOhNdA+A@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=aaron@os.amperecomputing.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).