Skip to contentSkip to conversation

arm64: mm: Ensure writes to swapper are ordered wrt subsequent cache maintenance

PATCH New Will Deacon 3 participants 3 messages Jun 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: mm: Ensure writes to swapper are ordered wrt subsequent cache maintenance

When rewriting swapper using nG mappings, we must performance cache maintenance around each page table access in order to avoid coherency problems with the host's cacheable alias under KVM. To ensure correct ordering of the maintenance with respect to Device memory accesses made with the Stage-1 MMU disabled, DMBs need to be added between the maintenance and the corresponding memory access.

This patch adds a missing DMB between writing a new page table entry and performing a clean+invalidate on the same line.

---
 arch/arm64/mm/proc.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/mm/proc.S +3 -2
index 5f9a73a4452c..03646e6a2ef4 100644
@@ -217,8 +217,9 @@ ENDPROC(idmap_cpu_replace_ttbr1)
 
 	.macro __idmap_kpti_put_pgtable_ent_ng, type
 	orr	\type, \type, #PTE_NG		// Same bit for blocks and pages
-	str	\type, [cur_\()\type\()p]	// Update the entry and ensure it
-	dc	civac, cur_\()\type\()p		// is visible to all CPUs.
+	str	\type, [cur_\()\type\()p]	// Update the entry and ensure
+	dmb	sy				// that it is visible to all
+	dc	civac, cur_\()\type\()p		// CPUs.
 	.endm
 
 /*
Signature · 1 line
2.1.4
reviewer
#1 lore raw

PATCH 1/1 arm64: mm: Ensure writes to swapper are ordered wrt subsequent cache maintenance

Quoted 7 lines · Will Deacon

When rewriting swapper using nG mappings, we must performance cache maintenance around each page table access in order to avoid coherency problems with the host's cacheable alias under KVM. To ensure correct ordering of the maintenance with respect to Device memory accesses made with the Stage-1 MMU disabled, DMBs need to be added between the maintenance and the corresponding memory access.

Quoted 5 lines

This patch adds a missing DMB between writing a new page table entry and performing a clean+invalidate on the same line.

Mark.

Quoted 23 lines
---
 arch/arm64/mm/proc.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/mm/proc.S +3 -2
index 5f9a73a4452c..03646e6a2ef4 100644
@@ -217,8 +217,9 @@ ENDPROC(idmap_cpu_replace_ttbr1)
 
 	.macro __idmap_kpti_put_pgtable_ent_ng, type
 	orr	\type, \type, #PTE_NG		// Same bit for blocks and pages
-	str	\type, [cur_\()\type\()p]	// Update the entry and ensure it
-	dc	civac, cur_\()\type\()p		// is visible to all CPUs.
+	str	\type, [cur_\()\type\()p]	// Update the entry and ensure
+	dmb	sy				// that it is visible to all
+	dc	civac, cur_\()\type\()p		// CPUs.
 	.endm
 
 /*
Signature · 1 line
2.1.4
maintainer Applied
#2 lore raw

PATCH 1/1 arm64: mm: Ensure writes to swapper are ordered wrt subsequent cache maintenance

In reply to Will Deacon
Quoted 7 lines · Will Deacon

When rewriting swapper using nG mappings, we must performance cache maintenance around each page table access in order to avoid coherency problems with the host's cacheable alias under KVM. To ensure correct ordering of the maintenance with respect to Device memory accesses made with the Stage-1 MMU disabled, DMBs need to be added between the maintenance and the corresponding memory access.

Quoted 5 lines

This patch adds a missing DMB between writing a new page table entry and performing a clean+invalidate on the same line.

Applied. Thanks.

Signature · 1 line
Catalin