public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Steffen Eiden <seiden@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	Ingo Franzki <ifranzki@linux.ibm.com>,
	Harald Freudenberger <freude@linux.ibm.com>,
	Christoph Schlameuss <schlameuss@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Subject: Re: [PATCH v2 5/6] s390/uvdevice: Add List Secrets Ext IOCTL
Date: Tue, 8 Oct 2024 16:48:26 +0200	[thread overview]
Message-ID: <20241008144826.27223-D-hca@linux.ibm.com> (raw)
In-Reply-To: <20241002160532.2425734-6-seiden@linux.ibm.com>

On Wed, Oct 02, 2024 at 06:05:31PM +0200, Steffen Eiden wrote:
> Add an extended List Secrets IOCTL. In contrast to the first list IOCTL
> this accepts an index as the first two bytes of the provided page as an
> input. This index is then taken as the index offset for the list UVC to
> receive later entries for the list.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
>  arch/s390/include/uapi/asm/uvdevice.h |  4 ++
>  drivers/s390/char/uvdevice.c          | 96 ++++++++++++++++++++-------
>  2 files changed, 75 insertions(+), 25 deletions(-)

...

> +/* The actual list(_ext) IOCTL.
> + * If list_ext is true, the first two bytes of the user buffer set the starting index of the
> + * list-UVC
> + */

This is not standard kernel comment style; there is no need for a line
with more than >80 characters here; and in this case it would be nice
to add a "." at the end of the sentence :)

> +static int list_secrets(struct uvio_ioctl_cb *uv_ioctl, bool list_ext)
> +{
> +	void __user *user_buf_arg = (void __user *)uv_ioctl->argument_addr;
> +	u16 __user *user_index = (u16 __user *)uv_ioctl->argument_addr;
> +	u8 *secrets = NULL;

No need to preinitialize.

> +	u16 start_idx = 0;
> +	int ret;
> +
> +	if (uv_ioctl->argument_len != UVIO_LIST_SECRETS_LEN)
> +		return -EINVAL;
> +
> +	BUILD_BUG_ON(UVIO_LIST_SECRETS_LEN != PAGE_SIZE);
> +	secrets = (u8 *)get_zeroed_page(GFP_KERNEL);
> +	if (!secrets)
> +		return -ENOMEM;
> +
> +	/* The extended call accepts an u16 index as input */
> +	ret = -EFAULT;
> +	if (list_ext) {
> +		if (get_user(start_idx, user_index))
> +			goto err;
> +	}
> +
> +	uv_list_secrets(secrets, start_idx, &uv_ioctl->uv_rc, &uv_ioctl->uv_rrc);
> +
> +	if (copy_to_user(user_buf_arg, secrets, UVIO_LIST_SECRETS_LEN))
> +		goto err;
> +	ret = 0;
> +
> +err:
> +	free_pages((unsigned long)secrets, 0);
> +	return ret;
> +}

If you would change the order of the code a bit, it would be possible
to write this shorter:

	int ret = 0;
	...
	if (list_ext && get_user(start_idx, user_index))
		return -EFAULT;
	secrets = (u8 *)get_zeroed_page(GFP_KERNEL);
	if (!secrets)
		return -ENOMEM;
	uv_list_secrets(secrets, start_idx, &uv_ioctl->uv_rc, &uv_ioctl->uv_rrc);
	if (copy_to_user(user_buf_arg, secrets, UVIO_LIST_SECRETS_LEN))
		ret = -EFAULT;
	free_page((unsigned long)secrets);
	return ret;

> +/** uvio_list_secrets_ext() - perform a List Secret UVC with a starting index
> + * @uv_ioctl: ioctl control block

This is not kernel doc style.

Anyway, just my 0.02.

  parent reply	other threads:[~2024-10-08 14:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 16:05 [PATCH v2 0/6] s390/uv: Retrieve Secrets Ultravisor Call support Steffen Eiden
2024-10-02 16:05 ` [PATCH v2 1/6] s390/boot/uv.c: Use a constant for more-data rc Steffen Eiden
2024-10-02 16:05 ` [PATCH v2 2/6] s390/uv: Retrieve UV secrets support Steffen Eiden
2024-10-07 12:31   ` Janosch Frank
2024-10-14 11:46     ` Steffen Eiden
2024-10-08 14:36   ` Heiko Carstens
2024-10-02 16:05 ` [PATCH v2 3/6] s390/uvdevice: Add Retrieve Secret IOCTL Steffen Eiden
2024-10-02 16:05 ` [PATCH v2 4/6] s390/uvdevice: Increase indent in IOCTL definitions Steffen Eiden
2024-10-02 16:05 ` [PATCH v2 5/6] s390/uvdevice: Add List Secrets Ext IOCTL Steffen Eiden
2024-10-08  9:01   ` Christoph Schlameuss
2024-10-08 14:48   ` Heiko Carstens [this message]
2024-10-02 16:05 ` [PATCH v2 6/6] s390/uv: Retrieve UV secrets sysfs support Steffen Eiden

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=20241008144826.27223-D-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=ifranzki@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=schlameuss@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