sstep.c (7fa95f9adaee7e5cbb195d3359741120829e488b) sstep.c (68a180a44c29d7e918ae7d3c18a01b0751d1c22f)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Single-step support.
4 *
5 * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM
6 */
7#include <linux/kernel.h>
8#include <linux/kprobes.h>
9#include <linux/ptrace.h>
10#include <linux/prefetch.h>
11#include <asm/sstep.h>
12#include <asm/processor.h>
13#include <linux/uaccess.h>
14#include <asm/cpu_has_feature.h>
15#include <asm/cputable.h>
16#include <asm/disassemble.h>
17
18extern char system_call_common[];
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Single-step support.
4 *
5 * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM
6 */
7#include <linux/kernel.h>
8#include <linux/kprobes.h>
9#include <linux/ptrace.h>
10#include <linux/prefetch.h>
11#include <asm/sstep.h>
12#include <asm/processor.h>
13#include <linux/uaccess.h>
14#include <asm/cpu_has_feature.h>
15#include <asm/cputable.h>
16#include <asm/disassemble.h>
17
18extern char system_call_common[];
19extern char system_call_vectored_emulate[];
20
21#ifdef CONFIG_PPC64
22/* Bits in SRR1 that are copied from MSR */
23#define MSR_MASK 0xffffffff87c0ffffUL
24#else
25#define MSR_MASK 0x87c0ffff
26#endif
27

--- 168 unchanged lines hidden (view full) ---

196static nokprobe_inline unsigned long mlsd_8lsd_ea(unsigned int instr,
197 unsigned int suffix,
198 const struct pt_regs *regs)
199{
200 int ra, prefix_r;
201 unsigned int dd;
202 unsigned long ea, d0, d1, d;
203
19
20#ifdef CONFIG_PPC64
21/* Bits in SRR1 that are copied from MSR */
22#define MSR_MASK 0xffffffff87c0ffffUL
23#else
24#define MSR_MASK 0x87c0ffff
25#endif
26

--- 168 unchanged lines hidden (view full) ---

195static nokprobe_inline unsigned long mlsd_8lsd_ea(unsigned int instr,
196 unsigned int suffix,
197 const struct pt_regs *regs)
198{
199 int ra, prefix_r;
200 unsigned int dd;
201 unsigned long ea, d0, d1, d;
202
204 prefix_r = instr & (1ul << 20);
205 ra = (suffix >> 16) & 0x1f;
203 prefix_r = GET_PREFIX_R(instr);
204 ra = GET_PREFIX_RA(suffix);
206
207 d0 = instr & 0x3ffff;
208 d1 = suffix & 0xffff;
209 d = (d0 << 16) | d1;
210
211 /*
212 * sign extend a 34 bit number
213 */

--- 1018 unchanged lines hidden (view full) ---

1232 op->type |= SETLK;
1233 if (branch_taken(word, regs, op))
1234 op->type |= BRTAKEN;
1235 return 1;
1236#ifdef CONFIG_PPC64
1237 case 17: /* sc */
1238 if ((word & 0xfe2) == 2)
1239 op->type = SYSCALL;
205
206 d0 = instr & 0x3ffff;
207 d1 = suffix & 0xffff;
208 d = (d0 << 16) | d1;
209
210 /*
211 * sign extend a 34 bit number
212 */

--- 1018 unchanged lines hidden (view full) ---

1231 op->type |= SETLK;
1232 if (branch_taken(word, regs, op))
1233 op->type |= BRTAKEN;
1234 return 1;
1235#ifdef CONFIG_PPC64
1236 case 17: /* sc */
1237 if ((word & 0xfe2) == 2)
1238 op->type = SYSCALL;
1240 else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) &&
1241 (word & 0xfe3) == 1)
1242 op->type = SYSCALL_VECTORED_0;
1243 else
1244 op->type = UNKNOWN;
1245 return 0;
1246#endif
1247 case 18: /* b */
1248 op->type = BRANCH | BRTAKEN;
1249 imm = word & 0x03fffffc;
1250 if (imm & 0x02000000)

--- 87 unchanged lines hidden (view full) ---

1338 rd = (word >> 21) & 0x1f;
1339 ra = (word >> 16) & 0x1f;
1340 rb = (word >> 11) & 0x1f;
1341 rc = (word >> 6) & 0x1f;
1342
1343 switch (opcode) {
1344#ifdef __powerpc64__
1345 case 1:
1239 else
1240 op->type = UNKNOWN;
1241 return 0;
1242#endif
1243 case 18: /* b */
1244 op->type = BRANCH | BRTAKEN;
1245 imm = word & 0x03fffffc;
1246 if (imm & 0x02000000)

--- 87 unchanged lines hidden (view full) ---

1334 rd = (word >> 21) & 0x1f;
1335 ra = (word >> 16) & 0x1f;
1336 rb = (word >> 11) & 0x1f;
1337 rc = (word >> 6) & 0x1f;
1338
1339 switch (opcode) {
1340#ifdef __powerpc64__
1341 case 1:
1346 prefix_r = word & (1ul << 20);
1347 ra = (suffix >> 16) & 0x1f;
1342 prefix_r = GET_PREFIX_R(word);
1343 ra = GET_PREFIX_RA(suffix);
1348 rd = (suffix >> 21) & 0x1f;
1349 op->reg = rd;
1350 op->val = regs->gpr[rd];
1351 suffixopcode = get_op(suffix);
1352 prefixtype = (word >> 24) & 0x3;
1353 switch (prefixtype) {
1354 case 2:
1355 if (prefix_r && ra)

--- 1358 unchanged lines hidden (view full) ---

2714 break;
2715 case 2: /* stq */
2716 if (!(rd & 1))
2717 op->type = MKOP(STORE, 0, 16);
2718 break;
2719 }
2720 break;
2721 case 1: /* Prefixed instructions */
1344 rd = (suffix >> 21) & 0x1f;
1345 op->reg = rd;
1346 op->val = regs->gpr[rd];
1347 suffixopcode = get_op(suffix);
1348 prefixtype = (word >> 24) & 0x3;
1349 switch (prefixtype) {
1350 case 2:
1351 if (prefix_r && ra)

--- 1358 unchanged lines hidden (view full) ---

2710 break;
2711 case 2: /* stq */
2712 if (!(rd & 1))
2713 op->type = MKOP(STORE, 0, 16);
2714 break;
2715 }
2716 break;
2717 case 1: /* Prefixed instructions */
2722 prefix_r = word & (1ul << 20);
2723 ra = (suffix >> 16) & 0x1f;
2718 prefix_r = GET_PREFIX_R(word);
2719 ra = GET_PREFIX_RA(suffix);
2724 op->update_reg = ra;
2725 rd = (suffix >> 21) & 0x1f;
2726 op->reg = rd;
2727 op->val = regs->gpr[rd];
2728
2729 suffixopcode = get_op(suffix);
2730 prefixtype = (word >> 24) & 0x3;
2731 switch (prefixtype) {

--- 645 unchanged lines hidden (view full) ---

3377 regs->gpr[10] = MSR_KERNEL;
3378 regs->gpr[11] = regs->nip + 4;
3379 regs->gpr[12] = regs->msr & MSR_MASK;
3380 regs->gpr[13] = (unsigned long) get_paca();
3381 regs->nip = (unsigned long) &system_call_common;
3382 regs->msr = MSR_KERNEL;
3383 return 1;
3384
2720 op->update_reg = ra;
2721 rd = (suffix >> 21) & 0x1f;
2722 op->reg = rd;
2723 op->val = regs->gpr[rd];
2724
2725 suffixopcode = get_op(suffix);
2726 prefixtype = (word >> 24) & 0x3;
2727 switch (prefixtype) {

--- 645 unchanged lines hidden (view full) ---

3373 regs->gpr[10] = MSR_KERNEL;
3374 regs->gpr[11] = regs->nip + 4;
3375 regs->gpr[12] = regs->msr & MSR_MASK;
3376 regs->gpr[13] = (unsigned long) get_paca();
3377 regs->nip = (unsigned long) &system_call_common;
3378 regs->msr = MSR_KERNEL;
3379 return 1;
3380
3385#ifdef CONFIG_PPC64_BOOK3S
3386 case SYSCALL_VECTORED_0: /* scv 0 */
3387 regs->gpr[9] = regs->gpr[13];
3388 regs->gpr[10] = MSR_KERNEL;
3389 regs->gpr[11] = regs->nip + 4;
3390 regs->gpr[12] = regs->msr & MSR_MASK;
3391 regs->gpr[13] = (unsigned long) get_paca();
3392 regs->nip = (unsigned long) &system_call_vectored_emulate;
3393 regs->msr = MSR_KERNEL;
3394 return 1;
3395#endif
3396
3397 case RFI:
3398 return -1;
3399#endif
3400 }
3401 return 0;
3402
3403 instr_done:
3404 regs->nip = truncate_if_32bit(regs->msr, regs->nip + GETLENGTH(op.type));
3405 return 1;
3406}
3407NOKPROBE_SYMBOL(emulate_step);
3381 case RFI:
3382 return -1;
3383#endif
3384 }
3385 return 0;
3386
3387 instr_done:
3388 regs->nip = truncate_if_32bit(regs->msr, regs->nip + GETLENGTH(op.type));
3389 return 1;
3390}
3391NOKPROBE_SYMBOL(emulate_step);