From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Christopher Covington <cov@codeaurora.org>
Cc: "Will Deacon" <will.deacon@arm.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Nicolas Pitre" <nico@linaro.org>,
"Jon Medhurst (Tixy)" <tixy@linaro.org>,
"Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
"Wang Nan" <wangnan0@huawei.com>,
"Nathan Lynch" <nathan_lynch@mentor.com>,
"Stephen Boyd" <sboyd@codeaurora.org>,
"Yingjoe Chen" <yingjoe.chen@mediatek.com>,
"Masahiro Yamada" <yamada.m@jp.panasonic.com>,
"Gregory CLEMENT" <gregory.clement@free-electrons.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Kees Cook" <keescook@chromium.org>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Maxime Coquelin stm32" <mcoquelin.stm32@gmail.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Paul Bolle" <pebolle@tiscali.nl>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm: Handle starting up in secure mode
Date: Wed, 26 Aug 2015 11:46:34 +0100 [thread overview]
Message-ID: <20150826104634.GB21084@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1440424572-27116-1-git-send-email-cov@codeaurora.org>
On Mon, Aug 24, 2015 at 09:55:26AM -0400, Christopher Covington wrote:
> +/*
> + * ARM Linux has the most features available in hypervisor mode and
> + * running in non-secure mode is recommended. Thus, try to get into
> + * hypervisor mode if we're not already there, or failing that, try
> + * to get into non-secure supervisor mode.
> + */
> +ENTRY(__mon_stub_install)
> + /*
> + * Store the mode field of the CPSR in r4 and return early if we're
> + * already in hypervisor mode.
> + */
> + mrs r4, cpsr
> + and r4, r4, #MODE_MASK
> + cmp r4, #HYP_MODE
> + reteq lr
> +
> + /*
> + * Save the link register in a non-banked register, r5, so that we
> + * still have access to it after mode switches.
> + */
> + mov r5, lr
> +
> + /*
> + * Read ID_PFR1 and store the value in r6. This register indicates
> + * the presence of the security and virtualization extensions. The
> + * former is interesting because we must traverse secure monitor mode
> + * to get to hypervisor mode and it allows easy manipulation of
> + * exception vectors via the Vector Base Address Register (VBAR).
> + *
> + * ID_PFR1 also indicates whether the generic timer is present, which
> + * has a handy register for our purposes, CNTFRQ. Accesses won't trap
> + * even with higher exception levels in AArch64 and writes will only
> + * succeed from the highest exception level on a system (the undefined
> + * exception from a failed write is used as a branch).
> + */
> +
> + mrc p15, 0, r6, c0, c1, 1 @ ID_PFR1
As this code can be built into any kernel for a CPU containing a MMU,
including all the way back to ARMv4, you had better make sure that
this code will run there without causing faults.
You should probably be checking the main ID register and ensuring that
the CPU supports the new ID scheme before trying to read CP15 registers
that may not be present in older cores.
> diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
> index 7c6b976..32fa451 100644
> --- a/arch/arm/mm/Kconfig
> +++ b/arch/arm/mm/Kconfig
> @@ -676,7 +676,7 @@ config ARM_THUMBEE
> make use of it. Say N for code that can run on CPUs without ThumbEE.
>
> config ARM_VIRT_EXT
> - bool
> + bool "Support for Virtualization Extensions"
This change is not explained in the commit message.
> depends on MMU
> default y if CPU_V7
> help
> @@ -684,9 +684,21 @@ config ARM_VIRT_EXT
> Extensions to install hypervisors without run-time firmware
> assistance.
>
> - A compliant bootloader is required in order to make maximum
> - use of this feature. Refer to Documentation/arm/Booting for
> - details.
> + A compliant bootloader or enabling ARM_SEC_EXT is required in
> + order to make maximum use of this feature. Refer to
> + Documentation/arm/Booting for details.
> +
> +config ARM_SEC_EXT
> + bool "Support for Security Extensions"
> + depends on MMU
> + default n
Please get rid of this redundant "default n".
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2015-08-26 10:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 13:55 Christopher Covington
2015-08-26 10:37 ` Ard Biesheuvel
2015-08-26 10:39 ` Dave Martin
2015-08-26 10:48 ` Russell King - ARM Linux
2015-08-26 14:19 ` Christopher Covington
2015-08-27 15:28 ` Dave Martin
2015-09-08 13:21 ` Linus Walleij
2015-08-26 10:46 ` Russell King - ARM Linux [this message]
2015-08-27 16:17 ` Daniel Thompson
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=20150826104634.GB21084@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=ard.biesheuvel@linaro.org \
--cc=arnd@arndb.de \
--cc=cov@codeaurora.org \
--cc=f.fainelli@gmail.com \
--cc=gregory.clement@free-electrons.com \
--cc=keescook@chromium.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=nathan_lynch@mentor.com \
--cc=nico@linaro.org \
--cc=pebolle@tiscali.nl \
--cc=sboyd@codeaurora.org \
--cc=tixy@linaro.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wangnan0@huawei.com \
--cc=will.deacon@arm.com \
--cc=yamada.m@jp.panasonic.com \
--cc=yingjoe.chen@mediatek.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
all inboxes | Powered by JetHome®