From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 1DA39A0A0C;
	Fri,  7 May 2021 20:50:27 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id D51674013F;
	Fri,  7 May 2021 20:50:26 +0200 (CEST)
Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com
 [209.85.210.52]) by mails.dpdk.org (Postfix) with ESMTP id B80B04013F
 for <dev@dpdk.org>; Fri,  7 May 2021 20:50:25 +0200 (CEST)
Received: by mail-ot1-f52.google.com with SMTP id
 u25-20020a0568302319b02902ac3d54c25eso8776582ote.1
 for <dev@dpdk.org>; Fri, 07 May 2021 11:50:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=mSbVEpNbyuZgN6n/avsYk5YewAyqNYvhFpOo6ordMSc=;
 b=IrkLkZH+nRI22lH6k6eF6bFfc3qwlGXrUW4eAHNvEDnhqtVahwK4kOVXoTK8S3WPN0
 rqp03SGK59AzFkX1zWN+qdqiXplsbOVvu9A9L+Yxl3vnpI3heAZTk8WBnQUGoUTTIeuO
 vyzRYwzNN8XLYA4s1KOxHEeg35TDhLc0vklUo=
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=mSbVEpNbyuZgN6n/avsYk5YewAyqNYvhFpOo6ordMSc=;
 b=Nn2RhA5A7XUUoQrChrwWCCJa+Ou9gy5M3Sr+AP+Af5s4x0qHLHQBc2/YZtC3f/3BeZ
 sNK6NKZW/XQPTYo3StfhSxo7Ged+xoFrLgwGBFZTOQMrsloSxWHpSBw01lv0lknq9Apw
 V2T/PhQssJeU+LxgU7yDY+vOM4Sdn7jTZoDMxXeS852gVoY3vxEwK6MBE5tHT1wA5s51
 ocY3SLcxkd2yQTB7jqD6iWBy37rNwmWrrvvJvE+9WIkui5CZkBxhYdbYhty/Vc4t3WtD
 o3zqtX1A1EsAGXkT1ZqfFNAmazzZeQNLu7HDieIMWkvIc4qfJabx/T2FqgNcj3ufuuL9
 VBAg==
X-Gm-Message-State: AOAM533HCbuPKpCF6oSRuCU19jlYsIKGe3Mii1oYP8Wcsdb9DdFXEu6H
 rLysC6dmHnGe/oCttAIyeuQ9f2+ycRRB0EByOPWd6g==
X-Google-Smtp-Source: ABdhPJwWkDP3eOP9Y7bdZOINj+DI+9zFz8Z6ttzhgfRhMEwDM1vwLynqRa8BLEbrAurBHgrA0PLDKJpFhtv4E4bd7eI=
X-Received: by 2002:a9d:6b85:: with SMTP id b5mr9245581otq.172.1620413424994; 
 Fri, 07 May 2021 11:50:24 -0700 (PDT)
MIME-Version: 1.0
References: <20210507181025.84012-1-lance.richardson@broadcom.com>
In-Reply-To: <20210507181025.84012-1-lance.richardson@broadcom.com>
From: Lance Richardson <lance.richardson@broadcom.com>
Date: Fri, 7 May 2021 14:50:14 -0400
Message-ID: <CADyeNECkwnsu6510b8cO2ALHMCNXuddJNr0fv+A8ytrFLtzsUA@mail.gmail.com>
To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>, 
 Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
 Dmitry Malloy <dmitrym@microsoft.com>, 
 Pallavi Kadam <pallavi.kadam@intel.com>
Cc: dev@dpdk.org, dpdk stable <stable@dpdk.org>
Content-Type: multipart/signed; protocol="application/pkcs7-signature";
 micalg=sha-256; boundary="0000000000009b6e6f05c1c1e675"
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
Subject: Re: [dpdk-dev] [PATCH] eal: fix memory mapping for 32-bit targets
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

--0000000000009b6e6f05c1c1e675
Content-Type: text/plain; charset="UTF-8"

On Fri, May 7, 2021 at 2:10 PM Lance Richardson
<lance.richardson@broadcom.com> wrote:
>
> For 32-bit targets, size_t is normally a 32-bit type and
> does not have sufficient range to represent 64-bit offsets
> that can are needed when mapping PCI addresses. Use off_t
> instead, which is usually a 64-bit type when compiled with
> _D_FILE_OFFSET_BITS=64 as is the case for DPDK.
>
> Found when attempting to run 32-bit Linux dpdk-testpmd
> using VFIO driver:
>
>     EAL: pci_map_resource(): cannot map resource(63, 0xc0010000, \
>     0x200000, 0x20000000000): Invalid argument ((nil))
>
> Fixes: c4b89ecb64ea ("eal: introduce memory management wrappers")
> Cc: stable@dpdk.org
> Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
> ---
>  lib/eal/include/rte_eal_paging.h |  2 +-
>  lib/eal/unix/eal_unix_memory.c   | 10 +++++-----
>  lib/eal/windows/eal_memory.c     |  2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/lib/eal/include/rte_eal_paging.h b/lib/eal/include/rte_eal_paging.h
> index ed98e70e9e..2c05025ffc 100644
> --- a/lib/eal/include/rte_eal_paging.h
> +++ b/lib/eal/include/rte_eal_paging.h
> @@ -61,7 +61,7 @@ enum rte_map_flags {
>  __rte_internal
>  void *
>  rte_mem_map(void *requested_addr, size_t size, int prot, int flags,
> -       int fd, size_t offset);
> +       int fd, off_t offset);
>
>  /**
>   * OS-independent implementation of POSIX munmap(3).
> diff --git a/lib/eal/unix/eal_unix_memory.c b/lib/eal/unix/eal_unix_memory.c
> index ec7156df96..51a42e1a43 100644
> --- a/lib/eal/unix/eal_unix_memory.c
> +++ b/lib/eal/unix/eal_unix_memory.c
> @@ -24,14 +24,14 @@
>
>  static void *
>  mem_map(void *requested_addr, size_t size, int prot, int flags,
> -       int fd, size_t offset)
> +       int fd, off_t offset)
>  {
>         void *virt = mmap(requested_addr, size, prot, flags, fd, offset);
>         if (virt == MAP_FAILED) {
>                 RTE_LOG(DEBUG, EAL,
> -                       "Cannot mmap(%p, 0x%zx, 0x%x, 0x%x, %d, 0x%zx): %s\n",
> -                       requested_addr, size, prot, flags, fd, offset,
> -                       strerror(errno));
> +                       "Cannot mmap(%p, 0x%zx, 0x%x, 0x%x, %d, 0x%llx): %s\n",
> +                       requested_addr, size, prot, flags, fd,
> +                       (unsigned long long)offset, strerror(errno));
>                 rte_errno = errno;
>                 return NULL;
>         }
> @@ -106,7 +106,7 @@ mem_rte_to_sys_prot(int prot)
>
>  void *
>  rte_mem_map(void *requested_addr, size_t size, int prot, int flags,
> -       int fd, size_t offset)
> +       int fd, off_t offset)
>  {
>         int sys_flags = 0;
>         int sys_prot;
> diff --git a/lib/eal/windows/eal_memory.c b/lib/eal/windows/eal_memory.c
> index 2cf5a5e649..f1c4b03e96 100644
> --- a/lib/eal/windows/eal_memory.c
> +++ b/lib/eal/windows/eal_memory.c
> @@ -508,7 +508,7 @@ eal_mem_set_dump(void *virt, size_t size, bool dump)
>
>  void *
>  rte_mem_map(void *requested_addr, size_t size, int prot, int flags,
> -       int fd, size_t offset)
> +       int fd, off_t offset)
>  {
>         HANDLE file_handle = INVALID_HANDLE_VALUE;
>         HANDLE mapping_handle = INVALID_HANDLE_VALUE;
> --
> 2.25.1
>

Windows compilation is failing in CI, apparently Windows doesn't
understand "off_t".

Should we add an "rte_off_t" definition for non-POSIX portability?

--0000000000009b6e6f05c1c1e675--