From: Janosch Frank <frankja@linux.ibm.com>
To: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
kvm@vger.kernel.org, borntraeger@de.ibm.com, david@redhat.com,
cohuck@redhat.com, linux-s390@vger.kernel.org
Subject: Re: [PATCH v8 2/4] selftests: KVM: Add fpu and one reg set/get library functions
Date: Thu, 30 Jan 2020 15:58:46 +0100 [thread overview]
Message-ID: <8095f321-0d31-1285-7fa5-a751aeb6e56f@linux.ibm.com> (raw)
In-Reply-To: <20200130143008.xy6lrnrrwer6xkdp@kamzik.brq.redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 6378 bytes --]
On 1/30/20 3:30 PM, Andrew Jones wrote:
> On Thu, Jan 30, 2020 at 03:10:55PM +0100, Janosch Frank wrote:
>> On 1/30/20 2:55 PM, Andrew Jones wrote:
>>> On Thu, Jan 30, 2020 at 11:36:21AM +0100, Thomas Huth wrote:
>>>> On 29/01/2020 21.03, Janosch Frank wrote:
>>>>> Add library access to more registers.
>>>>>
>>>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>>>> ---
>>>>> .../testing/selftests/kvm/include/kvm_util.h | 6 +++
>>>>> tools/testing/selftests/kvm/lib/kvm_util.c | 48 +++++++++++++++++++
>>>>> 2 files changed, 54 insertions(+)
>>>>>
>>>>> diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
>>>>> index 29cccaf96baf..ae0d14c2540a 100644
>>>>> --- a/tools/testing/selftests/kvm/include/kvm_util.h
>>>>> +++ b/tools/testing/selftests/kvm/include/kvm_util.h
>>>>> @@ -125,6 +125,12 @@ void vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid,
>>>>> struct kvm_sregs *sregs);
>>>>> int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid,
>>>>> struct kvm_sregs *sregs);
>>>>> +void vcpu_fpu_get(struct kvm_vm *vm, uint32_t vcpuid,
>>>>> + struct kvm_fpu *fpu);
>>>>> +void vcpu_fpu_set(struct kvm_vm *vm, uint32_t vcpuid,
>>>>> + struct kvm_fpu *fpu);
>
> nit: no need for the above line breaks. We don't even get to 80 char.
>
>>>>> +void vcpu_get_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg);
>>>>> +void vcpu_set_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg);
>>>>> #ifdef __KVM_HAVE_VCPU_EVENTS
>>>>> void vcpu_events_get(struct kvm_vm *vm, uint32_t vcpuid,
>>>>> struct kvm_vcpu_events *events);
>>>>> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
>>>>> index 41cf45416060..dae117728ec6 100644
>>>>> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
>>>>> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
>>>>> @@ -1373,6 +1373,54 @@ int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs)
>>>>> return ioctl(vcpu->fd, KVM_SET_SREGS, sregs);
>>>>> }
>>>>>
>>>>> +void vcpu_fpu_get(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_fpu *fpu)
>>>>> +{
>>>>> + struct vcpu *vcpu = vcpu_find(vm, vcpuid);
>>>>> + int ret;
>>>>> +
>>>>> + TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid);
>>>>> +
>>>>> + ret = ioctl(vcpu->fd, KVM_GET_FPU, fpu);
>>>>> + TEST_ASSERT(ret == 0, "KVM_GET_FPU failed, rc: %i errno: %i",
>>>>> + ret, errno);
>>>>> +}
>>>>> +
>>>>> +void vcpu_fpu_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_fpu *fpu)
>>>>> +{
>>>>> + struct vcpu *vcpu = vcpu_find(vm, vcpuid);
>>>>> + int ret;
>>>>> +
>>>>> + TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid);
>>>>> +
>>>>> + ret = ioctl(vcpu->fd, KVM_SET_FPU, fpu);
>>>>> + TEST_ASSERT(ret == 0, "KVM_SET_FPU failed, rc: %i errno: %i",
>>>>> + ret, errno);
>>>>> +}
>>>>> +
>>>>> +void vcpu_get_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg)
>>>>> +{
>>>>> + struct vcpu *vcpu = vcpu_find(vm, vcpuid);
>>>>> + int ret;
>>>>> +
>>>>> + TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid);
>>>>> +
>>>>> + ret = ioctl(vcpu->fd, KVM_GET_ONE_REG, reg);
>>>>> + TEST_ASSERT(ret == 0, "KVM_GET_ONE_REG failed, rc: %i errno: %i",
>>>>> + ret, errno);
>>>>> +}
>>>>> +
>>>>> +void vcpu_set_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg)
>>>>> +{
>>>>> + struct vcpu *vcpu = vcpu_find(vm, vcpuid);
>>>>> + int ret;
>>>>> +
>>>>> + TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid);
>>>>> +
>>>>> + ret = ioctl(vcpu->fd, KVM_SET_ONE_REG, reg);
>>>>> + TEST_ASSERT(ret == 0, "KVM_SET_ONE_REG failed, rc: %i errno: %i",
>>>>> + ret, errno);
>>>>> +}
>>>>> +
>>>>> /*
>>>>> * VCPU Ioctl
>>>>> *
>>>>>
>>>>
>>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>>>
>>>
>>> How about what's below instead. It should be equivalent.
>>
>> With your proposed changes we loose a bit verbosity in the error
>> messages. I need to think about which I like more.
>
> Looks like both error messages are missing something. The ones above are
> missing the string version of errno. The ones below are missing the string
> version of cmd. It's easy to add the string version of errno, which is
> an argument for keeping the functions above (but we could at least use
> _vcpu_ioctl to avoid duplicating the vcpu_find and vcpu!=NULL assert).
Will do
> Or, we could consider adding a kvm_ioctl_cmd_to_string() function,
> which might be nice for other ioctl wrappers now and in the future.
> It shouldn't be too bad to generate a string table from kvm.h, but of
> course we'd have to keep it maintained.
I'm currently occupied with managing a lot of patches, so something like
that is not very high on my todo list.
>
> Thanks,
> drew
>
>>
>>>
>>> Thanks,
>>> drew
>>>
>>> diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
>>> index 29cccaf96baf..d96a072e69bf 100644
>>> --- a/tools/testing/selftests/kvm/include/kvm_util.h
>>> +++ b/tools/testing/selftests/kvm/include/kvm_util.h
>>> @@ -125,6 +125,31 @@ void vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid,
>>> struct kvm_sregs *sregs);
>>> int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid,
>>> struct kvm_sregs *sregs);
>>> +
>>> +static inline void
>>> +vcpu_fpu_get(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_fpu *fpu)
>>> +{
>>> + vcpu_ioctl(vm, vcpuid, KVM_GET_FPU, fpu);
>>> +}
>>> +
>>> +static inline void
>>> +vcpu_fpu_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_fpu *fpu)
>>> +{
>>> + vcpu_ioctl(vm, vcpuid, KVM_SET_FPU, fpu);
>>> +}
>>> +
>>> +static inline void
>>> +vcpu_get_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg)
>>> +{
>>> + vcpu_ioctl(vm, vcpuid, KVM_GET_ONE_REG, reg);
>>> +}
>>> +
>>> +static inline void
>>> +vcpu_set_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg)
>>> +{
>>> + vcpu_ioctl(vm, vcpuid, KVM_SET_ONE_REG, reg);
>>> +}
>>> +
>>> #ifdef __KVM_HAVE_VCPU_EVENTS
>>> void vcpu_events_get(struct kvm_vm *vm, uint32_t vcpuid,
>>> struct kvm_vcpu_events *events);
>>>
>>
>>
>
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-01-30 14:58 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 20:03 [PATCH v8 0/4] KVM: s390: Add new reset vcpu API Janosch Frank
2020-01-29 20:03 ` [PATCH v8 1/4] " Janosch Frank
2020-01-30 8:55 ` [PATCH/FIXUP FOR STABLE BEFORE THIS SERIES] KVM: s390: do not clobber user space fpc during guest reset Christian Borntraeger
2020-01-30 9:49 ` David Hildenbrand
2020-01-30 10:39 ` Cornelia Huck
2020-01-30 10:56 ` Thomas Huth
2020-01-30 11:07 ` Christian Borntraeger
2020-01-30 11:01 ` Christian Borntraeger
2020-01-30 11:14 ` Christian Borntraeger
2020-01-30 11:20 ` David Hildenbrand
2020-01-30 11:27 ` Christian Borntraeger
2020-01-30 11:42 ` [PATCH v2] KVM: s390: do not clobber user space registers during guest reset/store status Christian Borntraeger
2020-01-30 11:44 ` Christian Borntraeger
2020-01-30 12:01 ` Christian Borntraeger
2020-01-30 12:38 ` David Hildenbrand
2020-01-30 9:00 ` [PATCH v8 1/4] KVM: s390: Add new reset vcpu API Thomas Huth
2020-01-30 9:58 ` Christian Borntraeger
2020-01-29 20:03 ` [PATCH v8 2/4] selftests: KVM: Add fpu and one reg set/get library functions Janosch Frank
2020-01-30 10:36 ` Thomas Huth
2020-01-30 13:55 ` Andrew Jones
2020-01-30 14:10 ` Janosch Frank
2020-01-30 14:30 ` Andrew Jones
2020-01-30 14:58 ` Janosch Frank [this message]
2020-01-30 15:04 ` Andrew Jones
2020-01-29 20:03 ` [PATCH v8 3/4] selftests: KVM: s390x: Add reset tests Janosch Frank
2020-01-30 10:51 ` Thomas Huth
2020-01-30 11:32 ` Janosch Frank
2020-01-30 11:36 ` Thomas Huth
2020-01-29 20:03 ` [PATCH v8 4/4] selftests: KVM: testing the local IRQs resets Janosch Frank
2020-01-30 10:55 ` Cornelia Huck
2020-01-30 11:18 ` Janosch Frank
2020-01-30 11:28 ` Cornelia Huck
2020-01-30 11:34 ` Janosch Frank
2020-01-30 11:10 ` Thomas Huth
2020-01-30 11:33 ` Janosch Frank
2020-01-30 9:10 ` [PATCH] KVM: s390: Cleanup initial cpu reset Janosch Frank
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8095f321-0d31-1285-7fa5-a751aeb6e56f@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox