Skip to content

Commit 9d2a55b

Browse files
Xiang Chenoupton
authored andcommitted
KVM: arm64: Fix the name of sys_reg_desc related to PMU
For those PMU system registers defined in sys_reg_descs[], use macro PMU_SYS_REG() / PMU_PMEVCNTR_EL0 / PMU_PMEVTYPER_EL0 to define them, and later two macros call macro PMU_SYS_REG() actually. Currently the input parameter of PMU_SYS_REG() is another macro which is calculation formula of the value of system registers, so for example, if we want to "SYS_PMINTENSET_EL1" as the name of sys register, actually the name we get is as following: (((3) << 19) | ((0) << 16) | ((9) << 12) | ((14) << 8) | ((1) << 5)) The name of system register is used in some tracepoints such as trace_kvm_sys_access(), if not set correctly, we need to analyze the inaccurate name to get the exact name (which also is inconsistent with other system registers), and also the inaccurate name occupies more space. To fix the issue, use the name as a input parameter of PMU_SYS_REG like MTE_REG or EL2_REG. Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Acked-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/1689305920-170523-1-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 6d4f923 commit 9d2a55b

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,18 +1114,19 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
11141114
{ SYS_DESC(SYS_DBGWCRn_EL1(n)), \
11151115
trap_wcr, reset_wcr, 0, 0, get_wcr, set_wcr }
11161116

1117-
#define PMU_SYS_REG(r) \
1118-
SYS_DESC(r), .reset = reset_pmu_reg, .visibility = pmu_visibility
1117+
#define PMU_SYS_REG(name) \
1118+
SYS_DESC(SYS_##name), .reset = reset_pmu_reg, \
1119+
.visibility = pmu_visibility
11191120

11201121
/* Macro to expand the PMEVCNTRn_EL0 register */
11211122
#define PMU_PMEVCNTR_EL0(n) \
1122-
{ PMU_SYS_REG(SYS_PMEVCNTRn_EL0(n)), \
1123+
{ PMU_SYS_REG(PMEVCNTRn_EL0(n)), \
11231124
.reset = reset_pmevcntr, .get_user = get_pmu_evcntr, \
11241125
.access = access_pmu_evcntr, .reg = (PMEVCNTR0_EL0 + n), }
11251126

11261127
/* Macro to expand the PMEVTYPERn_EL0 register */
11271128
#define PMU_PMEVTYPER_EL0(n) \
1128-
{ PMU_SYS_REG(SYS_PMEVTYPERn_EL0(n)), \
1129+
{ PMU_SYS_REG(PMEVTYPERn_EL0(n)), \
11291130
.reset = reset_pmevtyper, \
11301131
.access = access_pmu_evtyper, .reg = (PMEVTYPER0_EL0 + n), }
11311132

@@ -2114,9 +2115,9 @@ static const struct sys_reg_desc sys_reg_descs[] = {
21142115
{ SYS_DESC(SYS_PMBSR_EL1), undef_access },
21152116
/* PMBIDR_EL1 is not trapped */
21162117

2117-
{ PMU_SYS_REG(SYS_PMINTENSET_EL1),
2118+
{ PMU_SYS_REG(PMINTENSET_EL1),
21182119
.access = access_pminten, .reg = PMINTENSET_EL1 },
2119-
{ PMU_SYS_REG(SYS_PMINTENCLR_EL1),
2120+
{ PMU_SYS_REG(PMINTENCLR_EL1),
21202121
.access = access_pminten, .reg = PMINTENSET_EL1 },
21212122
{ SYS_DESC(SYS_PMMIR_EL1), trap_raz_wi },
21222123

@@ -2163,41 +2164,41 @@ static const struct sys_reg_desc sys_reg_descs[] = {
21632164
{ SYS_DESC(SYS_CTR_EL0), access_ctr },
21642165
{ SYS_DESC(SYS_SVCR), undef_access },
21652166

2166-
{ PMU_SYS_REG(SYS_PMCR_EL0), .access = access_pmcr,
2167+
{ PMU_SYS_REG(PMCR_EL0), .access = access_pmcr,
21672168
.reset = reset_pmcr, .reg = PMCR_EL0 },
2168-
{ PMU_SYS_REG(SYS_PMCNTENSET_EL0),
2169+
{ PMU_SYS_REG(PMCNTENSET_EL0),
21692170
.access = access_pmcnten, .reg = PMCNTENSET_EL0 },
2170-
{ PMU_SYS_REG(SYS_PMCNTENCLR_EL0),
2171+
{ PMU_SYS_REG(PMCNTENCLR_EL0),
21712172
.access = access_pmcnten, .reg = PMCNTENSET_EL0 },
2172-
{ PMU_SYS_REG(SYS_PMOVSCLR_EL0),
2173+
{ PMU_SYS_REG(PMOVSCLR_EL0),
21732174
.access = access_pmovs, .reg = PMOVSSET_EL0 },
21742175
/*
21752176
* PM_SWINC_EL0 is exposed to userspace as RAZ/WI, as it was
21762177
* previously (and pointlessly) advertised in the past...
21772178
*/
2178-
{ PMU_SYS_REG(SYS_PMSWINC_EL0),
2179+
{ PMU_SYS_REG(PMSWINC_EL0),
21792180
.get_user = get_raz_reg, .set_user = set_wi_reg,
21802181
.access = access_pmswinc, .reset = NULL },
2181-
{ PMU_SYS_REG(SYS_PMSELR_EL0),
2182+
{ PMU_SYS_REG(PMSELR_EL0),
21822183
.access = access_pmselr, .reset = reset_pmselr, .reg = PMSELR_EL0 },
2183-
{ PMU_SYS_REG(SYS_PMCEID0_EL0),
2184+
{ PMU_SYS_REG(PMCEID0_EL0),
21842185
.access = access_pmceid, .reset = NULL },
2185-
{ PMU_SYS_REG(SYS_PMCEID1_EL0),
2186+
{ PMU_SYS_REG(PMCEID1_EL0),
21862187
.access = access_pmceid, .reset = NULL },
2187-
{ PMU_SYS_REG(SYS_PMCCNTR_EL0),
2188+
{ PMU_SYS_REG(PMCCNTR_EL0),
21882189
.access = access_pmu_evcntr, .reset = reset_unknown,
21892190
.reg = PMCCNTR_EL0, .get_user = get_pmu_evcntr},
2190-
{ PMU_SYS_REG(SYS_PMXEVTYPER_EL0),
2191+
{ PMU_SYS_REG(PMXEVTYPER_EL0),
21912192
.access = access_pmu_evtyper, .reset = NULL },
2192-
{ PMU_SYS_REG(SYS_PMXEVCNTR_EL0),
2193+
{ PMU_SYS_REG(PMXEVCNTR_EL0),
21932194
.access = access_pmu_evcntr, .reset = NULL },
21942195
/*
21952196
* PMUSERENR_EL0 resets as unknown in 64bit mode while it resets as zero
21962197
* in 32bit mode. Here we choose to reset it as zero for consistency.
21972198
*/
2198-
{ PMU_SYS_REG(SYS_PMUSERENR_EL0), .access = access_pmuserenr,
2199+
{ PMU_SYS_REG(PMUSERENR_EL0), .access = access_pmuserenr,
21992200
.reset = reset_val, .reg = PMUSERENR_EL0, .val = 0 },
2200-
{ PMU_SYS_REG(SYS_PMOVSSET_EL0),
2201+
{ PMU_SYS_REG(PMOVSSET_EL0),
22012202
.access = access_pmovs, .reg = PMOVSSET_EL0 },
22022203

22032204
{ SYS_DESC(SYS_TPIDR_EL0), NULL, reset_unknown, TPIDR_EL0 },
@@ -2353,7 +2354,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
23532354
* PMCCFILTR_EL0 resets as unknown in 64bit mode while it resets as zero
23542355
* in 32bit mode. Here we choose to reset it as zero for consistency.
23552356
*/
2356-
{ PMU_SYS_REG(SYS_PMCCFILTR_EL0), .access = access_pmu_evtyper,
2357+
{ PMU_SYS_REG(PMCCFILTR_EL0), .access = access_pmu_evtyper,
23572358
.reset = reset_val, .reg = PMCCFILTR_EL0, .val = 0 },
23582359

23592360
EL2_REG(VPIDR_EL2, access_rw, reset_unknown, 0),

0 commit comments

Comments
 (0)