@@ -1211,6 +1211,43 @@ int kvm_init_nv_sysregs(struct kvm *kvm)
1211
1211
res0 |= SCTLR_EL1_EPAN ;
1212
1212
set_sysreg_masks (kvm , SCTLR_EL1 , res0 , res1 );
1213
1213
1214
+ /* MDCR_EL2 */
1215
+ res0 = MDCR_EL2_RES0 ;
1216
+ res1 = MDCR_EL2_RES1 ;
1217
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMUVer , IMP ))
1218
+ res0 |= (MDCR_EL2_HPMN | MDCR_EL2_TPMCR |
1219
+ MDCR_EL2_TPM | MDCR_EL2_HPME );
1220
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMSVer , IMP ))
1221
+ res0 |= MDCR_EL2_E2PB | MDCR_EL2_TPMS ;
1222
+ if (!kvm_has_feat (kvm , ID_AA64DFR1_EL1 , SPMU , IMP ))
1223
+ res0 |= MDCR_EL2_EnSPM ;
1224
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMUVer , V3P1 ))
1225
+ res0 |= MDCR_EL2_HPMD ;
1226
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , TraceFilt , IMP ))
1227
+ res0 |= MDCR_EL2_TTRF ;
1228
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMUVer , V3P5 ))
1229
+ res0 |= MDCR_EL2_HCCD | MDCR_EL2_HLP ;
1230
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , TraceBuffer , IMP ))
1231
+ res0 |= MDCR_EL2_E2TB ;
1232
+ if (!kvm_has_feat (kvm , ID_AA64MMFR0_EL1 , FGT , IMP ))
1233
+ res0 |= MDCR_EL2_TDCC ;
1234
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , MTPMU , IMP ) ||
1235
+ kvm_has_feat (kvm , ID_AA64PFR0_EL1 , EL3 , IMP ))
1236
+ res0 |= MDCR_EL2_MTPME ;
1237
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMUVer , V3P7 ))
1238
+ res0 |= MDCR_EL2_HPMFZO ;
1239
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMSS , IMP ))
1240
+ res0 |= MDCR_EL2_PMSSE ;
1241
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , PMSVer , V1P2 ))
1242
+ res0 |= MDCR_EL2_HPMFZS ;
1243
+ if (!kvm_has_feat (kvm , ID_AA64DFR1_EL1 , EBEP , IMP ))
1244
+ res0 |= MDCR_EL2_PMEE ;
1245
+ if (!kvm_has_feat (kvm , ID_AA64DFR0_EL1 , DebugVer , V8P9 ))
1246
+ res0 |= MDCR_EL2_EBWE ;
1247
+ if (!kvm_has_feat (kvm , ID_AA64DFR2_EL1 , STEP , IMP ))
1248
+ res0 |= MDCR_EL2_EnSTEPOP ;
1249
+ set_sysreg_masks (kvm , MDCR_EL2 , res0 , res1 );
1250
+
1214
1251
return 0 ;
1215
1252
}
1216
1253
0 commit comments