Skip to content

Commit 88aea41

Browse files
Marc Zyngieroupton
authored andcommitted
arm64: cpufeature: Handle NV_frac as a synonym of NV2
With ARMv9.5, an implementation supporting Nested Virtualization is allowed to only support NV2, and to avoid supporting the old (and useless) ARMv8.3 variant. This is indicated by ID_AA64MMFR2_EL1.NV being 0 (as if NV wasn't implemented) and ID_AA64MMFR4_EL1.NV_frac being 1 (indicating that NV2 is actually supported). Given that KVM only deals with NV2 and refuses to use the old NV, detecting NV2 or NV_frac is what we need to enable it. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Joey Gouly <joey.gouly@arm.com> Link: https://lore.kernel.org/r/20250220134907.554085-2-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 0ad2507 commit 88aea41

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr3[] = {
497497

498498
static const struct arm64_ftr_bits ftr_id_aa64mmfr4[] = {
499499
S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_E2H0_SHIFT, 4, 0),
500+
ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_NV_frac_SHIFT, 4, 0),
500501
ARM64_FTR_END,
501502
};
502503

@@ -2162,7 +2163,7 @@ static bool has_nested_virt_support(const struct arm64_cpu_capabilities *cap,
21622163
if (kvm_get_mode() != KVM_MODE_NV)
21632164
return false;
21642165

2165-
if (!has_cpuid_feature(cap, scope)) {
2166+
if (!cpucap_multi_entry_cap_matches(cap, scope)) {
21662167
pr_warn("unavailable: %s\n", cap->desc);
21672168
return false;
21682169
}
@@ -2519,7 +2520,17 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
25192520
.capability = ARM64_HAS_NESTED_VIRT,
25202521
.type = ARM64_CPUCAP_SYSTEM_FEATURE,
25212522
.matches = has_nested_virt_support,
2522-
ARM64_CPUID_FIELDS(ID_AA64MMFR2_EL1, NV, NV2)
2523+
.match_list = (const struct arm64_cpu_capabilities []){
2524+
{
2525+
.matches = has_cpuid_feature,
2526+
ARM64_CPUID_FIELDS(ID_AA64MMFR2_EL1, NV, NV2)
2527+
},
2528+
{
2529+
.matches = has_cpuid_feature,
2530+
ARM64_CPUID_FIELDS(ID_AA64MMFR4_EL1, NV_frac, NV2_ONLY)
2531+
},
2532+
{ /* Sentinel */ }
2533+
},
25232534
},
25242535
{
25252536
.capability = ARM64_HAS_32BIT_EL0_DO_NOT_USE,

0 commit comments

Comments
 (0)