<commit_before>#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_KVM_H

#include <linux/tracepoint.h>
#include <asm/sie.h>
#include <asm/debug.h>
#include <asm/dis.h>

#undef TRACE_SYSTEM
#define TRACE_SYSTEM kvm
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace

/*
 * Helpers for vcpu-specific tracepoints containing the same information
 * as s390dbf VCPU_EVENTs.
 */
#define VCPU_PROTO_COMMON struct kvm_vcpu *vcpu
#define VCPU_ARGS_COMMON vcpu
#define VCPU_FIELD_COMMON __field(int, id)			\
	__field(unsigned long, pswmask)				\
	__field(unsigned long, pswaddr)
#define VCPU_ASSIGN_COMMON do {						\
	__entry->id = vcpu->vcpu_id;					\
	__entry->pswmask = vcpu->arch.sie_block->gpsw.mask;		\
	__entry->pswaddr = vcpu->arch.sie_block->gpsw.addr;		\
	} while (0);
#define VCPU_TP_PRINTK(p_str, p_args...)				\
	TP_printk("%02d[%016lx-%016lx]: " p_str, __entry->id,		\
		  __entry->pswmask, __entry->pswaddr, p_args)

TRACE_EVENT(kvm_s390_skey_related_inst,
	    TP_PROTO(VCPU_PROTO_COMMON),
	    TP_ARGS(VCPU_ARGS_COMMON),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    ),
	    VCPU_TP_PRINTK("%s", "first instruction related to skeys on vcpu")
	);

TRACE_EVENT(kvm_s390_major_guest_pfault,
	    TP_PROTO(VCPU_PROTO_COMMON),
	    TP_ARGS(VCPU_ARGS_COMMON),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    ),
	    VCPU_TP_PRINTK("%s", "major fault, maybe applicable for pfault")
	);

TRACE_EVENT(kvm_s390_pfault_init,
	    TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
	    TP_ARGS(VCPU_ARGS_COMMON, pfault_token),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(long, pfault_token)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->pfault_token = pfault_token;
		    ),
	    VCPU_TP_PRINTK("init pfault token %ld", __entry->pfault_token)
	);

TRACE_EVENT(kvm_s390_pfault_done,
	    TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
	    TP_ARGS(VCPU_ARGS_COMMON, pfault_token),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(long, pfault_token)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->pfault_token = pfault_token;
		    ),
	    VCPU_TP_PRINTK("done pfault token %ld", __entry->pfault_token)
	);

/*
 * Tracepoints for SIE entry and exit.
 */
TRACE_EVENT(kvm_s390_sie_enter,
	    TP_PROTO(VCPU_PROTO_COMMON, int cpuflags),
	    TP_ARGS(VCPU_ARGS_COMMON, cpuflags),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(int, cpuflags)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->cpuflags = cpuflags;
		    ),

	    VCPU_TP_PRINTK("entering sie flags %x", __entry->cpuflags)
	);

TRACE_EVENT(kvm_s390_sie_fault,
	    TP_PROTO(VCPU_PROTO_COMMON),
	    TP_ARGS(VCPU_ARGS_COMMON),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    ),

	    VCPU_TP_PRINTK("%s", "fault in sie instruction")
	);

TRACE_EVENT(kvm_s390_sie_exit,
	    TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode),
	    TP_ARGS(VCPU_ARGS_COMMON, icptcode),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(u8, icptcode)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->icptcode = icptcode;
		    ),

	    VCPU_TP_PRINTK("exit sie icptcode %d (%s)", __entry->icptcode,
			   __print_symbolic(__entry->icptcode,
					    sie_intercept_code))
	);

/*
 * Trace point for intercepted instructions.
 */
TRACE_EVENT(kvm_s390_intercept_instruction,
	    TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
	    TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(__u64, instruction)
		    __field(char, insn[8])
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->instruction = ((__u64)ipa << 48) |
		    ((__u64)ipb << 16);
		    ),

	    VCPU_TP_PRINTK("intercepted instruction %016llx (%s)",
			   __entry->instruction,
			   insn_to_mnemonic((unsigned char *)
					    &__entry->instruction,
					 __entry->insn, sizeof(__entry->insn)) ?
			   "unknown" : __entry->insn)
	);<commit_msg>KVM: s390: Use intercept_insn decoder in trace event<commit_after>#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_KVM_H

#include <linux/tracepoint.h>
#include <asm/sie.h>
#include <asm/debug.h>
#include <asm/dis.h>

#undef TRACE_SYSTEM
#define TRACE_SYSTEM kvm
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace

/*
 * Helpers for vcpu-specific tracepoints containing the same information
 * as s390dbf VCPU_EVENTs.
 */
#define VCPU_PROTO_COMMON struct kvm_vcpu *vcpu
#define VCPU_ARGS_COMMON vcpu
#define VCPU_FIELD_COMMON __field(int, id)			\
	__field(unsigned long, pswmask)				\
	__field(unsigned long, pswaddr)
#define VCPU_ASSIGN_COMMON do {						\
	__entry->id = vcpu->vcpu_id;					\
	__entry->pswmask = vcpu->arch.sie_block->gpsw.mask;		\
	__entry->pswaddr = vcpu->arch.sie_block->gpsw.addr;		\
	} while (0);
#define VCPU_TP_PRINTK(p_str, p_args...)				\
	TP_printk("%02d[%016lx-%016lx]: " p_str, __entry->id,		\
		  __entry->pswmask, __entry->pswaddr, p_args)

TRACE_EVENT(kvm_s390_skey_related_inst,
	    TP_PROTO(VCPU_PROTO_COMMON),
	    TP_ARGS(VCPU_ARGS_COMMON),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    ),
	    VCPU_TP_PRINTK("%s", "first instruction related to skeys on vcpu")
	);

TRACE_EVENT(kvm_s390_major_guest_pfault,
	    TP_PROTO(VCPU_PROTO_COMMON),
	    TP_ARGS(VCPU_ARGS_COMMON),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    ),
	    VCPU_TP_PRINTK("%s", "major fault, maybe applicable for pfault")
	);

TRACE_EVENT(kvm_s390_pfault_init,
	    TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
	    TP_ARGS(VCPU_ARGS_COMMON, pfault_token),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(long, pfault_token)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->pfault_token = pfault_token;
		    ),
	    VCPU_TP_PRINTK("init pfault token %ld", __entry->pfault_token)
	);

TRACE_EVENT(kvm_s390_pfault_done,
	    TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
	    TP_ARGS(VCPU_ARGS_COMMON, pfault_token),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(long, pfault_token)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->pfault_token = pfault_token;
		    ),
	    VCPU_TP_PRINTK("done pfault token %ld", __entry->pfault_token)
	);

/*
 * Tracepoints for SIE entry and exit.
 */
TRACE_EVENT(kvm_s390_sie_enter,
	    TP_PROTO(VCPU_PROTO_COMMON, int cpuflags),
	    TP_ARGS(VCPU_ARGS_COMMON, cpuflags),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(int, cpuflags)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->cpuflags = cpuflags;
		    ),

	    VCPU_TP_PRINTK("entering sie flags %x", __entry->cpuflags)
	);

TRACE_EVENT(kvm_s390_sie_fault,
	    TP_PROTO(VCPU_PROTO_COMMON),
	    TP_ARGS(VCPU_ARGS_COMMON),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    ),

	    VCPU_TP_PRINTK("%s", "fault in sie instruction")
	);

TRACE_EVENT(kvm_s390_sie_exit,
	    TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode),
	    TP_ARGS(VCPU_ARGS_COMMON, icptcode),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(u8, icptcode)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->icptcode = icptcode;
		    ),

	    VCPU_TP_PRINTK("exit sie icptcode %d (%s)", __entry->icptcode,
			   __print_symbolic(__entry->icptcode,
					    sie_intercept_code))
	);

/*
 * Trace point for intercepted instructions.
 */
TRACE_EVENT(kvm_s390_intercept_instruction,
	    TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
	    TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),

	    TP_STRUCT__entry(
		    VCPU_FIELD_COMMON
		    __field(__u64, instruction)
		    ),

	    TP_fast_assign(
		    VCPU_ASSIGN_COMMON
		    __entry->instruction = ((__u64)ipa << 48) |
		    ((__u64)ipb << 16);
		    ),

	    VCPU_TP_PRINTK("intercepted instruction %016llx (%s)",
			   __entry->instruction,
			   __print_symbolic(icpt_insn_decoder(__entry->instruction),
					    icpt_insn_codes))
	);
{'fraction_non_alphanumeric': 0.10123249970084959, 'fraction_numerical': 0.01364125882493718, 'mean_word_length': 3.4576, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4853233', 'n_tokens_mistral': 3787, 'n_tokens_neox': 3256, 'n_words': 478}