Skip to content

Commit eecff81

Browse files
antonblanchardpaulusmack
authored andcommitted
powerpc: Create PPC_WARN_ALIGNMENT to match PPC_WARN_EMULATED
perf_event wants a separate event for alignment and emulation faults, so create another emulation event. This will make it easy to hook in perf_event at one spot. We pass in regs which will be required for these events. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent f7d7986 commit eecff81

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎arch/powerpc/include/asm/emulated_ops.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern u32 ppc_warn_emulated;
5757

5858
extern void ppc_warn_emulated_print(const char *type);
5959

60-
#define PPC_WARN_EMULATED(type) \
60+
#define __PPC_WARN_EMULATED(type) \
6161
do { \
6262
atomic_inc(&ppc_emulated.type.val); \
6363
if (ppc_warn_emulated) \
@@ -66,8 +66,11 @@ extern void ppc_warn_emulated_print(const char *type);
6666

6767
#else /* !CONFIG_PPC_EMULATED_STATS */
6868

69-
#define PPC_WARN_EMULATED(type) do { } while (0)
69+
#define __PPC_WARN_EMULATED(type) do { } while (0)
7070

7171
#endif /* !CONFIG_PPC_EMULATED_STATS */
7272

73+
#define PPC_WARN_EMULATED(type, regs) __PPC_WARN_EMULATED(type)
74+
#define PPC_WARN_ALIGNMENT(type, regs) __PPC_WARN_EMULATED(type)
75+
7376
#endif /* _ASM_POWERPC_EMULATED_OPS_H */

‎arch/powerpc/kernel/align.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ int fix_alignment(struct pt_regs *regs)
732732

733733
#ifdef CONFIG_SPE
734734
if ((instr >> 26) == 0x4) {
735-
PPC_WARN_EMULATED(spe);
735+
PPC_WARN_ALIGNMENT(spe, regs);
736736
return emulate_spe(regs, reg, instr);
737737
}
738738
#endif
@@ -786,15 +786,15 @@ int fix_alignment(struct pt_regs *regs)
786786
flags |= SPLT;
787787
nb = 8;
788788
}
789-
PPC_WARN_EMULATED(vsx);
789+
PPC_WARN_ALIGNMENT(vsx, regs);
790790
return emulate_vsx(addr, reg, areg, regs, flags, nb);
791791
}
792792
#endif
793793
/* A size of 0 indicates an instruction we don't support, with
794794
* the exception of DCBZ which is handled as a special case here
795795
*/
796796
if (instr == DCBZ) {
797-
PPC_WARN_EMULATED(dcbz);
797+
PPC_WARN_ALIGNMENT(dcbz, regs);
798798
return emulate_dcbz(regs, addr);
799799
}
800800
if (unlikely(nb == 0))
@@ -804,7 +804,7 @@ int fix_alignment(struct pt_regs *regs)
804804
* function
805805
*/
806806
if (flags & M) {
807-
PPC_WARN_EMULATED(multiple);
807+
PPC_WARN_ALIGNMENT(multiple, regs);
808808
return emulate_multiple(regs, addr, reg, nb,
809809
flags, instr, swiz);
810810
}
@@ -825,11 +825,11 @@ int fix_alignment(struct pt_regs *regs)
825825

826826
/* Special case for 16-byte FP loads and stores */
827827
if (nb == 16) {
828-
PPC_WARN_EMULATED(fp_pair);
828+
PPC_WARN_ALIGNMENT(fp_pair, regs);
829829
return emulate_fp_pair(addr, reg, flags);
830830
}
831831

832-
PPC_WARN_EMULATED(unaligned);
832+
PPC_WARN_ALIGNMENT(unaligned, regs);
833833

834834
/* If we are loading, get the data from user space, else
835835
* get it from register values

‎arch/powerpc/kernel/traps.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -759,15 +759,15 @@ static int emulate_instruction(struct pt_regs *regs)
759759

760760
/* Emulate the mfspr rD, PVR. */
761761
if ((instword & PPC_INST_MFSPR_PVR_MASK) == PPC_INST_MFSPR_PVR) {
762-
PPC_WARN_EMULATED(mfpvr);
762+
PPC_WARN_EMULATED(mfpvr, regs);
763763
rd = (instword >> 21) & 0x1f;
764764
regs->gpr[rd] = mfspr(SPRN_PVR);
765765
return 0;
766766
}
767767

768768
/* Emulating the dcba insn is just a no-op. */
769769
if ((instword & PPC_INST_DCBA_MASK) == PPC_INST_DCBA) {
770-
PPC_WARN_EMULATED(dcba);
770+
PPC_WARN_EMULATED(dcba, regs);
771771
return 0;
772772
}
773773

@@ -776,27 +776,27 @@ static int emulate_instruction(struct pt_regs *regs)
776776
int shift = (instword >> 21) & 0x1c;
777777
unsigned long msk = 0xf0000000UL >> shift;
778778

779-
PPC_WARN_EMULATED(mcrxr);
779+
PPC_WARN_EMULATED(mcrxr, regs);
780780
regs->ccr = (regs->ccr & ~msk) | ((regs->xer >> shift) & msk);
781781
regs->xer &= ~0xf0000000UL;
782782
return 0;
783783
}
784784

785785
/* Emulate load/store string insn. */
786786
if ((instword & PPC_INST_STRING_GEN_MASK) == PPC_INST_STRING) {
787-
PPC_WARN_EMULATED(string);
787+
PPC_WARN_EMULATED(string, regs);
788788
return emulate_string_inst(regs, instword);
789789
}
790790

791791
/* Emulate the popcntb (Population Count Bytes) instruction. */
792792
if ((instword & PPC_INST_POPCNTB_MASK) == PPC_INST_POPCNTB) {
793-
PPC_WARN_EMULATED(popcntb);
793+
PPC_WARN_EMULATED(popcntb, regs);
794794
return emulate_popcntb_inst(regs, instword);
795795
}
796796

797797
/* Emulate isel (Integer Select) instruction */
798798
if ((instword & PPC_INST_ISEL_MASK) == PPC_INST_ISEL) {
799-
PPC_WARN_EMULATED(isel);
799+
PPC_WARN_EMULATED(isel, regs);
800800
return emulate_isel(regs, instword);
801801
}
802802

@@ -995,7 +995,7 @@ void SoftwareEmulation(struct pt_regs *regs)
995995
#ifdef CONFIG_MATH_EMULATION
996996
errcode = do_mathemu(regs);
997997
if (errcode >= 0)
998-
PPC_WARN_EMULATED(math);
998+
PPC_WARN_EMULATED(math, regs);
999999

10001000
switch (errcode) {
10011001
case 0:
@@ -1018,7 +1018,7 @@ void SoftwareEmulation(struct pt_regs *regs)
10181018
#elif defined(CONFIG_8XX_MINIMAL_FPEMU)
10191019
errcode = Soft_emulate_8xx(regs);
10201020
if (errcode >= 0)
1021-
PPC_WARN_EMULATED(8xx);
1021+
PPC_WARN_EMULATED(8xx, regs);
10221022

10231023
switch (errcode) {
10241024
case 0:
@@ -1129,7 +1129,7 @@ void altivec_assist_exception(struct pt_regs *regs)
11291129

11301130
flush_altivec_to_thread(current);
11311131

1132-
PPC_WARN_EMULATED(altivec);
1132+
PPC_WARN_EMULATED(altivec, regs);
11331133
err = emulate_altivec(regs);
11341134
if (err == 0) {
11351135
regs->nip += 4; /* skip emulated instruction */

0 commit comments

Comments
 (0)