Skip to contentSkip to conversation

ARM: ioremap: Fix static vm area boundary checking.

PATCH In review Richard Lee 3 participants 6 messages May 15, 2014 – May 16, 2014 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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;

---

Change in V2:
- PAGE_SIZE --> PAGE_MASK
- remove the 'size' page size align operation.

 arch/arm/mm/ioremap.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +38 -2
index be69333..f235ab7 100644
@@ -47,16 +47,52 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
 {
 	struct static_vm *svm;
 	struct vm_struct *vm;
+	size_t offset;
+
+	offset = paddr & ~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_MASK;
+		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;
Signature · 1 line
1.8.4
#1 lore raw
Quoted 22 lines · Richard Lee

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
Quoted 6 lines

<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;

instead of doing this repeatedly, why not simply ensure the recorded static vm information is already page aligned in the first place?

Quoted 77 lines

---

Change in V2:
- PAGE_SIZE --> PAGE_MASK
- remove the 'size' page size align operation.

 arch/arm/mm/ioremap.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +38 -2
index be69333..f235ab7 100644
@@ -47,16 +47,52 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
 {
 	struct static_vm *svm;
 	struct vm_struct *vm;
+	size_t offset;
+
+	offset = paddr & ~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_MASK;
+		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;
Signature · 1 line
1.8.4
#2 lore raw
Quoted 29 lines · Nicolas Pitre
Quoted 27 lines · Richard Lee

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;

Quoted 5 lines
Quoted 1 line

instead of doing this repeatedly, why not simply ensure the recorded static vm information is already page aligned in the first place?

Sorry, I'm not very sure what vm information you meant here.

And the 'svm->vm->addr' and 'svm->vm->size' are all page aligned already, but we cannot make sure that the 'paddr' and 'svm->vm->phys_addr' are page aligned.

Thanks,

BRs
Richard Lee

Quoted 79 lines
Quoted 79 lines

---

Change in V2:
- PAGE_SIZE --> PAGE_MASK
- remove the 'size' page size align operation.

 arch/arm/mm/ioremap.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +38 -3
index be69333..f235ab7 100644
@@ -47,16 +47,52 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
 {
      struct static_vm *svm;
      struct vm_struct *vm;
+     size_t offset;
+
+     offset = paddr & ~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_MASK;
+             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

#3 lore raw
Quoted 39 lines

Subject: Re: [PATCHv2] ARM: ioremap: Fix static vm area boundary checking.

Quoted 29 lines · Nicolas Pitre
Quoted 27 lines · Richard Lee

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;

Quoted 5 lines
Quoted 1 line

instead of doing this repeatedly, why not simply ensure the recorded static vm information is already page aligned in the first place?

Quoted 6 lines

Sorry, I'm not very sure what vm information you meant here.

And the 'svm->vm->addr' and 'svm->vm->size' are all page aligned already, but we cannot make sure that the 'paddr' and 'svm->vm->phys_addr' are page aligned.

The paddr and svm->vm->phys_addr are all already pfn aligned here. What we should fix about is the boundary of them.

Thanks,
BRs
Xiubo

Quoted 90 lines

Thanks,

BRs
Richard Lee

Quoted 14 lines
Quoted 14 lines

---

Change in V2:
- PAGE_SIZE --> PAGE_MASK
- remove the 'size' page size align operation.

Quoted 8 lines

arch/arm/mm/ioremap.c static struct static_vm

Quoted 8 lines
 arch/arm/mm/ioremap.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +0 -0
index be69333..f235ab7 100644
@@ -47,16 +47,52 @@ static struct static_vm

*find_static_vm_paddr(phys_addr_t paddr,

Quoted 17 lines
Quoted 17 lines
arch/arm/mm/ioremap.c +6 -0
 {
      struct static_vm *svm;
      struct vm_struct *vm;
+     size_t offset;
+
+     offset = paddr & ~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;
 
Quoted 7 lines

arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,

Quoted 7 lines
arch/arm/mm/ioremap.c +5 -2
-             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)

Quoted 9 lines

arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,

Quoted 9 lines
arch/arm/mm/ioremap.c +9 -0
+              *       paddr2 --->|       |    |
+              *                  |     --| <--|-- svm->vm->phys_addr
+              *                  |       |    |
+              *       paddr3 --->|       |    |
+              *                  |       |    |
+              *                  |-------| <--|-- next page boundary
+              *                  |       |    |
+              *       paddr4 --->|       |    | <----- svm->vm->size,
+              *                  |       |    |         including guard

page

Quoted 11 lines

arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,

Quoted 7 lines
arch/arm/mm/ioremap.c +7 -0
+              *                  |       |    |
+              * max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
+              *                  | ///// |    |
+              *       paddr5 --->| guard |    |
+              *                  | page  |    |
+              *                  | ///// |    |
+              *                   -------  <-/-- svm->vm->addr + svm-

vm_size

Quoted 3 lines
arch/arm/mm/ioremap.c +3 -0
+              *
+              * <1> If paddr == paddr1, then continue;
+              * <2> If paddr == paddr2~paddr4 and paddr_end >

phys_addr_end,

Quoted 14 lines
Quoted 14 lines
arch/arm/mm/ioremap.c +8 -1
+              *     then continue;
+              * <3> if paddr >= paddr5 then continue;
+              */
+             vmoff = vm->phys_addr & ~PAGE_MASK;
+             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

#4 lore raw
Quoted 41 lines · Li.Xiubo at freescale.com
Quoted 41 lines

Subject: Re: [PATCHv2] ARM: ioremap: Fix static vm area boundary checking.

Quoted 29 lines · Nicolas Pitre
Quoted 27 lines · Richard Lee

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;

Quoted 5 lines
Quoted 1 line

instead of doing this repeatedly, why not simply ensure the recorded static vm information is already page aligned in the first place?

Sorry, I'm not very sure what vm information you meant here.

Quoted 8 lines
Quoted 4 lines

And the 'svm->vm->addr' and 'svm->vm->size' are all page aligned already, but we cannot make sure that the 'paddr' and 'svm->vm->phys_addr' are page aligned.

The paddr and svm->vm->phys_addr are all already pfn aligned here. What we should fix about is the boundary of them.

Sorry, I'm a fresher and I'll be out of the opensource mail list for changing jobs and then I have no chance to do this.
Could you help me fix this issue please ?

And thanks for your help about how to appoarch the opensource list. Thanks very much,

Richard,

Quoted 81 lines
Quoted 81 lines
Quoted 11 lines
Quoted 11 lines

Change in V2:
- PAGE_SIZE --> PAGE_MASK
- remove the 'size' page size align operation.

Quoted 8 lines

arch/arm/mm/ioremap.c static struct static_vm

Quoted 8 lines
 arch/arm/mm/ioremap.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +0 -0
index be69333..f235ab7 100644
@@ -47,16 +47,52 @@ static struct static_vm

*find_static_vm_paddr(phys_addr_t paddr,

Quoted 17 lines
Quoted 17 lines
arch/arm/mm/ioremap.c +6 -0
 {
      struct static_vm *svm;
      struct vm_struct *vm;
+     size_t offset;
+
+     offset = paddr & ~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;
 
Quoted 7 lines

arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,

Quoted 7 lines
arch/arm/mm/ioremap.c +5 -2
-             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)

Quoted 9 lines

arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,

Quoted 9 lines
arch/arm/mm/ioremap.c +9 -0
+              *       paddr2 --->|       |    |
+              *                  |     --| <--|-- svm->vm->phys_addr
+              *                  |       |    |
+              *       paddr3 --->|       |    |
+              *                  |       |    |
+              *                  |-------| <--|-- next page boundary
+              *                  |       |    |
+              *       paddr4 --->|       |    | <----- svm->vm->size,
+              *                  |       |    |         including guard

page

Quoted 11 lines

arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,

Quoted 7 lines
arch/arm/mm/ioremap.c +7 -0
+              *                  |       |    |
+              * max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
+              *                  | ///// |    |
+              *       paddr5 --->| guard |    |
+              *                  | page  |    |
+              *                  | ///// |    |
+              *                   -------  <-/-- svm->vm->addr + svm-

vm_size

Quoted 3 lines
arch/arm/mm/ioremap.c +3 -0
+              *
+              * <1> If paddr == paddr1, then continue;
+              * <2> If paddr == paddr2~paddr4 and paddr_end >

phys_addr_end,

Quoted 14 lines
Quoted 14 lines
arch/arm/mm/ioremap.c +8 -1
+              *     then continue;
+              * <3> if paddr >= paddr5 then continue;
+              */
+             vmoff = vm->phys_addr & ~PAGE_MASK;
+             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

#5 lore raw
In reply to Richard Lee
Quoted 36 lines · Richard Lee
Quoted 29 lines · Nicolas Pitre
Quoted 27 lines · Richard Lee

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;

Quoted 5 lines
Quoted 1 line

instead of doing this repeatedly, why not simply ensure the recorded static vm information is already page aligned in the first place?

Quoted 5 lines

Sorry, I'm not very sure what vm information you meant here.

And the 'svm->vm->addr' and 'svm->vm->size' are all page aligned already, but we cannot make sure that the 'paddr' and 'svm->vm->phys_addr' are page aligned.

If ->vm->addr is page aligned, then ->vm->phys_addr must be page aligned as well. The hardware does virtual to physical mappings on a page granularity. It is then not important to align paddr for the purpose of the search.

In other words, I fail to understand what problem your patch solves.

Nicolas