From: Janosch Frank <frankja@linux.ibm.com>
To: Steffen Eiden <seiden@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org,
Viktor Mihajlovski <mihajlov@linux.ibm.com>
Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>,
Nico Boehr <nrb@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Hendrik Brueckner <brueckner@linux.ibm.com>
Subject: Re: [PATCH v2 5/6] s390/uv: replace scnprintf with sysfs_emit
Date: Mon, 5 Jun 2023 15:55:34 +0200 [thread overview]
Message-ID: <2fca9573-5989-d61e-52ec-552f4e176971@linux.ibm.com> (raw)
In-Reply-To: <20230519093708.810957-6-seiden@linux.ibm.com>
On 5/19/23 11:37, Steffen Eiden wrote:
> Replace scnprintf(page, PAGE_SIZE, ...) with the page size aware
> sysfs_emit(page, ...) which adds some sanity checks.
>
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
> arch/s390/kernel/uv.c | 36 +++++++++++++++---------------------
> 1 file changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
> index cb2ee06df286..d5b5d7e83c17 100644
> --- a/arch/s390/kernel/uv.c
> +++ b/arch/s390/kernel/uv.c
> @@ -462,11 +462,11 @@ EXPORT_SYMBOL_GPL(arch_make_page_accessible);
> static ssize_t uv_query_facilities(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
The last argument is called buf so let's also change that over to make
all of the functions look the same.
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n%lx\n%lx\n%lx\n",
> - uv_info.inst_calls_list[0],
> - uv_info.inst_calls_list[1],
> - uv_info.inst_calls_list[2],
> - uv_info.inst_calls_list[3]);
> + return sysfs_emit(page, "%lx\n%lx\n%lx\n%lx\n",
> + uv_info.inst_calls_list[0],
> + uv_info.inst_calls_list[1],
> + uv_info.inst_calls_list[2],
> + uv_info.inst_calls_list[3]);
> }
>
> static struct kobj_attribute uv_query_facilities_attr =
> @@ -493,8 +493,7 @@ static struct kobj_attribute uv_query_supp_se_hdr_pcf_attr =
> static ssize_t uv_query_dump_cpu_len(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n",
> - uv_info.guest_cpu_stor_len);
> + return sysfs_emit(page, "%lx\n", uv_info.guest_cpu_stor_len);
> }
>
> static struct kobj_attribute uv_query_dump_cpu_len_attr =
> @@ -503,8 +502,7 @@ static struct kobj_attribute uv_query_dump_cpu_len_attr =
> static ssize_t uv_query_dump_storage_state_len(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n",
> - uv_info.conf_dump_storage_state_len);
> + return sysfs_emit(page, "%lx\n", uv_info.conf_dump_storage_state_len);
> }
>
> static struct kobj_attribute uv_query_dump_storage_state_len_attr =
> @@ -513,8 +511,7 @@ static struct kobj_attribute uv_query_dump_storage_state_len_attr =
> static ssize_t uv_query_dump_finalize_len(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n",
> - uv_info.conf_dump_finalize_len);
> + return sysfs_emit(page, "%lx\n", uv_info.conf_dump_finalize_len);
> }
>
> static struct kobj_attribute uv_query_dump_finalize_len_attr =
> @@ -532,8 +529,7 @@ static struct kobj_attribute uv_query_feature_indications_attr =
> static ssize_t uv_query_max_guest_cpus(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%d\n",
> - uv_info.max_guest_cpu_id + 1);
> + return sysfs_emit(page, "%d\n", uv_info.max_guest_cpu_id + 1);
> }
>
> static struct kobj_attribute uv_query_max_guest_cpus_attr =
> @@ -542,8 +538,7 @@ static struct kobj_attribute uv_query_max_guest_cpus_attr =
> static ssize_t uv_query_max_guest_vms(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%d\n",
> - uv_info.max_num_sec_conf);
> + return sysfs_emit(page, "%d\n", uv_info.max_num_sec_conf);
> }
>
> static struct kobj_attribute uv_query_max_guest_vms_attr =
> @@ -552,8 +547,7 @@ static struct kobj_attribute uv_query_max_guest_vms_attr =
> static ssize_t uv_query_max_guest_addr(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n",
> - uv_info.max_sec_stor_addr);
> + return sysfs_emit(page, "%lx\n", uv_info.max_sec_stor_addr);
> }
>
> static struct kobj_attribute uv_query_max_guest_addr_attr =
> @@ -562,7 +556,7 @@ static struct kobj_attribute uv_query_max_guest_addr_attr =
> static ssize_t uv_query_supp_att_req_hdr_ver(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_att_req_hdr_ver);
> + return sysfs_emit(page, "%lx\n", uv_info.supp_att_req_hdr_ver);
> }
>
> static struct kobj_attribute uv_query_supp_att_req_hdr_ver_attr =
> @@ -571,7 +565,7 @@ static struct kobj_attribute uv_query_supp_att_req_hdr_ver_attr =
> static ssize_t uv_query_supp_att_pflags(struct kobject *kobj,
> struct kobj_attribute *attr, char *page)
> {
> - return scnprintf(page, PAGE_SIZE, "%lx\n", uv_info.supp_att_pflags);
> + return sysfs_emit(page, "%lx\n", uv_info.supp_att_pflags);
> }
>
> static struct kobj_attribute uv_query_supp_att_pflags_attr =
> @@ -605,7 +599,7 @@ static ssize_t uv_is_prot_virt_guest(struct kobject *kobj,
> #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
> val = prot_virt_guest;
> #endif
> - return scnprintf(page, PAGE_SIZE, "%d\n", val);
> + return sysfs_emit(page, "%d\n", val);
> }
>
> static ssize_t uv_is_prot_virt_host(struct kobject *kobj,
> @@ -617,7 +611,7 @@ static ssize_t uv_is_prot_virt_host(struct kobject *kobj,
> val = prot_virt_host;
> #endif
>
> - return scnprintf(page, PAGE_SIZE, "%d\n", val);
> + return sysfs_emit(page, "%d\n", val);
> }
>
> static struct kobj_attribute uv_prot_virt_guest =
next prev parent reply other threads:[~2023-06-05 13:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 9:37 [PATCH v2 0/6] s390/uvdevice: Expose secret UVCs Steffen Eiden
2023-05-19 9:37 ` [PATCH v2 1/6] s390/uvdevice: Add info IOCTL Steffen Eiden
2023-06-05 12:39 ` Janosch Frank
2023-05-19 9:37 ` [PATCH v2 2/6] s390/uvdevice: Add 'Add Secret' UVC Steffen Eiden
2023-06-05 13:19 ` Janosch Frank
2023-05-19 9:37 ` [PATCH v2 3/6] s390/uvdevice: Add 'List Secrets' UVC Steffen Eiden
2023-06-05 13:29 ` Janosch Frank
2023-05-19 9:37 ` [PATCH v2 4/6] s390/uvdevice: Add 'Lock Secret Store' UVC Steffen Eiden
2023-06-05 13:34 ` Janosch Frank
2023-05-19 9:37 ` [PATCH v2 5/6] s390/uv: replace scnprintf with sysfs_emit Steffen Eiden
2023-06-05 13:55 ` Janosch Frank [this message]
2023-05-19 9:37 ` [PATCH v2 6/6] s390/uv: Update query for secret-UVCs Steffen Eiden
2023-06-05 14:03 ` Janosch Frank
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=2fca9573-5989-d61e-52ec-552f4e176971@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mihajlov@linux.ibm.com \
--cc=nrb@linux.ibm.com \
--cc=seiden@linux.ibm.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