mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 18:13:41 +02:00
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>
This commit is contained in:
parent
8d94458263
commit
ad90512f12
|
|
@ -25,6 +25,7 @@ struct reg_bits_to_feat_map {
|
|||
#define FIXED_VALUE BIT(2) /* RAZ/WI or RAO/WI in KVM */
|
||||
#define MASKS_POINTER BIT(3) /* Pointer to fgt_masks struct instead of bits */
|
||||
#define AS_RES1 BIT(4) /* RES1 when not supported */
|
||||
#define REQUIRES_E2H1 BIT(5) /* Add HCR_EL2.E2H RES1 as a pre-condition */
|
||||
|
||||
unsigned long flags;
|
||||
|
||||
|
|
@ -311,21 +312,6 @@ static bool feat_trbe_mpam(struct kvm *kvm)
|
|||
(read_sysreg_s(SYS_TRBIDR_EL1) & TRBIDR_EL1_MPAM));
|
||||
}
|
||||
|
||||
static bool feat_asid2_e2h1(struct kvm *kvm)
|
||||
{
|
||||
return kvm_has_feat(kvm, FEAT_ASID2) && !kvm_has_feat(kvm, FEAT_E2H0);
|
||||
}
|
||||
|
||||
static bool feat_d128_e2h1(struct kvm *kvm)
|
||||
{
|
||||
return kvm_has_feat(kvm, FEAT_D128) && !kvm_has_feat(kvm, FEAT_E2H0);
|
||||
}
|
||||
|
||||
static bool feat_mec_e2h1(struct kvm *kvm)
|
||||
{
|
||||
return kvm_has_feat(kvm, FEAT_MEC) && !kvm_has_feat(kvm, FEAT_E2H0);
|
||||
}
|
||||
|
||||
static bool feat_ebep_pmuv3_ss(struct kvm *kvm)
|
||||
{
|
||||
return kvm_has_feat(kvm, FEAT_EBEP) || kvm_has_feat(kvm, FEAT_PMUv3_SS);
|
||||
|
|
@ -1045,15 +1031,15 @@ static const DECLARE_FEAT_MAP(sctlr2_desc, SCTLR2_EL1,
|
|||
sctlr2_feat_map, FEAT_SCTLR2);
|
||||
|
||||
static const struct reg_bits_to_feat_map tcr2_el2_feat_map[] = {
|
||||
NEEDS_FEAT(TCR2_EL2_FNG1 |
|
||||
TCR2_EL2_FNG0 |
|
||||
TCR2_EL2_A2,
|
||||
feat_asid2_e2h1),
|
||||
NEEDS_FEAT(TCR2_EL2_DisCH1 |
|
||||
TCR2_EL2_DisCH0 |
|
||||
TCR2_EL2_D128,
|
||||
feat_d128_e2h1),
|
||||
NEEDS_FEAT(TCR2_EL2_AMEC1, feat_mec_e2h1),
|
||||
NEEDS_FEAT_FLAG(TCR2_EL2_FNG1 |
|
||||
TCR2_EL2_FNG0 |
|
||||
TCR2_EL2_A2,
|
||||
REQUIRES_E2H1, FEAT_ASID2),
|
||||
NEEDS_FEAT_FLAG(TCR2_EL2_DisCH1 |
|
||||
TCR2_EL2_DisCH0 |
|
||||
TCR2_EL2_D128,
|
||||
REQUIRES_E2H1, FEAT_D128),
|
||||
NEEDS_FEAT_FLAG(TCR2_EL2_AMEC1, REQUIRES_E2H1, FEAT_MEC),
|
||||
NEEDS_FEAT(TCR2_EL2_AMEC0, FEAT_MEC),
|
||||
NEEDS_FEAT(TCR2_EL2_HAFT, FEAT_HAFT),
|
||||
NEEDS_FEAT(TCR2_EL2_PTTWI |
|
||||
|
|
@ -1284,6 +1270,7 @@ static struct resx compute_resx_bits(struct kvm *kvm,
|
|||
unsigned long require,
|
||||
unsigned long exclude)
|
||||
{
|
||||
bool e2h0 = kvm_has_feat(kvm, FEAT_E2H0);
|
||||
struct resx resx = {};
|
||||
|
||||
for (int i = 0; i < map_size; i++) {
|
||||
|
|
@ -1306,6 +1293,9 @@ static struct resx compute_resx_bits(struct kvm *kvm,
|
|||
match = idreg_feat_match(kvm, &map[i]);
|
||||
}
|
||||
|
||||
if (map[i].flags & REQUIRES_E2H1)
|
||||
match &= !e2h0;
|
||||
|
||||
if (!match) {
|
||||
if (map[i].flags & AS_RES1)
|
||||
resx.res1 |= reg_feat_map_bits(&map[i]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user