[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200924084015.GC27174@8bytes.org>
Date: Thu, 24 Sep 2020 10:40:16 +0200
From: Joerg Roedel <joro@...tes.org>
To: Jacob Pan <jacob.jun.pan@...ux.intel.com>
Cc: Jacob Pan <jacob.pan.linux@...il.com>,
iommu@...ts.linux-foundation.org,
LKML <linux-kernel@...r.kernel.org>,
Alex Williamson <alex.williamson@...hat.com>,
Lu Baolu <baolu.lu@...ux.intel.com>,
David Woodhouse <dwmw2@...radead.org>,
Jonathan Corbet <corbet@....net>,
Jean-Philippe Brucker <jean-philippe@...aro.com>,
Eric Auger <eric.auger@...hat.com>,
Yi Liu <yi.l.liu@...el.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
Raj Ashok <ashok.raj@...el.com>, Wu Hao <hao.wu@...el.com>,
Yi Sun <yi.y.sun@...el.com>
Subject: Re: [PATCH v9 3/7] iommu/uapi: Introduce enum type for PASID data
format
Hi Jacob,
On Fri, Sep 18, 2020 at 10:11:08AM -0700, Jacob Pan wrote:
> On Fri, 18 Sep 2020 11:44:50 +0200, Joerg Roedel <joro@...tes.org> wrote:
>
> > On Fri, Sep 11, 2020 at 02:57:52PM -0700, Jacob Pan wrote:
> > > There can be multiple vendor-specific PASID data formats used in UAPI
> > > structures. This patch adds enum type with a last entry which makes
> > > range checking much easier.
> >
> > But it also makes it much easier to screw up the numbers (which are ABI)
> > by inserting a new value into the middle. I prefer defines here, or
> > alternativly BUILD_BUG_ON() checks for the numbers.
> >
> I am not following, the purpose of IOMMU_PASID_FORMAT_LAST *is* for
> preparing the future insertion of new value into the middle.
> The checking against IOMMU_PASID_FORMAT_LAST is to protect ABI
> compatibility by making sure that out of range format are rejected in all
> versions of the ABI.
But with the enum you could have:
enum {
VTD_FOO,
SMMU_FOO,
LAST,
};
which makes VTD_FOO==0 and SMMU_FOO==1, and when in the next version
someone adds:
enum {
VTD_FOO,
VTD_BAR,
SMMU_FOO,
LAST,
};
then SMMU_FOO will become 2 and break ABI. So I'd like to have this
checked somewhere.
Regards,
Joerg
Powered by blists - more mailing lists