diff options
Diffstat (limited to 'arch/powerpc/lib/sstep.c')
-rw-r--r-- | arch/powerpc/lib/sstep.c | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index f73daa6f3970..9a52349874ee 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c | |||
@@ -46,6 +46,18 @@ extern int do_stxvd2x(int rn, unsigned long ea); | |||
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Emulate the truncation of 64 bit values in 32-bit mode. | ||
50 | */ | ||
51 | static unsigned long truncate_if_32bit(unsigned long msr, unsigned long val) | ||
52 | { | ||
53 | #ifdef __powerpc64__ | ||
54 | if ((msr & MSR_64BIT) == 0) | ||
55 | val &= 0xffffffffUL; | ||
56 | #endif | ||
57 | return val; | ||
58 | } | ||
59 | |||
60 | /* | ||
49 | * Determine whether a conditional branch instruction would branch. | 61 | * Determine whether a conditional branch instruction would branch. |
50 | */ | 62 | */ |
51 | static int __kprobes branch_taken(unsigned int instr, struct pt_regs *regs) | 63 | static int __kprobes branch_taken(unsigned int instr, struct pt_regs *regs) |
@@ -91,11 +103,8 @@ static unsigned long __kprobes dform_ea(unsigned int instr, struct pt_regs *regs | |||
91 | if (instr & 0x04000000) /* update forms */ | 103 | if (instr & 0x04000000) /* update forms */ |
92 | regs->gpr[ra] = ea; | 104 | regs->gpr[ra] = ea; |
93 | } | 105 | } |
94 | #ifdef __powerpc64__ | 106 | |
95 | if (!(regs->msr & MSR_SF)) | 107 | return truncate_if_32bit(regs->msr, ea); |
96 | ea &= 0xffffffffUL; | ||
97 | #endif | ||
98 | return ea; | ||
99 | } | 108 | } |
100 | 109 | ||
101 | #ifdef __powerpc64__ | 110 | #ifdef __powerpc64__ |
@@ -114,9 +123,8 @@ static unsigned long __kprobes dsform_ea(unsigned int instr, struct pt_regs *reg | |||
114 | if ((instr & 3) == 1) /* update forms */ | 123 | if ((instr & 3) == 1) /* update forms */ |
115 | regs->gpr[ra] = ea; | 124 | regs->gpr[ra] = ea; |
116 | } | 125 | } |
117 | if (!(regs->msr & MSR_SF)) | 126 | |
118 | ea &= 0xffffffffUL; | 127 | return truncate_if_32bit(regs->msr, ea); |
119 | return ea; | ||
120 | } | 128 | } |
121 | #endif /* __powerpc64 */ | 129 | #endif /* __powerpc64 */ |
122 | 130 | ||
@@ -137,11 +145,8 @@ static unsigned long __kprobes xform_ea(unsigned int instr, struct pt_regs *regs | |||
137 | if (do_update) /* update forms */ | 145 | if (do_update) /* update forms */ |
138 | regs->gpr[ra] = ea; | 146 | regs->gpr[ra] = ea; |
139 | } | 147 | } |
140 | #ifdef __powerpc64__ | 148 | |
141 | if (!(regs->msr & MSR_SF)) | 149 | return truncate_if_32bit(regs->msr, ea); |
142 | ea &= 0xffffffffUL; | ||
143 | #endif | ||
144 | return ea; | ||
145 | } | 150 | } |
146 | 151 | ||
147 | /* | 152 | /* |
@@ -467,7 +472,7 @@ static void __kprobes set_cr0(struct pt_regs *regs, int rd) | |||
467 | 472 | ||
468 | regs->ccr = (regs->ccr & 0x0fffffff) | ((regs->xer >> 3) & 0x10000000); | 473 | regs->ccr = (regs->ccr & 0x0fffffff) | ((regs->xer >> 3) & 0x10000000); |
469 | #ifdef __powerpc64__ | 474 | #ifdef __powerpc64__ |
470 | if (!(regs->msr & MSR_SF)) | 475 | if (!(regs->msr & MSR_64BIT)) |
471 | val = (int) val; | 476 | val = (int) val; |
472 | #endif | 477 | #endif |
473 | if (val < 0) | 478 | if (val < 0) |
@@ -488,7 +493,7 @@ static void __kprobes add_with_carry(struct pt_regs *regs, int rd, | |||
488 | ++val; | 493 | ++val; |
489 | regs->gpr[rd] = val; | 494 | regs->gpr[rd] = val; |
490 | #ifdef __powerpc64__ | 495 | #ifdef __powerpc64__ |
491 | if (!(regs->msr & MSR_SF)) { | 496 | if (!(regs->msr & MSR_64BIT)) { |
492 | val = (unsigned int) val; | 497 | val = (unsigned int) val; |
493 | val1 = (unsigned int) val1; | 498 | val1 = (unsigned int) val1; |
494 | } | 499 | } |
@@ -571,8 +576,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
571 | if ((instr & 2) == 0) | 576 | if ((instr & 2) == 0) |
572 | imm += regs->nip; | 577 | imm += regs->nip; |
573 | regs->nip += 4; | 578 | regs->nip += 4; |
574 | if ((regs->msr & MSR_SF) == 0) | 579 | regs->nip = truncate_if_32bit(regs->msr, regs->nip); |
575 | regs->nip &= 0xffffffffUL; | ||
576 | if (instr & 1) | 580 | if (instr & 1) |
577 | regs->link = regs->nip; | 581 | regs->link = regs->nip; |
578 | if (branch_taken(instr, regs)) | 582 | if (branch_taken(instr, regs)) |
@@ -605,13 +609,9 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
605 | imm -= 0x04000000; | 609 | imm -= 0x04000000; |
606 | if ((instr & 2) == 0) | 610 | if ((instr & 2) == 0) |
607 | imm += regs->nip; | 611 | imm += regs->nip; |
608 | if (instr & 1) { | 612 | if (instr & 1) |
609 | regs->link = regs->nip + 4; | 613 | regs->link = truncate_if_32bit(regs->msr, regs->nip + 4); |
610 | if ((regs->msr & MSR_SF) == 0) | 614 | imm = truncate_if_32bit(regs->msr, imm); |
611 | regs->link &= 0xffffffffUL; | ||
612 | } | ||
613 | if ((regs->msr & MSR_SF) == 0) | ||
614 | imm &= 0xffffffffUL; | ||
615 | regs->nip = imm; | 615 | regs->nip = imm; |
616 | return 1; | 616 | return 1; |
617 | case 19: | 617 | case 19: |
@@ -619,11 +619,8 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
619 | case 16: /* bclr */ | 619 | case 16: /* bclr */ |
620 | case 528: /* bcctr */ | 620 | case 528: /* bcctr */ |
621 | imm = (instr & 0x400)? regs->ctr: regs->link; | 621 | imm = (instr & 0x400)? regs->ctr: regs->link; |
622 | regs->nip += 4; | 622 | regs->nip = truncate_if_32bit(regs->msr, regs->nip + 4); |
623 | if ((regs->msr & MSR_SF) == 0) { | 623 | imm = truncate_if_32bit(regs->msr, imm); |
624 | regs->nip &= 0xffffffffUL; | ||
625 | imm &= 0xffffffffUL; | ||
626 | } | ||
627 | if (instr & 1) | 624 | if (instr & 1) |
628 | regs->link = regs->nip; | 625 | regs->link = regs->nip; |
629 | if (branch_taken(instr, regs)) | 626 | if (branch_taken(instr, regs)) |
@@ -1617,11 +1614,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
1617 | return 0; /* invoke DSI if -EFAULT? */ | 1614 | return 0; /* invoke DSI if -EFAULT? */ |
1618 | } | 1615 | } |
1619 | instr_done: | 1616 | instr_done: |
1620 | regs->nip += 4; | 1617 | regs->nip = truncate_if_32bit(regs->msr, regs->nip + 4); |
1621 | #ifdef __powerpc64__ | ||
1622 | if ((regs->msr & MSR_SF) == 0) | ||
1623 | regs->nip &= 0xffffffffUL; | ||
1624 | #endif | ||
1625 | return 1; | 1618 | return 1; |
1626 | 1619 | ||
1627 | logical_done: | 1620 | logical_done: |