When the page fault happened in user space, we need check it's
caused by stack frame pointer update instruction and update
local variable @flag with FAULT_FLAG_USER. Currently, the code
has two separate check for the same condition. That's unnecessary.
This removes one of the duplicated check. No functinal changes
introduced.
Signed-off-by: Gavin Shan <redacted>
---
arch/powerpc/mm/fault.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
@@ -294,11 +294,10 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,*canresultinfault,whichwillcauseadeadlockwhencalledwith*mmap_semheld*/-if(user_mode(regs))-store_update_sp=store_updates_sp(regs);--if(user_mode(regs))+if(user_mode(regs)){flags|=FAULT_FLAG_USER;+store_update_sp=store_updates_sp(regs);+}/* When running in the kernel we expect faults to occur only to*addressesinuserspace.Allotherfaultsrepresenterrorsinthe
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: Gavin Shan <redacted>
---
arch/powerpc/mm/mem.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
@@ -492,7 +492,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,*Wedon'tneedtoworryabout_PAGE_PRESENTherebecauseweare*calledwitheithermm->page_table_lockheldorptllockheld*/-unsignedlongaccess=0,trap;+unsignedlongaccess,trap;/* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */if(!pte_young(*ptep)||address>=TASK_SIZE)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2016-05-09 10:03:51
On Fri, 2016-26-02 at 00:26:25 UTC, Gavin Shan wrote:
When the page fault happened in user space, we need check it's
caused by stack frame pointer update instruction and update
local variable @flag with FAULT_FLAG_USER. Currently, the code
has two separate check for the same condition. That's unnecessary.
This removes one of the duplicated check. No functinal changes
introduced.
It's possible though that store_updates_sp() changes regs, and causes
user_mode(regs) to change, which would mean the second check is necessary.
That's not true with the current code, but you should mention that you confirmed
that in the change log.
On Mon, May 09, 2016 at 08:03:50PM +1000, Michael Ellerman wrote:
On Fri, 2016-26-02 at 00:26:25 UTC, Gavin Shan wrote:
quoted
When the page fault happened in user space, we need check it's
caused by stack frame pointer update instruction and update
local variable @flag with FAULT_FLAG_USER. Currently, the code
has two separate check for the same condition. That's unnecessary.
This removes one of the duplicated check. No functinal changes
introduced.
It's possible though that store_updates_sp() changes regs, and causes
user_mode(regs) to change, which would mean the second check is necessary.
That's not true with the current code, but you should mention that you confirmed
that in the change log.
Thanks for review. Yeah, store_updates_sp() checks the failing instruction
is the one updating stack frame pointer (stdu and the variable). The info
is used to expand the stack later. All of it should have been documented
in the commit log.
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2016-05-10 21:48:38
On Fri, 2016-26-02 at 00:26:26 UTC, Gavin Shan wrote:
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: Gavin Shan <redacted>