All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Janosch Frank <frankja@linux.ibm.com>
Cc: kvm@vger.kernel.org, david@redhat.com, cohuck@redhat.com,
	linux-s390@vger.kernel.org, thuth@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2 5/6] s390x: uv-guest: Test invalid commands
Date: Tue, 11 May 2021 19:12:03 +0200	[thread overview]
Message-ID: <20210511191203.79a08cbf@ibm-vm> (raw)
In-Reply-To: <20210510135148.1904-6-frankja@linux.ibm.com>

On Mon, 10 May 2021 13:51:47 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> Let's check if the UV calls that should not be available in a
> protected guest 2 are actually not available. Also let's check if they
> are falsely indicated to be available.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

but see below for a nit

> ---
>  s390x/uv-guest.c | 46 +++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 39 insertions(+), 7 deletions(-)
> 
> diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c
> index e99029a7..ce2ef79b 100644
> --- a/s390x/uv-guest.c
> +++ b/s390x/uv-guest.c
> @@ -121,16 +121,48 @@ static void test_sharing(void)
>  	report_prefix_pop();
>  }
>  
> +static struct {
> +	const char *name;
> +	uint16_t cmd;
> +	uint16_t len;
> +	int call_bit;
> +} invalid_cmds[] = {
> +	{ "bogus", 0x4242, sizeof(struct uv_cb_header), -1 },
> +	{ "init", UVC_CMD_INIT_UV, sizeof(struct uv_cb_init),
> BIT_UVC_CMD_INIT_UV },
> +	{ "create conf", UVC_CMD_CREATE_SEC_CONF, sizeof(struct
> uv_cb_cgc), BIT_UVC_CMD_CREATE_SEC_CONF },
> +	{ "destroy conf", UVC_CMD_DESTROY_SEC_CONF, sizeof(struct
> uv_cb_nodata), BIT_UVC_CMD_DESTROY_SEC_CONF },
> +	{ "create cpu", UVC_CMD_CREATE_SEC_CPU, sizeof(struct
> uv_cb_csc), BIT_UVC_CMD_CREATE_SEC_CPU },
> +	{ "destroy cpu", UVC_CMD_DESTROY_SEC_CPU, sizeof(struct
> uv_cb_nodata), BIT_UVC_CMD_DESTROY_SEC_CPU },
> +	{ "conv to", UVC_CMD_CONV_TO_SEC_STOR, sizeof(struct
> uv_cb_cts), BIT_UVC_CMD_CONV_TO_SEC_STOR },
> +	{ "conv from", UVC_CMD_CONV_FROM_SEC_STOR, sizeof(struct
> uv_cb_cfs), BIT_UVC_CMD_CONV_FROM_SEC_STOR },
> +	{ "set sec conf", UVC_CMD_SET_SEC_CONF_PARAMS, sizeof(struct
> uv_cb_ssc), BIT_UVC_CMD_SET_SEC_PARMS },
> +	{ "unpack", UVC_CMD_UNPACK_IMG, sizeof(struct uv_cb_unp),
> BIT_UVC_CMD_UNPACK_IMG },
> +	{ "verify", UVC_CMD_VERIFY_IMG, sizeof(struct uv_cb_nodata),
> BIT_UVC_CMD_VERIFY_IMG },
> +	{ "cpu reset", UVC_CMD_CPU_RESET, sizeof(struct
> uv_cb_nodata), BIT_UVC_CMD_CPU_RESET },
> +	{ "cpu initial reset", UVC_CMD_CPU_RESET_INITIAL,
> sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_RESET_INITIAL },
> +	{ "conf clear reset", UVC_CMD_PERF_CONF_CLEAR_RESET,
> sizeof(struct uv_cb_nodata), BIT_UVC_CMD_PREPARE_CLEAR_RESET },
> +	{ "cpu clear reset", UVC_CMD_CPU_RESET_CLEAR, sizeof(struct
> uv_cb_nodata), BIT_UVC_CMD_CPU_PERFORM_CLEAR_RESET },
> +	{ "cpu set state", UVC_CMD_CPU_SET_STATE, sizeof(struct
> uv_cb_cpu_set_state), BIT_UVC_CMD_CPU_SET_STATE },
> +	{ "pin shared", UVC_CMD_PIN_PAGE_SHARED, sizeof(struct
> uv_cb_cfs), BIT_UVC_CMD_PIN_PAGE_SHARED },
> +	{ "unpin shared", UVC_CMD_UNPIN_PAGE_SHARED, sizeof(struct
> uv_cb_cts), BIT_UVC_CMD_UNPIN_PAGE_SHARED },
> +	{ 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");
> +	for (i = 0; invalid_cmds[i].name; i++) {
> +		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 &&
> +		       invalid_cmds[i].call_bit == -1 ? true :
> !uv_query_test_call(invalid_cmds[i].call_bit),

maybe this is more readable:

(invalid_cmds[i].call_bit == -1 ||
 !uv_query_test_call(invalid_cmds[i].call_bit))

> +		       "%s", invalid_cmds[i].name);
> +	}
> +	report_prefix_pop();
>  }
>  
>  int main(void)


  parent reply	other threads:[~2021-05-11 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 13:51 [kvm-unit-tests PATCH v2 0/6] s390x: uv: Extend guest test and add host test Janosch Frank
2021-05-10 13:51 ` [kvm-unit-tests PATCH v2 1/6] s390x: uv-guest: Add invalid share location test Janosch Frank
2021-05-10 13:51 ` [kvm-unit-tests PATCH v2 2/6] s390x: Add more Ultravisor command structure definitions Janosch Frank
2021-05-11 16:02   ` Cornelia Huck
2021-05-10 13:51 ` [kvm-unit-tests PATCH v2 3/6] s390x: uv: Add UV lib Janosch Frank
2021-05-11 16:13   ` Cornelia Huck
2021-05-18 13:10     ` Janosch Frank
2021-05-10 13:51 ` [kvm-unit-tests PATCH v2 4/6] s390x: Test for share/unshare call support before using them Janosch Frank
2021-05-11 16:15   ` Cornelia Huck
2021-05-10 13:51 ` [kvm-unit-tests PATCH v2 5/6] s390x: uv-guest: Test invalid commands Janosch Frank
2021-05-11 16:22   ` Cornelia Huck
2021-05-11 17:12   ` Claudio Imbrenda [this message]
2021-05-10 13:51 ` [kvm-unit-tests PATCH v2 6/6] s390x: Add UV host test Janosch Frank
2021-05-11 16:25   ` Cornelia Huck

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=20210511191203.79a08cbf@ibm-vm \
    --to=imbrenda@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.