kvm-stat.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 <errno.h>
  12. #include "../../util/kvm-stat.h"
  13. #include <asm/sie.h>
  14. define_exit_reasons_table(sie_exit_reasons, sie_intercept_code);
  15. define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes);
  16. define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes);
  17. define_exit_reasons_table(sie_diagnose_codes, diagnose_codes);
  18. define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes);
  19. const char *vcpu_id_str = "id";
  20. const int decode_str_len = 40;
  21. const char *kvm_exit_reason = "icptcode";
  22. const char *kvm_entry_trace = "kvm:kvm_s390_sie_enter";
  23. const char *kvm_exit_trace = "kvm:kvm_s390_sie_exit";
  24. static void event_icpt_insn_get_key(struct perf_evsel *evsel,
  25. struct perf_sample *sample,
  26. struct event_key *key)
  27. {
  28. unsigned long insn;
  29. insn = perf_evsel__intval(evsel, sample, "instruction");
  30. key->key = icpt_insn_decoder(insn);
  31. key->exit_reasons = sie_icpt_insn_codes;
  32. }
  33. static void event_sigp_get_key(struct perf_evsel *evsel,
  34. struct perf_sample *sample,
  35. struct event_key *key)
  36. {
  37. key->key = perf_evsel__intval(evsel, sample, "order_code");
  38. key->exit_reasons = sie_sigp_order_codes;
  39. }
  40. static void event_diag_get_key(struct perf_evsel *evsel,
  41. struct perf_sample *sample,
  42. struct event_key *key)
  43. {
  44. key->key = perf_evsel__intval(evsel, sample, "code");
  45. key->exit_reasons = sie_diagnose_codes;
  46. }
  47. static void event_icpt_prog_get_key(struct perf_evsel *evsel,
  48. struct perf_sample *sample,
  49. struct event_key *key)
  50. {
  51. key->key = perf_evsel__intval(evsel, sample, "code");
  52. key->exit_reasons = sie_icpt_prog_codes;
  53. }
  54. static struct child_event_ops child_events[] = {
  55. { .name = "kvm:kvm_s390_intercept_instruction",
  56. .get_key = event_icpt_insn_get_key },
  57. { .name = "kvm:kvm_s390_handle_sigp",
  58. .get_key = event_sigp_get_key },
  59. { .name = "kvm:kvm_s390_handle_diag",
  60. .get_key = event_diag_get_key },
  61. { .name = "kvm:kvm_s390_intercept_prog",
  62. .get_key = event_icpt_prog_get_key },
  63. { NULL, NULL },
  64. };
  65. static struct kvm_events_ops exit_events = {
  66. .is_begin_event = exit_event_begin,
  67. .is_end_event = exit_event_end,
  68. .child_ops = child_events,
  69. .decode_key = exit_event_decode_key,
  70. .name = "VM-EXIT"
  71. };
  72. const char *kvm_events_tp[] = {
  73. "kvm:kvm_s390_sie_enter",
  74. "kvm:kvm_s390_sie_exit",
  75. "kvm:kvm_s390_intercept_instruction",
  76. "kvm:kvm_s390_handle_sigp",
  77. "kvm:kvm_s390_handle_diag",
  78. "kvm:kvm_s390_intercept_prog",
  79. NULL,
  80. };
  81. struct kvm_reg_events_ops kvm_reg_events_ops[] = {
  82. { .name = "vmexit", .ops = &exit_events },
  83. { NULL, NULL },
  84. };
  85. const char * const kvm_skip_events[] = {
  86. "Wait state",
  87. NULL,
  88. };
  89. int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
  90. {
  91. if (strstr(cpuid, "IBM")) {
  92. kvm->exit_reasons = sie_exit_reasons;
  93. kvm->exit_reasons_isa = "SIE";
  94. } else
  95. return -ENOTSUP;
  96. return 0;
  97. }