grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 5/9] kern/ieee1275/init: ppc64: Add support for alignment req


From: Stefan Berger
Subject: Re: [PATCH 5/9] kern/ieee1275/init: ppc64: Add support for alignment requirements
Date: Fri, 10 Nov 2023 09:56:37 -0500
User-agent: Mozilla Thunderbird



On 11/10/23 09:23, Stefan Berger wrote:


On 11/10/23 08:09, Hari Bathini wrote:


On 31/10/23 11:20 pm, Stefan Berger wrote:
Add support for memory alignment requirements and adjust a candidate
address to it before checking whether the block is large enough. This
must be done in this order since the alignment adjustment can make a
block smaller than what was requested.

None of the current callers has memory alignment requirements but the
ieee1275 loader for kernel and initrd will use it to convey them.

Signed-off-by: stefan Berger <stefanb@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Pavithra Prakash <pavrampu@in.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Carolyn Scherrer <cpscherr@us.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
---
  grub-core/kern/ieee1275/init.c        | 14 ++++++++++++++
  include/grub/powerpc/ieee1275/alloc.h |  1 +
  2 files changed, 15 insertions(+)

diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index a0ce9d55e..542a4c595 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -506,6 +506,20 @@ regions_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
              }
          }
      }
+
+  /* Honor alignment restrictions on candidate addr */
+  if (rcr->align)
+    {
+      grub_uint64_t align_addr = ALIGN_UP (addr, rcr->align);
+      grub_uint64_t d = align_addr - addr;
+
+      if (d > len)
+        return 0;
+

+      len -= d;

Curious.. Is 'len' here length of the region or the claim request size?

len is the length of the requested size of a memory region

Actually, the above statement was not correct. It is the length of a free memory region that starts at addr with length len. If addr is now aligned-up the memory region that we can use becomes smaller by the number of bytes that we lost by the the alignment (align-up!), ot an extent that the resulting address can even become unusable ( if (d > len) ) if it is beyond that free region. Finally, we have to decrease the size of the length of the memory region by 'd'.


If latter, why should 'len' have any impact here??

Thanks
Hari

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]