From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com,
linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
thuth@redhat.com
Subject: [kvm-unit-tests PATCH v2 5/6] s390x: uv-guest: Test invalid commands
Date: Mon, 10 May 2021 13:51:47 +0000 [thread overview]
Message-ID: <20210510135148.1904-6-frankja@linux.ibm.com> (raw)
In-Reply-To: <20210510135148.1904-1-frankja@linux.ibm.com>
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>
---
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),
+ "%s", invalid_cmds[i].name);
+ }
+ report_prefix_pop();
}
int main(void)
--
2.30.2
next prev parent reply other threads:[~2021-05-10 13:56 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 ` Janosch Frank [this message]
2021-05-11 16:22 ` [kvm-unit-tests PATCH v2 5/6] s390x: uv-guest: Test invalid commands Cornelia Huck
2021-05-11 17:12 ` Claudio Imbrenda
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=20210510135148.1904-6-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=cohuck@redhat.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;
as well as URLs for NNTP newsgroup(s).