From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <rahul.lakkireddy@chelsio.com>
Received: from stargate3.asicdesigners.com (stargate.chelsio.com
 [67.207.112.58]) by dpdk.org (Postfix) with ESMTP id 1734BC6EC
 for <dev@dpdk.org>; Thu, 18 Jun 2015 16:24:09 +0200 (CEST)
Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94])
 by stargate3.asicdesigners.com (8.13.8/8.13.8) with ESMTP id t5IEO3tw030819;
 Thu, 18 Jun 2015 07:24:04 -0700
Date: Thu, 18 Jun 2015 19:53:12 +0530
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Message-ID: <20150618142310.GA3406@scalar.blr.asicdesigners.com>
References: <61d1c9174f7f9159d4005dd2cea16c7719cec964.1434462470.git.rahul.lakkireddy@chelsio.com>
 <1931055.A5YAhvXmAm@xps13>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1931055.A5YAhvXmAm@xps13>
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: dev@dpdk.org, Felix Marti <felix@chelsio.com>,
 Nirranjan Kirubaharan <nirranjan@chelsio.com>,
 Kumar Sanghvi <kumaras@chelsio.com>
Subject: Re: [dpdk-dev] [PATCH] vfio: Fix overflow while assigning vfio BAR
 region offset and size
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 18 Jun 2015 14:24:10 -0000

Hi Thomas,

On Wed, Jun 17, 2015 at 14:09:35 +0200, Thomas Monjalon wrote:
> Hi Rahul,
> 
> 2015-06-16 19:46, Rahul Lakkireddy:
> > After the commit-id 90a1633b2 (eal/linux: allow to map BARs with MSI-X tables),
> 
> Please show this information before the Signed-off-by lines:
> Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables")
> generated with this git alias:
> fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")'
> 

Ok. I'll add it in v2.

> > VFIO stopped working. On further debug, found that although BAR region
> 
> I suppose the whole VFIO didn't stopped working.
> Please precise the conditions of the failures (large offset, etc).

When using vfio, the probe fails over Chelsio T5 after commit-id 90a1633b2
(eal/linux: allow to map BARs with MSI-X tables). While debugging further, found
that the region offset for BAR 2 returned by VFIO is too large to fit in uint32_t.
Also, before the above commit, the region offset was passed to mmap as it is and so
VFIO is working fine before the above commit.

> 
> > offset and size from vfio are read as u64, they are truncated when assigned to
> > uint32_t variables resulting in wrong offset being passed for mmap.
> > 
> > The fix is to use uint64_t for offset and size.
> 
> Unfortunately, it doesn't build for 32-bit target.

I tried on RHEL-6.0 32-bit with T=i686-native-linuxapp-gcc and it built fine.
So, am I missing something here or some option may be?
I will also try out on newer distro like ubuntu 32-bit and confirm.


Thanks,
Rahul.