From patchwork Fri May 7 19:06:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Richardson X-Patchwork-Id: 93051 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 50CC0A0A0F; Fri, 7 May 2021 21:07:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 907164068A; Fri, 7 May 2021 21:07:10 +0200 (CEST) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 293BF4013F for ; Fri, 7 May 2021 21:07:09 +0200 (CEST) Received: by mail-pl1-f180.google.com with SMTP id h7so5701029plt.1 for ; Fri, 07 May 2021 12:07:09 -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=2bTLagQLk4VpygN1KOs3dVjJHCp8KTpI6tjGbSQ7Tp4=; b=Gd7bW+l7Ltdii2rX+HuupFsIaijzm6GIo3VtMJcGEXoYQT3iiTkk5RIaGSAv1/2Ga3 PC++igAaUZoAXpk9CvUMoVaiogZhRjmfOozTSiyGu8HHMhzERcoyshVJK+rQ6yVszo/n /hll3qVtwk2XJTC5vbY9zKtxYet3bcd0DpeT8= 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=2bTLagQLk4VpygN1KOs3dVjJHCp8KTpI6tjGbSQ7Tp4=; b=CKMOQKVAMI7BX7uWzLyIlY5R7puVrjYrb+vqlBSytrFmCaCjoCrgkdiCrsS042rIb6 ZWZpFyJi7WW24U+dX+olel1wC3oTewPOFyVxGSdYwcROr9iMUjmFCzeI+uJYqXhA9+V7 dvUNIJ6iGweE6ithmsA3Rfr+aq2qVSp72DMdUzrayt48Pkbn4agw5S6T2XTscQLngWuP hw0Q1D4oKLYbXr3qKWeQK+/jXWvb/P0+9mSR2XIyf4dGkzpFoTV1OmJGjB8+cFezmfcD A4BaDGWB7E/a+Q/hZ8obyA6fsoNofy/4wU7ZuE9+OTtHCMzqwUmnY9ApoBrvfwoNnoAw wUfQ== X-Gm-Message-State: AOAM530LyQ1UTG0fl1FoPpEu6Ogfu79MbRuXvdL0LBeI52goaeEhfHnX F+rQPYtglz0XTr8VAe5XuCXA9g== X-Google-Smtp-Source: ABdhPJy/BrdkBb4Dhq75XezWmcEbJJAvSaiW4R1VcYt6ngKERfW943WLGfyfSrGJhAIw9ce/Isky5A== X-Received: by 2002:a17:902:db09:b029:ee:f2d5:3d0f with SMTP id m9-20020a170902db09b02900eef2d53d0fmr11177335plx.13.1620414427943; Fri, 07 May 2021 12:07:07 -0700 (PDT) Received: from localhost.localdomain ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id i14sm5341074pgk.77.2021.05.07.12.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 12:07:07 -0700 (PDT) From: Lance Richardson To: Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev@dpdk.org, stable@dpdk.org Date: Fri, 7 May 2021 15:06:57 -0400 Message-Id: <20210507190657.84927-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 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH v2] 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" 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 --- 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 | 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..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..41a94a7511 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, 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%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, 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;