From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B540C433ED for ; Wed, 21 Apr 2021 16:29:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2A466140F for ; Wed, 21 Apr 2021 16:29:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2A466140F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=y9AAr4VwY51thUDstp46a7WUJvEMD/5pMQ8kr/x09xs=; b=NM4zuhjra2ojkbnt63CRlzB1Y 1GhT6ZgRsOhgxmo8If1zIQQiS4TR/nL7r1FH7ayIHCr7CGIqcvSpE+RBftzx3W8+tFd3qpo3gRWUl /+BDVni/na4TTWpnbeAXKOMb3fHj63OZ32sQ5rq2oEArU4urxvRgT8lv4YuiPJCkhn+Yke9bkKrsK lD8TOjF0bJg6mA+e6RBzfXPEyJv79w9Tt/4tBKlevn3Y/018ZWEnx0esiwuolr+Lo2b8N3E3Rlvy2 hWR3inC8ZJZAtTgOYsgAOOoY/TGAcC2qSzvcVzN86DwzdrhcXRe+Zn/5wwGq28agvy8cAjKJG75Kl rdyyAqTbg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZFhs-00Ek7w-KR; Wed, 21 Apr 2021 16:28:04 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZFho-00Ek70-Tm for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 16:28:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SmfHH6hIJqwyK5X8i5q3Sks3m+nCGH0WqXp+KsNmUL8=; b=JWxGGOTnonn2DDYxXW8b9miC/1 5blthlRwLHisCwS6IUinV+lvGx3AcqYoz3Shiy2z1cTFlMS3zWi1Ed2cESy9UxwCBmy2yrWeRkUNb O17jhigRVP06qimgNsLsXKfMrWpA0h/Y+AoeJDKaA/NmcBhdju/qixOZRIonfpkFuuhgE2V9ilEgb nnSXcqda3LL5+5Ca5nL8A483YbR5aFFXOwJHNgXJGJmBSlw+JHiNgpVaSXT4iaizE2qV7HP9ArWF9 UQhEs+7SnCRYgjqZcT3PGs/Dx2JCwD3T9ooxzo1FdN33ihkgdDBtFn4/v0+Ov3CDSmaUP2YoZDVnn GMXv7d1g==; Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZFhj-00D1hL-NU for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 16:27:59 +0000 Received: by mail-wm1-x32a.google.com with SMTP id n10-20020a05600c4f8ab0290130f0d3cba3so2887461wmq.1 for ; Wed, 21 Apr 2021 09:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SmfHH6hIJqwyK5X8i5q3Sks3m+nCGH0WqXp+KsNmUL8=; b=DXNQF6+X23W/5T4j3zpPuPMt02MDsg03lPN+3HSFpoY2UlMTCml7AhmoyozG0E2Q39 qk4NKcw6Mkbji1CoIrq497pJKaqywM/s/l0rqIZr+LR2Ec3BQIYPhHmgyPt1x9kQtKIg JV/RQ+1kCUHhV5WmXHyA0TQYDDBelvBNectYOsf8uCeauDfYl+EOu+xu6qLuh+dCmx6J xVOMVqOOu0T09Zh/akTZDXfT3iuYRkCZhFRBgHZnvQkd2HyWEnbCX99Pji/MzbFswFFj k63kG+iYhk8Fqo8XMDKsLmlKFxAXe4pOmXzDIUAqRHaa7nIBfRgSGDwzBmtreIbzqn4r y0pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SmfHH6hIJqwyK5X8i5q3Sks3m+nCGH0WqXp+KsNmUL8=; b=nHJvSdWymwpgA5xBS1N1Dupbx+oTvrc0x2nCaFKUvPB1nfNADVNBHxy0YMLnpn5yln bRilZXyOCUH0SQZGvg0p4Dd2CKNHpqPim2XS/nOF9I9qc+jAL8KsPtAMpiTWafaQ6upr OrfE26NXvQdRfVSYu+a0TFfmB07ht9vg5JQZs4mB70P3jsJThfBnfZbWRZLMobal/Mq/ tPCPs8pEr5s3hNZVpB04YKAlRTxbWlON3geOmAODWv0+fes6zqG932AF01z3b59Z6vhq SfWnP18QmzgSOl3meXawNsr3m4UxqG0ww7e5FlIRsZHe+MRLPZcj4M/3nPoehchgL9GD UhZQ== X-Gm-Message-State: AOAM533BsNzpa6fngdxhKI9b3p+wfAEyKwbVXQWuRyxF3WGyBLu7mjno mB7X3p5eAZ3HG6maPmHsoJdB+w== X-Google-Smtp-Source: ABdhPJws9ys5bphkU3GPm/kXkaoFkOzDHxBDE6IlGGSz8bHo2vzb71zyUPD73s4ZA5mj9uvFsZMMCA== X-Received: by 2002:a1c:7f16:: with SMTP id a22mr10182034wmd.17.1619022473891; Wed, 21 Apr 2021 09:27:53 -0700 (PDT) Received: from elver.google.com ([2a00:79e0:15:13:c552:ee7c:6a14:80cc]) by smtp.gmail.com with ESMTPSA id f23sm2803158wmf.37.2021.04.21.09.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 09:27:52 -0700 (PDT) Date: Wed, 21 Apr 2021 18:27:47 +0200 From: Marco Elver To: Marek Szyprowski Cc: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Ingo Molnar , Jiri Olsa , Mark Rutland , Namhyung Kim , Thomas Gleixner , Alexander Potapenko , Al Viro , Arnd Bergmann , Christian Brauner , Dmitry Vyukov , Jann Horn , Jens Axboe , Matt Morehouse , Peter Collingbourne , Ian Rogers , Oleg Nesterov , kasan-dev , linux-arch , linux-fsdevel , LKML , the arch/x86 maintainers , "open list:KERNEL SELFTEST FRAMEWORK" , Geert Uytterhoeven , Bartlomiej Zolnierkiewicz , Linux ARM , linux-tegra@vger.kernel.org, jonathanh@nvidia.com Subject: Re: [PATCH v4 05/10] signal: Introduce TRAP_PERF si_code and si_perf to siginfo Message-ID: References: <1fbf3429-42e5-0959-9a5c-91de80f02b6a@samsung.com> <43f8a3bf-34c5-0fc9-c335-7f92eaf23022@samsung.com> <740077ce-efe1-b171-f807-bc5fd95a32ba@samsung.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_092755_818496_E5C65B67 X-CRM114-Status: GOOD ( 27.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 21, 2021 at 05:11PM +0200, Marco Elver wrote: > +Cc linux-arm-kernel > [...] > > > > I've managed to reproduce this issue with a public Raspberry Pi OS Lite > > rootfs image, even without deploying kernel modules: > > > > https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-03-25/2021-03-04-raspios-buster-armhf-lite.zip > > > > # qemu-system-arm -M virt -smp 2 -m 512 -kernel zImage -append "earlycon > > console=ttyAMA0 root=/dev/vda2 rw rootwait" -serial stdio -display none > > -monitor null -device virtio-blk-device,drive=virtio-blk -drive > > file=/tmp/2021-03-04-raspios-buster-armhf-lite.img,id=virtio-blk,if=none,format=raw > > -netdev user,id=user -device virtio-net-device,netdev=user > > > > The above one doesn't boot if zImage z compiled from commit fb6cc127e0b6 > > and boots if compiled from 2e498d0a74e5. In both cases I've used default > > arm/multi_v7_defconfig and > > gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabi toolchain. > > Yup, I've narrowed it down to the addition of "__u64 _perf" to > siginfo_t. My guess is the __u64 causes a different alignment for a > bunch of adjacent fields. It seems that x86 and m68k are the only ones > that have compile-time tests for the offsets. Arm should probably add > those -- I have added a bucket of static_assert() in > arch/arm/kernel/signal.c and see that something's off. > > I'll hopefully have a fix in a day or so. Arm and compiler folks: are there some special alignment requirement for __u64 on arm 32-bit? (And if there is for arm64, please shout as well.) With the static-asserts below, the only thing that I can do to fix it is to completely remove the __u64. Padding it before or after with __u32 just does not work. It seems that the use of __u64 shifts everything in __sifields by 4 bytes. diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h index d0bb9125c853..b02a4ac55938 100644 --- a/include/uapi/asm-generic/siginfo.h +++ b/include/uapi/asm-generic/siginfo.h @@ -92,7 +92,10 @@ union __sifields { __u32 _pkey; } _addr_pkey; /* used when si_code=TRAP_PERF */ - __u64 _perf; + struct { + __u32 _perf1; + __u32 _perf2; + } _perf; }; } _sigfault; ^^ works, but I'd hate to have to split this into 2 __u32 because it makes the whole design worse. What alignment trick do we have to do here to fix it for __u64? ------ >8 ------ diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index a3a38d0a4c85..6c558dc314c3 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -725,3 +725,41 @@ asmlinkage void do_rseq_syscall(struct pt_regs *regs) rseq_syscall(regs); } #endif + +/* + * Compile-time tests for siginfo_t offsets. Changes to NSIG* likely come with + * new fields; new fields should be added below. + */ +static_assert(NSIGILL == 11); +static_assert(NSIGFPE == 15); +static_assert(NSIGSEGV == 9); +static_assert(NSIGBUS == 5); +static_assert(NSIGTRAP == 6); +static_assert(NSIGCHLD == 6); +static_assert(NSIGSYS == 2); +static_assert(offsetof(siginfo_t, si_signo) == 0x00); +static_assert(offsetof(siginfo_t, si_errno) == 0x04); +static_assert(offsetof(siginfo_t, si_code) == 0x08); +static_assert(offsetof(siginfo_t, si_pid) == 0x0c); +#if 0 +static_assert(offsetof(siginfo_t, si_uid) == 0x10); +static_assert(offsetof(siginfo_t, si_tid) == 0x0c); +static_assert(offsetof(siginfo_t, si_overrun) == 0x10); +static_assert(offsetof(siginfo_t, si_status) == 0x14); +static_assert(offsetof(siginfo_t, si_utime) == 0x18); +static_assert(offsetof(siginfo_t, si_stime) == 0x1c); +static_assert(offsetof(siginfo_t, si_value) == 0x14); +static_assert(offsetof(siginfo_t, si_int) == 0x14); +static_assert(offsetof(siginfo_t, si_ptr) == 0x14); +static_assert(offsetof(siginfo_t, si_addr) == 0x0c); +static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x10); +static_assert(offsetof(siginfo_t, si_lower) == 0x14); +static_assert(offsetof(siginfo_t, si_upper) == 0x18); +static_assert(offsetof(siginfo_t, si_pkey) == 0x14); +static_assert(offsetof(siginfo_t, si_perf) == 0x10); +static_assert(offsetof(siginfo_t, si_band) == 0x0c); +static_assert(offsetof(siginfo_t, si_fd) == 0x10); +static_assert(offsetof(siginfo_t, si_call_addr) == 0x0c); +static_assert(offsetof(siginfo_t, si_syscall) == 0x10); +static_assert(offsetof(siginfo_t, si_arch) == 0x14); +#endif _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel