Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  Copyright 2007 Sony Corporation
0004  */
0005 
0006 #ifndef _ASM_POWERPC_EMULATED_OPS_H
0007 #define _ASM_POWERPC_EMULATED_OPS_H
0008 
0009 #include <linux/atomic.h>
0010 #include <linux/perf_event.h>
0011 
0012 
0013 #ifdef CONFIG_PPC_EMULATED_STATS
0014 
0015 struct ppc_emulated_entry {
0016     const char *name;
0017     atomic_t val;
0018 };
0019 
0020 extern struct ppc_emulated {
0021 #ifdef CONFIG_ALTIVEC
0022     struct ppc_emulated_entry altivec;
0023 #endif
0024     struct ppc_emulated_entry dcba;
0025     struct ppc_emulated_entry dcbz;
0026     struct ppc_emulated_entry fp_pair;
0027     struct ppc_emulated_entry isel;
0028     struct ppc_emulated_entry mcrxr;
0029     struct ppc_emulated_entry mfpvr;
0030     struct ppc_emulated_entry multiple;
0031     struct ppc_emulated_entry popcntb;
0032     struct ppc_emulated_entry spe;
0033     struct ppc_emulated_entry string;
0034     struct ppc_emulated_entry sync;
0035     struct ppc_emulated_entry unaligned;
0036 #ifdef CONFIG_MATH_EMULATION
0037     struct ppc_emulated_entry math;
0038 #endif
0039 #ifdef CONFIG_VSX
0040     struct ppc_emulated_entry vsx;
0041 #endif
0042 #ifdef CONFIG_PPC64
0043     struct ppc_emulated_entry mfdscr;
0044     struct ppc_emulated_entry mtdscr;
0045     struct ppc_emulated_entry lq_stq;
0046     struct ppc_emulated_entry lxvw4x;
0047     struct ppc_emulated_entry lxvh8x;
0048     struct ppc_emulated_entry lxvd2x;
0049     struct ppc_emulated_entry lxvb16x;
0050 #endif
0051 } ppc_emulated;
0052 
0053 extern u32 ppc_warn_emulated;
0054 
0055 extern void ppc_warn_emulated_print(const char *type);
0056 
0057 #define __PPC_WARN_EMULATED(type)                    \
0058     do {                                 \
0059         atomic_inc(&ppc_emulated.type.val);          \
0060         if (ppc_warn_emulated)                   \
0061             ppc_warn_emulated_print(ppc_emulated.type.name); \
0062     } while (0)
0063 
0064 #else /* !CONFIG_PPC_EMULATED_STATS */
0065 
0066 #define __PPC_WARN_EMULATED(type)   do { } while (0)
0067 
0068 #endif /* !CONFIG_PPC_EMULATED_STATS */
0069 
0070 #define PPC_WARN_EMULATED(type, regs)                   \
0071     do {                                \
0072         perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,       \
0073             1, regs, 0);                    \
0074         __PPC_WARN_EMULATED(type);              \
0075     } while (0)
0076 
0077 #define PPC_WARN_ALIGNMENT(type, regs)                  \
0078     do {                                \
0079         perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS,       \
0080             1, regs, regs->dar);                \
0081         __PPC_WARN_EMULATED(type);              \
0082     } while (0)
0083 
0084 #endif /* _ASM_POWERPC_EMULATED_OPS_H */