From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: George Dunlap <george.dunlap@citrix.com>
Subject: Re: [PATCH 09/11] kexec: avoid effectively open-coding xzalloc_flex_struct()
Date: Fri, 9 Apr 2021 13:54:09 +0100 [thread overview]
Message-ID: <8131c6f5-ed8c-98ae-376a-fe8f7b63a790@citrix.com> (raw)
In-Reply-To: <4ea9c4a3-74c0-1722-fa5d-3930be99ef4a@suse.com>
On 08/04/2021 13:21, Jan Beulich wrote:
> There is a difference in generated code: xzalloc_bytes() forces
> SMP_CACHE_BYTES alignment. I think we not only don't need this here, but
> actually don't want it.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
This honestly looks like a backwards step. In particular, ...
>
> --- a/xen/common/kexec.c
> +++ b/xen/common/kexec.c
> @@ -463,7 +463,10 @@ static void * alloc_from_crash_heap(cons
> /* Allocate a crash note buffer for a newly onlined cpu. */
> static int kexec_init_cpu_notes(const unsigned long cpu)
> {
> - Elf_Note * note = NULL;
> + struct elf_notes {
> + Elf_Note first;
> + unsigned char more[];
> + } *notes = NULL;
> int ret = 0;
> int nr_bytes = 0;
>
> @@ -477,7 +480,8 @@ static int kexec_init_cpu_notes(const un
>
> /* If we dont care about the position of allocation, malloc. */
> if ( low_crashinfo_mode == LOW_CRASHINFO_NONE )
> - note = xzalloc_bytes(nr_bytes);
> + notes = xzalloc_flex_struct(struct elf_notes, more,
> + nr_bytes - sizeof(notes->first));
... this is far more error prone than the code you replaced, seeing as
there is now a chance that it can underflow.
~Andrew
next prev parent reply other threads:[~2021-04-09 12:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 12:13 [PATCH 00/11] assorted replacement of x[mz]alloc_bytes() Jan Beulich
2021-04-08 12:16 ` [PATCH 01/11] x86/HVM: avoid effectively open-coding xzalloc_flex_struct() Jan Beulich
2021-04-08 12:20 ` Andrew Cooper
2021-04-08 12:17 ` [PATCH 02/11] x86/vPMU: " Jan Beulich
2021-04-08 12:25 ` Andrew Cooper
2021-04-08 12:29 ` Jan Beulich
2021-04-08 12:17 ` [PATCH 03/11] x86/MCE: avoid effectively open-coding xmalloc_array() Jan Beulich
2021-04-08 12:18 ` [PATCH 04/11] x86/HVM: " Jan Beulich
2021-04-08 12:19 ` [PATCH 05/11] x86/oprofile: " Jan Beulich
2021-04-08 12:20 ` [PATCH 06/11] x86/IRQ: avoid over-alignment in alloc_pirq_struct() Jan Beulich
2021-04-08 12:20 ` [PATCH 07/11] EFI/runtime: avoid effectively open-coding xmalloc_array() Jan Beulich
2021-04-08 12:21 ` [PATCH 08/11] hypfs: avoid effectively open-coding xzalloc_array() Jan Beulich
2021-04-08 14:28 ` Juergen Gross
2021-04-08 12:21 ` [PATCH 09/11] kexec: avoid effectively open-coding xzalloc_flex_struct() Jan Beulich
2021-04-09 12:54 ` Andrew Cooper [this message]
2021-04-09 13:23 ` Jan Beulich
2021-04-08 12:22 ` [PATCH 10/11] video/lfb: avoid effectively open-coding xzalloc_array() Jan Beulich
2021-04-08 12:23 ` [PATCH 11/11] Arm/optee: don't open-code xzalloc_flex_struct() Jan Beulich
2021-04-13 18:19 ` Julien Grall
2021-04-14 7:03 ` Jan Beulich
2021-04-15 10:26 ` Julien Grall
2021-04-15 11:02 ` Jan Beulich
2021-04-15 11:31 ` Julien Grall
2021-04-08 12:57 ` [PATCH 00/11] assorted replacement of x[mz]alloc_bytes() Andrew Cooper
2021-04-08 14:12 ` Jan Beulich
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=8131c6f5-ed8c-98ae-376a-fe8f7b63a790@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).