From: Jim MacArthur <jim.macarthur@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 3/5] target/arm/ptw.c: Add Granule Bypass Windows
Date: Fri, 29 May 2026 17:44:49 +0100 [thread overview]
Message-ID: <ahnCgXdlwjro5Ybj@linaro.org> (raw)
In-Reply-To: <c5e98ece-ecad-42cc-9b83-154453f535a5@linaro.org>
On Thu, May 28, 2026 at 11:52:09AM -0700, Richard Henderson wrote:
> On 5/28/26 08:34, Jim MacArthur wrote:
> > + /*
> > + * GPC Priority 1 (R_GMGRR):
> > + * If GPCCR_EL3.GPCBW is 1 and the configuration GPCBW
> > + * is invalid, the access fails as GPT walk fault at level 0.
> > + */
> > + if (FIELD_EX64(gpccr, GPCCR, GPCBW)) {
> > + /*
> > + * GPCBW is invalid if the base address is:
> > + * not aligned to the size programmed in BWSIZE, or
> > + * greater than or equal to the stride value configured by BWSTRIDE.
> > + */
> > + uint64_t bw_size_mask = -1L << (bw_size_field + 31);
> > + if (bw_start & bw_size_mask) {
> > + goto fault_walk;
> > + }
> > + if (bw_start & bw_stride_mask) {
> > + goto fault_walk;
> > + }
> > + }
> > +
> > switch (FIELD_EX64(gpccr, GPCCR, PGS)) {
>
> ... here.
>
> None of the checks you're adding are correct:
> - Missing size and stride validation,
> - Alignment check vs size is incorrect; you wanted
>
> bw_start & MAKE_64BIT_MASK(0, bw_size + BW_ADDR_SHIFT)
>
> - Check vs stride is incorrect; you wanted bw_stride <= bw_addr.
>
> See GPCRegistersConsistent().
Thanks for the review Richard; the bw_size_mask check was indeed wrong.
On bw_stride_mask: it was intended to keep the high bits in bw_stride_mask
hence this bitwise comparison should have been equivalent to
bw_stride <= bw_addr; in fact the other use of bw_stride_mask was incorrect.
However, since both Arm and Intel GCC produce roughly the same code for both
I will replace it with the more readable arithmetic operation.
On size and stride validation: there are reserved values for these fields,
but the ARM does not say explicitly (that I can see) that they make GPCBW
/invalid/, so it wasn't clear to me that we should fault on these.
Jim
next prev parent reply other threads:[~2026-05-29 16:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 15:34 [PATCH 0/5] target/arm: Add aarch64 GPC3 bypass windows Jim MacArthur
2026-05-28 15:34 ` [PATCH 1/5] target/arm/cpu-features.h: x-rme now means GPC3 Jim MacArthur
2026-05-28 18:03 ` Richard Henderson
2026-05-28 15:34 ` [PATCH 2/5] target/arm: Setup new registers for GPC3 Jim MacArthur
2026-05-28 18:14 ` Richard Henderson
2026-05-28 18:25 ` Richard Henderson
2026-05-28 15:34 ` [PATCH 3/5] target/arm/ptw.c: Add Granule Bypass Windows Jim MacArthur
2026-05-28 18:52 ` Richard Henderson
2026-05-29 16:44 ` Jim MacArthur [this message]
2026-05-29 17:11 ` Richard Henderson
2026-05-28 15:34 ` [PATCH 4/5] tests/tcg/aarch64/system: Alternative boot object for exception logging Jim MacArthur
2026-05-28 15:34 ` [PATCH 5/5] tests/tcg/aarch64/system/gpc-test.c: Basic test for granule protection check Jim MacArthur
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=ahnCgXdlwjro5Ybj@linaro.org \
--to=jim.macarthur@linaro.org \
--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 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.