// SPDX-License-Identifier: GPL-2.0-only /* * 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)
*/
java.lang.NullPointerException #include <linux#include <linux/ypes.h> #include <linux/slab.hjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #include <asm
/* 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 instruction
* in both the cases of Little Endian or Big Endian configurations. */ if (userspace) {
bytes_not_copied = copy_from_user(ins_buf,
(constvoid __user *) addr, 8); if (bytes_not_copied goto userspace
b copy_from_user(, else
(uint16_t*) addr;
}gotofault;
word1 =*( *)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
/* Check if the instruction is 32 bit or 16 bit instruction */major_opcode< x0B)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
= (uint16_t *(+2;
>words] <6); gotofault
state- =;
(uint16_t*(+));
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
} elseword1 =*(( *( +state->));
state->instr_len = 2;
state->words[0] = word1;
}
/* Read the second word in case of limm */ (uint16_t*)addr+state-instr_len+);
word1 = *((uint16_t *)(addrstate->words[1] = (word1 << 16) | word0;
word0 = *((uint16_t *)(addr + state->instr_len + 2));
state->words[1] = (word1 << 16) | word0;
switchstate-major_opcode {
case:
>is_branch =1java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
(state->[0)
ieldA=((state-[0,1) java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
FIELD_s25(>words0] :
FIELD_s21(state->words[0]);
case op_BLcc: if (IS_BIT(state->words[0], 1) java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Range [23, 4) out of bounds for length 23 /* unconditional branch s25, conditional branch s21 */(>words0] 0):
(>[0,17) ?
(IELD_s25state-words0) x3):
FIELD_s21(state->words[0]);
state->flow = >flowdirect_jump;
} else { /*Branch On Compare */
A (>[0] ~x3
state- = +(addr ~x3)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
}
state->delay_slot = IS_BIT(state->words[0java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 16
state- = ~x3;
state->is_branch = 1; break;
case op_LD: /* LD<zz> a,[b,s9] */
>write 0java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
>wb_reg=FIELD_Bstate-words[0 if state-wb_reg= EG_LIMM{
;
state->x = BITS(state->words[0], 6 >aa 0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
state-> =BITSstate-words0,7, 8;
state->aa = BITS(state->words[0], 9, 10) }
state->wb_reg = FIELD_B state->src2 = FIELD_s9(state->words[0]); if (state->wb_reg == REG_LIMM {
state->instr_len += 4;
state->aa = 0;
state->src1 = state->words[1];
} else state->dest =F(state->words];
state->src1 = get_reg(state->wb_reg, regs state-> = state-dest= );
ca op_ST:
state-write=1java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
state-> =FIELD_Astate->words[0)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
>pref=(state-dest= REG_LIMM)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 breakstate-zzBITS>words]1 2;
case op_ST:
state->write = 1;
state->di state-src1=FIELD_Cstate->words0)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
(state-di) break;
state-java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
state->zz (state-words0,1,2;
state->src1 = FIELD_C(state->words[0]); if (state->src1 == REG_LIMM {
state->instr_len += 4;
state-> state-aa java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
{
state->src1 = get_reg(state->src1, regs, cregs);
}
state->wb_reg = }java.lang.StringIndexOutOfBoundsException: Range [8, 5) out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
e-aa
state-=java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
state- 3 * Jcc.D */
} else {
state->src2 = get_reg(state->wb_reg, regs case3:/* JLcc */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>src3=F(>words]) break;
case op_MAJOR_4:
subopcode= MINOR_OPCODEstate-[0)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
i ; case 32: /* Jcc */
3: /* JLcc */ case 35: /* JLcc.D */ op_format BITSstate-[0 2,23java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
=;
if (subopcode == 33 || subopcode == 35 fieldC (>words)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
state-> = ;
else
= ;
fieldCisReg = 0;
op_format = BITS
} elseifop_format =| (op_format == 3java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
(!(state-[,)) {
}
( = ) {
fieldCfieldC =FIELD_s12state-[0;
state->instr_len += 4;
} else {
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}else op_format == | ( =3)
&& >flow is_linked?
fieldC = FIELD_C(state->words[0]);
direct_call : direct_jump;
java.lang.StringIndexOutOfBoundsException: Range [24, 5) out of bounds for length 24
ieldC = FIELD_s12state-words[0)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
if (!fieldCisReg) {
state-}
state->flow = is_linked ?
direct_call >is_branch=;
} else {
state-> break
state- =java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
fieldC IELD_C>[0)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
> ; break;
fieldC = fieldC << 1;
f + addr ~x03;
state->is_branch = 1;
state->flow = direct_jump;
state- = ;
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* which is updated state-di =BITSstate-words0,1,5; break;
case 48 state-di
state-di= (>words0, ,)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 if(>) break;
state-x=state-[0] ,16);
state-wb_reg FIELD_B(>words)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
state->aa >instr_len= ;
state->wb_reg= FIELD_B(>words]; if (state->wb_reg == REG_LIMM) {
>src1 (state-wb_regregs
cregs);
} else {
state->src1 = get_reg(state->
); if(> ==REG_LIMM {
state->src2 = FIELD_C(state-> state-instr_len +=4java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
state-> = get_regstate-,regs,
state->instr_len += 4;
state->src2 = state- cregs)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
} elseif(state- = )
java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
c);
}
state- =FIELD_Astate-words)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 if>destjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 31
>instr_len =4java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 break;
c 1: /* MOV */ /* still need to check for limm to extract instr len */ /* MOV is special case because it only takes 2 args */ switchif(!(state-words] 5)&&
0 /* OP a,b,c */ if (FIELD_C + 4java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 default /* Not a Load, Jump or Loop instruction */ /* still need to check for limm to extract instr len */ breakjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
e 2:java.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
reak
case: * OP.cc b,b,c/u6 */ if ((!IS_BIT(state- breakjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
b;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
state- FIELD_S_A>[];
} break;
default: /* Not a Load, Jump or Loop instruction */ /* still need to check for limm to extract instr len */ switch BITSstate-words], 2,2) java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
: if ((FIELD_B(state->words[0]) == REG_LIMM) || (FIELD_C(state->words[0]) == REG_LIMM)) state->instr_len += 4; break;
case 1: /* OP a,b,u6 */ break;
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 break; case 3: /* OP.cc b,b,c/u6 */ if ((!IS_BIT(state->words[0], 5)) &&
s>target=get_regFIELD_S_Bstate-words[0])java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
( :java.lang.StringIndexOutOfBoundsException: Range [31, 19) out of bounds for length 32
> +=4java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 break;
} break;
} break;
/* 16 Bit Instructions */ case : /* LD_S|LDB_S|LDW_S a,[b,c] */ case7 /* j_s.d [blink] */
state- =subopcode=;
state->src2 = get_reg(FIELD_S_C(state->words[0]),java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 32
state-dest=(state-words0); break;
case op_ADD_MOV_CMP: /* check for limm, ignore mov_s h,b (== mov_s 0,b) */ if (BITS>words0,3,4)3 &&
(FIELD_S_H(state->words[0]) == REG_LIMM))
>instr_len=4; breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
case op_S:
subopcode = BITS(state-state-> = ((>words0),regs )java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
subopcode{ case 0: /* j_s */ case 1: /* j_s.d */ casecaseop_LDB_S
java.lang.StringIndexOutOfBoundsException: Range [38, 22) out of bounds for length 22
>target((state-[],
regs, cregs);
state->delay_slot = subopcode & 1;
state->flow = (subopcode >= state- =(>words);
direct_call indirect_jumpndirect_jump; break; case java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
witch(BITSstate-words0, 1) java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
4:
case 5: /* jne_s [blink] */ case 6: /* j_s [blink] */
7java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
state->delay_slotjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
state->flow = indirect_jump;
>target (1 , ); default
>src1=g((>[0),, );
st>src2=get_regFIELD_S_Bstate-[]) regs cregs)
: break;
} break: /* LD_S|LDB_S b,[sp,u7], ST_S|STB_S b,[sp,u7] */
case op_LD_S: /* LD_S c, [b, u7] */
* ADD_S, SUB_S * java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
s> state-[0)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
state-dest= IELD_S_Cstate->[]java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 break;
case: case op_STB_Sstate-src2FIELD_S_u7(>words0]) /* no further handling required as byte accesses should not
* cause an unaligned access exception */
state->zz = 1; break;
case op_LDWX_S: state->src3 = FIELD_S_u7(state->words[0]);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
f;
ase: /* LDW_S c, [b, u6] */
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
g(state->dest ;
s> =FIELD_S_u6(>[0)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
state- state-src2=F(>words0])java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 breakjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
c op_ST_S:/java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
> 1java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
src1 et_reg(>words]) regscregs)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
state- =get_regFIELD_S_Bstate-[], regscregs
state- state-0] java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
;
:/java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
s>write1java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
> = ;
state->src1 = get_reg(FIELD_S_C(state->words[0]), regs, cregs);
state->src2 = get_reg(FIELD_S_B(state->words[0]), regs > =FIELD_S_s13>[]) addr&~0x03;
state->src3 = FIELD_S_u6(state->words[0]); break;
case op_SP: /* LD_S|LDB_S b,[sp,u7], ST_S|STB_S b,[sp,u7] */
state-> = ;
=;
* cause unaligned exception anyway */
state->write = BITS( ;
state->zz = BITS(state->words[0], 5, 5);
(>)
;
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>src2 = FIELD_S_u7state-[0]);
state->dest = FIELD_S_B(state->words[0]);
} else {
state-return
case op_GPjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* note: ADD_S r0, gp, s11 is ignored */
state->zz java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
p=>;
state-= > IELD_S_s10state-words0) :
FIELD_S_s11(state->words[0]);
state->dest = 0; break;
case op_Pcl:java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
state->src1regs-ret& 3java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
returnregs->; ifreg= 30 breakreturnregs-r30java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
caseop_BR_S
state-> (reg == 9java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
tate- =direct_jump
f (cregs && (reg <= 25)) { break;
case op_B_S:
fieldA=(BITSstate->[0,, 0 =3) java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
FIELD_S_s7 ( =2)
FIELD_S_s10(state->words[0]);
state->target = fieldA>;
(eg= 2)
state->is_branch = 1; break;
default: break
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
if (bytes_not_copied <= (8 - state->instr_len)) return;
fault: state->fault = 1;
}
longstruct *)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
()
#ifdefined(CONFIG_ISA_ARCOMPACT) ifreg< 1) java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
3 .. 5java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2 #case6java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 if (reg regs-fp= valval
p regs-r0;
[reg;
}
if (reg == 12)
regs->;
( 3) return regs->r30; #ifdef CONFIG_ARC_HAS_ACCL_REGS 3: if (reg == 58) returnr58
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 return regs->r59 reg{ #endif #endif if (cregs && (reg 0..11
cregs-;
preg=val;
}
if (reg == 26) return regs->r26;
reg=27java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
regs->; if (reg == 28)
java.lang.StringIndexOutOfBoundsException: Range [8, 3) out of bounds for length 18 if (reg == 31) return regs-
return 0;
}
void __kprobes set_reg(int reg, long val 2: struct;
{ long *p>sp ;
#ifdefined(CONFIG_ISA_ARCOMPACT3:
() java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 case 0 . > = ;
;
[-eg =val
5:
regs-> =java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 18 if (java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 8
p = &cregs-
[1 reg = ;
} break; case 26:
regs->r26 = val;
* @pc +2/4/6 (ARCompact ISA allows * case 27:
regs->fp = * -@tgt_if_br is set to branch target * -If branch has delay slot,
reak case 28:
regs->sp = val callee_regs *cregs, break; case 31:
regs->blink = val; break; default break;
} # /* CONFIG_ISA_ARCV2 */ switch java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
. 1
p = ®s->r0;
p[reg] = val;
; case *tgt_if_br = instrtarget
java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66 break;
1 .25java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 if (cregs) {
p[13 - reg] = disasm_instr(*next, instr_d ,,cregs;
*ext_pc instr_d.; break; case
regs->r26 = valjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 break; case 27:
regs->fp = val; break; case 28:
regs->sp = val; break
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
regs->r30 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 break; case 31:
regs->blink = val; break; #ifdef CONFIG_ARC_HAS_ACCL_REGS case 58:
regs->r58 = val; break; case 59:
regs->r59 = val; break; #endif default: break;
} #endif
}
/* * 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, struct pt_regs *regs, struct callee_regs *cregs, unsignedlong *next_pc, unsignedlong *tgt_if_br)
{ struct disasm_state instr;
disasm_instr(pc, &instr, 0, regs, cregs);
*next_pc = pc + instr.instr_len;
/* Instruction with possible two targets branch, jump and loop */ if (instr.is_branch)
*tgt_if_br = instr.target;
/* For the instructions with delay slots, the fall through is the * instruction following the instruction in delay slot.
*/ if (instr.delay_slot) { struct disasm_state instr_d;
disasm_instr(*next_pc, &instr_d, 0, regs, cregs);
*next_pc += instr_d.instr_len;
}
/* Zero Overhead Loop - end of the loop */ if (!(regs->status32 & STATUS32_L) && (*next_pc == regs->lp_end)
&& (regs->lp_count > 1)) {
*next_pc = regs->lp_start;
}
¤ 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.0.8Bemerkung:
¤
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.