Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp919549ybt; Fri, 26 Jun 2020 15:05:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyshcTboo/ZpdUiXxedMsszycv//7nSipdots0Bnv03vgeuwQsQjfZo6xL4drp70KnXsaj8 X-Received: by 2002:aa7:df08:: with SMTP id c8mr5533912edy.372.1593209142784; Fri, 26 Jun 2020 15:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593209142; cv=none; d=google.com; s=arc-20160816; b=K6jTaw+2Pe0tUCKN+EIdwfWNKpcDV1zbLYTRFva8WWMmToMz17R0PnkG+UxMys0L0B wk1JLhU1ydG8iOV2PXvW7XO/KJ7ZzC/r+Us1jXwcQMokKX+vnvqDKHDHeeB+Zl+8jz0S JNF6tg0aFVq043xHwG7hpbxV7+WIHGaa6uDwTJl5qhYi33M+AmYPwxmRWW4qkleYcju0 /HWdA8UkzQCkEmuKZhjohZzUJF13b8ykp38IT0RQL5/Ohp9prKnUMaR6inixAsD4qJLA T/3h5nRGHHWZDyT1d/o2gkPYW9/mQjBTgrP7mupuRMYqsx2WNyguhXNTtH15o0To8ChZ kN5g== 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=mVn/IGMjx4cc5gwW7/qDDK8qlX0wzi90o8+RDG48stc=; b=UNv/tcU7S+8Vl89rhaTrxkIlIZV4ixyhovSLMc9i2dIPqYi5svscZcDHG0xpECJ5ND WMPg4cnPXxCsj2m5MQ75+rWHo6MIrEHGwwQzAK1KmPjW2N5ix5WBhKU+x6fkhS3ivBX8 e4jYw50//K/qUV7jPAAguRKcDWquimhMhWBihh/ez7RQ1AOF7FAELjqAMf+a5hn1ZYqP vJzLTbbiC051Lvz2T74Y+8GK2SJopvmtO43k/DobIZwsMksrexlKIWYLo9SbCyLsHIIw IfXl3SGHloaEwJtGa3+u6FUuvIMEKB6d4j+Rg14bdd7Jr/Zc9qTvqB6wrI6D4Q+Il5WJ yS6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FJoUvBwf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si11710745edf.278.2020.06.26.15.05.19; Fri, 26 Jun 2020 15:05:42 -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=@kernel.org header.s=default header.b=FJoUvBwf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725965AbgFZWD7 (ORCPT + 99 others); Fri, 26 Jun 2020 18:03:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:45076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgFZWD7 (ORCPT ); Fri, 26 Jun 2020 18:03:59 -0400 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 631B02089D; Fri, 26 Jun 2020 22:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593209038; bh=WOQTvXobQ4W5JjaUMq7kWZE0jMQeOGk5MGW4rZFNYmQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FJoUvBwf+2SSHz2fr5vxPYd6aoefwHL0tlm86G/9+r8GmMcp2ZfwG8v/QP7defuDT D6lsId8SoNK8CT/QFVljdlp7a2LKRNtj3CK7eEWI766szCKWXBke3IKnvh4VpFJvxX DKoi6BJrlVFKVMovm4nd8G3e0rQBjBfAenxKjkPE= Received: by mail-oi1-f179.google.com with SMTP id k4so9332362oik.2; Fri, 26 Jun 2020 15:03:58 -0700 (PDT) X-Gm-Message-State: AOAM5308w1Yb/XT7UKtcwSKFIgbRW2pJ7IzRgfo6kYgCPCk6Xf5Ao4AX UZGQBxQW5rAu8k34QGjVdAF9JQLu2NuQ3QcpBUg= X-Received: by 2002:aca:ba03:: with SMTP id k3mr4145023oif.33.1593209037748; Fri, 26 Jun 2020 15:03:57 -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: Ard Biesheuvel Date: Sat, 27 Jun 2020 00:03:46 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 01/11] efi: Fix gcc error around __umoddi3 for 32 bit builds To: Atish Patra 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 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.