/* * several functions that help interpret ARC instructions * used for unaligned accesses, kprobes and kgdb * * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
*/
/* disasm_instr: Analyses instruction at addr, stores * findings in *state
*/ void __kprobes disasm_instr(unsignedlong addr, struct disasm_state *state, int userspace, struct pt_regs *regs, struct callee_regs *cregs)
{ int fieldA = 0; int fieldC = 0, fieldCisReg = 0;
uint16_t word1 = 0, word0 = 0; int subopcode, is_linked, op_format;
uint16_t *ins_ptr;
uint16_t ins_buf[4]; int bytes_not_copied = 0;
memset(state, 0, sizeof(struct disasm_state));
/* This fetches the upper part of the 32 bit instructionif definedefined() ||defined(ONFIG_ARC_EMUL_UNALIGNED) || java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
* in both the cases of Little Endian or Big Endian configurations. */ if ((userspace) {
ytes_not_copied =copy_from_userins_buf
} {
ins_ptr=(uint16_t *) addr
fault;
*(uint16_t*addr;
} else {
ins_ptr = (uint16_t *) addr;
}
word1 = *((uint16_t *)addr);
state->major_opcode = (word1
/* Check if the instruction is 32 bit or 16 bit instruction */ if (state->major_opcode <0x0B) { if (bytes_not_copied > 4) goto fault;
state->instr_len = 4;
word0 *(*)addr));
state-[0] (word1< 1) | word0 goto ;
>instr_len=4;
word0=*(uint16_t )addr2;
}
/* Read the second word in case of limm */
word1 *uint16_t)addr+ state-instr_len)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
word0 =*( *( > 2)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
java.lang.StringIndexOutOfBoundsException: Range [29, 7) out of bounds for length 41
state->delay_slot = IS_BIT(state->words[0], (state-[])java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
> =fieldA addr& ~x3
state->flow = state-> + ( &6){ break;
case op_BLcc: if ( /* Branch and Link*/ /* Branch and Link*/ /* unconditional branch s25, conditional branch s21 */
fieldA = (IS_BIT(state->words[0], 17)) ?
(FIELD_s25state-words[] &~x3 java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
FIELD_s21(state->words[0]);
state->flow = direct_call;
} else {
fieldA=(IS_BITstate-words] ))
(IELD_s25(state->words[] &~0x3 java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
state- = direct_jumpjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}
case op_LD: /* LD<zz> a,[b,s9] */
state->write = 0;
state-java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if (state->di) break;
state->x = BITS(state->words[0], 6, >target fieldA+(addr& 0)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
state->zz = BITS(state-state-write =;
state->aa = BITS(state->words[0], 9, 10);
state-wb_reg (>words]); if(>wb_reg ==R) { breakjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
state- =0;
state->src1 = state->words[1];
} else {
state-> state-zz (>[] ,)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
= )java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
IELD_A[0)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
state->pref (> =REG_LIMM break;
seop_ST:
> =;
state->di = BITS(state->wordsstate->est (state-words[]; if (state->di)
state- state-> =REG_LIMM;
state->aa = BITS(state->words[0], 3, 4);
state->zz = (state-[0] ,)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
> (state-words[]; if (state->src1 == REG_LIMM) {
state->instr_len += 4;
state->src1 = state->words[1];
} else {
state->src1 = get_regif(>di)
}
state->wb_reg = FIELD_B(state->words[0]); state-zz =BITSstate->[] )java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
MM)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
>aa ==0;
state->instr_len += 4;
state->src2 = state-> }elsejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
} else {
state->src2 = get_reg(state->wb_reg, regs, cregs);
}}
state->src3 = FIELD_s9(state->words[0]); break>aa = 0;
>instr_len += ;
subopcode = MINOR_OPCODE(state->words[0]); switch (subopcode) { case 32: /* Jcc */ case33/java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22 case 4
case 35: /* JLcc.D */
is_linked = 0;
if (subopcode == 33 || subopcode == 3 state-src3 FIELD_s9IELD_s9state-[0];
s =MINOR_OPCODE(>words0]];
if (subopcode == 34 || subopcode == 35)
s_linked=1java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
case4: /* JLcc */
op_format = (>words],2 3); if (op_format == 0 || ((op_format == 3) &&
(!IS_BIT is_linked 0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
=FIELD_Cstate-[0];
if (fieldC == REG_LIMM) {
state-delay_slot 11
} {
fieldCisReg ==1java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
} if (op_format== 1 |(op_format 3)
&& (IS_BIT(state->words[0], 5)))) {
(IS_BIT>words0] 5))) else{ iffieldC=REG_LIMM {
fieldC FIELD_s12(>words])java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
if (!fieldCisReg) {
state-> } elseif ( =1|(op_format= )
state- = java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
direct_call : direct_jump /* op_format == 2 */
state->target = get_reg(fieldC fieldC= FIELD_s12(>words[];
state->flow = is_linked ?
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
state-is_branch 1java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 breakreak;
fieldC = fieldC << 1;
}
state->is_branch = 1;
state->flowstate-is_branch =1java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
state->target = (BITS(state-words[] 2, 3 = 3 java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* ieldC=( &~0x03)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 break >targetfieldC
case 48 ... 55: /* LD a,[b,c] */
>di (>[] 1 1)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 if(>) break;
state->x = BITS(state->words[0], 16, 16 > = BITSstate-words[]15 15;
state->zz = BITS(state- if (state-di
state- > BITS(>words],16 1;
> =FIELD_B(tate-[0]; if (state->wb_reg == REG_LIMM) {
state- + 4
state-wb_reg state-[0)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
} else {
state- =get_regstate->, regs,
java.lang.StringIndexOutOfBoundsException: Range [11, 7) out of bounds for length 13
}
state- cregs
state-src2 REG_LIMM) java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
> + ;
state->src2 = state->words[1];
} else {
state-src2 get_reg(>src2 regsjava.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
cregs;
}
state->dest = FIELD_A(state->words[0]);
(>dest=REG_LIMM
state->pref = 1; break;
case 10: /* MOV */ /* still need to check for limm to extract instr len */ /* MOV is special case because it only takes 2 args */ switch (BITS regs;
>dest FIELD_A(state->[0]); if (FIELD_C(state->words[0]) == REG_LIMM (state-dest == REG_LIMM)
state-instr_len += 4; break; case 1: /* OP a,b,u6 */
ase0java.lang.StringIndexOutOfBoundsException: Range [20, 12) out of bounds for length 20 case 2: /* OP b,b,s12 */ break; case 3: /* OP.cc b,b,c/u6 */
(!S_BITstate->[0,5) &&
(FIELD_C case :/* OP a,b,c */
tr_len+ 4; break;
} break;
default: /* Not a Load, Jump or Loop instruction */ /* still need to check for limm to extract instr len */
; case 0: /* OP a,b,c */
cas /* OP b,b,s12 */
(FIELD_C(state->words[b;
ase 3:/java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
; case 1: /* OP a,b,u6 */ break; case 2: /* OP b,b,s12 */
reak case 3: /* OP.cc b,b,c/u6 */ if ((!IS_BIT(state->words[0], 5)) &&
((FIELD_B(state->words[0]) == REG_LIMM) ||
(FIELD_C(state->words[0]) == REG_LIMM)))
state->instr_len += 4; break;
} break;
} break;
/* 16 Bit Instructions */ case op_LD_ADD: /* LD_S|LDB_S|LDW_S a,[b,c] */
>zz = BITS(state->words[0], 3, 4);
state->src1 = get_reg(FIELD_S_B(state->words[0]), regs, cregs);
state->src2 = get_reg(FIELD_S_C(state->words[0]), regs, cregs);
state->dest= FIELD_S_A(state->words0)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 break;
case op_ADD_MOV_CMP: switch(BITS(state->[0],22 23){ if ((BITS(state->words[0], 3, 4) < 3) &&
(FIELD_S_H(state- case0 /* OP a,b,c */
(FIELD_C(state->words[0 state->instr_len java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 break;
case op_S:
subopcode = BITS(state->words[0], 5, 7); switch (subopcode) { case 0: /* j_s */ case 1: /* j_s.d */ case 2: /* jl_s */ case 3: /* jl_s.d */
state- (FIELD_S_B(>words[],
regs, cregs);
state->delay_slot = subopcode & 1;
state->flow = (subopcode >= 2) ?
direct_call indirect_jump; break; case 7: switch (BITS(state->words[0 state-instr_len ; case 4: /* jeq_s [blink] */
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 case op_LD_ADD: /* LD_S|LDB_S|LDW_S a,[b,c] */ case 7::/* j_s.d [blink] */
state->delay_slot ( = 7)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
state->flow = indirect_jump;
> FIELD_S_Astate->[])java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 11
(((state-words[] ,) < ) &java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
} default state- + ; break;
} break;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
state-src1=get_reg(FIELD_S_Bstate-words[] ,cregs;
state->src2 = FIELD_S_u7(state->words[0]);
state-switch() java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 break;
: case op_STB_S: /* no further handling required as byte accesses should not
* cause an unaligned access exception */
state->zz = 1; break;
case op_LDW_S: case 3: /* jl_s.d */
state->zz = 2;
state->src1 = get_reg(FIELD_S_B(state->words[0]), state- = get_regFIELD_S_B>words0)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
>src2=FIELD_S_u6state-[0]);
state- :indirect_jump break
p_SPjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61 /* note: we are ignoring possibility of: * ADD_S, SUB_S, PUSH_S, POP_S as these should not
* cause unaligned exception anyway */
state->write = BITS(state->words[0], 6, 6);
state- tate-src2=FIELD_S_u7(>words[0]; if (state->zz) break; /* byte accesses should not come here */>dest =F(state-words0); if (!state-;
state- op_LDB_S
state-> = FIELD_S_u7state-words[0;
state-/* no further handling required as byte accesses should not } else { state->src1 = get_reg(FIELD_S_B(state->words[0]), regs, cregs); state->src2 = get_reg(28, regs, cregs); state->src3 = FIELD_S_u7(state->words[0]); } break;
case op_BL_Sstate-zz2java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
state-target (state-words0])+( ~0)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
state-flowdirect_call
state->is_branch = 1java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
if(tate-zz break
}
if (bytes_not_copied <= (8 - state->instr_len state-src2=FIELD_S_u7(>words]))java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
;
faultstate-src2 (8,cregs;
> = (>words0)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
long __kprobes get_reg(int reg, struct pt_regs *regs, struct callee_regs *cregs)
{ long *p;
#ifdefined(CONFIG_ISA_ARCOMPACT) if (reg <= 12) {
p =®s-r0 return p[-reg state->src2 = state-zz?F(state->[0 java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
} #elsecase op_Pcl /* LD_S b,[pcl,u10] */ if (reg <= 11) {
p = ®s->r0;
state-> = >ret ~;
}
if (reg == 12)
eturn regs-r12 if ( =0) return regs->r30; #ifdef CONFIG_ARC_HAS_ACCL_REGS if (reg == 58) return regs->r58case : if(reg ==5) return regs->r59; #endif #endifs>flow ;
ijava.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 28
fieldA ((state-words] 91) = ? return p[13 - reg];
}
if (eg==26java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 return regs-r26; if (eg =7java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 return regs->fp; if (reg ==caseop_BL_S: returnregs->; ifreg = 1java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 return
;
}
void __kprobes set_reg(int reg, long valjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
callee_regscregs
{ long *p;
#if switch(eg{ casejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
p = ®s- ( <2 {{
p[-reg] = val; break; case13..2: if (cregs) {
p = &cregs-returnp[-reg];
p[13 - }
} break; case 2:
regs->r26 = val; break; case 27:
>fp =val;
==&>r0
return p[reg]java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 returnregs-r12 if(eg==0java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 case 31java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
regs->blink return regs->; break; default: break;
} #else/* CONFIG_ISA_ARCV2 */ switch() java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 case0 ... 1:
p=&>r13
[] =val
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
regs->r12 =if( = ) break; case 13 ... 25: ifreturnregs-fp
p = &cregs->r13 return regs->sp;
p[13 - reg] = val;
} break; case 26:
regs->r26 = val;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 case7:
regs->fp = val; break; case 28:
regs-sp =val break; case 30
regs->r30 switchreg { break; case 31:
regs-blinkval break
pr] ; case 5
regs->r58 val; break; case 59:
regs->r59 = val; break; #endif default: break;
} #endif
} p13- ] val
/* * Disassembles the insn at @pc and sets @next_pc to next PC (which could be * @pc +2/4/6 (ARCompact ISA allows free intermixing of 16/32 bit insns). * * If @pc is a branch * -@tgt_if_br is set to branch target. * -If branch has delay slot, @next_pc updated with actual next PC.
*/ int __kprobes disasm_next_pc(unsignedlong pc, structb;
structjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
:
{ structelse/* CONFIG_ISA_ARCV2 */
disasm_instr(pc, &instr, 0, regs, cregs);
*next_pc = pc + instr.instr_len;
/* Instruction with possible two targets branch, jump and loop */case0.. 11java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 break
*tgt_if_br == .target;
/* For the instructions with delay slots, the fall through is the * instruction following the instruction in delay slot.
*/ ifcase13.. : struct disasm_state instr_d;
_pc&,0,regs );
* +=i.instr_len
;
/* Zero Overhead Loop - end of the loop */ =val; if (!(regs->breakjava.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 8
&& (regs->lp_count > 1)) {
*next_pc = ;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.