From: Janosch Frank <frankja@linux.ibm.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com,
borntraeger@de.ibm.com, cohuck@redhat.com,
linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
thuth@redhat.com
Subject: [kvm-unit-tests GIT PULL 5/9] s390x: uv-guest: Test invalid commands
Date: Wed, 26 May 2021 16:55:35 +0200 [thread overview]
Message-ID: <20210526145539.52008-6-frankja@linux.ibm.com> (raw)
In-Reply-To: <20210526145539.52008-1-frankja@linux.ibm.com>
Lets check if the UV calls that should not be available in a
protected guest 2 are actually not available. Also lets check if they
are falsely indicated to be available.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: Thomas Huth <thuth@redhat.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..f05ae4c3 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 || !uv_query_test_call(invalid_cmds[i].call_bit)),
+ "%s", invalid_cmds[i].name);
+ }
+ report_prefix_pop();
}
int main(void)
--
2.31.1
next prev parent reply other threads:[~2021-05-26 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 14:55 [kvm-unit-tests GIT PULL 0/9] s390x update 2021-26-05 Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 1/9] s390x: uv-guest: Add invalid share location test Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 2/9] s390x: Add more Ultravisor command structure definitions Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 3/9] s390x: uv: Add UV lib Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 4/9] s390x: Test for share/unshare call support before using them Janosch Frank
2021-05-26 14:55 ` Janosch Frank [this message]
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 6/9] s390x: Add UV host test Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 7/9] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 8/9] lib: s390x: sclp: Extend feature probing Janosch Frank
2021-05-26 14:55 ` [kvm-unit-tests GIT PULL 9/9] s390x: cpumodel: FMT2 and FMT4 SCLP test Janosch Frank
2021-05-26 16:33 ` [kvm-unit-tests GIT PULL 0/9] s390x update 2021-26-05 Paolo Bonzini
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=20210526145539.52008-6-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@de.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=pbonzini@redhat.com \
--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).