mbox series

[early-RFC,0/5] xen/arm: Don't switch TTBR while the MMU is on

Message ID 20220309112048.17377-1-julien@xen.org (mailing list archive)
Headers show
Series xen/arm: Don't switch TTBR while the MMU is on | expand

Message

Julien Grall March 9, 2022, 11:20 a.m. UTC
From: Julien Grall <jgrall@amazon.com>

Hi all,

Currently, Xen on Arm will switch TTBR whilst the MMU is on. This is
similar to replacing existing mappings with new ones. So we need to
follow a break-before-make sequence.

When switching the TTBR, we need to temporary disable the MMU
before update the TTBR. This means the page-tables must contain an
identity mapping.

The current memory layout is not very flexible and has an higher chance
to clash with the identity mapping.

On Arm64, we have plenty of unused virtual address space Therefore, we can
simply reshuffle the layout to leave the first part of the virtual
address space empty.

On Arm32, the virtual address space is already quite full. That said,
we are currently reserving 2GB for the temporary mapping. This is far
too much given those mappings are temporary. It would be sufficient
to only reserve a few MBs.

The Arm32 part is not yet addressed in this version. The series is
sent as an early RFC to gather some feedback on the approach.

After this series, most of Xen page-table code should be compliant
with the Arm Arm. The last two issues I am aware of are:
 - domheap: Mappings are replaced without using the Break-Before-Make
   approach.
 - The cache is not cleaned/invalidated when updating the page-tables
   with Data cache off (like during early boot).

This series is based on "xen/arm: mm: Remove open-coding mappings"
along with some extra small patches. Some of them are already merged.
For convience, I pushed a branch with everything applied:

https://xenbits.xen.org/git-http/people/julieng/xen-unstable.git
branch boot-pt-rework-v1

Note the build for arm32 is likely broken. This will be addressed
on the next version.

Cheers,

Julien GralL (1):
  xen/arm: mm: Introduce helpers to prepare/enable/disable the identity
    mapping

Julien Grall (4):
  xen/arm: Clean-up the memory layout
  xen/arm64: Rework the memory layout
  xen/arm: mm: Rework switch_ttbr()
  xen/arm: smpboot: Directly switch to the runtime page-tables

 xen/arch/arm/arm64/head.S         |  63 ++++++++--------
 xen/arch/arm/include/asm/config.h |  44 +++++++----
 xen/arch/arm/include/asm/mm.h     |   2 +
 xen/arch/arm/mm.c                 | 120 +++++++++++++++++++++++-------
 xen/arch/arm/smpboot.c            |   3 +
 5 files changed, 160 insertions(+), 72 deletions(-)