[PW_SID:1141925] RISC-V: KVM: Add PMU event filter support - #2428
[PW_SID:1141925] RISC-V: KVM: Add PMU event filter support#2428linux-riscv-bot wants to merge 3 commits into
Conversation
Allow userspace to restrict which SBI PMU events a guest is permitted to program via the new VM ioctl KVM_SET_PMU_EVENT_FILTER. It takes a struct kvm_pmu_event_filter whose events[] array holds SBI PMU event indices encoded as (type << 16) | code. The action field selects ALLOW (only listed events may be programmed) or DENY (listed events are rejected); nevents == 0 clears any active filter. The filter is enforced in kvm_riscv_vcpu_pmu_ctr_cfg_match(), where a disallowed event fails configuration with SBI_ERR_NOT_SUPPORTED. It governs new counter configuration only and is not retroactive. The filter lives in struct kvm_arch, read via SRCU on the vCPU run path and replaced under kvm->lock with synchronize_srcu_expedited(). Event indices are masked to their valid bits before comparison, so reserved high bits cannot bypass a DENY filter. Advertise the feature with KVM_CAP_PMU_EVENT_FILTER. Assisted-by: YuanSheng:deepseek-v4-pro Co-developed-by: Quan Zhou <zhouquan@iscas.ac.cn> Signed-off-by: Quan Zhou <zhouquan@iscas.ac.cn> Signed-off-by: Yuhang.chen <yhchen312@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add a selftest that exercises KVM_SET_PMU_EVENT_FILTER on RISC-V. The guest programs the CPU cycles and instructions SBI PMU events through SBI_EXT_PMU_COUNTER_CFG_MATCH while the host installs filters with the ALLOW and DENY actions, asserting that disallowed events return SBI_ERR_NOT_SUPPORTED and allowed events succeed. The test also validates ioctl argument rejection: an invalid action, a non-zero flags field, and an over-large nevents value are each expected to fail with -EINVAL or -E2BIG. A baseline run verifies PMU availability and the test skips (KSFT_SKIP) when PMU or the filter capability is absent. Assisted-by: YuanSheng:deepseek-v4-pro Co-developed-by: Quan Zhou <zhouquan@iscas.ac.cn> Signed-off-by: Quan Zhou <zhouquan@iscas.ac.cn> Signed-off-by: Yuhang.chen <yhchen312@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
|
Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test" |
abf8962 to
9fa746d
Compare
PR for series 1141925 applied to workflow__riscv__fixes
Name: RISC-V: KVM: Add PMU event filter support
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1141925
Version: 2