From: marc.zyngier@arm•com (Marc Zyngier)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH] kvm: arm: Enforce some NS-SVC initialisation
Date: Tue, 16 Aug 2016 14:33:55 +0100 [thread overview]
Message-ID: <57B31643.1000600@arm.com> (raw)
In-Reply-To: <5322cdb9cb397741d15b60c6693ad39dbf74b6d5.1469101945.git.robin.murphy@arm.com>
On 21/07/16 13:01, Robin Murphy wrote:
> Since the non-secure copies of banked registers lack architecturally
> defined reset values, there is no actual guarantee when entering in Hyp
> from secure-only firmware that the non-secure PL1 state will look the
> way that kernel entry (in particular the decompressor stub) expects.
> So far, we've been getting away with it thanks to implementation details
> of ARMv7 cores and/or bootloader behaviour, but for the sake of forwards
> compatibility let's try to ensure that we have a minimally sane state
> before dropping down into it.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm•com>
> ---
> arch/arm/kernel/hyp-stub.S | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S
> index 0b1e4a93d67e..7de3fe15ab21 100644
> --- a/arch/arm/kernel/hyp-stub.S
> +++ b/arch/arm/kernel/hyp-stub.S
> @@ -142,6 +142,18 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE
> and r7, #0x1f @ Preserve HPMN
> mcr p15, 4, r7, c1, c1, 1 @ HDCR
>
> + @ Make sure NS-SVC is initialised appropriately
> + mrc p15, 0, r7, c1, c0, 0 @ SCTLR
> + orr r7, #(1 << 5) @ CP15 barriers enabled
> + bic r7, #(3 << 19) @ WXN and UWXN disabled
I think that while you're doing this, you also may want to clear SED and
ITD so that a BE kernel has a chance to survive its first instruction
(assuming it it uses the decompressor...).
> + mcr p15, 0, r7, c1, c0, 0 @ SCTLR
> +
> + mrc p15, 0, r7, c0, c0, 0 @ MIDR
> + mcr p15, 4, r7, c0, c0, 0 @ VPIDR
> +
> + mrc p15, 0, r7, c0, c0, 5 @ MPIDR
> + mcr p15, 4, r7, c0, c0, 5 @ VMPIDR
> +
> #if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER)
> @ make CNTP_* and CNTPCT accessible from PL1
> mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1
>
Otherwise looks good.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2016-08-16 13:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 12:01 [PATCH] kvm: arm: Enforce some NS-SVC initialisation Robin Murphy
2016-08-16 13:33 ` Marc Zyngier [this message]
2016-08-16 14:51 ` Robin Murphy
2016-08-16 17:49 ` [PATCH v2] " Robin Murphy
2016-08-17 10:05 ` Marc Zyngier
2016-08-17 11:16 ` Christoffer Dall
2016-08-17 11:17 ` Christoffer Dall
2016-08-17 11:32 ` Christoffer Dall
2016-09-06 16:41 ` Christoffer Dall
2016-09-06 16:44 ` Robin Murphy
2016-09-06 16:59 ` Christoffer Dall
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=57B31643.1000600@arm.com \
--to=marc.zyngier@arm$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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