Skip to contentSkip to conversation

xen/arm: mm: Clear boot pagetables before bringing-up each secondary CPU

PATCH RESEND In review Julien Grall 4 participants 9 messages Sep 21, 2019 – Oct 16, 2019

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 xen/arm: mm: Clear boot pagetables before bringing-up each secondary CPU

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

---
 xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 
     switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
     clear_table(boot_pgtable);
 #ifdef CONFIG_ARM_64
     clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 #endif
     clear_table(boot_second);
     clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
 }
 
 #ifdef CONFIG_ARM_64
 int init_secondary_pagetables(int cpu)
 {
+    clear_boot_pagetables();
+
     /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
     per_cpu(xen_pgtable, cpu) = first;
     per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
     /* Set init_ttbr for this CPU coming up */
     init_ttbr = __pa(first);
     clean_dcache(init_ttbr);
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

Taking into account fixed remark below:

Quoted 17 lines
---
 xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +3 -2
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 
     switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32

xen/arch/arm/mm.c void __init setup_pagetables(unsigned long boot_phys_offset) · line 719

Quoted 10 lines
xen/arch/arm/mm.c +10 -0
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)

Missing full stop.

Quoted 34 lines
xen/arch/arm/mm.c +5 -7
+     */
     clear_table(boot_pgtable);
 #ifdef CONFIG_ARM_64
     clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 #endif
     clear_table(boot_second);
     clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
 }
 
 #ifdef CONFIG_ARM_64
 int init_secondary_pagetables(int cpu)
 {
+    clear_boot_pagetables();
+
     /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
     per_cpu(xen_pgtable, cpu) = first;
     per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
     /* Set init_ttbr for this CPU coming up */
     init_ttbr = __pa(first);
     clean_dcache(init_ttbr);
Signature · 5 lines
Volodymyr Babchuk at EPAM
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
In reply to Julien Grall

Ping.

Quoted 70 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

---
  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
  1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 
      switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
      clear_table(boot_pgtable);
  #ifdef CONFIG_ARM_64
      clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
  #endif
      clear_table(boot_second);
      clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
  }
 
  #ifdef CONFIG_ARM_64
  int init_secondary_pagetables(int cpu)
  {
+    clear_boot_pagetables();
+
      /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
      per_cpu(xen_pgtable, cpu) = first;
      per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
      /* Set init_ttbr for this CPU coming up */
      init_ttbr = __pa(first);
      clean_dcache(init_ttbr);
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw
In reply to Julien Grall

Gentle ping.

Quoted 70 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

---
  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
  1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 
      switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
      clear_table(boot_pgtable);
  #ifdef CONFIG_ARM_64
      clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
  #endif
      clear_table(boot_second);
      clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
  }
 
  #ifdef CONFIG_ARM_64
  int init_secondary_pagetables(int cpu)
  {
+    clear_boot_pagetables();
+
      /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
      per_cpu(xen_pgtable, cpu) = first;
      per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
      /* Set init_ttbr for this CPU coming up */
      init_ttbr = __pa(first);
      clean_dcache(init_ttbr);
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#4 lore raw
In reply to Julien Grall
Quoted 8 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

Quoted 64 lines
---
 xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 
     switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
     clear_table(boot_pgtable);
 #ifdef CONFIG_ARM_64
     clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 #endif
     clear_table(boot_second);
     clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
 }
 
 #ifdef CONFIG_ARM_64
 int init_secondary_pagetables(int cpu)
 {
+    clear_boot_pagetables();
+
     /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
     per_cpu(xen_pgtable, cpu) = first;
     per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
     /* Set init_ttbr for this CPU coming up */
     init_ttbr = __pa(first);
     clean_dcache(init_ttbr);
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw

+Juergen

Quoted 77 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

Quoted 64 lines
---
  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
  1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
 
      switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
      clear_table(boot_pgtable);
  #ifdef CONFIG_ARM_64
      clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
  #endif
      clear_table(boot_second);
      clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
  }
 
  #ifdef CONFIG_ARM_64
  int init_secondary_pagetables(int cpu)
  {
+    clear_boot_pagetables();
+
      /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
      per_cpu(xen_pgtable, cpu) = first;
      per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
      /* Set init_ttbr for this CPU coming up */
      init_ttbr = __pa(first);
      clean_dcache(init_ttbr);
Signature · 1 line
2.11.0
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

Hi,

I actually forgot to CC Juergen. No wonder why I had no answer :(.

Cheers,

Quoted 79 lines · Julien Grall

+Juergen

Quoted 75 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

Quoted 62 lines

---
  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------

  1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long 
 boot_phys_offset)
       switch_ttbr(ttbr);
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
       clear_table(boot_pgtable);
   #ifdef CONFIG_ARM_64
       clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long 
 boot_phys_offset)
   #endif
       clear_table(boot_second);
       clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
   }
   #ifdef CONFIG_ARM_64
   int init_secondary_pagetables(int cpu)
   {
+    clear_boot_pagetables();
+
       /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
       per_cpu(xen_pgtable, cpu) = first;
       per_cpu(xen_dommap, cpu) = domheap;
+    clear_boot_pagetables();
+
       /* Set init_ttbr for this CPU coming up */
       init_ttbr = __pa(first);
       clean_dcache(init_ttbr);
Signature · 1 line
2.11.0
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#7 lore raw

Hi,

Argh forgot again. Maybe the 3rd will be better?

Sorry for the noise.

Cheers,

Quoted 87 lines · Julien Grall

Hi,

I actually forgot to CC Juergen. No wonder why I had no answer :(.

Cheers,

Quoted 79 lines · Julien Grall

+Juergen

Quoted 75 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

Quoted 62 lines

---
  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------

  1 file changed, 18 insertions(+), 9 deletions(-)
xen/arch/arm/mm.c +18 -9
index 1129dc28c8..e14ee76ff8 100644
@@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long 
 boot_phys_offset)
       switch_ttbr(ttbr);
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
       clear_table(boot_pgtable);
   #ifdef CONFIG_ARM_64
       clear_table(boot_first);
@@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long 
 boot_phys_offset)
   #endif
       clear_table(boot_second);
       clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
   }
   #ifdef CONFIG_ARM_64
   int init_secondary_pagetables(int cpu)
   {
+    clear_boot_pagetables();
+
       /* Set init_ttbr 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;
@@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
       per_cpu(xen_pgtable, cpu) = first;
       per_cpu(xen_dommap, cpu) = domheap;
+    clear_boot_pagetables();
+
       /* Set init_ttbr for this CPU coming up */
       init_ttbr = __pa(first);
       clean_dcache(init_ttbr);
Signature · 1 line
2.11.0
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#8 lore raw
Quoted 3 lines · Julien Grall

Hi,

Argh forgot again. Maybe the 3rd will be better?

Yes! You made it! ;-)

Quoted 27 lines

Sorry for the noise.

Cheers,

Quoted 21 lines · Julien Grall

Hi,

I actually forgot to CC Juergen. No wonder why I had no answer :(.

Cheers,

Quoted 14 lines · Julien Grall

+Juergen

Quoted 11 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall

At the moment, boot pagetables are only cleared once at boot. This means when booting CPU2 (and onwards) then boot pagetables will not be cleared.

To keep the interface exactly the same for all secondary CPU, the boot pagetables are now cleared before bringing-up each secondary CPU.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel