Skip to content

Commit 3e1ae44

Browse files
committed
ARC: [mm] Remove @Write argument to do_page_fault()
This can be ascertained within do_page_fault() since it gets the full ECR (Exception Cause Register). Further, for both the callers of do_page_fault(): Prot-V / D-TLB-Miss, the cause sub-fields in ECR are same for same type of access, making the code much more simpler. D-TLB-Miss [LD] 0x00_21_01_00 Prot-V [LD] 0x00_23_01_00 ^^ D-TLB-Miss [ST] 0x00_21_02_00 Prot-V [ST] 0x00_23_02_00 ^^ D-TLB-Miss [EX] 0x00_21_03_00 Prot-V [EX] 0x00_23_03_00 ^^ This helps code consolidation, which is even better when moving code from assembler to "C". Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent 3abc944 commit 3e1ae44

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

arch/arc/kernel/entry.S

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ ARC_ENTRY EV_TLBProtV
355355
; ecr and efa were not saved in case an Intr sneaks in
356356
; after fake rtie
357357
;
358-
lr r3, [ecr]
359-
lr r4, [efa]
358+
lr r2, [ecr]
359+
lr r1, [efa] ; Faulting Data address
360360

361361
; --------(4) Return from CPU Exception Mode ---------
362362
; Fake a rtie, but rtie to next label
@@ -371,23 +371,17 @@ ARC_ENTRY EV_TLBProtV
371371
; -Access Violaton (WRITE to READ ONLY Page) - for linux COW
372372
; -Unaligned Access (READ/WRITE on odd boundary)
373373
;
374-
cmp r3, 0x230400 ; Misaligned data access ?
374+
cmp r2, 0x230400 ; Misaligned data access ?
375375
beq 4f
376376

377377
;========= (6a) Access Violation Processing ========
378-
cmp r3, 0x230100
379-
mov r1, 0x0 ; if LD exception ? write = 0
380-
mov.ne r1, 0x1 ; else write = 1
381-
382-
mov r2, r4 ; faulting address
383378
mov r0, sp ; pt_regs
384379
bl do_page_fault
385380
b ret_from_exception
386381

387382
;========== (6b) Non aligned access ============
388383
4:
389-
mov r0, r3 ; cause code
390-
mov r1, r4 ; faulting address
384+
mov r0, r2 ; cause code
391385
mov r2, sp ; pt_regs
392386

393387
#ifdef CONFIG_ARC_MISALIGN_ACCESS

arch/arc/mm/fault.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ static int handle_vmalloc_fault(struct mm_struct *mm, unsigned long address)
5252
return 1;
5353
}
5454

55-
void do_page_fault(struct pt_regs *regs, int write, unsigned long address,
55+
void do_page_fault(struct pt_regs *regs, unsigned long address,
5656
unsigned long cause_code)
5757
{
5858
struct vm_area_struct *vma = NULL;
5959
struct task_struct *tsk = current;
6060
struct mm_struct *mm = tsk->mm;
6161
siginfo_t info;
6262
int fault, ret;
63+
int write = cause_code & (1 << ECR_C_BIT_DTLB_ST_MISS); /* ST/EX */
6364
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
6465
(write ? FAULT_FLAG_WRITE : 0);
6566

arch/arc/mm/tlbex.S

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -381,18 +381,8 @@ do_slow_path_pf:
381381

382382
; ------- setup args for Linux Page fault Hanlder ---------
383383
mov_s r0, sp
384-
lr r2, [efa]
385-
lr r3, [ecr]
386-
387-
; Both st and ex imply WRITE access of some sort, hence do_page_fault( )
388-
; invoked with write=1 for DTLB-st/ex Miss and write=0 for ITLB miss or
389-
; DTLB-ld Miss
390-
; DTLB Miss Cause code is ld = 0x01 , st = 0x02, ex = 0x03
391-
; Following code uses that fact that st/ex have one bit in common
392-
393-
btst_s r3, ECR_C_BIT_DTLB_ST_MISS
394-
mov.z r1, 0
395-
mov.nz r1, 1
384+
lr r1, [efa]
385+
lr r2, [ecr]
396386

397387
; We don't want exceptions to be disabled while the fault is handled.
398388
; Now that we have saved the context we return from exception hence

0 commit comments

Comments
 (0)