ARM: bootm: Allow booting in secure mode on hyp capable systems
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Older Linux kernels will not properly boot in hype mode, add support for a bootm_boot_mode environment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.
--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
arch/arm/lib/bootm.c +18 -5
@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {
@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2); +if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif +kernel_entry (0 , machid, r2); }#endif }
Signature · 1 line
2.1.0
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 5 lines · Hans de Goede
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>
Looks good to me.
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Hi Marc, Hans,
Quoted 5 lines · Marc Zyngier
Quoted 4 lines · Hans de Goede
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.
Quoted 7 lines
Quoted 1 line
Signed-off-by Hans de Goede <[email protected]>Looks good to me.
Acked-by Marc Zyngier <[email protected]>M.
Should we consider this a bugfix? For instance, hHow old are these "older kernels"?
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 12 lines · Albert ARIBAUD
Hi Marc, Hans,
Quoted 7 lines · Marc Zyngier
Quoted 5 lines · Hans de Goede
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>
Quoted 8 lines
Quoted 5 lines
Looks good to me.
Acked-by Marc Zyngier <[email protected]>M.Should we consider this a bugfix? For instance, hHow old are these "older kernels"?
No idea. Probably in the low 3.x range, for x <= 4. Not sure if that's a bug fix though...
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
In reply to Hans de GoedeQuoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);
arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }
BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
https://github.com/ssvb/u-boot-sunxi-dram/commit/e914abe551e712a59a8fc1ac9a4b8490e8e7c866
Signature · 2 lines
Best regards, Siarhei Siamashka
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 57 lines · Siarhei Siamashka
Quoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
Quoted 1 line
https://github.com/ssvb/u-boot-sunxi-dram/commit/e914abe551e712a59a8fc1ac9a4b8490e8e7c866
And thus preventing kernels with appended DT (not provided by u-boot), but still using HYP/non-sec/PSCI from booting.
Sorry, but using DT as a way to distinguish between all these cases is just wrong.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 60 lines · On Wed, 15 Oct 2014 11:31:44 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 57 lines · Siarhei Siamashka
Quoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
Quoted 7 lines
And thus preventing kernels with appended DT (not provided by u-boot), but still using HYP/non-sec/PSCI from booting.
Sorry, but using DT as a way to distinguish between all these cases is just wrong.
Thanks,
Do you see the HACK prefix in the summary of that patch?
Or are you saying that it is really impossible to distinguish your use case of having the appended DT without resorting to the use of the environment config options?
Signature · 2 lines
Best regards, Siarhei Siamashka
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 67 lines · Siarhei Siamashka
Quoted 64 lines · On Wed, 15 Oct 2014 11:31:44 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 57 lines · Siarhei Siamashka
Quoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
Quoted 1 line
https://github.com/ssvb/u-boot-sunxi-dram/commit/e914abe551e712a59a8fc1ac9a4b8490e8e7c866And thus preventing kernels with appended DT (not provided by u-boot), but still using HYP/non-sec/PSCI from booting.
Quoted 6 lines
Quoted 4 lines
Sorry, but using DT as a way to distinguish between all these cases is just wrong.
Thanks,
Do you see the HACK prefix in the summary of that patch?
I do. But the fact that you even mention it here makes me think that you believe it is a better approach that Hans'.
Quoted 3 lines
Or are you saying that it is really impossible to distinguish your use case of having the appended DT without resorting to the use of the environment config options?
Think of it. How do you find out about what the kernel wants? This is just a blob...
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 71 lines · On Wed, 15 Oct 2014 13:42:33 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 70 lines · Siarhei Siamashka
Quoted 67 lines · On Wed, 15 Oct 2014 11:31:44 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 57 lines · Siarhei Siamashka
Quoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
Quoted 1 line
https://github.com/ssvb/u-boot-sunxi-dram/commit/e914abe551e712a59a8fc1ac9a4b8490e8e7c866And thus preventing kernels with appended DT (not provided by u-boot), but still using HYP/non-sec/PSCI from booting.
Sorry, but using DT as a way to distinguish between all these cases is just wrong.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Thanks,
Do you see the HACK prefix in the summary of that patch?
I do. But the fact that you even mention it here makes me think that you believe it is a better approach that Hans'.
The need to meddle with the environment variables makes Hans' approach immensely less useful for the end users.
In your Ivory Tower, you may think that you have resolved the problem. But in reality, u-boot will still have to be patched before deploying it to the end users in order to prevent them from running into troubles.
Other than this, are you really happy about granting the users full rights to allow booting the kernel in the secure mode via a simple environment variables tweak? Can't it potentially become a security breach in some scenarios?
Quoted 6 lines
Quoted 3 lines
Or are you saying that it is really impossible to distinguish your use case of having the appended DT without resorting to the use of the environment config options?
Think of it. How do you find out about what the kernel wants? This is just a blob...
The FDT blob has a header with an easily recognisable signature. So we can see the difference between the FDT and FEX blobs if the blob is provided to u-boot. And if no blob is provided at all, then we are sure that it can't be booted by the sunxi-3.4 kernel.
I can see only one theoretically problematic scenario, where u-boot is provided with the non-FDT and non-FEX blob, but loads a kernel, which has FDT statically compiled in. How does this actually play with PSCI? And what about the new device drivers model, which is going to depend on FDT information itself? Are we really happy allowing to use different FDT blobs for the u-boot and the kernel in the same system?
Or have I missed something?
Either way, following the least surprise principle, IMHO u-boot should log the reason for making a decision about whether it is switching to the non-secure mode or not. This is useful for troubleshooting.
Signature · 2 lines
Best regards, Siarhei Siamashka
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
[...]
Quoted 4 lines
Other than this, are you really happy about granting the users full rights to allow booting the kernel in the secure mode via a simple environment variables tweak? Can't it potentially become a security breach in some scenarios?
U-Boot must be running in secure mode in order to boot a kernel in secure mode. If U-Boot has been placed in secure mode with such an option, there is obviously nothing in the secure world to protect. As the user is in charge of booting the kernel, there is nothing in the normal world to protect.
There is no security breach here.
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
Or are you saying that it is really impossible to distinguish your use case of having the appended DT without resorting to the use of the environment config options?
Think of it. How do you find out about what the kernel wants? This is just a blob...
The FDT blob has a header with an easily recognisable signature. So we can see the difference between the FDT and FEX blobs if the blob is provided to u-boot. And if no blob is provided at all, then we are sure that it can't be booted by the sunxi-3.4 kernel.
FEX vs DT is specific to sunxi, whereas an explcit boot mode option is more generally useful. It is possible to have a kernel which can boot in either mode, where the security state the kernel runs in is a user choice, regardless of the presence or absence of a DTB.
Trying to guess how an OS will react and working around that is only going to cause problems when that OS changes over time.
Quoted 3 lines
I can see only one theoretically problematic scenario, where u-boot is provided with the non-FDT and non-FEX blob, but loads a kernel, which has FDT statically compiled in. How does this actually play with PSCI?
It would be completely orthogonal, just as the presence or absence of a DTB is orthogonal to the presence or absence of PSCI
Quoted 3 lines
And what about the new device drivers model, which is going to depend on FDT information itself? Are we really happy allowing to use different FDT blobs for the u-boot and the kernel in the same system?
There are already differences between what U-Boot needs to know and the kernel needs to know, e.g. secure peripherals if the kernel is booted in a non-secure mode. So in general you might need separate DTBs; the physical address spaces are different.
Quoted 5 lines
Or have I missed something?
Either way, following the least surprise principle, IMHO u-boot should log the reason for making a decision about whether it is switching to the non-secure mode or not. This is useful for troubleshooting.
Printing a message would make sense regardless of how the mode is selected.
Thanks,
Mark.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 7 lines · On Wed, 15 Oct 2014 15:39:32 +0100 Mark Rutland <[email protected]> wrote:
[...]
Quoted 4 lines
Other than this, are you really happy about granting the users full rights to allow booting the kernel in the secure mode via a simple environment variables tweak? Can't it potentially become a security breach in some scenarios?
Quoted 7 lines
U-Boot must be running in secure mode in order to boot a kernel in secure mode. If U-Boot has been placed in secure mode with such an option, there is obviously nothing in the secure world to protect. As the user is in charge of booting the kernel, there is nothing in the normal world to protect.
There is no security breach here.
OK, it's good to know that this change does not increase the attack surface.
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
Or are you saying that it is really impossible to distinguish your use case of having the appended DT without resorting to the use of the environment config options?
Think of it. How do you find out about what the kernel wants? This is just a blob...
The FDT blob has a header with an easily recognisable signature. So we can see the difference between the FDT and FEX blobs if the blob is provided to u-boot. And if no blob is provided at all, then we are sure that it can't be booted by the sunxi-3.4 kernel.
Quoted 4 lines
FEX vs DT is specific to sunxi, whereas an explcit boot mode option is more generally useful. It is possible to have a kernel which can boot in either mode, where the security state the kernel runs in is a user choice, regardless of the presence or absence of a DTB.
Indeed. The patch from Hans primarily targets sunxi hardware, but clearly has a broader scope than just this.
Quoted 2 lines
Trying to guess how an OS will react and working around that is only going to cause problems when that OS changes over time.
True, but in some cases we are the ones who can control and/or predict the evolution of both the OS and the u-boot development. I believe that's exactly the case with the community maintained legacy sunxi-3.4 kernel.
Quoted 7 lines
Quoted 3 lines
I can see only one theoretically problematic scenario, where u-boot is provided with the non-FDT and non-FEX blob, but loads a kernel, which has FDT statically compiled in. How does this actually play with PSCI?
It would be completely orthogonal, just as the presence or absence of a DTB is orthogonal to the presence or absence of PSCI
Quoted 8 lines
Quoted 3 lines
And what about the new device drivers model, which is going to depend on FDT information itself? Are we really happy allowing to use different FDT blobs for the u-boot and the kernel in the same system?
There are already differences between what U-Boot needs to know and the kernel needs to know, e.g. secure peripherals if the kernel is booted in a non-secure mode. So in general you might need separate DTBs; the physical address spaces are different.
Sounds like this may be a hell to maintain and keep working nicely together
Quoted 11 lines
Quoted 5 lines
Or have I missed something?
Either way, following the least surprise principle, IMHO u-boot should log the reason for making a decision about whether it is switching to the non-secure mode or not. This is useful for troubleshooting.
Printing a message would make sense regardless of how the mode is selected.
Thanks,
Mark.
Thanks for the explanations.
Signature · 2 lines
Best regards, Siarhei Siamashka
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
In reply to Siarhei SiamashkaQuoted 82 lines · Siarhei Siamashka
Quoted 72 lines · On Wed, 15 Oct 2014 13:42:33 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 70 lines · Siarhei Siamashka
Quoted 67 lines · On Wed, 15 Oct 2014 11:31:44 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 57 lines · Siarhei Siamashka
Quoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
Quoted 1 line
https://github.com/ssvb/u-boot-sunxi-dram/commit/e914abe551e712a59a8fc1ac9a4b8490e8e7c866And thus preventing kernels with appended DT (not provided by u-boot), but still using HYP/non-sec/PSCI from booting.
Sorry, but using DT as a way to distinguish between all these cases is just wrong.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Thanks,
Do you see the HACK prefix in the summary of that patch?
I do. But the fact that you even mention it here makes me think that you believe it is a better approach that Hans'.
Quoted 6 lines
The need to meddle with the environment variables makes Hans' approach immensely less useful for the end users.
In your Ivory Tower, you may think that you have resolved the problem. But in reality, u-boot will still have to be patched before deploying it to the end users in order to prevent them from running into troubles.
My position in a nice ivory tower allows me to see further than you seem to do, and makes me prefer robust solutions, as opposed to random hacks that impact unsuspecting users by modifying the way things gets booted based on decisions made by someone who may or may not have any idea of what said users are trying to achieve.
Hans' solution is simple, robust, and doesn't randomly change behaviour. That's definitely good enough for me.
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
PATCH 1/1 ARM: bootm: Allow booting in secure mode on hyp capable systems
Quoted 90 lines · On Wed, 15 Oct 2014 17:40:38 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 82 lines · Siarhei Siamashka
Quoted 72 lines · On Wed, 15 Oct 2014 13:42:33 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 70 lines · Siarhei Siamashka
Quoted 67 lines · On Wed, 15 Oct 2014 11:31:44 +0100 Marc Zyngier <[email protected]> wrote:
Quoted 57 lines · Siarhei Siamashka
Quoted 41 lines · On Wed, 15 Oct 2014 12:13:05 +0200 Hans de Goede <[email protected]> wrote:
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/lib/bootm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)arch/arm/lib/bootm.c +12
-5@@ -235,6 +235,18 @@ static void boot_prep_linux(bootm_headers_t *images) } } +#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) +static bool boot_nonsec (void ) +{ +char *s =getenv ("bootm_boot_mode" ); + +if (s && !strcmp (s,"sec" )) +return false; + +return true; +} +#endif +/* Subcommand: GO */ static void boot_jump_linux (bootm_headers_t *images,int flag) {@@ -283,12 +295,13 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)if (!fake) {#if defined(CONFIG_ARMV7_NONSEC ) || defined(CONFIG_ARMV7_VIRT ) -armv7_init_nonsec (); -secure_ram_addr (_do_nonsec_entry)(kernel_entry, -0 , machid, r2); -#else -kernel_entry (0 , machid, r2);arch/arm/lib/bootm.c static void boot_jump_linux(bootm_headers_t *images, int flag) · line 307
Quoted 10 lines
arch/arm/lib/bootm.c +6
-0+if (boot_nonsec ()) { +armv7_init_nonsec (); +secure_ram_addr (_do_nonsec_entry)(kernel_entry, +0 , machid, r2); + }#endif + kernel_entry(0, machid, r2); }#endif }BTW, I'm currently achieving the same result, but without the need to do extra environment configuration gymnastics for the end users:
Quoted 1 line
https://github.com/ssvb/u-boot-sunxi-dram/commit/e914abe551e712a59a8fc1ac9a4b8490e8e7c866And thus preventing kernels with appended DT (not provided by u-boot), but still using HYP/non-sec/PSCI from booting.
Sorry, but using DT as a way to distinguish between all these cases is just wrong.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Thanks,
Do you see the HACK prefix in the summary of that patch?
I do. But the fact that you even mention it here makes me think that you believe it is a better approach that Hans'.
Quoted 6 lines
The need to meddle with the environment variables makes Hans' approach immensely less useful for the end users.
In your Ivory Tower, you may think that you have resolved the problem. But in reality, u-boot will still have to be patched before deploying it to the end users in order to prevent them from running into troubles.
Quoted 5 lines
My position in a nice ivory tower allows me to see further than you seem to do, and makes me prefer robust solutions, as opposed to random hacks that impact unsuspecting users by modifying the way things gets booted based on decisions made by someone who may or may not have any idea of what said users are trying to achieve.
Basically, your reasoning boils down to "I'm a cool guy, so I know it better than you". And you just quoted only the irrelevant part, skipping the rest. Not sure if participating in this kind of debate makes any sense for me.
Quoted 2 lines
Hans' solution is simple, robust, and doesn't randomly change behaviour. That's definitely good enough for me.
To sum it up:
1) I'm in favour of having a way to toggle between booting in secure and non-secure mode
2) I'm neutral to the idea of adding this new environment variable and have no objections. Especially if it is also useful on non-sunxi hardware.
3) I still think that u-boot has enough information at runtime to make a reliable decision (on sunxi hardware) without any need for the extra environment variable, but we just agree to disagree.
And since the patch from Hans is moving things in the right direction
Have a nice day :-)
Signature · 2 lines
Best regards, Siarhei Siamashka
Hi,
Quoted 12 lines · Albert ARIBAUD
Hi Marc, Hans,
Quoted 7 lines · Marc Zyngier
Quoted 5 lines · Hans de Goede
Older Linux kernels will not properly boot in hype mode, add support for a
bootm_boot_modeenvironment variable, which when set to "sec" will cause u-boot to boot in secure mode even when build with non-sec (and hyp) support.Signed-off-by Hans de Goede <[email protected]>
Quoted 7 lines
Quoted 5 lines
Looks good to me.
Acked-by Marc Zyngier <[email protected]>M.Should we consider this a bugfix?
This is not really a bug fix, this adds a mechanism to select between secure / non secure boot on non-secure boot capable systems, as some older kernels do not work in non-secure mode. Even with this in place old (broken) kernels will still not magically work. Some sunxi specific patches are needed for that, as well as the user actually setting the environment variable.
I'm targetting the next u-boot release for getting old sunxi kernels to work for people who prefer using those kernels.
Quoted 1 line
For instance, hHow old are these "older kernels"?
The linux-sunxi kernel I'm specifically targetting is a 3.4 kernel, but this should be useful in general on all platforms which support booting in non-secure mode.
Regards,
Hans