Skip to contentSkip to conversation

xen/arm: Properly clean update to init_ttbr and smp_up_cpu

PATCH In review Julien Grall 3 participants 4 messages Jan 30, 2024 – Feb 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: Properly clean update to init_ttbr and smp_up_cpu

From: Julien Grall <[email protected]>

Recent rework to the secondary boot code modified how init_ttbr and smp_up_cpu are accessed. Rather than directly accessing them, we are using a pointer to them.

The helper clean_dcache() is expected to take the variable in parameter and then clean its content. As we now pass a pointer to the variable, we will clean the area storing the address rather than the content itself.

Switch to use clean_dcache_va_range() to avoid casting the pointer.

Fixes a5ed59e62c6f ("arm/mmu: Move init_ttbr to a new section .data.idmap")
Fixes 9a5114074b04 ("arm/smpboot: Move smp_up_cpu to a new section .data.idmap)
---
 xen/arch/arm/mmu/smpboot.c | 2 +-
 xen/arch/arm/smpboot.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/mmu/smpboot.c +1 -1
index bc91fdfe3331..4ffc8254a44b 100644
@@ -88,7 +88,7 @@ static void set_init_ttbr(lpae_t *root)
      * init_ttbr will be accessed with the MMU off, so ensure the update
      * is visible by cleaning the cache.
      */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(uint64_t));
 
     unmap_domain_page(ptr);
 }
xen/arch/arm/smpboot.c +1 -1
index 119bfa3160ad..a84e706d77da 100644
@@ -449,7 +449,7 @@ static void set_smp_up_cpu(unsigned long mpidr)
      * smp_up_cpu will be accessed with the MMU off, so ensure the update
      * is visible by cleaning the cache.
      */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(unsigned long));
 
     unmap_domain_page(ptr);
 
Signature · 1 line
2.40.1
Tested-by on v1 1/1
#1 lore raw

On 30.01.24 19:29, Julien Grall wrote:

Hello Julien

Quoted 10 lines

From: Julien Grall <[email protected]>

Recent rework to the secondary boot code modified how init_ttbr and smp_up_cpu are accessed. Rather than directly accessing them, we are using a pointer to them.

The helper clean_dcache() is expected to take the variable in parameter and then clean its content. As we now pass a pointer to the variable, we will clean the area storing the address rather than the content itself.

Quoted 7 lines

Switch to use clean_dcache_va_range() to avoid casting the pointer.

Fixes a5ed59e62c6f ("arm/mmu: Move init_ttbr to a new section .data.idmap")
Fixes 9a5114074b04 ("arm/smpboot: Move smp_up_cpu to a new section .data.idmap)
[on Renesas R-Car Gen3 SoC with 8 cores (Arm64)]
Quoted 31 lines
---
  xen/arch/arm/mmu/smpboot.c | 2 +-
  xen/arch/arm/smpboot.c     | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/mmu/smpboot.c +1 -1
index bc91fdfe3331..4ffc8254a44b 100644
@@ -88,7 +88,7 @@ static void set_init_ttbr(lpae_t *root)
       * init_ttbr will be accessed with the MMU off, so ensure the update
       * is visible by cleaning the cache.
       */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(uint64_t));
 
      unmap_domain_page(ptr);
  }
xen/arch/arm/smpboot.c +1 -1
index 119bfa3160ad..a84e706d77da 100644
@@ -449,7 +449,7 @@ static void set_smp_up_cpu(unsigned long mpidr)
       * smp_up_cpu will be accessed with the MMU off, so ensure the update
       * is visible by cleaning the cache.
       */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(unsigned long));
 
      unmap_domain_page(ptr);
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Julien Grall

Hi Julien,

Nice finding :-)

Quoted 12 lines · Julien Grall

From: Julien Grall <[email protected]>

Recent rework to the secondary boot code modified how init_ttbr and smp_up_cpu are accessed. Rather than directly accessing them, we are using a pointer to them.

The helper clean_dcache() is expected to take the variable in parameter and then clean its content. As we now pass a pointer to the variable, we will clean the area storing the address rather than the content itself.

Quoted 7 lines

Switch to use clean_dcache_va_range() to avoid casting the pointer.

Fixes a5ed59e62c6f ("arm/mmu: Move init_ttbr to a new section .data.idmap")
Fixes 9a5114074b04 ("arm/smpboot: Move smp_up_cpu to a new section .data.idmap)

Cheers
Bertrand

Quoted 34 lines

---
xen/arch/arm/mmu/smpboot.c | 2 +-
xen/arch/arm/smpboot.c | 2 +-

2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/mmu/smpboot.c +1 -1
index bc91fdfe3331..4ffc8254a44b 100644
@@ -88,7 +88,7 @@ static void set_init_ttbr(lpae_t *root)
     * init_ttbr will be accessed with the MMU off, so ensure the update
     * is visible by cleaning the cache.
     */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(uint64_t));
 
    unmap_domain_page(ptr);
 }
xen/arch/arm/smpboot.c +1 -1
index 119bfa3160ad..a84e706d77da 100644
@@ -449,7 +449,7 @@ static void set_smp_up_cpu(unsigned long mpidr)
     * smp_up_cpu will be accessed with the MMU off, so ensure the update
     * is visible by cleaning the cache.
     */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(unsigned long));
 
    unmap_domain_page(ptr);
 
Signature · 1 line
2.40.1
#3 lore raw

Hi,

Quoted 14 lines · Bertrand Marquis
Quoted 14 lines · Julien Grall

From: Julien Grall <[email protected]>

Recent rework to the secondary boot code modified how init_ttbr and smp_up_cpu are accessed. Rather than directly accessing them, we are using a pointer to them.

The helper clean_dcache() is expected to take the variable in parameter and then clean its content. As we now pass a pointer to the variable, we will clean the area storing the address rather than the content itself.

Switch to use clean_dcache_va_range() to avoid casting the pointer.

Quoted 7 lines
Quoted 5 lines
Fixes a5ed59e62c6f ("arm/mmu: Move init_ttbr to a new section .data.idmap")
Fixes 9a5114074b04 ("arm/smpboot: Move smp_up_cpu to a new section .data.idmap)

Committed. Thanks.

Cheers,

Signature · 1 line
Julien Grall