kvm-stat.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Arch specific functions for perf kvm stat.
  3. *
  4. * Copyright 2014 IBM Corp.
  5. * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License (version 2 only)
  9. * as published by the Free Software Foundation.
  10. */
  11. #include "../../util/kvm-stat.h"
  12. #include <asm/kvm_perf.h>
  13. define_exit_reasons_table(sie_exit_reasons, sie_intercept_code);
  14. define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes);
  15. define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes);
  16. define_exit_reasons_table(sie_diagnose_codes, diagnose_codes);
  17. define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes);
  18. static void event_icpt_insn_get_key(struct perf_evsel *evsel,
  19. struct perf_sample *sample,
  20. struct event_key *key)
  21. {
  22. unsigned long insn;
  23. insn = perf_evsel__intval(evsel, sample, "instruction");
  24. key->key = icpt_insn_decoder(insn);
  25. key->exit_reasons = sie_icpt_insn_codes;
  26. }
  27. static void event_sigp_get_key(struct perf_evsel *evsel,
  28. struct perf_sample *sample,
  29. struct event_key *key)
  30. {
  31. key->key = perf_evsel__intval(evsel, sample, "order_code");
  32. key->exit_reasons = sie_sigp_order_codes;
  33. }
  34. static void event_diag_get_key(struct perf_evsel *evsel,
  35. struct perf_sample *sample,
  36. struct event_key *key)
  37. {
  38. key->key = perf_evsel__intval(evsel, sample, "code");
  39. key->exit_reasons = sie_diagnose_codes;
  40. }
  41. static void event_icpt_prog_get_key(struct perf_evsel *evsel,
  42. struct perf_sample *sample,
  43. struct event_key *key)
  44. {
  45. key->key = perf_evsel__intval(evsel, sample, "code");
  46. key->exit_reasons = sie_icpt_prog_codes;
  47. }
  48. static struct child_event_ops child_events[] = {
  49. { .name = "kvm:kvm_s390_intercept_instruction",
  50. .get_key = event_icpt_insn_get_key },
  51. { .name = "kvm:kvm_s390_handle_sigp",
  52. .get_key = event_sigp_get_key },
  53. { .name = "kvm:kvm_s390_handle_diag",
  54. .get_key = event_diag_get_key },
  55. { .name = "kvm:kvm_s390_intercept_prog",
  56. .get_key = event_icpt_prog_get_key },
  57. { NULL, NULL },
  58. };
  59. static struct kvm_events_ops exit_events = {
  60. .is_begin_event = exit_event_begin,
  61. .is_end_event = exit_event_end,
  62. .child_ops = child_events,
  63. .decode_key = exit_event_decode_key,
  64. .name = "VM-EXIT"
  65. };
  66. const char * const kvm_events_tp[] = {
  67. "kvm:kvm_s390_sie_enter",
  68. "kvm:kvm_s390_sie_exit",
  69. "kvm:kvm_s390_intercept_instruction",
  70. "kvm:kvm_s390_handle_sigp",
  71. "kvm:kvm_s390_handle_diag",
  72. "kvm:kvm_s390_intercept_prog",
  73. NULL,
  74. };
  75. struct kvm_reg_events_ops kvm_reg_events_ops[] = {
  76. { .name = "vmexit", .ops = &exit_events },
  77. { NULL, NULL },
  78. };
  79. const char * const kvm_skip_events[] = {
  80. "Wait state",
  81. NULL,
  82. };
  83. int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
  84. {
  85. if (strstr(cpuid, "IBM/S390")) {
  86. kvm->exit_reasons = sie_exit_reasons;
  87. kvm->exit_reasons_isa = "SIE";
  88. } else
  89. return -ENOTSUP;
  90. return 0;
  91. }