[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 09/11] kexec: avoid effectively open-coding xzalloc_flex_struct()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 9 Apr 2021 13:54:09 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+3sz/kHKcQ/kphMk5MS83SWxQhL4qGgP93o8Mpqi5As=; b=Ur/KyXj5jtr1O6P3gXTmGb7OMHPu4uLQ7wCwyux9W0asYlmndbx3T2lMa3M+VnZGIRi16YDLWv1jpUQF8vYfVkQar8lCUfOjF+BXIau0Tk36zCKBD/gydEh3L/Tqy99PW6erSC90bJNG8F058D1C/ycc88nYA2ZAXiE1BZtWWsaZxdZ/aw1CPooz4qFGLBOADirzr9Do3BgzyNom15kxYQDUe/BPQxkZHfg2nj+3VqTxgxkiF/Ue7gjRhfS6Q3Bua9+yeT2r6nhyx95LS5i1xLm6MMAnq+jigGspZjmGsWMMWRklQl+iUkGq1hCydFcuc50CzzczpyQSDA1Ev4+sAA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jp09cWfE9vyVub2GxMD3CfasQxxGLN1VQ5nvLooq82eYnoGckUngKA+C3goXNRMAG+Ax9/jQaZOY+hvOxSqBlXgwVRhXpxm5Q+kBW7yfVjXQcZ41y0dhOJpMKXPNt3vOonEoys4NGHe8vxa09/3V8FDUOq1bWgqlQ6wHfBDv84Xv9BSLXqYxi+8OUb97O4HiiWg2upF1f9CKEj/fc1v/IQVahsIAiZTGwpxoGRjSVmcQEHIFU3G5XpIhC+7XLNa1hJ6Ixuyv5shYTbVMPnYQcqkr0SLBaVV00V+mEJ5QeyG87Ava3P43vw8iV1/VQkgqaAAluy2xyFQGXc+nHYd9iw==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Fri, 09 Apr 2021 12:54:31 +0000
  • Ironport-hdrordr: A9a23:+4wJeah/GyCflTNnZDjnrBRGP3BQXwh13DAbvn1ZSRFFG/Gwv9 yynfgdyB//gCsQXnZlotybJKycWxrnmKJdy4N5B9efdSPhv3alK5wn0Jv6z1TbaknD38N+9Y MlSahxD9XsEUN35PyR3CCUG8stqePpzImGnuHbpk0CcShPS4VNqzh0ERyaFEoefngiObMcGI CH7sRK4xqMEE5nDfiTPXUOU+jdq9CjrvuPDSIuPBI79BKIyQqh9b+SKXOl9y0DWDBCy6pKyx mmryXF4MyY0s2T+1vn+EL4q79Xn9bgzdUrPr3wtuElbg/CpyztSIBoW7iptC04rue1+D8R4a XxiiZlBetfwTf8eXy0vAvM1mDboUkTwk6n83C0qz/CptH0Xz0zAcYpv/MmTjLpr3AOkfs59Y Aj5RP/i7NnSSnusQ642v3zEzZtrUawqWpKq59ps1VvFbEwRZUUkZYS5ypuYfE9NRO/0q8LOs 90AvrR4f5HGGnqFUzxjy1UzNugUm9bJGb+fmEy/sic0z1hlHtk1UcvxMsGgnca9J4mIqM0n9 j5Dg==
  • Ironport-sdr: mE1CCGo6sn09WCtbBvysd4h3Pi80r3DPSTPOfcssNWwWa7JMwjmsy+mG69X+Td5GTDA4Tkhfr6 pcSthcWM1wpqbyfIXsaT7263H5WPB6rf5I9HCWK2x96rxFL5Cw63sUjMnDlQ0Jp44SJLIrv39t u8hHoDePodAML4gS7wo7jT5LJOW9yoss6R7Ns0edY+pvb9fCTvBi23EF8Xg0jGRaSmL9pq9B7C 95EOpvrmtIS02EFnqb9WMPbBBH/NXfib8ifcnaNiZfMk4sn3j6rntGzUqQVpQnl8JRCB5UJaag u0E=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>

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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.