Skip to contentSkip to conversation

xen/arm: Split MMU code as the prepration of MPU work

PATCH Superseded Henry Wang 4 participants 41 messages Aug 1, 2023 – Aug 10, 2023

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Henry Wang

author
#0 lore raw

v4 cover xen/arm: Split MMU code as the prepration of MPU work

Based on the discussion in the Xen Summit [1], sending this series out after addressing the comments in v3 [2] as the preparation work to add MPU support.

Mostly code movement, with some of Kconfig and build system (mainly Makefiles) adjustment. No functional change expected.

[1] https://lore.kernel.org/xen-devel/AS8PR08MB799122F8B0CB841DED64F4819226A@AS8PR08MB7991.eurprd08.prod.outlook.com/
[2] https://lore.kernel.org/xen-devel/[email protected]/

Henry Wang (4):
xen/arm: Introduce 'choice' for memory system architecture xen/arm64: Split and move MMU-specific head.S to mmu/head.S xen/arm64: Move setup_fixmap() to create_page_tables() xen/arm: Extract MMU-specific code

Penny Zheng (6):
xen/arm: Fold pmap and fixmap into MMU system
xen/arm: mm: Use generic variable/function names for extendability xen/arm: mmu: move MMU-specific setup_mm to mmu/setup.c xen/arm: mmu: move MMU specific P2M code to mmu/p2m.{c,h} xen/arm: mmu: relocate copy_from_paddr() to setup.c xen/arm: mmu: enable SMMU subsystem only in MMU

Wei Chen (3):
xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm xen/arm64: prepare for moving MMU related code from head.S xen/arm: Move MMU related definitions from config.h to mmu/layout.h

 xen/arch/arm/Kconfig                    |   16 +-
 xen/arch/arm/Makefile                   |    1 +
 xen/arch/arm/arm32/head.S               |    4 +-
 xen/arch/arm/arm64/Makefile             |    2 +-
 xen/arch/arm/arm64/head.S               |  497 +------
 xen/arch/arm/arm64/mmu/Makefile         |    2 +
 xen/arch/arm/arm64/mmu/head.S           |  471 ++++++
 xen/arch/arm/arm64/{ => mmu}/mm.c       |   11 +-
 xen/arch/arm/arm64/smpboot.c            |    6 +-
 xen/arch/arm/include/asm/arm64/macros.h |   36 +
 xen/arch/arm/include/asm/arm64/mm.h     |    7 +-
 xen/arch/arm/include/asm/config.h       |  132 +-
 xen/arch/arm/include/asm/fixmap.h       |    7 +-
 xen/arch/arm/include/asm/mm.h           |   28 +-
 xen/arch/arm/include/asm/mmu/layout.h   |  146 ++
 xen/arch/arm/include/asm/mmu/mm.h       |   55 +
 xen/arch/arm/include/asm/mmu/p2m.h      |   18 +
 xen/arch/arm/include/asm/p2m.h          |   33 +-
 xen/arch/arm/include/asm/page.h         |   15 -
 xen/arch/arm/include/asm/setup.h        |    8 +-
 xen/arch/arm/kernel.c                   |   27 -
 xen/arch/arm/mm.c                       | 1119 --------------
 xen/arch/arm/mmu/Makefile               |    3 +
 xen/arch/arm/mmu/mm.c                   | 1153 +++++++++++++++
 xen/arch/arm/mmu/p2m.c                  | 1610 ++++++++++++++++++++
 xen/arch/arm/mmu/setup.c                |  366 +++++
 xen/arch/arm/p2m.c                      | 1772 ++---------------------
 xen/arch/arm/setup.c                    |  326 +----
 xen/arch/arm/smpboot.c                  |    4 +-
 xen/arch/arm/xen.lds.S                  |    1 +
 xen/drivers/passthrough/Kconfig         |    3 +-
 31 files changed, 4064 insertions(+), 3815 deletions(-)
 create mode 100644 xen/arch/arm/arm64/mmu/Makefile
 create mode 100644 xen/arch/arm/arm64/mmu/head.S
 rename xen/arch/arm/arm64/{ => mmu}/mm.c (95%)
 create mode 100644 xen/arch/arm/include/asm/mmu/layout.h
 create mode 100644 xen/arch/arm/include/asm/mmu/mm.h
 create mode 100644 xen/arch/arm/include/asm/mmu/p2m.h
 create mode 100644 xen/arch/arm/mmu/Makefile
 create mode 100644 xen/arch/arm/mmu/mm.c
 create mode 100644 xen/arch/arm/mmu/p2m.c
 create mode 100644 xen/arch/arm/mmu/setup.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v4 1/13 xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

From: Wei Chen <[email protected]>

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

---
v4:
- Clarify remove_identity_mapping() is called on boot CPU and keep the function/proc format consistent in commit msg.
- Drop inaccurate (due to the refactor) in-code comment.
- Rename enable_{boot,runtime}_mmu to enable_{boot,secondary}_cpu_mm.
- Reword the in-code comment on top of enable_{boot,secondary}_cpu_mm.
- Call "fail" for unreachable code.
v3:
- new patch

---
 xen/arch/arm/arm64/head.S | 89 ++++++++++++++++++++++++++++++---------
 1 file changed, 70 insertions(+), 19 deletions(-)
xen/arch/arm/arm64/head.S +70 -19
index 31cdb54d74..2af9f974d5 100644
@@ -313,21 +313,11 @@ real_start_efi:
 
         bl    check_cpu_mode
         bl    cpu_init
-        bl    create_page_tables
-        load_paddr x0, boot_pgtable
-        bl    enable_mmu
 
-        /* We are still in the 1:1 mapping. Jump to the runtime Virtual Address. */
-        ldr   x0, =primary_switched
-        br    x0
+        ldr   lr, =primary_switched
+        b     enable_boot_cpu_mm
+
 primary_switched:
-        /*
-         * The 1:1 map may clash with other parts of the Xen virtual memory
-         * layout. As it is not used anymore, remove it completely to
-         * avoid having to worry about replacing existing mapping
-         * afterwards.
-         */
-        bl    remove_identity_mapping
         bl    setup_fixmap
 #ifdef CONFIG_EARLY_PRINTK
         /* Use a virtual address to access the UART. */
@@ -372,13 +362,10 @@ GLOBAL(init_secondary)
 #endif
         bl    check_cpu_mode
         bl    cpu_init
-        load_paddr x0, init_ttbr
-        ldr   x0, [x0]
-        bl    enable_mmu
 
-        /* We are still in the 1:1 mapping. Jump to the runtime Virtual Address. */
-        ldr   x0, =secondary_switched
-        br    x0
+        ldr   lr, =secondary_switched
+        b     enable_secondary_cpu_mm
+
 secondary_switched:
 #ifdef CONFIG_EARLY_PRINTK
         /* Use a virtual address to access the UART. */
@@ -737,6 +724,70 @@ enable_mmu:
         ret
 ENDPROC(enable_mmu)
 
+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:
+        mov   x5, lr
+
+        load_paddr x0, init_ttbr
+        ldr   x0, [x0]
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /* return to secondary_switched */
+        ret
+ENDPROC(enable_secondary_cpu_mm)
+
+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:
+        mov   x5, lr
+
+        bl    create_page_tables
+        load_paddr x0, boot_pgtable
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /*
+         * The MMU is turned on and we are in the 1:1 mapping. Switch
+         * to the runtime mapping.
+         */
+        ldr   x0, =1f
+        br    x0
+1:
+        /*
+         * The 1:1 map may clash with other parts of the Xen virtual memory
+         * layout. As it is not used anymore, remove it completely to
+         * avoid having to worry about replacing existing mapping
+         * afterwards. Function will return to primary_switched.
+         */
+        b     remove_identity_mapping
+
+        /*
+         * Below is supposed to be unreachable code, as "ret" in
+         * remove_identity_mapping will use the return address in LR in advance.
+         */
+        b     fail
+ENDPROC(enable_boot_cpu_mm)
+
 /*
  * Remove the 1:1 map from the page-tables. It is not easy to keep track
  * where the 1:1 map was mapped, so we will look for the top-level entry
Signature · 1 line
2.25.1
Reviewed-by Tested-by on v4 1/13
#2 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Hi Henry,

Quoted 15 lines · Henry Wang

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

From: Wei Chen <[email protected]>

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

Quoted 7 lines

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

With two comments

Quoted 65 lines

---
v4:
- Clarify remove_identity_mapping() is called on boot CPU and keep the function/proc format consistent in commit msg.
- Drop inaccurate (due to the refactor) in-code comment.
- Rename enable_{boot,runtime}_mmu to enable_{boot,secondary}_cpu_mm.
- Reword the in-code comment on top of enable_{boot,secondary}_cpu_mm.
- Call "fail" for unreachable code.
v3:
- new patch

---
  xen/arch/arm/arm64/head.S | 89 ++++++++++++++++++++++++++++++---------
  1 file changed, 70 insertions(+), 19 deletions(-)
xen/arch/arm/arm64/head.S +7 -19
index 31cdb54d74..2af9f974d5 100644
@@ -313,21 +313,11 @@ real_start_efi:
 
          bl    check_cpu_mode
          bl    cpu_init
-        bl    create_page_tables
-        load_paddr x0, boot_pgtable
-        bl    enable_mmu
 
-        /* We are still in the 1:1 mapping. Jump to the runtime Virtual Address. */
-        ldr   x0, =primary_switched
-        br    x0
+        ldr   lr, =primary_switched
+        b     enable_boot_cpu_mm
+
  primary_switched:
-        /*
-         * The 1:1 map may clash with other parts of the Xen virtual memory
-         * layout. As it is not used anymore, remove it completely to
-         * avoid having to worry about replacing existing mapping
-         * afterwards.
-         */
-        bl    remove_identity_mapping
          bl    setup_fixmap
  #ifdef CONFIG_EARLY_PRINTK
          /* Use a virtual address to access the UART. */
@@ -372,13 +362,10 @@ GLOBAL(init_secondary)
  #endif
          bl    check_cpu_mode
          bl    cpu_init
-        load_paddr x0, init_ttbr
-        ldr   x0, [x0]
-        bl    enable_mmu
 
-        /* We are still in the 1:1 mapping. Jump to the runtime Virtual Address. */
-        ldr   x0, =secondary_switched
-        br    x0
+        ldr   lr, =secondary_switched
+        b     enable_secondary_cpu_mm
+
  secondary_switched:
  #ifdef CONFIG_EARLY_PRINTK
          /* Use a virtual address to access the UART. */
@@ -737,6 +724,70 @@ enable_mmu:
          ret
  ENDPROC(enable_mmu)
 
+/*

xen/arch/arm/arm64/head.S enable_mmu: · line 737

Quoted 10 lines
xen/arch/arm/arm64/head.S +10 -0
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:

I will prefer "enable_secondary_cpu_mmu" as it is MMU specific. And ...

Quoted 13 lines
xen/arch/arm/arm64/head.S +13 -0
+        mov   x5, lr
+
+        load_paddr x0, init_ttbr
+        ldr   x0, [x0]
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /* return to secondary_switched */
+        ret
+ENDPROC(enable_secondary_cpu_mm)
+
+/*

xen/arch/arm/arm64/head.S enable_mmu: · line 760

Quoted 10 lines
xen/arch/arm/arm64/head.S +10 -0
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

- Ayan

Quoted 37 lines
xen/arch/arm/arm64/head.S +30 -1
+        mov   x5, lr
+
+        bl    create_page_tables
+        load_paddr x0, boot_pgtable
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /*
+         * The MMU is turned on and we are in the 1:1 mapping. Switch
+         * to the runtime mapping.
+         */
+        ldr   x0, =1f
+        br    x0
+1:
+        /*
+         * The 1:1 map may clash with other parts of the Xen virtual memory
+         * layout. As it is not used anymore, remove it completely to
+         * avoid having to worry about replacing existing mapping
+         * afterwards. Function will return to primary_switched.
+         */
+        b     remove_identity_mapping
+
+        /*
+         * Below is supposed to be unreachable code, as "ret" in
+         * remove_identity_mapping will use the return address in LR in advance.
+         */
+        b     fail
+ENDPROC(enable_boot_cpu_mm)
+
  /*
   * Remove the 1:1 map from the page-tables. It is not easy to keep track
   * where the 1:1 map was mapped, so we will look for the top-level entry
--

2.25.1

author
#3 lore raw

RE: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Hi Ayan,

Quoted 21 lines

-----Original Message-----
Hi Henry,

Quoted 10 lines

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

Quoted 7 lines

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

Quoted 5 lines

With two comments

Thanks, and...

Quoted 13 lines

xen/arch/arm/arm64/head.S enable_mmu: · line 737

Quoted 12 lines
xen/arch/arm/arm64/head.S +11 -0
+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:

I will prefer "enable_secondary_cpu_mmu" as it is MMU specific. And ...

...actually this as well as...

Quoted 5 lines
Quoted 5 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *

Quoted 8 lines
Quoted 6 lines

+ * Inputs:
+ * lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

...this, are the name suggested by Julien in [1], so probably I will stick to these names, unless he would prefer the proposed names. I would personally prefer the names that Julien suggested too, because from the comments above these two functions, these functions not only enable the MMU, but also turn on the d-cache, hence a more generic name (using "mm"), is more appropriate here I guess.

[1] https://lore.kernel.org/xen-devel/[email protected]/

Kind regards,
Henry

Quoted 2 lines

- Ayan

#4 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Quoted 1 line · Henry Wang

Hi Ayan,

Hi Henry,

Quoted 59 lines
Quoted 21 lines

-----Original Message-----
Hi Henry,

Quoted 10 lines

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

Quoted 7 lines

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

Quoted 5 lines

With two comments

Thanks, and...

Quoted 13 lines

xen/arch/arm/arm64/head.S enable_mmu: · line 737

Quoted 12 lines
xen/arch/arm/arm64/head.S +11 -0
+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:

I will prefer "enable_secondary_cpu_mmu" as it is MMU specific. And ...

...actually this as well as...

Quoted 5 lines
Quoted 5 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *

Quoted 8 lines
Quoted 6 lines

+ * Inputs:
+ * lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

Quoted 6 lines

...this, are the name suggested by Julien in [1], so probably I will stick to these names, unless he would prefer the proposed names. I would personally prefer the names that Julien suggested too, because from the comments above these two functions, these functions not only enable the MMU, but also turn on the d-cache, hence a more generic name (using "mm"), is more appropriate here I guess.

I have suggested those name because the two functions are meant to abstract the implementation between MPU and MMU (see [2] for the MPU).

If we prefix them with *_mmu now, they will have to be renamed later on and will just introduce unnecessary churn.

Quoted 2 lines

[1] https://lore.kernel.org/xen-devel/[email protected]/

[2] https://gitlab.com/xen-project/people/henryw/xen/-/blob/mpu_v4/xen/arch/arm/arm64/mpu/head.S?ref_type=heads#L205

Signature · 1 line
Julien Grall
author
#5 lore raw

RE: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Hi Julien,

Quoted 12 lines

-----Original Message-----
Subject: Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Quoted 8 lines
Quoted 1 line

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

...this, are the name suggested by Julien in [1], so probably I will stick to these names, unless he would prefer the proposed names. I would personally prefer the names that Julien suggested too, because from the comments above these two functions, these functions not only enable the MMU, but also turn on the d-cache, hence a more generic name (using "mm"), is more appropriate here I guess.

Quoted 5 lines

I have suggested those name because the two functions are meant to abstract the implementation between MPU and MMU (see [2] for the MPU).

If we prefix them with *_mmu now, they will have to be renamed later on and will just introduce unnecessary churn.

Exactly, I fully agree with you. If we can do all the renaming in one shot to fit both MMU and MPU, we should definitely go for it.

Kind regards,
Henry

Quoted 11 lines
Quoted 3 lines

[1] https://lore.kernel.org/xen-devel/c10bc254-ad79-dada-d5fb-

[email protected]/

[2]
https://gitlab.com/xen-project/people/henryw/xen/-
/blob/mpu_v4/xen/arch/arm/arm64/mpu/head.S?ref_type=heads#L205

--
Julien Grall

#6 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

In reply to Henry Wang
Quoted 55 lines · Henry Wang

Hi Ayan,

Quoted 17 lines

-----Original Message-----
Hi Henry,

Quoted 14 lines

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

Quoted 8 lines
Quoted 3 lines

With two comments

Thanks, and...

Quoted 4 lines
Quoted 4 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).

Quoted 8 lines
Quoted 7 lines

+ *
+ * Inputs:
+ * lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:

I will prefer "enable_secondary_cpu_mmu" as it is MMU specific. And ...

...actually this as well as...

Quoted 4 lines
Quoted 4 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).

Quoted 8 lines
Quoted 7 lines

+ *
+ * Inputs:
+ * lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

Quoted 8 lines

...this, are the name suggested by Julien in [1], so probably I will stick to these names, unless he would prefer the proposed names. I would personally prefer the names that Julien suggested too, because from the comments above these two functions, these functions not only enable the MMU, but also turn on the d-cache, hence a more generic name (using "mm"), is more appropriate here I guess.

[1] https://lore.kernel.org/xen-devel/[email protected]/

This is fine. My concern is minor.

If this file is going to contain MPU specific logic as well in future, then suffixing a *_mmu might help to distinguish the two.

- Ayan

Quoted 5 lines

Kind regards,
Henry

Quoted 1 line

- Ayan

#7 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Quoted 66 lines · Ayan Kumar Halder
Quoted 64 lines · Henry Wang

Hi Ayan,

Quoted 17 lines

-----Original Message-----
Hi Henry,

Quoted 14 lines

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

Quoted 8 lines
Quoted 3 lines

With two comments

Thanks, and...

Quoted 5 lines
Quoted 5 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).

Quoted 8 lines
Quoted 7 lines

+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:

I will prefer "enable_secondary_cpu_mmu" as it is MMU specific. And ...

...actually this as well as...

Quoted 5 lines
Quoted 5 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).

Quoted 8 lines
Quoted 7 lines

+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

...this, are the name suggested by Julien in [1], so probably I will stick to these names, unless he would prefer the proposed names. I would personally prefer the names that Julien suggested too, because from the comments above these two functions, these functions not only enable the MMU, but also turn on the d-cache, hence a more generic name (using "mm"), is more appropriate here I guess.

Quoted 5 lines
Quoted 1 line

[1] https://lore.kernel.org/xen-devel/[email protected]/

This is fine. My concern is minor.

If this file is going to contain MPU specific logic as well in future, then suffixing a *_mmu might help to distinguish the two.

For this series, it is quite important to look at the end result. In this case, the MMU logic will be moved in its own file. enable_boot_cpu_mm() and enable_second_cpu_mm() will be implemented differently between the MMU and MPU to avoid #ifdeferay in head.S.

Cheers,

Signature · 1 line
Julien Grall
#8 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Hi Julien/Henry,

Thanks for the explanation.

Quoted 70 lines · Julien Grall
Quoted 67 lines · Ayan Kumar Halder
Quoted 65 lines · Henry Wang

Hi Ayan,

Quoted 17 lines

-----Original Message-----
Hi Henry,

Quoted 14 lines

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

Quoted 8 lines
Quoted 3 lines

With two comments

Thanks, and...

Quoted 6 lines
Quoted 6 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).

Quoted 8 lines
Quoted 7 lines

+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_secondary_cpu_mm:

I will prefer "enable_secondary_cpu_mmu" as it is MMU specific. And ...

...actually this as well as...

Quoted 5 lines
Quoted 5 lines

+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).

Quoted 8 lines
Quoted 7 lines

+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:

prefer "enable_boot_cpu_mmu" as it is MMU specific as well.

...this, are the name suggested by Julien in [1], so probably I will stick to these names, unless he would prefer the proposed names. I would personally prefer the names that Julien suggested too, because from the comments above these two functions, these functions not only enable the MMU, but also turn on the d-cache, hence a more generic name (using "mm"), is more appropriate here I guess.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

[1] https://lore.kernel.org/xen-devel/[email protected]/

This is fine. My concern is minor.

If this file is going to contain MPU specific logic as well in future, then suffixing a *_mmu might help to distinguish the two.

For this series, it is quite important to look at the end result. In this case, the MMU logic will be moved in its own file. enable_boot_cpu_mm() and enable_second_cpu_mm() will be implemented differently between the MMU and MPU to avoid #ifdeferay in head.S.

Makes sense. I am happy with it.

- Ayan

Quoted 3 lines

Cheers,

#9 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

In reply to Henry Wang

Hi Henry,

Title: NIT: Add () after _mm to stay consistent with the rest.

Quoted 93 lines · Henry Wang

From: Wei Chen <[email protected]>

At the moment, on MMU system, enable_mmu() will return to an address in the 1:1 mapping, then each path is responsible to switch to virtual runtime mapping. Then remove_identity_mapping() is called on the boot CPU to remove all 1:1 mapping.

Since remove_identity_mapping() is not necessary on Non-MMU system, and we also avoid creating empty function for Non-MMU system, trying to keep only one codeflow in arm64/head.S, we move path switch and remove_identity_mapping() in enable_mmu() on MMU system.

As the remove_identity_mapping should only be called for the boot CPU only, so we introduce enable_boot_cpu_mm() for boot CPU and enable_secondary_cpu_mm() for secondary CPUs in this patch.

---
v4:
- Clarify remove_identity_mapping() is called on boot CPU and keep the function/proc format consistent in commit msg.
- Drop inaccurate (due to the refactor) in-code comment.
- Rename enable_{boot,runtime}_mmu to enable_{boot,secondary}_cpu_mm.
- Reword the in-code comment on top of enable_{boot,secondary}_cpu_mm.
- Call "fail" for unreachable code.
v3:
- new patch

---
  xen/arch/arm/arm64/head.S | 89 ++++++++++++++++++++++++++++++---------
  1 file changed, 70 insertions(+), 19 deletions(-)
xen/arch/arm/arm64/head.S +16 -19
index 31cdb54d74..2af9f974d5 100644
@@ -313,21 +313,11 @@ real_start_efi:
 
          bl    check_cpu_mode
          bl    cpu_init
-        bl    create_page_tables
-        load_paddr x0, boot_pgtable
-        bl    enable_mmu
 
-        /* We are still in the 1:1 mapping. Jump to the runtime Virtual Address. */
-        ldr   x0, =primary_switched
-        br    x0
+        ldr   lr, =primary_switched
+        b     enable_boot_cpu_mm
+
  primary_switched:
-        /*
-         * The 1:1 map may clash with other parts of the Xen virtual memory
-         * layout. As it is not used anymore, remove it completely to
-         * avoid having to worry about replacing existing mapping
-         * afterwards.
-         */
-        bl    remove_identity_mapping
          bl    setup_fixmap
  #ifdef CONFIG_EARLY_PRINTK
          /* Use a virtual address to access the UART. */
@@ -372,13 +362,10 @@ GLOBAL(init_secondary)
  #endif
          bl    check_cpu_mode
          bl    cpu_init
-        load_paddr x0, init_ttbr
-        ldr   x0, [x0]
-        bl    enable_mmu
 
-        /* We are still in the 1:1 mapping. Jump to the runtime Virtual Address. */
-        ldr   x0, =secondary_switched
-        br    x0
+        ldr   lr, =secondary_switched
+        b     enable_secondary_cpu_mm
+
  secondary_switched:
  #ifdef CONFIG_EARLY_PRINTK
          /* Use a virtual address to access the UART. */
@@ -737,6 +724,70 @@ enable_mmu:
          ret
  ENDPROC(enable_mmu)
 
+/*
+ * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */

xen/arch/arm/arm64/head.S enable_mmu: · line 746

Quoted 10 lines
xen/arch/arm/arm64/head.S +10 -0
+enable_secondary_cpu_mm:
+        mov   x5, lr
+
+        load_paddr x0, init_ttbr
+        ldr   x0, [x0]
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /* return to secondary_switched */

Technically, you will return to the virtual address set in 'lr'. This is 'secondary_switched' today but this could change.

So it would be better to have a more generic comment like:

Return to the virtual address requested by the caller.

Quoted 24 lines
xen/arch/arm/arm64/head.S +24 -0
+        ret
+ENDPROC(enable_secondary_cpu_mm)
+
+/*
+ * Enable mm (turn on the data cache and the MMU) for the boot CPU.
+ * The function will return to the virtual address provided in LR (e.g. the
+ * runtime mapping).
+ *
+ * Inputs:
+ *   lr : Virtual address to return to.
+ *
+ * Clobbers x0 - x5
+ */
+enable_boot_cpu_mm:
+        mov   x5, lr
+
+        bl    create_page_tables
+        load_paddr x0, boot_pgtable
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /*
+         * The MMU is turned on and we are in the 1:1 mapping. Switch

xen/arch/arm/arm64/head.S enable_mmu: · line 780

Quoted 10 lines
xen/arch/arm/arm64/head.S +10 -0
+         * to the runtime mapping.
+         */
+        ldr   x0, =1f
+        br    x0
+1:
+        /*
+         * The 1:1 map may clash with other parts of the Xen virtual memory
+         * layout. As it is not used anymore, remove it completely to
+         * avoid having to worry about replacing existing mapping
+         * afterwards. Function will return to primary_switched.

Same remark here.

xen/arch/arm/arm64/head.S enable_mmu: · line 788

Quoted 8 lines
xen/arch/arm/arm64/head.S +8 -0
+         */
+        b     remove_identity_mapping
+
+        /*
+         * Below is supposed to be unreachable code, as "ret" in
+         * remove_identity_mapping will use the return address in LR in advance.
+         */
+        b     fail

Looking at this again, I am not entirely sure how this could reached if remove_identity_mapping use 'ret' and you call it with 'b'. So I would suggest to drop it and move 'mov lr, x5' closer to 'b remove_identity_mapping'. So it is clearer that it will return.

xen/arch/arm/arm64/head.S enable_mmu: · line 793

Quoted 5 lines
xen/arch/arm/arm64/head.S +2 -0
+ENDPROC(enable_boot_cpu_mm)
+
  /*
   * Remove the 1:1 map from the page-tables. It is not easy to keep track
   * where the 1:1 map was mapped, so we will look for the top-level entry

Cheers,

Signature · 1 line
Julien Grall
author
#10 lore raw

Re: [PATCH v4 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_mm

Hi Julien,

Quoted 5 lines · Julien Grall

Hi Henry,

Title: NIT: Add () after _mm to stay consistent with the rest.

Yes sure, I will add “()” in v5.

Quoted 17 lines · Henry Wang

xen/arch/arm/arm64/head.S enable_mmu: · line 746

Quoted 12 lines

From: Wei Chen <[email protected]>

xen/arch/arm/arm64/head.S +10 -0
+enable_secondary_cpu_mm:
+        mov   x5, lr
+
+        load_paddr x0, init_ttbr
+        ldr   x0, [x0]
+
+        bl    enable_mmu
+        mov   lr, x5
+
+        /* return to secondary_switched */

Technically, you will return to the virtual address set in 'lr'. This is 'secondary_switched' today but this could change.

Quoted 3 lines

So it would be better to have a more generic comment like:

Return to the virtual address requested by the caller.

Sure, and...

Quoted 5 lines
Quoted 5 lines
xen/arch/arm/arm64/head.S +3 -0
+        ret
+ENDPROC(enable_secondary_cpu_mm)
+
Quoted 8 lines

xen/arch/arm/arm64/head.S enable_mmu: · line 780

Quoted 6 lines

+1:

xen/arch/arm/arm64/head.S +5 -0
+        /*
+         * The 1:1 map may clash with other parts of the Xen virtual memory
+         * layout. As it is not used anymore, remove it completely to
+         * avoid having to worry about replacing existing mapping
+         * afterwards. Function will return to primary_switched.

Same remark here.

…same here.

Quoted 11 lines

xen/arch/arm/arm64/head.S enable_mmu: · line 788

Quoted 9 lines
xen/arch/arm/arm64/head.S +8 -0
+         */
+        b     remove_identity_mapping
+
+        /*
+         * Below is supposed to be unreachable code, as "ret" in
+         * remove_identity_mapping will use the return address in LR in advance.
+         */
+        b     fail

Looking at this again, I am not entirely sure how this could reached if remove_identity_mapping use 'ret' and you call it with 'b'. So I would suggest to drop it and move 'mov lr, x5' closer to 'b remove_identity_mapping'. So it is clearer that it will return.

Ok, I’ve addressed this locally and tested the change, Xen and Dom0 boot fine with the changes that you suggested. Will send v5 soon after fixing all your comments. Thanks!

Kind regards,
Henry

Quoted 11 lines

xen/arch/arm/arm64/head.S enable_mmu: · line 793

Quoted 6 lines
xen/arch/arm/arm64/head.S +2 -0
+ENDPROC(enable_boot_cpu_mm)
+
 /*
  * Remove the 1:1 map from the page-tables. It is not easy to keep track
  * where the 1:1 map was mapped, so we will look for the top-level entry

Cheers,

Signature · 1 line
Julien Grall
author
#11 lore raw

PATCH v4 2/13 xen/arm: Introduce 'choice' for memory system architecture

In reply to Henry Wang

There are two types of memory system architectures available for Arm-based systems, namely the Virtual Memory System Architecture (VMSA) and the Protected Memory System Architecture (PMSA). According to ARM DDI 0487G.a, A VMSA provides a Memory Management Unit (MMU) that controls address translation, access permissions, and memory attribute determination and checking, for memory accesses made by the PE. And refer to ARM DDI 0600A.c, the PMSA supports a unified memory protection scheme where an Memory Protection Unit (MPU) manages instruction and data access. Currently, Xen only suuports VMSA.

As a preparation of the Xen MPU (PMSA) support. Introduce a Kconfig choice under the "Architecture Features" menu for user to choose the memory system architecture for the system. Since currently only VMSA is supported, only add the bool CONFIG_HAS_MMU to keep consistent with the default behavior. User can choose either VMSA or PMSA but not both in the future after PMSA/MPU is supported in Xen.

---
v4:
- Completely rework "[v3,06/52] xen/arm: introduce CONFIG_HAS_MMU"

---
 xen/arch/arm/Kconfig | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
xen/arch/arm/Kconfig +14 -0
index fd57a82dd2..0e38e9ba17 100644
@@ -59,6 +59,20 @@ config PADDR_BITS
 	default 40 if ARM_PA_BITS_40
 	default 48 if ARM_64
 
+choice
+	prompt "Memory system architecture"
+	default HAS_MMU
+	help
+	  User can choose the memory system architecture.
+	  A Virtual Memory System Architecture (VMSA) provides a Memory Management
+	  Unit (MMU) that controls address translation, access permissions, and
+	  memory attribute determination and checking, for memory accesses made by
+	  the PE.
+
+config HAS_MMU
+	bool "MMU for a VMSA system"
+endchoice
+
 source "arch/Kconfig"
 
 config ACPI
Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH v4 02/13] xen/arm: Introduce 'choice' for memory system architecture

Hi Henry,

Quoted 20 lines · Henry Wang

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

There are two types of memory system architectures available for Arm-based systems, namely the Virtual Memory System Architecture (VMSA) and the Protected Memory System Architecture (PMSA). According to ARM DDI 0487G.a, A VMSA provides a Memory Management Unit (MMU) that controls address translation, access permissions, and memory attribute determination and checking, for memory accesses made by the PE. And refer to ARM DDI 0600A.c, the PMSA supports a unified memory protection scheme where an Memory Protection Unit (MPU) manages instruction and data access. Currently, Xen only suuports VMSA.

As a preparation of the Xen MPU (PMSA) support. Introduce a Kconfig choice under the "Architecture Features" menu for user to choose the memory system architecture for the system. Since currently only VMSA is supported, only add the bool CONFIG_HAS_MMU to keep consistent with the default behavior. User can choose either VMSA or PMSA but not both in the future after PMSA/MPU is supported in Xen.

Quoted 2 lines

The patch looks good, but it does not cleanly apply

b4 mbox [email protected]

git am ./[email protected]

Applying: xen/arm: Introduce 'choice' for memory system architecture
error: xen/arch/arm/Kconfig: does not match index
Patch failed at 0001 xen/arm: Introduce 'choice' for memory system architecture

- Ayan

Quoted 36 lines

---
v4:
- Completely rework "[v3,06/52] xen/arm: introduce CONFIG_HAS_MMU"

---
  xen/arch/arm/Kconfig | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
xen/arch/arm/Kconfig +14 -1
index fd57a82dd2..0e38e9ba17 100644
@@ -59,6 +59,20 @@ config PADDR_BITS
         default 40 if ARM_PA_BITS_40
         default 48 if ARM_64
 
+choice
+       prompt "Memory system architecture"
+       default HAS_MMU
+       help
+         User can choose the memory system architecture.
+         A Virtual Memory System Architecture (VMSA) provides a Memory Management
+         Unit (MMU) that controls address translation, access permissions, and
+         memory attribute determination and checking, for memory accesses made by
+         the PE.
+
+config HAS_MMU
+       bool "MMU for a VMSA system"
+endchoice
+
  source "arch/Kconfig"
 
  config ACPI
--

2.25.1

author
#13 lore raw

Re: [PATCH v4 02/13] xen/arm: Introduce 'choice' for memory system architecture

Hi Ayan,

Quoted 30 lines · Ayan Kumar Halder

Hi Henry,

Quoted 20 lines · Henry Wang

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

There are two types of memory system architectures available for Arm-based systems, namely the Virtual Memory System Architecture (VMSA) and the Protected Memory System Architecture (PMSA). According to ARM DDI 0487G.a, A VMSA provides a Memory Management Unit (MMU) that controls address translation, access permissions, and memory attribute determination and checking, for memory accesses made by the PE. And refer to ARM DDI 0600A.c, the PMSA supports a unified memory protection scheme where an Memory Protection Unit (MPU) manages instruction and data access. Currently, Xen only suuports VMSA.

As a preparation of the Xen MPU (PMSA) support. Introduce a Kconfig choice under the "Architecture Features" menu for user to choose the memory system architecture for the system. Since currently only VMSA is supported, only add the bool CONFIG_HAS_MMU to keep consistent with the default behavior. User can choose either VMSA or PMSA but not both in the future after PMSA/MPU is supported in Xen.

Quoted 2 lines

The patch looks good, but it does not cleanly apply

Quoted 7 lines

b4 mbox [email protected]

git am ./[email protected]

Applying: xen/arm: Introduce 'choice' for memory system architecture
error: xen/arch/arm/Kconfig: does not match index
Patch failed at 0001 xen/arm: Introduce 'choice' for memory system architecture

This is weird, so I tried to apply this patch (by clicking the mbox button on the top right of [1]) on top of
65f0d6fc80 x86: Drop opt_pku entirely

and below is what I have:

$ git am ~/v4-02-13-xen-arm-Introduce-choice-for-memory-system-architecture.patch
Applying: xen/arm: Introduce 'choice' for memory system architecture

I suspect recently there is some Kconfig changes, so could you please clarify your base commit? Thanks!

[1] https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/

Kind regards,
Henry

Quoted 2 lines

- Ayan

#14 lore raw

Re: [PATCH v4 02/13] xen/arm: Introduce 'choice' for memory system architecture

In reply to Henry Wang

Hi Henry,

Quoted 10 lines · Henry Wang

There are two types of memory system architectures available for Arm-based systems, namely the Virtual Memory System Architecture (VMSA) and the Protected Memory System Architecture (PMSA). According to ARM DDI 0487G.a, A VMSA provides a Memory Management Unit (MMU) that controls address translation, access permissions, and memory attribute determination and checking, for memory accesses made by the PE. And refer to ARM DDI 0600A.c, the PMSA supports a unified memory protection scheme where an Memory Protection Unit (MPU) manages instruction and data access. Currently, Xen only suuports VMSA.

Quoted 6 lines

As a preparation of the Xen MPU (PMSA) support. Introduce a Kconfig choice under the "Architecture Features" menu for user to choose the memory system architecture for the system. Since currently only VMSA is supported, only add the bool CONFIG_HAS_MMU to keep consistent with the default behavior. User can choose either VMSA or PMSA but not both in the future after PMSA/MPU is supported in Xen.

So in the long run I agree that we will want to have a choice. But this seems to be a bit premature to introduce it now as the user can't select the MPU and also can't deselect MMU.

Therefore, I think it would be best if we introduce an unselectable config for now. Like:

HAS_MMU
def_bool y

This could be turned to a choice once you introduce the MPU.

Also, from my understanding, we are using the prefix HAS_ to indicate if an architecture support the given feature. In your case, you will want the user to select it, so I would just name the config MMU.

Cheers,

Signature · 1 line
Julien Grall
author
#15 lore raw

Re: [PATCH v4 02/13] xen/arm: Introduce 'choice' for memory system architecture

Hi Julien,

Quoted 23 lines · Julien Grall

Hi Henry,

Quoted 7 lines · Henry Wang

There are two types of memory system architectures available for Arm-based systems, namely the Virtual Memory System Architecture (VMSA) and the Protected Memory System Architecture (PMSA). According to ARM DDI 0487G.a, A VMSA provides a Memory Management Unit (MMU) that controls address translation, access permissions, and memory attribute determination and checking, for memory accesses made by the PE. And refer to ARM DDI 0600A.c, the PMSA supports a unified memory protection

Quoted 8 lines

scheme where an Memory Protection Unit (MPU) manages instruction and data access. Currently, Xen only suuports VMSA.
As a preparation of the Xen MPU (PMSA) support. Introduce a Kconfig choice under the "Architecture Features" menu for user to choose the memory system architecture for the system. Since currently only VMSA is supported, only add the bool CONFIG_HAS_MMU to keep consistent with the default behavior. User can choose either VMSA or PMSA but not both in the future after PMSA/MPU is supported in Xen.

So in the long run I agree that we will want to have a choice. But this seems to be a bit premature to introduce it now as the user can't select the MPU and also can't deselect MMU.

Quoted 8 lines

Therefore, I think it would be best if we introduce an unselectable config for now. Like:

HAS_MMU
def_bool y

This could be turned to a choice once you introduce the MPU.

Also, from my understanding, we are using the prefix HAS_ to indicate if an architecture support the given feature. In your case, you will want the user to select it, so I would just name the config MMU.

Make sense, I will just introduce a

MMU
def_bool y

in this patch and turn this to a choice between CONFIG_MMU and CONFIG_MPU in the last patch of the full MPU series where MPU is expected to be functional.

Kind regards,
Henry

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall
author
#16 lore raw

PATCH v4 3/13 xen/arm64: prepare for moving MMU related code from head.S

In reply to Henry Wang

From: Wei Chen <[email protected]>

We want to reuse head.S for MPU systems, but there are some code are implemented for MMU systems only. We will move such code to another MMU specific file. But before that we will do some indentations fix in this patch to make them be easier for reviewing:
1. Fix the indentations and incorrect style of code comments.
2. Fix the indentations for .text.header section.
3. Rename puts() to asm_puts() for global export

---
v4:
- Rebase to pick the adr -> adr_l change in PRINT(_s).
- Correct in-code comment for asm_puts() and add a note to mention that asm_puts() should be only called from assembly.
- Drop redundant puts (now asm_puts) under CONFIG_EARLY_PRINTK. v3:
- fix commit message
- Rename puts() to asm_puts() for global export
v2:
- New patch.

---
 xen/arch/arm/arm64/head.S | 46 ++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 22 deletions(-)
xen/arch/arm/arm64/head.S +24 -22
index 2af9f974d5..b29bffce5b 100644
@@ -94,7 +94,7 @@
 #define PRINT(_s)          \
         mov   x3, lr ;     \
         adr_l x0, 98f ;    \
-        bl    puts    ;    \
+        bl    asm_puts ;   \
         mov   lr, x3 ;     \
         RODATA_STR(98, _s)
 
@@ -136,21 +136,21 @@
         add \xb, \xb, x20
 .endm
 
-        .section .text.header, "ax", %progbits
-        /*.aarch64*/
+.section .text.header, "ax", %progbits
+/*.aarch64*/
 
-        /*
-         * Kernel startup entry point.
-         * ---------------------------
-         *
-         * The requirements are:
-         *   MMU = off, D-cache = off, I-cache = on or off,
-         *   x0 = physical address to the FDT blob.
-         *
-         * This must be the very first address in the loaded image.
-         * It should be linked at XEN_VIRT_START, and loaded at any
-         * 4K-aligned address.
-         */
+/*
+ * Kernel startup entry point.
+ * ---------------------------
+ *
+ * The requirements are:
+ *   MMU = off, D-cache = off, I-cache = on or off,
+ *   x0 = physical address to the FDT blob.
+ *
+ * This must be the very first address in the loaded image.
+ * It should be linked at XEN_VIRT_START, and loaded at any
+ * 4K-aligned address.
+ */
 
 GLOBAL(start)
         /*
@@ -535,7 +535,7 @@ ENDPROC(cpu_init)
  * Macro to create a mapping entry in \tbl to \phys. Only mapping in 3rd
  * level table (i.e page granularity) is supported.
  *
- * ptbl:     table symbol where the entry will be created
+ * ptbl:    table symbol where the entry will be created
  * virt:    virtual address
  * phys:    physical address (should be page aligned)
  * tmp1:    scratch register
@@ -970,19 +970,22 @@ init_uart:
         ret
 ENDPROC(init_uart)
 
-/* Print early debug messages.
+/*
+ * Print early debug messages.
+ * Note: This function is only supposed to be called from assembly.
  * x0: Nul-terminated string to print.
  * x23: Early UART base address
- * Clobbers x0-x1 */
-puts:
+ * Clobbers x0-x1
+ */
+ENTRY(asm_puts)
         early_uart_ready x23, 1
         ldrb  w1, [x0], #1           /* Load next char */
         cbz   w1, 1f                 /* Exit on nul */
         early_uart_transmit x23, w1
-        b     puts
+        b     asm_puts
 1:
         ret
-ENDPROC(puts)
+ENDPROC(asm_puts)
 
 /*
  * Print a 64-bit number in hex.
@@ -1012,7 +1015,6 @@ hex:    .ascii "0123456789abcdef"
 
 ENTRY(early_puts)
 init_uart:
-puts:
 putn:   ret
 
 #endif /* !CONFIG_EARLY_PRINTK */
Signature · 1 line
2.25.1
Reviewed-by on v4 3/13
#17 lore raw

Re: [PATCH v4 03/13] xen/arm64: prepare for moving MMU related code from head.S

Quoted 14 lines · Henry Wang

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

From: Wei Chen <[email protected]>

We want to reuse head.S for MPU systems, but there are some code are implemented for MMU systems only. We will move such code to another MMU specific file. But before that we will do some indentations fix in this patch to make them be easier for reviewing:
1. Fix the indentations and incorrect style of code comments.
2. Fix the indentations for .text.header section.
3. Rename puts() to asm_puts() for global export

Quoted 3 lines
Quoted 113 lines

---
v4:
- Rebase to pick the adr -> adr_l change in PRINT(_s).
- Correct in-code comment for asm_puts() and add a note to mention that asm_puts() should be only called from assembly.
- Drop redundant puts (now asm_puts) under CONFIG_EARLY_PRINTK. v3:

(quoted diff) +0 -2
-  fix commit message
-  Rename puts() to asm_puts() for global export

v2:

(quoted diff) +0 -2
-  New patch.
---
  xen/arch/arm/arm64/head.S | 46 ++++++++++++++++++++-------------------
  1 file changed, 24 insertions(+), 22 deletions(-)
xen/arch/arm/arm64/head.S +24 -23
index 2af9f974d5..b29bffce5b 100644
@@ -94,7 +94,7 @@
  #define PRINT(_s)          \
          mov   x3, lr ;     \
          adr_l x0, 98f ;    \
-        bl    puts    ;    \
+        bl    asm_puts ;   \
          mov   lr, x3 ;     \
          RODATA_STR(98, _s)
 
@@ -136,21 +136,21 @@
          add \xb, \xb, x20
  .endm
 
-        .section .text.header, "ax", %progbits
-        /*.aarch64*/
+.section .text.header, "ax", %progbits
+/*.aarch64*/
 
-        /*
-         * Kernel startup entry point.
-         * ---------------------------
-         *
-         * The requirements are:
-         *   MMU = off, D-cache = off, I-cache = on or off,
-         *   x0 = physical address to the FDT blob.
-         *
-         * This must be the very first address in the loaded image.
-         * It should be linked at XEN_VIRT_START, and loaded at any
-         * 4K-aligned address.
-         */
+/*
+ * Kernel startup entry point.
+ * ---------------------------
+ *
+ * The requirements are:
+ *   MMU = off, D-cache = off, I-cache = on or off,
+ *   x0 = physical address to the FDT blob.
+ *
+ * This must be the very first address in the loaded image.
+ * It should be linked at XEN_VIRT_START, and loaded at any
+ * 4K-aligned address.
+ */
 
  GLOBAL(start)
          /*
@@ -535,7 +535,7 @@ ENDPROC(cpu_init)
   * Macro to create a mapping entry in \tbl to \phys. Only mapping in 3rd
   * level table (i.e page granularity) is supported.
   *
- * ptbl:     table symbol where the entry will be created
+ * ptbl:    table symbol where the entry will be created
   * virt:    virtual address
   * phys:    physical address (should be page aligned)
   * tmp1:    scratch register
@@ -970,19 +970,22 @@ init_uart:
          ret
  ENDPROC(init_uart)
 
-/* Print early debug messages.
+/*
+ * Print early debug messages.
+ * Note: This function is only supposed to be called from assembly.
   * x0: Nul-terminated string to print.
   * x23: Early UART base address
- * Clobbers x0-x1 */
-puts:
+ * Clobbers x0-x1
+ */
+ENTRY(asm_puts)
          early_uart_ready x23, 1
          ldrb  w1, [x0], #1           /* Load next char */
          cbz   w1, 1f                 /* Exit on nul */
          early_uart_transmit x23, w1
-        b     puts
+        b     asm_puts
  1:
          ret
-ENDPROC(puts)
+ENDPROC(asm_puts)
 
  /*
   * Print a 64-bit number in hex.
@@ -1012,7 +1015,6 @@ hex:    .ascii "0123456789abcdef"
 
  ENTRY(early_puts)
  init_uart:
-puts:
  putn:   ret
 
  #endif /* !CONFIG_EARLY_PRINTK */
--

2.25.1

Reviewed-by on v4 3/13
#18 lore raw

Re: [PATCH v4 03/13] xen/arm64: prepare for moving MMU related code from head.S

In reply to Henry Wang

Hi Henry,

Quoted 11 lines · Henry Wang

From: Wei Chen <[email protected]>

We want to reuse head.S for MPU systems, but there are some code are implemented for MMU systems only. We will move such code to another MMU specific file. But before that we will do some indentations fix in this patch to make them be easier for reviewing:
1. Fix the indentations and incorrect style of code comments.
2. Fix the indentations for .text.header section.
3. Rename puts() to asm_puts() for global export

Quoted 3 lines

With one remark below:

Quoted 74 lines

---
v4:
- Rebase to pick the adr -> adr_l change in PRINT(_s).
- Correct in-code comment for asm_puts() and add a note to mention that asm_puts() should be only called from assembly.
- Drop redundant puts (now asm_puts) under CONFIG_EARLY_PRINTK. v3:

(quoted diff) +0 -2
-  fix commit message
-  Rename puts() to asm_puts() for global export

v2:

(quoted diff) +0 -2
-  New patch.
---
  xen/arch/arm/arm64/head.S | 46 ++++++++++++++++++++-------------------
  1 file changed, 24 insertions(+), 22 deletions(-)
xen/arch/arm/arm64/head.S +16 -16
index 2af9f974d5..b29bffce5b 100644
@@ -94,7 +94,7 @@
  #define PRINT(_s)          \
          mov   x3, lr ;     \
          adr_l x0, 98f ;    \
-        bl    puts    ;    \
+        bl    asm_puts ;   \
          mov   lr, x3 ;     \
          RODATA_STR(98, _s)
 
@@ -136,21 +136,21 @@
          add \xb, \xb, x20
  .endm
 
-        .section .text.header, "ax", %progbits
-        /*.aarch64*/
+.section .text.header, "ax", %progbits
+/*.aarch64*/
 
-        /*
-         * Kernel startup entry point.
-         * ---------------------------
-         *
-         * The requirements are:
-         *   MMU = off, D-cache = off, I-cache = on or off,
-         *   x0 = physical address to the FDT blob.
-         *
-         * This must be the very first address in the loaded image.
-         * It should be linked at XEN_VIRT_START, and loaded at any
-         * 4K-aligned address.
-         */
+/*
+ * Kernel startup entry point.
+ * ---------------------------
+ *
+ * The requirements are:
+ *   MMU = off, D-cache = off, I-cache = on or off,
+ *   x0 = physical address to the FDT blob.
+ *
+ * This must be the very first address in the loaded image.
+ * It should be linked at XEN_VIRT_START, and loaded at any
+ * 4K-aligned address.
+ */
 
  GLOBAL(start)
          /*
@@ -535,7 +535,7 @@ ENDPROC(cpu_init)
   * Macro to create a mapping entry in \tbl to \phys. Only mapping in 3rd
   * level table (i.e page granularity) is supported.
   *
- * ptbl:     table symbol where the entry will be created
+ * ptbl:    table symbol where the entry will be created
   * virt:    virtual address
   * phys:    physical address (should be page aligned)
   * tmp1:    scratch register

xen/arch/arm/arm64/head.S init_uart: · line 975

Quoted 7 lines
xen/arch/arm/arm64/head.S +3 -1
@@ -970,19 +970,22 @@ init_uart:
          ret
  ENDPROC(init_uart)
 
-/* Print early debug messages.
+/*
+ * Print early debug messages.
+ * Note: This function is only supposed to be called from assembly.

I realize the wording is just a copy of what I wrote earlier on. But I would use 'must' as this is a stronger than 'is supposed to'.

This can be dealt on commit if there is nothing else to change.

Cheers,

Signature · 1 line
Julien Grall
author
#19 lore raw

Re: [PATCH v4 03/13] xen/arm64: prepare for moving MMU related code from head.S

Hi Julien,

Quoted 18 lines · Julien Grall

Hi Henry,

Quoted 9 lines · Henry Wang

From: Wei Chen <[email protected]>
We want to reuse head.S for MPU systems, but there are some code are implemented for MMU systems only. We will move such code to another MMU specific file. But before that we will do some indentations fix in this patch to make them be easier for reviewing:
1. Fix the indentations and incorrect style of code comments.
2. Fix the indentations for .text.header section.
3. Rename puts() to asm_puts() for global export

Quoted 3 lines
Quoted 3 lines

With one remark below:

Thanks! I have taken this tag with...

Quoted 8 lines
Quoted 6 lines

-/* Print early debug messages.
+/*
+ * Print early debug messages.
+ * Note: This function is only supposed to be called from assembly.

I realize the wording is just a copy of what I wrote earlier on. But I would use 'must' as this is a stronger than 'is supposed to'.

…this fixed locally.

Quoted 2 lines

This can be dealt on commit if there is nothing else to change.

Either way works for me, maybe you can add this patch to your queue for your next round of committing. If I don’t see this patch being committed by the time when I send v5, I will keep this patch in the v5 series and send it with your Reviewed-by tag.

Kind regards,
Henry

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall
author
#20 lore raw

PATCH v4 4/13 xen/arm64: Split and move MMU-specific head.S to mmu/head.S

In reply to Henry Wang

The MMU specific code in head.S will not be used on MPU systems. Instead of introducing more #ifdefs which will bring complexity to the code, move MMU related code to mmu/head.S and keep common code in head.S. Two notes while moving:
- As "fail" in original head.S is very simple and this name is too easy to be conflicted, duplicate it in mmu/head.S instead of exporting it.
- Use ENTRY() for enable_secondary_cpu_mm, enable_boot_cpu_mm and setup_fixmap to please the compiler after the code movement.

Also move the assembly macros shared by head.S and mmu/head.S to macros.h.

Note that, only the first 4KB of Xen image will be mapped as identity (PA == VA). At the moment, Xen guarantees this by having everything that needs to be used in the identity mapping in .text.header section of head.S, and the size will be checked by _idmap_start and _idmap_end at link time if this fits in 4KB. Since we are introducing a new head.S in this patch, although we can add .text.header to the new file to guarantee all identity map code still in the first 4KB. However, the order of these two files on this 4KB depends on the build toolchains. Hence, introduce a new section named .text.idmap in the region between _idmap_start and _idmap_end. And in Xen linker script, we force the .text.idmap contents to linked after .text.header. This will ensure code of head.S always be at the top of Xen binary.

---
v4:
- Rework "[v3,08/52] xen/arm64: move MMU related code from head.S to mmu/head.S"
- Don't move the "yet to shared" macro such as print_reg.
- Fold "[v3,04/52] xen/arm: add .text.idmap in ld script for Xen identity map sections" to this patch. Rework commit msg.

---
 xen/arch/arm/arm64/Makefile             |   1 +
 xen/arch/arm/arm64/head.S               | 497 +-----------------------
 xen/arch/arm/arm64/mmu/Makefile         |   1 +
 xen/arch/arm/arm64/mmu/head.S           | 487 +++++++++++++++++++++++
 xen/arch/arm/include/asm/arm64/macros.h |  36 ++
 xen/arch/arm/xen.lds.S                  |   1 +
 6 files changed, 527 insertions(+), 496 deletions(-)
 create mode 100644 xen/arch/arm/arm64/mmu/Makefile
 create mode 100644 xen/arch/arm/arm64/mmu/head.S
xen/arch/arm/arm64/Makefile +1 -0
index 54ad55c75c..ce8749f046 100644
@@ -1,4 +1,5 @@
 obj-y += lib/
+obj-$(CONFIG_HAS_MMU) += mmu/
 
 obj-y += cache.o
 obj-y += cpufeature.o
xen/arch/arm/arm64/head.S +1 -496

532 lines not on this page · raw message

xen/arch/arm/arm64/mmu/Makefile new file +1 -0
new file mode 100644
index 0000000000..3340058c08
@@ -0,0 +1 @@
+obj-y += head.o
xen/arch/arm/arm64/mmu/head.S new file +487 -0

487 lines not on this page · raw message

xen/arch/arm/include/asm/arm64/macros.h +36 -0
index 140e223b4c..99c401fcaf 100644
@@ -32,6 +32,42 @@
         hint    #22
     .endm
 
+#ifdef CONFIG_EARLY_PRINTK
+/*
+ * Macro to print a string to the UART, if there is one.
+ *
+ * Clobbers x0 - x3
+ */
+#define PRINT(_s)          \
+        mov   x3, lr ;     \
+        adr_l x0, 98f ;    \
+        bl    asm_puts ;   \
+        mov   lr, x3 ;     \
+        RODATA_STR(98, _s)
+
+#else /* CONFIG_EARLY_PRINTK */
+#define PRINT(s)
+
+#endif /* !CONFIG_EARLY_PRINTK */
+
+/*
+ * Pseudo-op for PC relative adr <reg>, <symbol> where <symbol> is
+ * within the range +/- 4GB of the PC.
+ *
+ * @dst: destination register (64 bit wide)
+ * @sym: name of the symbol
+ */
+.macro  adr_l, dst, sym
+        adrp \dst, \sym
+        add  \dst, \dst, :lo12:\sym
+.endm
+
+/* Load the physical address of a symbol into xb */
+.macro load_paddr xb, sym
+        ldr \xb, =\sym
+        add \xb, \xb, x20
+.endm
+
 /*
  * Register aliases.
  */
xen/arch/arm/xen.lds.S +1 -0
index a3c90ca823..59b80d122f 100644
@@ -34,6 +34,7 @@ SECTIONS
        _stext = .;             /* Text section */
        _idmap_start = .;
        *(.text.header)
+       *(.text.idmap)
        _idmap_end = .;
 
        *(.text.cold)
Signature · 1 line
2.25.1
author
#21 lore raw

PATCH v4 5/13 xen/arm: Move MMU related definitions from config.h to mmu/layout.h

In reply to Henry Wang

From: Wei Chen <[email protected]>

Xen defines some global configuration macros for Arm in config.h. However there are some address layout related definitions that are defined for MMU systems only, and these definitions could not be used by MPU systems. Adding ifdefs with CONFIG_HAS_MPU to gate these definitions will result in a messy and hard-to-read/maintain code.

So move MMU related definitions to a new file, i.e. mmu/layout.h to avoid spreading "#ifdef" everywhere.

---
v4:
- Rebase on top of latest staging to pick the recent UBSAN change to the layout.
- Use #ifdef CONFIG_HAS_MMU instead of #ifndef CONFIG_HAS_MPU, add a #else case.
- Rework commit message.
v3:
- name the new header layout.h
v2:
- Remove duplicated FIXMAP definitions from config_mmu.h

---
 xen/arch/arm/include/asm/config.h     | 132 +----------------------
 xen/arch/arm/include/asm/mmu/layout.h | 146 ++++++++++++++++++++++++++
 2 files changed, 149 insertions(+), 129 deletions(-)
 create mode 100644 xen/arch/arm/include/asm/mmu/layout.h
xen/arch/arm/include/asm/config.h +3 -129
index 83cbf6b0cb..a3cde7f2d7 100644
@@ -71,136 +71,10 @@
 #include <xen/const.h>
 #include <xen/page-size.h>
 
-/*
- * ARM32 layout:
- *   0  -   2M   Unmapped
- *   2M -  10M   Xen text, data, bss
- *  10M -  12M   Fixmap: special-purpose 4K mapping slots
- *  12M -  16M   Early boot mapping of FDT
- *  16M -  18M   Livepatch vmap (if compiled in)
- *
- *  32M - 128M   Frametable: 32 bytes per page for 12GB of RAM
- * 256M -   1G   VMAP: ioremap and early_ioremap use this virtual address
- *                    space
- *
- *   1G -   2G   Xenheap: always-mapped memory
- *   2G -   4G   Domheap: on-demand-mapped
- *
- * ARM64 layout:
- * 0x0000000000000000 - 0x000001ffffffffff (2TB, L0 slots [0..3])
- *
- *  Reserved to identity map Xen
- *
- * 0x0000020000000000 - 0x0000027fffffffff (512GB, L0 slot [4])
- *  (Relative offsets)
- *   0  -   2M   Unmapped
- *   2M -  10M   Xen text, data, bss
- *  10M -  12M   Fixmap: special-purpose 4K mapping slots
- *  12M -  16M   Early boot mapping of FDT
- *  16M -  18M   Livepatch vmap (if compiled in)
- *
- *   1G -   2G   VMAP: ioremap and early_ioremap
- *
- *  32G -  64G   Frametable: 56 bytes per page for 2TB of RAM
- *
- * 0x0000028000000000 - 0x00007fffffffffff (125TB, L0 slots [5..255])
- *  Unused
- *
- * 0x0000800000000000 - 0x000084ffffffffff (5TB, L0 slots [256..265])
- *  1:1 mapping of RAM
- *
- * 0x0000850000000000 - 0x0000ffffffffffff (123TB, L0 slots [266..511])
- *  Unused
- */
-
-#ifdef CONFIG_ARM_32
-#define XEN_VIRT_START          _AT(vaddr_t, MB(2))
+#ifdef CONFIG_HAS_MMU
+#include <asm/mmu/layout.h>
 #else
-
-#define SLOT0_ENTRY_BITS  39
-#define SLOT0(slot) (_AT(vaddr_t,slot) << SLOT0_ENTRY_BITS)
-#define SLOT0_ENTRY_SIZE  SLOT0(1)
-
-#define XEN_VIRT_START          (SLOT0(4) + _AT(vaddr_t, MB(2)))
-#endif
-
-/*
- * Reserve enough space so both UBSAN and GCOV can be enabled together
- * plus some slack for future growth.
- */
-#define XEN_VIRT_SIZE           _AT(vaddr_t, MB(8))
-#define XEN_NR_ENTRIES(lvl)     (XEN_VIRT_SIZE / XEN_PT_LEVEL_SIZE(lvl))
-
-#define FIXMAP_VIRT_START       (XEN_VIRT_START + XEN_VIRT_SIZE)
-#define FIXMAP_VIRT_SIZE        _AT(vaddr_t, MB(2))
-
-#define FIXMAP_ADDR(n)          (FIXMAP_VIRT_START + (n) * PAGE_SIZE)
-
-#define BOOT_FDT_VIRT_START     (FIXMAP_VIRT_START + FIXMAP_VIRT_SIZE)
-#define BOOT_FDT_VIRT_SIZE      _AT(vaddr_t, MB(4))
-
-#ifdef CONFIG_LIVEPATCH
-#define LIVEPATCH_VMAP_START    (BOOT_FDT_VIRT_START + BOOT_FDT_VIRT_SIZE)
-#define LIVEPATCH_VMAP_SIZE    _AT(vaddr_t, MB(2))
-#endif
-
-#define HYPERVISOR_VIRT_START  XEN_VIRT_START
-
-#ifdef CONFIG_ARM_32
-
-#define CONFIG_SEPARATE_XENHEAP 1
-
-#define FRAMETABLE_VIRT_START  _AT(vaddr_t, MB(32))
-#define FRAMETABLE_SIZE        MB(128-32)
-#define FRAMETABLE_NR          (FRAMETABLE_SIZE / sizeof(*frame_table))
-
-#define VMAP_VIRT_START        _AT(vaddr_t, MB(256))
-#define VMAP_VIRT_SIZE         _AT(vaddr_t, GB(1) - MB(256))
-
-#define XENHEAP_VIRT_START     _AT(vaddr_t, GB(1))
-#define XENHEAP_VIRT_SIZE      _AT(vaddr_t, GB(1))
-
-#define DOMHEAP_VIRT_START     _AT(vaddr_t, GB(2))
-#define DOMHEAP_VIRT_SIZE      _AT(vaddr_t, GB(2))
-
-#define DOMHEAP_ENTRIES        1024  /* 1024 2MB mapping slots */
-
-/* Number of domheap pagetable pages required at the second level (2MB mappings) */
-#define DOMHEAP_SECOND_PAGES (DOMHEAP_VIRT_SIZE >> FIRST_SHIFT)
-
-/*
- * The temporary area is overlapping with the domheap area. This may
- * be used to create an alias of the first slot containing Xen mappings
- * when turning on/off the MMU.
- */
-#define TEMPORARY_AREA_FIRST_SLOT    (first_table_offset(DOMHEAP_VIRT_START))
-
-/* Calculate the address in the temporary area */
-#define TEMPORARY_AREA_ADDR(addr)                           \
-     (((addr) & ~XEN_PT_LEVEL_MASK(1)) |                    \
-      (TEMPORARY_AREA_FIRST_SLOT << XEN_PT_LEVEL_SHIFT(1)))
-
-#define TEMPORARY_XEN_VIRT_START    TEMPORARY_AREA_ADDR(XEN_VIRT_START)
-
-#else /* ARM_64 */
-
-#define IDENTITY_MAPPING_AREA_NR_L0  4
-
-#define VMAP_VIRT_START  (SLOT0(4) + GB(1))
-#define VMAP_VIRT_SIZE   GB(1)
-
-#define FRAMETABLE_VIRT_START  (SLOT0(4) + GB(32))
-#define FRAMETABLE_SIZE        GB(32)
-#define FRAMETABLE_NR          (FRAMETABLE_SIZE / sizeof(*frame_table))
-
-#define DIRECTMAP_VIRT_START   SLOT0(256)
-#define DIRECTMAP_SIZE         (SLOT0_ENTRY_SIZE * (266 - 256))
-#define DIRECTMAP_VIRT_END     (DIRECTMAP_VIRT_START + DIRECTMAP_SIZE - 1)
-
-#define XENHEAP_VIRT_START     directmap_virt_start
-
-#define HYPERVISOR_VIRT_END    DIRECTMAP_VIRT_END
-
+# error "Unknown memory management layout"
 #endif
 
 #define NR_hypercalls 64
xen/arch/arm/include/asm/mmu/layout.h new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v4 5/13
#22 lore raw

Re: [PATCH v4 05/13] xen/arm: Move MMU related definitions from config.h to mmu/layout.h

Hi Henry,

Quoted 6 lines · Henry Wang

From: Wei Chen <[email protected]>

Xen defines some global configuration macros for Arm in config.h. However there are some address layout related definitions that are defined for MMU systems only, and these definitions could not be used by MPU systems. Adding ifdefs with CONFIG_HAS_MPU to gate these

You haven't yet introduced HAS_MPU. So I would suggest to write: 'Adding ifdefs to differentiate the MPU from MMU layout will result in a ...'.

Quoted 4 lines

definitions will result in a messy and hard-to-read/maintain code.

So move MMU related definitions to a new file, i.e. mmu/layout.h to avoid spreading "#ifdef" everywhere.

AFAICT, you are moving all memory layout definition in a separate file. So I would say it explicitely rather than using "MMU related definitions".

Quoted 4 lines

With the comments addressed:

Cheers,

Signature · 1 line
Julien Grall
author
#23 lore raw

Re: [PATCH v4 05/13] xen/arm: Move MMU related definitions from config.h to mmu/layout.h

Hi Julien,

Quoted 19 lines · Julien Grall

Hi Henry,

Quoted 5 lines · Henry Wang

From: Wei Chen <[email protected]>
Xen defines some global configuration macros for Arm in config.h. However there are some address layout related definitions that are defined for MMU systems only, and these definitions could not be used by MPU systems. Adding ifdefs with CONFIG_HAS_MPU to gate these

You haven't yet introduced HAS_MPU. So I would suggest to write: 'Adding ifdefs to differentiate the MPU from MMU layout will result in a ...'.

Quoted 3 lines

definitions will result in a messy and hard-to-read/maintain code. So move MMU related definitions to a new file, i.e. mmu/layout.h to avoid spreading "#ifdef" everywhere.

AFAICT, you are moving all memory layout definition in a separate file. So I would say it explicitely rather than using "MMU related definitions".

Quoted 7 lines
Quoted 3 lines

With the comments addressed:

Thanks, I’ve taken this tag with above two comments fixed.

Kind regards,
Henry

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall
author
#24 lore raw

PATCH v4 6/13 xen/arm64: Move setup_fixmap() to create_page_tables()

In reply to Henry Wang

The original assembly setup_fixmap() is actually doing two seperate tasks, one is enabling the early UART when earlyprintk on, and the other is to set up the fixmap (even when earlyprintk is off).

Per discussion in [1], since commit
9d267c049d92 ("xen/arm64: Rework the memory layout"), there is no chance that the fixmap and the mapping of early UART will clash with the 1:1 mapping. Therefore the mapping of both the fixmap and the early UART can be moved to the end of create_pagetables(). For the future MPU support work, the early UART mapping could then be moved in prepare_early_mappings().

No functional change intended.

[1] https://lore.kernel.org/xen-devel/[email protected]/

---
v4:
- Rework "[v3,12/52] xen/mmu: extract early uart mapping from setup_fixmap"

---
 xen/arch/arm/arm64/head.S     |  1 -
 xen/arch/arm/arm64/mmu/head.S | 50 ++++++++++++-----------------------
 2 files changed, 17 insertions(+), 34 deletions(-)
xen/arch/arm/arm64/head.S +0 -1
index e4f579a48e..56f68a8e37 100644
@@ -275,7 +275,6 @@ real_start_efi:
         b     enable_boot_cpu_mm
 
 primary_switched:
-        bl    setup_fixmap
 #ifdef CONFIG_EARLY_PRINTK
         /* Use a virtual address to access the UART. */
         ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
xen/arch/arm/arm64/mmu/head.S +17 -33

62 lines not on this page · raw message

Signature · 1 line
2.25.1
#25 lore raw

Re: [PATCH v4 06/13] xen/arm64: Move setup_fixmap() to create_page_tables()

Hi Henry,

Title: NIT: It is more a fold rather than move.

Quoted 3 lines · Henry Wang

For the
future MPU support work, the early UART mapping could then be moved in prepare_early_mappings().

I would drop this sentence as this is more related to the future implementation of MPU rather than this patch itself.

xen/arch/arm/arm64/mmu/head.S

Quoted 30 lines

No functional change intended.

[1] https://lore.kernel.org/xen-devel/[email protected]/

---
v4:
- Rework "[v3,12/52] xen/mmu: extract early uart mapping from setup_fixmap"

---
  xen/arch/arm/arm64/head.S     |  1 -
  xen/arch/arm/arm64/mmu/head.S | 50 ++++++++++++-----------------------
  2 files changed, 17 insertions(+), 34 deletions(-)
xen/arch/arm/arm64/head.S +0 -1
index e4f579a48e..56f68a8e37 100644
@@ -275,7 +275,6 @@ real_start_efi:
          b     enable_boot_cpu_mm
 
  primary_switched:
-        bl    setup_fixmap
  #ifdef CONFIG_EARLY_PRINTK
          /* Use a virtual address to access the UART. */
          ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
xen/arch/arm/arm64/mmu/head.S +0 -0
index b7c3dd423a..6bd94c3a45 100644

The second paragraph in create_page_tables() now needs to be dropped.

Quoted 11 lines
xen/arch/arm/arm64/mmu/head.S +7 -0
@@ -231,6 +231,23 @@ link_from_second_id:
          create_table_entry boot_second_id, boot_third_id, x19, 2, x0, x1, x2
  link_from_third_id:
          create_mapping_entry boot_third_id, x19, x19, x0, x1, x2
+
+#ifdef CONFIG_EARLY_PRINTK
+        /* Add UART to the fixmap table */
+        ldr   x0, =EARLY_UART_VIRTUAL_ADDRESS
+        /* x23: Early UART base physical address */
+        create_mapping_entry xen_fixmap, x0, x23, x1, x2, x3, type=PT_DEV_L3
+#endif

xen/arch/arm/arm64/mmu/head.S link_from_second_id: · line 250

Quoted 10 lines
xen/arch/arm/arm64/mmu/head.S +10 -0
+        /* Map fixmap into boot_second */
+        ldr   x0, =FIXMAP_ADDR(0)
+        create_table_entry boot_second, xen_fixmap, x0, 2, x1, x2, x3
+        /* Ensure any page table updates made above have occurred. */
+        dsb   nshst
+        /*
+         * The fixmap area will be used soon after. So ensure no hardware
+         * translation happens before the dsb completes.
+         */
+        isb

The DSB/ISB is not necessary anymore as you are not modifying live page-tables. So I would prefer if this is removed.

Cheers,

Signature · 1 line
Julien Grall
author
#26 lore raw

Re: [PATCH v4 06/13] xen/arm64: Move setup_fixmap() to create_page_tables()

Hi Julien,

Quoted 5 lines · Julien Grall

Hi Henry,

Title: NIT: It is more a fold rather than move.

You are correct, using “fold” here is more appropriate.

Quoted 7 lines · Henry Wang
Quoted 3 lines

For the
future MPU support work, the early UART mapping could then be moved in prepare_early_mappings().

I would drop this sentence as this is more related to the future implementation of MPU rather than this patch itself.

Sure, v5 will drop this.

Quoted 20 lines
Quoted 20 lines

No functional change intended.
[1] https://lore.kernel.org/xen-devel/[email protected]/

---
v4:
- Rework "[v3,12/52] xen/mmu: extract early uart mapping from setup_fixmap"

---
 xen/arch/arm/arm64/head.S     |  1 -
 xen/arch/arm/arm64/mmu/head.S | 50 ++++++++++++-----------------------
 2 files changed, 17 insertions(+), 34 deletions(-)
xen/arch/arm/arm64/head.S +0 -1
index e4f579a48e..56f68a8e37 100644
@@ -275,7 +275,6 @@ real_start_efi:
         b     enable_boot_cpu_mm
   primary_switched:
-        bl    setup_fixmap
 #ifdef CONFIG_EARLY_PRINTK
Quoted 8 lines

xen/arch/arm/arm64/mmu/head.S

Quoted 6 lines
xen/arch/arm/arm64/head.S +0 -0
         /* Use a virtual address to access the UART. */
         ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
xen/arch/arm/arm64/mmu/head.S +0 -0
index b7c3dd423a..6bd94c3a45 100644

The second paragraph in create_page_tables() now needs to be dropped.

Thanks for finding this! Yes this should be dropped.

Quoted 16 lines
Quoted 16 lines
xen/arch/arm/arm64/mmu/head.S +11 -0
@@ -231,6 +231,23 @@ link_from_second_id:
         create_table_entry boot_second_id, boot_third_id, x19, 2, x0, x1, x2
 link_from_third_id:
         create_mapping_entry boot_third_id, x19, x19, x0, x1, x2
+
+#ifdef CONFIG_EARLY_PRINTK
+        /* Add UART to the fixmap table */
+        ldr   x0, =EARLY_UART_VIRTUAL_ADDRESS
+        /* x23: Early UART base physical address */
+        create_mapping_entry xen_fixmap, x0, x23, x1, x2, x3, type=PT_DEV_L3
+#endif
+        /* Map fixmap into boot_second */
+        ldr   x0, =FIXMAP_ADDR(0)
+        create_table_entry boot_second, xen_fixmap, x0, 2, x1, x2, x3
+        /* Ensure any page table updates made above have occurred. */
Quoted 8 lines

xen/arch/arm/arm64/mmu/head.S link_from_second_id: · line 250

Quoted 6 lines
xen/arch/arm/arm64/mmu/head.S +6 -0
+        dsb   nshst
+        /*
+         * The fixmap area will be used soon after. So ensure no hardware
+         * translation happens before the dsb completes.
+         */
+        isb

The DSB/ISB is not necessary anymore as you are not modifying live page-tables. So I would prefer if this is removed.

Sure.

Kind regards,
Henry

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall
author
#27 lore raw

PATCH v4 7/13 xen/arm: Extract MMU-specific code

In reply to Henry Wang

Currently, most of the MMU-specific code is in mm.{c,h}. To make the mm extendable, this commit extract the MMU-specific code by firstly:
- Create a arch/arm/include/asm/mmu/ subdir.
- Create a arch/arm/mmu/ subdir.

Then move the MMU-specific code to above mmu subdir, which includes below changes:
- Move arch/arm/arm64/mm.c to arch/arm/arm64/mmu/mm.c
- Move MMU-related declaration in arch/arm/include/asm/mm.h to arch/arm/include/asm/mmu/mm.h
- Move the MMU-related declaration dump_pt_walk() in asm/page.h and pte_of_xenaddr() in asm/setup.h to the new asm/mmu/mm.h.
- Move MMU-related code in arch/arm/mm.c to arch/arm/mmu/mm.c.

Also modify the build system (Makefiles in this case) to pick above mentioned code changes.

This patch is a pure code movement, no functional change intended.

---
With the code movement of this patch, the descriptions on top of xen/arch/arm/mm.c and xen/arch/arm/mmu/mm.c might need some changes, suggestions?
v4:
- Rework "[v3,13/52] xen/mmu: extract mmu-specific codes from mm.c/mm.h" with the lastest staging branch, only do the code movement in this patch to ease the review.

---
 xen/arch/arm/Makefile             |    1 +
 xen/arch/arm/arm64/Makefile       |    1 -
 xen/arch/arm/arm64/mmu/Makefile   |    1 +
 xen/arch/arm/arm64/{ => mmu}/mm.c |    0
 xen/arch/arm/include/asm/mm.h     |   20 +-
 xen/arch/arm/include/asm/mmu/mm.h |   55 ++
 xen/arch/arm/include/asm/page.h   |   15 -
 xen/arch/arm/include/asm/setup.h  |    3 -
 xen/arch/arm/mm.c                 | 1119 ----------------------------
 xen/arch/arm/mmu/Makefile         |    1 +
 xen/arch/arm/mmu/mm.c             | 1146 +++++++++++++++++++++++++++++
 11 files changed, 1208 insertions(+), 1154 deletions(-)
 rename xen/arch/arm/arm64/{ => mmu}/mm.c (100%)
 create mode 100644 xen/arch/arm/include/asm/mmu/mm.h
 create mode 100644 xen/arch/arm/mmu/Makefile
 create mode 100644 xen/arch/arm/mmu/mm.c
xen/arch/arm/Makefile +1 -0
index 7bf07e9920..9801b9dfd0 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_ARM_32) += arm32/
 obj-$(CONFIG_ARM_64) += arm64/
 obj-$(CONFIG_ACPI) += acpi/
+obj-$(CONFIG_HAS_MMU) += mmu/
 obj-$(CONFIG_HAS_PCI) += pci/
 ifneq ($(CONFIG_NO_PLAT),y)
 obj-y += platforms/
xen/arch/arm/arm64/Makefile +0 -1
index ce8749f046..731d00cc8a 100644
@@ -11,7 +11,6 @@ obj-y += entry.o
 obj-y += head.o
 obj-y += insn.o
 obj-$(CONFIG_LIVEPATCH) += livepatch.o
-obj-y += mm.o
 obj-y += smc.o
 obj-y += smpboot.o
 obj-$(CONFIG_ARM64_SVE) += sve.o sve-asm.o
xen/arch/arm/arm64/mmu/Makefile +1 -0
index 3340058c08..a8a750a3d0 100644
@@ -1 +1,2 @@
 obj-y += head.o
+obj-y += mm.o
xen/arch/arm/arm64/mmu/mm.c renamed from xen/arch/arm/arm64/mm.c +0 -0
similarity index 100%
rename from xen/arch/arm/arm64/mm.c
rename to xen/arch/arm/arm64/mmu/mm.c
xen/arch/arm/include/asm/mm.h +4 -16
index 4262165ce2..e70ce4dc61 100644
@@ -14,6 +14,10 @@
 # error "unknown ARM variant"
 #endif
 
+#ifdef CONFIG_HAS_MMU
+#include <asm/mmu/mm.h>
+#endif
+
 /* Align Xen to a 2 MiB boundary. */
 #define XEN_PADDR_ALIGN (1 << 21)
 
@@ -165,13 +169,6 @@ struct page_info
 #define _PGC_need_scrub   _PGC_allocated
 #define PGC_need_scrub    PGC_allocated
 
-extern mfn_t directmap_mfn_start, directmap_mfn_end;
-extern vaddr_t directmap_virt_end;
-#ifdef CONFIG_ARM_64
-extern vaddr_t directmap_virt_start;
-extern unsigned long directmap_base_pdx;
-#endif
-
 #ifdef CONFIG_ARM_32
 #define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
 #define is_xen_heap_mfn(mfn) ({                                 \
@@ -194,7 +191,6 @@ extern unsigned long directmap_base_pdx;
 
 #define maddr_get_owner(ma)   (page_get_owner(maddr_to_page((ma))))
 
-#define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
 /* PDX of the first page in the frame table. */
 extern unsigned long frametable_base_pdx;
 
@@ -207,8 +203,6 @@ extern unsigned long total_pages;
 extern void setup_pagetables(unsigned long boot_phys_offset);
 /* Map FDT in boot pagetable */
 extern void *early_fdt_map(paddr_t fdt_paddr);
-/* Switch to a new root page-tables */
-extern void switch_ttbr(uint64_t ttbr);
 /* Remove early mappings */
 extern void remove_early_mappings(void);
 /* Allocate and initialise pagetables for a secondary CPU. Sets init_ttbr to the
@@ -216,12 +210,6 @@ extern void remove_early_mappings(void);
 extern int init_secondary_pagetables(int cpu);
 /* Switch secondary CPUS to its own pagetables and finalise MMU setup */
 extern void mmu_init_secondary_cpu(void);
-/*
- * For Arm32, set up the direct-mapped xenheap: up to 1GB of contiguous,
- * always-mapped memory. Base must be 32MB aligned and size a multiple of 32MB.
- * For Arm64, map the region in the directmap area.
- */
-extern void setup_directmap_mappings(unsigned long base_mfn, unsigned long nr_mfns);
 /* Map a frame table to cover physical addresses ps through pe */
 extern void setup_frametable_mappings(paddr_t ps, paddr_t pe);
 /* map a physical range in virtual memory */
xen/arch/arm/include/asm/mmu/mm.h new file +55 -0

55 lines not on this page · raw message

xen/arch/arm/include/asm/page.h +0 -15
index ea96983ab9..247c170ac8 100644
@@ -257,21 +257,6 @@ static inline void write_pte(lpae_t *p, lpae_t pte)
 /* Flush the dcache for an entire page. */
 void flush_page_to_ram(unsigned long mfn, bool sync_icache);
 
-/*
- * Print a walk of a page table or p2m
- *
- * ttbr is the base address register (TTBR0_EL2 or VTTBR_EL2)
- * addr is the PA or IPA to translate
- * root_level is the starting level of the page table
- *   (e.g. TCR_EL2.SL0 or VTCR_EL2.SL0 )
- * nr_root_tables is the number of concatenated tables at the root.
- *   this can only be != 1 for P2M walks starting at the first or
- *   subsequent level.
- */
-void dump_pt_walk(paddr_t ttbr, paddr_t addr,
-                  unsigned int root_level,
-                  unsigned int nr_root_tables);
-
 /* Print a walk of the hypervisor's page tables for a virtual addr. */
 extern void dump_hyp_walk(vaddr_t addr);
 /* Print a walk of the p2m for a domain for a physical address. */
xen/arch/arm/include/asm/setup.h +0 -3
index 19dc637d55..f0f64d228c 100644
@@ -176,9 +176,6 @@ extern lpae_t boot_first_id[XEN_PT_LPAE_ENTRIES];
 extern lpae_t boot_second_id[XEN_PT_LPAE_ENTRIES];
 extern lpae_t boot_third_id[XEN_PT_LPAE_ENTRIES];
 
-/* Find where Xen will be residing at runtime and return a PT entry */
-lpae_t pte_of_xenaddr(vaddr_t);
-
 extern const char __ro_after_init_start[], __ro_after_init_end[];
 
 struct init_info
xen/arch/arm/mm.c +0 -1119

1,166 lines not on this page · raw message

xen/arch/arm/mmu/Makefile new file +1 -0
new file mode 100644
index 0000000000..b18cec4836
@@ -0,0 +1 @@
+obj-y += mm.o
xen/arch/arm/mmu/mm.c new file +1146 -0

1,146 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#28 lore raw

PATCH v4 8/13 xen/arm: Fold pmap and fixmap into MMU system

In reply to Henry Wang

From: Penny Zheng <[email protected]>

fixmap and pmap are MMU-specific features, so fold them to MMU system. Do the folding for pmap by moving the HAS_PMAP Kconfig selection under HAS_MMU. Do the folding for fixmap by moving the implementation of virt_to_fix() to mmu/mm.c, so that unnecessary stubs can be avoided.

---
v4:
- Rework "[v3,11/52] xen/arm: mmu: fold FIXMAP into MMU system", change the order of this patch and avoid introducing stubs.

---
 xen/arch/arm/Kconfig              | 2 +-
 xen/arch/arm/include/asm/fixmap.h | 7 +------
 xen/arch/arm/mmu/mm.c             | 7 +++++++
 3 files changed, 9 insertions(+), 7 deletions(-)
xen/arch/arm/Kconfig +1 -1
index 0e38e9ba17..1b60a938c2 100644
@@ -15,7 +15,6 @@ config ARM
 	select HAS_DEVICE_TREE
 	select HAS_PASSTHROUGH
 	select HAS_PDX
-	select HAS_PMAP
 	select HAS_UBSAN
 	select IOMMU_FORCE_PT_SHARE
 
@@ -71,6 +70,7 @@ choice
 
 config HAS_MMU
 	bool "MMU for a VMSA system"
+	select HAS_PMAP
 endchoice
 
 source "arch/Kconfig"
xen/arch/arm/include/asm/fixmap.h +1 -6
index 734eb9b1d4..5d5de6995a 100644
@@ -36,12 +36,7 @@ extern void clear_fixmap(unsigned int map);
 
 #define fix_to_virt(slot) ((void *)FIXMAP_ADDR(slot))
 
-static inline unsigned int virt_to_fix(vaddr_t vaddr)
-{
-    BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
-
-    return ((vaddr - FIXADDR_START) >> PAGE_SHIFT);
-}
+extern unsigned int virt_to_fix(vaddr_t vaddr);
 
 #endif /* __ASSEMBLY__ */
 
xen/arch/arm/mmu/mm.c +7 -0
index b70982e9d6..1d6267e6c5 100644
@@ -1136,6 +1136,13 @@ int __init populate_pt_range(unsigned long virt, unsigned long nr_mfns)
     return xen_pt_update(virt, INVALID_MFN, nr_mfns, _PAGE_POPULATE);
 }
 
+unsigned int virt_to_fix(vaddr_t vaddr)
+{
+    BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
+
+    return ((vaddr - FIXADDR_START) >> PAGE_SHIFT);
+}
+
 /*
  * Local variables:
  * mode: C
Signature · 1 line
2.25.1
author
#29 lore raw

PATCH v4 9/13 xen/arm: mm: Use generic variable/function names for extendability

In reply to Henry Wang

From: Penny Zheng <[email protected]>

As preparation for MPU support, which will use some variables/functions for both MMU and MPU system, We rename the affected variable/function to more generic names:
- init_ttbr -> init_mm,
- mmu_init_secondary_cpu() -> mm_init_secondary_cpu()
- init_secondary_pagetables() -> init_secondary_mm()
- Add a wrapper update_mm_mapping() for MMU system's update_identity_mapping()

Modify the related in-code comment to reflect above changes, take the opportunity to fix the incorrect coding style of the in-code comments.

---
v4:
- Extract the renaming part from the original patch:
"[v3,13/52] xen/mmu: extract mmu-specific codes from mm.c/mm.h"

---
 xen/arch/arm/arm32/head.S           |  4 ++--
 xen/arch/arm/arm64/mmu/head.S       |  2 +-
 xen/arch/arm/arm64/mmu/mm.c         | 11 ++++++++---
 xen/arch/arm/arm64/smpboot.c        |  6 +++---
 xen/arch/arm/include/asm/arm64/mm.h |  7 ++++---
 xen/arch/arm/include/asm/mm.h       | 10 ++++++----
 xen/arch/arm/mmu/mm.c               | 20 ++++++++++----------
 xen/arch/arm/smpboot.c              |  4 ++--
 8 files changed, 36 insertions(+), 28 deletions(-)
xen/arch/arm/arm32/head.S +2 -2
index 33b038e7e0..03ab68578a 100644
@@ -238,11 +238,11 @@ GLOBAL(init_secondary)
 secondary_switched:
         /*
          * Non-boot CPUs need to move on to the proper pagetables, which were
-         * setup in init_secondary_pagetables.
+         * setup in init_secondary_mm.
          *
          * XXX: This is not compliant with the Arm Arm.
          */
-        mov_w r4, init_ttbr          /* VA of HTTBR value stashed by CPU 0 */
+        mov_w r4, init_mm            /* VA of HTTBR value stashed by CPU 0 */
         ldrd  r4, r5, [r4]           /* Actual value */
         dsb
         mcrr  CP64(r4, r5, HTTBR)
xen/arch/arm/arm64/mmu/head.S +1 -1
index 6bd94c3a45..6e638ff082 100644
@@ -303,7 +303,7 @@ ENDPROC(enable_mmu)
 ENTRY(enable_secondary_cpu_mm)
         mov   x5, lr
 
-        load_paddr x0, init_ttbr
+        load_paddr x0, init_mm
         ldr   x0, [x0]
 
         bl    enable_mmu
xen/arch/arm/arm64/mmu/mm.c +8 -3
index 78b7c7eb00..ed0fc5ff7b 100644
@@ -106,7 +106,7 @@ void __init arch_setup_page_tables(void)
     prepare_runtime_identity_mapping();
 }
 
-void update_identity_mapping(bool enable)
+static void update_identity_mapping(bool enable)
 {
     paddr_t id_addr = virt_to_maddr(_start);
     int rc;
@@ -120,6 +120,11 @@ void update_identity_mapping(bool enable)
     BUG_ON(rc);
 }
 
+void update_mm_mapping(bool enable)
+{
+    update_identity_mapping(enable);
+}
+
 extern void switch_ttbr_id(uint64_t ttbr);
 
 typedef void (switch_ttbr_fn)(uint64_t ttbr);
@@ -131,7 +136,7 @@ void __init switch_ttbr(uint64_t ttbr)
     lpae_t pte;
 
     /* Enable the identity mapping in the boot page tables */
-    update_identity_mapping(true);
+    update_mm_mapping(true);
 
     /* Enable the identity mapping in the runtime page tables */
     pte = pte_of_xenaddr((vaddr_t)switch_ttbr_id);
@@ -148,7 +153,7 @@ void __init switch_ttbr(uint64_t ttbr)
      * Note it is not necessary to disable it in the boot page tables
      * because they are not going to be used by this CPU anymore.
      */
-    update_identity_mapping(false);
+    update_mm_mapping(false);
 }
 
 /*
xen/arch/arm/arm64/smpboot.c +3 -3
index 9637f42469..2b1d086a1e 100644
@@ -111,18 +111,18 @@ int arch_cpu_up(int cpu)
     if ( !smp_enable_ops[cpu].prepare_cpu )
         return -ENODEV;
 
-    update_identity_mapping(true);
+    update_mm_mapping(true);
 
     rc = smp_enable_ops[cpu].prepare_cpu(cpu);
     if ( rc )
-        update_identity_mapping(false);
+        update_mm_mapping(false);
 
     return rc;
 }
 
 void arch_cpu_up_finish(void)
 {
-    update_identity_mapping(false);
+    update_mm_mapping(false);
 }
 
 /*
xen/arch/arm/include/asm/arm64/mm.h +4 -3
index e0bd23a6ed..7a389c4b21 100644
@@ -15,13 +15,14 @@ static inline bool arch_mfns_in_directmap(unsigned long mfn, unsigned long nr)
 void arch_setup_page_tables(void);
 
 /*
- * Enable/disable the identity mapping in the live page-tables (i.e.
- * the one pointed by TTBR_EL2).
+ * In MMU system, enable/disable the identity mapping in the live
+ * page-tables (i.e. the one pointed by TTBR_EL2) through
+ * update_identity_mapping().
  *
  * Note that nested call (e.g. enable=true, enable=true) is not
  * supported.
  */
-void update_identity_mapping(bool enable);
+void update_mm_mapping(bool enable);
 
 #endif /* __ARM_ARM64_MM_H__ */
 
xen/arch/arm/include/asm/mm.h +6 -4
index e70ce4dc61..2b61a89b9f 100644
@@ -205,11 +205,13 @@ extern void setup_pagetables(unsigned long boot_phys_offset);
 extern void *early_fdt_map(paddr_t fdt_paddr);
 /* Remove early mappings */
 extern void remove_early_mappings(void);
-/* Allocate and initialise pagetables for a secondary CPU. Sets init_ttbr to the
- * new page table */
-extern int init_secondary_pagetables(int cpu);
+/*
+ * Allocate and initialise pagetables for a secondary CPU. Sets init_mm to the
+ * new page table
+ */
+extern int init_secondary_mm(int cpu);
 /* Switch secondary CPUS to its own pagetables and finalise MMU setup */
-extern void mmu_init_secondary_cpu(void);
+extern void mm_init_secondary_cpu(void);
 /* Map a frame table to cover physical addresses ps through pe */
 extern void setup_frametable_mappings(paddr_t ps, paddr_t pe);
 /* map a physical range in virtual memory */
xen/arch/arm/mmu/mm.c +10 -10
index 1d6267e6c5..7486c35ec0 100644
@@ -106,7 +106,7 @@ DEFINE_BOOT_PAGE_TABLE(xen_fixmap);
 static DEFINE_PAGE_TABLES(xen_xenmap, XEN_NR_ENTRIES(2));
 
 /* Non-boot CPUs use this to find the correct pagetables. */
-uint64_t init_ttbr;
+uint64_t init_mm;
 
 static paddr_t phys_offset;
 
@@ -492,18 +492,18 @@ static void clear_boot_pagetables(void)
 }
 
 #ifdef CONFIG_ARM_64
-int init_secondary_pagetables(int cpu)
+int init_secondary_mm(int cpu)
 {
     clear_boot_pagetables();
 
-    /* Set init_ttbr for this CPU coming up. All CPus share a single setof
+    /* Set init_mm for this CPU coming up. All CPus share a single setof
      * pagetables, but rewrite it each time for consistency with 32 bit. */
-    init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
-    clean_dcache(init_ttbr);
+    init_mm = (uintptr_t) xen_pgtable + phys_offset;
+    clean_dcache(init_mm);
     return 0;
 }
 #else
-int init_secondary_pagetables(int cpu)
+int init_secondary_mm(int cpu)
 {
     lpae_t *first;
 
@@ -529,16 +529,16 @@ int init_secondary_pagetables(int cpu)
 
     clear_boot_pagetables();
 
-    /* Set init_ttbr for this CPU coming up */
-    init_ttbr = __pa(first);
-    clean_dcache(init_ttbr);
+    /* Set init_mm for this CPU coming up */
+    init_mm = __pa(first);
+    clean_dcache(init_mm);
 
     return 0;
 }
 #endif
 
 /* MMU setup for secondary CPUS (which already have paging enabled) */
-void mmu_init_secondary_cpu(void)
+void mm_init_secondary_cpu(void)
 {
     xen_pt_enforce_wnx();
 }
xen/arch/arm/smpboot.c +2 -2
index e107b86b7b..8bcdbea66c 100644
@@ -359,7 +359,7 @@ void start_secondary(void)
      */
     update_system_features(&current_cpu_data);
 
-    mmu_init_secondary_cpu();
+    mm_init_secondary_cpu();
 
     gic_init_secondary_cpu();
 
@@ -448,7 +448,7 @@ int __cpu_up(unsigned int cpu)
 
     printk("Bringing up CPU%d\n", cpu);
 
-    rc = init_secondary_pagetables(cpu);
+    rc = init_secondary_mm(cpu);
     if ( rc < 0 )
         return rc;
 
Signature · 1 line
2.25.1
author
#30 lore raw

PATCH v4 10/13 xen/arm: mmu: move MMU-specific setup_mm to mmu/setup.c

In reply to Henry Wang

From: Penny Zheng <[email protected]>

setup_mm is used for Xen to setup memory management subsystem at boot time, like boot allocator, direct-mapping, xenheap initialization, frametable and static memory pages.

We could inherit some components seamlessly in later MPU system like boot allocator, whilst we need to implement some components differently in MPU, like xenheap, etc. There are some components that is specific to MMU only, like direct-mapping.

In the commit, we move MMU-specific components into mmu/setup.c, in preparation of implementing MPU version of setup_mm later in future commit. Also, make init_pdx(), init_staticmem_pages(), setup_mm(), and populate_boot_allocator() public for future MPU inplementation.

---
v4:
- No change

---
 xen/arch/arm/include/asm/setup.h |   5 +
 xen/arch/arm/mmu/Makefile        |   1 +
 xen/arch/arm/mmu/setup.c         | 339 +++++++++++++++++++++++++++++++
 xen/arch/arm/setup.c             | 326 +----------------------------
 4 files changed, 349 insertions(+), 322 deletions(-)
 create mode 100644 xen/arch/arm/mmu/setup.c
xen/arch/arm/include/asm/setup.h +5 -0
index f0f64d228c..0922549631 100644
@@ -156,6 +156,11 @@ struct bootcmdline *boot_cmdline_find_by_kind(bootmodule_kind kind);
 struct bootcmdline * boot_cmdline_find_by_name(const char *name);
 const char *boot_module_kind_as_string(bootmodule_kind kind);
 
+extern void init_pdx(void);
+extern void init_staticmem_pages(void);
+extern void populate_boot_allocator(void);
+extern void setup_mm(void);
+
 extern uint32_t hyp_traps_vector[];
 void init_traps(void);
 
xen/arch/arm/mmu/Makefile +1 -0
index b18cec4836..4aa1fb466d 100644
@@ -1 +1,2 @@
 obj-y += mm.o
+obj-y += setup.o
xen/arch/arm/mmu/setup.c new file +339 -0

339 lines not on this page · raw message

xen/arch/arm/setup.c +4 -322

368 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#31 lore raw

PATCH v4 11/13 xen/arm: mmu: move MMU specific P2M code to mmu/p2m.{c,h}

In reply to Henry Wang

From: Penny Zheng <[email protected]>

Current P2M implementation is designed for MMU system only. We move the MMU-specific codes into mmu/p2m.c, and only keep generic codes in p2m.c, like VMID allocator, etc. We also move MMU-specific definitions and declarations to mmu/p2m.h, such as p2m_tlb_flush_sync(). Also expose previously static functions p2m_vmid_allocator_init(), p2m_alloc_vmid(), __p2m_set_entry() and setup_virt_paging_one() for futher MPU usage.

With the code movement, global variable max_vmid is used in multiple files instead of a single file (and will be used in MPU P2M implementation), declare it in the header and remove the "static" of this variable.

Add #ifdef CONFIG_HAS_MMU to p2m_write_unlock() since future MPU work does not need p2m_tlb_flush_sync().

---
v4:
- Rework the patch to drop the unnecessary changes.
- Rework the commit msg a bit.
v3:
- remove MPU stubs
- adapt to the introduction of new directories: mmu/ v2:
- new commit

---
 xen/arch/arm/include/asm/mmu/p2m.h |   18 +
 xen/arch/arm/include/asm/p2m.h     |   33 +-
 xen/arch/arm/mmu/Makefile          |    1 +
 xen/arch/arm/mmu/p2m.c             | 1610 +++++++++++++++++++++++++
 xen/arch/arm/p2m.c                 | 1772 ++--------------------------
 5 files changed, 1745 insertions(+), 1689 deletions(-)
 create mode 100644 xen/arch/arm/include/asm/mmu/p2m.h
 create mode 100644 xen/arch/arm/mmu/p2m.c
xen/arch/arm/include/asm/mmu/p2m.h new file +18 -0
new file mode 100644
index 0000000000..f829e325ce
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __ARM_MMU_P2M_H__
+#define __ARM_MMU_P2M_H__
+
+struct p2m_domain;
+void p2m_force_tlb_flush_sync(struct p2m_domain *p2m);
+void p2m_tlb_flush_sync(struct p2m_domain *p2m);
+
+#endif /* __ARM_MMU_P2M_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/arm/include/asm/p2m.h +31 -2
index 940495d42b..37401461fa 100644
@@ -19,6 +19,22 @@ extern unsigned int p2m_root_level;
 #define P2M_ROOT_ORDER    p2m_root_order
 #define P2M_ROOT_LEVEL p2m_root_level
 
+#define MAX_VMID_8_BIT  (1UL << 8)
+#define MAX_VMID_16_BIT (1UL << 16)
+
+#define INVALID_VMID 0 /* VMID 0 is reserved */
+
+#ifdef CONFIG_ARM_64
+extern unsigned int max_vmid;
+/* VMID is by default 8 bit width on AArch64 */
+#define MAX_VMID       max_vmid
+#else
+/* VMID is always 8 bit width on AArch32 */
+#define MAX_VMID        MAX_VMID_8_BIT
+#endif
+
+#define P2M_ROOT_PAGES    (1<<P2M_ROOT_ORDER)
+
 struct domain;
 
 extern void memory_type_changed(struct domain *);
@@ -156,6 +172,10 @@ typedef enum {
 #endif
 #include <xen/p2m-common.h>
 
+#ifdef CONFIG_HAS_MMU
+#include <asm/mmu/p2m.h>
+#endif
+
 static inline bool arch_acquire_resource_check(struct domain *d)
 {
     /*
@@ -180,7 +200,11 @@ void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
  */
 void p2m_restrict_ipa_bits(unsigned int ipa_bits);
 
+void p2m_vmid_allocator_init(void);
+int p2m_alloc_vmid(struct domain *d);
+
 /* Second stage paging setup, to be called on all CPUs */
+void setup_virt_paging_one(void *data);
 void setup_virt_paging(void);
 
 /* Init the datastructures for later use by the p2m code */
@@ -242,8 +266,6 @@ static inline int p2m_is_write_locked(struct p2m_domain *p2m)
     return rw_is_write_locked(&p2m->lock);
 }
 
-void p2m_tlb_flush_sync(struct p2m_domain *p2m);
-
 /* Look up the MFN corresponding to a domain's GFN. */
 mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t);
 
@@ -269,6 +291,13 @@ int p2m_set_entry(struct p2m_domain *p2m,
                   p2m_type_t t,
                   p2m_access_t a);
 
+int __p2m_set_entry(struct p2m_domain *p2m,
+                    gfn_t sgfn,
+                    unsigned int page_order,
+                    mfn_t smfn,
+                    p2m_type_t t,
+                    p2m_access_t a);
+
 bool p2m_resolve_translation_fault(struct domain *d, gfn_t gfn);
 
 void p2m_clear_root_pages(struct p2m_domain *p2m);
xen/arch/arm/mmu/Makefile +1 -0
index 4aa1fb466d..a4f07ab90a 100644
@@ -1,2 +1,3 @@
 obj-y += mm.o
+obj-y += p2m.o
 obj-y += setup.o
xen/arch/arm/mmu/p2m.c new file +1610 -0

1,610 lines not on this page · raw message

xen/arch/arm/p2m.c +85 -1687

1,305 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

author
#32 lore raw

PATCH v4 12/13 xen/arm: mmu: relocate copy_from_paddr() to setup.c

In reply to Henry Wang

From: Penny Zheng <[email protected]>

Function copy_from_paddr() is defined in asm/setup.h, so it is better to be implemented in setup.c.

Current copy_from_paddr() implementation is mmu-specific, so this commit moves copy_from_paddr() into mmu/setup.c, and it is also benefical for us to implement MPU version of copy_from_paddr() in later commit.

---
v4:
- No change
v3:
- new commit

---
 xen/arch/arm/kernel.c    | 27 ---------------------------
 xen/arch/arm/mmu/setup.c | 27 +++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 27 deletions(-)
xen/arch/arm/kernel.c +0 -27
index 508c54824d..0d433a32e7 100644
@@ -41,33 +41,6 @@ struct minimal_dtb_header {
 
 #define DTB_MAGIC 0xd00dfeedU
 
-/**
- * copy_from_paddr - copy data from a physical address
- * @dst: destination virtual address
- * @paddr: source physical address
- * @len: length to copy
- */
-void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
-{
-    void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
-
-    while (len) {
-        unsigned long l, s;
-
-        s = paddr & (PAGE_SIZE-1);
-        l = min(PAGE_SIZE - s, len);
-
-        set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC);
-        memcpy(dst, src + s, l);
-        clean_dcache_va_range(dst, l);
-        clear_fixmap(FIXMAP_MISC);
-
-        paddr += l;
-        dst += l;
-        len -= l;
-    }
-}
-
 static void __init place_modules(struct kernel_info *info,
                                  paddr_t kernbase, paddr_t kernend)
 {
xen/arch/arm/mmu/setup.c +27 -0
index e05cca3f86..889ada6b87 100644
@@ -329,6 +329,33 @@ void __init setup_mm(void)
 }
 #endif
 
+/*
+ * copy_from_paddr - copy data from a physical address
+ * @dst: destination virtual address
+ * @paddr: source physical address
+ * @len: length to copy
+ */
+void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
+{
+    void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
+
+    while (len) {
+        unsigned long l, s;
+
+        s = paddr & (PAGE_SIZE-1);
+        l = min(PAGE_SIZE - s, len);
+
+        set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC);
+        memcpy(dst, src + s, l);
+        clean_dcache_va_range(dst, l);
+        clear_fixmap(FIXMAP_MISC);
+
+        paddr += l;
+        dst += l;
+        len -= l;
+    }
+}
+
 /*
  * Local variables:
  * mode: C
Signature · 1 line
2.25.1
author
#33 lore raw

PATCH v4 13/13 xen/arm: mmu: enable SMMU subsystem only in MMU

In reply to Henry Wang

From: Penny Zheng <[email protected]>

SMMU subsystem is only supported in MMU system, so we make it dependent on CONFIG_HAS_MMU.

---
v4:
- No change
v3:
- new patch

---
 xen/drivers/passthrough/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/drivers/passthrough/Kconfig +2 -1
index 864fcf3b0c..5a8d666829 100644
@@ -5,6 +5,7 @@ config HAS_PASSTHROUGH
 if ARM
 config ARM_SMMU
 	bool "ARM SMMUv1 and v2 driver"
+	depends on HAS_MMU
 	default y
 	---help---
 	  Support for implementations of the ARM System MMU architecture
@@ -15,7 +16,7 @@ config ARM_SMMU
 
 config ARM_SMMU_V3
 	bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support" if EXPERT
-	depends on ARM_64 && (!ACPI || BROKEN)
+	depends on ARM_64 && (!ACPI || BROKEN) && HAS_MMU
 	---help---
 	 Support for implementations of the ARM System MMU architecture
 	 version 3. Driver is in experimental stage and should not be used in
Signature · 1 line
2.25.1
Acked-by on v4 13/13
#34 lore raw

Re: [PATCH v4 13/13] xen/arm: mmu: enable SMMU subsystem only in MMU

Quoted 8 lines · Henry Wang

From: Penny Zheng <[email protected]>

SMMU subsystem is only supported in MMU system, so we make it dependent on CONFIG_HAS_MMU.

While entirely Arm-specific, this looks to require a non-Arm ack:

Jan

author
#35 lore raw

RE: [PATCH v4 13/13] xen/arm: mmu: enable SMMU subsystem only in MMU

(+ Julien, Stefano, Bertrand)

Hi Jan,

Quoted 8 lines

-----Original Message-----
Subject: Re: [PATCH v4 13/13] xen/arm: mmu: enable SMMU subsystem only in MMU

Quoted 3 lines · Henry Wang

From: Penny Zheng <[email protected]>

SMMU subsystem is only supported in MMU system, so we make it

Quoted 8 lines

dependent

Quoted 5 lines

on CONFIG_HAS_MMU.

While entirely Arm-specific, this looks to require a non-Arm ack:

Exactly, the default "Cc:" list was from the add_maintainers.pl and I noticed this right after sending the patch out. I will add the Arm maintainers in this reply (sorry for the inconvenience caused).

Quoted 1 line

Thank you very much!

Kind regards,
Henry

Quoted 2 lines

Jan

author
#36 lore raw

Re: [PATCH v4 13/13] xen/arm: mmu: enable SMMU subsystem only in MMU

In reply to Jan Beulich

Hi Jan,

Quoted 8 lines · Jan Beulich
Quoted 5 lines · Henry Wang

From: Penny Zheng <[email protected]>

SMMU subsystem is only supported in MMU system, so we make it dependent on CONFIG_HAS_MMU.

Quoted 6 lines
Quoted 3 lines

While entirely Arm-specific, this looks to require a non-Arm ack:

Based on the discussion in [1], now CONFIG_HAS_MMU is agreed to be renamed as CONFIG_MMU, I will do the renaming but I would like to confirm with you that if I can still take your asked-by tag with such change. Thanks!

[1] https://lore.kernel.org/xen-devel/[email protected]/

Kind regards,
Henry

Quoted 2 lines

Jan

#37 lore raw

Re: [PATCH v4 13/13] xen/arm: mmu: enable SMMU subsystem only in MMU

Quoted 11 lines · Henry Wang
Quoted 11 lines · Jan Beulich
Quoted 8 lines · Henry Wang

From: Penny Zheng <[email protected]>

SMMU subsystem is only supported in MMU system, so we make it dependent on CONFIG_HAS_MMU.

Quoted 6 lines
Quoted 2 lines

While entirely Arm-specific, this looks to require a non-Arm ack:

Based on the discussion in [1], now CONFIG_HAS_MMU is agreed to be renamed as CONFIG_MMU, I will do the renaming but I would like to confirm with you that if I can still take your asked-by tag with such change. Thanks!

Yes, that's fine to retain.

Jan

#38 lore raw
In reply to Henry Wang

Hi,

Quoted 5 lines · Henry Wang

Based on the discussion in the Xen Summit [1], sending this series out after addressing the comments in v3 [2] as the preparation work to add MPU support.

Mostly code movement, with some of Kconfig and build system (mainly Makefiles) adjustment. No functional change expected.

I can't really review this series without knowing how this will integrate with the rest of the MPU work. Can you at least provide a tree with all the patches applied (including the MPU one)?

Cheers,

Signature · 1 line
Julien Grall
author
#39 lore raw

Hi Julien,

Thanks for your prompt response and your time on the review!

Quoted 10 lines

-----Original Message-----
From: Julien Grall <[email protected]>
Subject: Re: [PATCH v4 00/13] xen/arm: Split MMU code as the prepration of MPU work

Hi,

Quoted 2 lines · Henry Wang

Based on the discussion in the Xen Summit [1], sending this series out after addressing the comments in v3 [2] as the preparation work to add MPU

Quoted 8 lines

support.

Quoted 2 lines

Mostly code movement, with some of Kconfig and build system (mainly

Makefiles)

Quoted 1 line

adjustment. No functional change expected.

I can't really review this series without knowing how this will integrate with the rest of the MPU work.

Sorry about it, I should have asked before sending the series.

Quoted 2 lines

Can you at least provide a tree
with all the patches applied (including the MPU one)?

See [1] for the full single core MPU implementation which I've verified locally about the MMU and MPU single core Linux boot on FVP, and looks like Gitlab is also not complaining [2].

Note that I've addressed comments from you and Ayan in v3 about the MMU/MPU helpers duplication and the arm32/arm64 split work. I didn't address the comment in [3] about the RES0 stuff, but I think this is not related to the MMU split series I sent yesterday to mailing list and the formal v4 MPU work sent to the mailing list will contain the fix for this comment.

[1] https://gitlab.com/xen-project/people/henryw/xen/-/commits/mpu_v4
[2] https://gitlab.com/xen-project/people/henryw/xen/-/pipelines/952742025
[3] https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/

Kind regards,
Henry

Quoted 5 lines

Cheers,

--
Julien Grall

#40 lore raw
Quoted 1 line · Henry Wang

Hi Julien,

Hi Henry,

-----Original Message-----

Quoted 18 lines
Quoted 9 lines

From: Julien Grall <[email protected]>
Subject: Re: [PATCH v4 00/13] xen/arm: Split MMU code as the prepration of MPU work

Hi,

Quoted 2 lines · Henry Wang

Based on the discussion in the Xen Summit [1], sending this series out after addressing the comments in v3 [2] as the preparation work to add MPU

Quoted 8 lines

support.

Quoted 2 lines

Mostly code movement, with some of Kconfig and build system (mainly

Makefiles)

Quoted 1 line

adjustment. No functional change expected.

I can't really review this series without knowing how this will integrate with the rest of the MPU work.

Quoted 8 lines

Sorry about it, I should have asked before sending the series.

Quoted 2 lines

Can you at least provide a tree
with all the patches applied (including the MPU one)?

See [1] for the full single core MPU implementation which I've verified locally about the MMU and MPU single core Linux boot on FVP, and looks like Gitlab is also not complaining [2].

Thanks for the link!

Quoted 7 lines

Note that I've addressed comments from you and Ayan in v3 about the MMU/MPU helpers duplication and the arm32/arm64 split work. I didn't address the comment in [3] about the RES0 stuff, but I think this is not related to the MMU split series I sent yesterday to mailing list and the formal v4 MPU work sent to the mailing list will contain the fix for this comment.

Agree, the RES0 bit is MPU specific.

Cheers,

Signature · 1 line
Julien Grall