* [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
@ 2022-02-15 7:48 Thomas Huth
2022-02-15 9:23 ` Claudio Imbrenda
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Thomas Huth @ 2022-02-15 7:48 UTC (permalink / raw)
To: Christian Borntraeger, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel
Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
guest") fixed the behavior of the SIDA memops for normal guests. It
would be nice to have a way to test whether the current kernel has
the fix applied or not. Thus add a check to the KVM selftests for
these two memops.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
index 9f49ead380ab..d19c3ffdea3f 100644
--- a/tools/testing/selftests/kvm/s390x/memop.c
+++ b/tools/testing/selftests/kvm/s390x/memop.c
@@ -160,6 +160,21 @@ int main(int argc, char *argv[])
run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
vcpu_run(vm, VCPU_ID); /* Run to sync new state */
+ /* Check that the SIDA calls are rejected for non-protected guests */
+ ksmo.gaddr = 0;
+ ksmo.flags = 0;
+ ksmo.size = 8;
+ ksmo.op = KVM_S390_MEMOP_SIDA_READ;
+ ksmo.buf = (uintptr_t)mem1;
+ ksmo.sida_offset = 0x1c0;
+ rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
+ TEST_ASSERT(rv == -1 && errno == EINVAL,
+ "ioctl does not reject SIDA_READ in non-protected mode");
+ ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
+ rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
+ TEST_ASSERT(rv == -1 && errno == EINVAL,
+ "ioctl does not reject SIDA_WRITE in non-protected mode");
+
kvm_vm_free(vm);
return 0;
--
2.27.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 7:48 [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests Thomas Huth
@ 2022-02-15 9:23 ` Claudio Imbrenda
2022-02-15 9:54 ` Janis Schoetterl-Glausch
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Claudio Imbrenda @ 2022-02-15 9:23 UTC (permalink / raw)
To: Thomas Huth
Cc: Christian Borntraeger, Janosch Frank, kvm, David Hildenbrand,
Paolo Bonzini, linux-kselftest, linux-kernel
On Tue, 15 Feb 2022 08:48:24 +0100
Thomas Huth <thuth@redhat.com> wrote:
> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
> guest") fixed the behavior of the SIDA memops for normal guests. It
> would be nice to have a way to test whether the current kernel has
> the fix applied or not. Thus add a check to the KVM selftests for
> these two memops.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
looks rather straightforward
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index 9f49ead380ab..d19c3ffdea3f 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c
> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>
> + /* Check that the SIDA calls are rejected for non-protected guests */
> + ksmo.gaddr = 0;
> + ksmo.flags = 0;
> + ksmo.size = 8;
> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
> + ksmo.buf = (uintptr_t)mem1;
> + ksmo.sida_offset = 0x1c0;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_READ in non-protected mode");
> + ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_WRITE in non-protected mode");
> +
> kvm_vm_free(vm);
>
> return 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 7:48 [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests Thomas Huth
2022-02-15 9:23 ` Claudio Imbrenda
@ 2022-02-15 9:54 ` Janis Schoetterl-Glausch
2022-02-15 9:59 ` Thomas Huth
2022-02-15 12:11 ` Christian Borntraeger
2022-02-15 15:25 ` Shuah Khan
3 siblings, 1 reply; 8+ messages in thread
From: Janis Schoetterl-Glausch @ 2022-02-15 9:54 UTC (permalink / raw)
To: Thomas Huth, Christian Borntraeger, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel
On 2/15/22 08:48, Thomas Huth wrote:
> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
> guest") fixed the behavior of the SIDA memops for normal guests. It
> would be nice to have a way to test whether the current kernel has
> the fix applied or not. Thus add a check to the KVM selftests for
> these two memops.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index 9f49ead380ab..d19c3ffdea3f 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c
> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>
> + /* Check that the SIDA calls are rejected for non-protected guests */
> + ksmo.gaddr = 0;
> + ksmo.flags = 0;
> + ksmo.size = 8;
> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
> + ksmo.buf = (uintptr_t)mem1;
> + ksmo.sida_offset = 0x1c0;
What is the rational for that constant?
Any would do, as long as size + offset < PAGE_SIZE, correct?
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_READ in non-protected mode");
> + ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_WRITE in non-protected mode");
> +
> kvm_vm_free(vm);
>
> return 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 9:54 ` Janis Schoetterl-Glausch
@ 2022-02-15 9:59 ` Thomas Huth
2022-02-15 10:03 ` Janis Schoetterl-Glausch
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Huth @ 2022-02-15 9:59 UTC (permalink / raw)
To: Janis Schoetterl-Glausch, Christian Borntraeger, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel
On 15/02/2022 10.54, Janis Schoetterl-Glausch wrote:
> On 2/15/22 08:48, Thomas Huth wrote:
>> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
>> guest") fixed the behavior of the SIDA memops for normal guests. It
>> would be nice to have a way to test whether the current kernel has
>> the fix applied or not. Thus add a check to the KVM selftests for
>> these two memops.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
>> index 9f49ead380ab..d19c3ffdea3f 100644
>> --- a/tools/testing/selftests/kvm/s390x/memop.c
>> +++ b/tools/testing/selftests/kvm/s390x/memop.c
>> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
>> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
>> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>>
>> + /* Check that the SIDA calls are rejected for non-protected guests */
>> + ksmo.gaddr = 0;
>> + ksmo.flags = 0;
>> + ksmo.size = 8;
>> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
>> + ksmo.buf = (uintptr_t)mem1;
>> + ksmo.sida_offset = 0x1c0;
>
> What is the rational for that constant?
> Any would do, as long as size + offset < PAGE_SIZE, correct?
Right, it's rather a random value.
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 9:59 ` Thomas Huth
@ 2022-02-15 10:03 ` Janis Schoetterl-Glausch
0 siblings, 0 replies; 8+ messages in thread
From: Janis Schoetterl-Glausch @ 2022-02-15 10:03 UTC (permalink / raw)
To: Thomas Huth, Christian Borntraeger, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel
On 2/15/22 10:59, Thomas Huth wrote:
> On 15/02/2022 10.54, Janis Schoetterl-Glausch wrote:
>> On 2/15/22 08:48, Thomas Huth wrote:
>>> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
>>> guest") fixed the behavior of the SIDA memops for normal guests. It
>>> would be nice to have a way to test whether the current kernel has
>>> the fix applied or not. Thus add a check to the KVM selftests for
>>> these two memops.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
>>> 1 file changed, 15 insertions(+)
>>>
>>> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
>>> index 9f49ead380ab..d19c3ffdea3f 100644
>>> --- a/tools/testing/selftests/kvm/s390x/memop.c
>>> +++ b/tools/testing/selftests/kvm/s390x/memop.c
>>> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
>>> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
>>> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>>>
>>> + /* Check that the SIDA calls are rejected for non-protected guests */
>>> + ksmo.gaddr = 0;
>>> + ksmo.flags = 0;
>>> + ksmo.size = 8;
>>> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
>>> + ksmo.buf = (uintptr_t)mem1;
>>> + ksmo.sida_offset = 0x1c0;
>>
>> What is the rational for that constant?
>> Any would do, as long as size + offset < PAGE_SIZE, correct?
>
> Right, it's rather a random value.
Ah, ok.
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
>
> Thomas
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 7:48 [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests Thomas Huth
2022-02-15 9:23 ` Claudio Imbrenda
2022-02-15 9:54 ` Janis Schoetterl-Glausch
@ 2022-02-15 12:11 ` Christian Borntraeger
2022-02-15 15:25 ` Shuah Khan
3 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2022-02-15 12:11 UTC (permalink / raw)
To: Thomas Huth, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel
Am 15.02.22 um 08:48 schrieb Thomas Huth:
> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
> guest") fixed the behavior of the SIDA memops for normal guests. It
> would be nice to have a way to test whether the current kernel has
> the fix applied or not. Thus add a check to the KVM selftests for
> these two memops.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Thanks, applied.
> ---
> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index 9f49ead380ab..d19c3ffdea3f 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c
> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>
> + /* Check that the SIDA calls are rejected for non-protected guests */
> + ksmo.gaddr = 0;
> + ksmo.flags = 0;
> + ksmo.size = 8;
> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
> + ksmo.buf = (uintptr_t)mem1;
> + ksmo.sida_offset = 0x1c0;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_READ in non-protected mode");
> + ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_WRITE in non-protected mode");
> +
> kvm_vm_free(vm);
>
> return 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 7:48 [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests Thomas Huth
` (2 preceding siblings ...)
2022-02-15 12:11 ` Christian Borntraeger
@ 2022-02-15 15:25 ` Shuah Khan
2022-02-21 9:31 ` Thomas Huth
3 siblings, 1 reply; 8+ messages in thread
From: Shuah Khan @ 2022-02-15 15:25 UTC (permalink / raw)
To: Thomas Huth, Christian Borntraeger, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel, Shuah Khan
On 2/15/22 12:48 AM, Thomas Huth wrote:
> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
> guest") fixed the behavior of the SIDA memops for normal guests. It
> would be nice to have a way to test whether the current kernel has
> the fix applied or not. Thus add a check to the KVM selftests for
> these two memops.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index 9f49ead380ab..d19c3ffdea3f 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c
> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>
> + /* Check that the SIDA calls are rejected for non-protected guests */
> + ksmo.gaddr = 0;
> + ksmo.flags = 0;
> + ksmo.size = 8;
> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
> + ksmo.buf = (uintptr_t)mem1;
> + ksmo.sida_offset = 0x1c0;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_READ in non-protected mode");
Printing what passed would be a good addition to understand the tests that
get run and expected to pass.
> + ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
> + TEST_ASSERT(rv == -1 && errno == EINVAL,
> + "ioctl does not reject SIDA_WRITE in non-protected mode");
> +
Same here.
> kvm_vm_free(vm);
>
> return 0;
>
Something to consider in a follow-on patch and future changes to these tests.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests
2022-02-15 15:25 ` Shuah Khan
@ 2022-02-21 9:31 ` Thomas Huth
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Huth @ 2022-02-21 9:31 UTC (permalink / raw)
To: Shuah Khan, Christian Borntraeger, Janosch Frank, kvm
Cc: David Hildenbrand, Claudio Imbrenda, Paolo Bonzini,
linux-kselftest, linux-kernel
On 15/02/2022 16.25, Shuah Khan wrote:
> On 2/15/22 12:48 AM, Thomas Huth wrote:
>> Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
>> guest") fixed the behavior of the SIDA memops for normal guests. It
>> would be nice to have a way to test whether the current kernel has
>> the fix applied or not. Thus add a check to the KVM selftests for
>> these two memops.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>> tools/testing/selftests/kvm/s390x/memop.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/tools/testing/selftests/kvm/s390x/memop.c
>> b/tools/testing/selftests/kvm/s390x/memop.c
>> index 9f49ead380ab..d19c3ffdea3f 100644
>> --- a/tools/testing/selftests/kvm/s390x/memop.c
>> +++ b/tools/testing/selftests/kvm/s390x/memop.c
>> @@ -160,6 +160,21 @@ int main(int argc, char *argv[])
>> run->psw_mask &= ~(3UL << (63 - 17)); /* Disable AR mode */
>> vcpu_run(vm, VCPU_ID); /* Run to sync new state */
>> + /* Check that the SIDA calls are rejected for non-protected guests */
>> + ksmo.gaddr = 0;
>> + ksmo.flags = 0;
>> + ksmo.size = 8;
>> + ksmo.op = KVM_S390_MEMOP_SIDA_READ;
>> + ksmo.buf = (uintptr_t)mem1;
>> + ksmo.sida_offset = 0x1c0;
>> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
>> + TEST_ASSERT(rv == -1 && errno == EINVAL,
>> + "ioctl does not reject SIDA_READ in non-protected mode");
>
> Printing what passed would be a good addition to understand the tests that
> get run and expected to pass.
Yes, I agree ... I'll add that for a follow-up patch to my TODO list.
>> + ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
>> + rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
>> + TEST_ASSERT(rv == -1 && errno == EINVAL,
>> + "ioctl does not reject SIDA_WRITE in non-protected mode");
>> +
>
> Same here.
>
>> kvm_vm_free(vm);
>> return 0;
>>
>
> Something to consider in a follow-on patch and future changes to these tests.
>
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Thanks!
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-02-21 10:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 7:48 [PATCH] selftests: kvm: Check whether SIDA memop fails for normal guests Thomas Huth
2022-02-15 9:23 ` Claudio Imbrenda
2022-02-15 9:54 ` Janis Schoetterl-Glausch
2022-02-15 9:59 ` Thomas Huth
2022-02-15 10:03 ` Janis Schoetterl-Glausch
2022-02-15 12:11 ` Christian Borntraeger
2022-02-15 15:25 ` Shuah Khan
2022-02-21 9:31 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).