Skip to contentSkip to conversation

arm/arm64: some fixups

PATCH Applied Andrew Jones 2 participants 5 messages Nov 21, 2017 – Nov 23, 2017

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

cover arm/arm64: some fixups

Fixups needed after the 'merge x86 vmalloc and arm/powerpc alloc' series was merged.

Andrew Jones (2):
Makefile: fix cscope target
arm/arm64: mmu: add missing TLB flushes

 Makefile      | 2 +-
 lib/arm/mmu.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/2 Makefile: fix cscope target

Since 031755db "arm: enable vmalloc" one of arm's source files is a symlink. cscope doesn't like that. Fix how we generate cscope.files in order to make it happy.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 72313347b8b0..7c0f8e220912 100644
@@ -121,5 +121,5 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
 cscope:
 	$(RM) ./cscope.*
 	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -print | sed 's,^\./,,' | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
 	cscope -bk
Signature · 1 line
2.13.6
#2 lore raw

PATCH 2/2 arm/arm64: mmu: add missing TLB flushes

In reply to Andrew Jones

Since 031755db "arm: enable vmalloc" the virtual addresses returned from malloc and friends are no longer identical to the physical addresses they map to. On some hardware the change exposes missing TLB flushes. Let's get them added.

---
 lib/arm/mmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/arm/mmu.c +2 -1
index 21bcf3a363af..2e5c993f1e7f 100644
@@ -86,6 +86,7 @@ static pteval_t *install_pte(pgd_t *pgtable, uintptr_t vaddr, pteval_t pte)
 {
 	pteval_t *p_pte = get_pte(pgtable, vaddr);
 	*p_pte = pte;
+	flush_tlb_page(vaddr);
 	return p_pte;
 }
 
@@ -136,9 +137,9 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset,
 		pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S;
 		pgd_val(*pgd) |= pgprot_val(prot);
 	}
+	flush_tlb_all();
 }
 
-
 void *setup_mmu(phys_addr_t phys_end)
 {
 	uintptr_t code_end = (uintptr_t)&etext;
Signature · 1 line
2.13.6
#3 lore raw

Re: [PATCH kvm-unit-tests 2/2] arm/arm64: mmu: add missing TLB flushes

2017-11-21 17:49+0100, Andrew Jones:

Quoted 23 lines

Since 031755db "arm: enable vmalloc" the virtual addresses returned from malloc and friends are no longer identical to the physical addresses they map to. On some hardware the change exposes missing TLB flushes. Let's get them added.

---
 lib/arm/mmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/arm/mmu.c +1 -0
index 21bcf3a363af..2e5c993f1e7f 100644
@@ -86,6 +86,7 @@ static pteval_t *install_pte(pgd_t *pgtable, uintptr_t vaddr, pteval_t pte)
 {
 	pteval_t *p_pte = get_pte(pgtable, vaddr);
 	*p_pte = pte;
+	flush_tlb_page(vaddr);
 	return p_pte;
 }
 

lib/arm/mmu.c void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset, · line 141

Quoted 5 lines
lib/arm/mmu.c +1 -0
@@ -136,9 +137,9 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset,
 		pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S;
 		pgd_val(*pgd) |= pgprot_val(prot);
 	}
+	flush_tlb_all();
 }

Applied, thanks.

Out of curiosity, when does it become better to use flush_tlb_all() than flush_tlb_page()? i.e.

lib/arm/mmu.c +1 -1
index 2e5c993f1e7f..030c44412c2a 100644
@@ -136,8 +136,8 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset,
 		pgd_val(*pgd) = paddr;
 		pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S;
 		pgd_val(*pgd) |= pgprot_val(prot);
+		flush_tlb_page(vaddr);
 	}
-	flush_tlb_all();
 }
 
 void *setup_mmu(phys_addr_t phys_end)
#4 lore raw

Re: [PATCH kvm-unit-tests 2/2] arm/arm64: mmu: add missing TLB flushes

Quoted 32 lines · Radim Krčmář

2017-11-21 17:49+0100, Andrew Jones:

Quoted 23 lines

Since 031755db "arm: enable vmalloc" the virtual addresses returned from malloc and friends are no longer identical to the physical addresses they map to. On some hardware the change exposes missing TLB flushes. Let's get them added.

---
 lib/arm/mmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/arm/mmu.c +1 -0
index 21bcf3a363af..2e5c993f1e7f 100644
@@ -86,6 +86,7 @@ static pteval_t *install_pte(pgd_t *pgtable, uintptr_t vaddr, pteval_t pte)
 {
 	pteval_t *p_pte = get_pte(pgtable, vaddr);
 	*p_pte = pte;
+	flush_tlb_page(vaddr);
 	return p_pte;
 }
 

lib/arm/mmu.c void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset, · line 141

Quoted 5 lines
lib/arm/mmu.c +1 -0
@@ -136,9 +137,9 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset,
 		pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S;
 		pgd_val(*pgd) |= pgprot_val(prot);
 	}
+	flush_tlb_all();
 }

Applied, thanks.

Quoted 3 lines

Out of curiosity, when does it become better to use flush_tlb_all() than flush_tlb_page()? i.e.

I was just being lazy with the mmu_set_range_sect() function, because, while that's currently part of the MMU API, it's actually only used in one place, setup_mmu(), which does mmu_enable() after its call anyway.

So, in short, the mmu_set_range_sect() hunk is correct, but not optimal, and it doesn't really matter :-)

drew