diff mbox series

[kvm-unit-tests,1/4] s390x: uv-host: Add attestation test

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

Commit Message

Steffen Eiden Jan. 27, 2022, 2:15 p.m. UTC
Adds an invalid command test for attestation in the uv-host.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
 lib/s390x/asm/uv.h | 24 +++++++++++++++++++++++-
 s390x/uv-host.c    |  3 ++-
 2 files changed, 25 insertions(+), 2 deletions(-)

Comments

Janosch Frank Jan. 28, 2022, 9 a.m. UTC | #1
On 1/27/22 15:15, Steffen Eiden wrote:
> Adds an invalid command test for attestation in the uv-host.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>

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

> ---
>   lib/s390x/asm/uv.h | 24 +++++++++++++++++++++++-
>   s390x/uv-host.c    |  3 ++-
>   2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
> index 97c90e81..38c322bf 100644
> --- a/lib/s390x/asm/uv.h
> +++ b/lib/s390x/asm/uv.h
> @@ -1,10 +1,11 @@
>   /*
>    * s390x Ultravisor related definitions
>    *
> - * Copyright (c) 2020 IBM Corp
> + * Copyright (c) 2020, 2022 IBM Corp

I'm not sure when we actually need/want to update this.

>    *
>    * Authors:
>    *  Janosch Frank <frankja@linux.ibm.com>
> + *  Steffen Eiden <seiden@linux.ibm.com>

I usually add myself to this list once I made significant contributions 
to the file (or if I create the file). If you have a look at the 
kernel's kvm-s390.c you'll see that I'm not yet on the list of its authors.

But, as visible in other discussions we're currently having, I'm not 
aware of a definite guideline for this. Looks like we should find an 
agreement within IBM and write it down.

>    *
>    * This code is free software; you can redistribute it and/or modify it
>    * under the terms of the GNU General Public License version 2.
> @@ -47,6 +48,7 @@
>   #define UVC_CMD_UNPIN_PAGE_SHARED	0x0342
>   #define UVC_CMD_SET_SHARED_ACCESS	0x1000
>   #define UVC_CMD_REMOVE_SHARED_ACCESS	0x1001
> +#define UVC_CMD_ATTESTATION		0x1020
>   
>   /* Bits in installed uv calls */
>   enum uv_cmds_inst {
> @@ -71,6 +73,7 @@ enum uv_cmds_inst {
>   	BIT_UVC_CMD_UNSHARE_ALL = 20,
>   	BIT_UVC_CMD_PIN_PAGE_SHARED = 21,
>   	BIT_UVC_CMD_UNPIN_PAGE_SHARED = 22,
> +	BIT_UVC_CMD_ATTESTATION = 28,
>   };
>   
>   struct uv_cb_header {
> @@ -178,6 +181,25 @@ struct uv_cb_cfs {
>   	u64 paddr;
>   }  __attribute__((packed))  __attribute__((aligned(8)));
>   
> +/* Retrieve Attestation Measurement */
> +struct uv_cb_attest {
> +	struct uv_cb_header header;	/* 0x0000 */
> +	u64 reserved08[2];		/* 0x0008 */
> +	u64 arcb_addr;			/* 0x0018 */
> +	u64 continuation_token;		/* 0x0020 */
> +	u8  reserved28[6];		/* 0x0028 */
> +	u16 user_data_length;		/* 0x002e */
> +	u8  user_data[256];		/* 0x0030 */
> +	u32 reserved130[3];		/* 0x0130 */
> +	u32 measurement_length;		/* 0x013c */
> +	u64 measurement_address;	/* 0x0140 */
> +	u8 config_uid[16];		/* 0x0148 */
> +	u32 reserved158;		/* 0x0158 */
> +	u32 add_data_length;		/* 0x015c */
> +	u64 add_data_address;		/* 0x0160 */
> +	u64 reserved168[4];		/* 0x0168 */
> +}  __attribute__((packed))  __attribute__((aligned(8)));
> +
>   /* Set Secure Config Parameter */
>   struct uv_cb_ssc {
>   	struct uv_cb_header header;
> diff --git a/s390x/uv-host.c b/s390x/uv-host.c
> index 92a41069..0f8ab94a 100644
> --- a/s390x/uv-host.c
> +++ b/s390x/uv-host.c
> @@ -2,7 +2,7 @@
>   /*
>    * Guest Ultravisor Call tests
>    *
> - * Copyright (c) 2021 IBM Corp
> + * Copyright (c) 2021, 2022 IBM Corp
>    *
>    * Authors:
>    *  Janosch Frank <frankja@linux.ibm.com>
> @@ -418,6 +418,7 @@ static struct cmd_list invalid_cmds[] = {
>   	{ "bogus", 0x4242, sizeof(struct uv_cb_header), -1},
>   	{ "share", UVC_CMD_SET_SHARED_ACCESS, sizeof(struct uv_cb_share), BIT_UVC_CMD_SET_SHARED_ACCESS },
>   	{ "unshare", UVC_CMD_REMOVE_SHARED_ACCESS, sizeof(struct uv_cb_share), BIT_UVC_CMD_REMOVE_SHARED_ACCESS },
> +	{ "attest", UVC_CMD_ATTESTATION, sizeof(struct uv_cb_attest), BIT_UVC_CMD_ATTESTATION },
>   	{ NULL, 0, 0 },
>   };
>   
>
Thomas Huth Jan. 28, 2022, 9:29 a.m. UTC | #2
On 28/01/2022 10.00, Janosch Frank wrote:
> On 1/27/22 15:15, Steffen Eiden wrote:
>> Adds an invalid command test for attestation in the uv-host.
>>
>> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> 
> Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
> 
>> ---
>>   lib/s390x/asm/uv.h | 24 +++++++++++++++++++++++-
>>   s390x/uv-host.c    |  3 ++-
>>   2 files changed, 25 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
>> index 97c90e81..38c322bf 100644
>> --- a/lib/s390x/asm/uv.h
>> +++ b/lib/s390x/asm/uv.h
>> @@ -1,10 +1,11 @@
>>   /*
>>    * s390x Ultravisor related definitions
>>    *
>> - * Copyright (c) 2020 IBM Corp
>> + * Copyright (c) 2020, 2022 IBM Corp
> 
> I'm not sure when we actually need/want to update this.

IANAL, but IIRC you can add/update the second year in the copyright 
statement if there has been a major change to the file in that year, so that 
should be fine. Not sure whether you still need the "(c)" these days, though.

  Thomas
Claudio Imbrenda Jan. 28, 2022, 9:58 a.m. UTC | #3
On Fri, 28 Jan 2022 10:29:42 +0100
Thomas Huth <thuth@redhat.com> wrote:

> On 28/01/2022 10.00, Janosch Frank wrote:
> > On 1/27/22 15:15, Steffen Eiden wrote:  
> >> Adds an invalid command test for attestation in the uv-host.
> >>
> >> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>  
> > 
> > Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
> >   
> >> ---
> >>   lib/s390x/asm/uv.h | 24 +++++++++++++++++++++++-
> >>   s390x/uv-host.c    |  3 ++-
> >>   2 files changed, 25 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
> >> index 97c90e81..38c322bf 100644
> >> --- a/lib/s390x/asm/uv.h
> >> +++ b/lib/s390x/asm/uv.h
> >> @@ -1,10 +1,11 @@
> >>   /*
> >>    * s390x Ultravisor related definitions
> >>    *
> >> - * Copyright (c) 2020 IBM Corp
> >> + * Copyright (c) 2020, 2022 IBM Corp  
> > 
> > I'm not sure when we actually need/want to update this.  
> 
> IANAL, but IIRC you can add/update the second year in the copyright 
> statement if there has been a major change to the file in that year, so that 
> should be fine. Not sure whether you still need the "(c)" these days, though.
> 
>   Thomas
> 

I think the format IBM wants is:

Copyright IBM Corp. 2020, 2022
diff mbox series

Patch

diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
index 97c90e81..38c322bf 100644
--- a/lib/s390x/asm/uv.h
+++ b/lib/s390x/asm/uv.h
@@ -1,10 +1,11 @@ 
 /*
  * s390x Ultravisor related definitions
  *
- * Copyright (c) 2020 IBM Corp
+ * Copyright (c) 2020, 2022 IBM Corp
  *
  * Authors:
  *  Janosch Frank <frankja@linux.ibm.com>
+ *  Steffen Eiden <seiden@linux.ibm.com>
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2.
@@ -47,6 +48,7 @@ 
 #define UVC_CMD_UNPIN_PAGE_SHARED	0x0342
 #define UVC_CMD_SET_SHARED_ACCESS	0x1000
 #define UVC_CMD_REMOVE_SHARED_ACCESS	0x1001
+#define UVC_CMD_ATTESTATION		0x1020
 
 /* Bits in installed uv calls */
 enum uv_cmds_inst {
@@ -71,6 +73,7 @@  enum uv_cmds_inst {
 	BIT_UVC_CMD_UNSHARE_ALL = 20,
 	BIT_UVC_CMD_PIN_PAGE_SHARED = 21,
 	BIT_UVC_CMD_UNPIN_PAGE_SHARED = 22,
+	BIT_UVC_CMD_ATTESTATION = 28,
 };
 
 struct uv_cb_header {
@@ -178,6 +181,25 @@  struct uv_cb_cfs {
 	u64 paddr;
 }  __attribute__((packed))  __attribute__((aligned(8)));
 
+/* Retrieve Attestation Measurement */
+struct uv_cb_attest {
+	struct uv_cb_header header;	/* 0x0000 */
+	u64 reserved08[2];		/* 0x0008 */
+	u64 arcb_addr;			/* 0x0018 */
+	u64 continuation_token;		/* 0x0020 */
+	u8  reserved28[6];		/* 0x0028 */
+	u16 user_data_length;		/* 0x002e */
+	u8  user_data[256];		/* 0x0030 */
+	u32 reserved130[3];		/* 0x0130 */
+	u32 measurement_length;		/* 0x013c */
+	u64 measurement_address;	/* 0x0140 */
+	u8 config_uid[16];		/* 0x0148 */
+	u32 reserved158;		/* 0x0158 */
+	u32 add_data_length;		/* 0x015c */
+	u64 add_data_address;		/* 0x0160 */
+	u64 reserved168[4];		/* 0x0168 */
+}  __attribute__((packed))  __attribute__((aligned(8)));
+
 /* Set Secure Config Parameter */
 struct uv_cb_ssc {
 	struct uv_cb_header header;
diff --git a/s390x/uv-host.c b/s390x/uv-host.c
index 92a41069..0f8ab94a 100644
--- a/s390x/uv-host.c
+++ b/s390x/uv-host.c
@@ -2,7 +2,7 @@ 
 /*
  * Guest Ultravisor Call tests
  *
- * Copyright (c) 2021 IBM Corp
+ * Copyright (c) 2021, 2022 IBM Corp
  *
  * Authors:
  *  Janosch Frank <frankja@linux.ibm.com>
@@ -418,6 +418,7 @@  static struct cmd_list invalid_cmds[] = {
 	{ "bogus", 0x4242, sizeof(struct uv_cb_header), -1},
 	{ "share", UVC_CMD_SET_SHARED_ACCESS, sizeof(struct uv_cb_share), BIT_UVC_CMD_SET_SHARED_ACCESS },
 	{ "unshare", UVC_CMD_REMOVE_SHARED_ACCESS, sizeof(struct uv_cb_share), BIT_UVC_CMD_REMOVE_SHARED_ACCESS },
+	{ "attest", UVC_CMD_ATTESTATION, sizeof(struct uv_cb_attest), BIT_UVC_CMD_ATTESTATION },
 	{ NULL, 0, 0 },
 };