Skip to content

Commit 5bd87ad

Browse files
committed
ARC: [ASID] Refactor the TLB paranoid debug code
-Asm code already has values of SW and HW ASID values, so they can be passed to the printing routine. Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent ade922f commit 5bd87ad

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎arch/arc/include/asm/mmu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef struct {
5252
} mm_context_t;
5353

5454
#ifdef CONFIG_ARC_DBG_TLB_PARANOIA
55-
void tlb_paranoid_check(unsigned int pid_sw, unsigned long address);
55+
void tlb_paranoid_check(unsigned int mm_asid, unsigned long address);
5656
#else
5757
#define tlb_paranoid_check(a, b)
5858
#endif

‎arch/arc/mm/tlb.c‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -688,25 +688,27 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
688688
* Low Level ASM TLB handler calls this if it finds that HW and SW ASIDS
689689
* don't match
690690
*/
691-
void print_asid_mismatch(int is_fast_path)
691+
void print_asid_mismatch(int mm_asid, int mmu_asid, int is_fast_path)
692692
{
693-
int pid_sw, pid_hw;
694-
pid_sw = current->active_mm->context.asid;
695-
pid_hw = read_aux_reg(ARC_REG_PID) & 0xff;
696-
697693
pr_emerg("ASID Mismatch in %s Path Handler: sw-pid=0x%x hw-pid=0x%x\n",
698-
is_fast_path ? "Fast" : "Slow", pid_sw, pid_hw);
694+
is_fast_path ? "Fast" : "Slow", mm_asid, mmu_asid);
699695

700696
__asm__ __volatile__("flag 1");
701697
}
702698

703-
void tlb_paranoid_check(unsigned int pid_sw, unsigned long addr)
699+
void tlb_paranoid_check(unsigned int mm_asid, unsigned long addr)
704700
{
705-
unsigned int pid_hw;
701+
unsigned int mmu_asid;
706702

707-
pid_hw = read_aux_reg(ARC_REG_PID) & 0xff;
703+
mmu_asid = read_aux_reg(ARC_REG_PID) & 0xff;
708704

709-
if (addr < 0x70000000 && ((pid_hw != pid_sw) || (pid_sw == NO_ASID)))
710-
print_asid_mismatch(0);
705+
/*
706+
* At the time of a TLB miss/installation
707+
* - HW version needs to match SW version
708+
* - SW needs to have a valid ASID
709+
*/
710+
if (addr < 0x70000000 &&
711+
((mmu_asid != mm_asid) || (mm_asid == NO_ASID)))
712+
print_asid_mismatch(mm_asid, mmu_asid, 0);
711713
}
712714
#endif

‎arch/arc/mm/tlbex.S‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ex_saved_reg1:
102102
; VERIFY if the ASID in MMU-PID Reg is same as
103103
; one in Linux data structures
104104

105-
DBG_ASID_MISMATCH
105+
tlb_paranoid_check_asm
106106
.endm
107107

108108
.macro TLBMISS_RESTORE_REGS
@@ -133,34 +133,32 @@ ex_saved_reg1:
133133
; In bizzare scenrios SW and HW ASID can get out-of-sync which is trouble.
134134
; So we try to detect this in TLB Mis shandler
135135

136-
137-
.macro DBG_ASID_MISMATCH
136+
.macro tlb_paranoid_check_asm
138137

139138
#ifdef CONFIG_ARC_DBG_TLB_PARANOIA
140139

141-
; make sure h/w ASID is same as s/w ASID
142-
143140
GET_CURR_TASK_ON_CPU r3
144141
ld r0, [r3, TASK_ACT_MM]
145142
ld r0, [r0, MM_CTXT+MM_CTXT_ASID]
146143

147144
lr r1, [ARC_REG_PID]
148145
and r1, r1, 0xFF
146+
149147
breq r1, r0, 5f
150148

151149
; Error if H/w and S/w ASID don't match, but NOT if in kernel mode
152-
lr r0, [erstatus]
153-
bbit0 r0, STATUS_U_BIT, 5f
150+
lr r2, [erstatus]
151+
bbit0 r2, STATUS_U_BIT, 5f
154152

155153
; We sure are in troubled waters, Flag the error, but to do so
156154
; need to switch to kernel mode stack to call error routine
157155
GET_TSK_STACK_BASE r3, sp
158156

159157
; Call printk to shoutout aloud
160-
mov r0, 1
158+
mov r2, 1
161159
j print_asid_mismatch
162160

163-
5: ; ASIDs match so proceed normally
161+
5: ; ASIDs match so proceed normally
164162
nop
165163

166164
#endif

0 commit comments

Comments
 (0)