diff mbox series

[U-Boot,v9,13/18] efi: Add a call to exit() along with why we can't use it

Message ID 20180808095433.230882-14-sjg@chromium.org
State Superseded, archived
Delegated to: Alexander Graf
Headers show
Series efi: Enable sandbox support for EFI loader | expand

Commit Message

Simon Glass Aug. 8, 2018, 9:54 a.m. UTC
The test should exit like any other EFI application, by calling exit()
in the boot services API. But this crashes at present on sandbox. For now,
add in the placeholder code.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 lib/efi_loader/efi_test.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Heinrich Schuchardt Aug. 23, 2018, 8:37 p.m. UTC | #1
On 08/08/2018 11:54 AM, Simon Glass wrote:
> The test should exit like any other EFI application, by calling exit()
> in the boot services API. But this crashes at present on sandbox. For now,
> add in the placeholder code.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v9: None
> Changes in v8: None
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  lib/efi_loader/efi_test.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c
> index 4b8d49f324b..5401a0f4715 100644
> --- a/lib/efi_loader/efi_test.c
> +++ b/lib/efi_loader/efi_test.c
> @@ -9,8 +9,18 @@
>  int efi_test(efi_handle_t image_handle, struct efi_system_table *systable)
>  {
>  	struct efi_simple_text_output_protocol *con_out = systable->con_out;
> +	struct efi_boot_services *boottime = systable->boottime;
> +	int ret;
>  
> -	con_out->output_string(con_out, L"Hello, world!\n");
> +	ret = con_out->output_string(con_out, L"Hello, world!\n");
> +
> +	/*
> +	 * We should really call EFI's exit() here but this crashes at present
> +	 * on sandbox due to the incorrect use of setjmp() and longjmp(). Once

What makes you think that setjmp and longjmp are incorrectly used?
Couldn't the sandbox implementation of both create the problem?

Best regards

Heinrich Schuchardt

> +	 * we can figure out how to make that work, this can be enabled.
> +	 */
> +	if (0)
> +		boottime->exit(image_handle, ret, 0, NULL);
>  
>  	return 0;
>  }
>
Alexander Graf Aug. 26, 2018, 5:13 p.m. UTC | #2
On 23.08.18 22:37, Heinrich Schuchardt wrote:
> On 08/08/2018 11:54 AM, Simon Glass wrote:
>> The test should exit like any other EFI application, by calling exit()
>> in the boot services API. But this crashes at present on sandbox. For now,
>> add in the placeholder code.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v9: None
>> Changes in v8: None
>> Changes in v7: None
>> Changes in v6: None
>> Changes in v5: None
>> Changes in v4: None
>> Changes in v3: None
>> Changes in v2: None
>>
>>  lib/efi_loader/efi_test.c | 12 +++++++++++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c
>> index 4b8d49f324b..5401a0f4715 100644
>> --- a/lib/efi_loader/efi_test.c
>> +++ b/lib/efi_loader/efi_test.c
>> @@ -9,8 +9,18 @@
>>  int efi_test(efi_handle_t image_handle, struct efi_system_table *systable)
>>  {
>>  	struct efi_simple_text_output_protocol *con_out = systable->con_out;
>> +	struct efi_boot_services *boottime = systable->boottime;
>> +	int ret;
>>  
>> -	con_out->output_string(con_out, L"Hello, world!\n");
>> +	ret = con_out->output_string(con_out, L"Hello, world!\n");
>> +
>> +	/*
>> +	 * We should really call EFI's exit() here but this crashes at present
>> +	 * on sandbox due to the incorrect use of setjmp() and longjmp(). Once
> 
> What makes you think that setjmp and longjmp are incorrectly used?
> Couldn't the sandbox implementation of both create the problem?

I agree, last time we tracked exit problems down to incorrect
setjmp/longjmp implementations in sandbox.


Alex
Simon Glass Sept. 14, 2018, 3:46 p.m. UTC | #3
Hi Alex,

On 26 August 2018 at 19:13, Alexander Graf <agraf@suse.de> wrote:
>
>
> On 23.08.18 22:37, Heinrich Schuchardt wrote:
>> On 08/08/2018 11:54 AM, Simon Glass wrote:
>>> The test should exit like any other EFI application, by calling exit()
>>> in the boot services API. But this crashes at present on sandbox. For now,
>>> add in the placeholder code.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>> Changes in v9: None
>>> Changes in v8: None
>>> Changes in v7: None
>>> Changes in v6: None
>>> Changes in v5: None
>>> Changes in v4: None
>>> Changes in v3: None
>>> Changes in v2: None
>>>
>>>  lib/efi_loader/efi_test.c | 12 +++++++++++-
>>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c
>>> index 4b8d49f324b..5401a0f4715 100644
>>> --- a/lib/efi_loader/efi_test.c
>>> +++ b/lib/efi_loader/efi_test.c
>>> @@ -9,8 +9,18 @@
>>>  int efi_test(efi_handle_t image_handle, struct efi_system_table *systable)
>>>  {
>>>      struct efi_simple_text_output_protocol *con_out = systable->con_out;
>>> +    struct efi_boot_services *boottime = systable->boottime;
>>> +    int ret;
>>>
>>> -    con_out->output_string(con_out, L"Hello, world!\n");
>>> +    ret = con_out->output_string(con_out, L"Hello, world!\n");
>>> +
>>> +    /*
>>> +     * We should really call EFI's exit() here but this crashes at present
>>> +     * on sandbox due to the incorrect use of setjmp() and longjmp(). Once
>>
>> What makes you think that setjmp and longjmp are incorrectly used?
>> Couldn't the sandbox implementation of both create the problem?
>
> I agree, last time we tracked exit problems down to incorrect
> setjmp/longjmp implementations in sandbox.

Yes that's what I mean. I'll reword it a bit.

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c
index 4b8d49f324b..5401a0f4715 100644
--- a/lib/efi_loader/efi_test.c
+++ b/lib/efi_loader/efi_test.c
@@ -9,8 +9,18 @@ 
 int efi_test(efi_handle_t image_handle, struct efi_system_table *systable)
 {
 	struct efi_simple_text_output_protocol *con_out = systable->con_out;
+	struct efi_boot_services *boottime = systable->boottime;
+	int ret;
 
-	con_out->output_string(con_out, L"Hello, world!\n");
+	ret = con_out->output_string(con_out, L"Hello, world!\n");
+
+	/*
+	 * We should really call EFI's exit() here but this crashes at present
+	 * on sandbox due to the incorrect use of setjmp() and longjmp(). Once
+	 * we can figure out how to make that work, this can be enabled.
+	 */
+	if (0)
+		boottime->exit(image_handle, ret, 0, NULL);
 
 	return 0;
 }