Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4138365ybi; Tue, 11 Jun 2019 01:26:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz08SFSVm0IgU8zoEGuI3oqoy/O5f5cdtDapTUcaeSheJbP0uEaG0gSymLiWkoBF9uBc6k1 X-Received: by 2002:a17:90a:c503:: with SMTP id k3mr26035332pjt.46.1560241601239; Tue, 11 Jun 2019 01:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560241601; cv=none; d=google.com; s=arc-20160816; b=QhE9JA3V0EgKOuD3g9JAATDk1j0mngRdxpmmWlW8dL0T3jvBBp5pHukMB3BmLDnd/h wDxQ6hJYaL+ns2+BM6oowdJF3hKSOn6eo+C7HQN0o+2MVOe0Zuw1Mdz+iD+UmZE1YIdh 2tFsEB8lMqvu5akoF5oPx6aEUwqHlQS4WDILH6ys89ds8esB8RCMSsIQo8RwWF2igDSp 08pZFbp5+21Wugvz5BRXAzQOID7dl+4zPELhyJy9eKU1IPKmbFuIkBtURylNLGGFmM+f GsPVsGYoM1OA1Nbx+8d5FS9EchIKfQ+0V80KBjBD3Nra8bkpmCEpa0lYVuR2aD72SruF UQMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=fRmoMIsZBSVoYdlrURu/R5LpVklxWrnPow9T+scl1c8=; b=wsGMdKzCMHxeKutSyKWTLyJyAKVj5ks9mf2qTFMC2wpWjxkQ6nP6B/Mq9iyBEeLxCc axOOnNvsc7PA9tV9b2hzy6DLpU5/GGRFcxheHGo2DGs/O7Fvd60cgCVM5+Gi+b9lTfqc dKnOVss1ETQFqr36R4FkARCBTnvJOMVa+zcazzmYOnnquOwkg202DDYlcUztYg+VD1l+ IFDYF9tJDvIQ6H85O7bOxJIKagyQMUBbSEus65jPZhUxGyzZ26Z2BCUoEoIRqG3sxG3A htSkAa8z5V+mr/lklZI4QuXrm2Fi3qIXQ43Rybh8Nb8wSJVW9IFyOrVfn2/4m/3VaqRe oDYA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m127si11715610pgm.231.2019.06.11.01.26.25; Tue, 11 Jun 2019 01:26:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404684AbfFKI0C (ORCPT + 99 others); Tue, 11 Jun 2019 04:26:02 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34887 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404073AbfFKI0C (ORCPT ); Tue, 11 Jun 2019 04:26:02 -0400 Received: by mail-lj1-f195.google.com with SMTP id x25so6075214ljh.2; Tue, 11 Jun 2019 01:26:00 -0700 (PDT) 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; bh=fRmoMIsZBSVoYdlrURu/R5LpVklxWrnPow9T+scl1c8=; b=gIcU94J47mvP6GNPNcFwUM2EV2b2fBSARTihfnzPd0RqXmqXFVQo4ilCXChC250ICZ 8Xz088n+h9BBMxYQdXbCykA4V1H9dz3o2gscvTA4Vt5L5EswHH2WBNeeS90IXpNLX5Ul 7SasOEDNAViOksYq01t1xVc58F0Nf+EQr7uGgP6QPAlvicTVX6EIZkAXMMIya9UdSqrI GFUmPH8QyChs2T/jM5ppO9Z+9a/kAFO0MpFhurQW9ZaVAuR1FBDZi4u7ydLmSQJ6eB1n 1bkZWpB4Wg0avUb26Qb2LeAGz5UAapqcLxHgHoPf+6/BR4HBUkmuFfi5SOtXZU2yA+jF a6Kg== X-Gm-Message-State: APjAAAUXwD04mHrGNj3D75TJ+XSIo03T499CZT922SkQs71fsIQ5QaGA rMsKp/XX+hkuvEjESFlJo5uQdlX29Zh6uLydFTw= X-Received: by 2002:a2e:91c5:: with SMTP id u5mr28381055ljg.65.1560241559914; Tue, 11 Jun 2019 01:25:59 -0700 (PDT) MIME-Version: 1.0 References: <20190610212015.9157-1-hch@lst.de> <20190610212015.9157-8-hch@lst.de> In-Reply-To: <20190610212015.9157-8-hch@lst.de> From: Geert Uytterhoeven Date: Tue, 11 Jun 2019 10:25:46 +0200 Message-ID: Subject: Re: [PATCH 07/15] binfmt_flat: use __be32 for the on-disk format To: Christoph Hellwig Cc: Greg Ungerer , Michal Simek , Linux ARM , linux-c6x-dev@linux-c6x.org, "moderated list:H8/300 ARCHITECTURE" , linux-m68k , linux-riscv@lists.infradead.org, Linux-sh list , linux-xtensa@linux-xtensa.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoph, On Mon, Jun 10, 2019 at 11:21 PM Christoph Hellwig wrote: > So far binfmt_flat has onl been supported on 32-bit platforms, so the > variable size of the fields didn't matter. But the upcoming RISC-V > nommu port supports 64-bit CPUs, and we now have a conflict between > the elf2flt creation tool that always uses 32-bit fields and the kernel > that uses (unsigned) long field. Switch to the userspace view as the > rest of the binfmt_flat format is completely architecture neutral, > and binfmt_flat isn't the right binary format for huge executables to > start with. > > While we're at it also ensure these fields are using __be types as > they big endian and are byteswapped when loaded. > > Signed-off-by: Christoph Hellwig > --- a/include/linux/flat.h > +++ b/include/linux/flat.h > @@ -67,19 +67,19 @@ struct flat_hdr { > #define OLD_FLAT_RELOC_TYPE_BSS 2 > > typedef union { > - unsigned long value; > + u32 value; > struct { > # if defined(mc68000) && !defined(CONFIG_COLDFIRE) > - signed long offset : 30; > - unsigned long type : 2; > + s32 offset : 30; > + u32 type : 2; > # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ > # elif defined(__BIG_ENDIAN_BITFIELD) > - unsigned long type : 2; > - signed long offset : 30; > + u32 type : 2; > + s32 offset : 30; > # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ > # elif defined(__LITTLE_ENDIAN_BITFIELD) > - signed long offset : 30; > - unsigned long type : 2; > + s32 offset : 30; > + u32 type : 2; > # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ The definitions of OLD_FLAT_FLAG_RAM are identical, so could be factored out. However, they appear to be unused. > # else > # error "Unknown bitfield order for flat files." Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds