* [PATCH v1 0/5] Initial support of Trusted Foundations on Tegra30
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
Hello,
This series of patches brings initial support of Trusted Foundations to
Tegra30, that is to the consumer-grade Tegra30 devices which do not allow
to easily replace the proprietary bootloader. Support is initial because
this series implements only a proper CPU boot-up (main + secondary cores)
and a basic L2 cache maintenance that is done using the TF firmware.
Suspend-resume support is missing yet as I couldn't get it to work
(CPU hangs on resume from suspend after awhile and seems that is related
to inappropriately done cache maintenance during of suspend-resume using
the firmware), it is work-in-progress for now.
This patchset is partially based on the work done by Michał Mirosław [0].
Please review, thanks.
[0] https://www.spinics.net/lists/linux-tegra/msg30368.html
Dmitry Osipenko (5):
ARM: trusted_foundations: Implement L2 cache initialization callback
ARM: trusted_foundations: Provide information about whether firmware
is registered
ARM: tegra: Setup L2 cache using Trusted Foundations firmware
ARM: tegra: Don't apply CPU erratas in insecure mode
ARM: tegra: Always boot CPU in ARM-mode
arch/arm/firmware/trusted_foundations.c | 28 ++++++++++++++++++++++
arch/arm/include/asm/trusted_foundations.h | 7 ++++++
arch/arm/mach-tegra/reset-handler.S | 28 +++++++++++++++-------
arch/arm/mach-tegra/reset.c | 5 +++-
arch/arm/mach-tegra/reset.h | 4 +++-
arch/arm/mach-tegra/tegra.c | 15 ++++++++++++
6 files changed, 77 insertions(+), 10 deletions(-)
--
2.17.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v1 0/5] Initial support of Trusted Foundations on Tegra30
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
This series of patches brings initial support of Trusted Foundations to
Tegra30, that is to the consumer-grade Tegra30 devices which do not allow
to easily replace the proprietary bootloader. Support is initial because
this series implements only a proper CPU boot-up (main + secondary cores)
and a basic L2 cache maintenance that is done using the TF firmware.
Suspend-resume support is missing yet as I couldn't get it to work
(CPU hangs on resume from suspend after awhile and seems that is related
to inappropriately done cache maintenance during of suspend-resume using
the firmware), it is work-in-progress for now.
This patchset is partially based on the work done by Micha? Miros?aw [0].
Please review, thanks.
[0] https://www.spinics.net/lists/linux-tegra/msg30368.html
Dmitry Osipenko (5):
ARM: trusted_foundations: Implement L2 cache initialization callback
ARM: trusted_foundations: Provide information about whether firmware
is registered
ARM: tegra: Setup L2 cache using Trusted Foundations firmware
ARM: tegra: Don't apply CPU erratas in insecure mode
ARM: tegra: Always boot CPU in ARM-mode
arch/arm/firmware/trusted_foundations.c | 28 ++++++++++++++++++++++
arch/arm/include/asm/trusted_foundations.h | 7 ++++++
arch/arm/mach-tegra/reset-handler.S | 28 +++++++++++++++-------
arch/arm/mach-tegra/reset.c | 5 +++-
arch/arm/mach-tegra/reset.h | 4 +++-
arch/arm/mach-tegra/tegra.c | 15 ++++++++++++
6 files changed, 77 insertions(+), 10 deletions(-)
--
2.17.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback
2018-05-20 10:15 ` Dmitry Osipenko
@ 2018-05-20 10:15 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
Implement L2 cache initialization firmware callback that should be invoked
early in boot to enable cache HW.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/firmware/trusted_foundations.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
index 3fb1b5a1dce9..198ce5c75ca0 100644
--- a/arch/arm/firmware/trusted_foundations.c
+++ b/arch/arm/firmware/trusted_foundations.c
@@ -18,8 +18,13 @@
#include <linux/init.h>
#include <linux/of.h>
#include <asm/firmware.h>
+#include <asm/outercache.h>
#include <asm/trusted_foundations.h>
+#define TF_CACHE_MAINT 0xfffff100
+
+#define TF_CACHE_INIT 1
+
#define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200
#define TF_CPU_PM 0xfffffffc
@@ -63,9 +68,27 @@ static int tf_prepare_idle(void)
return 0;
}
+#ifdef CONFIG_CACHE_L2X0
+static void tf_cache_write_sec(unsigned long val, unsigned int reg)
+{
+ pr_warn("%s: Ignoring write [0x%x]: 0x%08lx\n", __func__, reg, val);
+}
+
+static int tf_init_cache(void)
+{
+ outer_cache.write_sec = tf_cache_write_sec;
+ tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_INIT, 0);
+
+ return 0;
+}
+#endif /* CONFIG_CACHE_L2X0 */
+
static const struct firmware_ops trusted_foundations_ops = {
.set_cpu_boot_addr = tf_set_cpu_boot_addr,
.prepare_idle = tf_prepare_idle,
+#ifdef CONFIG_CACHE_L2X0
+ .l2x0_init = tf_init_cache,
+#endif
};
void register_trusted_foundations(struct trusted_foundations_platform_data *pd)
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: linux-arm-kernel
Implement L2 cache initialization firmware callback that should be invoked
early in boot to enable cache HW.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/firmware/trusted_foundations.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
index 3fb1b5a1dce9..198ce5c75ca0 100644
--- a/arch/arm/firmware/trusted_foundations.c
+++ b/arch/arm/firmware/trusted_foundations.c
@@ -18,8 +18,13 @@
#include <linux/init.h>
#include <linux/of.h>
#include <asm/firmware.h>
+#include <asm/outercache.h>
#include <asm/trusted_foundations.h>
+#define TF_CACHE_MAINT 0xfffff100
+
+#define TF_CACHE_INIT 1
+
#define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200
#define TF_CPU_PM 0xfffffffc
@@ -63,9 +68,27 @@ static int tf_prepare_idle(void)
return 0;
}
+#ifdef CONFIG_CACHE_L2X0
+static void tf_cache_write_sec(unsigned long val, unsigned int reg)
+{
+ pr_warn("%s: Ignoring write [0x%x]: 0x%08lx\n", __func__, reg, val);
+}
+
+static int tf_init_cache(void)
+{
+ outer_cache.write_sec = tf_cache_write_sec;
+ tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_INIT, 0);
+
+ return 0;
+}
+#endif /* CONFIG_CACHE_L2X0 */
+
static const struct firmware_ops trusted_foundations_ops = {
.set_cpu_boot_addr = tf_set_cpu_boot_addr,
.prepare_idle = tf_prepare_idle,
+#ifdef CONFIG_CACHE_L2X0
+ .l2x0_init = tf_init_cache,
+#endif
};
void register_trusted_foundations(struct trusted_foundations_platform_data *pd)
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 2/5] ARM: trusted_foundations: Provide information about whether firmware is registered
2018-05-20 10:15 ` Dmitry Osipenko
@ 2018-05-20 10:15 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
Add a helper that provides information about whether Trusted Foundations
firmware operations have been registered.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/firmware/trusted_foundations.c | 5 +++++
arch/arm/include/asm/trusted_foundations.h | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
index 198ce5c75ca0..0428351574de 100644
--- a/arch/arm/firmware/trusted_foundations.c
+++ b/arch/arm/firmware/trusted_foundations.c
@@ -120,3 +120,8 @@ void of_register_trusted_foundations(void)
panic("Trusted Foundation: missing version-minor property\n");
register_trusted_foundations(&pdata);
}
+
+bool trusted_foundations_registered(void)
+{
+ return firmware_ops == &trusted_foundations_ops;
+}
diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h
index 00748350cf72..bfd0d780824b 100644
--- a/arch/arm/include/asm/trusted_foundations.h
+++ b/arch/arm/include/asm/trusted_foundations.h
@@ -31,6 +31,7 @@
#include <linux/of.h>
#include <linux/cpu.h>
#include <linux/smp.h>
+#include <linux/types.h>
struct trusted_foundations_platform_data {
unsigned int version_major;
@@ -41,6 +42,7 @@ struct trusted_foundations_platform_data {
void register_trusted_foundations(struct trusted_foundations_platform_data *pd);
void of_register_trusted_foundations(void);
+bool trusted_foundations_registered(void);
#else /* CONFIG_TRUSTED_FOUNDATIONS */
@@ -68,6 +70,11 @@ static inline void of_register_trusted_foundations(void)
if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations"))
register_trusted_foundations(NULL);
}
+
+static inline bool trusted_foundations_registered(void)
+{
+ return false;
+}
#endif /* CONFIG_TRUSTED_FOUNDATIONS */
#endif
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 2/5] ARM: trusted_foundations: Provide information about whether firmware is registered
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: linux-arm-kernel
Add a helper that provides information about whether Trusted Foundations
firmware operations have been registered.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/firmware/trusted_foundations.c | 5 +++++
arch/arm/include/asm/trusted_foundations.h | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
index 198ce5c75ca0..0428351574de 100644
--- a/arch/arm/firmware/trusted_foundations.c
+++ b/arch/arm/firmware/trusted_foundations.c
@@ -120,3 +120,8 @@ void of_register_trusted_foundations(void)
panic("Trusted Foundation: missing version-minor property\n");
register_trusted_foundations(&pdata);
}
+
+bool trusted_foundations_registered(void)
+{
+ return firmware_ops == &trusted_foundations_ops;
+}
diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h
index 00748350cf72..bfd0d780824b 100644
--- a/arch/arm/include/asm/trusted_foundations.h
+++ b/arch/arm/include/asm/trusted_foundations.h
@@ -31,6 +31,7 @@
#include <linux/of.h>
#include <linux/cpu.h>
#include <linux/smp.h>
+#include <linux/types.h>
struct trusted_foundations_platform_data {
unsigned int version_major;
@@ -41,6 +42,7 @@ struct trusted_foundations_platform_data {
void register_trusted_foundations(struct trusted_foundations_platform_data *pd);
void of_register_trusted_foundations(void);
+bool trusted_foundations_registered(void);
#else /* CONFIG_TRUSTED_FOUNDATIONS */
@@ -68,6 +70,11 @@ static inline void of_register_trusted_foundations(void)
if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations"))
register_trusted_foundations(NULL);
}
+
+static inline bool trusted_foundations_registered(void)
+{
+ return false;
+}
#endif /* CONFIG_TRUSTED_FOUNDATIONS */
#endif
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 3/5] ARM: tegra: Setup L2 cache using Trusted Foundations firmware
2018-05-20 10:15 ` Dmitry Osipenko
(?)
@ 2018-05-20 10:15 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, Peter Geis, linux-kernel, linux-arm-kernel,
Michał Mirosław
On Tegra20/30 L2 cache must be initialized using firmware call if CPU
is running in insecure mode. Initialize L2 cache and setup the outer-cache
callbacks in early boot using the firmware API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/tegra.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index f9587be48235..590b1cf1a8c4 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -38,6 +38,7 @@
#include <soc/tegra/fuse.h>
#include <soc/tegra/pmc.h>
+#include <asm/firmware.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
@@ -70,9 +71,23 @@ u32 tegra_uart_config[3] = {
0,
};
+static void __init tegra_trusted_foundations_l2x0_cache_init(void)
+{
+ if (IS_ENABLED(CONFIG_CACHE_L2X0) &&
+ IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
+ of_machine_is_compatible("nvidia,tegra20"))
+ call_firmware_op(l2x0_init);
+
+ if (IS_ENABLED(CONFIG_CACHE_L2X0) &&
+ IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) &&
+ of_machine_is_compatible("nvidia,tegra30"))
+ call_firmware_op(l2x0_init);
+}
+
static void __init tegra_init_early(void)
{
of_register_trusted_foundations();
+ tegra_trusted_foundations_l2x0_cache_init();
tegra_cpu_reset_handler_init();
}
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 3/5] ARM: tegra: Setup L2 cache using Trusted Foundations firmware
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
On Tegra20/30 L2 cache must be initialized using firmware call if CPU
is running in insecure mode. Initialize L2 cache and setup the outer-cache
callbacks in early boot using the firmware API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/tegra.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index f9587be48235..590b1cf1a8c4 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -38,6 +38,7 @@
#include <soc/tegra/fuse.h>
#include <soc/tegra/pmc.h>
+#include <asm/firmware.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
@@ -70,9 +71,23 @@ u32 tegra_uart_config[3] = {
0,
};
+static void __init tegra_trusted_foundations_l2x0_cache_init(void)
+{
+ if (IS_ENABLED(CONFIG_CACHE_L2X0) &&
+ IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
+ of_machine_is_compatible("nvidia,tegra20"))
+ call_firmware_op(l2x0_init);
+
+ if (IS_ENABLED(CONFIG_CACHE_L2X0) &&
+ IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) &&
+ of_machine_is_compatible("nvidia,tegra30"))
+ call_firmware_op(l2x0_init);
+}
+
static void __init tegra_init_early(void)
{
of_register_trusted_foundations();
+ tegra_trusted_foundations_l2x0_cache_init();
tegra_cpu_reset_handler_init();
}
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 3/5] ARM: tegra: Setup L2 cache using Trusted Foundations firmware
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: linux-arm-kernel
On Tegra20/30 L2 cache must be initialized using firmware call if CPU
is running in insecure mode. Initialize L2 cache and setup the outer-cache
callbacks in early boot using the firmware API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/tegra.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index f9587be48235..590b1cf1a8c4 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -38,6 +38,7 @@
#include <soc/tegra/fuse.h>
#include <soc/tegra/pmc.h>
+#include <asm/firmware.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
@@ -70,9 +71,23 @@ u32 tegra_uart_config[3] = {
0,
};
+static void __init tegra_trusted_foundations_l2x0_cache_init(void)
+{
+ if (IS_ENABLED(CONFIG_CACHE_L2X0) &&
+ IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
+ of_machine_is_compatible("nvidia,tegra20"))
+ call_firmware_op(l2x0_init);
+
+ if (IS_ENABLED(CONFIG_CACHE_L2X0) &&
+ IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) &&
+ of_machine_is_compatible("nvidia,tegra30"))
+ call_firmware_op(l2x0_init);
+}
+
static void __init tegra_init_early(void)
{
of_register_trusted_foundations();
+ tegra_trusted_foundations_l2x0_cache_init();
tegra_cpu_reset_handler_init();
}
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 4/5] ARM: tegra: Don't apply CPU erratas in insecure mode
2018-05-20 10:15 ` Dmitry Osipenko
@ 2018-05-20 10:15 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
CPU isn't allowed to touch secure registers while running under secure
monitor. Hence skip applying CPU erratas in the reset handler if Trusted
Foundations firmware presents.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/reset-handler.S | 27 +++++++++++++++++++--------
arch/arm/mach-tegra/reset.c | 3 +++
arch/arm/mach-tegra/reset.h | 4 +++-
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S
index 805f306fa6f7..d84c74a95806 100644
--- a/arch/arm/mach-tegra/reset-handler.S
+++ b/arch/arm/mach-tegra/reset-handler.S
@@ -121,6 +121,12 @@ ENTRY(__tegra_cpu_reset_handler)
cpsid aif, 0x13 @ SVC mode, interrupts disabled
tegra_get_soc_id TEGRA_APB_MISC_BASE, r6
+
+ adr r12, __tegra_cpu_reset_handler_data
+ ldr r0, [r12, #RESET_DATA(TF_PRESENT)]
+ cmp r0, #0
+ bne after_errata
+
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
t20_check:
cmp r6, #TEGRA20
@@ -155,7 +161,6 @@ after_errata:
and r10, r10, #0x3 @ R10 = CPU number
mov r11, #1
mov r11, r11, lsl r10 @ R11 = CPU mask
- adr r12, __tegra_cpu_reset_handler_data
#ifdef CONFIG_SMP
/* Does the OS know about this CPU? */
@@ -169,10 +174,9 @@ after_errata:
cmp r6, #TEGRA20
bne 1f
/* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
- mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET
mov r0, #CPU_NOT_RESETTABLE
cmp r10, #0
- strneb r0, [r5, #__tegra20_cpu1_resettable_status_offset]
+ strneb r0, [r12, #RESET_DATA(RESETTABLE_STATUS)]
1:
#endif
@@ -278,13 +282,20 @@ ENDPROC(__tegra_cpu_reset_handler)
.type __tegra_cpu_reset_handler_data, %object
.globl __tegra_cpu_reset_handler_data
__tegra_cpu_reset_handler_data:
- .rept TEGRA_RESET_DATA_SIZE
- .long 0
- .endr
+ .long 0 /* TEGRA_RESET_MASK_PRESENT */
+ .long 0 /* TEGRA_RESET_MASK_LP1 */
+ .long 0 /* TEGRA_RESET_MASK_LP2 */
+ .long 0 /* TEGRA_RESET_STARTUP_SECONDARY */
+ .long 0 /* TEGRA_RESET_STARTUP_LP2 */
+ .long 0 /* TEGRA_RESET_STARTUP_LP1 */
+
.globl __tegra20_cpu1_resettable_status_offset
.equ __tegra20_cpu1_resettable_status_offset, \
. - __tegra_cpu_reset_handler_start
- .byte 0
- .align L1_CACHE_SHIFT
+ .long 0 /* TEGRA_RESET_RESETTABLE_STATUS */
+ .globl __tegra_tf_present
+ .equ __tegra_tf_present, . - __tegra_cpu_reset_handler_start
+ .long 0 /* TEGRA_RESET_TF_PRESENT */
+ .align L1_CACHE_SHIFT
ENTRY(__tegra_cpu_reset_handler_end)
diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
index dc558892753c..b02ae7699842 100644
--- a/arch/arm/mach-tegra/reset.c
+++ b/arch/arm/mach-tegra/reset.c
@@ -24,6 +24,7 @@
#include <asm/cacheflush.h>
#include <asm/firmware.h>
#include <asm/hardware/cache-l2x0.h>
+#include <asm/trusted_foundations.h>
#include "iomap.h"
#include "irammap.h"
@@ -89,6 +90,8 @@ static void __init tegra_cpu_reset_handler_enable(void)
void __init tegra_cpu_reset_handler_init(void)
{
+ __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] =
+ trusted_foundations_registered();
#ifdef CONFIG_SMP
__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h
index 9c479c7925b8..0d9ddc022ece 100644
--- a/arch/arm/mach-tegra/reset.h
+++ b/arch/arm/mach-tegra/reset.h
@@ -25,7 +25,9 @@
#define TEGRA_RESET_STARTUP_SECONDARY 3
#define TEGRA_RESET_STARTUP_LP2 4
#define TEGRA_RESET_STARTUP_LP1 5
-#define TEGRA_RESET_DATA_SIZE 6
+#define TEGRA_RESET_RESETTABLE_STATUS 6
+#define TEGRA_RESET_TF_PRESENT 7
+#define TEGRA_RESET_DATA_SIZE 8
#ifndef __ASSEMBLY__
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 4/5] ARM: tegra: Don't apply CPU erratas in insecure mode
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: linux-arm-kernel
CPU isn't allowed to touch secure registers while running under secure
monitor. Hence skip applying CPU erratas in the reset handler if Trusted
Foundations firmware presents.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/reset-handler.S | 27 +++++++++++++++++++--------
arch/arm/mach-tegra/reset.c | 3 +++
arch/arm/mach-tegra/reset.h | 4 +++-
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S
index 805f306fa6f7..d84c74a95806 100644
--- a/arch/arm/mach-tegra/reset-handler.S
+++ b/arch/arm/mach-tegra/reset-handler.S
@@ -121,6 +121,12 @@ ENTRY(__tegra_cpu_reset_handler)
cpsid aif, 0x13 @ SVC mode, interrupts disabled
tegra_get_soc_id TEGRA_APB_MISC_BASE, r6
+
+ adr r12, __tegra_cpu_reset_handler_data
+ ldr r0, [r12, #RESET_DATA(TF_PRESENT)]
+ cmp r0, #0
+ bne after_errata
+
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
t20_check:
cmp r6, #TEGRA20
@@ -155,7 +161,6 @@ after_errata:
and r10, r10, #0x3 @ R10 = CPU number
mov r11, #1
mov r11, r11, lsl r10 @ R11 = CPU mask
- adr r12, __tegra_cpu_reset_handler_data
#ifdef CONFIG_SMP
/* Does the OS know about this CPU? */
@@ -169,10 +174,9 @@ after_errata:
cmp r6, #TEGRA20
bne 1f
/* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
- mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET
mov r0, #CPU_NOT_RESETTABLE
cmp r10, #0
- strneb r0, [r5, #__tegra20_cpu1_resettable_status_offset]
+ strneb r0, [r12, #RESET_DATA(RESETTABLE_STATUS)]
1:
#endif
@@ -278,13 +282,20 @@ ENDPROC(__tegra_cpu_reset_handler)
.type __tegra_cpu_reset_handler_data, %object
.globl __tegra_cpu_reset_handler_data
__tegra_cpu_reset_handler_data:
- .rept TEGRA_RESET_DATA_SIZE
- .long 0
- .endr
+ .long 0 /* TEGRA_RESET_MASK_PRESENT */
+ .long 0 /* TEGRA_RESET_MASK_LP1 */
+ .long 0 /* TEGRA_RESET_MASK_LP2 */
+ .long 0 /* TEGRA_RESET_STARTUP_SECONDARY */
+ .long 0 /* TEGRA_RESET_STARTUP_LP2 */
+ .long 0 /* TEGRA_RESET_STARTUP_LP1 */
+
.globl __tegra20_cpu1_resettable_status_offset
.equ __tegra20_cpu1_resettable_status_offset, \
. - __tegra_cpu_reset_handler_start
- .byte 0
- .align L1_CACHE_SHIFT
+ .long 0 /* TEGRA_RESET_RESETTABLE_STATUS */
+ .globl __tegra_tf_present
+ .equ __tegra_tf_present, . - __tegra_cpu_reset_handler_start
+ .long 0 /* TEGRA_RESET_TF_PRESENT */
+ .align L1_CACHE_SHIFT
ENTRY(__tegra_cpu_reset_handler_end)
diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
index dc558892753c..b02ae7699842 100644
--- a/arch/arm/mach-tegra/reset.c
+++ b/arch/arm/mach-tegra/reset.c
@@ -24,6 +24,7 @@
#include <asm/cacheflush.h>
#include <asm/firmware.h>
#include <asm/hardware/cache-l2x0.h>
+#include <asm/trusted_foundations.h>
#include "iomap.h"
#include "irammap.h"
@@ -89,6 +90,8 @@ static void __init tegra_cpu_reset_handler_enable(void)
void __init tegra_cpu_reset_handler_init(void)
{
+ __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] =
+ trusted_foundations_registered();
#ifdef CONFIG_SMP
__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h
index 9c479c7925b8..0d9ddc022ece 100644
--- a/arch/arm/mach-tegra/reset.h
+++ b/arch/arm/mach-tegra/reset.h
@@ -25,7 +25,9 @@
#define TEGRA_RESET_STARTUP_SECONDARY 3
#define TEGRA_RESET_STARTUP_LP2 4
#define TEGRA_RESET_STARTUP_LP1 5
-#define TEGRA_RESET_DATA_SIZE 6
+#define TEGRA_RESET_RESETTABLE_STATUS 6
+#define TEGRA_RESET_TF_PRESENT 7
+#define TEGRA_RESET_DATA_SIZE 8
#ifndef __ASSEMBLY__
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 5/5] ARM: tegra: Always boot CPU in ARM-mode
2018-05-20 10:15 ` Dmitry Osipenko
@ 2018-05-20 10:15 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
CPU always jumps into the reset handler in ARM-mode from the Trusted
Foundations firmware, hence make CPU to always jump into kernel in
ARM-mode regardless of the firmware presence to support Thumb2 kernel + TF
case.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/reset-handler.S | 1 +
arch/arm/mach-tegra/reset.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S
index d84c74a95806..7e15c3bdf118 100644
--- a/arch/arm/mach-tegra/reset-handler.S
+++ b/arch/arm/mach-tegra/reset-handler.S
@@ -115,6 +115,7 @@ ENTRY(__tegra_cpu_reset_handler_start)
* must be position-independent.
*/
+ .arm
.align L1_CACHE_SHIFT
ENTRY(__tegra_cpu_reset_handler)
diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
index b02ae7699842..3f1ef4561298 100644
--- a/arch/arm/mach-tegra/reset.c
+++ b/arch/arm/mach-tegra/reset.c
@@ -97,7 +97,7 @@ void __init tegra_cpu_reset_handler_init(void)
__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
*((u32 *)cpu_possible_mask);
__tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_SECONDARY] =
- __pa_symbol((void *)secondary_startup);
+ __pa_symbol((void *)secondary_startup_arm);
#endif
#ifdef CONFIG_PM_SLEEP
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v1 5/5] ARM: tegra: Always boot CPU in ARM-mode
@ 2018-05-20 10:15 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 10:15 UTC (permalink / raw)
To: linux-arm-kernel
CPU always jumps into the reset handler in ARM-mode from the Trusted
Foundations firmware, hence make CPU to always jump into kernel in
ARM-mode regardless of the firmware presence to support Thumb2 kernel + TF
case.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/mach-tegra/reset-handler.S | 1 +
arch/arm/mach-tegra/reset.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S
index d84c74a95806..7e15c3bdf118 100644
--- a/arch/arm/mach-tegra/reset-handler.S
+++ b/arch/arm/mach-tegra/reset-handler.S
@@ -115,6 +115,7 @@ ENTRY(__tegra_cpu_reset_handler_start)
* must be position-independent.
*/
+ .arm
.align L1_CACHE_SHIFT
ENTRY(__tegra_cpu_reset_handler)
diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
index b02ae7699842..3f1ef4561298 100644
--- a/arch/arm/mach-tegra/reset.c
+++ b/arch/arm/mach-tegra/reset.c
@@ -97,7 +97,7 @@ void __init tegra_cpu_reset_handler_init(void)
__tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
*((u32 *)cpu_possible_mask);
__tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_SECONDARY] =
- __pa_symbol((void *)secondary_startup);
+ __pa_symbol((void *)secondary_startup_arm);
#endif
#ifdef CONFIG_PM_SLEEP
--
2.17.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback
2018-05-20 10:15 ` Dmitry Osipenko
@ 2018-05-20 14:08 ` Russell King - ARM Linux
-1 siblings, 0 replies; 19+ messages in thread
From: Russell King - ARM Linux @ 2018-05-20 14:08 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, linux-tegra, linux-arm-kernel,
linux-kernel, Peter Geis, Michał Mirosław
On Sun, May 20, 2018 at 01:15:38PM +0300, Dmitry Osipenko wrote:
> Implement L2 cache initialization firmware callback that should be invoked
> early in boot to enable cache HW.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> arch/arm/firmware/trusted_foundations.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
> index 3fb1b5a1dce9..198ce5c75ca0 100644
> --- a/arch/arm/firmware/trusted_foundations.c
> +++ b/arch/arm/firmware/trusted_foundations.c
> @@ -18,8 +18,13 @@
> #include <linux/init.h>
> #include <linux/of.h>
> #include <asm/firmware.h>
> +#include <asm/outercache.h>
> #include <asm/trusted_foundations.h>
>
> +#define TF_CACHE_MAINT 0xfffff100
> +
> +#define TF_CACHE_INIT 1
> +
> #define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200
>
> #define TF_CPU_PM 0xfffffffc
> @@ -63,9 +68,27 @@ static int tf_prepare_idle(void)
> return 0;
> }
>
> +#ifdef CONFIG_CACHE_L2X0
> +static void tf_cache_write_sec(unsigned long val, unsigned int reg)
> +{
> + pr_warn("%s: Ignoring write [0x%x]: 0x%08lx\n", __func__, reg, val);
Why at warning level? Is this some issue that the user needs to be
warned about?
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback
@ 2018-05-20 14:08 ` Russell King - ARM Linux
0 siblings, 0 replies; 19+ messages in thread
From: Russell King - ARM Linux @ 2018-05-20 14:08 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, May 20, 2018 at 01:15:38PM +0300, Dmitry Osipenko wrote:
> Implement L2 cache initialization firmware callback that should be invoked
> early in boot to enable cache HW.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> arch/arm/firmware/trusted_foundations.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
> index 3fb1b5a1dce9..198ce5c75ca0 100644
> --- a/arch/arm/firmware/trusted_foundations.c
> +++ b/arch/arm/firmware/trusted_foundations.c
> @@ -18,8 +18,13 @@
> #include <linux/init.h>
> #include <linux/of.h>
> #include <asm/firmware.h>
> +#include <asm/outercache.h>
> #include <asm/trusted_foundations.h>
>
> +#define TF_CACHE_MAINT 0xfffff100
> +
> +#define TF_CACHE_INIT 1
> +
> #define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200
>
> #define TF_CPU_PM 0xfffffffc
> @@ -63,9 +68,27 @@ static int tf_prepare_idle(void)
> return 0;
> }
>
> +#ifdef CONFIG_CACHE_L2X0
> +static void tf_cache_write_sec(unsigned long val, unsigned int reg)
> +{
> + pr_warn("%s: Ignoring write [0x%x]: 0x%08lx\n", __func__, reg, val);
Why at warning level? Is this some issue that the user needs to be
warned about?
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback
2018-05-20 14:08 ` Russell King - ARM Linux
@ 2018-05-20 14:53 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 14:53 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Thierry Reding, Jonathan Hunter, linux-tegra, linux-arm-kernel,
linux-kernel, Peter Geis, Michał Mirosław
On 20.05.2018 17:08, Russell King - ARM Linux wrote:
> On Sun, May 20, 2018 at 01:15:38PM +0300, Dmitry Osipenko wrote:
>> Implement L2 cache initialization firmware callback that should be invoked
>> early in boot to enable cache HW.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>> arch/arm/firmware/trusted_foundations.c | 23 +++++++++++++++++++++++
>> 1 file changed, 23 insertions(+)
>>
>> diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
>> index 3fb1b5a1dce9..198ce5c75ca0 100644
>> --- a/arch/arm/firmware/trusted_foundations.c
>> +++ b/arch/arm/firmware/trusted_foundations.c
>> @@ -18,8 +18,13 @@
>> #include <linux/init.h>
>> #include <linux/of.h>
>> #include <asm/firmware.h>
>> +#include <asm/outercache.h>
>> #include <asm/trusted_foundations.h>
>>
>> +#define TF_CACHE_MAINT 0xfffff100
>> +
>> +#define TF_CACHE_INIT 1
>> +
>> #define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200
>>
>> #define TF_CPU_PM 0xfffffffc
>> @@ -63,9 +68,27 @@ static int tf_prepare_idle(void)
>> return 0;
>> }
>>
>> +#ifdef CONFIG_CACHE_L2X0
>> +static void tf_cache_write_sec(unsigned long val, unsigned int reg)
>> +{
>> + pr_warn("%s: Ignoring write [0x%x]: 0x%08lx\n", __func__, reg, val);
>
> Why at warning level? Is this some issue that the user needs to be
> warned about?
>
If cache-l2x0 code will be changed in the future in a way that it will try to do
something using the secure-registers, then user should be informed about that
incident as we are ignoring the accesses to secure-registers and this may lead
to an undesired consequences. If a such change in cache-l2x0 will happen, then
we will have to take some action by either fixing the invalid accesses or
silencing the warning message if will be appropriate. For now I'd prefer to have
verbosity in the KMSG to masking the potential problems.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback
@ 2018-05-20 14:53 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-20 14:53 UTC (permalink / raw)
To: linux-arm-kernel
On 20.05.2018 17:08, Russell King - ARM Linux wrote:
> On Sun, May 20, 2018 at 01:15:38PM +0300, Dmitry Osipenko wrote:
>> Implement L2 cache initialization firmware callback that should be invoked
>> early in boot to enable cache HW.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>> arch/arm/firmware/trusted_foundations.c | 23 +++++++++++++++++++++++
>> 1 file changed, 23 insertions(+)
>>
>> diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
>> index 3fb1b5a1dce9..198ce5c75ca0 100644
>> --- a/arch/arm/firmware/trusted_foundations.c
>> +++ b/arch/arm/firmware/trusted_foundations.c
>> @@ -18,8 +18,13 @@
>> #include <linux/init.h>
>> #include <linux/of.h>
>> #include <asm/firmware.h>
>> +#include <asm/outercache.h>
>> #include <asm/trusted_foundations.h>
>>
>> +#define TF_CACHE_MAINT 0xfffff100
>> +
>> +#define TF_CACHE_INIT 1
>> +
>> #define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200
>>
>> #define TF_CPU_PM 0xfffffffc
>> @@ -63,9 +68,27 @@ static int tf_prepare_idle(void)
>> return 0;
>> }
>>
>> +#ifdef CONFIG_CACHE_L2X0
>> +static void tf_cache_write_sec(unsigned long val, unsigned int reg)
>> +{
>> + pr_warn("%s: Ignoring write [0x%x]: 0x%08lx\n", __func__, reg, val);
>
> Why at warning level? Is this some issue that the user needs to be
> warned about?
>
If cache-l2x0 code will be changed in the future in a way that it will try to do
something using the secure-registers, then user should be informed about that
incident as we are ignoring the accesses to secure-registers and this may lead
to an undesired consequences. If a such change in cache-l2x0 will happen, then
we will have to take some action by either fixing the invalid accesses or
silencing the warning message if will be appropriate. For now I'd prefer to have
verbosity in the KMSG to masking the potential problems.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v1 4/5] ARM: tegra: Don't apply CPU erratas in insecure mode
2018-05-20 10:15 ` Dmitry Osipenko
@ 2018-05-21 7:36 ` Dmitry Osipenko
-1 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-21 7:36 UTC (permalink / raw)
To: Russell King, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-arm-kernel, linux-kernel, Peter Geis,
Michał Mirosław
On 20.05.2018 13:15, Dmitry Osipenko wrote:
> CPU isn't allowed to touch secure registers while running under secure
> monitor. Hence skip applying CPU erratas in the reset handler if Trusted
> Foundations firmware presents.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> arch/arm/mach-tegra/reset-handler.S | 27 +++++++++++++++++++--------
> arch/arm/mach-tegra/reset.c | 3 +++
> arch/arm/mach-tegra/reset.h | 4 +++-
> 3 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S
> index 805f306fa6f7..d84c74a95806 100644
> --- a/arch/arm/mach-tegra/reset-handler.S
> +++ b/arch/arm/mach-tegra/reset-handler.S
> @@ -121,6 +121,12 @@ ENTRY(__tegra_cpu_reset_handler)
> cpsid aif, 0x13 @ SVC mode, interrupts disabled
>
> tegra_get_soc_id TEGRA_APB_MISC_BASE, r6
> +
> + adr r12, __tegra_cpu_reset_handler_data
> + ldr r0, [r12, #RESET_DATA(TF_PRESENT)]
> + cmp r0, #0
> + bne after_errata
> +
> #ifdef CONFIG_ARCH_TEGRA_2x_SOC
> t20_check:
> cmp r6, #TEGRA20
> @@ -155,7 +161,6 @@ after_errata:
> and r10, r10, #0x3 @ R10 = CPU number
> mov r11, #1
> mov r11, r11, lsl r10 @ R11 = CPU mask
> - adr r12, __tegra_cpu_reset_handler_data
>
> #ifdef CONFIG_SMP
> /* Does the OS know about this CPU? */
> @@ -169,10 +174,9 @@ after_errata:
> cmp r6, #TEGRA20
> bne 1f
> /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
> - mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET
> mov r0, #CPU_NOT_RESETTABLE
> cmp r10, #0
> - strneb r0, [r5, #__tegra20_cpu1_resettable_status_offset]
> + strneb r0, [r12, #RESET_DATA(RESETTABLE_STATUS)]
> 1:
> #endif
>
> @@ -278,13 +282,20 @@ ENDPROC(__tegra_cpu_reset_handler)
> .type __tegra_cpu_reset_handler_data, %object
> .globl __tegra_cpu_reset_handler_data
> __tegra_cpu_reset_handler_data:
> - .rept TEGRA_RESET_DATA_SIZE
> - .long 0
> - .endr
> + .long 0 /* TEGRA_RESET_MASK_PRESENT */
> + .long 0 /* TEGRA_RESET_MASK_LP1 */
> + .long 0 /* TEGRA_RESET_MASK_LP2 */
> + .long 0 /* TEGRA_RESET_STARTUP_SECONDARY */
> + .long 0 /* TEGRA_RESET_STARTUP_LP2 */
> + .long 0 /* TEGRA_RESET_STARTUP_LP1 */
> +
> .globl __tegra20_cpu1_resettable_status_offset
> .equ __tegra20_cpu1_resettable_status_offset, \
> . - __tegra_cpu_reset_handler_start
> - .byte 0
> - .align L1_CACHE_SHIFT
> + .long 0 /* TEGRA_RESET_RESETTABLE_STATUS */
>
> + .globl __tegra_tf_present
> + .equ __tegra_tf_present, . - __tegra_cpu_reset_handler_start
I've noticed that __tegra_tf_present shouldn't belong to this patch, I've missed
to remove it while was rebasing.
Also, it occurred to me that it will be much better to remove the whole array
__tegra_cpu_reset_handler_data definition in the asm and get back to the
original ".rept TEGRA_RESET_DATA_SIZE" instead. That will make this part of
code much nicer, I'll change that in v2.
Russell / Thierry, please give you acks-reviews where appropriate and let me
know if I should change anything else in v2, thanks.
> + .long 0 /* TEGRA_RESET_TF_PRESENT */
> + .align L1_CACHE_SHIFT
> ENTRY(__tegra_cpu_reset_handler_end)
> diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
> index dc558892753c..b02ae7699842 100644
> --- a/arch/arm/mach-tegra/reset.c
> +++ b/arch/arm/mach-tegra/reset.c
> @@ -24,6 +24,7 @@
> #include <asm/cacheflush.h>
> #include <asm/firmware.h>
> #include <asm/hardware/cache-l2x0.h>
> +#include <asm/trusted_foundations.h>
>
> #include "iomap.h"
> #include "irammap.h"
> @@ -89,6 +90,8 @@ static void __init tegra_cpu_reset_handler_enable(void)
>
> void __init tegra_cpu_reset_handler_init(void)
> {
> + __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] =
> + trusted_foundations_registered();
>
> #ifdef CONFIG_SMP
> __tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
> diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h
> index 9c479c7925b8..0d9ddc022ece 100644
> --- a/arch/arm/mach-tegra/reset.h
> +++ b/arch/arm/mach-tegra/reset.h
> @@ -25,7 +25,9 @@
> #define TEGRA_RESET_STARTUP_SECONDARY 3
> #define TEGRA_RESET_STARTUP_LP2 4
> #define TEGRA_RESET_STARTUP_LP1 5
> -#define TEGRA_RESET_DATA_SIZE 6
> +#define TEGRA_RESET_RESETTABLE_STATUS 6
> +#define TEGRA_RESET_TF_PRESENT 7
> +#define TEGRA_RESET_DATA_SIZE 8
>
> #ifndef __ASSEMBLY__
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v1 4/5] ARM: tegra: Don't apply CPU erratas in insecure mode
@ 2018-05-21 7:36 ` Dmitry Osipenko
0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2018-05-21 7:36 UTC (permalink / raw)
To: linux-arm-kernel
On 20.05.2018 13:15, Dmitry Osipenko wrote:
> CPU isn't allowed to touch secure registers while running under secure
> monitor. Hence skip applying CPU erratas in the reset handler if Trusted
> Foundations firmware presents.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> arch/arm/mach-tegra/reset-handler.S | 27 +++++++++++++++++++--------
> arch/arm/mach-tegra/reset.c | 3 +++
> arch/arm/mach-tegra/reset.h | 4 +++-
> 3 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S
> index 805f306fa6f7..d84c74a95806 100644
> --- a/arch/arm/mach-tegra/reset-handler.S
> +++ b/arch/arm/mach-tegra/reset-handler.S
> @@ -121,6 +121,12 @@ ENTRY(__tegra_cpu_reset_handler)
> cpsid aif, 0x13 @ SVC mode, interrupts disabled
>
> tegra_get_soc_id TEGRA_APB_MISC_BASE, r6
> +
> + adr r12, __tegra_cpu_reset_handler_data
> + ldr r0, [r12, #RESET_DATA(TF_PRESENT)]
> + cmp r0, #0
> + bne after_errata
> +
> #ifdef CONFIG_ARCH_TEGRA_2x_SOC
> t20_check:
> cmp r6, #TEGRA20
> @@ -155,7 +161,6 @@ after_errata:
> and r10, r10, #0x3 @ R10 = CPU number
> mov r11, #1
> mov r11, r11, lsl r10 @ R11 = CPU mask
> - adr r12, __tegra_cpu_reset_handler_data
>
> #ifdef CONFIG_SMP
> /* Does the OS know about this CPU? */
> @@ -169,10 +174,9 @@ after_errata:
> cmp r6, #TEGRA20
> bne 1f
> /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
> - mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET
> mov r0, #CPU_NOT_RESETTABLE
> cmp r10, #0
> - strneb r0, [r5, #__tegra20_cpu1_resettable_status_offset]
> + strneb r0, [r12, #RESET_DATA(RESETTABLE_STATUS)]
> 1:
> #endif
>
> @@ -278,13 +282,20 @@ ENDPROC(__tegra_cpu_reset_handler)
> .type __tegra_cpu_reset_handler_data, %object
> .globl __tegra_cpu_reset_handler_data
> __tegra_cpu_reset_handler_data:
> - .rept TEGRA_RESET_DATA_SIZE
> - .long 0
> - .endr
> + .long 0 /* TEGRA_RESET_MASK_PRESENT */
> + .long 0 /* TEGRA_RESET_MASK_LP1 */
> + .long 0 /* TEGRA_RESET_MASK_LP2 */
> + .long 0 /* TEGRA_RESET_STARTUP_SECONDARY */
> + .long 0 /* TEGRA_RESET_STARTUP_LP2 */
> + .long 0 /* TEGRA_RESET_STARTUP_LP1 */
> +
> .globl __tegra20_cpu1_resettable_status_offset
> .equ __tegra20_cpu1_resettable_status_offset, \
> . - __tegra_cpu_reset_handler_start
> - .byte 0
> - .align L1_CACHE_SHIFT
> + .long 0 /* TEGRA_RESET_RESETTABLE_STATUS */
>
> + .globl __tegra_tf_present
> + .equ __tegra_tf_present, . - __tegra_cpu_reset_handler_start
I've noticed that __tegra_tf_present shouldn't belong to this patch, I've missed
to remove it while was rebasing.
Also, it occurred to me that it will be much better to remove the whole array
__tegra_cpu_reset_handler_data definition in the asm and get back to the
original ".rept TEGRA_RESET_DATA_SIZE" instead. That will make this part of
code much nicer, I'll change that in v2.
Russell / Thierry, please give you acks-reviews where appropriate and let me
know if I should change anything else in v2, thanks.
> + .long 0 /* TEGRA_RESET_TF_PRESENT */
> + .align L1_CACHE_SHIFT
> ENTRY(__tegra_cpu_reset_handler_end)
> diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
> index dc558892753c..b02ae7699842 100644
> --- a/arch/arm/mach-tegra/reset.c
> +++ b/arch/arm/mach-tegra/reset.c
> @@ -24,6 +24,7 @@
> #include <asm/cacheflush.h>
> #include <asm/firmware.h>
> #include <asm/hardware/cache-l2x0.h>
> +#include <asm/trusted_foundations.h>
>
> #include "iomap.h"
> #include "irammap.h"
> @@ -89,6 +90,8 @@ static void __init tegra_cpu_reset_handler_enable(void)
>
> void __init tegra_cpu_reset_handler_init(void)
> {
> + __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] =
> + trusted_foundations_registered();
>
> #ifdef CONFIG_SMP
> __tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
> diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h
> index 9c479c7925b8..0d9ddc022ece 100644
> --- a/arch/arm/mach-tegra/reset.h
> +++ b/arch/arm/mach-tegra/reset.h
> @@ -25,7 +25,9 @@
> #define TEGRA_RESET_STARTUP_SECONDARY 3
> #define TEGRA_RESET_STARTUP_LP2 4
> #define TEGRA_RESET_STARTUP_LP1 5
> -#define TEGRA_RESET_DATA_SIZE 6
> +#define TEGRA_RESET_RESETTABLE_STATUS 6
> +#define TEGRA_RESET_TF_PRESENT 7
> +#define TEGRA_RESET_DATA_SIZE 8
>
> #ifndef __ASSEMBLY__
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2018-05-21 7:36 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-20 10:15 [PATCH v1 0/5] Initial support of Trusted Foundations on Tegra30 Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
2018-05-20 10:15 ` [PATCH v1 1/5] ARM: trusted_foundations: Implement L2 cache initialization callback Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
2018-05-20 14:08 ` Russell King - ARM Linux
2018-05-20 14:08 ` Russell King - ARM Linux
2018-05-20 14:53 ` Dmitry Osipenko
2018-05-20 14:53 ` Dmitry Osipenko
2018-05-20 10:15 ` [PATCH v1 2/5] ARM: trusted_foundations: Provide information about whether firmware is registered Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
2018-05-20 10:15 ` [PATCH v1 3/5] ARM: tegra: Setup L2 cache using Trusted Foundations firmware Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
2018-05-20 10:15 ` [PATCH v1 4/5] ARM: tegra: Don't apply CPU erratas in insecure mode Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
2018-05-21 7:36 ` Dmitry Osipenko
2018-05-21 7:36 ` Dmitry Osipenko
2018-05-20 10:15 ` [PATCH v1 5/5] ARM: tegra: Always boot CPU in ARM-mode Dmitry Osipenko
2018-05-20 10:15 ` Dmitry Osipenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.