DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Lance Richardson <lance.richardson@broadcom.com>
Cc: 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>,
	dev@dpdk.org, stable@dpdk.org, anatoly.burakov@intel.com
Subject: Re: [dpdk-dev] [PATCH v3] eal: fix memory mapping for 32-bit targets
Date: Mon, 10 May 2021 14:42:22 +0200	[thread overview]
Message-ID: <2003089.4ItjxMFgZf@thomas> (raw)
In-Reply-To: <20210508142753.114343-1-lance.richardson@broadcom.com>

+Cc Anatoly

08/05/2021 16:27, Lance Richardson:
> 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 uint64_t
> instead.
> 
> 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>
> ---
> v3: Use PRIx64 instead of llx to format offset in log message.
> v2: Use uint64_t instead of off_t (off_t is unknown to Windows).
> 
>  lib/eal/include/rte_eal_paging.h |  2 +-
>  lib/eal/unix/eal_unix_memory.c   | 11 ++++++-----
>  lib/eal/windows/eal_memory.c     |  2 +-
>  3 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/eal/include/rte_eal_paging.h b/lib/eal/include/rte_eal_paging.h
> index ed98e70e9e..c60317d0f5 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, uint64_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..68ae93bd6e 100644
> --- a/lib/eal/unix/eal_unix_memory.c
> +++ b/lib/eal/unix/eal_unix_memory.c
> @@ -5,6 +5,7 @@
>  #include <string.h>
>  #include <sys/mman.h>
>  #include <unistd.h>
> +#include <inttypes.h>
>  
>  #include <rte_eal_paging.h>
>  #include <rte_errno.h>
> @@ -24,14 +25,14 @@
>  
>  static void *
>  mem_map(void *requested_addr, size_t size, int prot, int flags,
> -	int fd, size_t offset)
> +	int fd, uint64_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%"PRIx64"): %s\n",
> +		    requested_addr, size, prot, flags, fd, offset,
> +		    strerror(errno));
>  		rte_errno = errno;
>  		return NULL;
>  	}
> @@ -106,7 +107,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, uint64_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..4db048ccb5 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, uint64_t offset)
>  {
>  	HANDLE file_handle = INVALID_HANDLE_VALUE;
>  	HANDLE mapping_handle = INVALID_HANDLE_VALUE;
> 






  reply	other threads:[~2021-05-10 12:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 18:10 [dpdk-dev] [PATCH] " Lance Richardson
2021-05-07 18:50 ` Lance Richardson
2021-05-07 18:55   ` Lance Richardson
2021-05-07 19:06 ` [dpdk-dev] [PATCH v2] " Lance Richardson
2021-05-07 20:51   ` Dmitry Kozlyuk
2021-05-07 21:35     ` Lance Richardson
2021-05-08 14:12 ` [dpdk-dev] [PATCH] " Lance Richardson
2021-05-08 14:27 ` [dpdk-dev] [PATCH v3] " Lance Richardson
2021-05-10 12:42   ` Thomas Monjalon [this message]
2021-05-10 15:31     ` Burakov, Anatoly
2021-05-10 15:55       ` Thomas Monjalon
2021-05-10 16:04         ` Lance Richardson
2021-05-11  7:55           ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2021-05-11 20:45       ` [dpdk-dev] " Thomas Monjalon
2021-05-11  8:17   ` Thomas Monjalon
2021-05-11 13:33     ` Lance Richardson
2021-05-11 14:45 ` [dpdk-dev] [PATCH v4] " Lance Richardson
2021-05-11 15:56   ` Lance Richardson
2021-05-11 16:08     ` Dmitry Kozlyuk
2021-05-11 20:45       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2003089.4ItjxMFgZf@thomas \
    --to=thomas@monjalon.net \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=lance.richardson@broadcom.com \
    --cc=navasile@linux.microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).