[PW_SID:1103948] KVM: riscv: Fix stale FWFT feature exposure and enhance selftests#2039
[PW_SID:1103948] KVM: riscv: Fix stale FWFT feature exposure and enhance selftests#2039linux-riscv-bot wants to merge 5 commits into
Conversation
Mark the vCPU CSRs as dirty after successfully setting an FWFT feature value. FWFT features may modify CSRs (e.g., pointer masking modifies henvcfg.PMM), and failing to mark them dirty can lead to the guest observing stale CSR state after vCPU scheduling or migration. Fixes: 1323a5c ("KVM: riscv: Skip CSR restore if VCPU is reloaded on the same core") Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add an optional init() callback to separate one-time hardware probing from runtime availability checks. For pointer masking, this allows probing supported PMM lengths during initialization while checking ISA extension availability at runtime. Fix try_to_set_pmm() to restore the previous HENVCFG.PMM value after probing, preventing side effects from hardware detection. Add preemption protection to ensure CSR probe sequences complete atomically on the same CPU. Fixes: 6f576fc ("RISC-V: KVM: Add support for SBI_FWFT_POINTER_MASKING_PMLEN") Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…sion 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: 6b72fd1 ("RISC-V: KVM: add support for FWFT SBI extension") Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Refactor the get-reg-list test to use unified sublist macros for ISA and SBI extensions, eliminating code duplication and improving maintainability. Previously, each extension had its own hand-coded sublist definition (e.g., SUBLIST_ZICBOM, SUBLIST_AIA, etc.) and the config structures repeated the same pattern. This made the code verbose and error-prone. Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…sublists Divide the monolithic SBI FWFT (Firmware Features) register list into separate sublists, each testing a specific FWFT feature independently with proper dependency checking. Previously, all FWFT features were tested together in a single sublist. This caused issues because: 1. Not all FWFT features are available on all platforms 2. Some features depend on specific ISA extensions (e.g., pointer_masking requires Smnpm) 3. Tests would fail if any single feature was unavailable Add the feature-specific SBI FWFT sublists with the following improvements: - Add check_fwft_feature() helper to verify FWFT feature availability at runtime - Update filter_reg() to handle per-feature FWFT register filtering Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 1: "[v5,1/5] KVM: RISC-V: SBI FWFT: Mark vCPU CSRs dirty after setting feature value" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 2: "[v5,2/5] KVM: RISC-V: SBI FWFT: Add optional init() callback for hardware probing" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 3: "[v5,3/5] KVM: RISC-V: SBI FWFT: Fix stale feature exposure after runtime extension changes" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 4: "[v5,4/5] KVM: riscv: selftests: Refactor ISA and SBI extension sublist macros" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
|
Patch 5: "[v5,5/5] KVM: riscv: selftests: Split SBI FWFT into separate feature-specific sublists" |
PR for series 1103948 applied to workflow__riscv__fixes
Name: KVM: riscv: Fix stale FWFT feature exposure and enhance selftests
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1103948
Version: 5