From: Marc Zyngier <marc.zyngier@arm.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 06/10] ARM: HYP/non-sec: allow relocation to secure RAM
Date: Wed, 07 May 2014 07:51:37 +0100 [thread overview]
Message-ID: <87fvkmqdxi.fsf@why.wild-wind.fr.eu.org> (raw)
In-Reply-To: <CAJgR-Bgws78F7eGW4t0vVU1hPGoRuo4Mx2SJ9rkHnH2BsPmgpw@mail.gmail.com> (Jon Loeliger's message of "Fri, 2 May 2014 21:30:05 +0100")
On Fri, May 02 2014 at 9:30:05 pm BST, Jon Loeliger <loeliger@gmail.com> wrote:
Hi Jon,
> I finally have all this working for me on an A9 system too!
Awesome! Ship it! ;-)
> However, there were a few things that I had to change a bit.
> For example, by CPUs will always come out of reset at 0x0
> and I do not have the ability to set their first-fetch address to
> anything else. To accommodate this, I need to ensure that
> the _monitor_vectors are loaded at address 0x0, and that
> the first entry in the exception vector (for reset) jumped to
> some notion of "secure_reset code". So I changed this code:
>
>
>> diff --git a/arch/arm/cpu/armv7/nonsec_virt.S
>> b/arch/arm/cpu/armv7/nonsec_virt.S
>> index b5c946f..2a43e3c 100644
>> --- a/arch/arm/cpu/armv7/nonsec_virt.S
>> +++ b/arch/arm/cpu/armv7/nonsec_virt.S
>> @@ -10,10 +10,13 @@
> > #include <linux/linkage.h>
> > #include <asm/gic.h>
> > #include <asm/armv7.h>
>> +#include <asm/proc-armv/ptrace.h>
>>
>> .arch_extension sec
>> .arch_extension virt
>>
>> + .pushsection ._secure.text, "ax"
>> +
>> .align 5
>> /* the vector table for secure state and HYP mode */
>> _monitor_vectors:
>> @@ -22,51 +25,86 @@ _monitor_vectors:
>> adr pc, _secure_monitor
>> .word 0
>> .word 0
>> - adr pc, _hyp_trap
>> + .word 0
>> .word 0
>> .word 0
>>
>> +.macro is_cpu_virt_capable tmp
>> + mrc p15, 0, \tmp, c0, c1, 1 @ read ID_PFR1
>> + and \tmp, \tmp, #CPUID_ARM_VIRT_MASK @ mask virtualization bits
>> + cmp \tmp, #(1 << CPUID_ARM_VIRT_SHIFT)
>> +.endm
>
> So that it did this too:
>
> @@ -20,15 +20,23 @@
> .align 5
> /* the vector table for secure state and HYP mode */
> _monitor_vectors:
> - .word 0 /* reset */
> - .word 0 /* undef */
> - adr pc, _secure_monitor
> + ldr pc, _secure_reset /* reset */
> + .word 0 /* undef */
> + adr pc, _secure_monitor /* SMC */
> .word 0
> .word 0
> .word 0
> .word 0
> .word 0
>
> +
> +_secure_reset:
> +#ifdef CONFIG_SECURE_MONITOR_RESET_FUNCTION
> + .word CONFIG_SECURE_MONITOR_RESET_FUNCTION
> +#else
> + .word 0
> +#endif
> +
> .macro is_cpu_virt_capable tmp
>
> That enabled me to define CONFIG_SECURE_MONITOR_RESET_FUNCTION
> in my config header file:
>
> /*
> * With the Secure Monitor at 0x0, its reset vector must also
> * then point off to the correct "out-of-reset entry function."
> */
> #define CONFIG_SECURE_MONITOR_RESET_FUNCTION _myplatform_cpu_entry
> #define CONFIG_ARMV7_SECURE_BASE 0x0
>
> That _myplatform_cpu_entry corresponds to your sunxi_cpu_entry code.
Yup, makes sense. Nit-pick: make the _secure_reset a weak symbol that
your platform code will overload, just like the rest of the PSCI
stuff. Saves the #ifdef horror; ;-)
> So, yeah, I know that isn't a proper patch and all. :-) I'm just
> sending you more information to ponder for this patch series! If you
> would like to generalize your patch this way, please feel free to do
> so. If not, I can send a proper patch after this hits mainline or so.
My prefered way would be indeed to have a proper patch on top of this to
handle the "coming out of reset" case. You'll get proper credit for the
idea! :-)
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2014-05-07 6:51 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-26 12:17 [U-Boot] [PATCH v4 00/10] ARMv7: add PSCI support to U-Boot Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 01/10] ARM: HYP/non-sec: move switch to non-sec to the last boot phase Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 02/10] ARM: HYP/non-sec: add a barrier after setting SCR.NS==1 Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 03/10] ARM: non-sec: reset CNTVOFF to zero Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 04/10] ARM: add missing HYP mode constant Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 05/10] ARM: HYP/non-sec: add separate section for secure code Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 06/10] ARM: HYP/non-sec: allow relocation to secure RAM Marc Zyngier
2014-05-02 20:30 ` Jon Loeliger
2014-05-02 21:03 ` Jon Loeliger
2014-05-07 7:05 ` Marc Zyngier
2014-05-07 14:28 ` Jon Loeliger
2014-05-07 6:51 ` Marc Zyngier [this message]
2014-05-07 14:30 ` Jon Loeliger
2014-06-09 19:06 ` Albert ARIBAUD
2014-04-26 12:17 ` [U-Boot] [PATCH v4 07/10] ARM: HYP/non-sec: add generic ARMv7 PSCI code Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 08/10] ARM: HYP/non-sec: add the option for a second-stage monitor Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 09/10] ARM: convert arch_fixup_memory_node to a generic FDT fixup function Marc Zyngier
2014-04-26 12:17 ` [U-Boot] [PATCH v4 10/10] ARM: HYP/non-sec/PSCI: emit DT nodes Marc Zyngier
2014-04-26 17:34 ` [U-Boot] DA850EVM with USE_NAND config does not pad the AIS file Tom Taylor
2014-05-05 13:09 ` Tom Rini
2014-05-02 20:13 ` [U-Boot] [PATCH v4 10/10] ARM: HYP/non-sec/PSCI: emit DT nodes Jon Loeliger
2014-05-07 6:38 ` Marc Zyngier
2014-04-26 14:24 ` [U-Boot] [PATCH v4 00/10] ARMv7: add PSCI support to U-Boot Dennis Gilmore
2014-04-26 16:31 ` Marc Zyngier
2014-04-26 21:34 ` Dennis Gilmore
2014-05-05 14:34 ` Jon Loeliger
2014-05-07 7:08 ` Marc Zyngier
2014-05-25 14:08 ` Albert ARIBAUD
2014-06-08 7:57 ` Albert ARIBAUD
2014-06-09 8:12 ` Marc Zyngier
2014-06-09 9:34 ` Albert ARIBAUD
2014-06-10 8:36 ` Albert ARIBAUD
2014-06-10 9:06 ` [U-Boot] [PATCH v4 00/10] ARMv7: add PSCI support to U-Boot - *not* applied Albert ARIBAUD
2014-06-10 9:11 ` Albert ARIBAUD
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=87fvkmqdxi.fsf@why.wild-wind.fr.eu.org \
--to=marc.zyngier@arm.com \
--cc=u-boot@lists.denx.de \
/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