emulated_ops.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2007 Sony Corporation
  4. */
  5. #ifndef _ASM_POWERPC_EMULATED_OPS_H
  6. #define _ASM_POWERPC_EMULATED_OPS_H
  7. #include <linux/atomic.h>
  8. #include <linux/perf_event.h>
  9. #ifdef CONFIG_PPC_EMULATED_STATS
  10. struct ppc_emulated_entry {
  11. const char *name;
  12. atomic_t val;
  13. };
  14. extern struct ppc_emulated {
  15. #ifdef CONFIG_ALTIVEC
  16. struct ppc_emulated_entry altivec;
  17. #endif
  18. struct ppc_emulated_entry dcba;
  19. struct ppc_emulated_entry dcbz;
  20. struct ppc_emulated_entry fp_pair;
  21. struct ppc_emulated_entry isel;
  22. struct ppc_emulated_entry mcrxr;
  23. struct ppc_emulated_entry mfpvr;
  24. struct ppc_emulated_entry multiple;
  25. struct ppc_emulated_entry popcntb;
  26. struct ppc_emulated_entry spe;
  27. struct ppc_emulated_entry string;
  28. struct ppc_emulated_entry sync;
  29. struct ppc_emulated_entry unaligned;
  30. #ifdef CONFIG_MATH_EMULATION
  31. struct ppc_emulated_entry math;
  32. #endif
  33. #ifdef CONFIG_VSX
  34. struct ppc_emulated_entry vsx;
  35. #endif
  36. #ifdef CONFIG_PPC64
  37. struct ppc_emulated_entry mfdscr;
  38. struct ppc_emulated_entry mtdscr;
  39. struct ppc_emulated_entry lq_stq;
  40. struct ppc_emulated_entry lxvw4x;
  41. struct ppc_emulated_entry lxvh8x;
  42. struct ppc_emulated_entry lxvd2x;
  43. struct ppc_emulated_entry lxvb16x;
  44. #endif
  45. } ppc_emulated;
  46. extern u32 ppc_warn_emulated;
  47. extern void ppc_warn_emulated_print(const char *type);
  48. #define __PPC_WARN_EMULATED(type) \
  49. do { \
  50. atomic_inc(&ppc_emulated.type.val); \
  51. if (ppc_warn_emulated) \
  52. ppc_warn_emulated_print(ppc_emulated.type.name); \
  53. } while (0)
  54. #else /* !CONFIG_PPC_EMULATED_STATS */
  55. #define __PPC_WARN_EMULATED(type) do { } while (0)
  56. #endif /* !CONFIG_PPC_EMULATED_STATS */
  57. #define PPC_WARN_EMULATED(type, regs) \
  58. do { \
  59. perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, \
  60. 1, regs, 0); \
  61. __PPC_WARN_EMULATED(type); \
  62. } while (0)
  63. #define PPC_WARN_ALIGNMENT(type, regs) \
  64. do { \
  65. perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, \
  66. 1, regs, regs->dar); \
  67. __PPC_WARN_EMULATED(type); \
  68. } while (0)
  69. #endif /* _ASM_POWERPC_EMULATED_OPS_H */