mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Giorgio Dal Molin <giorgio.nicole@arcor.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: imx7d enable second core
Date: Thu, 19 Jul 2018 17:52:36 +0200 (CEST)	[thread overview]
Message-ID: <493874249.8067.1532015556353@mail.vodafone.de> (raw)
In-Reply-To: <CAHQ1cqFHRFYzKnjhD4-2+=-5dC8AGQNYKyuPZbwp8yWUauXAfw@mail.gmail.com>

Hi Andrey,

> On July 18, 2018 at 6:54 PM Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
> 
> 
> On Wed, Jul 18, 2018 at 12:28 AM Giorgio Dal Molin
> <giorgio.nicole@arcor.de> wrote:
> >
> > Hi all,
> >
> > I'm currently working with the imx7d sabre board from NXP.
> >
> > I have now a running barebox bootloader and a booting kernel.
> >
> > My problem is now that, apparently, only one core is active:
> >
> > ...
> > commandline: console=ttymxc0,115200n8 ip=11.0.0.4::11.0.0.2:255.0.0.0::eth0: root=/dev/mmcblk0p2 rootdelay=1
> > Starting kernel in secure mode
> 
> AFAIK, this means that you are booting in secure mode and secure
> monitor code, which also implements PSCI needed for SMP to work, will
> _not_ be installed by Barebox. One way to fix this would be to set:
> 
>  global.bootm.secure_state=nonsecure
> 
> before booting Linux. Doing that I get:
> 
> # lscpu -e
> CPU SOCKET CORE ONLINE MAXMHZ   MINMHZ
> 0   0      0    yes    996.0000 792.0000
> 1   0      1    yes    996.0000 792.0000
> #
> 
> on my SabreSD board.
> 

I think I've found some inconsistencies in the SECURE / NONSECURE implementation
in barebox.

In arch/arm/include/asm/secure.h there is the definition:

...
enum arm_security_state {
	ARM_STATE_SECURE,
	ARM_STATE_NONSECURE,
 	ARM_STATE_HYP,
 };

where ARM_STATE_SECURE == 0 and ARM_STATE_NONSECURE == 1;

In arch/arm/cpu/psci.c we have:

...
static int of_psci_fixup(struct device_node *root, void *unused)
{
	struct device_node *psci;
	int ret;

	if (bootm_arm_security_state() < ARM_STATE_NONSECURE)
		return 0;

	psci = of_create_node(root, "/psci");
	if (!psci)
 ...

This is a bit surprising and conterintuitive: I think the logic should
be so that if the current mode is not secure then we want to go out, otherwise
we want to generate the /psci {} dt block for the kernel. If this is true then
we have an error here.

One more use of the state is in the start_linux() function, in arch/arm/lib32/armlinux.c:

...
void start_linux(void *adr, int swap, unsigned long initrd_address,
		 unsigned long initrd_size, void *oftree,
		 enum arm_security_state state)
{
	void (*kernel)(int zero, int arch, void *params) = adr;
	void *params = NULL;
	int architecture;
	int ret;

	if (IS_ENABLED(CONFIG_ARM_SECURE_MONITOR) && state > ARM_STATE_NONSECURE) {
		ret = armv7_secure_monitor_install();
		if (ret)
			pr_err("Failed to install secure monitor\n");
	}
...

In this case the secure monitor would be installed only in case state == ARM_STATE_HYP,
also strange...

I tried to fix things so:

In arch/arm/include/asm/secure.h:

...
enum arm_security_state {
	ARM_STATE_NONSECURE,
	ARM_STATE_SECURE,
 	ARM_STATE_HYP,
 };

In arch/arm/cpu/psci.c:

...
static int of_psci_fixup(struct device_node *root, void *unused)
{
	struct device_node *psci;
	int ret;

	if (bootm_arm_security_state() < ARM_STATE_SECURE)
		return 0;

	psci = of_create_node(root, "/psci");
	if (!psci)
 ...

Moreover, in arch/arm/cpu/sm.c I initialized the global var. bootm_secure_state: = ARM_STATE_SECURE

static int sm_init(void)
{
...
	bootm_secure_state = ARM_STATE_SECURE
}

With these fixes I can boot the imx7d sabre in secure mode with 2 cores.
Unfortunately the CAAM cripto module still doesn't work :-(

giorgio

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-07-19 15:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  7:27 Giorgio Dal Molin
2018-07-18  7:56 ` Oleksij Rempel
2018-07-18 16:54 ` Andrey Smirnov
2018-07-19  7:16   ` Giorgio Dal Molin
2018-07-19 16:02     ` Andrey Smirnov
2018-07-19 16:16       ` Giorgio Dal Molin
2018-07-19 15:52   ` Giorgio Dal Molin [this message]
2018-07-19 16:09     ` Andrey Smirnov
2018-07-19 16:18       ` Giorgio Dal Molin
2019-10-15 11:29 Giorgio Dal Molin
2019-10-15 11:37 ` Ahmad Fatoum
2019-10-15 11:51   ` Ahmad Fatoum
2019-10-15 12:11   ` Giorgio Dal Molin
2019-10-15 12:47     ` Ahmad Fatoum

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=493874249.8067.1532015556353@mail.vodafone.de \
    --to=giorgio.nicole@arcor.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@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