From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org,
qemu-devel@nongnu.org, agraf@suse.de,
laurent.desnogues@gmail.com, serge.fdrv@gmail.com
Subject: Re: [Qemu-devel] [PATCH v3 3/9] target-arm: Add support for S2 page-table protection bits
Date: Wed, 07 Oct 2015 17:19:50 +0100 [thread overview]
Message-ID: <87612iy7kp.fsf@linaro.org> (raw)
In-Reply-To: <1443911939-2825-4-git-send-email-edgar.iglesias@gmail.com>
Edgar E. Iglesias <edgar.iglesias@gmail.com> writes:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> ---
> target-arm/helper.c | 41 +++++++++++++++++++++++++++++++++++++----
> 1 file changed, 37 insertions(+), 4 deletions(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 507324f..610f1b5 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -6015,6 +6015,28 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
> return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx));
> }
>
> +/* Translate S2 section/page access permissions to protection flags
> + *
> + * @env: CPUARMState
> + * @s2ap: The 2-bit stage2 access permissions (S2AP)
> + * @xn: XN (execute-never) bit
> + */
> +static int get_S2prot(CPUARMState *env, int s2ap, int xn)
> +{
> + int prot = 0;
> +
> + if (s2ap & 1) {
> + prot |= PAGE_READ;
> + }
> + if (s2ap & 2) {
> + prot |= PAGE_WRITE;
> + }
> + if (!xn) {
> + prot |= PAGE_EXEC;
> + }
> + return prot;
> +}
> +
> /* Translate section/page access permissions to protection flags
> *
> * @env: CPUARMState
> @@ -6628,9 +6650,15 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
> */
> page_size = (1ULL << ((granule_sz * (4 - level)) + 3));
> descaddr |= (address & (page_size - 1));
> - /* Extract attributes from the descriptor and merge with table attrs */
> + /* Extract attributes from the descriptor */
> attrs = extract64(descriptor, 2, 10)
> | (extract64(descriptor, 52, 12) << 10);
> +
> + if (mmu_idx == ARMMMUIdx_S2NS) {
> + /* Stage 2 table descriptors do not include any attribute fields */
> + break;
> + }
> + /* Merge in attributes from table descriptors */
> attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
> attrs |= extract32(tableattrs, 3, 1) << 5; /* APTable[1] => AP[2] */
> /* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
> @@ -6652,11 +6680,16 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
> }
>
> ap = extract32(attrs, 4, 2);
> - ns = extract32(attrs, 3, 1);
> xn = extract32(attrs, 12, 1);
> - pxn = extract32(attrs, 11, 1);
OK I've gotten lost in the ARM ARM. Is there an architecture defined
format the final attrs we construct from the page tables is meant to
conform to? Or is the choice of the final structure arbitrary?
>
> - *prot = get_S1prot(env, mmu_idx, va_size == 64, ap, ns, xn, pxn);
> + if (mmu_idx == ARMMMUIdx_S2NS) {
> + ns = true;
> + *prot = get_S2prot(env, ap, xn);
> + } else {
> + ns = extract32(attrs, 3, 1);
> + pxn = extract32(attrs, 11, 1);
> + *prot = get_S1prot(env, mmu_idx, va_size == 64, ap, ns, xn, pxn);
> + }
>
> fault_type = permission_fault;
> if (!(*prot & (1 << access_type))) {
--
Alex Bennée
next prev parent reply other threads:[~2015-10-07 16:19 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-03 22:38 [Qemu-devel] [PATCH v3 0/9] arm: Steps towards EL2 support round 5 Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 1/9] target-arm: Add HPFAR_EL2 Edgar E. Iglesias
2015-10-07 11:51 ` Alex Bennée
2015-10-07 21:18 ` Peter Maydell
2015-10-08 7:52 ` Alex Bennée
2015-10-08 5:38 ` Laurent Desnogues
2015-10-08 8:18 ` Peter Maydell
2015-10-08 8:24 ` Alex Bennée
2015-10-08 9:40 ` Laurent Desnogues
2015-10-08 9:14 ` Alex Bennée
2015-10-08 19:16 ` Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 2/9] target-arm: Add computation of starting level for S2 PTW Edgar E. Iglesias
2015-10-07 12:24 ` Alex Bennée
2015-10-08 19:35 ` Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 3/9] target-arm: Add support for S2 page-table protection bits Edgar E. Iglesias
2015-10-07 16:19 ` Alex Bennée [this message]
2015-10-07 23:11 ` Peter Maydell
2015-10-14 12:45 ` Alex Bennée
2015-10-14 19:38 ` Peter Maydell
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 4/9] target-arm: Avoid inline for get_phys_addr Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 5/9] target-arm: Add ARMMMUFaultInfo Edgar E. Iglesias
2015-10-07 16:24 ` Alex Bennée
2015-10-08 19:25 ` Edgar E. Iglesias
2015-10-08 20:06 ` Edgar E. Iglesias
2015-10-08 21:15 ` Peter Maydell
2015-10-14 13:00 ` Alex Bennée
2015-10-14 20:47 ` Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 6/9] target-arm: Add S2 translation to 64bit S1 PTWs Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 7/9] target-arm: Add S2 translation to 32bit " Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 8/9] target-arm: Route S2 MMU faults to EL2 Edgar E. Iglesias
2015-10-03 22:38 ` [Qemu-devel] [PATCH v3 9/9] target-arm: Add support for S1 + S2 MMU translations Edgar E. Iglesias
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=87612iy7kp.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=agraf@suse.de \
--cc=edgar.iglesias@gmail.com \
--cc=edgar.iglesias@xilinx.com \
--cc=laurent.desnogues@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=serge.fdrv@gmail.com \
/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).