* [PATCH v3 02/10] ARM: safely switch from HYP to SVC mode if required
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-03-26 19:20 ` [PATCH v3 03/10] ARM: allow secure monitor code to be built without PSCI Lucas Stach
` (7 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
This is a port of the Linux safe_svcmode_maskall macro to
the Barebox lowlevel init.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
v3: fix whitespace
---
arch/arm/cpu/lowlevel.S | 18 +++++++++++++++---
arch/arm/include/asm/system.h | 26 ++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/lowlevel.S b/arch/arm/cpu/lowlevel.S
index 7696a198e764..43665981e48b 100644
--- a/arch/arm/cpu/lowlevel.S
+++ b/arch/arm/cpu/lowlevel.S
@@ -1,16 +1,28 @@
#include <linux/linkage.h>
#include <init.h>
#include <asm/system.h>
+#include <asm/opcodes-virt.h>
.section ".text_bare_init_","ax"
ENTRY(arm_cpu_lowlevel_init)
/* save lr, since it may be banked away with a processor mode change */
mov r2, lr
+
/* set the cpu to SVC32 mode, mask irq and fiq */
mrs r12, cpsr
- bic r12, r12, #0x1f
- orr r12, r12, #0xd3
- msr cpsr, r12
+ eor r12, r12, #HYP_MODE
+ tst r12, #MODE_MASK
+ bic r12, r12, #MODE_MASK
+ orr r12, r12, #(PSR_I_BIT | PSR_F_BIT | SVC_MODE)
+THUMB( orr r12, r12, #PSR_T_BIT )
+ bne 1f
+ orr r12, r12, #PSR_A_BIT
+ adr lr, 2f
+ msr spsr_cxsf, r12
+ __MSR_ELR_HYP(14)
+ __ERET
+1: msr cpsr_c, r12
+2:
#if __LINUX_ARM_ARCH__ >= 6
/*
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 57c76186b499..55e0f4090295 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -60,6 +60,32 @@
#define CR_AFE (1 << 29) /* Access flag enable */
#define CR_TE (1 << 30) /* Thumb exception enable */
+/*
+ * PSR bits
+ */
+#define USR_MODE 0x00000010
+#define FIQ_MODE 0x00000011
+#define IRQ_MODE 0x00000012
+#define SVC_MODE 0x00000013
+#define ABT_MODE 0x00000017
+#define HYP_MODE 0x0000001a
+#define UND_MODE 0x0000001b
+#define SYSTEM_MODE 0x0000001f
+#define MODE32_BIT 0x00000010
+#define MODE_MASK 0x0000001f
+
+#define PSR_T_BIT 0x00000020
+#define PSR_F_BIT 0x00000040
+#define PSR_I_BIT 0x00000080
+#define PSR_A_BIT 0x00000100
+#define PSR_E_BIT 0x00000200
+#define PSR_J_BIT 0x01000000
+#define PSR_Q_BIT 0x08000000
+#define PSR_V_BIT 0x10000000
+#define PSR_C_BIT 0x20000000
+#define PSR_Z_BIT 0x40000000
+#define PSR_N_BIT 0x80000000
+
#ifndef __ASSEMBLY__
#if __LINUX_ARM_ARCH__ >= 7
static inline unsigned int current_el(void)
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 03/10] ARM: allow secure monitor code to be built without PSCI
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
2018-03-26 19:20 ` [PATCH v3 02/10] ARM: safely switch from HYP to SVC mode if required Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-03-26 19:20 ` [PATCH v3 04/10] ARM: add file for HYP mode related setup Lucas Stach
` (6 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
The hyp mode handling added in the secure monitor code is also useful
when Barebox doesn't have PSCI control. Allow to build without PSCI.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/cpu/sm_as.S | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/sm_as.S b/arch/arm/cpu/sm_as.S
index 09580e75de5f..0d01e1bf2435 100644
--- a/arch/arm/cpu/sm_as.S
+++ b/arch/arm/cpu/sm_as.S
@@ -129,7 +129,9 @@ secure_monitor:
sub sp, sp, #4*4 @ allocate result structure on stack
mov r12, sp
push {r4-r6, r12}
+#ifdef CONFIG_ARM_PSCI
bl psci_entry
+#endif
pop {r4-r6, r12}
ldm r12, {r0-r3}
add sp, sp, #4*4
@@ -163,6 +165,8 @@ ENTRY(psci_cpu_entry)
mcr p15, 0, r0, c1, c0, 1 @ ACTLR
bl secure_monitor_stack_setup
+#ifdef CONFIG_ARM_PSCI
bl psci_cpu_entry_c
+#endif
ENDPROC(psci_cpu_entry)
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 04/10] ARM: add file for HYP mode related setup
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
2018-03-26 19:20 ` [PATCH v3 02/10] ARM: safely switch from HYP to SVC mode if required Lucas Stach
2018-03-26 19:20 ` [PATCH v3 03/10] ARM: allow secure monitor code to be built without PSCI Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-04-05 7:30 ` Sascha Hauer
` (2 more replies)
2018-03-26 19:20 ` [PATCH v3 05/10] ARM: don't try to install secure monitor when entered in HYP mode Lucas Stach
` (5 subsequent siblings)
8 siblings, 3 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
This adds routines to add hyp mode vectors and switch back to HYP
mode from SVC. This is needed in both the PBL and Barebox proper.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
v3:
- fix whitespace
- use __BARE_INIT
---
arch/arm/cpu/Makefile | 4 ++
arch/arm/cpu/hyp.S | 116 ++++++++++++++++++++++++++++++++++++++++++
arch/arm/cpu/sm_as.S | 11 ----
arch/arm/include/asm/secure.h | 8 +++
4 files changed, 128 insertions(+), 11 deletions(-)
create mode 100644 arch/arm/cpu/hyp.S
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 13fe12c31f6f..f86dff975bb4 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -9,6 +9,10 @@ obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
obj-$(CONFIG_MMU) += mmu.o mmu-early.o
pbl-$(CONFIG_MMU) += mmu-early.o
lwl-y += lowlevel.o
+obj-y += hyp.o
+AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
+pbl-y += hyp.o
+AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
endif
obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
diff --git a/arch/arm/cpu/hyp.S b/arch/arm/cpu/hyp.S
new file mode 100644
index 000000000000..1314b56eab25
--- /dev/null
+++ b/arch/arm/cpu/hyp.S
@@ -0,0 +1,116 @@
+#include <linux/linkage.h>
+#include <asm/system.h>
+#include <asm/opcodes-virt.h>
+#include <init.h>
+
+.arch_extension sec
+.arch_extension virt
+
+__BARE_INIT
+
+.data
+ .align 2
+ENTRY(__boot_cpu_mode)
+ .long 0
+.text
+
+ENTRY(__hyp_install)
+ mrs r12, cpsr
+ and r12, r12, #MODE_MASK
+
+ @ Save the initial CPU state
+ adr r0, .L__boot_cpu_mode_offset
+ ldr r1, [r0]
+ str r12, [r0, r1]
+
+ cmp r12, #HYP_MODE
+ movne pc, lr @ give up if the CPU is not in HYP mode
+
+ @ Now install the hypervisor stub:
+ adr r12, __hyp_vectors
+ mcr p15, 4, r12, c12, c0, 0 @ set hypervisor vector base (HVBAR)
+
+ @ Disable all traps, so we don't get any nasty surprise
+ mov r12, #0
+ mcr p15, 4, r12, c1, c1, 0 @ HCR
+ mcr p15, 4, r12, c1, c1, 2 @ HCPTR
+ mcr p15, 4, r12, c1, c1, 3 @ HSTR
+
+THUMB( orr r12, #(1 << 30) ) @ HSCTLR.TE
+ mcr p15, 4, r12, c1, c0, 0 @ HSCTLR
+
+ mrc p15, 4, r12, c1, c1, 1 @ HDCR
+ and r12, #0x1f @ Preserve HPMN
+ mcr p15, 4, r12, c1, c1, 1 @ HDCR
+
+ @ Make sure NS-SVC is initialised appropriately
+ mrc p15, 0, r12, c1, c0, 0 @ SCTLR
+ orr r12, #(1 << 5) @ CP15 barriers enabled
+ bic r12, #(3 << 7) @ Clear SED/ITD for v8 (RES0 for v7)
+ bic r12, #(3 << 19) @ WXN and UWXN disabled
+ mcr p15, 0, r12, c1, c0, 0 @ SCTLR
+
+ mrc p15, 0, r12, c0, c0, 0 @ MIDR
+ mcr p15, 4, r12, c0, c0, 0 @ VPIDR
+
+ mrc p15, 0, r12, c0, c0, 5 @ MPIDR
+ mcr p15, 4, r12, c0, c0, 5 @ VMPIDR
+ bx lr
+ENDPROC(__hyp_install)
+
+ENTRY(armv7_hyp_install)
+ mov r2, lr
+
+ bl __hyp_install
+
+ /* set the cpu to SVC32 mode, mask irq and fiq */
+ mrs r12, cpsr
+ eor r12, r12, #HYP_MODE
+ tst r12, #MODE_MASK
+ bic r12, r12, #MODE_MASK
+ orr r12, r12, #(PSR_I_BIT | PSR_F_BIT | SVC_MODE)
+THUMB( orr r12, r12, #PSR_T_BIT )
+ bne 1f
+ orr r12, r12, #PSR_A_BIT
+ adr lr, 2f
+ msr spsr_cxsf, r12
+ __MSR_ELR_HYP(14)
+ __ERET
+1: msr cpsr_c, r12
+2:
+ mov pc, r2
+ENDPROC(armv7_hyp_install)
+
+ENTRY(armv7_switch_to_hyp)
+ mov r0, lr
+ mov r1, sp @ save SVC copy of LR and SP
+ isb
+ hvc #0 @ for older asm: .byte 0x70, 0x00, 0x40, 0xe1
+ mov sp, r1
+ mov lr, r0 @ restore SVC copy of LR and SP
+
+ bx lr
+ENDPROC(armv7_switch_to_hyp)
+
+.align 2
+.L__boot_cpu_mode_offset:
+ .long __boot_cpu_mode - .
+
+/* The HYP trap is crafted to match armv7_switch_to_hyp() */
+__hyp_do_trap:
+ mov lr, r0
+ mov sp, r1
+ bx lr
+ENDPROC(__hyp_do_trap)
+
+.align 5
+__hyp_vectors:
+__hyp_reset: W(b) .
+__hyp_und: W(b) .
+__hyp_svc: W(b) .
+__hyp_pabort: W(b) .
+__hyp_dabort: W(b) .
+__hyp_trap: W(b) __hyp_do_trap
+__hyp_irq: W(b) .
+__hyp_fiq: W(b) .
+ENDPROC(__hyp_vectors)
diff --git a/arch/arm/cpu/sm_as.S b/arch/arm/cpu/sm_as.S
index 0d01e1bf2435..de6cd0406f4f 100644
--- a/arch/arm/cpu/sm_as.S
+++ b/arch/arm/cpu/sm_as.S
@@ -148,17 +148,6 @@ hyp_trap:
mov pc, lr @ do no switch modes, but
@ return to caller
-ENTRY(armv7_switch_to_hyp)
- mov r0, lr
- mov r1, sp @ save SVC copy of LR and SP
- isb
- hvc #0 @ for older asm: .byte 0x70, 0x00, 0x40, 0xe1
- mov sp, r1
- mov lr, r0 @ restore SVC copy of LR and SP
-
- bx lr
-ENDPROC(armv7_switch_to_hyp)
-
ENTRY(psci_cpu_entry)
mrc p15, 0, r0, c1, c0, 1 @ ACTLR
orr r0, r0, #(1 << 6) @ Set SMP bit
diff --git a/arch/arm/include/asm/secure.h b/arch/arm/include/asm/secure.h
index a4cb1f6c1c44..4eb2c3ec3011 100644
--- a/arch/arm/include/asm/secure.h
+++ b/arch/arm/include/asm/secure.h
@@ -5,9 +5,17 @@
int armv7_secure_monitor_install(void);
int __armv7_secure_monitor_install(void);
+
+#ifndef CONFIG_CPU_V8
void armv7_switch_to_hyp(void);
+void armv7_hyp_install(void);
+#else
+static inline void armv7_switch_to_hyp(void) { };
+static inline void armv7_hyp_install(void) { };
+#endif
extern unsigned char secure_monitor_init_vectors[];
+extern int __boot_cpu_mode;
enum arm_security_state {
ARM_STATE_SECURE,
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 04/10] ARM: add file for HYP mode related setup
2018-03-26 19:20 ` [PATCH v3 04/10] ARM: add file for HYP mode related setup Lucas Stach
@ 2018-04-05 7:30 ` Sascha Hauer
2018-04-05 7:47 ` Sascha Hauer
2018-04-05 7:54 ` Sascha Hauer
2 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2018-04-05 7:30 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
On Mon, Mar 26, 2018 at 09:20:19PM +0200, Lucas Stach wrote:
> This adds routines to add hyp mode vectors and switch back to HYP
> mode from SVC. This is needed in both the PBL and Barebox proper.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> v3:
> - fix whitespace
> - use __BARE_INIT
> ---
> arch/arm/cpu/Makefile | 4 ++
> arch/arm/cpu/hyp.S | 116 ++++++++++++++++++++++++++++++++++++++++++
> arch/arm/cpu/sm_as.S | 11 ----
> arch/arm/include/asm/secure.h | 8 +++
> 4 files changed, 128 insertions(+), 11 deletions(-)
> create mode 100644 arch/arm/cpu/hyp.S
>
> diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
> index 13fe12c31f6f..f86dff975bb4 100644
> --- a/arch/arm/cpu/Makefile
> +++ b/arch/arm/cpu/Makefile
> @@ -9,6 +9,10 @@ obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
> obj-$(CONFIG_MMU) += mmu.o mmu-early.o
> pbl-$(CONFIG_MMU) += mmu-early.o
> lwl-y += lowlevel.o
> +obj-y += hyp.o
> +AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> +pbl-y += hyp.o
> +AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> endif
For building files regularly and pbl we have obj-pbl-y. Also I would
really prefer to depend that on CONFIG_CPU_32v7
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 04/10] ARM: add file for HYP mode related setup
2018-03-26 19:20 ` [PATCH v3 04/10] ARM: add file for HYP mode related setup Lucas Stach
2018-04-05 7:30 ` Sascha Hauer
@ 2018-04-05 7:47 ` Sascha Hauer
2018-04-05 7:54 ` Sascha Hauer
2 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2018-04-05 7:47 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
On Mon, Mar 26, 2018 at 09:20:19PM +0200, Lucas Stach wrote:
> This adds routines to add hyp mode vectors and switch back to HYP
> mode from SVC. This is needed in both the PBL and Barebox proper.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> v3:
> - fix whitespace
> - use __BARE_INIT
> ---
> arch/arm/cpu/Makefile | 4 ++
> arch/arm/cpu/hyp.S | 116 ++++++++++++++++++++++++++++++++++++++++++
> arch/arm/cpu/sm_as.S | 11 ----
> arch/arm/include/asm/secure.h | 8 +++
> 4 files changed, 128 insertions(+), 11 deletions(-)
> create mode 100644 arch/arm/cpu/hyp.S
>
> diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
> index 13fe12c31f6f..f86dff975bb4 100644
> --- a/arch/arm/cpu/Makefile
> +++ b/arch/arm/cpu/Makefile
> @@ -9,6 +9,10 @@ obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
> obj-$(CONFIG_MMU) += mmu.o mmu-early.o
> pbl-$(CONFIG_MMU) += mmu-early.o
> lwl-y += lowlevel.o
> +obj-y += hyp.o
> +AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> +pbl-y += hyp.o
> +AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> endif
>
> obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
> diff --git a/arch/arm/cpu/hyp.S b/arch/arm/cpu/hyp.S
> new file mode 100644
> index 000000000000..1314b56eab25
> --- /dev/null
> +++ b/arch/arm/cpu/hyp.S
> @@ -0,0 +1,116 @@
> +#include <linux/linkage.h>
> +#include <asm/system.h>
> +#include <asm/opcodes-virt.h>
> +#include <init.h>
> +
> +.arch_extension sec
> +.arch_extension virt
> +
> +__BARE_INIT
> +
> +.data
> + .align 2
> +ENTRY(__boot_cpu_mode)
> + .long 0
> +.text
> +
> +ENTRY(__hyp_install)
> + mrs r12, cpsr
> + and r12, r12, #MODE_MASK
> +
> + @ Save the initial CPU state
> + adr r0, .L__boot_cpu_mode_offset
> + ldr r1, [r0]
> + str r12, [r0, r1]
> +
> + cmp r12, #HYP_MODE
> + movne pc, lr @ give up if the CPU is not in HYP mode
> +
> + @ Now install the hypervisor stub:
> + adr r12, __hyp_vectors
> + mcr p15, 4, r12, c12, c0, 0 @ set hypervisor vector base (HVBAR)
> +
> + @ Disable all traps, so we don't get any nasty surprise
> + mov r12, #0
> + mcr p15, 4, r12, c1, c1, 0 @ HCR
> + mcr p15, 4, r12, c1, c1, 2 @ HCPTR
> + mcr p15, 4, r12, c1, c1, 3 @ HSTR
> +
> +THUMB( orr r12, #(1 << 30) ) @ HSCTLR.TE
> + mcr p15, 4, r12, c1, c0, 0 @ HSCTLR
> +
> + mrc p15, 4, r12, c1, c1, 1 @ HDCR
> + and r12, #0x1f @ Preserve HPMN
> + mcr p15, 4, r12, c1, c1, 1 @ HDCR
> +
> + @ Make sure NS-SVC is initialised appropriately
> + mrc p15, 0, r12, c1, c0, 0 @ SCTLR
> + orr r12, #(1 << 5) @ CP15 barriers enabled
> + bic r12, #(3 << 7) @ Clear SED/ITD for v8 (RES0 for v7)
> + bic r12, #(3 << 19) @ WXN and UWXN disabled
> + mcr p15, 0, r12, c1, c0, 0 @ SCTLR
> +
> + mrc p15, 0, r12, c0, c0, 0 @ MIDR
> + mcr p15, 4, r12, c0, c0, 0 @ VPIDR
> +
> + mrc p15, 0, r12, c0, c0, 5 @ MPIDR
> + mcr p15, 4, r12, c0, c0, 5 @ VMPIDR
> + bx lr
> +ENDPROC(__hyp_install)
> +
> +ENTRY(armv7_hyp_install)
> + mov r2, lr
> +
> + bl __hyp_install
> +
> + /* set the cpu to SVC32 mode, mask irq and fiq */
> + mrs r12, cpsr
> + eor r12, r12, #HYP_MODE
> + tst r12, #MODE_MASK
> + bic r12, r12, #MODE_MASK
> + orr r12, r12, #(PSR_I_BIT | PSR_F_BIT | SVC_MODE)
> +THUMB( orr r12, r12, #PSR_T_BIT )
> + bne 1f
> + orr r12, r12, #PSR_A_BIT
> + adr lr, 2f
> + msr spsr_cxsf, r12
> + __MSR_ELR_HYP(14)
> + __ERET
> +1: msr cpsr_c, r12
> +2:
> + mov pc, r2
> +ENDPROC(armv7_hyp_install)
armv7_hyp_install does the same as arm_cpu_lowlevel_init().
arm_cpu_lowlevel_init() was called by the board code already, why do you
have to do this again in the generic startup path?
I understand that you have to call __hyp_install in non-pbl code again,
but wouldn't it be sufficient to call only that?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 04/10] ARM: add file for HYP mode related setup
2018-03-26 19:20 ` [PATCH v3 04/10] ARM: add file for HYP mode related setup Lucas Stach
2018-04-05 7:30 ` Sascha Hauer
2018-04-05 7:47 ` Sascha Hauer
@ 2018-04-05 7:54 ` Sascha Hauer
2018-04-10 10:53 ` Lucas Stach
2 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2018-04-05 7:54 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
On Mon, Mar 26, 2018 at 09:20:19PM +0200, Lucas Stach wrote:
> This adds routines to add hyp mode vectors and switch back to HYP
> mode from SVC. This is needed in both the PBL and Barebox proper.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> v3:
> - fix whitespace
> - use __BARE_INIT
> ---
> arch/arm/cpu/Makefile | 4 ++
> arch/arm/cpu/hyp.S | 116 ++++++++++++++++++++++++++++++++++++++++++
> arch/arm/cpu/sm_as.S | 11 ----
> arch/arm/include/asm/secure.h | 8 +++
> 4 files changed, 128 insertions(+), 11 deletions(-)
> create mode 100644 arch/arm/cpu/hyp.S
>
> diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
> index 13fe12c31f6f..f86dff975bb4 100644
> --- a/arch/arm/cpu/Makefile
> +++ b/arch/arm/cpu/Makefile
> @@ -9,6 +9,10 @@ obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
> obj-$(CONFIG_MMU) += mmu.o mmu-early.o
> pbl-$(CONFIG_MMU) += mmu-early.o
> lwl-y += lowlevel.o
> +obj-y += hyp.o
> +AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> +pbl-y += hyp.o
> +AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> endif
>
> obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
> diff --git a/arch/arm/cpu/hyp.S b/arch/arm/cpu/hyp.S
> new file mode 100644
> index 000000000000..1314b56eab25
> --- /dev/null
> +++ b/arch/arm/cpu/hyp.S
> @@ -0,0 +1,116 @@
> +#include <linux/linkage.h>
> +#include <asm/system.h>
> +#include <asm/opcodes-virt.h>
> +#include <init.h>
> +
> +.arch_extension sec
> +.arch_extension virt
> +
> +__BARE_INIT
> +
> +.data
> + .align 2
> +ENTRY(__boot_cpu_mode)
> + .long 0
> +.text
> +
> +ENTRY(__hyp_install)
> + mrs r12, cpsr
> + and r12, r12, #MODE_MASK
> +
> + @ Save the initial CPU state
> + adr r0, .L__boot_cpu_mode_offset
> + ldr r1, [r0]
> + str r12, [r0, r1]
Naa, this won't work. You save the cpsr value in __boot_cpu_mode, but
this variable exists both in PBL and regular barebox, __hyp_install
is called multiple times and cpsr is modified right after saving it.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 04/10] ARM: add file for HYP mode related setup
2018-04-05 7:54 ` Sascha Hauer
@ 2018-04-10 10:53 ` Lucas Stach
2018-04-11 8:41 ` Sascha Hauer
0 siblings, 1 reply; 19+ messages in thread
From: Lucas Stach @ 2018-04-10 10:53 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Am Donnerstag, den 05.04.2018, 09:54 +0200 schrieb Sascha Hauer:
> On Mon, Mar 26, 2018 at 09:20:19PM +0200, Lucas Stach wrote:
> > This adds routines to add hyp mode vectors and switch back to HYP
> > mode from SVC. This is needed in both the PBL and Barebox proper.
> >
> > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > > Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> > ---
> > v3:
> > - fix whitespace
> > - use __BARE_INIT
> > ---
> > arch/arm/cpu/Makefile | 4 ++
> > arch/arm/cpu/hyp.S | 116 ++++++++++++++++++++++++++++++++++++++++++
> > arch/arm/cpu/sm_as.S | 11 ----
> > arch/arm/include/asm/secure.h | 8 +++
> > 4 files changed, 128 insertions(+), 11 deletions(-)
> > create mode 100644 arch/arm/cpu/hyp.S
> >
> > diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
> > index 13fe12c31f6f..f86dff975bb4 100644
> > --- a/arch/arm/cpu/Makefile
> > +++ b/arch/arm/cpu/Makefile
> > @@ -9,6 +9,10 @@ obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
> > obj-$(CONFIG_MMU) += mmu.o mmu-early.o
> > pbl-$(CONFIG_MMU) += mmu-early.o
> > lwl-y += lowlevel.o
> > +obj-y += hyp.o
> > +AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> > +pbl-y += hyp.o
> > +AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> > endif
> >
> > obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
> > diff --git a/arch/arm/cpu/hyp.S b/arch/arm/cpu/hyp.S
> > new file mode 100644
> > index 000000000000..1314b56eab25
> > --- /dev/null
> > +++ b/arch/arm/cpu/hyp.S
> > @@ -0,0 +1,116 @@
> > +#include <linux/linkage.h>
> > +#include <asm/system.h>
> > +#include <asm/opcodes-virt.h>
> > +#include <init.h>
> > +
> > +.arch_extension sec
> > +.arch_extension virt
> > +
> > +__BARE_INIT
> > +
> > +.data
> > > > + .align 2
> > +ENTRY(__boot_cpu_mode)
> > > > + .long 0
> > +.text
> > +
> > +ENTRY(__hyp_install)
> > > > > > + mrs r12, cpsr
> > > > > > + and r12, r12, #MODE_MASK
> > +
> > > > + @ Save the initial CPU state
> > > > > > + adr r0, .L__boot_cpu_mode_offset
> > > > > > + ldr r1, [r0]
> > + str r12, [r0, r1]
>
> Naa, this won't work. You save the cpsr value in __boot_cpu_mode, but
> this variable exists both in PBL and regular barebox, __hyp_install
> is called multiple times and cpsr is modified right after saving it.
It does. ;)
I guess its non-obvious from the code flow, but what we do is to drop
down to SVC in the PBL, then jump back to HYP before starting barebox
proper and the dropping down to SVC again on barebox entry.
All in all this is less-than-pretty, but IMHO it's the lesser evil than
trying to implement some communication channel from PBL to barebox
proper to pass information like this.
So I guess this code needs some more comments...
Regards,
Lucas
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 04/10] ARM: add file for HYP mode related setup
2018-04-10 10:53 ` Lucas Stach
@ 2018-04-11 8:41 ` Sascha Hauer
0 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2018-04-11 8:41 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
On Tue, Apr 10, 2018 at 12:53:32PM +0200, Lucas Stach wrote:
> Am Donnerstag, den 05.04.2018, 09:54 +0200 schrieb Sascha Hauer:
> > On Mon, Mar 26, 2018 at 09:20:19PM +0200, Lucas Stach wrote:
> > > This adds routines to add hyp mode vectors and switch back to HYP
> > > mode from SVC. This is needed in both the PBL and Barebox proper.
> > >
> > > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > > > Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> > > ---
> > > v3:
> > > - fix whitespace
> > > - use __BARE_INIT
> > > ---
> > > arch/arm/cpu/Makefile | 4 ++
> > > arch/arm/cpu/hyp.S | 116 ++++++++++++++++++++++++++++++++++++++++++
> > > arch/arm/cpu/sm_as.S | 11 ----
> > > arch/arm/include/asm/secure.h | 8 +++
> > > 4 files changed, 128 insertions(+), 11 deletions(-)
> > > create mode 100644 arch/arm/cpu/hyp.S
> > >
> > > diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
> > > index 13fe12c31f6f..f86dff975bb4 100644
> > > --- a/arch/arm/cpu/Makefile
> > > +++ b/arch/arm/cpu/Makefile
> > > @@ -9,6 +9,10 @@ obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
> > > obj-$(CONFIG_MMU) += mmu.o mmu-early.o
> > > pbl-$(CONFIG_MMU) += mmu-early.o
> > > lwl-y += lowlevel.o
> > > +obj-y += hyp.o
> > > +AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> > > +pbl-y += hyp.o
> > > +AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
> > > endif
> > >
> > > obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
> > > diff --git a/arch/arm/cpu/hyp.S b/arch/arm/cpu/hyp.S
> > > new file mode 100644
> > > index 000000000000..1314b56eab25
> > > --- /dev/null
> > > +++ b/arch/arm/cpu/hyp.S
> > > @@ -0,0 +1,116 @@
> > > +#include <linux/linkage.h>
> > > +#include <asm/system.h>
> > > +#include <asm/opcodes-virt.h>
> > > +#include <init.h>
> > > +
> > > +.arch_extension sec
> > > +.arch_extension virt
> > > +
> > > +__BARE_INIT
> > > +
> > > +.data
> > > > > + .align 2
> > > +ENTRY(__boot_cpu_mode)
> > > > > + .long 0
> > > +.text
> > > +
> > > +ENTRY(__hyp_install)
> > > > > > > + mrs r12, cpsr
> > > > > > > + and r12, r12, #MODE_MASK
> > > +
> > > > > + @ Save the initial CPU state
> > > > > > > + adr r0, .L__boot_cpu_mode_offset
> > > > > > > + ldr r1, [r0]
> > > + str r12, [r0, r1]
> >
> > Naa, this won't work. You save the cpsr value in __boot_cpu_mode, but
> > this variable exists both in PBL and regular barebox, __hyp_install
> > is called multiple times and cpsr is modified right after saving it.
>
> It does. ;)
>
> I guess its non-obvious from the code flow, but what we do is to drop
> down to SVC in the PBL, then jump back to HYP before starting barebox
> proper and the dropping down to SVC again on barebox entry.
> All in all this is less-than-pretty, but IMHO it's the lesser evil than
> trying to implement some communication channel from PBL to barebox
> proper to pass information like this.
>
> So I guess this code needs some more comments...
Yep ;)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 05/10] ARM: don't try to install secure monitor when entered in HYP mode
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
` (2 preceding siblings ...)
2018-03-26 19:20 ` [PATCH v3 04/10] ARM: add file for HYP mode related setup Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-03-26 19:20 ` [PATCH v3 06/10] ARM: default to starting kernel in HYP mode when entered in HYP Lucas Stach
` (4 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
When Barebox has been entered in HYP mode, the CPU is already switched
to the non-secure world and it's not possible for Barebox to install
it's own secure monitor.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/cpu/sm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm/cpu/sm.c b/arch/arm/cpu/sm.c
index 5808dfd92bdc..71bb394c8540 100644
--- a/arch/arm/cpu/sm.c
+++ b/arch/arm/cpu/sm.c
@@ -184,6 +184,9 @@ int armv7_secure_monitor_install(void)
return -EINVAL;
}
+ if (__boot_cpu_mode == HYP_MODE)
+ return 0;
+
mmuon = get_cr() & CR_M;
vbar = get_vbar();
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 06/10] ARM: default to starting kernel in HYP mode when entered in HYP
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
` (3 preceding siblings ...)
2018-03-26 19:20 ` [PATCH v3 05/10] ARM: don't try to install secure monitor when entered in HYP mode Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-03-26 19:20 ` [PATCH v3 07/10] ARM: install HYP vectors at PBL and Barebox entry Lucas Stach
` (3 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
When Barebox has been entered in HYP mode, there is a high chance that
the kernel is intended to be started in HYP mode also. Get this
default into place.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/cpu/sm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm/cpu/sm.c b/arch/arm/cpu/sm.c
index 71bb394c8540..3369fbb5ff1a 100644
--- a/arch/arm/cpu/sm.c
+++ b/arch/arm/cpu/sm.c
@@ -264,6 +264,9 @@ static int sm_init(void)
bootm_secure_state_names,
ARRAY_SIZE(bootm_secure_state_names));
+ if (__boot_cpu_mode == HYP_MODE)
+ bootm_secure_state = ARM_STATE_HYP;
+
return 0;
}
device_initcall(sm_init);
\ No newline at end of file
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 07/10] ARM: install HYP vectors at PBL and Barebox entry
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
` (4 preceding siblings ...)
2018-03-26 19:20 ` [PATCH v3 06/10] ARM: default to starting kernel in HYP mode when entered in HYP Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-04-05 7:42 ` Sascha Hauer
2018-03-26 19:20 ` [PATCH v3 08/10] ARM: rpi: add revision IDs for Pi 3 Model B and Pi Zero Lucas Stach
` (2 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
If the CPU was already in HYP mode when entering the PBL, install a
simple trap handler to allow to get back from SVC to HYP before
switching to HYP mode.
As the vectors are part of the currently running binary, we need to
do the same setup when starting the real Barebox binary, as the PBL
setup vectors might get overwritten. To do this we trap into HYP mode
just before jumping to Barebox and then re-do the vector setup and
SVC switch as the first thing in Barebox proper.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/cpu/lowlevel.S | 3 +++
arch/arm/cpu/start-pbl.c | 4 ++++
arch/arm/cpu/start.c | 3 +++
arch/arm/cpu/uncompress.c | 4 ++++
4 files changed, 14 insertions(+)
diff --git a/arch/arm/cpu/lowlevel.S b/arch/arm/cpu/lowlevel.S
index 43665981e48b..13dfe496ad17 100644
--- a/arch/arm/cpu/lowlevel.S
+++ b/arch/arm/cpu/lowlevel.S
@@ -8,6 +8,9 @@ ENTRY(arm_cpu_lowlevel_init)
/* save lr, since it may be banked away with a processor mode change */
mov r2, lr
+ /* careful: the hyp install corrupts r0 and r1 */
+ bl __hyp_install
+
/* set the cpu to SVC32 mode, mask irq and fiq */
mrs r12, cpsr
eor r12, r12, #HYP_MODE
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index e851b4a2da5e..e0793579e2e8 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -26,6 +26,7 @@
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
+#include <asm/secure.h>
#include <asm/pgtable.h>
#include <asm/cache.h>
#include <asm/unaligned.h>
@@ -100,5 +101,8 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
else
barebox = (void *)barebox_base;
+ if (__boot_cpu_mode == HYP_MODE)
+ armv7_switch_to_hyp();
+
barebox(membase, memsize, boarddata);
}
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 171e6ad0eb7a..a0db6436f387 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -24,6 +24,7 @@
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
+#include <asm/secure.h>
#include <asm/unaligned.h>
#include <asm/cache.h>
#include <memory.h>
@@ -145,6 +146,8 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
unsigned long malloc_start, malloc_end;
unsigned long barebox_size = barebox_image_size + MAX_BSS_SIZE;
+ armv7_hyp_install();
+
if (IS_ENABLED(CONFIG_RELOCATABLE)) {
unsigned long barebox_base = arm_mem_barebox_image(membase,
endmem,
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index 9d7fe0e921a9..28636aa8101f 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -27,6 +27,7 @@
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
+#include <asm/secure.h>
#include <asm/pgtable.h>
#include <asm/cache.h>
#include <asm/unaligned.h>
@@ -109,5 +110,8 @@ void __noreturn barebox_multi_pbl_start(unsigned long membase,
pr_debug("jumping to uncompressed image at 0x%p\n", barebox);
+ if (__boot_cpu_mode == HYP_MODE)
+ armv7_switch_to_hyp();
+
barebox(membase, memsize, boarddata);
}
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 07/10] ARM: install HYP vectors at PBL and Barebox entry
2018-03-26 19:20 ` [PATCH v3 07/10] ARM: install HYP vectors at PBL and Barebox entry Lucas Stach
@ 2018-04-05 7:42 ` Sascha Hauer
2018-04-10 10:34 ` Lucas Stach
0 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2018-04-05 7:42 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
On Mon, Mar 26, 2018 at 09:20:22PM +0200, Lucas Stach wrote:
> If the CPU was already in HYP mode when entering the PBL, install a
> simple trap handler to allow to get back from SVC to HYP before
> switching to HYP mode.
>
> As the vectors are part of the currently running binary, we need to
> do the same setup when starting the real Barebox binary, as the PBL
> setup vectors might get overwritten. To do this we trap into HYP mode
> just before jumping to Barebox and then re-do the vector setup and
> SVC switch as the first thing in Barebox proper.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> arch/arm/cpu/lowlevel.S | 3 +++
> arch/arm/cpu/start-pbl.c | 4 ++++
> arch/arm/cpu/start.c | 3 +++
> arch/arm/cpu/uncompress.c | 4 ++++
> 4 files changed, 14 insertions(+)
>
> diff --git a/arch/arm/cpu/lowlevel.S b/arch/arm/cpu/lowlevel.S
> index 43665981e48b..13dfe496ad17 100644
> --- a/arch/arm/cpu/lowlevel.S
> +++ b/arch/arm/cpu/lowlevel.S
> @@ -8,6 +8,9 @@ ENTRY(arm_cpu_lowlevel_init)
> /* save lr, since it may be banked away with a processor mode change */
> mov r2, lr
>
> + /* careful: the hyp install corrupts r0 and r1 */
> + bl __hyp_install
> +
> /* set the cpu to SVC32 mode, mask irq and fiq */
> mrs r12, cpsr
> eor r12, r12, #HYP_MODE
> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
> index e851b4a2da5e..e0793579e2e8 100644
> --- a/arch/arm/cpu/start-pbl.c
> +++ b/arch/arm/cpu/start-pbl.c
> @@ -26,6 +26,7 @@
> #include <asm/barebox-arm-head.h>
> #include <asm-generic/memory_layout.h>
> #include <asm/sections.h>
> +#include <asm/secure.h>
> #include <asm/pgtable.h>
> #include <asm/cache.h>
> #include <asm/unaligned.h>
> @@ -100,5 +101,8 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
> else
> barebox = (void *)barebox_base;
>
> + if (__boot_cpu_mode == HYP_MODE)
> + armv7_switch_to_hyp();
> +
> barebox(membase, memsize, boarddata);
> }
> diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
> index 171e6ad0eb7a..a0db6436f387 100644
> --- a/arch/arm/cpu/start.c
> +++ b/arch/arm/cpu/start.c
> @@ -24,6 +24,7 @@
> #include <asm/barebox-arm-head.h>
> #include <asm-generic/memory_layout.h>
> #include <asm/sections.h>
> +#include <asm/secure.h>
> #include <asm/unaligned.h>
> #include <asm/cache.h>
> #include <memory.h>
> @@ -145,6 +146,8 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
> unsigned long malloc_start, malloc_end;
> unsigned long barebox_size = barebox_image_size + MAX_BSS_SIZE;
>
> + armv7_hyp_install();
Calling a armv7 specific function in a generic code path is not so nice.
If this is really necessary then I suggest to #ifdef it here rather than
in the header file (where armv7_hyp_install() expands to a noop for
armv8. And what about the older architectures? A quick test revealed
this works on armv5, but is this intentional or by accident?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 07/10] ARM: install HYP vectors at PBL and Barebox entry
2018-04-05 7:42 ` Sascha Hauer
@ 2018-04-10 10:34 ` Lucas Stach
0 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-04-10 10:34 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Am Donnerstag, den 05.04.2018, 09:42 +0200 schrieb Sascha Hauer:
> On Mon, Mar 26, 2018 at 09:20:22PM +0200, Lucas Stach wrote:
> > If the CPU was already in HYP mode when entering the PBL, install a
> > simple trap handler to allow to get back from SVC to HYP before
> > switching to HYP mode.
> >
> > As the vectors are part of the currently running binary, we need to
> > do the same setup when starting the real Barebox binary, as the PBL
> > setup vectors might get overwritten. To do this we trap into HYP mode
> > just before jumping to Barebox and then re-do the vector setup and
> > SVC switch as the first thing in Barebox proper.
> >
> > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > > > Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> > ---
> > arch/arm/cpu/lowlevel.S | 3 +++
> > arch/arm/cpu/start-pbl.c | 4 ++++
> > arch/arm/cpu/start.c | 3 +++
> > arch/arm/cpu/uncompress.c | 4 ++++
> > 4 files changed, 14 insertions(+)
> >
> > diff --git a/arch/arm/cpu/lowlevel.S b/arch/arm/cpu/lowlevel.S
> > index 43665981e48b..13dfe496ad17 100644
> > --- a/arch/arm/cpu/lowlevel.S
> > +++ b/arch/arm/cpu/lowlevel.S
> > @@ -8,6 +8,9 @@ ENTRY(arm_cpu_lowlevel_init)
> > > > /* save lr, since it may be banked away with a processor mode change */
> > > > > > mov r2, lr
> >
> > > > + /* careful: the hyp install corrupts r0 and r1 */
> > > > > > + bl __hyp_install
> > +
> > > > /* set the cpu to SVC32 mode, mask irq and fiq */
> > > > > > mrs r12, cpsr
> > > > > > eor r12, r12, #HYP_MODE
> > diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
> > index e851b4a2da5e..e0793579e2e8 100644
> > --- a/arch/arm/cpu/start-pbl.c
> > +++ b/arch/arm/cpu/start-pbl.c
> > @@ -26,6 +26,7 @@
> > #include <asm/barebox-arm-head.h>
> > #include <asm-generic/memory_layout.h>
> > #include <asm/sections.h>
> > +#include <asm/secure.h>
> > #include <asm/pgtable.h>
> > #include <asm/cache.h>
> > #include <asm/unaligned.h>
> > @@ -100,5 +101,8 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
> > > > else
> > > > barebox = (void *)barebox_base;
> >
> > > > + if (__boot_cpu_mode == HYP_MODE)
> > > > + armv7_switch_to_hyp();
> > +
> > > > barebox(membase, memsize, boarddata);
> > }
> > diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
> > index 171e6ad0eb7a..a0db6436f387 100644
> > --- a/arch/arm/cpu/start.c
> > +++ b/arch/arm/cpu/start.c
> > @@ -24,6 +24,7 @@
> > #include <asm/barebox-arm-head.h>
> > #include <asm-generic/memory_layout.h>
> > #include <asm/sections.h>
> > +#include <asm/secure.h>
> > #include <asm/unaligned.h>
> > #include <asm/cache.h>
> > #include <memory.h>
> > @@ -145,6 +146,8 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
> > > > unsigned long malloc_start, malloc_end;
> > > > unsigned long barebox_size = barebox_image_size + MAX_BSS_SIZE;
> >
> > + armv7_hyp_install();
>
> Calling a armv7 specific function in a generic code path is not so nice.
> If this is really necessary then I suggest to #ifdef it here rather than
> in the header file (where armv7_hyp_install() expands to a noop for
> armv8. And what about the older architectures? A quick test revealed
> this works on armv5, but is this intentional or by accident?
Yep, it is coded to be a quick return on older < ARMv7 with the
executed instructions being compatible. I'll still change this to a
IS_ENABLED condition, as this might save some code size if only !ARMv7
arches are enabled in the config.
Thanks,
Lucas
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 08/10] ARM: rpi: add revision IDs for Pi 3 Model B and Pi Zero
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
` (5 preceding siblings ...)
2018-03-26 19:20 ` [PATCH v3 07/10] ARM: install HYP vectors at PBL and Barebox entry Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-03-26 19:20 ` [PATCH v3 09/10] ARM: rpi: add raspberry pi 3 support Lucas Stach
2018-03-26 19:20 ` [PATCH v3 10/10] ARM: rpi: autosize malloc area Lucas Stach
8 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
From: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 2 ++
arch/arm/mach-bcm283x/include/mach/mbox.h | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 6e375bc984de..aec8cb27ed40 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -174,6 +174,8 @@ const struct rpi_model rpi_models_old_scheme[] = {
const struct rpi_model rpi_models_new_scheme[] = {
RPI_MODEL(0, "Unknown model", NULL),
RPI_MODEL(BCM2836_BOARD_REV_2_B, "2 Model B", rpi_b_plus_init),
+ RPI_MODEL(BCM2837_BOARD_REV_3_B, "3 Model B", rpi_b_plus_init),
+ RPI_MODEL(BCM2837_BOARD_REV_ZERO, "Zero", rpi_b_plus_init),
};
static int rpi_board_rev = 0;
diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index 2b5aea88ee0a..4cddf99a8429 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -129,6 +129,10 @@ struct bcm2835_mbox_tag_hdr {
/* RPi 2 */
#define BCM2836_BOARD_REV_2_B 0x4
+/* RPi 3 */
+#define BCM2837_BOARD_REV_3_B 0x8
+/* Zero */
+#define BCM2837_BOARD_REV_ZERO 0x9
/*
* 0x2..0xf from:
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 09/10] ARM: rpi: add raspberry pi 3 support
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
` (6 preceding siblings ...)
2018-03-26 19:20 ` [PATCH v3 08/10] ARM: rpi: add revision IDs for Pi 3 Model B and Pi Zero Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
2018-09-16 15:09 ` Alexander Dahl
2018-03-26 19:20 ` [PATCH v3 10/10] ARM: rpi: autosize malloc area Lucas Stach
8 siblings, 1 reply; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
This adds basic support at the same feature level as the other
supported raspberry pi boards.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/raspberry-pi/lowlevel.c | 14 ++++++++++++--
arch/arm/configs/rpi_defconfig | 2 ++
arch/arm/dts/Makefile | 1 +
arch/arm/dts/bcm2837-rpi-3.dts | 15 +++++++++++++++
arch/arm/mach-bcm283x/Kconfig | 6 ++++++
arch/arm/mach-bcm283x/core.c | 1 +
images/Makefile.bcm283x | 4 ++++
7 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/dts/bcm2837-rpi-3.dts
diff --git a/arch/arm/boards/raspberry-pi/lowlevel.c b/arch/arm/boards/raspberry-pi/lowlevel.c
index 4e71e29e0c0b..5ca0d3877069 100644
--- a/arch/arm/boards/raspberry-pi/lowlevel.c
+++ b/arch/arm/boards/raspberry-pi/lowlevel.c
@@ -1,7 +1,7 @@
+#include <asm/barebox-arm.h>
+#include <asm/cache.h>
#include <common.h>
#include <linux/sizes.h>
-#include <asm/barebox-arm.h>
-#include <asm/barebox-arm-head.h>
#include <mach/platform.h>
extern char __dtb_bcm2835_rpi_start[];
@@ -23,3 +23,13 @@ ENTRY_FUNCTION(start_raspberry_pi2, r0, r1, r2)
barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
}
+
+extern char __dtb_bcm2837_rpi_3_start[];
+ENTRY_FUNCTION(start_raspberry_pi3, r0, r1, r2)
+{
+ void *fdt = __dtb_bcm2837_rpi_3_start - get_runtime_offset();
+
+ arm_cpu_lowlevel_init();
+
+ barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
+}
diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
index f3aef4290425..cd88b4ac751c 100644
--- a/arch/arm/configs/rpi_defconfig
+++ b/arch/arm/configs/rpi_defconfig
@@ -1,9 +1,11 @@
CONFIG_ARCH_BCM283X=y
CONFIG_MACH_RPI=y
CONFIG_MACH_RPI2=y
+CONFIG_MACH_RPI3=y
CONFIG_AEABI=y
CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
CONFIG_ARM_UNWIND=y
+CONFIG_IMAGE_COMPRESSION_NONE=y
CONFIG_MMU=y
CONFIG_MALLOC_TLSF=y
CONFIG_KALLSYMS=y
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0526a6f40724..0eab313c5011 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -66,6 +66,7 @@ pbl-dtb-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += rk3288-phycore-som.dtb.o
pbl-dtb-$(CONFIG_MACH_REALQ7) += imx6q-dmo-edmqmx6.dtb.o
pbl-dtb-$(CONFIG_MACH_RPI) += bcm2835-rpi.dtb.o
pbl-dtb-$(CONFIG_MACH_RPI2) += bcm2836-rpi-2.dtb.o
+pbl-dtb-$(CONFIG_MACH_RPI3) += bcm2837-rpi-3.dtb.o
pbl-dtb-$(CONFIG_MACH_SABRELITE) += imx6q-sabrelite.dtb.o imx6dl-sabrelite.dtb.o
pbl-dtb-$(CONFIG_MACH_SABRESD) += imx6q-sabresd.dtb.o
pbl-dtb-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += imx6sx-sdb.dtb.o
diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts
new file mode 100644
index 000000000000..f8c58c570137
--- /dev/null
+++ b/arch/arm/dts/bcm2837-rpi-3.dts
@@ -0,0 +1,15 @@
+#include <arm64/broadcom/bcm2837-rpi-3-b.dts>
+
+/ {
+ chosen {
+ stdout-path = &uart0;
+ };
+
+ memory {
+ reg = <0x0 0x0>;
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
index 1457f114ccaa..af2f88c47acb 100644
--- a/arch/arm/mach-bcm283x/Kconfig
+++ b/arch/arm/mach-bcm283x/Kconfig
@@ -19,6 +19,12 @@ config MACH_RPI2
select CPU_V7
select MACH_RPI_COMMON
+config MACH_RPI3
+ bool "RaspberryPi 3 (BCM2837/CORTEX-A53)"
+ select CPU_V7
+ select MACH_RPI_COMMON
+ select ARM_SECURE_MONITOR
+
endmenu
config MACH_RPI_DEBUG_UART_BASE
diff --git a/arch/arm/mach-bcm283x/core.c b/arch/arm/mach-bcm283x/core.c
index fddcb0d1a1d4..26f0996b1cb8 100644
--- a/arch/arm/mach-bcm283x/core.c
+++ b/arch/arm/mach-bcm283x/core.c
@@ -41,6 +41,7 @@ static int bcm2835_clk_init(void)
clk = clk_fixed("uart0-pl0110", 3 * 1000 * 1000);
clk_register_clkdev(clk, NULL, "uart0-pl0110");
clk_register_clkdev(clk, NULL, "20201000.serial");
+ clk_register_clkdev(clk, NULL, "3f201000.serial");
clk = clk_fixed("bcm2835-cs", 1 * 1000 * 1000);
clk_register_clkdev(clk, NULL, "bcm2835-cs");
diff --git a/images/Makefile.bcm283x b/images/Makefile.bcm283x
index d59ef043f05c..d14e648926ac 100644
--- a/images/Makefile.bcm283x
+++ b/images/Makefile.bcm283x
@@ -9,3 +9,7 @@ image-$(CONFIG_MACH_RPI) += barebox-raspberry-pi-1.img
pblx-$(CONFIG_MACH_RPI2) += start_raspberry_pi2
FILE_barebox-raspberry-pi-2.img = start_raspberry_pi2.pblx
image-$(CONFIG_MACH_RPI2) += barebox-raspberry-pi-2.img
+
+pblx-$(CONFIG_MACH_RPI3) += start_raspberry_pi3
+FILE_barebox-raspberry-pi-3.img = start_raspberry_pi3.pblx
+image-$(CONFIG_MACH_RPI3) += barebox-raspberry-pi-3.img
\ No newline at end of file
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 09/10] ARM: rpi: add raspberry pi 3 support
2018-03-26 19:20 ` [PATCH v3 09/10] ARM: rpi: add raspberry pi 3 support Lucas Stach
@ 2018-09-16 15:09 ` Alexander Dahl
2018-09-17 10:34 ` Roland Hieber
0 siblings, 1 reply; 19+ messages in thread
From: Alexander Dahl @ 2018-09-16 15:09 UTC (permalink / raw)
To: Lucas Stach; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 5785 bytes --]
Hei hei,
this patch series for RPi3 support was not merged yet. What is the
current status? Would it help if I test it on a raspberry pi 3?
(Background: I have a RPi3 lying around and would like to use
DistroKit on it.)
Greets
Alex
On Mon, Mar 26, 2018 at 09:20:24PM +0200, Lucas Stach wrote:
> This adds basic support at the same feature level as the other
> supported raspberry pi boards.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> arch/arm/boards/raspberry-pi/lowlevel.c | 14 ++++++++++++--
> arch/arm/configs/rpi_defconfig | 2 ++
> arch/arm/dts/Makefile | 1 +
> arch/arm/dts/bcm2837-rpi-3.dts | 15 +++++++++++++++
> arch/arm/mach-bcm283x/Kconfig | 6 ++++++
> arch/arm/mach-bcm283x/core.c | 1 +
> images/Makefile.bcm283x | 4 ++++
> 7 files changed, 41 insertions(+), 2 deletions(-)
> create mode 100644 arch/arm/dts/bcm2837-rpi-3.dts
>
> diff --git a/arch/arm/boards/raspberry-pi/lowlevel.c b/arch/arm/boards/raspberry-pi/lowlevel.c
> index 4e71e29e0c0b..5ca0d3877069 100644
> --- a/arch/arm/boards/raspberry-pi/lowlevel.c
> +++ b/arch/arm/boards/raspberry-pi/lowlevel.c
> @@ -1,7 +1,7 @@
> +#include <asm/barebox-arm.h>
> +#include <asm/cache.h>
> #include <common.h>
> #include <linux/sizes.h>
> -#include <asm/barebox-arm.h>
> -#include <asm/barebox-arm-head.h>
> #include <mach/platform.h>
>
> extern char __dtb_bcm2835_rpi_start[];
> @@ -23,3 +23,13 @@ ENTRY_FUNCTION(start_raspberry_pi2, r0, r1, r2)
>
> barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
> }
> +
> +extern char __dtb_bcm2837_rpi_3_start[];
> +ENTRY_FUNCTION(start_raspberry_pi3, r0, r1, r2)
> +{
> + void *fdt = __dtb_bcm2837_rpi_3_start - get_runtime_offset();
> +
> + arm_cpu_lowlevel_init();
> +
> + barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
> +}
> diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
> index f3aef4290425..cd88b4ac751c 100644
> --- a/arch/arm/configs/rpi_defconfig
> +++ b/arch/arm/configs/rpi_defconfig
> @@ -1,9 +1,11 @@
> CONFIG_ARCH_BCM283X=y
> CONFIG_MACH_RPI=y
> CONFIG_MACH_RPI2=y
> +CONFIG_MACH_RPI3=y
> CONFIG_AEABI=y
> CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
> CONFIG_ARM_UNWIND=y
> +CONFIG_IMAGE_COMPRESSION_NONE=y
> CONFIG_MMU=y
> CONFIG_MALLOC_TLSF=y
> CONFIG_KALLSYMS=y
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 0526a6f40724..0eab313c5011 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -66,6 +66,7 @@ pbl-dtb-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += rk3288-phycore-som.dtb.o
> pbl-dtb-$(CONFIG_MACH_REALQ7) += imx6q-dmo-edmqmx6.dtb.o
> pbl-dtb-$(CONFIG_MACH_RPI) += bcm2835-rpi.dtb.o
> pbl-dtb-$(CONFIG_MACH_RPI2) += bcm2836-rpi-2.dtb.o
> +pbl-dtb-$(CONFIG_MACH_RPI3) += bcm2837-rpi-3.dtb.o
> pbl-dtb-$(CONFIG_MACH_SABRELITE) += imx6q-sabrelite.dtb.o imx6dl-sabrelite.dtb.o
> pbl-dtb-$(CONFIG_MACH_SABRESD) += imx6q-sabresd.dtb.o
> pbl-dtb-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += imx6sx-sdb.dtb.o
> diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts
> new file mode 100644
> index 000000000000..f8c58c570137
> --- /dev/null
> +++ b/arch/arm/dts/bcm2837-rpi-3.dts
> @@ -0,0 +1,15 @@
> +#include <arm64/broadcom/bcm2837-rpi-3-b.dts>
> +
> +/ {
> + chosen {
> + stdout-path = &uart0;
> + };
> +
> + memory {
> + reg = <0x0 0x0>;
> + };
> +};
> +
> +&uart0 {
> + status = "okay";
> +};
> diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
> index 1457f114ccaa..af2f88c47acb 100644
> --- a/arch/arm/mach-bcm283x/Kconfig
> +++ b/arch/arm/mach-bcm283x/Kconfig
> @@ -19,6 +19,12 @@ config MACH_RPI2
> select CPU_V7
> select MACH_RPI_COMMON
>
> +config MACH_RPI3
> + bool "RaspberryPi 3 (BCM2837/CORTEX-A53)"
> + select CPU_V7
> + select MACH_RPI_COMMON
> + select ARM_SECURE_MONITOR
> +
> endmenu
>
> config MACH_RPI_DEBUG_UART_BASE
> diff --git a/arch/arm/mach-bcm283x/core.c b/arch/arm/mach-bcm283x/core.c
> index fddcb0d1a1d4..26f0996b1cb8 100644
> --- a/arch/arm/mach-bcm283x/core.c
> +++ b/arch/arm/mach-bcm283x/core.c
> @@ -41,6 +41,7 @@ static int bcm2835_clk_init(void)
> clk = clk_fixed("uart0-pl0110", 3 * 1000 * 1000);
> clk_register_clkdev(clk, NULL, "uart0-pl0110");
> clk_register_clkdev(clk, NULL, "20201000.serial");
> + clk_register_clkdev(clk, NULL, "3f201000.serial");
>
> clk = clk_fixed("bcm2835-cs", 1 * 1000 * 1000);
> clk_register_clkdev(clk, NULL, "bcm2835-cs");
> diff --git a/images/Makefile.bcm283x b/images/Makefile.bcm283x
> index d59ef043f05c..d14e648926ac 100644
> --- a/images/Makefile.bcm283x
> +++ b/images/Makefile.bcm283x
> @@ -9,3 +9,7 @@ image-$(CONFIG_MACH_RPI) += barebox-raspberry-pi-1.img
> pblx-$(CONFIG_MACH_RPI2) += start_raspberry_pi2
> FILE_barebox-raspberry-pi-2.img = start_raspberry_pi2.pblx
> image-$(CONFIG_MACH_RPI2) += barebox-raspberry-pi-2.img
> +
> +pblx-$(CONFIG_MACH_RPI3) += start_raspberry_pi3
> +FILE_barebox-raspberry-pi-3.img = start_raspberry_pi3.pblx
> +image-$(CONFIG_MACH_RPI3) += barebox-raspberry-pi-3.img
> \ No newline at end of file
> --
> 2.16.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
/"\ ASCII RIBBON | »With the first link, the chain is forged. The first
\ / CAMPAIGN | speech censured, the first thought forbidden, the
X AGAINST | first freedom denied, chains us all irrevocably.«
/ \ HTML MAIL | (Jean-Luc Picard, quoting Judge Aaron Satie)
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 09/10] ARM: rpi: add raspberry pi 3 support
2018-09-16 15:09 ` Alexander Dahl
@ 2018-09-17 10:34 ` Roland Hieber
0 siblings, 0 replies; 19+ messages in thread
From: Roland Hieber @ 2018-09-17 10:34 UTC (permalink / raw)
To: Alexander Dahl, Lucas Stach, barebox
Hi Alex,
Lucas said last week [0] that he needs to find time to polish this
series in order to resubmit it.
[0]: https://www.mail-archive.com/barebox@lists.infradead.org/msg27855.html
- Roland
On Sun, Sep 16, 2018 at 05:09:13PM +0200, Alexander Dahl wrote:
> Hei hei,
>
> this patch series for RPi3 support was not merged yet. What is the
> current status? Would it help if I test it on a raspberry pi 3?
>
> (Background: I have a RPi3 lying around and would like to use
> DistroKit on it.)
>
> Greets
> Alex
>
> On Mon, Mar 26, 2018 at 09:20:24PM +0200, Lucas Stach wrote:
> > This adds basic support at the same feature level as the other
> > supported raspberry pi boards.
> >
> > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > Tested-by: Roland Hieber <r.hieber@pengutronix.de>
> > ---
> > arch/arm/boards/raspberry-pi/lowlevel.c | 14 ++++++++++++--
> > arch/arm/configs/rpi_defconfig | 2 ++
> > arch/arm/dts/Makefile | 1 +
> > arch/arm/dts/bcm2837-rpi-3.dts | 15 +++++++++++++++
> > arch/arm/mach-bcm283x/Kconfig | 6 ++++++
> > arch/arm/mach-bcm283x/core.c | 1 +
> > images/Makefile.bcm283x | 4 ++++
> > 7 files changed, 41 insertions(+), 2 deletions(-)
> > create mode 100644 arch/arm/dts/bcm2837-rpi-3.dts
> >
> > diff --git a/arch/arm/boards/raspberry-pi/lowlevel.c b/arch/arm/boards/raspberry-pi/lowlevel.c
> > index 4e71e29e0c0b..5ca0d3877069 100644
> > --- a/arch/arm/boards/raspberry-pi/lowlevel.c
> > +++ b/arch/arm/boards/raspberry-pi/lowlevel.c
> > @@ -1,7 +1,7 @@
> > +#include <asm/barebox-arm.h>
> > +#include <asm/cache.h>
> > #include <common.h>
> > #include <linux/sizes.h>
> > -#include <asm/barebox-arm.h>
> > -#include <asm/barebox-arm-head.h>
> > #include <mach/platform.h>
> >
> > extern char __dtb_bcm2835_rpi_start[];
> > @@ -23,3 +23,13 @@ ENTRY_FUNCTION(start_raspberry_pi2, r0, r1, r2)
> >
> > barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
> > }
> > +
> > +extern char __dtb_bcm2837_rpi_3_start[];
> > +ENTRY_FUNCTION(start_raspberry_pi3, r0, r1, r2)
> > +{
> > + void *fdt = __dtb_bcm2837_rpi_3_start - get_runtime_offset();
> > +
> > + arm_cpu_lowlevel_init();
> > +
> > + barebox_arm_entry(BCM2835_SDRAM_BASE, SZ_512M, fdt);
> > +}
> > diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
> > index f3aef4290425..cd88b4ac751c 100644
> > --- a/arch/arm/configs/rpi_defconfig
> > +++ b/arch/arm/configs/rpi_defconfig
> > @@ -1,9 +1,11 @@
> > CONFIG_ARCH_BCM283X=y
> > CONFIG_MACH_RPI=y
> > CONFIG_MACH_RPI2=y
> > +CONFIG_MACH_RPI3=y
> > CONFIG_AEABI=y
> > CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
> > CONFIG_ARM_UNWIND=y
> > +CONFIG_IMAGE_COMPRESSION_NONE=y
> > CONFIG_MMU=y
> > CONFIG_MALLOC_TLSF=y
> > CONFIG_KALLSYMS=y
> > diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> > index 0526a6f40724..0eab313c5011 100644
> > --- a/arch/arm/dts/Makefile
> > +++ b/arch/arm/dts/Makefile
> > @@ -66,6 +66,7 @@ pbl-dtb-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += rk3288-phycore-som.dtb.o
> > pbl-dtb-$(CONFIG_MACH_REALQ7) += imx6q-dmo-edmqmx6.dtb.o
> > pbl-dtb-$(CONFIG_MACH_RPI) += bcm2835-rpi.dtb.o
> > pbl-dtb-$(CONFIG_MACH_RPI2) += bcm2836-rpi-2.dtb.o
> > +pbl-dtb-$(CONFIG_MACH_RPI3) += bcm2837-rpi-3.dtb.o
> > pbl-dtb-$(CONFIG_MACH_SABRELITE) += imx6q-sabrelite.dtb.o imx6dl-sabrelite.dtb.o
> > pbl-dtb-$(CONFIG_MACH_SABRESD) += imx6q-sabresd.dtb.o
> > pbl-dtb-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += imx6sx-sdb.dtb.o
> > diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts
> > new file mode 100644
> > index 000000000000..f8c58c570137
> > --- /dev/null
> > +++ b/arch/arm/dts/bcm2837-rpi-3.dts
> > @@ -0,0 +1,15 @@
> > +#include <arm64/broadcom/bcm2837-rpi-3-b.dts>
> > +
> > +/ {
> > + chosen {
> > + stdout-path = &uart0;
> > + };
> > +
> > + memory {
> > + reg = <0x0 0x0>;
> > + };
> > +};
> > +
> > +&uart0 {
> > + status = "okay";
> > +};
> > diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
> > index 1457f114ccaa..af2f88c47acb 100644
> > --- a/arch/arm/mach-bcm283x/Kconfig
> > +++ b/arch/arm/mach-bcm283x/Kconfig
> > @@ -19,6 +19,12 @@ config MACH_RPI2
> > select CPU_V7
> > select MACH_RPI_COMMON
> >
> > +config MACH_RPI3
> > + bool "RaspberryPi 3 (BCM2837/CORTEX-A53)"
> > + select CPU_V7
> > + select MACH_RPI_COMMON
> > + select ARM_SECURE_MONITOR
> > +
> > endmenu
> >
> > config MACH_RPI_DEBUG_UART_BASE
> > diff --git a/arch/arm/mach-bcm283x/core.c b/arch/arm/mach-bcm283x/core.c
> > index fddcb0d1a1d4..26f0996b1cb8 100644
> > --- a/arch/arm/mach-bcm283x/core.c
> > +++ b/arch/arm/mach-bcm283x/core.c
> > @@ -41,6 +41,7 @@ static int bcm2835_clk_init(void)
> > clk = clk_fixed("uart0-pl0110", 3 * 1000 * 1000);
> > clk_register_clkdev(clk, NULL, "uart0-pl0110");
> > clk_register_clkdev(clk, NULL, "20201000.serial");
> > + clk_register_clkdev(clk, NULL, "3f201000.serial");
> >
> > clk = clk_fixed("bcm2835-cs", 1 * 1000 * 1000);
> > clk_register_clkdev(clk, NULL, "bcm2835-cs");
> > diff --git a/images/Makefile.bcm283x b/images/Makefile.bcm283x
> > index d59ef043f05c..d14e648926ac 100644
> > --- a/images/Makefile.bcm283x
> > +++ b/images/Makefile.bcm283x
> > @@ -9,3 +9,7 @@ image-$(CONFIG_MACH_RPI) += barebox-raspberry-pi-1.img
> > pblx-$(CONFIG_MACH_RPI2) += start_raspberry_pi2
> > FILE_barebox-raspberry-pi-2.img = start_raspberry_pi2.pblx
> > image-$(CONFIG_MACH_RPI2) += barebox-raspberry-pi-2.img
> > +
> > +pblx-$(CONFIG_MACH_RPI3) += start_raspberry_pi3
> > +FILE_barebox-raspberry-pi-3.img = start_raspberry_pi3.pblx
> > +image-$(CONFIG_MACH_RPI3) += barebox-raspberry-pi-3.img
> > \ No newline at end of file
> > --
> > 2.16.1
> >
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
>
> --
> /"\ ASCII RIBBON | »With the first link, the chain is forged. The first
> \ / CAMPAIGN | speech censured, the first thought forbidden, the
> X AGAINST | first freedom denied, chains us all irrevocably.«
> / \ HTML MAIL | (Jean-Luc Picard, quoting Judge Aaron Satie)
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
Roland Hieber | r.hieber@pengutronix.de |
Pengutronix e.K. | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 10/10] ARM: rpi: autosize malloc area
2018-03-26 19:20 [PATCH v3 01/10] ARM: import opcode helpers from Linux kernel Lucas Stach
` (7 preceding siblings ...)
2018-03-26 19:20 ` [PATCH v3 09/10] ARM: rpi: add raspberry pi 3 support Lucas Stach
@ 2018-03-26 19:20 ` Lucas Stach
8 siblings, 0 replies; 19+ messages in thread
From: Lucas Stach @ 2018-03-26 19:20 UTC (permalink / raw)
To: barebox
Autosize the malloc area according to the available RAM size.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/configs/rpi_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
index cd88b4ac751c..2bb615849324 100644
--- a/arch/arm/configs/rpi_defconfig
+++ b/arch/arm/configs/rpi_defconfig
@@ -7,6 +7,7 @@ CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
CONFIG_ARM_UNWIND=y
CONFIG_IMAGE_COMPRESSION_NONE=y
CONFIG_MMU=y
+CONFIG_MALLOC_SIZE=0x0
CONFIG_MALLOC_TLSF=y
CONFIG_KALLSYMS=y
CONFIG_PROMPT="R-Pi> "
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread