Commit 171cb719 authored by Gavin Shan's avatar Gavin Shan Committed by Michael Ellerman

powerpc/mm: Improve readability of update_mmu_cache()

The function is used to update the MMU with software PTE. It can
be called by data access exception handler (0x300) or instruction
access exception handler (0x400). If the function is called by
0x400 handler, the local variable @access is set to _PAGE_EXEC
to indicate the software PTE should have that flag set. When the
function is called by 0x300 handler, @access is set to zero.

This improves the readability of the function by replacing if
statements with switch. No logical changes introduced.
Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent dd0b52c4
...@@ -491,7 +491,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, ...@@ -491,7 +491,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
* We don't need to worry about _PAGE_PRESENT here because we are * We don't need to worry about _PAGE_PRESENT here because we are
* called with either mm->page_table_lock held or ptl lock held * called with either mm->page_table_lock held or ptl lock held
*/ */
unsigned long access = 0, trap; unsigned long access, trap;
if (radix_enabled()) if (radix_enabled())
return; return;
...@@ -506,13 +507,19 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, ...@@ -506,13 +507,19 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
* *
* We also avoid filling the hash if not coming from a fault * We also avoid filling the hash if not coming from a fault
*/ */
if (current->thread.regs == NULL)
return; trap = current->thread.regs ? TRAP(current->thread.regs) : 0UL;
trap = TRAP(current->thread.regs); switch (trap) {
if (trap == 0x400) case 0x300:
access |= _PAGE_EXEC; access = 0UL;
else if (trap != 0x300) break;
case 0x400:
access = _PAGE_EXEC;
break;
default:
return; return;
}
hash_preload(vma->vm_mm, address, access, trap); hash_preload(vma->vm_mm, address, access, trap);
#endif /* CONFIG_PPC_STD_MMU */ #endif /* CONFIG_PPC_STD_MMU */
#if (defined(CONFIG_PPC_BOOK3E_64) || defined(CONFIG_PPC_FSL_BOOK3E)) \ #if (defined(CONFIG_PPC_BOOK3E_64) || defined(CONFIG_PPC_FSL_BOOK3E)) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment