From: Janosch Frank <frankja@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
thuth@redhat.com, david@redhat.com
Subject: Re: [kvm-unit-tests PATCH 5/6] s390x: uv-guest: Test invalid commands
Date: Mon, 26 Apr 2021 15:40:07 +0200 [thread overview]
Message-ID: <6a059cd0-cc31-7430-b62d-529fd72f1c9b@linux.ibm.com> (raw)
In-Reply-To: <20210420162649.4f9b77a6@ibm-vm>
On 4/20/21 4:26 PM, Claudio Imbrenda wrote:
> On Tue, 16 Mar 2021 09:16:53 +0000
> Janosch Frank <frankja@linux.ibm.com> wrote:
>
>> Let's check if the commands that are not indicated as available
>> produce a invalid command error.
>
> you say this, but you don't actually check that the commands are
> actually reported as unavailable
I'm a bit torn about this.
It is a UV guest test after all and we check that we are a UV guest in
main() so we are not able to accidentally run as a host. So those
indication bits and their associated calls should never be available.
>
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>> s390x/uv-guest.c | 44 +++++++++++++++++++++++++++++++++++++-------
>> 1 file changed, 37 insertions(+), 7 deletions(-)
>>
>> diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c
>> index 8915b2f1..517e3c66 100644
>> --- a/s390x/uv-guest.c
>> +++ b/s390x/uv-guest.c
>> @@ -120,16 +120,46 @@ static void test_sharing(void)
>> report_prefix_pop();
>> }
>>
>> +static struct {
>> + const char *name;
>> + uint16_t cmd;
>> + uint16_t len;
>> +} invalid_cmds[] = {
>> + { "bogus", 0x4242, sizeof(struct uv_cb_header) },
>> + { "init", UVC_CMD_INIT_UV, sizeof(struct uv_cb_init) },
>> + { "create conf", UVC_CMD_CREATE_SEC_CONF, sizeof(struct
>> uv_cb_cgc) },
>> + { "destroy conf", UVC_CMD_DESTROY_SEC_CONF, sizeof(struct
>> uv_cb_nodata) },
>> + { "create cpu", UVC_CMD_CREATE_SEC_CPU, sizeof(struct
>> uv_cb_csc) },
>> + { "destroy cpu", UVC_CMD_DESTROY_SEC_CPU, sizeof(struct
>> uv_cb_nodata) },
>> + { "conv to", UVC_CMD_CONV_TO_SEC_STOR, sizeof(struct
>> uv_cb_cts) },
>> + { "conv from", UVC_CMD_CONV_FROM_SEC_STOR, sizeof(struct
>> uv_cb_cfs) },
>> + { "set sec conf", UVC_CMD_SET_SEC_CONF_PARAMS, sizeof(struct
>> uv_cb_ssc) },
>> + { "unpack", UVC_CMD_UNPACK_IMG, sizeof(struct uv_cb_unp) },
>> + { "verify", UVC_CMD_VERIFY_IMG, sizeof(struct uv_cb_nodata)
>> },
>> + { "cpu reset", UVC_CMD_CPU_RESET, sizeof(struct
>> uv_cb_nodata) },
>> + { "cpu initial reset", UVC_CMD_CPU_RESET_INITIAL,
>> sizeof(struct uv_cb_nodata) },
>> + { "conf clear reset", UVC_CMD_PERF_CONF_CLEAR_RESET,
>> sizeof(struct uv_cb_nodata) },
>> + { "cpu clear reset", UVC_CMD_CPU_RESET_CLEAR, sizeof(struct
>> uv_cb_nodata) },
>> + { "cpu set state", UVC_CMD_CPU_SET_STATE, sizeof(struct
>> uv_cb_cpu_set_state) },
>> + { "pin shared", UVC_CMD_PIN_PAGE_SHARED, sizeof(struct
>> uv_cb_cfs) },
>> + { "unpin shared", UVC_CMD_UNPIN_PAGE_SHARED, sizeof(struct
>> uv_cb_cts) },
>> + { NULL, 0, 0 },
>> +};
>> +
>> static void test_invalid(void)
>> {
>> - struct uv_cb_header uvcb = {
>> - .len = 16,
>> - .cmd = 0x4242,
>> - };
>> - int cc;
>> + struct uv_cb_header *hdr = (void *)page;
>> + int cc, i;
>>
>> - cc = uv_call(0, (u64)&uvcb);
>> - report(cc == 1 && uvcb.rc == UVC_RC_INV_CMD, "invalid
>> command");
>> + report_prefix_push("invalid");
>
> here you just blindly loop over all the commands, without checking
> their actual availability
>
>> + for (i = 0; invalid_cmds[i].name; i++) {
>
> maybe you can add another field for the availability bit (or even put
> them in the right order so the bit is the index) and here add something
> like
>
> if (uv_query_test_feature(i))
> continue;
>
> so you will be sure the command is not available
>
>> + hdr->cmd = invalid_cmds[i].cmd;
>> + hdr->len = invalid_cmds[i].len;
>> + cc = uv_call(0, (u64)hdr);
>> + report(cc == 1 && hdr->rc == UVC_RC_INV_CMD, "%s",
>> + invalid_cmds[i].name);
>> + }
>> + report_prefix_pop();
>> }
>>
>> int main(void)
>
next prev parent reply other threads:[~2021-04-26 13:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 9:16 [kvm-unit-tests PATCH 0/6] s390x: uv: Extend guest test and add host test Janosch Frank
2021-03-16 9:16 ` [kvm-unit-tests PATCH 1/6] s390x: uv-guest: Add invalid share location test Janosch Frank
2021-04-19 11:24 ` Thomas Huth
2021-04-19 11:45 ` Janosch Frank
2021-04-20 8:48 ` Thomas Huth
2021-04-20 13:40 ` Claudio Imbrenda
2021-04-21 11:04 ` Cornelia Huck
2021-03-16 9:16 ` [kvm-unit-tests PATCH 2/6] s390x: Add more Ultravisor command structure definitions Janosch Frank
2021-04-20 14:09 ` Claudio Imbrenda
2021-04-21 11:13 ` Cornelia Huck
2021-04-26 14:33 ` Janosch Frank
2021-03-16 9:16 ` [kvm-unit-tests PATCH 3/6] s390x: uv: Add UV lib Janosch Frank
2021-04-20 14:15 ` Claudio Imbrenda
2021-04-26 14:20 ` Janosch Frank
2021-03-16 9:16 ` [kvm-unit-tests PATCH 4/6] s390x: Test for share/unshare call support before using them Janosch Frank
2021-04-20 14:18 ` Claudio Imbrenda
2021-03-16 9:16 ` [kvm-unit-tests PATCH 5/6] s390x: uv-guest: Test invalid commands Janosch Frank
2021-04-20 14:26 ` Claudio Imbrenda
2021-04-26 13:40 ` Janosch Frank [this message]
2021-03-16 9:16 ` [kvm-unit-tests PATCH 6/6] s390x: Add UV host test Janosch Frank
2021-04-20 15:47 ` Claudio Imbrenda
2021-04-26 14:31 ` Janosch Frank
2021-04-19 7:24 ` [kvm-unit-tests PATCH 0/6] s390x: uv: Extend guest test and add " 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=6a059cd0-cc31-7430-b62d-529fd72f1c9b@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=david@redhat.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