summaryrefslogtreecommitdiff
path: root/scripts/include/array_size.h
diff options
context:
space:
mode:
authorYong-Xuan Wang <yongxuan.wang@sifive.com>2026-06-01 13:26:24 +0300
committerAnup Patel <anup@brainfault.org>2026-06-05 19:08:58 +0300
commite659112a39cd93150d93c4661444a439d512e1ca (patch)
tree6afa46cbf4d55dbc9938951e4f98e124957234c0 /scripts/include/array_size.h
parent86957e5b4bff60c2f97d79c922e5dfafe0d94151 (diff)
downloadlinux-e659112a39cd93150d93c4661444a439d512e1ca.tar.xz
KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes
Fix a bug where FWFT features could be incorrectly exposed to guests after userspace disables their dependent ISA extensions at runtime. The 'supported' field in kvm_sbi_fwft_config was set once during vCPU initialization based on the initial hardware/extension availability. However, when userspace subsequently disables ISA extensions via the KVM ONE_REG interface, the 'supported' field was not updated. This caused the following issues: 1. FWFT features would remain visible and accessible to guests even after their prerequisite ISA extensions were disabled 2. Guests could configure FWFT features that depend on disabled extensions, leading to undefined behavior 3. The static 'supported' flag and the dynamic supported() callback could disagree about feature availability The fix introduces a two-layer checking mechanism: 1. Add an optional init() callback to the kvm_sbi_fwft_feature structure for features that require hardware probing during initialization. This separates the one-time hardware detection logic from the runtime availability check. 2. Add runtime checks in all FWFT-related functions that call feature->supported(vcpu) if the callback exists. This ensures feature availability is re-evaluated based on the current ISA extension state. This approach maintains the cached 'supported' field for initialization- time decisions while ensuring runtime availability is always determined by the current vCPU configuration, not initialization-time snapshots. Fixes: 6b72fd170592 ("RISC-V: KVM: add support for FWFT SBI extension") Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260601-kvm-get_reg_list-v2-v5-3-415d08a2813b@sifive.com Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'scripts/include/array_size.h')
0 files changed, 0 insertions, 0 deletions