mbox series

[Xen-devel,v3,00/28] xen/arm: Rework head.S to make it more compliant with the Arm Arm

Message ID 20190812173019.11956-1-julien.grall@arm.com
Headers show
Series xen/arm: Rework head.S to make it more compliant with the Arm Arm | expand

Message

Julien Grall Aug. 12, 2019, 5:29 p.m. UTC
Hi all,

This is part of the boot/memory rework for Xen on Arm, but not sent as
MM-PARTx as this is focusing on the boot code.

Similar to the memory code, the boot code is not following the Arm Arm and
could lead to memory corruption/TLB conflict abort. I am not aware
of any platforms where Xen fails to boot, yet it should be fixed sooner
rather than later.

While making the code more compliant, I have also took the opportunity
to simplify the boot and also add more documentation.

After this series, the boot CPU and secondary CPUs path is mostly compliant
with the Arm Arm. The only non-compliant places I am aware of are:
    1) create_page_tables: Some rework is necessary to update the page-tables
       safely without the MMU on.
    2) The switches between boot and runtime page-tables (for both boot CPU
        and secondary CPUs) are not safe.

All will be addressed in follow-up series. The boot code would also benefits
another proof read for missing isb()/dsb().


For convenience I provided a branch based on staging:
   git://xenbits.xen.org/people/julieng/xen-unstable.git branch boot/v3

Cheers,

Julien Grall (28):
  xen/arm: lpae: Allow more LPAE helpers to be used in assembly
  xen/arm64: head: Remove 1:1 mapping as soon as it is not used
  xen/arm64: head: Rework and document setup_fixmap()
  xen/arm64: head: Rework and document launch()
  xen/arm64: head: Setup TTBR_EL2 in enable_mmu() and add missing isb
  xen/arm64: head: Introduce a macro to get a PC-relative address of a
    symbol
  xen/arm64: head: Fix typo in the documentation on top of init_uart()
  xen/arm32: head: Add a macro to move an immediate constant into a
    32-bit register
  xen/arm32: head: Mark the end of subroutines with ENDPROC
  xen/arm32: head: Don't clobber r14/lr in the macro PRINT
  xen/arm32: head: Rework UART initialization on boot CPU
  xen/arm32: head: Introduce print_reg
  xen/arm32: head: Introduce distinct paths for the boot CPU and
    secondary CPUs
  xen/arm32: head: Rework and document check_cpu_mode()
  xen/arm32: head: Rework and document zero_bss()
  xen/arm32: head: Document create_pages_tables()
  xen/arm32: head: Document enable_mmu()
  xen/arm32: head: Move assembly switch to the runtime PT in secondary
    CPUs path
  xen/arm32: head: Don't setup the fixmap on secondary CPUs
  xen/arm32: head: Remove 1:1 mapping as soon as it is not used
  xen/arm32: head: Rework and document setup_fixmap()
  xen/arm32: head: Rework and document launch()
  xen/arm32: head: Setup HTTBR in enable_mmu() and add missing isb
  xen/arm: Zero BSS after the MMU and D-cache is turned on
  xen/arm64: head: Introduce macros to create table and mapping entry
  xen/arm64: head: Use a page mapping for the 1:1 mapping in
    create_page_tables()
  xen/arm32: head: Introduce macros to create table and mapping entry
  xen/arm32: head: Use a page mapping for the 1:1 mapping in
    create_page_tables()

 xen/arch/arm/arm32/head.S  | 601 ++++++++++++++++++++++++++++++---------------
 xen/arch/arm/arm64/head.S  | 438 +++++++++++++++++++++------------
 xen/arch/arm/mm.c          |  25 +-
 xen/include/asm-arm/lpae.h |  10 +-
 4 files changed, 716 insertions(+), 358 deletions(-)

Comments

Julien Grall Aug. 12, 2019, 5:33 p.m. UTC | #1
On 12/08/2019 18:30, Julien Grall wrote:
> putn() and puts() are two subroutines. Add ENDPROC for the benefits of
> static analysis tools and the reader.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> Acked-by: Stefano Stabellini <sstabllini@kernel.org>

Hmmm, I made a typo in Stefano's e-mail address. I can fix it on commit message 
(or next version).

Cheers,

> 
> ---
>      Changes in v3:
>          - Add Stefano's acked-by
> 
>      Changes in v2:
>          - Patch added
> ---
>   xen/arch/arm/arm32/head.S | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
> index 99f4af18d8..8b4c8a4714 100644
> --- a/xen/arch/arm/arm32/head.S
> +++ b/xen/arch/arm/arm32/head.S
> @@ -518,6 +518,7 @@ puts:
>           moveq pc, lr
>           early_uart_transmit r11, r1
>           b puts
> +ENDPROC(puts)
>   
>   /*
>    * Print a 32-bit number in hex.  Specific to the PL011 UART.
> @@ -537,6 +538,7 @@ putn:
>           subs  r3, r3, #1
>           bne   1b
>           mov   pc, lr
> +ENDPROC(putn)
>   
>   hex:    .ascii "0123456789abcdef"
>           .align 2
>