[U-Boot] [PATCH] armv8: aarch64: Fix the warning about x1-x3 nonzero issue

For 64-bit kernel, there is a warning about x1-x3 nonzero in violation of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com --- arch/arm/cpu/armv8/transition.S | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv8/transition.S b/arch/arm/cpu/armv8/transition.S index adb9f35..06b6664 100644 --- a/arch/arm/cpu/armv8/transition.S +++ b/arch/arm/cpu/armv8/transition.S @@ -26,9 +26,27 @@ ENTRY(armv8_switch_to_el2) * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined. * When running in EL2 now, jump to the * address saved in x3. + * + * For 64-bit kernel, there is a warning about + * x1-x3 nonzero in violation of boot protocol. + * x3 should be reset to zero before jumping to + * the kernel. Use x4 instead of x3 as parameter. */ - br x3 -1: armv8_switch_to_el2_m x3, x4, x5 + mov x4, x3 + mov x3, #0 + br x4 +1: + /* + * For 64-bit kernel, there is a warning about + * x1-x3 nonzero in violation of boot protocol. + * x3 should be reset to zero before jumping to + * the kernel. Use x4, x5, x6 instead of x3, x4, + * x5 as parameters. + */ + mov x5, x4 + mov x4, x3 + mov x3, #0 + armv8_switch_to_el2_m x4, x5, x6 ENDPROC(armv8_switch_to_el2)
ENTRY(armv8_switch_to_el1) @@ -36,9 +54,27 @@ ENTRY(armv8_switch_to_el1) 0: /* x3 is kernel entry point. When running in EL1 * now, jump to the address saved in x3. + * + * For 64-bit kernel, there is a warning about + * x1-x3 nonzero in violation of boot protocol. + * x3 should be reset to zero before jumping to + * the kernel. Use x4 instead of x3 as parameter. + */ + mov x4, x3 + mov x3, #0 + br x4 +1: + /* + * For 64-bit kernel, there is a warning about + * x1-x3 nonzero in violation of boot protocol. + * x3 should be reset to zero before jumping to + * the kernel. Use x4, x5, x6 instead of x3, x4, + * x5 as parameters. */ - br x3 -1: armv8_switch_to_el1_m x3, x4, x5 + mov x5, x4 + mov x4, x3 + mov x3, #0 + armv8_switch_to_el1_m x4, x5, x6 ENDPROC(armv8_switch_to_el1)
WEAK(armv8_el2_to_aarch32)

Am 13.01.2017 um 08:50 schrieb Alison Wang b18965@freescale.com:
For 64-bit kernel, there is a warning about x1-x3 nonzero in violation of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
If x3 is part of the boot protocol, please treat it as function argument rather than hard code it to 0.
Alex
arch/arm/cpu/armv8/transition.S | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv8/transition.S b/arch/arm/cpu/armv8/transition.S index adb9f35..06b6664 100644 --- a/arch/arm/cpu/armv8/transition.S +++ b/arch/arm/cpu/armv8/transition.S @@ -26,9 +26,27 @@ ENTRY(armv8_switch_to_el2) * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined. * When running in EL2 now, jump to the * address saved in x3.
*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
*/* the kernel. Use x4 instead of x3 as parameter.
- br x3
-1: armv8_switch_to_el2_m x3, x4, x5
- mov x4, x3
- mov x3, #0
- br x4
+1:
- /*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4, x5, x6 instead of x3, x4,
* x5 as parameters.
*/
- mov x5, x4
- mov x4, x3
- mov x3, #0
- armv8_switch_to_el2_m x4, x5, x6
ENDPROC(armv8_switch_to_el2)
ENTRY(armv8_switch_to_el1) @@ -36,9 +54,27 @@ ENTRY(armv8_switch_to_el1) 0: /* x3 is kernel entry point. When running in EL1 * now, jump to the address saved in x3.
*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4 instead of x3 as parameter.
*/
- mov x4, x3
- mov x3, #0
- br x4
+1:
- /*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4, x5, x6 instead of x3, x4,
*/* x5 as parameters.
- br x3
-1: armv8_switch_to_el1_m x3, x4, x5
- mov x5, x4
- mov x4, x3
- mov x3, #0
- armv8_switch_to_el1_m x4, x5, x6
ENDPROC(armv8_switch_to_el1)
WEAK(armv8_el2_to_aarch32)
2.1.0.27.g96db324

Am 13.01.2017 um 08:50 schrieb Alison Wang b18965@freescale.com:
For 64-bit kernel, there is a warning about x1-x3 nonzero in
violation
of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
If x3 is part of the boot protocol, please treat it as function argument rather than hard code it to 0.
[Alison Wang] I think x3 need to set to 0. Refer to the codes for the warning in kernel,
if (boot_args[1] || boot_args[2] || boot_args[3]) { pr_err("WARNING: x1-x3 nonzero in violation of boot protocol:\n" "\tx1: %016llx\n\tx2: %016llx\n\tx3: %016llx\n" "This indicates a broken bootloader or old kernel\n", boot_args[1], boot_args[2], boot_args[3]); }
arch/arm/cpu/armv8/transition.S | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv8/transition.S b/arch/arm/cpu/armv8/transition.S index adb9f35..06b6664 100644 --- a/arch/arm/cpu/armv8/transition.S +++ b/arch/arm/cpu/armv8/transition.S @@ -26,9 +26,27 @@ ENTRY(armv8_switch_to_el2) * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined. * When running in EL2 now, jump to the * address saved in x3.
*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
*/* the kernel. Use x4 instead of x3 as parameter.
- br x3
-1: armv8_switch_to_el2_m x3, x4, x5
- mov x4, x3
- mov x3, #0
- br x4
+1:
- /*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4, x5, x6 instead of x3, x4,
* x5 as parameters.
*/
- mov x5, x4
- mov x4, x3
- mov x3, #0
- armv8_switch_to_el2_m x4, x5, x6
ENDPROC(armv8_switch_to_el2)
ENTRY(armv8_switch_to_el1) @@ -36,9 +54,27 @@ ENTRY(armv8_switch_to_el1) 0: /* x3 is kernel entry point. When running in EL1 * now, jump to the address saved in x3.
*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4 instead of x3 as parameter.
*/
- mov x4, x3
- mov x3, #0
- br x4
+1:
- /*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4, x5, x6 instead of x3, x4,
*/* x5 as parameters.
- br x3
-1: armv8_switch_to_el1_m x3, x4, x5
- mov x5, x4
- mov x4, x3
- mov x3, #0
- armv8_switch_to_el1_m x4, x5, x6
ENDPROC(armv8_switch_to_el1)
WEAK(armv8_el2_to_aarch32)
2.1.0.27.g96db324
Best Regards, Alison Wang

On 01/13/2017 09:23 AM, Alison Wang wrote:
Am 13.01.2017 um 08:50 schrieb Alison Wang b18965@freescale.com:
For 64-bit kernel, there is a warning about x1-x3 nonzero in
violation
of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
If x3 is part of the boot protocol, please treat it as function argument rather than hard code it to 0.
[Alison Wang] I think x3 need to set to 0. Refer to the codes for the warning in kernel,
if (boot_args[1] || boot_args[2] || boot_args[3]) { pr_err("WARNING: x1-x3 nonzero in violation of boot protocol:\n" "\tx1: %016llx\n\tx2: %016llx\n\tx3: %016llx\n" "This indicates a broken bootloader or old kernel\n", boot_args[1], boot_args[2], boot_args[3]); }
Yes, that merely means that the kernel doesn't take 3 arguments, it takes 4. Today args[1..3] have to be 0, but I don't want to iron that out in u-boot code.
So in pseudo-code, what we do today is we call
entry(dt_addr, 0, 0);
and instead we should be calling
entry(dt_addr, 0, 0, 0);
So in U-Boot code that means we should change the prototype for our switch function from
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 entry_point, u64 es_flag);
to
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 arg4, u64 entry_point, u64 es_flag);
and adapt the macros accordingly to use x5/x6 instead of x4/5.
Alex

On 01/13/2017 09:23 AM, Alison Wang wrote:
Am 13.01.2017 um 08:50 schrieb Alison Wang b18965@freescale.com:
For 64-bit kernel, there is a warning about x1-x3 nonzero in
violation
of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
If x3 is part of the boot protocol, please treat it as function argument rather than hard code it to 0.
[Alison Wang] I think x3 need to set to 0. Refer to the codes for the warning in kernel,
if (boot_args[1] || boot_args[2] || boot_args[3]) { pr_err("WARNING: x1-x3 nonzero in violation of boot
protocol:\n"
"\tx1: %016llx\n\tx2: %016llx\n\tx3: %016llx\n"
"This indicates a broken bootloader or old
kernel\n",
boot_args[1], boot_args[2], boot_args[3]); }
Yes, that merely means that the kernel doesn't take 3 arguments, it takes 4. Today args[1..3] have to be 0, but I don't want to iron that out in u-boot code.
So in pseudo-code, what we do today is we call
entry(dt_addr, 0, 0);
and instead we should be calling
entry(dt_addr, 0, 0, 0);
So in U-Boot code that means we should change the prototype for our switch function from
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 entry_point, u64 es_flag);
to
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 arg4, u64 entry_point, u64 es_flag);
and adapt the macros accordingly to use x5/x6 instead of x4/5.
[Alison Wang] I understand your meaning. Actually, I thought that method too. Well, my concern is that there are more changes. Not only armv8_switch_to_el2 and armv8_switch_to_el1, all the places calling them need to change too. It may cause more problems. With this concern, I choose a simple way to fix this issue before.
Best Regards, Alison Wang

On 01/13/2017 10:36 AM, Alison Wang wrote:
On 01/13/2017 09:23 AM, Alison Wang wrote:
Am 13.01.2017 um 08:50 schrieb Alison Wang b18965@freescale.com:
For 64-bit kernel, there is a warning about x1-x3 nonzero in
violation
of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
If x3 is part of the boot protocol, please treat it as function argument rather than hard code it to 0.
[Alison Wang] I think x3 need to set to 0. Refer to the codes for the warning in kernel,
if (boot_args[1] || boot_args[2] || boot_args[3]) { pr_err("WARNING: x1-x3 nonzero in violation of boot
protocol:\n" "\tx1: %016llx\n\tx2: %016llx\n\tx3: %016llx\n"
"This indicates a broken bootloader or old
kernel\n",
boot_args[1], boot_args[2], boot_args[3]); }
Yes, that merely means that the kernel doesn't take 3 arguments, it takes 4. Today args[1..3] have to be 0, but I don't want to iron that out in u-boot code.
So in pseudo-code, what we do today is we call
entry(dt_addr, 0, 0);
and instead we should be calling
entry(dt_addr, 0, 0, 0);
So in U-Boot code that means we should change the prototype for our switch function from
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 entry_point, u64 es_flag);
to
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 arg4, u64 entry_point, u64 es_flag);
and adapt the macros accordingly to use x5/x6 instead of x4/5.
[Alison Wang] I understand your meaning. Actually, I thought that method too. Well, my concern is that there are more changes. Not only armv8_switch_to_el2 and armv8_switch_to_el1, all the places calling them need to change too. It may cause more problems. With this concern, I choose a simple way to fix this issue before.
I think there'll be enough people testing Linux boot :), let's try to fix it properly right away.
Alex

On 01/13/2017 10:36 AM, Alison Wang wrote:
On 01/13/2017 09:23 AM, Alison Wang wrote:
Am 13.01.2017 um 08:50 schrieb Alison Wang b18965@freescale.com:
For 64-bit kernel, there is a warning about x1-x3 nonzero in
violation
of boot protocol. x3 should be reset to zero before jumping to
the
kernel.
This patch will adjust the parameters to transfer and make sure
x3
is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
If x3 is part of the boot protocol, please treat it as function argument rather than hard code it to 0.
[Alison Wang] I think x3 need to set to 0. Refer to the codes for the warning in kernel,
if (boot_args[1] || boot_args[2] || boot_args[3]) { pr_err("WARNING: x1-x3 nonzero in violation of
boot
protocol:\n" "\tx1: %016llx\n\tx2: %016llx\n\tx3: %016llx\n"
"This indicates a broken bootloader or
old
kernel\n",
boot_args[1], boot_args[2], boot_args[3]); }
Yes, that merely means that the kernel doesn't take 3 arguments, it takes 4. Today args[1..3] have to be 0, but I don't want to iron
that
out in u-boot code.
So in pseudo-code, what we do today is we call
entry(dt_addr, 0, 0);
and instead we should be calling
entry(dt_addr, 0, 0, 0);
So in U-Boot code that means we should change the prototype for our switch function from
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 entry_point, u64 es_flag);
to
void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr, u64 arg4, u64 entry_point, u64 es_flag);
and adapt the macros accordingly to use x5/x6 instead of x4/5.
[Alison Wang] I understand your meaning. Actually, I thought that
method too. Well, my concern is that there are more changes. Not only armv8_switch_to_el2 and armv8_switch_to_el1, all the places calling them need to change too. It may cause more problems. With this concern, I choose a simple way to fix this issue before.
I think there'll be enough people testing Linux boot :), let's try to fix it properly right away.
[Alison Wang] Ok, I will send v2 patch. Please help to review.
Thanks.
Best Regards, Alison Wang

Hi, Ryan,
This patch is to fix the issue about a warning for ARMv8 64-bit kernel you reported before. I have tested on my LayerScape boards. Please review and try on your boards too.
Thanks.
Best Regards, Alison Wang
-----Original Message----- From: Alison Wang [mailto:b18965@freescale.com] Sent: Friday, January 13, 2017 3:50 PM To: york sun york.sun@nxp.com; ryan.harkin@linaro.org; agraf@suse.de; Scott Wood scott.wood@nxp.com; Stuart Yoder stuart.yoder@nxp.com; Leo Li leoyang.li@nxp.com; fenghua@phytium.com.cn; linus.walleij@linaro.org; u-boot@lists.denx.de Cc: Jason Jin jason.jin@nxp.com; Alison Wang alison.wang@nxp.com Subject: [PATCH] armv8: aarch64: Fix the warning about x1-x3 nonzero issue
For 64-bit kernel, there is a warning about x1-x3 nonzero in violation of boot protocol. x3 should be reset to zero before jumping to the kernel.
This patch will adjust the parameters to transfer and make sure x3 is zero.
Signed-off-by: Alison Wang alison.wang@nxp.com
arch/arm/cpu/armv8/transition.S | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv8/transition.S b/arch/arm/cpu/armv8/transition.S index adb9f35..06b6664 100644 --- a/arch/arm/cpu/armv8/transition.S +++ b/arch/arm/cpu/armv8/transition.S @@ -26,9 +26,27 @@ ENTRY(armv8_switch_to_el2) * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined. * When running in EL2 now, jump to the * address saved in x3.
*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
*/* the kernel. Use x4 instead of x3 as parameter.
- br x3
-1: armv8_switch_to_el2_m x3, x4, x5
- mov x4, x3
- mov x3, #0
- br x4
+1:
- /*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4, x5, x6 instead of x3, x4,
* x5 as parameters.
*/
- mov x5, x4
- mov x4, x3
- mov x3, #0
- armv8_switch_to_el2_m x4, x5, x6
ENDPROC(armv8_switch_to_el2)
ENTRY(armv8_switch_to_el1) @@ -36,9 +54,27 @@ ENTRY(armv8_switch_to_el1) 0: /* x3 is kernel entry point. When running in EL1 * now, jump to the address saved in x3.
*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4 instead of x3 as parameter.
*/
- mov x4, x3
- mov x3, #0
- br x4
+1:
- /*
* For 64-bit kernel, there is a warning about
* x1-x3 nonzero in violation of boot protocol.
* x3 should be reset to zero before jumping to
* the kernel. Use x4, x5, x6 instead of x3, x4,
*/* x5 as parameters.
- br x3
-1: armv8_switch_to_el1_m x3, x4, x5
- mov x5, x4
- mov x4, x3
- mov x3, #0
- armv8_switch_to_el1_m x4, x5, x6
ENDPROC(armv8_switch_to_el1)
WEAK(armv8_el2_to_aarch32)
2.1.0.27.g96db324
participants (3)
-
Alexander Graf
-
Alison Wang
-
Alison Wang