Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2017-01-12 Thread Alison Wang
Hi, Ryan,

Thanks for your feedback. I will do some investigation and give you my 
solution.


Best Regards,
Alison Wang

> -Original Message-
> From: Ryan Harkin [mailto:ryan.har...@linaro.org]
> Sent: Wednesday, January 11, 2017 4:59 PM
> To: Alison Wang 
> Cc: york sun ; Alexander Graf ; Scott
> Wood ; Stuart Yoder ; Leo Li
> ; David Feng ; Michal Simek
> ; thomas...@samsung.com; mk7.k...@samsung.com; U-Boot
> ML ; Alison Wang ; Jason Jin
> ; Jon Medhurst (Tixy) 
> Subject: Re: [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32
> execution state
> 
> Hi Alison,
> 
> I wasn't sure where about in this thread to reply to this patch, so I
> thought here was as good as any...
> 
> I know I tested this commit and it works for me. However, my colleague
> Tixy has spotted a recent warning on the kernel dmesg output that only
> arrived with an update to u-boot:
> 
> [0.00] WARNING: x1-x3 nonzero in violation of boot protocol:
> [0.00] x1: 
> [0.00] x2: 
> [0.00] x3: 8008
> [0.00] This indicates a broken bootloader or old kernel
> 
> This happens on our ARM64 kernels, both the 4.4 based kernel and the
> 4.9.0 based kernel. They boot, it's with the extra warning.
> 
> I bisected it down to the change in this email thread, upstream as
> commit ec6617c39741adc6c54952564579e32c3c09c66f in the master repo.
> 
> And I can see below in many places that the code is using x3 for the
> first time. I'm not sure which one is causing the warning in the kernel,
> but I guess we need to reset x3 to zero before jumping to the kernel?
> 
> I'm happy to test any fixes if you wish to send them to me.
> 
> Thanks,
> Ryan.
> 
> 
> 
> On 10 November 2016 at 02:49, Alison Wang  wrote:
> > To support loading a 32-bit OS, the execution state will change from
> > AArch64 to AArch32 when jumping to kernel.
> >
> > The architecture information will be got through checking FIT image,
> > then U-Boot will load 32-bit OS or 64-bit OS automatically.
> >
> > Signed-off-by: Ebony Zhu 
> > Signed-off-by: Alison Wang 
> > Signed-off-by: Chenhui Zhao 
> > ---
> > Changes in v8:
> > - Fix the issue when U-Boot is running in EL2 or EL1.
> >
> > Changes in v7:
> > - Move the call for armv8_switch_to_el2_m into this patch.
> >
> > Changes in v6:
> > - Modified armv8_switch_to_el1(). It will always jump to ep when
> switching to AArch64 or AArch32 modes.
> > - Make other platforms compatible with the new armv8_switch_to_el2()
> and armv8_switch_to_el1().
> >
> > Changes in v5:
> > - Modified armv8_switch_to_el2(). It will always jump to ep when
> switching to AArch64 or AArch32 modes.
> >
> > Changes in v4:
> > - Correct config ARM64_SUPPORT_AARCH32.
> > - Omit arch and ftaddr arguments.
> > - Rename "xreg5" to "tmp".
> > - Use xxx_RES1 to combine all RES1 fields in xxx register.
> > - Use an immediate cmp directly.
> > - Use #ifdef for CONFIG_ARM64_SUPPORT_AARCH32.
> >
> > Changes in v3:
> > - Comments the functions and the arguments.
> > - Rename the real parameters.
> > - Use the macros instead of the magic values.
> > - Remove the redundant codes.
> > - Clean up all of the mess in boot_jump_linux().
> > - Add CONFIG_ARM64_SUPPORT_AARCH32 to detect for some ARM64 system
> doesn't support AArch32 state.
> >
> > Changes in v2:
> > - armv8_switch_to_el2_aarch32() is removed. armv8_switch_to_el2_m is
> used
> >   to switch to AArch64 EL2 or AArch32 Hyp.
> > - armv8_switch_to_el1_aarch32() is removed. armv8_switch_to_el1_m is
> used
> >   to switch to AArch64 EL1 or AArch32 SVC.
> >
> >  arch/arm/Kconfig  |   6 +
> >  arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S  |  61 +++--
> >  arch/arm/cpu/armv8/start.S|   8 ++
> >  arch/arm/cpu/armv8/transition.S   |  23 +++-
> >  arch/arm/include/asm/arch-fsl-layerscape/mp.h |   4 +
> >  arch/arm/include/asm/macro.h  | 176
> +++---
> >  arch/arm/include/asm/system.h | 119
> -
> >  arch/arm/lib/bootm.c  |  39 +-
> >  arch/arm/mach-rmobile/lowlevel_init_gen3.S|   9 +-
> >  common/image-fit.c|  19 ++-
> >  10 files changed, 396 insertions(+), 68 deletions(-)
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index
> > d7a9b11..18c23c0 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -126,6 +126,12 @@ config ENABLE_ARM_SOC_BOOT0_HOOK
> >   ARM_SOC_BOOT0_HOOK which contains the required assembler
> >   preprocessor code.
> >
> > +config ARM64_SUPPORT_AARCH32
> > +   bool "ARM64 system support AArch32 execution state"
> > +   default y if ARM64 && !TARGET_THUNDERX_88XX
> > +   help
> > + This ARM64 system supports AArch32 execution state.
> > +
> >  choice
> > prompt "Target select"
> > default TARGET_HIKEY
> > diff --git a/arch/arm/cpu/armv8

Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2017-01-11 Thread Ryan Harkin
Hi Alison,

I wasn't sure where about in this thread to reply to this patch, so I
thought here was as good as any...

I know I tested this commit and it works for me. However, my colleague
Tixy has spotted a recent warning on the kernel dmesg output that only
arrived with an update to u-boot:

[0.00] WARNING: x1-x3 nonzero in violation of boot protocol:
[0.00] x1: 
[0.00] x2: 
[0.00] x3: 8008
[0.00] This indicates a broken bootloader or old kernel

This happens on our ARM64 kernels, both the 4.4 based kernel and the
4.9.0 based kernel. They boot, it's with the extra warning.

I bisected it down to the change in this email thread, upstream as
commit ec6617c39741adc6c54952564579e32c3c09c66f in the master repo.

And I can see below in many places that the code is using x3 for the
first time. I'm not sure which one is causing the warning in the
kernel, but I guess we need to reset x3 to zero before jumping to the
kernel?

I'm happy to test any fixes if you wish to send them to me.

Thanks,
Ryan.



On 10 November 2016 at 02:49, Alison Wang  wrote:
> To support loading a 32-bit OS, the execution state will change from
> AArch64 to AArch32 when jumping to kernel.
>
> The architecture information will be got through checking FIT image,
> then U-Boot will load 32-bit OS or 64-bit OS automatically.
>
> Signed-off-by: Ebony Zhu 
> Signed-off-by: Alison Wang 
> Signed-off-by: Chenhui Zhao 
> ---
> Changes in v8:
> - Fix the issue when U-Boot is running in EL2 or EL1.
>
> Changes in v7:
> - Move the call for armv8_switch_to_el2_m into this patch.
>
> Changes in v6:
> - Modified armv8_switch_to_el1(). It will always jump to ep when switching to 
> AArch64 or AArch32 modes.
> - Make other platforms compatible with the new armv8_switch_to_el2() and 
> armv8_switch_to_el1().
>
> Changes in v5:
> - Modified armv8_switch_to_el2(). It will always jump to ep when switching to 
> AArch64 or AArch32 modes.
>
> Changes in v4:
> - Correct config ARM64_SUPPORT_AARCH32.
> - Omit arch and ftaddr arguments.
> - Rename "xreg5" to "tmp".
> - Use xxx_RES1 to combine all RES1 fields in xxx register.
> - Use an immediate cmp directly.
> - Use #ifdef for CONFIG_ARM64_SUPPORT_AARCH32.
>
> Changes in v3:
> - Comments the functions and the arguments.
> - Rename the real parameters.
> - Use the macros instead of the magic values.
> - Remove the redundant codes.
> - Clean up all of the mess in boot_jump_linux().
> - Add CONFIG_ARM64_SUPPORT_AARCH32 to detect for some ARM64 system doesn't 
> support AArch32 state.
>
> Changes in v2:
> - armv8_switch_to_el2_aarch32() is removed. armv8_switch_to_el2_m is used
>   to switch to AArch64 EL2 or AArch32 Hyp.
> - armv8_switch_to_el1_aarch32() is removed. armv8_switch_to_el1_m is used
>   to switch to AArch64 EL1 or AArch32 SVC.
>
>  arch/arm/Kconfig  |   6 +
>  arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S  |  61 +++--
>  arch/arm/cpu/armv8/start.S|   8 ++
>  arch/arm/cpu/armv8/transition.S   |  23 +++-
>  arch/arm/include/asm/arch-fsl-layerscape/mp.h |   4 +
>  arch/arm/include/asm/macro.h  | 176 
> +++---
>  arch/arm/include/asm/system.h | 119 -
>  arch/arm/lib/bootm.c  |  39 +-
>  arch/arm/mach-rmobile/lowlevel_init_gen3.S|   9 +-
>  common/image-fit.c|  19 ++-
>  10 files changed, 396 insertions(+), 68 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index d7a9b11..18c23c0 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -126,6 +126,12 @@ config ENABLE_ARM_SOC_BOOT0_HOOK
>   ARM_SOC_BOOT0_HOOK which contains the required assembler
>   preprocessor code.
>
> +config ARM64_SUPPORT_AARCH32
> +   bool "ARM64 system support AArch32 execution state"
> +   default y if ARM64 && !TARGET_THUNDERX_88XX
> +   help
> + This ARM64 system supports AArch32 execution state.
> +
>  choice
> prompt "Target select"
> default TARGET_HIKEY
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S 
> b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
> index 5700b1f..8e6ad4b 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
> @@ -13,6 +13,7 @@
>  #ifdef CONFIG_MP
>  #include 
>  #endif
> +#include 
>
>  ENTRY(lowlevel_init)
> mov x29, lr /* Save LR */
> @@ -339,11 +340,6 @@ ENTRY(secondary_boot_func)
>  gic_wait_for_interrupt_m x0, w1
>  #endif
>
> -   bl secondary_switch_to_el2
> -#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
> -   bl secondary_switch_to_el1
> -#endif
> -
>  slave_cpu:
> wfe
> ldr x0, [x11]
> @@ -356,19 +352,64 @@ slave_cpu:
> tbz x1, #25, cpu_is_le
> rev x0, x0  /* BE to LE conversion */

Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-22 Thread york sun
On 11/22/2016 09:32 AM, Alexander Graf wrote:
> On 11/21/2016 10:48 PM, york sun wrote:
>> Alex,
>>
>> Since you are most familiar with EFI boot code, can you send a patch to
>> address this? I can squash it with Alison's patch after testing. My
>> current test branch is
>> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit.denx.de%2F%3Fp%3Du-boot%2Fu-boot-fsl-qoriq.git%3Ba%3Dshortlog%3Bh%3Drefs%2Fheads%2Ftest_qoriq&data=01%7C01%7Cyork.sun%40nxp.com%7C822c0a7505844c4f759408d412fd7f66%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=4OCWr5ZP%2B1ufIO%2FgZo69qgfMW%2F3YUb5ibJvOhhOOlEI%3D&reserved=0.
>
> Ok, you should have a patch now :). I was still able to boot SLES with it.
>

Great! Thanks.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-22 Thread Alexander Graf

On 11/21/2016 10:48 PM, york sun wrote:

Alex,

Since you are most familiar with EFI boot code, can you send a patch to
address this? I can squash it with Alison's patch after testing. My
current test branch is
http://git.denx.de/?p=u-boot/u-boot-fsl-qoriq.git;a=shortlog;h=refs/heads/test_qoriq.


Ok, you should have a patch now :). I was still able to boot SLES with it.


Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-22 Thread Alexander Graf

On 11/22/2016 06:07 PM, york sun wrote:

On 11/22/2016 09:02 AM, Alexander Graf wrote:

On 11/21/2016 10:48 PM, york sun wrote:

On 11/21/2016 01:07 PM, Alexander Graf wrote:

On 21/11/2016 21:45, york sun wrote:

On 11/21/2016 12:40 PM, Alexander Graf wrote:

On 21/11/2016 21:23, york sun wrote:

On 11/09/2016 07:02 PM, Alison Wang wrote:

To support loading a 32-bit OS, the execution state will change from
AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image,
then U-Boot will load 32-bit OS or 64-bit OS automatically.

Signed-off-by: Ebony Zhu 
Signed-off-by: Alison Wang 
Signed-off-by: Chenhui Zhao 
---
Changes in v8:
- Fix the issue when U-Boot is running in EL2 or EL1.


Alison,

There is a conflict when merging with upstream code. Alex Graf merged
his change to support EFI booting. See commit
69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines


   if (current_el() == 3) {
   smp_kick_all_cpus();
   dcache_disable();
   armv8_switch_to_el2();
   dcache_enable();
   }

Function armv8_switch_to_el2() didn't take any argument before you
change. With your proposed change to support 32-bit OS, you added
arguments to this function, and presume this function always load OS.
This may be flawed. Would it be possible to keep armv8_switch_to_el2()
but introduce another function to carry out switching EL while loading OS?

Alison introduced it based on my comments - and I'd prefer if we only
have the function call based version :).

It should be reasonably straight forward to move to it here. Just create
a new helper stub that enables the dcache and calls entry().


Alex,

Do you always load OS when calling armv8_switch_to_el2()? In this case
of efi booting, kernel entry point needs to be passed to the new
armv8_switch_to_el2 function. The new armv8_switch_to_el2 function
doesn't return, so you cannot continue to run the code.

We always call some random function pointer in the new flow. That can be
a kernel entry point, but it can also just be a function pointer. In
this case, the code would basically look like this:

static ulong efi_run_in_el2(ulong (*entry), void *arg1, void *arg2)
{
   dcache_enable();
   return entry(arg1, arg2);
}

if (current_el() == 3) {
   ...
   return armv8_switch_to_el2(efi_run_in_el2, entry,
&loaded_image_info, &systab);
}


Alex,

Since you are most familiar with EFI boot code, can you send a patch to
address this? I can squash it with Alison's patch after testing. My
current test branch is
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit.denx.de%2F%3Fp%3Du-boot%2Fu-boot-fsl-qoriq.git%3Ba%3Dshortlog%3Bh%3Drefs%2Fheads%2Ftest_qoriq&data=01%7C01%7Cyork.sun%40nxp.com%7C0b9b6fdb53c94e1a953d08d412f9502f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=ALW8GdHxkPJghve%2BxbKQ1E9ssjFxSOf35PvVuY34ZiA%3D&reserved=0.

While trying to fix this up, I ran across another compile breakage:

arch/arm/cpu/armv8/fsl-layerscape/mp.c:114: undefined reference to
`initiator_type'
arch/arm/cpu/armv8/fsl-layerscape/mp.c:123: undefined reference to
`initiator_type'


Possibly cause by a new set of patches sent by Priyanka for LS2088A.
Let's use upstream master branch plus Alison's three patches.


No worries, the patch below fixes it. Just wanted to let you know.

Alex


diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c

index 59b0870..d6ee546 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -191,7 +191,7 @@ void enable_caches(void)
 }
 #endif

-inline u32 initiator_type(u32 cluster, int init_id)
+u32 initiator_type(u32 cluster, int init_id)
 {
struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
u32 idx = (cluster >> (init_id * 8)) & TP_CLUSTER_INIT_MASK;

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-22 Thread york sun
On 11/22/2016 09:02 AM, Alexander Graf wrote:
> On 11/21/2016 10:48 PM, york sun wrote:
>> On 11/21/2016 01:07 PM, Alexander Graf wrote:
>>>
>>> On 21/11/2016 21:45, york sun wrote:
 On 11/21/2016 12:40 PM, Alexander Graf wrote:
>
> On 21/11/2016 21:23, york sun wrote:
>> On 11/09/2016 07:02 PM, Alison Wang wrote:
>>> To support loading a 32-bit OS, the execution state will change from
>>> AArch64 to AArch32 when jumping to kernel.
>>>
>>> The architecture information will be got through checking FIT image,
>>> then U-Boot will load 32-bit OS or 64-bit OS automatically.
>>>
>>> Signed-off-by: Ebony Zhu 
>>> Signed-off-by: Alison Wang 
>>> Signed-off-by: Chenhui Zhao 
>>> ---
>>> Changes in v8:
>>> - Fix the issue when U-Boot is running in EL2 or EL1.
>>>
>> Alison,
>>
>> There is a conflict when merging with upstream code. Alex Graf merged
>> his change to support EFI booting. See commit
>> 69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines
>>
>>
>>   if (current_el() == 3) {
>>   smp_kick_all_cpus();
>>   dcache_disable();
>>   armv8_switch_to_el2();
>>   dcache_enable();
>>   }
>>
>> Function armv8_switch_to_el2() didn't take any argument before you
>> change. With your proposed change to support 32-bit OS, you added
>> arguments to this function, and presume this function always load OS.
>> This may be flawed. Would it be possible to keep armv8_switch_to_el2()
>> but introduce another function to carry out switching EL while loading 
>> OS?
> Alison introduced it based on my comments - and I'd prefer if we only
> have the function call based version :).
>
> It should be reasonably straight forward to move to it here. Just create
> a new helper stub that enables the dcache and calls entry().
>
 Alex,

 Do you always load OS when calling armv8_switch_to_el2()? In this case
 of efi booting, kernel entry point needs to be passed to the new
 armv8_switch_to_el2 function. The new armv8_switch_to_el2 function
 doesn't return, so you cannot continue to run the code.
>>> We always call some random function pointer in the new flow. That can be
>>> a kernel entry point, but it can also just be a function pointer. In
>>> this case, the code would basically look like this:
>>>
>>> static ulong efi_run_in_el2(ulong (*entry), void *arg1, void *arg2)
>>> {
>>>   dcache_enable();
>>>   return entry(arg1, arg2);
>>> }
>>>
>>> if (current_el() == 3) {
>>>   ...
>>>   return armv8_switch_to_el2(efi_run_in_el2, entry,
>>> &loaded_image_info, &systab);
>>> }
>>>
>> Alex,
>>
>> Since you are most familiar with EFI boot code, can you send a patch to
>> address this? I can squash it with Alison's patch after testing. My
>> current test branch is
>> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit.denx.de%2F%3Fp%3Du-boot%2Fu-boot-fsl-qoriq.git%3Ba%3Dshortlog%3Bh%3Drefs%2Fheads%2Ftest_qoriq&data=01%7C01%7Cyork.sun%40nxp.com%7C0b9b6fdb53c94e1a953d08d412f9502f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=ALW8GdHxkPJghve%2BxbKQ1E9ssjFxSOf35PvVuY34ZiA%3D&reserved=0.
>
> While trying to fix this up, I ran across another compile breakage:
>
> arch/arm/cpu/armv8/fsl-layerscape/mp.c:114: undefined reference to
> `initiator_type'
> arch/arm/cpu/armv8/fsl-layerscape/mp.c:123: undefined reference to
> `initiator_type'
>

Possibly cause by a new set of patches sent by Priyanka for LS2088A. 
Let's use upstream master branch plus Alison's three patches.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-22 Thread Alexander Graf

On 11/21/2016 10:48 PM, york sun wrote:

On 11/21/2016 01:07 PM, Alexander Graf wrote:


On 21/11/2016 21:45, york sun wrote:

On 11/21/2016 12:40 PM, Alexander Graf wrote:


On 21/11/2016 21:23, york sun wrote:

On 11/09/2016 07:02 PM, Alison Wang wrote:

To support loading a 32-bit OS, the execution state will change from
AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image,
then U-Boot will load 32-bit OS or 64-bit OS automatically.

Signed-off-by: Ebony Zhu 
Signed-off-by: Alison Wang 
Signed-off-by: Chenhui Zhao 
---
Changes in v8:
- Fix the issue when U-Boot is running in EL2 or EL1.


Alison,

There is a conflict when merging with upstream code. Alex Graf merged
his change to support EFI booting. See commit
69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines


  if (current_el() == 3) {
  smp_kick_all_cpus();
  dcache_disable();
  armv8_switch_to_el2();
  dcache_enable();
  }

Function armv8_switch_to_el2() didn't take any argument before you
change. With your proposed change to support 32-bit OS, you added
arguments to this function, and presume this function always load OS.
This may be flawed. Would it be possible to keep armv8_switch_to_el2()
but introduce another function to carry out switching EL while loading OS?

Alison introduced it based on my comments - and I'd prefer if we only
have the function call based version :).

It should be reasonably straight forward to move to it here. Just create
a new helper stub that enables the dcache and calls entry().


Alex,

Do you always load OS when calling armv8_switch_to_el2()? In this case
of efi booting, kernel entry point needs to be passed to the new
armv8_switch_to_el2 function. The new armv8_switch_to_el2 function
doesn't return, so you cannot continue to run the code.

We always call some random function pointer in the new flow. That can be
a kernel entry point, but it can also just be a function pointer. In
this case, the code would basically look like this:

static ulong efi_run_in_el2(ulong (*entry), void *arg1, void *arg2)
{
  dcache_enable();
  return entry(arg1, arg2);
}

if (current_el() == 3) {
  ...
  return armv8_switch_to_el2(efi_run_in_el2, entry,
&loaded_image_info, &systab);
}


Alex,

Since you are most familiar with EFI boot code, can you send a patch to
address this? I can squash it with Alison's patch after testing. My
current test branch is
http://git.denx.de/?p=u-boot/u-boot-fsl-qoriq.git;a=shortlog;h=refs/heads/test_qoriq.


While trying to fix this up, I ran across another compile breakage:

arch/arm/cpu/armv8/fsl-layerscape/mp.c:114: undefined reference to 
`initiator_type'
arch/arm/cpu/armv8/fsl-layerscape/mp.c:123: undefined reference to 
`initiator_type'



Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-21 Thread Alison Wang
Hi, Alex,

> On 11/21/2016 01:07 PM, Alexander Graf wrote:
> >
> >
> > On 21/11/2016 21:45, york sun wrote:
> >> On 11/21/2016 12:40 PM, Alexander Graf wrote:
> >>>
> >>>
> >>> On 21/11/2016 21:23, york sun wrote:
>  On 11/09/2016 07:02 PM, Alison Wang wrote:
> > To support loading a 32-bit OS, the execution state will change
> > from
> > AArch64 to AArch32 when jumping to kernel.
> >
> > The architecture information will be got through checking FIT
> > image, then U-Boot will load 32-bit OS or 64-bit OS automatically.
> >
> > Signed-off-by: Ebony Zhu 
> > Signed-off-by: Alison Wang 
> > Signed-off-by: Chenhui Zhao 
> > ---
> > Changes in v8:
> > - Fix the issue when U-Boot is running in EL2 or EL1.
> >
> 
>  Alison,
> 
>  There is a conflict when merging with upstream code. Alex Graf
>  merged his change to support EFI booting. See commit
>  69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines
> 
> 
>   if (current_el() == 3) {
>   smp_kick_all_cpus();
>   dcache_disable();
>   armv8_switch_to_el2();
>   dcache_enable();
>   }
> 
>  Function armv8_switch_to_el2() didn't take any argument before you
>  change. With your proposed change to support 32-bit OS, you added
>  arguments to this function, and presume this function always load
> OS.
>  This may be flawed. Would it be possible to keep
>  armv8_switch_to_el2() but introduce another function to carry out
> switching EL while loading OS?
> >>>
> >>> Alison introduced it based on my comments - and I'd prefer if we
> >>> only have the function call based version :).
> >>>
> >>> It should be reasonably straight forward to move to it here. Just
> >>> create a new helper stub that enables the dcache and calls entry().
> >>>
> >>
> >> Alex,
> >>
> >> Do you always load OS when calling armv8_switch_to_el2()? In this
> >> case of efi booting, kernel entry point needs to be passed to the
> new
> >> armv8_switch_to_el2 function. The new armv8_switch_to_el2 function
> >> doesn't return, so you cannot continue to run the code.
> >
> > We always call some random function pointer in the new flow. That can
> > be a kernel entry point, but it can also just be a function pointer.
> > In this case, the code would basically look like this:
> >
> > static ulong efi_run_in_el2(ulong (*entry), void *arg1, void *arg2) {
> >  dcache_enable();
> >  return entry(arg1, arg2);
> > }
> >
> > if (current_el() == 3) {
> >  ...
> >  return armv8_switch_to_el2(efi_run_in_el2, entry,
> > &loaded_image_info, &systab); }
> >
> 
> Alex,
> 
> Since you are most familiar with EFI boot code, can you send a patch to
> address this? I can squash it with Alison's patch after testing. My
> current test branch is
> http://git.denx.de/?p=u-boot/u-boot-fsl-
> qoriq.git;a=shortlog;h=refs/heads/test_qoriq.
> 
> 
[Alison Wang] Please send a patch to fix this issue. It blocks our efforts for
the patch set armv8: Support loading 32-bit OS in AArch32 execution state.

Thanks.


Best Regards,
Alison Wang
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-21 Thread york sun
On 11/21/2016 01:07 PM, Alexander Graf wrote:
>
>
> On 21/11/2016 21:45, york sun wrote:
>> On 11/21/2016 12:40 PM, Alexander Graf wrote:
>>>
>>>
>>> On 21/11/2016 21:23, york sun wrote:
 On 11/09/2016 07:02 PM, Alison Wang wrote:
> To support loading a 32-bit OS, the execution state will change from
> AArch64 to AArch32 when jumping to kernel.
>
> The architecture information will be got through checking FIT image,
> then U-Boot will load 32-bit OS or 64-bit OS automatically.
>
> Signed-off-by: Ebony Zhu 
> Signed-off-by: Alison Wang 
> Signed-off-by: Chenhui Zhao 
> ---
> Changes in v8:
> - Fix the issue when U-Boot is running in EL2 or EL1.
>

 Alison,

 There is a conflict when merging with upstream code. Alex Graf merged
 his change to support EFI booting. See commit
 69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines


  if (current_el() == 3) {
  smp_kick_all_cpus();
  dcache_disable();
  armv8_switch_to_el2();
  dcache_enable();
  }

 Function armv8_switch_to_el2() didn't take any argument before you
 change. With your proposed change to support 32-bit OS, you added
 arguments to this function, and presume this function always load OS.
 This may be flawed. Would it be possible to keep armv8_switch_to_el2()
 but introduce another function to carry out switching EL while loading OS?
>>>
>>> Alison introduced it based on my comments - and I'd prefer if we only
>>> have the function call based version :).
>>>
>>> It should be reasonably straight forward to move to it here. Just create
>>> a new helper stub that enables the dcache and calls entry().
>>>
>>
>> Alex,
>>
>> Do you always load OS when calling armv8_switch_to_el2()? In this case
>> of efi booting, kernel entry point needs to be passed to the new
>> armv8_switch_to_el2 function. The new armv8_switch_to_el2 function
>> doesn't return, so you cannot continue to run the code.
>
> We always call some random function pointer in the new flow. That can be
> a kernel entry point, but it can also just be a function pointer. In
> this case, the code would basically look like this:
>
> static ulong efi_run_in_el2(ulong (*entry), void *arg1, void *arg2)
> {
>  dcache_enable();
>  return entry(arg1, arg2);
> }
>
> if (current_el() == 3) {
>  ...
>  return armv8_switch_to_el2(efi_run_in_el2, entry,
> &loaded_image_info, &systab);
> }
>

Alex,

Since you are most familiar with EFI boot code, can you send a patch to 
address this? I can squash it with Alison's patch after testing. My 
current test branch is 
http://git.denx.de/?p=u-boot/u-boot-fsl-qoriq.git;a=shortlog;h=refs/heads/test_qoriq.

Thanks.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-21 Thread york sun
On 11/09/2016 07:02 PM, Alison Wang wrote:
> To support loading a 32-bit OS, the execution state will change from
> AArch64 to AArch32 when jumping to kernel.
>
> The architecture information will be got through checking FIT image,
> then U-Boot will load 32-bit OS or 64-bit OS automatically.
>
> Signed-off-by: Ebony Zhu 
> Signed-off-by: Alison Wang 
> Signed-off-by: Chenhui Zhao 
> ---
> Changes in v8:
> - Fix the issue when U-Boot is running in EL2 or EL1.
>

Alison,

There is a conflict when merging with upstream code. Alex Graf merged 
his change to support EFI booting. See commit 
69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines


 if (current_el() == 3) {
 smp_kick_all_cpus();
 dcache_disable();
 armv8_switch_to_el2();
 dcache_enable();
 }

Function armv8_switch_to_el2() didn't take any argument before you 
change. With your proposed change to support 32-bit OS, you added 
arguments to this function, and presume this function always load OS. 
This may be flawed. Would it be possible to keep armv8_switch_to_el2() 
but introduce another function to carry out switching EL while loading OS?

York
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-21 Thread Alexander Graf



On 21/11/2016 21:45, york sun wrote:

On 11/21/2016 12:40 PM, Alexander Graf wrote:



On 21/11/2016 21:23, york sun wrote:

On 11/09/2016 07:02 PM, Alison Wang wrote:

To support loading a 32-bit OS, the execution state will change from
AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image,
then U-Boot will load 32-bit OS or 64-bit OS automatically.

Signed-off-by: Ebony Zhu 
Signed-off-by: Alison Wang 
Signed-off-by: Chenhui Zhao 
---
Changes in v8:
- Fix the issue when U-Boot is running in EL2 or EL1.



Alison,

There is a conflict when merging with upstream code. Alex Graf merged
his change to support EFI booting. See commit
69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines


 if (current_el() == 3) {
 smp_kick_all_cpus();
 dcache_disable();
 armv8_switch_to_el2();
 dcache_enable();
 }

Function armv8_switch_to_el2() didn't take any argument before you
change. With your proposed change to support 32-bit OS, you added
arguments to this function, and presume this function always load OS.
This may be flawed. Would it be possible to keep armv8_switch_to_el2()
but introduce another function to carry out switching EL while loading OS?


Alison introduced it based on my comments - and I'd prefer if we only
have the function call based version :).

It should be reasonably straight forward to move to it here. Just create
a new helper stub that enables the dcache and calls entry().



Alex,

Do you always load OS when calling armv8_switch_to_el2()? In this case
of efi booting, kernel entry point needs to be passed to the new
armv8_switch_to_el2 function. The new armv8_switch_to_el2 function
doesn't return, so you cannot continue to run the code.


We always call some random function pointer in the new flow. That can be 
a kernel entry point, but it can also just be a function pointer. In 
this case, the code would basically look like this:


static ulong efi_run_in_el2(ulong (*entry), void *arg1, void *arg2)
{
dcache_enable();
return entry(arg1, arg2);
}

if (current_el() == 3) {
...
return armv8_switch_to_el2(efi_run_in_el2, entry, 
&loaded_image_info, &systab);

}


Alex
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-21 Thread york sun
On 11/21/2016 12:40 PM, Alexander Graf wrote:
>
>
> On 21/11/2016 21:23, york sun wrote:
>> On 11/09/2016 07:02 PM, Alison Wang wrote:
>>> To support loading a 32-bit OS, the execution state will change from
>>> AArch64 to AArch32 when jumping to kernel.
>>>
>>> The architecture information will be got through checking FIT image,
>>> then U-Boot will load 32-bit OS or 64-bit OS automatically.
>>>
>>> Signed-off-by: Ebony Zhu 
>>> Signed-off-by: Alison Wang 
>>> Signed-off-by: Chenhui Zhao 
>>> ---
>>> Changes in v8:
>>> - Fix the issue when U-Boot is running in EL2 or EL1.
>>>
>>
>> Alison,
>>
>> There is a conflict when merging with upstream code. Alex Graf merged
>> his change to support EFI booting. See commit
>> 69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines
>>
>>
>>  if (current_el() == 3) {
>>  smp_kick_all_cpus();
>>  dcache_disable();
>>  armv8_switch_to_el2();
>>  dcache_enable();
>>  }
>>
>> Function armv8_switch_to_el2() didn't take any argument before you
>> change. With your proposed change to support 32-bit OS, you added
>> arguments to this function, and presume this function always load OS.
>> This may be flawed. Would it be possible to keep armv8_switch_to_el2()
>> but introduce another function to carry out switching EL while loading OS?
>
> Alison introduced it based on my comments - and I'd prefer if we only
> have the function call based version :).
>
> It should be reasonably straight forward to move to it here. Just create
> a new helper stub that enables the dcache and calls entry().
>

Alex,

Do you always load OS when calling armv8_switch_to_el2()? In this case 
of efi booting, kernel entry point needs to be passed to the new 
armv8_switch_to_el2 function. The new armv8_switch_to_el2 function 
doesn't return, so you cannot continue to run the code.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-21 Thread Alexander Graf



On 21/11/2016 21:23, york sun wrote:

On 11/09/2016 07:02 PM, Alison Wang wrote:

To support loading a 32-bit OS, the execution state will change from
AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image,
then U-Boot will load 32-bit OS or 64-bit OS automatically.

Signed-off-by: Ebony Zhu 
Signed-off-by: Alison Wang 
Signed-off-by: Chenhui Zhao 
---
Changes in v8:
- Fix the issue when U-Boot is running in EL2 or EL1.



Alison,

There is a conflict when merging with upstream code. Alex Graf merged
his change to support EFI booting. See commit
69bd459d343fe1e5a68a6f187d8c99c78c6fc6ce. Specifically these lines


 if (current_el() == 3) {
 smp_kick_all_cpus();
 dcache_disable();
 armv8_switch_to_el2();
 dcache_enable();
 }

Function armv8_switch_to_el2() didn't take any argument before you
change. With your proposed change to support 32-bit OS, you added
arguments to this function, and presume this function always load OS.
This may be flawed. Would it be possible to keep armv8_switch_to_el2()
but introduce another function to carry out switching EL while loading OS?


Alison introduced it based on my comments - and I'd prefer if we only 
have the function call based version :).


It should be reasonably straight forward to move to it here. Just create 
a new helper stub that enables the dcache and calls entry().



Alex
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8 1/3] armv8: Support loading 32-bit OS in AArch32 execution state

2016-11-09 Thread Alison Wang
To support loading a 32-bit OS, the execution state will change from
AArch64 to AArch32 when jumping to kernel.

The architecture information will be got through checking FIT image,
then U-Boot will load 32-bit OS or 64-bit OS automatically.

Signed-off-by: Ebony Zhu 
Signed-off-by: Alison Wang 
Signed-off-by: Chenhui Zhao 
---
Changes in v8:
- Fix the issue when U-Boot is running in EL2 or EL1.

Changes in v7:
- Move the call for armv8_switch_to_el2_m into this patch. 

Changes in v6:
- Modified armv8_switch_to_el1(). It will always jump to ep when switching to 
AArch64 or AArch32 modes.
- Make other platforms compatible with the new armv8_switch_to_el2() and 
armv8_switch_to_el1().

Changes in v5:
- Modified armv8_switch_to_el2(). It will always jump to ep when switching to 
AArch64 or AArch32 modes.

Changes in v4:
- Correct config ARM64_SUPPORT_AARCH32.
- Omit arch and ftaddr arguments.
- Rename "xreg5" to "tmp".
- Use xxx_RES1 to combine all RES1 fields in xxx register.
- Use an immediate cmp directly.
- Use #ifdef for CONFIG_ARM64_SUPPORT_AARCH32.

Changes in v3:
- Comments the functions and the arguments.
- Rename the real parameters.
- Use the macros instead of the magic values.
- Remove the redundant codes.
- Clean up all of the mess in boot_jump_linux().
- Add CONFIG_ARM64_SUPPORT_AARCH32 to detect for some ARM64 system doesn't 
support AArch32 state.

Changes in v2:
- armv8_switch_to_el2_aarch32() is removed. armv8_switch_to_el2_m is used
  to switch to AArch64 EL2 or AArch32 Hyp.
- armv8_switch_to_el1_aarch32() is removed. armv8_switch_to_el1_m is used
  to switch to AArch64 EL1 or AArch32 SVC.

 arch/arm/Kconfig  |   6 +
 arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S  |  61 +++--
 arch/arm/cpu/armv8/start.S|   8 ++
 arch/arm/cpu/armv8/transition.S   |  23 +++-
 arch/arm/include/asm/arch-fsl-layerscape/mp.h |   4 +
 arch/arm/include/asm/macro.h  | 176 +++---
 arch/arm/include/asm/system.h | 119 -
 arch/arm/lib/bootm.c  |  39 +-
 arch/arm/mach-rmobile/lowlevel_init_gen3.S|   9 +-
 common/image-fit.c|  19 ++-
 10 files changed, 396 insertions(+), 68 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d7a9b11..18c23c0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -126,6 +126,12 @@ config ENABLE_ARM_SOC_BOOT0_HOOK
  ARM_SOC_BOOT0_HOOK which contains the required assembler
  preprocessor code.
 
+config ARM64_SUPPORT_AARCH32
+   bool "ARM64 system support AArch32 execution state"
+   default y if ARM64 && !TARGET_THUNDERX_88XX
+   help
+ This ARM64 system supports AArch32 execution state.
+
 choice
prompt "Target select"
default TARGET_HIKEY
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S 
b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
index 5700b1f..8e6ad4b 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
+++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
@@ -13,6 +13,7 @@
 #ifdef CONFIG_MP
 #include 
 #endif
+#include 
 
 ENTRY(lowlevel_init)
mov x29, lr /* Save LR */
@@ -339,11 +340,6 @@ ENTRY(secondary_boot_func)
 gic_wait_for_interrupt_m x0, w1
 #endif
 
-   bl secondary_switch_to_el2
-#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
-   bl secondary_switch_to_el1
-#endif
-
 slave_cpu:
wfe
ldr x0, [x11]
@@ -356,19 +352,64 @@ slave_cpu:
tbz x1, #25, cpu_is_le
rev x0, x0  /* BE to LE conversion */
 cpu_is_le:
-   br  x0  /* branch to the given address */
+   ldr x5, [x11, #24]
+   ldr x6, =IH_ARCH_DEFAULT
+   cmp x6, x5
+   b.eq1f
+
+#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+   adr x3, secondary_switch_to_el1
+   ldr x4, =ES_TO_AARCH64
+#else
+   ldr x3, [x11]
+   ldr x4, =ES_TO_AARCH32
+#endif
+   bl  secondary_switch_to_el2
+
+1:
+#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+   adr x3, secondary_switch_to_el1
+#else
+   ldr x3, [x11]
+#endif
+   ldr x4, =ES_TO_AARCH64
+   bl  secondary_switch_to_el2
+
 ENDPROC(secondary_boot_func)
 
 ENTRY(secondary_switch_to_el2)
-   switch_el x0, 1f, 0f, 0f
+   switch_el x5, 1f, 0f, 0f
 0: ret
-1: armv8_switch_to_el2_m x0
+1: armv8_switch_to_el2_m x3, x4, x5
 ENDPROC(secondary_switch_to_el2)
 
 ENTRY(secondary_switch_to_el1)
-   switch_el x0, 0f, 1f, 0f
+   mrs x0, mpidr_el1
+   ubfmx1, x0, #8, #15
+   ubfmx2, x0, #0, #1
+   orr x10, x2, x1, lsl #2 /* x10 has LPID */
+
+   lsl x1, x10, #6
+   ldr x0, =__spin_table
+   /* physical address of this cpus spin table element */
+   add x11, x1, x0
+
+   ldr x3, [x11]
+
+   ldr x5, [x11, #24]
+   ldr x6, =IH_ARCH_DEFAULT
+