Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1935614ybi; Thu, 4 Jul 2019 02:20:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxI3zwo4ZSCkiWdd/vf58Gd0U8uMrHdaiNISlU1uvGN3zBjdHQz5EhnYiY/fWXnL0/KJsA4 X-Received: by 2002:a63:4518:: with SMTP id s24mr43255184pga.123.1562232007979; Thu, 04 Jul 2019 02:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562232007; cv=none; d=google.com; s=arc-20160816; b=WmuC9VBlSlz5jPhfOzHBQgLsxOCzPPuxxiBdQ1b1utIwSbaDpMkCpIA8eNIXBIjuuQ Js2YJr1s/G/xjGQ+JcGRE6fygyzBS0h4RRS+6HnSNbojvZaj9O0BCprd0MIxUtKwOS4j lXx8HXrFU8LJDp1FRUWWBnxkuNbTndhmaFqhUyETcB1we31bCgBbNSzMOygCCy1dojoL 0H51JMyhyAVj6yGlHPtHhJcwwd1RBBwZXUb7gVrTQabPLP7ezZImm6iUR0iqQKcQqQ8M kdV7iBfhEv/fKZ3F+TkGRDbZ+3CWLoz0gtPyyMEKX23lgpxsH/yLi68CEEa+Q5RBFQGs STUQ== 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=UU1LRzgJ9KtlIamPG1rpTOdBbiRt377kXD3IRu4KTEc=; b=00s2OUPXzG19vymUYrpvqQReqt5Q665dxQIe2aqhS0PK+SQt/0sLcA+XZTtp9XeRlY nzXGKirPh/Na7HVTpPOXqjNzbJJVOnV9ma9VlHakJnE3muSgrSYRCZ9933DWKJ7zn5ki BRAhe3ad8EE1an4v/VHwZhmE6Ee9ZgI41R8ytJii52HOYVQG/WfyWUhM3dIizIGOU4C+ MgEFKp7jemqeXoGKSpZHPt/8jSmZHAc1nnfYHw237nli/LsWdPsek0GpK6G8OtZlCzGu XQwWt4LL97+3qhtJWyhVEuRufFJ9mTTZZiARfv4Ho5jLjJ+DGGCWurT3LvTlHwIL4YrX uznQ== 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 g24si4994681pgj.197.2019.07.04.02.19.52; Thu, 04 Jul 2019 02:20:07 -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 S1727275AbfGDJTb (ORCPT + 99 others); Thu, 4 Jul 2019 05:19:31 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:33614 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727147AbfGDJTa (ORCPT ); Thu, 4 Jul 2019 05:19:30 -0400 Received: by mail-qt1-f194.google.com with SMTP id h24so7378782qto.0 for ; Thu, 04 Jul 2019 02:19:30 -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=UU1LRzgJ9KtlIamPG1rpTOdBbiRt377kXD3IRu4KTEc=; b=WgiZHTN9qZ6nFhuCUpG2LVjkyW3WX5VDZn4TPjBad3pSSXROgjqBp1RCASoCNesZKM uKmDqEW+/vZyuouz5O1CbpKmDHpq7hwd6G9I6i2VnFgXheNpwr9VuM67k6yFhqS0Nxda t2kkB3GVbtz+tlKxd6aKOBM6sI/DHcRznSwyXPHaPQNeW+V20ZId5LiEchdeyP4HD4G1 InWh36VgRRFtPKRVPfxoBRTv+5IP97KvQb05+UqZAbKjaFQNWzavpl17tDkOP69sL4N+ bvPgwVWmrywkbqOZJytsNfl27XaLTd+7vrR23siorcjR2VjOb8K5CZfzRiBxsakmIHY7 y7UA== X-Gm-Message-State: APjAAAWwpLPfQQ9zlqsA41v6erOc3/EE5CD3kwd9KJJf2ylWTgpDDKxg suJPIJdFEdA4dl8tboiStjZYPys6Dx/MghUj62wk8IhE34o= X-Received: by 2002:aed:3363:: with SMTP id u90mr2705494qtd.7.1562231969777; Thu, 04 Jul 2019 02:19:29 -0700 (PDT) MIME-Version: 1.0 References: <20190703005202.7578-1-alistair.francis@wdc.com> In-Reply-To: From: Arnd Bergmann Date: Thu, 4 Jul 2019 11:19:13 +0200 Message-ID: Subject: Re: [PATCH RESEND 0/2] RISC-V: Handle the siginfo_t offset problem To: Andreas Schwab Cc: Alistair Francis , Alistair Francis , linux-riscv@lists.infradead.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 On Thu, Jul 4, 2019 at 9:20 AM Andreas Schwab wrote: > > On Jul 03 2019, Alistair Francis wrote: > > > On Wed, Jul 3, 2019 at 12:08 AM Andreas Schwab wrote: > >> > >> On Jul 02 2019, Alistair Francis wrote: > >> > >> > In the RISC-V 32-bit glibc port [1] the siginfo_t struct in the kernel > >> > doesn't line up with the struct in glibc. In glibc world the _sifields > >> > union is 8 byte alligned (although I can't figure out why) > >> > >> Try ptype/o in gdb. > > > > That's a useful tip, I'll be sure to use that next time. > > It was a serious note. If the structs don't line up then there is a > mismatch in types that cannot be solved by adding spurious padding. You > need to fix the types instead. Would it be an option to align all the basic typedefs (off_t, time_t, clock_t, ...) between glibc and kernel then, and just use the existing sysdeps/unix/sysv/linux/generic/bits/typesizes.h after all to avoid surprises like this? As of v2 the functional difference is -#define __INO_T_TYPE __ULONGWORD_TYPE +#define __INO_T_TYPE __UQUAD_TYPE #define __INO64_T_TYPE __UQUAD_TYPE #define __MODE_T_TYPE __U32_TYPE -#define __NLINK_T_TYPE __U32_TYPE -#define __OFF_T_TYPE __SLONGWORD_TYPE +#define __NLINK_T_TYPE __UQUAD_TYPE +#define __OFF_T_TYPE __SQUAD_TYPE #define __OFF64_T_TYPE __SQUAD_TYPE -#define __RLIM_T_TYPE __ULONGWORD_TYPE +#define __RLIM_T_TYPE __UQUAD_TYPE #define __RLIM64_T_TYPE __UQUAD_TYPE -#define __BLKCNT_T_TYPE __SLONGWORD_TYPE +#define __BLKCNT_T_TYPE __SQUAD_TYPE #define __BLKCNT64_T_TYPE __SQUAD_TYPE -#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE +#define __FSBLKCNT_T_TYPE __UQUAD_TYPE #define __FSBLKCNT64_T_TYPE __UQUAD_TYPE -#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE +#define __FSFILCNT_T_TYPE __UQUAD_TYPE #define __FSFILCNT64_T_TYPE __UQUAD_TYPE -#define __FSWORD_T_TYPE __SWORD_TYPE +#define __FSWORD_T_TYPE __SQUAD_TYPE -#define __CLOCK_T_TYPE __SLONGWORD_TYPE -#define __TIME_T_TYPE __SLONGWORD_TYPE +#define __CLOCK_T_TYPE __SQUAD_TYPE +#define __TIME_T_TYPE __SQUAD_TYPE #define __USECONDS_T_TYPE __U32_TYPE -#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __SUSECONDS_T_TYPE __SQUAD_TYPE -#define __BLKSIZE_T_TYPE __S32_TYPE +#define __BLKSIZE_T_TYPE __SQUAD_TYPE #define __FSID_T_TYPE struct { int __val[2]; } #define __SSIZE_T_TYPE __SWORD_TYPE -#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE -#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE -#define __CPU_MASK_TYPE __ULONGWORD_TYPE +#define __SYSCALL_SLONG_TYPE __SQUAD_TYPE +#define __SYSCALL_ULONG_TYPE __UQUAD_TYPE +#define __CPU_MASK_TYPE __UQUAD_TYPE -#ifdef __LP64__ # define __RLIM_T_MATCHES_RLIM64_T 1 -#else -# define __RLIM_T_MATCHES_RLIM64_T 0 -#endif +#define __ASSUME_TIME64_SYSCALLS 1 +#define __ASSUME_RLIM64_SYSCALLS 1 Since the sysdeps/unix/sysv/linux/generic/bits/typesizes.h definitions generally match the kernel, anything diverging from that has the potential of breaking it, so the difference should probably be kept to the absolute minimum. I think these ones are wrong and will cause bugs similar to the clock_t issue if they are used with kernel interfaces: __NLINK_T_TYPE, __FSWORD_T_TYPE, __CLOCK_T_TYPE, __BLKSIZE_T_TYPE, __SYSCALL_ULONG_TYPE, __SYSCALL_SLONG_TYPE, __CPU_MASK_TYPE These are fine as long as they are only used in user space and to wrap kernel syscalls, but I think most of them can end up being passed to the kernel, so it seems safer not to have rv32 diverge without a good reason. The remaining ones (__INO_T_TYPE, __OFF_T_TYPE, __BLKCNT_T_TYPE, __FSBLKCNT_T_TYPE, __FSFILCNT_T_TYPE, __TIME_T_TYPE) all follow the pattern where the kernel has an old 32-bit type and a new 64-bit type, but the kernel tries not to expose the 32-bit interfaces to user space on new architectures and only provide the 64-bit replacements, but there are a couple of interfaces that never got replaced, typically in driver and file system ioctls. Since glibc already has code to deal with the 64-bit types and that is well tested, it would seem safer to me to just #undef the old types completely rather than defining them to 64-bit, which would make them incompatible with the kernel's types. Arnd