Skip to content

[PW_SID:1141925] RISC-V: KVM: Add PMU event filter support - #2428

Open
linux-riscv-bot wants to merge 3 commits into
workflow__riscv__fixesfrom
pw1141925
Open

[PW_SID:1141925] RISC-V: KVM: Add PMU event filter support#2428
linux-riscv-bot wants to merge 3 commits into
workflow__riscv__fixesfrom
pw1141925

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

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

Linux RISC-V bot and others added 3 commits August 7, 2026 03:32
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>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 117.55 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1152.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1438.98 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.99 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.54 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.15 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 78.78 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.85 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
kdoc
Desc: Detects for kdoc errors
Duration: 0.72 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Add PMU event filter support"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 116.61 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1105.36 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1402.79 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.72 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.20 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.86 seconds
Result: WARNING
Output:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#42: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 206 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 4cfe551cb7a6 ("RISC-V: KVM: selftests: Add PMU event filter test") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 0 checks, 206 lines checked
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 79.36 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
kdoc
Desc: Detects for kdoc errors
Duration: 0.74 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
module-param
Desc: Detect module_param changes
Duration: 0.63 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: selftests: Add PMU event filter test"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot force-pushed the workflow__riscv__fixes branch from abf8962 to 9fa746d Compare August 8, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant