Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3023942ybt; Mon, 29 Jun 2020 13:11:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyBSWR07ex6xw+9+YqfTnLLIDnBPdLRQaqsFoCprebFP6qlAKZV0dQKP+hGIAD/nBK5zz5 X-Received: by 2002:a17:906:7c07:: with SMTP id t7mr16018303ejo.487.1593461503114; Mon, 29 Jun 2020 13:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593461503; cv=none; d=google.com; s=arc-20160816; b=i3tZrr02plDB4ToeggfwpT4+YMavPH/W37wol5LTRnQq+NFX6pgqCsWAvHzI/UM0R/ +w6gTkMb8C6Z6kF/u+pOoyJXIfNtekZMyRMtb0ceCf/7vqHV22ialbf+d6iwfEGFzZ0W oMKZT8ZyoJFd5RyWVBuxjdajtCgr7+grMoLc0QMFmUAgCEhaOw4IWtlZhE08c6aWbD02 qEdx1pePraL8pfj39UrwMnyqAFP3U3EhwwfY1FP78ir/QoMV9V7O4PXOH9I9GthhiGQf G6gYYeIkzi9PPnSThXuQDkWB45D33Y6v2csMYRAJfgvvRkR+e0PvbaMHuWlv7pgdDStv QEgw== 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:dkim-signature; bh=DuXPs2KRc0kRkrIeNHomDGkRgeQMj5m4hx2hmqHrvd0=; b=Ul607TrtDid6mc3sXK96YwNaSJQwxomLxVU02895+sWn4tIn03vPheFovgnNWzh1JV Z8VBK/lKVDdo8E8q6PY1jaJPTqQKm4yeoZOl0EIAaHr/2Vmuf+xj37reZ8O8BtTGnBYv gJ6+jS8dI3vIb8ao74E6LrOttesB3dZfA0WuxuPR4XJJ+64StCYGuzm1+VXEgYrj3BZh NMnLL8R+6h/O5Ctl8fGNNobeMuwDItF91CLaEI2LFGKcocOvVyNFgdmfVtVFmuFMfH/D ZiH7BbTI0jWkdSjXWTi+PytgVdnaTQxigTV266VX9OCAJi5TLSG9ppk7HlsoLeu6op1E qZmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=RwCEbkr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si381743ejf.650.2020.06.29.13.11.19; Mon, 29 Jun 2020 13:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=RwCEbkr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbgF2UKO (ORCPT + 99 others); Mon, 29 Jun 2020 16:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728956AbgF2UKI (ORCPT ); Mon, 29 Jun 2020 16:10:08 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22517C03E979 for ; Mon, 29 Jun 2020 13:10:08 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id z15so6579023wrl.8 for ; Mon, 29 Jun 2020 13:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DuXPs2KRc0kRkrIeNHomDGkRgeQMj5m4hx2hmqHrvd0=; b=RwCEbkr7yIXMwaL6oCI6h3TFBrn9VLnCgp8TQCTIrSgyVQuzK7Iywclm3ny1C/A1j6 CiUUsHeusFGkR4ofBNlMT4xs3Kk14kgzfpLpcB8o5VTHHC+x3qfdunD/jM1rZKGu8j+1 HFbJcxtTP50PS+jYQqGKvl03Itsy8M6Zm5+f4= 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=DuXPs2KRc0kRkrIeNHomDGkRgeQMj5m4hx2hmqHrvd0=; b=chwb7zkz9NrlUyV8qi6WJhUbFzJMXJLqgu8Xh+xAzXfGSXdKvVSq/TaEB/Xfpl4u5e jE5ZODkf4Lr54aVAsJsbbs6gAYvRI9YvZl5u20YiMHDr+aSIbK/HtRAXRME9gTy1XMIm akFlV8/z9xFqxmB6PiWjEmmJOYrFDzYCtMc40OH9JCpAZ9Atbz+oz7Amhluje647tXQG 9DHB5iEPhHnxrE+ludAYw2L73Jxyn9oCOXcQ4jfir7dsapEyBpypqs1Qp9cu0fBri3zM BHWM/Kpi0nNM2SotEs0WBKkDTkAqSY+DJ+2ehtSIuQYVNGNplVWJL3yGVn5vRQkfHu+A XTNQ== X-Gm-Message-State: AOAM533JvMq240xqxGHoiKkWh/GRAJNy80Y/rrxeKJ9RNcweOgrfTf6D Uea0TmISGIYNqnJmYkRwr2GRn6WTw6EG7m0s55hf X-Received: by 2002:adf:e884:: with SMTP id d4mr17770822wrm.176.1593461406779; Mon, 29 Jun 2020 13:10:06 -0700 (PDT) MIME-Version: 1.0 References: <20200625234516.31406-1-atish.patra@wdc.com> <20200625234516.31406-2-atish.patra@wdc.com> <5e2ce2ae-5458-8579-576a-76721f7d3b08@gmx.de> In-Reply-To: From: Atish Patra Date: Mon, 29 Jun 2020 13:09:55 -0700 Message-ID: Subject: Re: [RFC PATCH 01/11] efi: Fix gcc error around __umoddi3 for 32 bit builds To: Ard Biesheuvel Cc: Heinrich Schuchardt , Atish Patra , "linux-kernel@vger.kernel.org List" , linux-efi , linux-riscv , Masahiro Yamada , Palmer Dabbelt , "linux-arm-kernel@lists.infradead.org" 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 Sat, Jun 27, 2020 at 2:22 AM Ard Biesheuvel wrote: > > On Sat, 27 Jun 2020 at 00:03, Ard Biesheuvel wrote: > > > > On Fri, 26 Jun 2020 at 23:56, Atish Patra wrote: > > > > > > On Thu, Jun 25, 2020 at 7:43 PM Heinrich Schuchardt wrote: > > > > > > > > On 6/26/20 1:45 AM, Atish Patra wrote: > > > > > 32bit gcc doesn't support modulo operation on 64 bit data. It results in > > > > > a __umoddi3 error while building EFI for 32 bit. > > > > > > > > > > Use bitwise operations instead of modulo operations to fix the issue. > > > > > > > > > > Signed-off-by: Atish Patra > > > > > --- > > > > > drivers/firmware/efi/libstub/alignedmem.c | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/firmware/efi/libstub/alignedmem.c b/drivers/firmware/efi/libstub/alignedmem.c > > > > > index cc89c4d6196f..1de9878ddd3a 100644 > > > > > --- a/drivers/firmware/efi/libstub/alignedmem.c > > > > > +++ b/drivers/firmware/efi/libstub/alignedmem.c > > > > > @@ -44,7 +44,7 @@ efi_status_t efi_allocate_pages_aligned(unsigned long size, unsigned long *addr, > > > > > *addr = ALIGN((unsigned long)alloc_addr, align); > > > > > > > > > > if (slack > 0) { > > > > > - int l = (alloc_addr % align) / EFI_PAGE_SIZE; > > > > > + int l = (alloc_addr & (align - 1)) / EFI_PAGE_SIZE; > > > > > > > > Here you rely on the compiler to silently convert the division by > > > > EFI_PAGE_SIZE into a right shift. Wouldn't it be cleaner to use > > > > EFI_PAGE_SHIFT to explicitly avoid a dependency on __udivdi3()? > > > > > > > > slack = (align >> EFI_PAGE_SHIFT) - 1; > > > > ... > > > > int l = (alloc_addr & (align - 1)) >> EFI_PAGE_SHIFT; > > > > > > > > > > Sure. I will update it in the next version. Thanks for the suggestion. > > > > Please don't. Dividing by EFI_PAGE_SIZE is perfectly fine, and is more readable. > > Actually, I will take this patch as a fix right away - 32-bit ARM has > the same issue (although it does not actually incorporate this object > file) > Thanks. I will drop it from my next version in that case. > In the meantime, please check how the stub gets pulled into your > kernel: the idea of a static library is that only the objects that are > used are included in the final build, but this turned out to be broken > for arm64 [0]. IOW, simply applying a similar change might fix your > build issue as well (assuming RISC-V does not actually call > efi_allocate_pages_aligned() anywhere) > Sorry. I missed this thread earlier. Yes. Applying a similar change fixes the static library linking for RISC-V. I don't see efi_allocate_pages_aligned or efi_random_alloc in vmlinux anymore. I will update my patch. Thanks. I did not see any new version of the next patch in that series [1]. Thus, I am leaving libstub/Makefile changes as it is. Please let me know if I missed something. [1] https://lore.kernel.org/linux-efi/CAMj1kXGg-w6N7jyG0pBJmeRctAhG2wWGoU=ryWj+Qi2UH-_m9Q@mail.gmail.com/ > [0] https://lore.kernel.org/linux-arm-kernel/20200604022031.164207-1-masahiroy@kernel.org/ -- Regards, Atish