Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Add REQUIRES_E2H1 constraint as configuration flags

A bunch of EL2 configuration are very similar to their EL1 counterpart,
with the added constraint that HCR_EL2.E2H being 1.

For us, this means HCR_EL2.E2H being RES1, which is something we can
statically evaluate.

Add a REQUIRES_E2H1 constraint, which allows us to express conditions
in a much simpler way (without extra code). Existing occurrences are
converted, before we add a lot more.

Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260202184329.2724080-12-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>

+14 -24
+14 -24
arch/arm64/kvm/config.c
··· 25 25 #define FIXED_VALUE BIT(2) /* RAZ/WI or RAO/WI in KVM */ 26 26 #define MASKS_POINTER BIT(3) /* Pointer to fgt_masks struct instead of bits */ 27 27 #define AS_RES1 BIT(4) /* RES1 when not supported */ 28 + #define REQUIRES_E2H1 BIT(5) /* Add HCR_EL2.E2H RES1 as a pre-condition */ 28 29 29 30 unsigned long flags; 30 31 ··· 310 309 return (kvm_has_feat(kvm, FEAT_TRBE) && 311 310 kvm_has_feat(kvm, FEAT_MPAM) && 312 311 (read_sysreg_s(SYS_TRBIDR_EL1) & TRBIDR_EL1_MPAM)); 313 - } 314 - 315 - static bool feat_asid2_e2h1(struct kvm *kvm) 316 - { 317 - return kvm_has_feat(kvm, FEAT_ASID2) && !kvm_has_feat(kvm, FEAT_E2H0); 318 - } 319 - 320 - static bool feat_d128_e2h1(struct kvm *kvm) 321 - { 322 - return kvm_has_feat(kvm, FEAT_D128) && !kvm_has_feat(kvm, FEAT_E2H0); 323 - } 324 - 325 - static bool feat_mec_e2h1(struct kvm *kvm) 326 - { 327 - return kvm_has_feat(kvm, FEAT_MEC) && !kvm_has_feat(kvm, FEAT_E2H0); 328 312 } 329 313 330 314 static bool feat_ebep_pmuv3_ss(struct kvm *kvm) ··· 1031 1045 sctlr2_feat_map, FEAT_SCTLR2); 1032 1046 1033 1047 static const struct reg_bits_to_feat_map tcr2_el2_feat_map[] = { 1034 - NEEDS_FEAT(TCR2_EL2_FNG1 | 1035 - TCR2_EL2_FNG0 | 1036 - TCR2_EL2_A2, 1037 - feat_asid2_e2h1), 1038 - NEEDS_FEAT(TCR2_EL2_DisCH1 | 1039 - TCR2_EL2_DisCH0 | 1040 - TCR2_EL2_D128, 1041 - feat_d128_e2h1), 1042 - NEEDS_FEAT(TCR2_EL2_AMEC1, feat_mec_e2h1), 1048 + NEEDS_FEAT_FLAG(TCR2_EL2_FNG1 | 1049 + TCR2_EL2_FNG0 | 1050 + TCR2_EL2_A2, 1051 + REQUIRES_E2H1, FEAT_ASID2), 1052 + NEEDS_FEAT_FLAG(TCR2_EL2_DisCH1 | 1053 + TCR2_EL2_DisCH0 | 1054 + TCR2_EL2_D128, 1055 + REQUIRES_E2H1, FEAT_D128), 1056 + NEEDS_FEAT_FLAG(TCR2_EL2_AMEC1, REQUIRES_E2H1, FEAT_MEC), 1043 1057 NEEDS_FEAT(TCR2_EL2_AMEC0, FEAT_MEC), 1044 1058 NEEDS_FEAT(TCR2_EL2_HAFT, FEAT_HAFT), 1045 1059 NEEDS_FEAT(TCR2_EL2_PTTWI | ··· 1270 1284 unsigned long require, 1271 1285 unsigned long exclude) 1272 1286 { 1287 + bool e2h0 = kvm_has_feat(kvm, FEAT_E2H0); 1273 1288 struct resx resx = {}; 1274 1289 1275 1290 for (int i = 0; i < map_size; i++) { ··· 1292 1305 default: 1293 1306 match = idreg_feat_match(kvm, &map[i]); 1294 1307 } 1308 + 1309 + if (map[i].flags & REQUIRES_E2H1) 1310 + match &= !e2h0; 1295 1311 1296 1312 if (!match) { 1297 1313 if (map[i].flags & AS_RES1)