erator' content='cgit v1.2.3'/>
aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/ia64/xen/privop_stat.c
blob: ae7aab2bb385503655c404f5cc87db89ddc2a63f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include <xen/lib.h>
#include <public/xen.h>
#include <xen/perfc.h>
#include <asm/atomic.h>
#include <asm/privop_stat.h>

#ifdef CONFIG_PRIVOP_ADDRS

struct privop_addr_count {
	unsigned long addr[PRIVOP_COUNT_NADDRS];
	unsigned int count[PRIVOP_COUNT_NADDRS];
	unsigned int overflow;
};

struct privop_addr_info {
	enum perfcounter perfc_addr;
	enum perfcounter perfc_count;
	enum perfcounter perfc_overflow;
};

#define PERFCOUNTER(var, name)
#define PERFCOUNTER_ARRAY(var, name, size)

#define PERFSTATUS(var, name)
#define PERFSTATUS_ARRAY(var, name, size)

#define PERFPRIVOPADDR(name)                        \
    {                                               \
        PERFC_privop_addr_##name##_addr,            \
        PERFC_privop_addr_##name##_count,           \
        PERFC_privop_addr_##name##_overflow         \
    },

static const struct privop_addr_info privop_addr_info[] = {
#include <asm/perfc_defn.h>
};

#define PRIVOP_COUNT_NINSTS \
        (sizeof(privop_addr_info) / sizeof(privop_addr_info[0]))

static DEFINE_PER_CPU(struct privop_addr_count[PRIVOP_COUNT_NINSTS], privop_addr_counter);

void privop_count_addr(unsigned long iip, enum privop_inst inst)
{
	struct privop_addr_count *v = this_cpu(privop_addr_counter) + inst;
	int i;

	if (inst >= PRIVOP_COUNT_NINSTS)
		return;
	for (i = 0; i < PRIVOP_COUNT_NADDRS; i++) {
		if (!v->addr[i]) {
			v->addr[i] = iip;
			v->count[i]++;
			return;
		}
		else if (v->addr[i] == iip) {
			v->count[i]++;
			return;
		}
	}
	v->overflow++;;
}

void gather_privop_addrs(void)
{
	unsigned int cpu;

	for_each_cpu ( cpu ) {
		perfc_t *perfcounters = per_cpu(perfcounters, cpu);
		struct privop_addr_count *s = per_cpu(privop_addr_counter, cpu);
		int i, j;

		for (i = 0; i < PRIVOP_COUNT_NINSTS; i++, s++) {
			perfc_t *d;

			/* Note: addresses are truncated!  */
			d = perfcounters + privop_addr_info[i].perfc_addr;
			for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
				d[j] = s->addr[j];

			d = perfcounters + privop_addr_info[i].perfc_count;
			for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
				d[j] = s->count[j];
		
			perfcounters[privop_addr_info[i].perfc_overflow] =
				s->overflow;
		}
	}
}

void reset_privop_addrs(void)
{
	unsigned int cpu;

	for_each_cpu ( cpu ) {
		struct privop_addr_count *v = per_cpu(privop_addr_counter, cpu);
		int i, j;

		for (i = 0; i < PRIVOP_COUNT_NINSTS; i++, v++) {
			for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
				v->addr[j] = v->count[j] = 0;
			v->overflow = 0;
		}
	}
}
#endif

/**************************************************************************
Privileged operation instrumentation routines
**************************************************************************/

#if 0
static const char * const Mpriv_str[64] = {
	"mov_to_rr", "mov_to_dbr", "mov_to_ibr", "mov_to_pkr",
	"mov_to_pmc", "mov_to_pmd", "<0x06>", "<0x07>",
	"<0x08>", "ptc_l", "ptc_g", "ptc_ga",
	"ptr_d", "ptr_i", "itr_d", "itr_i",
	"mov_from_rr", "mov_from_dbr", "mov_from_ibr", "mov_from_pkr",
	"mov_from_pmc", "<0x15>", "<0x16>", "<0x17>",
	"<0x18>", "<0x19>", "privified-thash", "privified-ttag",
	"<0x1c>", "<0x1d>", "tpa", "tak",
	"<0x20>", "<0x21>", "<0x22>", "<0x23>",
	"mov_from_cr", "mov_from_psr", "<0x26>", "<0x27>",
	"<0x28>", "<0x29>", "<0x2a>", "<0x2b>",
	"mov_to_cr", "mov_to_psr", "itc_d", "itc_i",
	"<0x30>", "<0x31>", "<0x32>", "<0x33>",
	"ptc_e", "<0x35>", "<0x36>", "<0x37>",
	"<0x38>", "<0x39>", "<0x3a>", "<0x3b>",
	"<0x3c>", "<0x3d>", "<0x3e>", "<0x3f>"
};

#define RS "Rsvd"
static const char * const cr_str[128] = {
	"dcr","itm","iva",RS,RS,RS,RS,RS,
	"pta",RS,RS,RS,RS,RS,RS,RS,
	"ipsr","isr",RS,"iip","ifa","itir","iipa","ifs",
	"iim","iha",RS,RS,RS,RS,RS,RS,
	RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
	RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
	"lid","ivr","tpr","eoi","irr0","irr1","irr2","irr3",
	"itv","pmv","cmcv",RS,RS,RS,RS,RS,
	"lrr0","lrr1",RS,RS,RS,RS,RS,RS,
	RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
	RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
	RS,RS,RS,RS,RS,RS,RS,RS
};

static const char * const hyperpriv_str[HYPERPRIVOP_MAX+1] = {
	0, "rfi", "rsm.dt", "ssm.dt", "cover", "itc.d", "itc.i", "ssm.i",
	"=ivr", "=tpr", "tpr=", "eoi", "itm=", "thash", "ptc.ga", "itr.d",
	"=rr", "rr=", "kr=", "fc", "=cpuid", "=pmd", "=ar.eflg", "ar.eflg="
};
#endif