162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#undef TRACE_SYSTEM
362306a36Sopenharmony_ci#define TRACE_SYSTEM msr
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#undef TRACE_INCLUDE_FILE
662306a36Sopenharmony_ci#define TRACE_INCLUDE_FILE msr-trace
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#undef TRACE_INCLUDE_PATH
962306a36Sopenharmony_ci#define TRACE_INCLUDE_PATH asm/
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#if !defined(_TRACE_MSR_H) || defined(TRACE_HEADER_MULTI_READ)
1262306a36Sopenharmony_ci#define _TRACE_MSR_H
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include <linux/tracepoint.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/*
1762306a36Sopenharmony_ci * Tracing for x86 model specific registers. Directly maps to the
1862306a36Sopenharmony_ci * RDMSR/WRMSR instructions.
1962306a36Sopenharmony_ci */
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ciDECLARE_EVENT_CLASS(msr_trace_class,
2262306a36Sopenharmony_ci	    TP_PROTO(unsigned msr, u64 val, int failed),
2362306a36Sopenharmony_ci	    TP_ARGS(msr, val, failed),
2462306a36Sopenharmony_ci	    TP_STRUCT__entry(
2562306a36Sopenharmony_ci		    __field(	unsigned,	msr )
2662306a36Sopenharmony_ci		    __field(    u64,		val )
2762306a36Sopenharmony_ci		    __field(    int,		failed )
2862306a36Sopenharmony_ci	    ),
2962306a36Sopenharmony_ci	    TP_fast_assign(
3062306a36Sopenharmony_ci		    __entry->msr = msr;
3162306a36Sopenharmony_ci		    __entry->val = val;
3262306a36Sopenharmony_ci		    __entry->failed = failed;
3362306a36Sopenharmony_ci	    ),
3462306a36Sopenharmony_ci	    TP_printk("%x, value %llx%s",
3562306a36Sopenharmony_ci		      __entry->msr,
3662306a36Sopenharmony_ci		      __entry->val,
3762306a36Sopenharmony_ci		      __entry->failed ? " #GP" : "")
3862306a36Sopenharmony_ci);
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciDEFINE_EVENT(msr_trace_class, read_msr,
4162306a36Sopenharmony_ci	     TP_PROTO(unsigned msr, u64 val, int failed),
4262306a36Sopenharmony_ci	     TP_ARGS(msr, val, failed)
4362306a36Sopenharmony_ci);
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciDEFINE_EVENT(msr_trace_class, write_msr,
4662306a36Sopenharmony_ci	     TP_PROTO(unsigned msr, u64 val, int failed),
4762306a36Sopenharmony_ci	     TP_ARGS(msr, val, failed)
4862306a36Sopenharmony_ci);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciDEFINE_EVENT(msr_trace_class, rdpmc,
5162306a36Sopenharmony_ci	     TP_PROTO(unsigned msr, u64 val, int failed),
5262306a36Sopenharmony_ci	     TP_ARGS(msr, val, failed)
5362306a36Sopenharmony_ci);
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#endif /* _TRACE_MSR_H */
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/* This part must be outside protection */
5862306a36Sopenharmony_ci#include <trace/define_trace.h>
59