On Wed, Nov 23, 2022, Wang, Lei wrote: > > On 6/3/2022 8:41 AM, Sean Christopherson wrote: > > Add helpers for the various one-off helpers used by x86's vCPU state > > save/restore helpers, and convert the other open coded ioctl()s to use > > existing helpers. > > > > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> > > --- > > .../selftests/kvm/include/x86_64/processor.h | 54 ++++++++ > > .../selftests/kvm/lib/x86_64/processor.c | 126 +++++------------- > > 2 files changed, 91 insertions(+), 89 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h > > index e4268432cfe8..1d46d60bb480 100644 > > --- a/tools/testing/selftests/kvm/include/x86_64/processor.h > > +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h > > @@ -432,6 +432,60 @@ const struct kvm_msr_list *kvm_get_feature_msr_index_list(void); > > bool kvm_msr_is_in_save_restore_list(uint32_t msr_index); > > uint64_t kvm_get_feature_msr(uint64_t msr_index); > > > > +static inline void vcpu_msrs_get(struct kvm_vm *vm, uint32_t vcpuid, > > + struct kvm_msrs *msrs) > > +{ > > + int r = __vcpu_ioctl(vm, vcpuid, KVM_GET_MSRS, msrs); > > + > > + TEST_ASSERT(r == msrs->nmsrs, > > + "KVM_GET_MSRS failed, r: %i (failed on MSR %x)", > > + r, r < 0 || r >= msrs->nmsrs ? -1 : msrs->entries[r].index); > > +} > > +static inline void vcpu_msrs_set(struct kvm_vm *vm, uint32_t vcpuid, > > + struct kvm_msrs *msrs) > > +{ > > + int r = __vcpu_ioctl(vm, vcpuid, KVM_SET_MSRS, msrs); > > + > > + TEST_ASSERT(r == msrs->nmsrs, > > + "KVM_GET_MSRS failed, r: %i (failed on MSR %x)", > > Hi, Sean, this should be the "KVM_SET_MSRS failed", right? Yep. I wish I could say I was cleverly justifying use of macro magic, but it was just a copy+paste goof.