diff mbox series

[5/5] s390/uv: Update query for secret-UVCs

Message ID 20230512093153.206378-6-seiden@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390/uvdevice: Expose secret UVCs | expand

Commit Message

Steffen Eiden May 12, 2023, 9:31 a.m. UTC
Update the query struct such that secret-UVC related
information can be parsed.
Add sysfs files for these new values.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
 arch/s390/boot/uv.c        |  4 ++++
 arch/s390/include/asm/uv.h | 11 ++++++++++-
 arch/s390/kernel/uv.c      | 40 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)

Comments

Heiko Carstens May 12, 2023, 12:53 p.m. UTC | #1
On Fri, May 12, 2023 at 11:31:53AM +0200, Steffen Eiden wrote:
> Update the query struct such that secret-UVC related
> information can be parsed.
> Add sysfs files for these new values.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
>  arch/s390/boot/uv.c        |  4 ++++
>  arch/s390/include/asm/uv.h | 11 ++++++++++-
>  arch/s390/kernel/uv.c      | 40 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 54 insertions(+), 1 deletion(-)
...
> +static ssize_t uv_query_supp_add_secret_req_ver(struct kobject *kobj,
> +						struct kobj_attribute *attr, char *page)
> +{
> +	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_req_ver);
> +}

FWIW, another minor thing: all of these should be sysfs_emit() instead.
Janosch Frank May 12, 2023, 1:27 p.m. UTC | #2
On 5/12/23 14:53, Heiko Carstens wrote:
> On Fri, May 12, 2023 at 11:31:53AM +0200, Steffen Eiden wrote:
>> Update the query struct such that secret-UVC related
>> information can be parsed.
>> Add sysfs files for these new values.
>>
>> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
>> ---
>>   arch/s390/boot/uv.c        |  4 ++++
>>   arch/s390/include/asm/uv.h | 11 ++++++++++-
>>   arch/s390/kernel/uv.c      | 40 ++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 54 insertions(+), 1 deletion(-)
> ...
>> +static ssize_t uv_query_supp_add_secret_req_ver(struct kobject *kobj,
>> +						struct kobj_attribute *attr, char *page)
>> +{
>> +	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_req_ver);
>> +}
> 
> FWIW, another minor thing: all of these should be sysfs_emit() instead.

Do you want us to move all of them to sysfs_emit() eventually or should 
we keep the scnprintfs() which are already in uv.c ?
Heiko Carstens May 12, 2023, 3:34 p.m. UTC | #3
On Fri, May 12, 2023 at 03:27:52PM +0200, Janosch Frank wrote:
> On 5/12/23 14:53, Heiko Carstens wrote:
> > On Fri, May 12, 2023 at 11:31:53AM +0200, Steffen Eiden wrote:
> > > Update the query struct such that secret-UVC related
> > > information can be parsed.
> > > Add sysfs files for these new values.
> > > 
> > > Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> > > ---
> > >   arch/s390/boot/uv.c        |  4 ++++
> > >   arch/s390/include/asm/uv.h | 11 ++++++++++-
> > >   arch/s390/kernel/uv.c      | 40 ++++++++++++++++++++++++++++++++++++++
> > >   3 files changed, 54 insertions(+), 1 deletion(-)
> > ...
> > > +static ssize_t uv_query_supp_add_secret_req_ver(struct kobject *kobj,
> > > +						struct kobj_attribute *attr, char *page)
> > > +{
> > > +	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_req_ver);
> > > +}
> > 
> > FWIW, another minor thing: all of these should be sysfs_emit() instead.
> 
> Do you want us to move all of them to sysfs_emit() eventually or should we
> keep the scnprintfs() which are already in uv.c ?

I'd convert the existing ones as well.
Claudio Imbrenda May 17, 2023, 3:54 p.m. UTC | #4
On Fri, 12 May 2023 11:31:53 +0200
Steffen Eiden <seiden@linux.ibm.com> wrote:

> Update the query struct such that secret-UVC related
> information can be parsed.
> Add sysfs files for these new values.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
>  arch/s390/boot/uv.c        |  4 ++++
>  arch/s390/include/asm/uv.h | 11 ++++++++++-
>  arch/s390/kernel/uv.c      | 40 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/boot/uv.c b/arch/s390/boot/uv.c
> index 0a077c0a2056..323b5cae3cf1 100644
> --- a/arch/s390/boot/uv.c
> +++ b/arch/s390/boot/uv.c
> @@ -47,6 +47,10 @@ void uv_query_info(void)
>  		uv_info.conf_dump_finalize_len = uvcb.conf_dump_finalize_len;
>  		uv_info.supp_att_req_hdr_ver = uvcb.supp_att_req_hdr_ver;
>  		uv_info.supp_att_pflags = uvcb.supp_att_pflags;
> +		uv_info.supp_add_secret_req_ver = uvcb.supp_add_secret_req_ver;
> +		uv_info.supp_add_secret_pcf = uvcb.supp_add_secret_pcf;
> +		uv_info.supp_secret_types = uvcb.supp_secret_types;
> +		uv_info.max_secrets = uvcb.max_num_secrets;
>  	}
>  
>  #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
> diff --git a/arch/s390/include/asm/uv.h b/arch/s390/include/asm/uv.h
> index 6180ac8909d5..eb2e11d8123f 100644
> --- a/arch/s390/include/asm/uv.h
> +++ b/arch/s390/include/asm/uv.h
> @@ -135,7 +135,12 @@ struct uv_cb_qui {
>  	u64 reservedd8;				/* 0x00d8 */
>  	u64 supp_att_req_hdr_ver;		/* 0x00e0 */
>  	u64 supp_att_pflags;			/* 0x00e8 */
> -	u8 reservedf0[256 - 240];		/* 0x00f0 */
> +	u64 reservedf0;				/* 0x00f0 */
> +	u64 supp_add_secret_req_ver;		/* 0x00f8 */
> +	u64 supp_add_secret_pcf;		/* 0x0100 */
> +	u64 supp_secret_types;			/* 0x0180 */
> +	u16 max_num_secrets;			/* 0x0110 */
> +	u8 reserved112[288 - 274];		/* 0x0112 */

I think it would be more readable and maintainable if you put the
offsets in hex (i.e. reserved112[0x120 - 0x112])

otherwise, something like this:

u16 max_num_secrets;
u16 reserved112[3]
u64 reserved118;

(I know it was not in hex before, it was not necessarily nice as it was)

>  } __packed __aligned(8);
>  
>  /* Initialize Ultravisor */
> @@ -384,6 +389,10 @@ struct uv_info {
>  	unsigned long conf_dump_finalize_len;
>  	unsigned long supp_att_req_hdr_ver;
>  	unsigned long supp_att_pflags;
> +	unsigned long supp_add_secret_req_ver;
> +	unsigned long supp_add_secret_pcf;
> +	unsigned long supp_secret_types;
> +	unsigned short max_secrets;
>  };
>  
>  extern struct uv_info uv_info;
> diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
> index 9f18a4af9c13..381444511bb7 100644
> --- a/arch/s390/kernel/uv.c
> +++ b/arch/s390/kernel/uv.c
> @@ -587,6 +587,42 @@ static ssize_t uv_query_supp_att_pflags(struct kobject *kobj,
>  static struct kobj_attribute uv_query_supp_att_pflags_attr =
>  	__ATTR(supp_att_pflags, 0444, uv_query_supp_att_pflags, NULL);
>  
> +static ssize_t uv_query_supp_add_secret_req_ver(struct kobject *kobj,
> +						struct kobj_attribute *attr, char *page)
> +{
> +	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_req_ver);
> +}
> +
> +static struct kobj_attribute uv_query_supp_add_secret_req_ver_attr =
> +	__ATTR(supp_add_secret_req_ver, 0444, uv_query_supp_add_secret_req_ver, NULL);
> +
> +static ssize_t uv_query_supp_add_secret_pcf(struct kobject *kobj,
> +					    struct kobj_attribute *attr, char *page)
> +{
> +	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_pcf);
> +}
> +
> +static struct kobj_attribute uv_query_supp_add_secret_pcf_attr =
> +	__ATTR(supp_add_secret_pcf, 0444, uv_query_supp_add_secret_pcf, NULL);
> +
> +static ssize_t uv_query_supp_secret_types(struct kobject *kobj,
> +					  struct kobj_attribute *attr, char *page)
> +{
> +	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_secret_types);
> +}
> +
> +static struct kobj_attribute uv_query_supp_secret_types_attr =
> +	__ATTR(supp_secret_types, 0444, uv_query_supp_secret_types, NULL);
> +
> +static ssize_t uv_query_max_secrets(struct kobject *kobj,
> +				    struct kobj_attribute *attr, char *page)
> +{
> +	return scnprintf(page, PAGE_SIZE, "%d\n", uv_info.max_secrets);
> +}
> +
> +static struct kobj_attribute uv_query_max_num_secrets_attr =
> +	__ATTR(max_secrets, 0444, uv_query_max_secrets, NULL);
> +
>  static struct attribute *uv_query_attrs[] = {
>  	&uv_query_facilities_attr.attr,
>  	&uv_query_feature_indications_attr.attr,
> @@ -600,6 +636,10 @@ static struct attribute *uv_query_attrs[] = {
>  	&uv_query_dump_cpu_len_attr.attr,
>  	&uv_query_supp_att_req_hdr_ver_attr.attr,
>  	&uv_query_supp_att_pflags_attr.attr,
> +	&uv_query_supp_add_secret_req_ver_attr.attr,
> +	&uv_query_supp_add_secret_pcf_attr.attr,
> +	&uv_query_supp_secret_types_attr.attr,
> +	&uv_query_max_num_secrets_attr.attr,
>  	NULL,
>  };
>
diff mbox series

Patch

diff --git a/arch/s390/boot/uv.c b/arch/s390/boot/uv.c
index 0a077c0a2056..323b5cae3cf1 100644
--- a/arch/s390/boot/uv.c
+++ b/arch/s390/boot/uv.c
@@ -47,6 +47,10 @@  void uv_query_info(void)
 		uv_info.conf_dump_finalize_len = uvcb.conf_dump_finalize_len;
 		uv_info.supp_att_req_hdr_ver = uvcb.supp_att_req_hdr_ver;
 		uv_info.supp_att_pflags = uvcb.supp_att_pflags;
+		uv_info.supp_add_secret_req_ver = uvcb.supp_add_secret_req_ver;
+		uv_info.supp_add_secret_pcf = uvcb.supp_add_secret_pcf;
+		uv_info.supp_secret_types = uvcb.supp_secret_types;
+		uv_info.max_secrets = uvcb.max_num_secrets;
 	}
 
 #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
diff --git a/arch/s390/include/asm/uv.h b/arch/s390/include/asm/uv.h
index 6180ac8909d5..eb2e11d8123f 100644
--- a/arch/s390/include/asm/uv.h
+++ b/arch/s390/include/asm/uv.h
@@ -135,7 +135,12 @@  struct uv_cb_qui {
 	u64 reservedd8;				/* 0x00d8 */
 	u64 supp_att_req_hdr_ver;		/* 0x00e0 */
 	u64 supp_att_pflags;			/* 0x00e8 */
-	u8 reservedf0[256 - 240];		/* 0x00f0 */
+	u64 reservedf0;				/* 0x00f0 */
+	u64 supp_add_secret_req_ver;		/* 0x00f8 */
+	u64 supp_add_secret_pcf;		/* 0x0100 */
+	u64 supp_secret_types;			/* 0x0180 */
+	u16 max_num_secrets;			/* 0x0110 */
+	u8 reserved112[288 - 274];		/* 0x0112 */
 } __packed __aligned(8);
 
 /* Initialize Ultravisor */
@@ -384,6 +389,10 @@  struct uv_info {
 	unsigned long conf_dump_finalize_len;
 	unsigned long supp_att_req_hdr_ver;
 	unsigned long supp_att_pflags;
+	unsigned long supp_add_secret_req_ver;
+	unsigned long supp_add_secret_pcf;
+	unsigned long supp_secret_types;
+	unsigned short max_secrets;
 };
 
 extern struct uv_info uv_info;
diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
index 9f18a4af9c13..381444511bb7 100644
--- a/arch/s390/kernel/uv.c
+++ b/arch/s390/kernel/uv.c
@@ -587,6 +587,42 @@  static ssize_t uv_query_supp_att_pflags(struct kobject *kobj,
 static struct kobj_attribute uv_query_supp_att_pflags_attr =
 	__ATTR(supp_att_pflags, 0444, uv_query_supp_att_pflags, NULL);
 
+static ssize_t uv_query_supp_add_secret_req_ver(struct kobject *kobj,
+						struct kobj_attribute *attr, char *page)
+{
+	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_req_ver);
+}
+
+static struct kobj_attribute uv_query_supp_add_secret_req_ver_attr =
+	__ATTR(supp_add_secret_req_ver, 0444, uv_query_supp_add_secret_req_ver, NULL);
+
+static ssize_t uv_query_supp_add_secret_pcf(struct kobject *kobj,
+					    struct kobj_attribute *attr, char *page)
+{
+	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_add_secret_pcf);
+}
+
+static struct kobj_attribute uv_query_supp_add_secret_pcf_attr =
+	__ATTR(supp_add_secret_pcf, 0444, uv_query_supp_add_secret_pcf, NULL);
+
+static ssize_t uv_query_supp_secret_types(struct kobject *kobj,
+					  struct kobj_attribute *attr, char *page)
+{
+	return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_secret_types);
+}
+
+static struct kobj_attribute uv_query_supp_secret_types_attr =
+	__ATTR(supp_secret_types, 0444, uv_query_supp_secret_types, NULL);
+
+static ssize_t uv_query_max_secrets(struct kobject *kobj,
+				    struct kobj_attribute *attr, char *page)
+{
+	return scnprintf(page, PAGE_SIZE, "%d\n", uv_info.max_secrets);
+}
+
+static struct kobj_attribute uv_query_max_num_secrets_attr =
+	__ATTR(max_secrets, 0444, uv_query_max_secrets, NULL);
+
 static struct attribute *uv_query_attrs[] = {
 	&uv_query_facilities_attr.attr,
 	&uv_query_feature_indications_attr.attr,
@@ -600,6 +636,10 @@  static struct attribute *uv_query_attrs[] = {
 	&uv_query_dump_cpu_len_attr.attr,
 	&uv_query_supp_att_req_hdr_ver_attr.attr,
 	&uv_query_supp_att_pflags_attr.attr,
+	&uv_query_supp_add_secret_req_ver_attr.attr,
+	&uv_query_supp_add_secret_pcf_attr.attr,
+	&uv_query_supp_secret_types_attr.attr,
+	&uv_query_max_num_secrets_attr.attr,
 	NULL,
 };