diff mbox series

[v4,06/21] efi_loader: Allow SMBIOS tables in highmem

Message ID 20180618152315.34233-7-agraf@suse.de
State Accepted
Commit 62f375787084b1835967bc4d735bc245096b99fc
Headers show
Series sandbox: efi_loader support | expand

Commit Message

Alexander Graf June 18, 2018, 3:23 p.m. UTC
We try hard to make sure that SMBIOS tables live in the lower 32bit.
However, when we can not find any space at all there, we should not
error out but instead just fall back to map them in the full address
space instead.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_smbios.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Simon Glass June 21, 2018, 2:01 a.m. UTC | #1
Hi Alex,

On 18 June 2018 at 09:23, Alexander Graf <agraf@suse.de> wrote:
> We try hard to make sure that SMBIOS tables live in the lower 32bit.
> However, when we can not find any space at all there, we should not
> error out but instead just fall back to map them in the full address
> space instead.

Does this actually happen?

>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  lib/efi_loader/efi_smbios.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
> index 7c3fc8af0b..932f7582ec 100644
> --- a/lib/efi_loader/efi_smbios.c
> +++ b/lib/efi_loader/efi_smbios.c
> @@ -26,8 +26,15 @@ efi_status_t efi_smbios_register(void)
>         /* Reserve 4kiB page for SMBIOS */
>         ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
>                                  EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
> -       if (ret != EFI_SUCCESS)
> -               return ret;
> +
> +       if (ret != EFI_SUCCESS) {
> +               /* Could not find space in lowmem, use highmem instead */
> +               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
> +                                        EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
> +
> +               if (ret != EFI_SUCCESS)
> +                       return ret;
> +       }
>
>         /*
>          * Generate SMBIOS tables - we know that efi_allocate_pages() returns
> --
> 2.12.3
>

Regards,
Simon
Alexander Graf June 21, 2018, 9:38 a.m. UTC | #2
On 06/21/2018 04:01 AM, Simon Glass wrote:
> Hi Alex,
>
> On 18 June 2018 at 09:23, Alexander Graf <agraf@suse.de> wrote:
>> We try hard to make sure that SMBIOS tables live in the lower 32bit.
>> However, when we can not find any space at all there, we should not
>> error out but instead just fall back to map them in the full address
>> space instead.
> Does this actually happen?

No, but it can. It really doesn't need to be part of this patch set either.

The main target where things like this can happen would be systems like 
an AMD Seattle, which does not have any RAM mapped <4GB.


Alex
Alexander Graf June 21, 2018, 3:13 p.m. UTC | #3
> We try hard to make sure that SMBIOS tables live in the lower 32bit.
> However, when we can not find any space at all there, we should not
> error out but instead just fall back to map them in the full address
> space instead.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Thanks, applied to efi-next

Alex
Simon Glass June 21, 2018, 7:44 p.m. UTC | #4
Hi Alex,

On 21 June 2018 at 03:38, Alexander Graf <agraf@suse.de> wrote:
>
> On 06/21/2018 04:01 AM, Simon Glass wrote:
>>
>> Hi Alex,
>>
>> On 18 June 2018 at 09:23, Alexander Graf <agraf@suse.de> wrote:
>>>
>>> We try hard to make sure that SMBIOS tables live in the lower 32bit.
>>> However, when we can not find any space at all there, we should not
>>> error out but instead just fall back to map them in the full address
>>> space instead.
>>
>> Does this actually happen?
>
>
> No, but it can. It really doesn't need to be part of this patch set either.
>
> The main target where things like this can happen would be systems like an AMD Seattle, which does not have any RAM mapped <4GB.

Ah OK. Then I think you should add that info to the commit message so
it is clear the problem we are solving.

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 7c3fc8af0b..932f7582ec 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -26,8 +26,15 @@  efi_status_t efi_smbios_register(void)
 	/* Reserve 4kiB page for SMBIOS */
 	ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
 				 EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
-	if (ret != EFI_SUCCESS)
-		return ret;
+
+	if (ret != EFI_SUCCESS) {
+		/* Could not find space in lowmem, use highmem instead */
+		ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+					 EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
+
+		if (ret != EFI_SUCCESS)
+			return ret;
+	}
 
 	/*
 	 * Generate SMBIOS tables - we know that efi_allocate_pages() returns