From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <alex.williamson@redhat.com>
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
 by dpdk.org (Postfix) with ESMTP id 67E6947D2
 for <dev@dpdk.org>; Thu, 28 Jul 2016 00:14:59 +0200 (CEST)
Received: from int-mx13.intmail.prod.int.phx2.redhat.com
 (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1.redhat.com (Postfix) with ESMTPS id 09E4881223;
 Wed, 27 Jul 2016 22:14:58 +0000 (UTC)
Received: from t450s.home (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3])
 by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with
 ESMTP id u6RMEvch003021; Wed, 27 Jul 2016 18:14:57 -0400
Date: Wed, 27 Jul 2016 16:14:57 -0600
From: Alex Williamson <alex.williamson@redhat.com>
To: anatoly.burakov@intel.com
Cc: dev@dpdk.org
Message-ID: <20160727161457.7992c756@t450s.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
 (mx1.redhat.com [10.5.110.25]); Wed, 27 Jul 2016 22:14:58 +0000 (UTC)
Subject: [dpdk-dev] [bug] dpdk-vfio: Invalid region/index assumption
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: Wed, 27 Jul 2016 22:14:59 -0000

Hi,

I took a quick look at the dpdk vfio code and spotted an invalid
assumption that should probably be corrected ASAP.  That is:

lib/librte_eal/linuxapp/eal/eal_vfio.h:
#define VFIO_GET_REGION_ADDR(x) ((uint64_t) x << 40ULL)
#define VFIO_GET_REGION_IDX(x) (x >> 40)

Region offset to index is an implementation detail of the kernel, the
vfio API defines that the offset of a given region (BAR) is found via
the offset field of struct vfio_region_info returned via the
VFIO_DEVICE_GET_REGION_INFO ioctl.  You're free to cache the offset
into any sort of local variable you like, but the kernel may change the
implementation of region index to offset at any point in time.  This is
explicitly not part of the ABI.  Is there a place to file a bug, or is
this sufficient?  Thanks,

Alex