Skip to content

Commit 54adbfe

Browse files
author
Marc Zyngier
committed
KVM: arm64: Always populate FGT masks at boot time
We currently only populate the FGT masks if the underlying HW does support FEAT_FGT. However, with the addition of the RES1 support for system registers, this results in a lot of noise at boot time, as reported by Nathan. That's because even if FGT isn't supported, we still check for the attribution of the bits to particular features, and not keeping the masks up-to-date leads to (fairly harmess) warnings. Given that we want these checks to be enforced even if the HW doesn't support FGT, enable the generation of FGT masks unconditionally (this is rather cheap anyway). Only the storage of the FGT configuration is avoided, which will save a tiny bit of memory on these machines. Reported-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Fixes: c259d76 ("KVM: arm64: Account for RES1 bits in DECLARE_FEAT_MAP() and co") Link: https://lore.kernel.org/r/20260120211558.GA834868@ax162 Link: https://patch.msgid.link/20260122085153.535538-1-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 80cbfd7 commit 54adbfe

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

arch/arm64/kvm/emulate-nested.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,9 +2276,6 @@ int __init populate_nv_trap_config(void)
22762276
kvm_info("nv: %ld coarse grained trap handlers\n",
22772277
ARRAY_SIZE(encoding_to_cgt));
22782278

2279-
if (!cpus_have_final_cap(ARM64_HAS_FGT))
2280-
goto check_mcb;
2281-
22822279
for (int i = 0; i < ARRAY_SIZE(encoding_to_fgt); i++) {
22832280
const struct encoding_to_trap_config *fgt = &encoding_to_fgt[i];
22842281
union trap_config tc;
@@ -2298,18 +2295,22 @@ int __init populate_nv_trap_config(void)
22982295
}
22992296

23002297
tc.val |= fgt->tc.val;
2298+
2299+
if (!aggregate_fgt(tc)) {
2300+
ret = -EINVAL;
2301+
print_nv_trap_error(fgt, "FGT bit is reserved", ret);
2302+
}
2303+
2304+
if (!cpus_have_final_cap(ARM64_HAS_FGT))
2305+
continue;
2306+
23012307
prev = xa_store(&sr_forward_xa, enc,
23022308
xa_mk_value(tc.val), GFP_KERNEL);
23032309

23042310
if (xa_is_err(prev)) {
23052311
ret = xa_err(prev);
23062312
print_nv_trap_error(fgt, "Failed FGT insertion", ret);
23072313
}
2308-
2309-
if (!aggregate_fgt(tc)) {
2310-
ret = -EINVAL;
2311-
print_nv_trap_error(fgt, "FGT bit is reserved", ret);
2312-
}
23132314
}
23142315
}
23152316

@@ -2325,7 +2326,6 @@ int __init populate_nv_trap_config(void)
23252326
kvm_info("nv: %ld fine grained trap handlers\n",
23262327
ARRAY_SIZE(encoding_to_fgt));
23272328

2328-
check_mcb:
23292329
for (int id = __MULTIPLE_CONTROL_BITS__; id < __COMPLEX_CONDITIONS__; id++) {
23302330
const enum cgt_group_id *cgids;
23312331

0 commit comments

Comments
 (0)