From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 3/6] target/arm: Honor TCR_ELx.{I}PS
Date: Tue, 14 Dec 2021 14:47:32 +0000 [thread overview]
Message-ID: <877dc7i6h3.fsf@linaro.org> (raw)
In-Reply-To: <20211208231154.392029-4-richard.henderson@linaro.org>
Richard Henderson <richard.henderson@linaro.org> writes:
> This field controls the output (intermediate) physical address size
> of the translation process. V8 requires to raise an AddressSize
> fault if the page tables are programmed incorrectly, such that any
> intermediate descriptor address, or the final translated address,
> is out of range.
>
> Add an outputsize field to ARMVAParameters, and fill it in during
> aa64_va_parameters. Pass the value to check_s2_mmu_setup to use
> instead of the raw PAMax value. Test the descaddr as extracted
> from TTBR and from page table entries.
>
> Restrict descaddrmask so that we won't raise the fault for v7.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/arm/internals.h | 1 +
> target/arm/helper.c | 92 +++++++++++++++++++++++++++++-------------
> 2 files changed, 65 insertions(+), 28 deletions(-)
>
> diff --git a/target/arm/internals.h b/target/arm/internals.h
> index 27d2fcd26c..3e801833b4 100644
> --- a/target/arm/internals.h
> +++ b/target/arm/internals.h
> @@ -1032,6 +1032,7 @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)
> */
> typedef struct ARMVAParameters {
> unsigned tsz : 8;
> + unsigned ps : 3;
> unsigned select : 1;
> bool tbi : 1;
> bool epd : 1;
> diff --git a/target/arm/helper.c b/target/arm/helper.c
> index fab9ee70d8..568914bd42 100644
> --- a/target/arm/helper.c
> +++ b/target/arm/helper.c
> @@ -11003,7 +11003,7 @@ do_fault:
> * false otherwise.
> */
> static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,
> - int inputsize, int stride)
> + int inputsize, int stride, int outputsize)
> {
> const int grainsize = stride + 3;
> int startsizecheck;
> @@ -11019,22 +11019,19 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,
> }
>
> if (is_aa64) {
> - CPUARMState *env = &cpu->env;
> - unsigned int pamax = arm_pamax(cpu);
> -
> switch (stride) {
> case 13: /* 64KB Pages. */
> - if (level == 0 || (level == 1 && pamax <= 42)) {
> + if (level == 0 || (level == 1 && outputsize <= 42)) {
> return false;
> }
> break;
> case 11: /* 16KB Pages. */
> - if (level == 0 || (level == 1 && pamax <= 40)) {
> + if (level == 0 || (level == 1 && outputsize <= 40)) {
> return false;
> }
> break;
> case 9: /* 4KB Pages. */
> - if (level == 0 && pamax <= 42) {
> + if (level == 0 && outputsize <= 42) {
> return false;
> }
> break;
> @@ -11043,8 +11040,8 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,
> }
>
> /* Inputsize checks. */
> - if (inputsize > pamax &&
> - (arm_el_is_aa64(env, 1) || inputsize > 40)) {
> + if (inputsize > outputsize &&
> + (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) {
> /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */
> return false;
> }
> @@ -11090,17 +11087,19 @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs)
> }
> #endif /* !CONFIG_USER_ONLY */
>
> +/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */
> +static const uint8_t pamax_map[] = {
> + [0] = 32,
> + [1] = 36,
> + [2] = 40,
> + [3] = 42,
> + [4] = 44,
> + [5] = 48,
> +};
I note that the IPS encoding includes b110 (6) for 52 bits or 4PB
addressing. I guess that gets introduced later.
Anyway:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
next prev parent reply other threads:[~2021-12-14 15:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 23:11 [PATCH for-7.0 0/6] target/arm: Implement LVA, LPA, LPA2 features Richard Henderson
2021-12-08 23:11 ` [PATCH 1/6] target/arm: Fault on invalid TCR_ELx.TxSZ Richard Henderson
2021-12-14 14:34 ` Alex Bennée
2022-01-06 18:27 ` Peter Maydell
2022-01-11 16:00 ` Peter Maydell
2021-12-08 23:11 ` [PATCH 2/6] target/arm: Move arm_pamax out of line Richard Henderson
2021-12-09 7:28 ` Philippe Mathieu-Daudé
2021-12-14 14:36 ` Alex Bennée
2021-12-08 23:11 ` [PATCH 3/6] target/arm: Honor TCR_ELx.{I}PS Richard Henderson
2021-12-09 7:43 ` Philippe Mathieu-Daudé
2021-12-14 14:47 ` Alex Bennée [this message]
2022-01-06 20:08 ` Peter Maydell
2021-12-08 23:11 ` [PATCH 4/6] target/arm: Implement FEAT_LVA Richard Henderson
2021-12-14 14:53 ` Alex Bennée
2022-01-06 20:23 ` Peter Maydell
2022-02-10 0:17 ` Richard Henderson
2021-12-08 23:11 ` [PATCH 5/6] target/arm: Implement FEAT_LPA Richard Henderson
2022-01-07 10:53 ` Peter Maydell
2021-12-08 23:11 ` [PATCH 6/6] target/arm: Implement FEAT_LPA2 Richard Henderson
2021-12-14 14:57 ` Alex Bennée
2021-12-14 20:24 ` Richard Henderson
2022-01-07 14:39 ` Peter Maydell
2022-02-10 2:48 ` Richard Henderson
2021-12-14 16:37 ` [PATCH for-7.0 0/6] target/arm: Implement LVA, LPA, LPA2 features Alex Bennée
2021-12-14 17:46 ` Richard Henderson
2022-01-20 16:09 ` 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=877dc7i6h3.fsf@linaro.org \
--to=alex.bennee@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.