Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp913760ybt; Fri, 26 Jun 2020 14:56:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVp+Il65BJ/OYPYztPAhN6GFHJPbktoZRmHHTYJYtWvPhHFMtFk0bjdOGbjDM3NkJ9YfBO X-Received: by 2002:a17:906:19c9:: with SMTP id h9mr4212337ejd.526.1593208617980; Fri, 26 Jun 2020 14:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593208617; cv=none; d=google.com; s=arc-20160816; b=u3vjB81S2rp2h9CpszQBvM4552sH4YAJtlBjHKE8mUZqmgQpC+3iDecwIPaKWuGHgJ nRnLbzG4edAhVzNWaODcxfQKDEeaD2TObKyGHLp2yuVWELttDWLQwASmz3h8wFJL9HYm qmCLrUcs3/m6XPdlXKkAxiPZGmrlIcRpng300ysGmf8L95lQU+1y3ORchR+YerYI6+50 /N1/Q658/Z26N4Wmf7cqHY1VP9mj4Th5ck3kvk2VAg6/mY/OJGwsXW6fJ/VF7l2pXrdD 2/k+VzFoMMUD9ZV57V87ddNEPaz2ppR/H5MrDlR8usTZbhSa9VzE1WGNha7o/Ubtcjgd QCbQ== 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=s24mstSCNQlTFolgjec0iiKMpvfLNvCEazKvZzeEqpA=; b=oOExpT27BvMLxHuP5o4jXQW3bOAJ3438QJlfQC3y2IeMCMMjOQUHe4Q6/t3/UY2Gz4 sW5ATEmNTK9VCTV4GzmIUeec9dJlHMxIv8seDW1IvVES3feBjK8g5IYnZMVJ6v6AS4Y4 h2aZU60pgez2H6i6IJX+Qr4cTVDzodghEFaCQntIQ+A/4mYHy0h7YjQoNlh74ZR6NaX2 eRj5U2dfbFq1dxVjShNBQfoa9994IVmXfCD3yXjSw8IK8lwu+Sllnn0J/quIt3hDqNyZ r2KiLzLRX6HnQgo5oRCsHMBgPGXk7gEKqCUKforkaCNI8cciKbXqQHI5QXrDfgJNCSZ/ gMQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=g+CAS8Ul; 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 qt10si1455151ejb.196.2020.06.26.14.56.34; Fri, 26 Jun 2020 14:56:57 -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=g+CAS8Ul; 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 S1725971AbgFZV4Z (ORCPT + 99 others); Fri, 26 Jun 2020 17:56:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgFZV4Y (ORCPT ); Fri, 26 Jun 2020 17:56:24 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68364C03E979 for ; Fri, 26 Jun 2020 14:56:24 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id f18so10703797wml.3 for ; Fri, 26 Jun 2020 14:56:24 -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=s24mstSCNQlTFolgjec0iiKMpvfLNvCEazKvZzeEqpA=; b=g+CAS8UlAQOOsv4s7ohlbFkbJmOpPZq5OC7QRzoSqEzhhgE34Acd5sfrAMN8Uu9C3O WjP+DC/W4+0jp5qX9LvxioOw4eodRT/6RRpQpqrwVQ3/k7qf0G9GOfAGstoLym1Coe0G Xph832bBIMuzUv0udF9hevqW5Jxiwdj/IOadY= 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=s24mstSCNQlTFolgjec0iiKMpvfLNvCEazKvZzeEqpA=; b=ZGTvE0fwVM/HXWJllxb+9aAOXEPxDqj9y0V5fA6QYjxCBLEk2LwfhVZcpVTMUdcLM1 Z9rCAfvwBoXVExX5UIntLfkngGcW4esgaWD6wfaHV0CwmlwKXdkeCWEc8HoDVfd8lYcU MJD0oyzl3eIuJAspeCKadfrg9VQum/+6rwLAJ+gJGjwK0ZuWBX7OmiW+QDMJNbKZHlzd FioxLr/HRq50DCxvlNuUk3hIVKPJX6uVRiFKLY/UZmiOTGWLsR2RONfxTVW3JTYNlIhW sWRa6uTok1ECXUiRgSWNC3YnnhjiOIPWcJVy2FetMbIBI9pFcsvgv3FmNxTRlSYwtYRj tNEA== X-Gm-Message-State: AOAM532BYomoQAfIfe2waafqViW9EU/BTBK4V3oj25Us+BaDUb0+RJaR 1ClM769KUznm9fbv40Jg5jKQpPGY6Z40X8hvLa4l X-Received: by 2002:a1c:9d09:: with SMTP id g9mr5333593wme.31.1593208583105; Fri, 26 Jun 2020 14:56:23 -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: <5e2ce2ae-5458-8579-576a-76721f7d3b08@gmx.de> From: Atish Patra Date: Fri, 26 Jun 2020 14:56:11 -0700 Message-ID: Subject: Re: [RFC PATCH 01/11] efi: Fix gcc error around __umoddi3 for 32 bit builds To: Heinrich Schuchardt Cc: Atish Patra , "linux-kernel@vger.kernel.org List" , Ard Biesheuvel , 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 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. > Best regards > > Heinrich > > > > > if (l) { > > efi_bs_call(free_pages, alloc_addr, slack - l + 1); > > > -- Regards, Atish