Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1946974yba; Fri, 10 May 2019 03:54:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqymZgZO8N+Eh1tfu4RDjkWSMpvohQj0yAPiw+KAjOpXZIgNRQfAB0CP4IwAZFGgL5QCx30K X-Received: by 2002:aa7:95bb:: with SMTP id a27mr1000581pfk.30.1557485699057; Fri, 10 May 2019 03:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557485699; cv=none; d=google.com; s=arc-20160816; b=SdLWeamZ1yBwU9MpwPmeCjgMV4zq4DI89aStFo6Da2vJMxq3i58aNteFENjcW9NQH0 J3hJKty2sNmNpQYEY8g6yPr1tXIwu3Oa9MUNJcB01/IbszKiOTjAi2VHvacFg2b3k/ju C5LO4/qojXG6WqQ5kaGovncg1jTCRXzjz3YmiA+0UvGa9UDD0OsGlls5xY5NSdZMoMhS jiDB7nv1TNIjNx/Kn8E0c10OU/XdW+tzFZ6ySsB6og+y0bywM4+m4ghlkluExCD7ZK2m oWctNYhc+2KK8ci5N9KUXCO198KfuUn409TZJmaiVn8thcSAZEsjgPrg0IjfW/ZJAjN4 i6/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6lmggy5LAhP6+/fqo3Cgjki+90sC2rjWaVQkUq7yfS0=; b=z7tEJVXMn2s9xGRJFI5UEtIc89g0l/zwx+PC26ITwh4g4OfDLwphl5ej2pxaAw/jjI xwF8r5Bb228w6t5qScwfp4rgZ4hYRn3nGplnSINQ0QigPX5IqlIHE3w/M3aUOL1zp5t6 yondMrfdIHQ5vRNGC6buLMZvs33r3J2sz8LnboRs6L59NRkdz0M8PhBiEXZ9FGA1NwjH Si1/NRcYDPsv14jDyZRj9WA3R5OlhTbMso7R2PgfwV6HwySekS4iQvA2UOOfn3ea8NAV dP+M0MbOAFsBVtsrELGEnFZCEvY3XE60646jAatgYLMW92cha3k8QSmbqg4JVwkhZUyU zD4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IiT+Y7M2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf12si6192311plb.126.2019.05.10.03.54.42; Fri, 10 May 2019 03:54:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IiT+Y7M2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727189AbfEJKxq (ORCPT + 99 others); Fri, 10 May 2019 06:53:46 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:52702 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727052AbfEJKxp (ORCPT ); Fri, 10 May 2019 06:53:45 -0400 Received: by mail-it1-f194.google.com with SMTP id q65so8627786itg.2 for ; Fri, 10 May 2019 03:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6lmggy5LAhP6+/fqo3Cgjki+90sC2rjWaVQkUq7yfS0=; b=IiT+Y7M2bPSekDVZ0GorTiBcC3mahvOegfQRIUpm047z/E7ZQiYTEDyK99JCx55xzr IM2JqTWji/VnQeDAi8vHeZtehsL8/RZPpgt+97oinEPEz7LNZyirIW2pB99JSzwjzIHz vX1MlDYQZbErxiPOntUk+nrtqfnBcBD61PQOtQMfi0ixxTtB5n9OphDCFNYmWIQaXa2M 554VgQPXpnXXfpRsDU/6EijWMNVV2DUYKmIbAAjAIbbfrtTeC2SB8DezrQ32Hfl9w3zJ CK5Zg50oSTq5MpWNxvpIofT8hYBIUn1z8D/FoU39PfQx6sEy0q8ZpTqfCH/lr8EXWewq pdiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6lmggy5LAhP6+/fqo3Cgjki+90sC2rjWaVQkUq7yfS0=; b=fin6XGb64EjR3HYx0rw5xNlZLUqfeahY1ZrEqrl3MNxjMkMPmP0ySwgdcC81n3cZQ6 mboVwrLn2N01LGpXieefpdJ4zNvOQk2trSFXqObCN6DLLIzLeapJRLjjOoxC41i9jt4H SJQ4hM/PqhldsU37u1vQzjhxZogsQGw2WV6KM9p+rn8M/q7KlAnG2tjToEtgvzsWMWI+ 7eJA8ReNPU2FTeiCkJEF/AYLe3mGYXXcRsdFIsbbhRgSa9k8SXSMf0SFpbRoMNEoB2k7 ioWivNaRj6hnge303go45uPuwIaIa00Q95jriR+EH6Z9QVaQLaE5F0DeKLSSPU3/E0Hx YGxg== X-Gm-Message-State: APjAAAVpOYCadrgd/yvh1aRl6bfQcRJ2TO9tpoEjnFLyCfp5vfe41i+l tr5OAWrhxgBFrNrrDrMzhno9FyDojL2kWTKUm4St5g== X-Received: by 2002:a24:6c13:: with SMTP id w19mr238759itb.144.1557485624546; Fri, 10 May 2019 03:53:44 -0700 (PDT) MIME-Version: 1.0 References: <20190412143538.11780-1-hch@lst.de> In-Reply-To: From: Dmitry Vyukov Date: Fri, 10 May 2019 12:53:33 +0200 Message-ID: Subject: Re: [PATCH, RFC] byteorder: sanity check toolchain vs kernel endianess To: Nick Kossifidis Cc: Arnd Bergmann , Christoph Hellwig , Linus Torvalds , Andrew Morton , linux-arch , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Kossifidis Date: Fri, Apr 12, 2019 at 6:08 PM To: Arnd Bergmann Cc: Christoph Hellwig, Linus Torvalds, Andrew Morton, linux-arch, , Linux Kernel Mailing List > =CE=A3=CF=84=CE=B9=CF=82 2019-04-12 17:53, Arnd Bergmann =CE=AD=CE=B3=CF= =81=CE=B1=CF=88=CE=B5: > > On Fri, Apr 12, 2019 at 4:36 PM Christoph Hellwig wrote: > >> > >> When removing some dead big endian checks in the RISC-V code Nick > >> suggested that we should have some generic sanity checks. I don't > >> think > >> we should have thos inside the RISC-V code, but maybe it might make > >> sense to have these in the generic byteorder headers. Note that these > >> are UAPI headers and some compilers might not actually define > >> __BYTE_ORDER__, so we first check that it actually exists. > >> > >> Suggested-by: Nick Kossifidis > >> Signed-off-by: Christoph Hellwig > > > > Acked-by: Arnd Bergmann > > > > Extra checking like this is good in general, but I'm not sure I see > > exactly what kind of issue one might expect to prevent with this: > > > > All architecture asm/byteorder.h headers either include the only > > possible option, or they check the compiler defined macros: > > > > arch/arc/include/uapi/asm/byteorder.h:#ifdef __BIG_ENDIAN__ > > arch/arm/include/uapi/asm/byteorder.h:#ifdef __ARMEB__ > > arch/arm64/include/uapi/asm/byteorder.h:#ifdef __AARCH64EB__ > > arch/c6x/include/uapi/asm/byteorder.h:#ifdef _BIG_ENDIAN > > arch/microblaze/include/uapi/asm/byteorder.h:#ifdef __MICROBLAZEEL__ > > arch/mips/include/uapi/asm/byteorder.h:#if defined(__MIPSEB__) > > arch/nds32/include/uapi/asm/byteorder.h:#ifdef __NDS32_EB__ > > arch/powerpc/include/uapi/asm/byteorder.h:#ifdef __LITTLE_ENDIAN__ > > arch/sh/include/uapi/asm/byteorder.h:#ifdef __LITTLE_ENDIAN__ > > arch/xtensa/include/uapi/asm/byteorder.h:#ifdef __XTENSA_EL__ > > > > Are you worried about toolchains that define those differently > > from what these headers expect? Did you encounter such a case? > > > > Arnd > > The following architectures just include the header file without > checking for any compiler macro: > > alpha: little_endian.h > csky: little_endian.h > h8300: big_endian.h > hexagon: little_endian.h > ia64: little_endian.h > m68k: big_endian.h > nios2: little_endian.h > openrisc: big_endian.h > parisc: big_endian.h > riscv: little_endian.h > s390: big_endian.h > sparc: big_endian.h > unicore32: little_endian.h > x86: little_endian.h > > Of those who do check for a compiler macro, they don't use the > generic macros (__ORDER_*_ENDIAN__) but arch-specific ones. > > Only two architectures (mips and xtensa) that support both big > and little endian return an error in case the endianess can't be > determined, the rest will move on without including any > of *_endian.h files. > > I think it's good to have a sanity check in-place for consistency. Hi, This broke our cross-builds from x86. I am using: $ powerpc64le-linux-gnu-gcc --version powerpc64le-linux-gnu-gcc (Debian 7.2.0-7) 7.2.0 and it says that it's little-endian somehow: $ powerpc64le-linux-gnu-gcc -dM -E - < /dev/null | grep BYTE_ORDER #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ Is it broke compiler? Or I always hold it wrong? Is there some additional flag I need to add? Thanks