All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Lin Liu" <lin.liu@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Shawn Anastasio" <sanastasio@raptorengineering.com>,
	"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
	"Daniel P . Smith" <dpsmith@apertussolutions.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v5 03/16] xen: Implement common byte{order,swap}.h
Date: Mon, 31 Mar 2025 14:59:15 +0100	[thread overview]
Message-ID: <0fafaf3f-ded6-4444-a635-bf32a47b209b@citrix.com> (raw)
In-Reply-To: <c79d76e2-3e6d-4c2a-a240-ee36daa559e0@suse.com>

On 31/03/2025 9:32 am, Jan Beulich wrote:
> On 28.03.2025 14:44, Andrew Cooper wrote:
>> From: Lin Liu <lin.liu@citrix.com>
>>
>> The current swab??() infrastructure is unecesserily complicated, and can be
>> repated entirely with compiler builtins.
>>
>> All supported compilers provide __BYTE_ORDER__ and __builtin_bswap??().
>>
>> Nothing in Xen cares about the values of __{BIG,LITTLE}_ENDIAN; just that one
>> of them is defined.  Therefore, centralise their definitions in xen/config.h
> And even if we cared somewhere, __ORDER_{BIG,LITTLE}_ENDIAN__ supply them
> just fine.
>
>> Signed-off-by: Lin Liu <lin.liu@citrix.com>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> with two nits taken care of:
>
>> --- /dev/null
>> +++ b/xen/include/xen/byteorder.h
>> @@ -0,0 +1,44 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +#ifndef XEN_BYTEORDER_H
>> +#define XEN_BYTEORDER_H
>> +
>> +#include <xen/byteswap.h>
>> +#include <xen/types.h>
> It's stdint.h that's needed here, not types.h?

Perhaps.

>
>> +#if defined(__LITTLE_ENDIAN)
>> +
>> +# define cpu_to_le64(x) (uint64_t)(x)
>> +# define le64_to_cpu(x) (uint64_t)(x)
>> +# define cpu_to_le32(x) (uint32_t)(x)
>> +# define le32_to_cpu(x) (uint32_t)(x)
>> +# define cpu_to_le16(x) (uint16_t)(x)
>> +# define le16_to_cpu(x) (uint16_t)(x)
> (Not just) for Misra these all need another pair of parentheses around the
> entire expressions.

Why?  For both points?  Eclair is happy, with this at least.

What does fail is a bit a of a curveball.

https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/andyhhp/xen/ECLAIR_normal/xen-bswap/ARM64/9556392204/PROJECT.ecd;/by_service/MC3A2.R20.6.html

cpu_to_le64() turns from a real function to a macro under ARM, meaning
that the #ifdef __BIG_ENDIAN in the middle of a bunch of constants
becomes UB.

I'll need to fix that separately.

~Andrew


  reply	other threads:[~2025-03-31 13:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-28 13:44 [PATCH v5 00/16] xen: Centralise byteswap infrastructure Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 01/16] xen/lzo: Remove more remanants of TMEM Andrew Cooper
2025-03-31  7:30   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 02/16] xen: Remove __{BIG,LITTLE}_ENDIAN_BITFIELD Andrew Cooper
2025-03-31  7:42   ` Jan Beulich
2025-03-31 14:08     ` Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 03/16] xen: Implement common byte{order,swap}.h Andrew Cooper
2025-03-31  8:32   ` Jan Beulich
2025-03-31 13:59     ` Andrew Cooper [this message]
2025-03-31 14:08       ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 04/16] xen/lib: Switch to xen/byteorder.h Andrew Cooper
2025-03-31  8:44   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 05/16] xen/device-tree: Remove use of *_to_cpup() helpers Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 06/16] xen/decompressors: " Andrew Cooper
2025-03-28 14:07   ` Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 07/16] xen/arch: Switch to new byteorder infrastructure Andrew Cooper
2025-03-31 13:53   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 08/16] xen/decompressors: Use " Andrew Cooper
2025-03-31 13:55   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 09/16] xen: Remove old " Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 10/16] crypto/vmac: Switch to xen/byteswap.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 11/16] xsm/flask: Switch {asm -> xen}/byteorder.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 12/16] xen/common: " Andrew Cooper
2025-03-31 13:58   ` Jan Beulich
2025-03-28 13:44 ` [PATCH v5 13/16] arm: Remove asm/byteorder.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 14/16] ppc: Drop asm/byteorder.h Andrew Cooper
2025-03-28 13:44 ` [PATCH v5 15/16] riscv: Remove asm/byteorder.h Andrew Cooper
2025-03-31 14:52   ` Oleksii Kurochko
2025-03-28 13:44 ` [PATCH v5 16/16] x86: Drop asm/byteorder.h Andrew Cooper
2025-03-31 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=0fafaf3f-ded6-4444-a635-bf32a47b209b@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=dpsmith@apertussolutions.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=lin.liu@citrix.com \
    --cc=michal.orzel@amd.com \
    --cc=oleksii.kurochko@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=sanastasio@raptorengineering.com \
    --cc=sstabellini@kernel.org \
    --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.