[MINI-OS PATCH] e820: fix e820_get_reserved_pfns() to reserve page aligned area

Juergen Gross posted 1 patch 3 months, 3 weeks ago
Failed in applying to current master (apply log)
e820.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[MINI-OS PATCH] e820: fix e820_get_reserved_pfns() to reserve page aligned area
Posted by Juergen Gross 3 months, 3 weeks ago
e820_get_reserved_pfns() needs to make sure to reserve only page
aligned memory areas.

Fixes: a7d27a7332ba ("mini-os: add memory map service functions")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/e820.c b/e820.c
index d8cfb1f4..1ffeaf00 100644
--- a/e820.c
+++ b/e820.c
@@ -365,7 +365,7 @@ unsigned long e820_get_reserved_pfns(int pages)
     unsigned long last = 0, needed = (long)pages << PAGE_SHIFT;
 
     for ( i = 0; i < e820_entries && e820_map[i].addr < last + needed; i++ )
-        last = e820_map[i].addr + e820_map[i].size;
+        last = round_pgup(e820_map[i].addr + e820_map[i].size);
 
     if ( i == 0 || e820_map[i - 1].type != E820_TYPE_SOFT_RESERVED )
         e820_insert_entry_at(i, last, needed, E820_TYPE_SOFT_RESERVED);
-- 
2.43.0
Re: [MINI-OS PATCH] e820: fix e820_get_reserved_pfns() to reserve page aligned area
Posted by Jan Beulich 3 months, 2 weeks ago
On 11.07.2025 14:03, Juergen Gross wrote:
> e820_get_reserved_pfns() needs to make sure to reserve only page
> aligned memory areas.
> 
> Fixes: a7d27a7332ba ("mini-os: add memory map service functions")
> Signed-off-by: Juergen Gross <jgross@suse.com>

I've committed this, but ...

> --- a/e820.c
> +++ b/e820.c
> @@ -365,7 +365,7 @@ unsigned long e820_get_reserved_pfns(int pages)
>      unsigned long last = 0, needed = (long)pages << PAGE_SHIFT;
>  
>      for ( i = 0; i < e820_entries && e820_map[i].addr < last + needed; i++ )
> -        last = e820_map[i].addr + e820_map[i].size;
> +        last = round_pgup(e820_map[i].addr + e820_map[i].size);
>  
>      if ( i == 0 || e820_map[i - 1].type != E820_TYPE_SOFT_RESERVED )
>          e820_insert_entry_at(i, last, needed, E820_TYPE_SOFT_RESERVED);

... I had to resolve fuzz here: There's no E820_TYPE_SOFT_RESERVED in the
upstream tree, afaics. I just hope I didn't screw up ...

Jan
Re: [MINI-OS PATCH] e820: fix e820_get_reserved_pfns() to reserve page aligned area
Posted by Jürgen Groß 3 months, 2 weeks ago
On 14.07.25 16:02, Jan Beulich wrote:
> On 11.07.2025 14:03, Juergen Gross wrote:
>> e820_get_reserved_pfns() needs to make sure to reserve only page
>> aligned memory areas.
>>
>> Fixes: a7d27a7332ba ("mini-os: add memory map service functions")
>> Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> I've committed this, but ...
> 
>> --- a/e820.c
>> +++ b/e820.c
>> @@ -365,7 +365,7 @@ unsigned long e820_get_reserved_pfns(int pages)
>>       unsigned long last = 0, needed = (long)pages << PAGE_SHIFT;
>>   
>>       for ( i = 0; i < e820_entries && e820_map[i].addr < last + needed; i++ )
>> -        last = e820_map[i].addr + e820_map[i].size;
>> +        last = round_pgup(e820_map[i].addr + e820_map[i].size);
>>   
>>       if ( i == 0 || e820_map[i - 1].type != E820_TYPE_SOFT_RESERVED )
>>           e820_insert_entry_at(i, last, needed, E820_TYPE_SOFT_RESERVED);
> 
> ... I had to resolve fuzz here: There's no E820_TYPE_SOFT_RESERVED in the
> upstream tree, afaics. I just hope I didn't screw up ...

Oh, I had this on top of my kexec() series. Your adaption is looking fine.


Juergen
Re: [MINI-OS PATCH] e820: fix e820_get_reserved_pfns() to reserve page aligned area
Posted by Jan Beulich 3 months, 3 weeks ago
On 11.07.2025 14:03, Juergen Gross wrote:
> e820_get_reserved_pfns() needs to make sure to reserve only page
> aligned memory areas.
> 
> Fixes: a7d27a7332ba ("mini-os: add memory map service functions")
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>