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 57269A0C42 for ; Sat, 8 May 2021 16:12:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 224DB40041; Sat, 8 May 2021 16:12:19 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 7B7BD40041 for ; Sat, 8 May 2021 16:12:17 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id t21so6666823plo.2 for ; Sat, 08 May 2021 07:12:17 -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=JOUoB5XjRy2jXZV5AnBM4IhvrC+GgSdH+yXoPS120JI=; b=XOlJfKKkjKfjuTv4Eu5m1gU67PeJ1dO+ZysVpIVYSuEoTHvtIBY9ZENU2gLkd3Rqiu Tde6gXJ0CJtm8DmMDhOU8F6z8LXy7wSeVOgSGJzTlSlUkEPOfXoeVyBiyI12bEdvwTEs PYlb2hyb0iXFfha4W27nWMfMcJr9+gYjYfBWY= 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=JOUoB5XjRy2jXZV5AnBM4IhvrC+GgSdH+yXoPS120JI=; b=iMnOp/4eIqHGGAHWTHhZsgkordXxGbN8GNE1OSBpdAP3VGIY1oUNQz5f/ahBXbP40V zGvuWm0wFf3Se9LwKNVIvjQvp8N5hIhb8kxkduqUZ9gwpPFQ4XYYDOsihk+Skm8cPxbE wD2l1bPcsL7IUptn63SCIccm5RVolb2GFk1gPTGi4vZvTbAZZnvKrVELwSLpTtl0Gi1h 97hDiYM4fcJxvrOedDjI0DCYOduNZpdeGaJVtW9ZpdKYzymGQCvomQd1GfyC2LbYK4Qk hgnzFJYXaOIJ9bKY7fZBI44MGeovXIcMuOPX5txNeUNtV7pn20TvZFmANDbX/qWKWAzu Ia+Q== X-Gm-Message-State: AOAM530nNqYy+3JlZcTLOFgPGr2VoSJRsdHIcW5Jy6gZQW7sTVOxBfvT 18TdbMeq53/QR7X+y7K/7Bvi4g== X-Google-Smtp-Source: ABdhPJz6IOJs83y9S7zkQDoAMTyH2CejMEykX+9zM2hYeeYZqhrn/M7R3hm4xcCxqJLKL5t07JL78A== X-Received: by 2002:a17:902:bc88:b029:ee:7ef1:e770 with SMTP id bb8-20020a170902bc88b02900ee7ef1e770mr15544146plb.19.1620483136370; Sat, 08 May 2021 07:12:16 -0700 (PDT) Received: from localhost.localdomain ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id s8sm7065486pfe.112.2021.05.08.07.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 07:12:15 -0700 (PDT) From: Lance Richardson To: Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev@dpdk.org, stable@dpdk.org Date: Sat, 8 May 2021 10:12:06 -0400 Message-Id: <20210508141206.107114-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="000000000000bc59e905c1d22145" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-stable] [PATCH] eal: fix memory mapping for 32-bit targets X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" --000000000000bc59e905c1d22145 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 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 --- 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 #include #include +#include #include #include @@ -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; -- 2.25.1 --000000000000bc59e905c1d22145--