[RFC PATCH v1] iommu/io-pgtable-arm-v7s: Check for leaf entry right after finding it
Will Deacon
will.deacon at arm.com
Fri Feb 24 07:18:23 PST 2017
On Tue, Feb 21, 2017 at 03:31:26PM +0200, Oleksandr Tyshchenko wrote:
> On Tue, Feb 21, 2017 at 2:00 PM, Robin Murphy <robin.murphy at arm.com> wrote:
> > Would it not be more logical (and simpler) to just check that the thing
> > we dereference is valid to dereference when we dereference it? i.e.:
> >
> > -----8<-----
> > diff --git a/drivers/iommu/io-pgtable-arm-v7s.c
> > b/drivers/iommu/io-pgtable-arm-v7s.c
> > index 0769276c0537..f3112f9ff494 100644
> > --- a/drivers/iommu/io-pgtable-arm-v7s.c
> > +++ b/drivers/iommu/io-pgtable-arm-v7s.c
> > @@ -418,8 +418,10 @@ static int __arm_v7s_map(struct arm_v7s_io_pgtable
> > *data, unsigned long iova,
> > pte |= ARM_V7S_ATTR_NS_TABLE;
> >
> > __arm_v7s_set_pte(ptep, pte, 1, cfg);
> > - } else {
> > + } else if (ARM_V7S_PTE_IS_TABLE(pte, lvl)) {
> > cptep = iopte_deref(pte, lvl);
> > + } else {
> > + return -EEXIST;
> > }
> >
> > /* Rinse, repeat */
> > ----->8-----
>
> Agree. Sounds reasonable.
>
> >
> > I think the equivalent could be done in LPAE as well.
>
> OK.
>
> I will resend both modified patches without RFC prefix, right?
Sounds good to me.
Will
More information about the linux-arm-kernel
mailing list