Skip to contentSkip to conversation

kvm/powerpc: Export kvm exit reasons

PATCH Superseded Hemant Kumar 2 participants 6 messages May 8, 2015 – May 13, 2015

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 kvm/powerpc: Export kvm exit reasons

To analyze the kvm exits with perf, we will need to map the exit codes with the exit reasons. Such a mapping exists today in trace_book3s.h. Currently its not exported to perf.

This patch moves these kvm exit reasons and their mapping from "arch/powerpc/kvm/trace_book3s.h" to "arch/powerpc/include/uapi/asm/trace_book3s.h".

Accordingly change the include files in "trace_hv.h" and "trace_pr.h".

---
Changes :
- Original patchset split into 2 patchsets now: for perf and powerpc side changes.

 arch/powerpc/include/uapi/asm/trace_book3s.h | 32 ++++++++++++++++++++++++++++
 arch/powerpc/kvm/trace_book3s.h              | 32 ----------------------------
 arch/powerpc/kvm/trace_hv.h                  |  2 +-
 arch/powerpc/kvm/trace_pr.h                  |  2 +-
 4 files changed, 34 insertions(+), 34 deletions(-)
 create mode 100644 arch/powerpc/include/uapi/asm/trace_book3s.h
 delete mode 100644 arch/powerpc/kvm/trace_book3s.h
arch/powerpc/include/uapi/asm/trace_book3s.h new file +32 -0
new file mode 100644
index 0000000..f647ce0
@@ -0,0 +1,32 @@
+#if !defined(_TRACE_KVM_BOOK3S_H)
+#define _TRACE_KVM_BOOK3S_H
+
+/*
+ * Common defines used by the trace macros in trace_pr.h and trace_hv.h
+ */
+
+#define kvm_trace_symbol_exit \
+	{0x100, "SYSTEM_RESET"}, \
+	{0x200, "MACHINE_CHECK"}, \
+	{0x300, "DATA_STORAGE"}, \
+	{0x380, "DATA_SEGMENT"}, \
+	{0x400, "INST_STORAGE"}, \
+	{0x480, "INST_SEGMENT"}, \
+	{0x500, "EXTERNAL"}, \
+	{0x501, "EXTERNAL_LEVEL"}, \
+	{0x502, "EXTERNAL_HV"}, \
+	{0x600, "ALIGNMENT"}, \
+	{0x700, "PROGRAM"}, \
+	{0x800, "FP_UNAVAIL"}, \
+	{0x900, "DECREMENTER"}, \
+	{0x980, "HV_DECREMENTER"}, \
+	{0xc00, "SYSCALL"}, \
+	{0xd00, "TRACE"}, \
+	{0xe00, "H_DATA_STORAGE"}, \
+	{0xe20, "H_INST_STORAGE"}, \
+	{0xe40, "H_EMUL_ASSIST"}, \
+	{0xf00, "PERFMON"}, \
+	{0xf20, "ALTIVEC"}, \
+	{0xf40, "VSX"}
+
+#endif
arch/powerpc/kvm/trace_book3s.h deleted +0 -32
deleted file mode 100644
index f647ce0..0000000
@@ -1,32 +0,0 @@
-#if !defined(_TRACE_KVM_BOOK3S_H)
-#define _TRACE_KVM_BOOK3S_H
-
-/*
- * Common defines used by the trace macros in trace_pr.h and trace_hv.h
- */
-
-#define kvm_trace_symbol_exit \
-	{0x100, "SYSTEM_RESET"}, \
-	{0x200, "MACHINE_CHECK"}, \
-	{0x300, "DATA_STORAGE"}, \
-	{0x380, "DATA_SEGMENT"}, \
-	{0x400, "INST_STORAGE"}, \
-	{0x480, "INST_SEGMENT"}, \
-	{0x500, "EXTERNAL"}, \
-	{0x501, "EXTERNAL_LEVEL"}, \
-	{0x502, "EXTERNAL_HV"}, \
-	{0x600, "ALIGNMENT"}, \
-	{0x700, "PROGRAM"}, \
-	{0x800, "FP_UNAVAIL"}, \
-	{0x900, "DECREMENTER"}, \
-	{0x980, "HV_DECREMENTER"}, \
-	{0xc00, "SYSCALL"}, \
-	{0xd00, "TRACE"}, \
-	{0xe00, "H_DATA_STORAGE"}, \
-	{0xe20, "H_INST_STORAGE"}, \
-	{0xe40, "H_EMUL_ASSIST"}, \
-	{0xf00, "PERFMON"}, \
-	{0xf20, "ALTIVEC"}, \
-	{0xf40, "VSX"}
-
-#endif
arch/powerpc/kvm/trace_hv.h +1 -1
index 33d9daf..02d0a07 100644
@@ -2,7 +2,7 @@
 #define _TRACE_KVM_HV_H
 
 #include <linux/tracepoint.h>
-#include "trace_book3s.h"
+#include <uapi/asm/trace_book3s.h>
 #include <asm/hvcall.h>
 #include <asm/kvm_asm.h>
 
arch/powerpc/kvm/trace_pr.h +1 -1
index 810507c..a9850c6 100644
@@ -3,7 +3,7 @@
 #define _TRACE_KVM_PR_H
 
 #include <linux/tracepoint.h>
-#include "trace_book3s.h"
+#include <uapi/asm/trace_book3s.h>
 
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM kvm_pr
Signature · 1 line
1.9.3
#1 lore raw

PATCH v3 2/3 kvm/powerpc: Add exit reason for return code 0x0

This patch adds an exit reason "RETURN_TO_HOST" for the return code 0x0.

---
 arch/powerpc/include/uapi/asm/trace_book3s.h | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/include/uapi/asm/trace_book3s.h +1 -0
index f647ce0..8635005 100644
@@ -6,6 +6,7 @@
  */
 
 #define kvm_trace_symbol_exit \
+	{0x0,	"RETURN_TO_HOST"}, \
 	{0x100, "SYSTEM_RESET"}, \
 	{0x200, "MACHINE_CHECK"}, \
 	{0x300, "DATA_STORAGE"}, \
Signature · 1 line
1.9.3
#2 lore raw

PATCH v3 3/3 kvm/powerpc: Export HCALL reason codes

In reply to Hemant Kumar

For perf to analyze the KVM events like hcalls, we need the hypervisor calls and their codes to be exported through uapi.

This patch moves most of the pSeries hcall codes from arch/powerpc/include/asm/hvcall.h to arch/powerpc/include/uapi/asm/hcall_codes.h.
It also moves the mapping <hcall_code-to-hcall_reason> from arch/powerpc/kvm/trace_hv.h to arch/powerpc/include/uapi/asm/trace_hcall.h.

---
 arch/powerpc/include/asm/hvcall.h           | 120 +--------------------------
 arch/powerpc/include/uapi/asm/hcall_codes.h | 123 ++++++++++++++++++++++++++++
 arch/powerpc/include/uapi/asm/trace_hcall.h | 122 +++++++++++++++++++++++++++
 arch/powerpc/kvm/trace_hv.h                 | 117 +-------------------------
 4 files changed, 248 insertions(+), 234 deletions(-)
 create mode 100644 arch/powerpc/include/uapi/asm/hcall_codes.h
 create mode 100644 arch/powerpc/include/uapi/asm/trace_hcall.h
arch/powerpc/include/asm/hvcall.h +2 -118
index 85bc8c0..799677d 100644
@@ -155,124 +155,8 @@
 /* Each control block has to be on a 4K boundary */
 #define H_CB_ALIGNMENT          4096
 
-/* pSeries hypervisor opcodes */
-#define H_REMOVE		0x04
-#define H_ENTER			0x08
-#define H_READ			0x0c
-#define H_CLEAR_MOD		0x10
-#define H_CLEAR_REF		0x14
-#define H_PROTECT		0x18
-#define H_GET_TCE		0x1c
-#define H_PUT_TCE		0x20
-#define H_SET_SPRG0		0x24
-#define H_SET_DABR		0x28
-#define H_PAGE_INIT		0x2c
-#define H_SET_ASR		0x30
-#define H_ASR_ON		0x34
-#define H_ASR_OFF		0x38
-#define H_LOGICAL_CI_LOAD	0x3c
-#define H_LOGICAL_CI_STORE	0x40
-#define H_LOGICAL_CACHE_LOAD	0x44
-#define H_LOGICAL_CACHE_STORE	0x48
-#define H_LOGICAL_ICBI		0x4c
-#define H_LOGICAL_DCBF		0x50
-#define H_GET_TERM_CHAR		0x54
-#define H_PUT_TERM_CHAR		0x58
-#define H_REAL_TO_LOGICAL	0x5c
-#define H_HYPERVISOR_DATA	0x60
-#define H_EOI			0x64
-#define H_CPPR			0x68
-#define H_IPI			0x6c
-#define H_IPOLL			0x70
-#define H_XIRR			0x74
-#define H_PERFMON		0x7c
-#define H_MIGRATE_DMA		0x78
-#define H_REGISTER_VPA		0xDC
-#define H_CEDE			0xE0
-#define H_CONFER		0xE4
-#define H_PROD			0xE8
-#define H_GET_PPP		0xEC
-#define H_SET_PPP		0xF0
-#define H_PURR			0xF4
-#define H_PIC			0xF8
-#define H_REG_CRQ		0xFC
-#define H_FREE_CRQ		0x100
-#define H_VIO_SIGNAL		0x104
-#define H_SEND_CRQ		0x108
-#define H_COPY_RDMA		0x110
-#define H_REGISTER_LOGICAL_LAN	0x114
-#define H_FREE_LOGICAL_LAN	0x118
-#define H_ADD_LOGICAL_LAN_BUFFER 0x11C
-#define H_SEND_LOGICAL_LAN	0x120
-#define H_BULK_REMOVE		0x124
-#define H_MULTICAST_CTRL	0x130
-#define H_SET_XDABR		0x134
-#define H_STUFF_TCE		0x138
-#define H_PUT_TCE_INDIRECT	0x13C
-#define H_CHANGE_LOGICAL_LAN_MAC 0x14C
-#define H_VTERM_PARTNER_INFO	0x150
-#define H_REGISTER_VTERM	0x154
-#define H_FREE_VTERM		0x158
-#define H_RESET_EVENTS          0x15C
-#define H_ALLOC_RESOURCE        0x160
-#define H_FREE_RESOURCE         0x164
-#define H_MODIFY_QP             0x168
-#define H_QUERY_QP              0x16C
-#define H_REREGISTER_PMR        0x170
-#define H_REGISTER_SMR          0x174
-#define H_QUERY_MR              0x178
-#define H_QUERY_MW              0x17C
-#define H_QUERY_HCA             0x180
-#define H_QUERY_PORT            0x184
-#define H_MODIFY_PORT           0x188
-#define H_DEFINE_AQP1           0x18C
-#define H_GET_TRACE_BUFFER      0x190
-#define H_DEFINE_AQP0           0x194
-#define H_RESIZE_MR             0x198
-#define H_ATTACH_MCQP           0x19C
-#define H_DETACH_MCQP           0x1A0
-#define H_CREATE_RPT            0x1A4
-#define H_REMOVE_RPT            0x1A8
-#define H_REGISTER_RPAGES       0x1AC
-#define H_DISABLE_AND_GETC      0x1B0
-#define H_ERROR_DATA            0x1B4
-#define H_GET_HCA_INFO          0x1B8
-#define H_GET_PERF_COUNT        0x1BC
-#define H_MANAGE_TRACE          0x1C0
-#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4
-#define H_QUERY_INT_STATE       0x1E4
-#define H_POLL_PENDING		0x1D8
-#define H_ILLAN_ATTRIBUTES	0x244
-#define H_MODIFY_HEA_QP		0x250
-#define H_QUERY_HEA_QP		0x254
-#define H_QUERY_HEA		0x258
-#define H_QUERY_HEA_PORT	0x25C
-#define H_MODIFY_HEA_PORT	0x260
-#define H_REG_BCMC		0x264
-#define H_DEREG_BCMC		0x268
-#define H_REGISTER_HEA_RPAGES	0x26C
-#define H_DISABLE_AND_GET_HEA	0x270
-#define H_GET_HEA_INFO		0x274
-#define H_ALLOC_HEA_RESOURCE	0x278
-#define H_ADD_CONN		0x284
-#define H_DEL_CONN		0x288
-#define H_JOIN			0x298
-#define H_VASI_STATE            0x2A4
-#define H_ENABLE_CRQ		0x2B0
-#define H_GET_EM_PARMS		0x2B8
-#define H_SET_MPP		0x2D0
-#define H_GET_MPP		0x2D4
-#define H_HOME_NODE_ASSOCIATIVITY 0x2EC
-#define H_BEST_ENERGY		0x2F4
-#define H_XIRR_X		0x2FC
-#define H_RANDOM		0x300
-#define H_COP			0x304
-#define H_GET_MPP_X		0x314
-#define H_SET_MODE		0x31C
-#define MAX_HCALL_OPCODE	H_SET_MODE
-
-/* Platform specific hcalls, used by KVM */
-#define H_RTAS			0xf000
+/* Include pSeries hypervisor opcodes */
+#include <uapi/asm/hcall_codes.h>
 
 /* "Platform specific hcalls", provided by PHYP */
 #define H_GET_24X7_CATALOG_PAGE	0xF078
arch/powerpc/include/uapi/asm/hcall_codes.h new file +123 -0

123 lines not on this page · raw message

arch/powerpc/include/uapi/asm/trace_hcall.h new file +122 -0

122 lines not on this page · raw message

arch/powerpc/kvm/trace_hv.h +1 -116

129 lines not on this page · raw message

Signature · 1 line
1.9.3
#3 lore raw

Re: [PATCH v3 3/3] kvm/powerpc: Export HCALL reason codes

Quoted 10 lines · Hemant Kumar

For perf to analyze the KVM events like hcalls, we need the hypervisor calls and their codes to be exported through uapi.

This patch moves most of the pSeries hcall codes from arch/powerpc/include/asm/hvcall.h to arch/powerpc/include/uapi/asm/hcall_codes.h.
It also moves the mapping <hcall_code-to-hcall_reason> from arch/powerpc/kvm/trace_hv.h to arch/powerpc/include/uapi/asm/trace_hcall.h.

Quoted 6 lines
---
 arch/powerpc/include/asm/hvcall.h           | 120 +--------------------------
 arch/powerpc/include/uapi/asm/hcall_codes.h | 123 ++++++++++++++++++++++++++++
 arch/powerpc/include/uapi/asm/trace_hcall.h | 122 +++++++++++++++++++++++++++
 arch/powerpc/kvm/trace_hv.h                 | 117 +-------------------------

When moving to uapi please add proper namespacing to indicate that this is pseries specific.

Quoted 6 lines
arch/powerpc/include/uapi/asm/trace_hcall.h new file +0 -0
new file mode 100644
index 0000000..00eac01

arch/powerpc/include/uapi/asm/trace_hcall.h line 10

Quoted 10 lines
arch/powerpc/include/uapi/asm/trace_hcall.h new file +10 -0
@@ -0,0 +1,122 @@
+#ifndef _KVM_TRACE_HCALL_MAP_H
+#define _KVM_TRACE_HCALL_MAP_H
+
+#include "hcall_codes.h"
+
+#define kvm_trace_symbol_hcall\
+	{H_REMOVE,"H_REMOVE"},					\
+	{H_ENTER,"H_ENTER"},					\
+	{H_READ,"H_READ"},					\
+	{H_CLEAR_MOD,"H_CLEAR_MOD"},				\

This is a rather odd way of exposing an array to userspace...

-Scott

#4 lore raw

Re: [PATCH v3 3/3] kvm/powerpc: Export HCALL reason codes

Quoted 11 lines · Scott Wood
Quoted 10 lines · Hemant Kumar

For perf to analyze the KVM events like hcalls, we need the hypervisor calls and their codes to be exported through uapi.

This patch moves most of the pSeries hcall codes from arch/powerpc/include/asm/hvcall.h to arch/powerpc/include/uapi/asm/hcall_codes.h.
It also moves the mapping <hcall_code-to-hcall_reason> from arch/powerpc/kvm/trace_hv.h to arch/powerpc/include/uapi/asm/trace_hcall.h.

Quoted 9 lines
Quoted 6 lines
---
  arch/powerpc/include/asm/hvcall.h           | 120 +--------------------------
  arch/powerpc/include/uapi/asm/hcall_codes.h | 123 ++++++++++++++++++++++++++++
  arch/powerpc/include/uapi/asm/trace_hcall.h | 122 +++++++++++++++++++++++++++
  arch/powerpc/kvm/trace_hv.h                 | 117 +-------------------------

When moving to uapi please add proper namespacing to indicate that this is pseries specific.

Sure, will add that.

Quoted 9 lines
Quoted 9 lines
arch/powerpc/include/uapi/asm/trace_hcall.h new file +3 -0
new file mode 100644
index 0000000..00eac01
@@ -0,0 +1,122 @@
+#ifndef _KVM_TRACE_HCALL_MAP_H
+#define _KVM_TRACE_HCALL_MAP_H
+
Quoted 9 lines

arch/powerpc/include/uapi/asm/trace_hcall.h line 10

Quoted 7 lines
arch/powerpc/include/uapi/asm/trace_hcall.h new file +7 -0
+#include "hcall_codes.h"
+
+#define kvm_trace_symbol_hcall\
+	{H_REMOVE,"H_REMOVE"},					\
+	{H_ENTER,"H_ENTER"},					\
+	{H_READ,"H_READ"},					\
+	{H_CLEAR_MOD,"H_CLEAR_MOD"},				\

This is a rather odd way of exposing an array to userspace...

Didn't get you here. Can you please elaborate?

I see some other files like arch/x86/include/uapi/asm/vmx.h exposing the reasons in a similar way.

Thanks for the review.

Signature · 1 line
Hemant Kumar
#5 lore raw

Re: [PATCH v3 3/3] kvm/powerpc: Export HCALL reason codes

Quoted 18 lines · Hemant Kumar
Quoted 17 lines · Scott Wood
Quoted 16 lines · Hemant Kumar

For perf to analyze the KVM events like hcalls, we need the hypervisor calls and their codes to be exported through uapi.

This patch moves most of the pSeries hcall codes from arch/powerpc/include/asm/hvcall.h to arch/powerpc/include/uapi/asm/hcall_codes.h.
It also moves the mapping <hcall_code-to-hcall_reason> from arch/powerpc/kvm/trace_hv.h to arch/powerpc/include/uapi/asm/trace_hcall.h.

---
  arch/powerpc/include/asm/hvcall.h           | 120 +--------------------------
  arch/powerpc/include/uapi/asm/hcall_codes.h | 123 ++++++++++++++++++++++++++++
  arch/powerpc/include/uapi/asm/trace_hcall.h | 122 +++++++++++++++++++++++++++
  arch/powerpc/kvm/trace_hv.h                 | 117 +-------------------------
Quoted 5 lines
Quoted 3 lines

When moving to uapi please add proper namespacing to indicate that this is pseries specific.

Sure, will add that.

Thanks.

Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
arch/powerpc/include/uapi/asm/trace_hcall.h new file +3 -0
new file mode 100644
index 0000000..00eac01
@@ -0,0 +1,122 @@
+#ifndef _KVM_TRACE_HCALL_MAP_H
+#define _KVM_TRACE_HCALL_MAP_H
+
Quoted 9 lines

arch/powerpc/include/uapi/asm/trace_hcall.h line 10

Quoted 7 lines
arch/powerpc/include/uapi/asm/trace_hcall.h new file +7 -0
+#include "hcall_codes.h"
+
+#define kvm_trace_symbol_hcall\
+	{H_REMOVE,"H_REMOVE"},					\
+	{H_ENTER,"H_ENTER"},					\
+	{H_READ,"H_READ"},					\
+	{H_CLEAR_MOD,"H_CLEAR_MOD"},				\

This is a rather odd way of exposing an array to userspace...

Quoted 4 lines

Didn't get you here. Can you please elaborate?

I see some other files like arch/x86/include/uapi/asm/vmx.h exposing the reasons in a similar way.

It just seemed like sloppy API to not have any typing associated with it and require the user to wrap it in an actual array; I wasn't aware there was precedent for this construction in uapi. I also would have expected a macro that doesn't behave like a normal element of C syntax (function, variable name, type, etc) to have been capitalized.

-Scott