mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v1 2/3] iommu: Fix an issue in iommu_page_response() flags check
       [not found] ` <1603849018-6578-3-git-send-email-yi.y.sun@linux.intel.com>
@ 2020-10-28  9:13   ` Jean-Philippe Brucker
  2020-10-29  6:30     ` Yi Sun
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Philippe Brucker @ 2020-10-28  9:13 UTC (permalink / raw)
  To: Yi Sun; +Cc: joro, dwmw2, baolu.lu, iommu, linux-kernel

Hi,

On Wed, Oct 28, 2020 at 09:36:57AM +0800, Yi Sun wrote:
> From: Jacob Pan <jacob.jun.pan@linux.intel.com>
> 
> original code fails when LAST_PAGE is set in flags.

LAST_PAGE is not documented to be a valid flags for page_response.
So isn't failing the right thing to do?

> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> ---
>  drivers/iommu/iommu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 8c470f4..053cec3 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1200,9 +1200,11 @@ int iommu_page_response(struct device *dev,
>  		return -EINVAL;
>  
>  	if (msg->version != IOMMU_PAGE_RESP_VERSION_1 ||
> -	    msg->flags & ~IOMMU_PAGE_RESP_PASID_VALID)
> +		!(msg->flags & IOMMU_PAGE_RESP_PASID_VALID)) {

It should be OK not to have PASID_VALID set, we're just checking for
undefined flags here.

Thanks,
Jean

> +		dev_warn_ratelimited(dev, "%s:Invalid ver %x: flags %x\n",
> +				__func__, msg->version, msg->flags);
>  		return -EINVAL;
> -
> +	}
>  	/* Only send response if there is a fault report pending */
>  	mutex_lock(&param->fault_param->lock);
>  	if (list_empty(&param->fault_param->faults)) {
> -- 
> 2.7.4
> 
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 2/3] iommu: Fix an issue in iommu_page_response() flags check
  2020-10-28  9:13   ` [PATCH v1 2/3] iommu: Fix an issue in iommu_page_response() flags check Jean-Philippe Brucker
@ 2020-10-29  6:30     ` Yi Sun
  0 siblings, 0 replies; 2+ messages in thread
From: Yi Sun @ 2020-10-29  6:30 UTC (permalink / raw)
  To: Jean-Philippe Brucker; +Cc: joro, dwmw2, baolu.lu, iommu, linux-kernel

On 20-10-28 10:13:56, Jean-Philippe Brucker wrote:
> Hi,
> 
> On Wed, Oct 28, 2020 at 09:36:57AM +0800, Yi Sun wrote:
> > From: Jacob Pan <jacob.jun.pan@linux.intel.com>
> > 
> > original code fails when LAST_PAGE is set in flags.
> 
> LAST_PAGE is not documented to be a valid flags for page_response.
> So isn't failing the right thing to do?
> 
> > 
> > Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> > Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> > ---
> >  drivers/iommu/iommu.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index 8c470f4..053cec3 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -1200,9 +1200,11 @@ int iommu_page_response(struct device *dev,
> >  		return -EINVAL;
> >  
> >  	if (msg->version != IOMMU_PAGE_RESP_VERSION_1 ||
> > -	    msg->flags & ~IOMMU_PAGE_RESP_PASID_VALID)
> > +		!(msg->flags & IOMMU_PAGE_RESP_PASID_VALID)) {
> 
> It should be OK not to have PASID_VALID set, we're just checking for
> undefined flags here.
> 
Thanks! You are right. Per published spec, we should not care LAST_PAGE
for page_response. I will remove this patch in next version.
 
> Thanks,
> Jean
> 
> > +		dev_warn_ratelimited(dev, "%s:Invalid ver %x: flags %x\n",
> > +				__func__, msg->version, msg->flags);
> >  		return -EINVAL;
> > -
> > +	}
> >  	/* Only send response if there is a fault report pending */
> >  	mutex_lock(&param->fault_param->lock);
> >  	if (list_empty(&param->fault_param->faults)) {
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > iommu mailing list
> > iommu@lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-29  7:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1603849018-6578-1-git-send-email-yi.y.sun@linux.intel.com>
     [not found] ` <1603849018-6578-3-git-send-email-yi.y.sun@linux.intel.com>
2020-10-28  9:13   ` [PATCH v1 2/3] iommu: Fix an issue in iommu_page_response() flags check Jean-Philippe Brucker
2020-10-29  6:30     ` Yi Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®