From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] arm: tcm: Don't crash when TCM banks are protected by TrustZone
Date: Thu, 4 Jun 2015 11:40:31 +0100 [thread overview]
Message-ID: <20150604104031.GB10388@e103592.cambridge.arm.com> (raw)
In-Reply-To: <1433257803-25318-1-git-send-email-michael@smart-africa.com>
On Tue, Jun 02, 2015 at 05:10:03PM +0200, Michael van der Westhuizen wrote:
> Fixes the TCM initialisation code to handle TCM banks that are
> present but inaccessible due to TrustZone configuration. This is
> the default case when enabling the non-secure world. It may also
> be the case that that the user decided to use TCM for TrustZone.
>
> This change has exposed a bug in handling of TCM where no TCM bank
> was usable (the 0 size TCM case). This change addresses the
> resulting hang.
[...]
> + *
> + * Encoding this as per A8.8.107 of DDI0406C, Encoding T1/A1, yields:
> + * 1111 1111 1111 1111 0000 1111 1101 1111 Required Mask
> + * 1110 1110 0001 1001 ???? 1111 0001 0001 mrc p15, 0, XX, c9, c1, 0
> + * 1110 1110 0001 1001 ???? 1111 0011 0001 mrc p15, 0, XX, c9, c1, 1
> + * [ ] [ ] [ ]| [ ] [ ] [ ] [ ]| +--- CRm
> + * | | | | | | | | +----- SBO
> + * | | | | | | | +------- opc2
> + * | | | | | | +----------- coproc
> + * | | | | | +---------------- Rt
> + * | | | | +--------------------- CRn
> + * | | | +------------------------- SBO
> + * | | +--------------------------- opc1
> + * | +------------------------------- instruction
> + * +------------------------------------ condition
> + */
> +#define TCM_REGION_READ_MASK 0xffff0fdf
> +#define TCM_REGION_READ_INSTR 0xee190f11
> +#define DEST_REG_SHIFT 12
> +#define DEST_REG_MASK 0xf
What happens in a Thumb-2 kernel?
I think it is safe, since Thumb-2 kernel implies v7, and v7 mandates the
TCMTR. Even if we did get an Undef, the code in traps.c rearranges the
bits of the offending insn into the "correct" order, and it so happens
that this also makes the encoding for MRC/MCR instructions identical
between ARM and Thumb.
For some other random instruction these assumptions may not hold, so
it is worth adding brief comment in case people blindly use this code
as a template for something else.
[...]
Cheers
---Dave
next prev parent reply other threads:[~2015-06-04 10:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 9:36 [PATCH] arm: tcm: Don't crash when TCM banks are protected by TrustZone Michael van der Westhuizen
2015-05-28 10:16 ` Dave Martin
2015-05-28 11:32 ` Michael van der Westhuizen
2015-05-28 13:32 ` Dave Martin
2015-05-28 13:37 ` Michael van der Westhuizen
2015-05-28 13:54 ` [PATCH v2] " Michael van der Westhuizen
2015-06-02 11:16 ` Linus Walleij
2015-06-02 14:52 ` Russell King - ARM Linux
2015-06-02 15:21 ` Michael van der Westhuizen
2015-06-02 15:35 ` Russell King - ARM Linux
2015-06-02 15:10 ` [PATCH v3] " Michael van der Westhuizen
2015-06-04 10:40 ` Dave Martin [this message]
2015-06-04 11:35 ` Michael van der Westhuizen
2015-06-04 11:58 ` [PATCH v4] " Michael van der Westhuizen
2015-06-04 12:14 ` Linus Walleij
2015-06-04 13:43 ` Dave Martin
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=20150604104031.GB10388@e103592.cambridge.arm.com \
--to=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.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