RE: [PATCH 1/5] omap iommu: Reject unaligned physical address at setting page table entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hiroshi,
 


> From: Hiroshi DOYU <Hiroshi.DOYU@xxxxxxxxx>
> 
> This rejects unaligned physical address at setting page table 
> entry and informs error to caller. Otherwise, a wrong address 
> may be used by IO device.
> 
> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@xxxxxxxxx>
> ---
>  arch/arm/plat-omap/iommu.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/plat-omap/iommu.c 
> b/arch/arm/plat-omap/iommu.c index 0e13766..b3591ee 100644
> --- a/arch/arm/plat-omap/iommu.c
> +++ b/arch/arm/plat-omap/iommu.c
> @@ -503,6 +503,12 @@ static int iopgd_alloc_section(struct 
> iommu *obj, u32 da, u32 pa, u32 prot)  {
>  	u32 *iopgd = iopgd_offset(obj, da);
>  
> +	if (pa & ~IOSECTION_MASK) {
> +		dev_err(obj->dev, "%s: pa:%08x should aligned 
> on %08lx\n",
> +			__func__, pa, IOSECTION_SIZE);
> +		return -EINVAL;
> +	}
> +

-- I think the alignment check should be present even for da address. Same comment for below checks.

>  	*iopgd = (pa & IOSECTION_MASK) | prot | IOPGD_SECTION;
>  	flush_iopgd_range(iopgd, iopgd);
>  	return 0;
> @@ -513,6 +519,12 @@ static int iopgd_alloc_super(struct 
> iommu *obj, u32 da, u32 pa, u32 prot)
>  	u32 *iopgd = iopgd_offset(obj, da);
>  	int i;
>  
> +	if (pa & ~IOSUPER_MASK) {
> +		dev_err(obj->dev, "%s: pa:%08x should aligned 
> on %08lx\n",
> +			__func__, pa, IOSUPER_SIZE);
> +		return -EINVAL;
> +	}
> +
>  	for (i = 0; i < 16; i++)
>  		*(iopgd + i) = (pa & IOSUPER_MASK) | prot | IOPGD_SUPER;
>  	flush_iopgd_range(iopgd, iopgd + 15);
> @@ -542,6 +554,12 @@ static int iopte_alloc_large(struct 
> iommu *obj, u32 da, u32 pa, u32 prot)
>  	u32 *iopte = iopte_alloc(obj, iopgd, da);
>  	int i;
>  
> +	if (pa & ~IOLARGE_MASK) {
> +		dev_err(obj->dev, "%s: pa:%08x should aligned 
> on %08lx\n",
> +			__func__, pa, IOLARGE_SIZE);
> +		return -EINVAL;
> +	}
> +
>  	if (IS_ERR(iopte))
>  		return PTR_ERR(iopte);
>  
> --
> 1.7.1.rc1
> 
> --
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux