On Sun, May 03, 2026 at 09:00:53PM -0700, Yong-Xuan Wang wrote: > Not all the registers in a sublist are supported on a platform, e.g. the > SUBLIST_SBI_FWFT list. Add the check_supported_reg() to remove the false > alarm of missing registers. > > Signed-off-by: Yong-Xuan Wang <[email protected]> > --- > tools/testing/selftests/kvm/riscv/get-reg-list.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c > b/tools/testing/selftests/kvm/riscv/get-reg-list.c > index 8d6b951434eb..d7cb9b5d37df 100644 > --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c > +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c > @@ -28,6 +28,18 @@ enum { > > static bool isa_ext_cant_disable[KVM_RISCV_ISA_EXT_MAX]; > > +bool check_supported_reg(struct kvm_vcpu *vcpu, __u64 reg) > +{ > + int ret; > + u64 data; > + > + ret = __vcpu_get_reg(vcpu, reg, &data); > + if (ret < 0) > + return false; > + > + return true; > +} > +
arm64 implements this function to only return false when a register's corresponding feature register isn't present or it indicates the feature isn't present. The above would return false for all missing registers, even when they shouldn't be. OIOW, the above makes for_each_missing_reg() useless for riscv. When its OK for registers to be missing, then we need some way to determine that. If a sublist has optional registers then it should be broken into multiple sublists. Then, this function can be implemented to return false for registers in the sublists of optional registers when we have determined those sublists won't be present. Thanks, drew

