All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens.net>
To: development@efficientek.com
Cc: The development of GNU GRUB <grub-devel@gnu.org>,
	leif@nuviainc.com, stefanb@linux.ibm.com, ps@pks.im,
	dkiper@net-space.pl
Subject: Re: [PATCH 11/19] efi: mm: Extract function to add memory regions
Date: Fri, 25 Mar 2022 14:30:54 +1100	[thread overview]
Message-ID: <87mthe909d.fsf@dja-thinkpad.axtens.net> (raw)
In-Reply-To: <20211019165820.10a21feb@crass-HP-ZBook-15-G2>

>>    /* Prepare a memory region to store two memory maps.  */
>>    memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
>>    if (! memory_map)
>> -    grub_fatal ("cannot allocate memory");
>> +    return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
>
> Something more descriptive would be nice, may be even "cannot allocate
> memory for memory map"

Yes.

>>  
>>    /* Obtain descriptors for available memory.  */
>>    map_size = MEMORY_MAP_SIZE;
>> @@ -588,14 +588,14 @@ grub_efi_mm_init (void)
>>  
>>        memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size));
>>        if (! memory_map)
>> -	grub_fatal ("cannot allocate memory");
>> +	return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
>
> Ditto. And maybe nice to have it slightly different, perhaps "cannot
> re-allocate memory map"

Yes.

>>  
>>        mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0,
>>  					   &desc_size, 0);
>>      }
>>  
>>    if (mm_status < 0)
>> -    grub_fatal ("cannot get memory map");
>> +    return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot get memory map");
>
> What are the range of values that mm_status could be? Would it be
> useful to include the status code in the error message? IOW, could a
> failure here be affected by a configuration that the user could change
> to make this work? Also I like the message "failed to retrieve memory
> map (status=%d)".
>

The function says:
/* Get the memory map as defined in the EFI spec. Return 1 if successful,
   return 0 if partial, or return -1 if an error occurs.  */

So no, I don't think we could print anything more interesting without
reworking the grub_efi_get_memory_map function.

>>  
>>    memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size);
>>  
>> @@ -610,7 +610,7 @@ grub_efi_mm_init (void)
>>  
>>    /* Allocate memory regions for GRUB's memory management.  */
>>    add_memory_regions (filtered_memory_map, desc_size,
>> -		      filtered_memory_map_end, BYTES_TO_PAGES (DEFAULT_HEAP_SIZE));
>> +		      filtered_memory_map_end, BYTES_TO_PAGES (required_bytes));
>>  
>>  #if 0
>>    /* For debug.  */
>
> What about turning this on when MM_DEBUG is on? Seems like it could be
> a useful (would been to get rid of/change the grub_fatal calls).
>

Perhaps, but I'm not sufficiently across EFI to be confident making that
sort of change, and I'm not well set up to test EFI systems or evaluate
the correctness or usefulness of any output. I think this would be
better deferred to another patch from someone with more experience in
the field.

Kind regards,
Daniel


  reply	other threads:[~2022-03-25  3:31 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  7:29 [PATCH 00/19] Requesting more memory from firmware Daniel Axtens
2021-10-12  7:29 ` [PATCH 01/19] grub-shell: Boot PowerPC using PMU instead of CUDA for power management Daniel Axtens
2021-10-12 17:11   ` Glenn Washburn
2021-10-20 15:39     ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 02/19] grub-shell: pseries: don't pass fw_opt to qemu Daniel Axtens
2021-10-12 18:57   ` Glenn Washburn
2021-10-20 15:43     ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 03/19] mm: document grub internal memory management structures Daniel Axtens
2021-10-12 19:18   ` Glenn Washburn
2021-11-24  0:57     ` Daniel Axtens
2021-10-12  7:29 ` [PATCH 04/19] mm: assert that we preserve header vs region alignment Daniel Axtens
2021-10-20 17:43   ` Daniel Kiper
2022-03-23  5:47     ` Daniel Axtens
2022-03-24 15:20       ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 05/19] mm: when adding a region, merge with region after as well as before Daniel Axtens
2021-11-04 16:36   ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 06/19] configure: properly pass through MM_DEBUG Daniel Axtens
2021-11-04 18:00   ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 07/19] Add memtool module with memory allocation stress-test Daniel Axtens
2021-10-19 19:47   ` Glenn Washburn
2021-11-09 12:54   ` Daniel Kiper
2021-11-10 22:29     ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 08/19] mm: Drop unused unloading of modules on OOM Daniel Axtens
2021-11-09 13:15   ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 09/19] mm: Allow dynamically requesting additional memory regions Daniel Axtens
2021-11-09 13:25   ` Daniel Kiper
2021-10-12  7:29 ` [PATCH 10/19] efi: mm: Always request a fixed number of pages on init Daniel Axtens
2021-11-09 13:32   ` Daniel Kiper
2021-10-12  7:30 ` [PATCH 11/19] efi: mm: Extract function to add memory regions Daniel Axtens
2021-10-19 21:39   ` Glenn Washburn
2021-10-19 21:58   ` Glenn Washburn
2022-03-25  3:30     ` Daniel Axtens [this message]
2021-11-09 13:38   ` Daniel Kiper
2021-10-12  7:30 ` [PATCH 12/19] efi: mm: Pass up errors from `add_memory_regions ()` Daniel Axtens
2021-10-19 21:37   ` Glenn Washburn
2021-11-09 13:56     ` Daniel Kiper
2021-11-09 16:10   ` Daniel Kiper
2021-10-12  7:30 ` [PATCH 13/19] efi: mm: Implement runtime addition of pages Daniel Axtens
2021-11-09 16:13   ` Daniel Kiper
2021-10-12  7:30 ` [PATCH 14/19] ieee1275: request memory with ibm, client-architecture-support Daniel Axtens
2021-10-12  7:30 ` [PATCH 15/19] ieee1275: drop len -= 1 quirk in heap_init Daniel Axtens
2021-10-12  7:30 ` [PATCH 16/19] ieee1275: support runtime memory claiming Daniel Axtens
2021-10-12  7:30 ` [PATCH 17/19] [not for merge] print more debug info in mm Daniel Axtens
2021-11-10 13:47   ` Daniel Kiper
2021-11-10 19:35     ` Glenn Washburn
2021-11-10 22:17       ` Daniel Kiper
2021-10-12  7:30 ` [PATCH 18/19] [not for merge] ieee1275 debugging info Daniel Axtens
2021-10-12  7:30 ` [PATCH 19/19] RFC: Ignore REGION_CONSECUTIVE Daniel Axtens
2021-11-10 14:00   ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mthe909d.fsf@dja-thinkpad.axtens.net \
    --to=dja@axtens.net \
    --cc=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=leif@nuviainc.com \
    --cc=ps@pks.im \
    --cc=stefanb@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.