From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Thomas Huth <thuth@redhat.com>,
Janosch Frank <frankja@linux.ibm.com>,
David Hildenbrand <david@redhat.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH 3/3] s390x: Test effect of storage keys on some more instructions
Date: Mon, 9 May 2022 16:07:26 +0200 [thread overview]
Message-ID: <9635e559-5c2c-30f4-ab19-aef28ba24ac0@linux.ibm.com> (raw)
In-Reply-To: <20220506185227.165c7d86@p-imbrenda>
On 5/6/22 18:52, Claudio Imbrenda wrote:
> On Thu, 5 May 2022 14:46:56 +0200
> Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:
>
>> Test correctness of some instructions handled by user space instead of
>> KVM with regards to storage keys.
>> Test success and error conditions, including coverage of storage and
>> fetch protection override.
>>
>> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
>> ---
>> s390x/skey.c | 277 ++++++++++++++++++++++++++++++++++++++++++++
>> s390x/unittests.cfg | 1 +
>> 2 files changed, 278 insertions(+)
>>
>> diff --git a/s390x/skey.c b/s390x/skey.c
>> index 56bf5f45..d50470a8 100644
>> --- a/s390x/skey.c
>> +++ b/s390x/skey.c
>> @@ -12,6 +12,7 @@
>> #include <asm/asm-offsets.h>
>> #include <asm/interrupt.h>
>> #include <vmalloc.h>
>> +#include <css.h>
>> #include <asm/page.h>
>> #include <asm/facility.h>
>> #include <asm/mem.h>
>> @@ -284,6 +285,114 @@ static void test_store_cpu_address(void)
>> report_prefix_pop();
>> }
>>
>> +/*
>> + * Perform CHANNEL SUBSYSTEM CALL (CHSC) instruction while temporarily executing
>> + * with access key 1.
>> + */
>> +static unsigned int channel_subsystem_call_key_1(void *communication_block)
>
> this function name is very long (maybe chsc_with_key_1 instead?)
It's because of consistency with set_prefix_key_1 where I spelled out the instruction
name too. Granted the name of chsc is longer.
When in doubt I go for what seems more readable/contains more information.
>
>> +{
>> + uint32_t program_mask;
>> +
>> + asm volatile (
>> + "spka 0x10\n\t"
>> + ".insn rre,0xb25f0000,%[communication_block],0\n\t"
>> + "spka 0\n\t"
>> + "ipm %[program_mask]\n"
>> + : [program_mask] "=d" (program_mask)
>> + : [communication_block] "d" (communication_block)
>> + : "memory"
>> + );
>> + return program_mask >> 28;
>> +}
>> +
>> +static void init_store_channel_subsystem_characteristics(uint16_t *communication_block)
>
> same here (init_comm_block?)
Since we're only performing one kind of operation in this test, that is fine,
but I'll add a comment saying how we initialize the communication block then.
>
>> +{
>> + memset(communication_block, 0, PAGE_SIZE);
>> + communication_block[0] = 0x10;
>> + communication_block[1] = 0x10;
>> + communication_block[9] = 0;
>> +}
>> +
>> +static void test_channel_subsystem_call(void)
>> +{
>> + static const char request_name[] = "Store channel-subsystem-characteristics";
>
> so this "request_name" is for when CHSC succeeds? why not just
> "Success" then?
That's the operation being performed. So maybe I should change it to
msg[] = "Performed store channel-subsystem-characteristics" ?
>
>> + uint16_t *communication_block = (uint16_t *)&pagebuf;
>
> long name (consider comm_block, or even cb)
>
>> + unsigned int cc;
>> +
>> + report_prefix_push("CHANNEL SUBSYSTEM CALL");
>> +
>> + report_prefix_push("zero key");
>> + init_store_channel_subsystem_characteristics(communication_block);
>
> see what I mean when I say that the names are too long? ^
Fits in 80 columns ;-)
>
>> + set_storage_key(communication_block, 0x10, 0);
>> + asm volatile (
>> + ".insn rre,0xb25f0000,%[communication_block],0\n\t"
>> + "ipm %[cc]\n"
>> + : [cc] "=d" (cc)
>> + : [communication_block] "d" (communication_block)
>> + : "memory"
>> + );
>> + cc = cc >> 28;
>> + report(cc == 0 && communication_block[9], request_name);
>> + report_prefix_pop();
>> +
>> + report_prefix_push("matching key");
>> + init_store_channel_subsystem_characteristics(communication_block);
>> + set_storage_key(communication_block, 0x10, 0);
>
> you just set the storage key in the previous test, and you did not set
> it back to 0, why do you need to set it again?
It's not necessary, but I want the tests to be independent from each other,
so you can remove/reorder/add ones without having to think.
>
>> + cc = channel_subsystem_call_key_1(communication_block);
>> + report(cc == 0 && communication_block[9], request_name);
>> + report_prefix_pop();
>> +
[...]
>> +
>> + cc = stsch(test_device_sid, schib);
>> + if (cc) {
>> + report_fail("could not store SCHIB");
>> + return;
>> + }
>> +
>> + report_prefix_push("zero key");
>> + schib->pmcw.intparm = 100;
>> + set_storage_key(schib, 0x28, 0);
>> + cc = msch(test_device_sid, schib);
>> + if (!cc) {
>> + WRITE_ONCE(schib->pmcw.intparm, 0);
>
> why are you using WRITE_ONCE here?
It's a dead store because of the stsch below.
That line is just for good measure so we know stsch really overwrote the value.
>
>> + cc = stsch(test_device_sid, schib);
>> + report(!cc && schib->pmcw.intparm == 100, "fetched from SCHIB");
[...]
prev parent reply other threads:[~2022-05-09 14:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 12:46 [kvm-unit-tests PATCH 0/3] s390x: More storage key instruction Janis Schoetterl-Glausch
2022-05-05 12:46 ` [kvm-unit-tests PATCH 1/3] s390x: Fix sclp facility bit numbers Janis Schoetterl-Glausch
2022-05-06 15:31 ` Claudio Imbrenda
2022-05-10 17:13 ` Janosch Frank
2022-05-10 17:13 ` Janosch Frank
2022-05-11 9:48 ` Janis Schoetterl-Glausch
2022-05-05 12:46 ` [kvm-unit-tests PATCH 2/3] s390x: Test TEID values in storage key test Janis Schoetterl-Glausch
2022-05-06 15:37 ` Claudio Imbrenda
2022-05-09 13:39 ` Janis Schoetterl-Glausch
2022-05-05 12:46 ` [kvm-unit-tests PATCH 3/3] s390x: Test effect of storage keys on some more instructions Janis Schoetterl-Glausch
2022-05-06 16:52 ` Claudio Imbrenda
2022-05-09 14:07 ` Janis Schoetterl-Glausch [this message]
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=9635e559-5c2c-30f4-ab19-aef28ba24ac0@linux.ibm.com \
--to=scgl@linux.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.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