From: dmkhn@proton.me
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Marek Marczykowski <marmarek@invisiblethingslab.com>,
Daniel Smith <dpsmith@apertussolutions.com>
Subject: Re: [PATCH v3] EFI/runtime: switch to xv[mz]alloc_array()
Date: Thu, 24 Jul 2025 01:59:56 +0000 [thread overview]
Message-ID: <aIGTmFl6WB7e+fqx@kraken> (raw)
In-Reply-To: <41b7e14c-59ef-40f5-8c43-69bdc5fb4531@suse.com>
On Wed, Jul 23, 2025 at 03:39:11PM +0200, Jan Beulich wrote:
> Use the more "modern" form, thus doing away with effectively open-coding
> xmalloc_array() at the same time. While there is a difference in
> generated code, as xmalloc_bytes() forces SMP_CACHE_BYTES alignment, if
> code really cared about such higher than default alignment, it should
> request so explicitly.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Denis Mukhin <dmukhin@ford.com>
> ---
> v3: Use xv[mz]alloc_array().
>
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -6,6 +6,7 @@
> #include <xen/irq.h>
> #include <xen/sections.h>
> #include <xen/time.h>
> +#include <xen/xvmalloc.h>
>
> DEFINE_XEN_GUEST_HANDLE(CHAR16);
>
> @@ -500,23 +501,23 @@ int efi_runtime_call(struct xenpf_efi_ru
> len = gwstrlen(guest_handle_cast(op->u.get_variable.name, CHAR16));
> if ( len < 0 )
> return len;
> - name = xmalloc_array(CHAR16, ++len);
> + name = xvmalloc_array(CHAR16, ++len);
> if ( !name )
> return -ENOMEM;
> if ( __copy_from_guest(name, op->u.get_variable.name, len) ||
> wmemchr(name, 0, len) != name + len - 1 )
> {
> - xfree(name);
> + xvfree(name);
> return -EIO;
> }
>
> size = op->u.get_variable.size;
> if ( size )
> {
> - data = xmalloc_bytes(size);
> + data = xvmalloc_array(unsigned char, size);
> if ( !data )
> {
> - xfree(name);
> + xvfree(name);
> return -ENOMEM;
> }
> }
> @@ -539,8 +540,8 @@ int efi_runtime_call(struct xenpf_efi_ru
> else
> rc = -EOPNOTSUPP;
>
> - xfree(data);
> - xfree(name);
> + xvfree(data);
> + xvfree(name);
> }
> break;
>
> @@ -553,17 +554,17 @@ int efi_runtime_call(struct xenpf_efi_ru
> len = gwstrlen(guest_handle_cast(op->u.set_variable.name, CHAR16));
> if ( len < 0 )
> return len;
> - name = xmalloc_array(CHAR16, ++len);
> + name = xvmalloc_array(CHAR16, ++len);
> if ( !name )
> return -ENOMEM;
> if ( __copy_from_guest(name, op->u.set_variable.name, len) ||
> wmemchr(name, 0, len) != name + len - 1 )
> {
> - xfree(name);
> + xvfree(name);
> return -EIO;
> }
>
> - data = xmalloc_bytes(op->u.set_variable.size);
> + data = xvmalloc_array(unsigned char, op->u.set_variable.size);
> if ( !data )
> rc = -ENOMEM;
> else if ( copy_from_guest(data, op->u.set_variable.data,
> @@ -581,8 +582,8 @@ int efi_runtime_call(struct xenpf_efi_ru
> efi_rs_leave(&state);
> }
>
> - xfree(data);
> - xfree(name);
> + xvfree(data);
> + xvfree(name);
> }
> break;
>
> @@ -598,13 +599,13 @@ int efi_runtime_call(struct xenpf_efi_ru
> return -EINVAL;
>
> size = op->u.get_next_variable_name.size;
> - name.raw = xzalloc_bytes(size);
> + name.raw = xvzalloc_array(unsigned char, size);
> if ( !name.raw )
> return -ENOMEM;
> if ( copy_from_guest(name.raw, op->u.get_next_variable_name.name,
> size) )
> {
> - xfree(name.raw);
> + xvfree(name.raw);
> return -EFAULT;
> }
>
> @@ -629,7 +630,7 @@ int efi_runtime_call(struct xenpf_efi_ru
> else
> rc = -EOPNOTSUPP;
>
> - xfree(name.raw);
> + xvfree(name.raw);
> }
> break;
>
>
next prev parent reply other threads:[~2025-07-24 2:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 13:39 [PATCH v3] EFI/runtime: switch to xv[mz]alloc_array() Jan Beulich
2025-07-24 1:59 ` dmkhn [this message]
2025-08-11 12:34 ` Ping: " Jan Beulich
2025-08-12 0:19 ` Daniel P. Smith
2025-08-12 6:12 ` Jan Beulich
2025-08-14 0:29 ` Daniel P. Smith
2025-08-14 6:46 ` Jan Beulich
2025-08-25 11:06 ` Jan Beulich
2025-11-25 15:14 ` Daniel P. Smith
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=aIGTmFl6WB7e+fqx@kraken \
--to=dmkhn@proton.me \
--cc=dpsmith@apertussolutions.com \
--cc=jbeulich@suse.com \
--cc=marmarek@invisiblethingslab.com \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.