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 <j...@8bytes.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