From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91747A0A0E; Tue, 11 May 2021 16:46:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DE25410E9; Tue, 11 May 2021 16:46:09 +0200 (CEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id C6E4440140 for ; Tue, 11 May 2021 16:46:07 +0200 (CEST) Received: by mail-pj1-f45.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so1496266pjv.1 for ; Tue, 11 May 2021 07:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=JEFyXbBK2E7TfbtzQHg02e8vSthECsW4kD/z0xg4pWU=; b=CuXV0cmWQqCKLyk3dz6hlUoAXvn01gu5sI/sh+dyGwBE9uZKPQQHSQpLjaDKBTrK9l S23X5ehhco4q2PoB3fsrpw+0AOtKVVKXQ16psg4wqFUuyCIe0eXNkubotlhc2W95qtH0 i9VXb4oYSehcVK2uzuwN+z0pCKVWjrmqm3QSc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=JEFyXbBK2E7TfbtzQHg02e8vSthECsW4kD/z0xg4pWU=; b=QZBBG3igCDaPusK4q2O9x+IM8bmNtKeoQ/0DXjJgDsoG0+SdTYQ+fRpdI+4LXVYhP5 KJw1x1m0O3c4k6CvLEJJbQ8htyLHhEfJpcPWVojEoee9lDs71wupvZKQIA4mnQGbLRXL nmYSOnTGQgbsQ+8uN7I0a1YeU3oP8IIePIWC9IfjkUtdcNgZyp0//YadMhj/7HZNHOBq HKbZkEPs+1JlDeJwRIxAR7VKMJsiJXL/W9XeqBfnyrz0LJIowY7f5UpsqLAsK174czdQ oGAQ/Nf5MJEhuwOSn+elHjo7PFFoy82tO6uzpzb5yL2hPamCH2fyWA4GfDKm5qv5jX1X re7w== X-Gm-Message-State: AOAM533PG97KU2rii3o6i0ZsAW2XNJM93NncD0uHalod+BN11+NcteRV yZIGnC5bUvIU/CpU0Xctk4rfbQ== X-Google-Smtp-Source: ABdhPJxxW4hynuDySTDGCU7CsWo799qGJhk7imvyd4DHqlJ2zzWRiZ8MEzExKpiVsynPG+AMca+mww== X-Received: by 2002:a17:902:fe06:b029:ef:77e8:da70 with SMTP id g6-20020a170902fe06b02900ef77e8da70mr145447plj.21.1620744366685; Tue, 11 May 2021 07:46:06 -0700 (PDT) Received: from localhost.localdomain ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id d16sm14258305pgk.34.2021.05.11.07.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 07:46:06 -0700 (PDT) From: Lance Richardson To: Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev@dpdk.org, anatoly.burakov@intel.com, thomas@monjalon.net, stable@dpdk.org Date: Tue, 11 May 2021 10:45:54 -0400 Message-Id: <20210511144554.146987-1-lance.richardson@broadcom.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507181025.84012-1-lance.richardson@broadcom.com> References: <20210507181025.84012-1-lance.richardson@broadcom.com> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000458f4f05c20ef4b9" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH v4] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" --000000000000458f4f05c20ef4b9 Content-Transfer-Encoding: 8bit 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 --- v4: Identical to v1, with now included in rte_eal_paging.h to (hopefully) make off_t available for Windows builds. v3: Use PRIx64 instead of llx ot 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 | 3 ++- lib/eal/unix/eal_unix_memory.c | 10 +++++----- 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..974bf5ee64 100644 --- a/lib/eal/include/rte_eal_paging.h +++ b/lib/eal/include/rte_eal_paging.h @@ -3,6 +3,7 @@ */ #include +#include #include @@ -61,7 +62,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 --000000000000458f4f05c20ef4b9--