* [PATCH] ARM: ioremap: Fix static vm area boundary checking.
@ 2014-05-15 5:57 Richard Lee
2014-05-15 8:55 ` Li.Xiubo at freescale.com
0 siblings, 1 reply; 3+ messages in thread
From: Richard Lee @ 2014-05-15 5:57 UTC (permalink / raw)
To: linux-arm-kernel
Static vm area boundary check:
paddr1 --->| |
| |
|-------| <-\--- svm->vm->addr(is page aligned)
paddr2 --->| | |
| --| <--|-- svm->vm->phys_addr
| | |
paddr3 --->| | |
| | |
|-------| <--|-- next page boundary
| | |
paddr4 --->| | | <----- svm->vm->size(including guard page)
| | |
| | |
max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
| ///// | |
paddr5 --->| guard | |
| page | |
| ///// | |
------- <-/--- svm->vm->addr + svm->vm_size
<1> If the paddr == paddr1, then continue;
<2> If the paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
then continue;
<3> if the paddr >= paddr5 then continue;
Signed-off-by: Richard Lee <superlibj8301@gmail.com>
---
arch/arm/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index be69333..2fa41f4 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -47,16 +47,56 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
{
struct static_vm *svm;
struct vm_struct *vm;
+ size_t offset;
+
+ /*
+ * Make sure the size the mapping size is page aligned.
+ */
+ size = PAGE_ALIGN((paddr & ~PAGE_SIZE) + size);
+ offset = paddr & ~PAGE_SIZE;
list_for_each_entry(svm, &static_vmlist, list) {
+ phys_addr_t paddr_end, phys_addr_end;
+ size_t vmoff;
+
vm = &svm->vm;
if (!(vm->flags & VM_ARM_STATIC_MAPPING))
continue;
if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
continue;
- if (vm->phys_addr > paddr ||
- paddr + size - 1 > vm->phys_addr + vm->size - 1)
+ /* Static vm area boundary check:
+ *
+ * paddr1 --->| |
+ * | |
+ * |-------| <-\--- svm->vm->addr(page aligned)
+ * paddr2 --->| | |
+ * | --| <--|-- svm->vm->phys_addr
+ * | | |
+ * paddr3 --->| | |
+ * | | |
+ * |-------| <--|-- next page boundary
+ * | | |
+ * paddr4 --->| | | <----- svm->vm->size,
+ * | | | including guard page
+ * | | |
+ * max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
+ * | ///// | |
+ * paddr5 --->| guard | |
+ * | page | |
+ * | ///// | |
+ * ------- <-/-- svm->vm->addr + svm->vm_size
+ *
+ * <1> If paddr == paddr1, then continue;
+ * <2> If paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
+ * then continue;
+ * <3> if paddr >= paddr5 then continue;
+ */
+ vmoff = vm->phys_addr & ~PAGE_SIZE;
+ phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - vmoff;
+ paddr_end = paddr + size - offset;
+ if (__phys_to_pfn(vm->phys_addr) > __phys_to_pfn(paddr) ||
+ paddr_end - 1 > phys_addr_end - 1)
continue;
return svm;
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] ARM: ioremap: Fix static vm area boundary checking.
2014-05-15 5:57 [PATCH] ARM: ioremap: Fix static vm area boundary checking Richard Lee
@ 2014-05-15 8:55 ` Li.Xiubo at freescale.com
2014-05-15 9:02 ` Richard Lee
0 siblings, 1 reply; 3+ messages in thread
From: Li.Xiubo at freescale.com @ 2014-05-15 8:55 UTC (permalink / raw)
To: linux-arm-kernel
> Subject: [PATCH] ARM: ioremap: Fix static vm area boundary checking.
>
> Static vm area boundary check:
>
> paddr1 --->| |
> | |
> |-------| <-\--- svm->vm->addr(is page aligned)
> paddr2 --->| | |
> | --| <--|-- svm->vm->phys_addr
> | | |
> paddr3 --->| | |
> | | |
> |-------| <--|-- next page boundary
> | | |
> paddr4 --->| | | <----- svm->vm->size(including guard page)
> | | |
> | | |
> max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
> | ///// | |
> paddr5 --->| guard | |
> | page | |
> | ///// | |
> ------- <-/--- svm->vm->addr + svm->vm_size
>
> <1> If the paddr == paddr1, then continue;
> <2> If the paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
> then continue;
> <3> if the paddr >= paddr5 then continue;
>
> Signed-off-by: Richard Lee <superlibj8301@gmail.com>
> ---
> arch/arm/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
> index be69333..2fa41f4 100644
> --- a/arch/arm/mm/ioremap.c
> +++ b/arch/arm/mm/ioremap.c
> @@ -47,16 +47,56 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t
> paddr,
> {
> struct static_vm *svm;
> struct vm_struct *vm;
> + size_t offset;
> +
> + /*
> + * Make sure the size the mapping size is page aligned.
> + */
> + size = PAGE_ALIGN((paddr & ~PAGE_SIZE) + size);
> + offset = paddr & ~PAGE_SIZE;
>
Shouldn't it be PAGE_MASK ?
> list_for_each_entry(svm, &static_vmlist, list) {
> + phys_addr_t paddr_end, phys_addr_end;
> + size_t vmoff;
> +
> vm = &svm->vm;
> if (!(vm->flags & VM_ARM_STATIC_MAPPING))
> continue;
> if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
> continue;
>
> - if (vm->phys_addr > paddr ||
> - paddr + size - 1 > vm->phys_addr + vm->size - 1)
> + /* Static vm area boundary check:
> + *
> + * paddr1 --->| |
> + * | |
> + * |-------| <-\--- svm->vm->addr(page aligned)
> + * paddr2 --->| | |
> + * | --| <--|-- svm->vm->phys_addr
> + * | | |
> + * paddr3 --->| | |
> + * | | |
> + * |-------| <--|-- next page boundary
> + * | | |
> + * paddr4 --->| | | <----- svm->vm->size,
> + * | | | including guard page
> + * | | |
> + * max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
> + * | ///// | |
> + * paddr5 --->| guard | |
> + * | page | |
> + * | ///// | |
> + * ------- <-/-- svm->vm->addr + svm->vm_size
> + *
> + * <1> If paddr == paddr1, then continue;
> + * <2> If paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
> + * then continue;
> + * <3> if paddr >= paddr5 then continue;
> + */
> + vmoff = vm->phys_addr & ~PAGE_SIZE;
And here.
Thanks,
BRs
Xiubo
> + phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - vmoff;
> + paddr_end = paddr + size - offset;
> + if (__phys_to_pfn(vm->phys_addr) > __phys_to_pfn(paddr) ||
> + paddr_end - 1 > phys_addr_end - 1)
> continue;
>
> return svm;
> --
> 1.8.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] ARM: ioremap: Fix static vm area boundary checking.
2014-05-15 8:55 ` Li.Xiubo at freescale.com
@ 2014-05-15 9:02 ` Richard Lee
0 siblings, 0 replies; 3+ messages in thread
From: Richard Lee @ 2014-05-15 9:02 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, May 15, 2014 at 4:55 PM, Li.Xiubo at freescale.com
<Li.Xiubo@freescale.com> wrote:
>> Subject: [PATCH] ARM: ioremap: Fix static vm area boundary checking.
>>
>> Static vm area boundary check:
>>
>> paddr1 --->| |
>> | |
>> |-------| <-\--- svm->vm->addr(is page aligned)
>> paddr2 --->| | |
>> | --| <--|-- svm->vm->phys_addr
>> | | |
>> paddr3 --->| | |
>> | | |
>> |-------| <--|-- next page boundary
>> | | |
>> paddr4 --->| | | <----- svm->vm->size(including guard page)
>> | | |
>> | | |
>> max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
>> | ///// | |
>> paddr5 --->| guard | |
>> | page | |
>> | ///// | |
>> ------- <-/--- svm->vm->addr + svm->vm_size
>>
>> <1> If the paddr == paddr1, then continue;
>> <2> If the paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
>> then continue;
>> <3> if the paddr >= paddr5 then continue;
>>
>> Signed-off-by: Richard Lee <superlibj8301@gmail.com>
>> ---
>> arch/arm/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 42 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
>> index be69333..2fa41f4 100644
>> --- a/arch/arm/mm/ioremap.c
>> +++ b/arch/arm/mm/ioremap.c
>> @@ -47,16 +47,56 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t
>> paddr,
>> {
>> struct static_vm *svm;
>> struct vm_struct *vm;
>> + size_t offset;
>> +
>> + /*
>> + * Make sure the size the mapping size is page aligned.
>> + */
>> + size = PAGE_ALIGN((paddr & ~PAGE_SIZE) + size);
>> + offset = paddr & ~PAGE_SIZE;
>>
>
> Shouldn't it be PAGE_MASK ?
>
Yes, it is. I'll fix it.
Thanks,
Best regards,
Richard Lee
>
>> list_for_each_entry(svm, &static_vmlist, list) {
>> + phys_addr_t paddr_end, phys_addr_end;
>> + size_t vmoff;
>> +
>> vm = &svm->vm;
>> if (!(vm->flags & VM_ARM_STATIC_MAPPING))
>> continue;
>> if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
>> continue;
>>
>> - if (vm->phys_addr > paddr ||
>> - paddr + size - 1 > vm->phys_addr + vm->size - 1)
>> + /* Static vm area boundary check:
>> + *
>> + * paddr1 --->| |
>> + * | |
>> + * |-------| <-\--- svm->vm->addr(page aligned)
>> + * paddr2 --->| | |
>> + * | --| <--|-- svm->vm->phys_addr
>> + * | | |
>> + * paddr3 --->| | |
>> + * | | |
>> + * |-------| <--|-- next page boundary
>> + * | | |
>> + * paddr4 --->| | | <----- svm->vm->size,
>> + * | | | including guard page
>> + * | | |
>> + * max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
>> + * | ///// | |
>> + * paddr5 --->| guard | |
>> + * | page | |
>> + * | ///// | |
>> + * ------- <-/-- svm->vm->addr + svm->vm_size
>> + *
>> + * <1> If paddr == paddr1, then continue;
>> + * <2> If paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
>> + * then continue;
>> + * <3> if paddr >= paddr5 then continue;
>> + */
>> + vmoff = vm->phys_addr & ~PAGE_SIZE;
>
> And here.
>
> Thanks,
> BRs
> Xiubo
>
>> + phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - vmoff;
>> + paddr_end = paddr + size - offset;
>> + if (__phys_to_pfn(vm->phys_addr) > __phys_to_pfn(paddr) ||
>> + paddr_end - 1 > phys_addr_end - 1)
>> continue;
>>
>> return svm;
>> --
>> 1.8.4
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-15 9:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 5:57 [PATCH] ARM: ioremap: Fix static vm area boundary checking Richard Lee
2014-05-15 8:55 ` Li.Xiubo at freescale.com
2014-05-15 9:02 ` Richard Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).