diff mbox series

[kvm-unit-tests,v3,4/5] s390x: uv-guest: add share bit test

Message ID 20220222145456.9956-5-seiden@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: Attestation tests | expand

Commit Message

Steffen Eiden Feb. 22, 2022, 2:54 p.m. UTC
The UV facility bits shared/unshared must both be set or none.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
 s390x/uv-guest.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Claudio Imbrenda Feb. 23, 2022, 3:36 p.m. UTC | #1
On Tue, 22 Feb 2022 14:54:55 +0000
Steffen Eiden <seiden@linux.ibm.com> wrote:

> The UV facility bits shared/unshared must both be set or none.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>

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

> ---
>  s390x/uv-guest.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c
> index 728c60aa..77057bd2 100644
> --- a/s390x/uv-guest.c
> +++ b/s390x/uv-guest.c
> @@ -159,6 +159,14 @@ static void test_invalid(void)
>  	report_prefix_pop();
>  }
>  
> +static void test_share_bits(void)
> +{
> +	bool unshare = uv_query_test_call(BIT_UVC_CMD_REMOVE_SHARED_ACCESS);
> +	bool share = uv_query_test_call(BIT_UVC_CMD_SET_SHARED_ACCESS);
> +
> +	report(!(share ^ unshare), "share bits");
> +}
> +
>  int main(void)
>  {
>  	bool has_uvc = test_facility(158);
> @@ -169,6 +177,12 @@ int main(void)
>  		goto done;
>  	}
>  
> +	/*
> +	 * Needs to be done before the guest-fence,
> +	 * as the fence tests if both shared bits are present
> +	 */
> +	test_share_bits();
> +
>  	if (!uv_os_is_guest()) {
>  		report_skip("Not a protected guest");
>  		goto done;
Janosch Frank March 23, 2022, 8:16 a.m. UTC | #2
On 2/22/22 15:54, Steffen Eiden wrote:
> The UV facility bits shared/unshared must both be set or none.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>

> ---
>   s390x/uv-guest.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c
> index 728c60aa..77057bd2 100644
> --- a/s390x/uv-guest.c
> +++ b/s390x/uv-guest.c
> @@ -159,6 +159,14 @@ static void test_invalid(void)
>   	report_prefix_pop();
>   }
>   
> +static void test_share_bits(void)
> +{
> +	bool unshare = uv_query_test_call(BIT_UVC_CMD_REMOVE_SHARED_ACCESS);
> +	bool share = uv_query_test_call(BIT_UVC_CMD_SET_SHARED_ACCESS);
> +
> +	report(!(share ^ unshare), "share bits");
> +}
> +
>   int main(void)
>   {
>   	bool has_uvc = test_facility(158);
> @@ -169,6 +177,12 @@ int main(void)
>   		goto done;
>   	}
>   
> +	/*
> +	 * Needs to be done before the guest-fence,
> +	 * as the fence tests if both shared bits are present
> +	 */
> +	test_share_bits();
> +
>   	if (!uv_os_is_guest()) {
>   		report_skip("Not a protected guest");
>   		goto done;
diff mbox series

Patch

diff --git a/s390x/uv-guest.c b/s390x/uv-guest.c
index 728c60aa..77057bd2 100644
--- a/s390x/uv-guest.c
+++ b/s390x/uv-guest.c
@@ -159,6 +159,14 @@  static void test_invalid(void)
 	report_prefix_pop();
 }
 
+static void test_share_bits(void)
+{
+	bool unshare = uv_query_test_call(BIT_UVC_CMD_REMOVE_SHARED_ACCESS);
+	bool share = uv_query_test_call(BIT_UVC_CMD_SET_SHARED_ACCESS);
+
+	report(!(share ^ unshare), "share bits");
+}
+
 int main(void)
 {
 	bool has_uvc = test_facility(158);
@@ -169,6 +177,12 @@  int main(void)
 		goto done;
 	}
 
+	/*
+	 * Needs to be done before the guest-fence,
+	 * as the fence tests if both shared bits are present
+	 */
+	test_share_bits();
+
 	if (!uv_os_is_guest()) {
 		report_skip("Not a protected guest");
 		goto done;