summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/riscv/processor.h
diff options
context:
space:
mode:
authorAtish Patra <atishp@rivosinc.com>2024-04-20 18:17:34 +0300
committerAnup Patel <anup@brainfault.org>2024-04-26 10:44:00 +0300
commit97be675bfdb5086a6ad1aeeaa43df78b1afd5a0d (patch)
treec6472812adce5533136604279461568d11ac379d /tools/testing/selftests/kvm/include/riscv/processor.h
parent9408a23fac62d31de067bd2b0099eb9151395345 (diff)
downloadlinux-97be675bfdb5086a6ad1aeeaa43df78b1afd5a0d.tar.xz
KVM: riscv: selftests: Add helper functions for extension checks
__vcpu_has_ext can check both SBI and ISA extensions when the first argument is properly converted to SBI/ISA extension IDs. Introduce two helper functions to make life easier for developers so they don't have to worry about the conversions. Replace the current usages as well with new helpers. Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20240420151741.962500-19-atishp@rivosinc.com Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'tools/testing/selftests/kvm/include/riscv/processor.h')
-rw-r--r--tools/testing/selftests/kvm/include/riscv/processor.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h
index 3b9cb39327ff..5f389166338c 100644
--- a/tools/testing/selftests/kvm/include/riscv/processor.h
+++ b/tools/testing/selftests/kvm/include/riscv/processor.h
@@ -50,6 +50,16 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t subtype,
bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext);
+static inline bool __vcpu_has_isa_ext(struct kvm_vcpu *vcpu, uint64_t isa_ext)
+{
+ return __vcpu_has_ext(vcpu, RISCV_ISA_EXT_REG(isa_ext));
+}
+
+static inline bool __vcpu_has_sbi_ext(struct kvm_vcpu *vcpu, uint64_t sbi_ext)
+{
+ return __vcpu_has_ext(vcpu, RISCV_SBI_EXT_REG(sbi_ext));
+}
+
struct ex_regs {
unsigned long ra;
unsigned long sp;