efi_loader: run CreateEvent() notify function based on flags
PATCH 1/2 efi_loader: run CreateEvent() notify function based on flags
The UEFI specification states that the tpl, function and context arguments are to be ignored if neither EVT_NOTIFY_WAIT or EVT_NOTIFY_SIGNAL are specified. This matches observed behaviour with an AMI EDK2 based UEFI implementation.
Skip calling the notify function if neither flag is present.
--- include/efi_api.h | 3 +++ lib/efi_loader/efi_boottime.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
include/efi_api.h +3 -0
@@ -28,6 +28,9 @@ enum efi_event_type {EFI_TIMER_RELATIVE =2 }; +#define EVT_NOTIFY_WAIT 0x00000100 +#define EVT_NOTIFY_SIGNAL 0x00000200 +/* EFI Boot Services table */ struct efi_boot_services {struct efi_table_hdr hdr;
lib/efi_loader/efi_boottime.c +3 -1
@@ -210,7 +210,9 @@ void efi_timer_check(void)/* Triggering! */ if (efi_event.trigger_type ==EFI_TIMER_PERIODIC ) efi_event.trigger_next += efi_event.trigger_time /10 ; - efi_event.notify_function (&efi_event, efi_event.notify_context); +if (efi_event.type & (EVT_NOTIFY_WAIT |EVT_NOTIFY_SIGNAL )) + efi_event.notify_function (&efi_event, + efi_event.notify_context); }WATCHDOG_RESET ();
Signature · 1 line
2.12.0
PATCH 2/2 efi_loader: check CreateEvent() parameters
Add some of the invalid parameter checks described in the UEFI specification for CreateEvent(). This does not include checking the validity of the type and tpl parameters.
--- lib/efi_loader/efi_boottime.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/efi_loader/efi_boottime.c +10 -0
@@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(return EFI_EXIT (EFI_OUT_OF_RESOURCES ); } +if (event ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + +if ((type &EVT_NOTIFY_SIGNAL ) && (type &EVT_NOTIFY_WAIT )) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + +if ((type & (EVT_NOTIFY_SIGNAL |EVT_NOTIFY_WAIT )) && + notify_function ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + efi_event.type = type; efi_event.notify_tpl = notify_tpl; efi_event.notify_function = notify_function;
Signature · 1 line
2.12.0
PATCH 2/2 efi_loader: check CreateEvent() parameters
Quoted 21 lines · Jonathan Gray
Add some of the invalid parameter checks described in the UEFI specification for
CreateEvent(). This does not include checking the validity of the type and tpl parameters.Signed-off-by Jonathan Gray <[email protected]>--- lib/efi_loader/efi_boottime.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/efi_loader/efi_boottime.c +3
-0@@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(return EFI_EXIT (EFI_OUT_OF_RESOURCES ); } +if (event ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); +
lib/efi_loader/efi_boottime.c static efi_status_t EFIAPI efi_create_event( · line 204
Quoted 10 lines
lib/efi_loader/efi_boottime.c +7
-0+if ((type &EVT_NOTIFY_SIGNAL ) && (type &EVT_NOTIFY_WAIT )) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + +if ((type & (EVT_NOTIFY_SIGNAL |EVT_NOTIFY_WAIT )) && + notify_function ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + efi_event.type = type; efi_event.notify_tpl = notify_tpl; efi_event.notify_function = notify_function;
In case of EVT_NOTIFY_WAIT we should also check if the event is already in the signaled state. But this flag is not implemented yet.
[U-Boot] Pull request: efi_loader: check CreateEvent() parameters
Dear Tom,
could you, please, consider pulling
[U-Boot,1/2] efi_loader: run CreateEvent() notify function based on flags
https://patchwork.ozlabs.org/patch/737793/
[U-Boot,2/2] efi_loader: check CreateEvent() parameters
https://patchwork.ozlabs.org/patch/737794/
I have reviewed the patches and tested loading grub via EFI on an Odroid C2 based on git HEAD (8d6040c725bfa40fba1bd6b5f356ee713c1ac7d1).
Best regards
Heinrich Schuchardt
Quoted 38 lines · Heinrich Schuchardt
Quoted 21 lines · Jonathan Gray
Add some of the invalid parameter checks described in the UEFI specification for
CreateEvent(). This does not include checking the validity of the type and tpl parameters.Signed-off-by Jonathan Gray <[email protected]>--- lib/efi_loader/efi_boottime.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/efi_loader/efi_boottime.c +3
-0@@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(return EFI_EXIT (EFI_OUT_OF_RESOURCES ); } +if (event ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); +lib/efi_loader/efi_boottime.c static efi_status_t EFIAPI efi_create_event( · line 204
Quoted 10 lines
lib/efi_loader/efi_boottime.c +7
-0+if ((type &EVT_NOTIFY_SIGNAL ) && (type &EVT_NOTIFY_WAIT )) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + +if ((type & (EVT_NOTIFY_SIGNAL |EVT_NOTIFY_WAIT )) && + notify_function ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + efi_event.type = type; efi_event.notify_tpl = notify_tpl; efi_event.notify_function = notify_function;In case of
EVT_NOTIFY_WAITwe should also check if the event is already in the signaled state. But this flag is not implemented yet.
[U-Boot] Pull request: efi_loader: check CreateEvent() parameters
Hi Heinrich,
Thanks a lot for the reminder email. I'll get them integrated asap.
Alex
Quoted 56 lines · Heinrich Schuchardt
Dear Tom,
could you, please, consider pulling
[U-Boot,1/2]
efi_loader: runCreateEvent()notify function based on flags
https://patchwork.ozlabs.org/patch/737793/[U-Boot,2/2]
efi_loader: checkCreateEvent()parameters
https://patchwork.ozlabs.org/patch/737794/I have reviewed the patches and tested loading grub via EFI on an Odroid C2 based on git HEAD (
8d6040c725bfa40fba1bd6b5f356ee713c1ac7d1).Best regards
Heinrich Schuchardt
Quoted 37 lines · Heinrich Schuchardt
Quoted 21 lines · Jonathan Gray
Add some of the invalid parameter checks described in the UEFI specification for
CreateEvent(). This does not include checking the validity of the type and tpl parameters.Signed-off-by Jonathan Gray <[email protected]>--- lib/efi_loader/efi_boottime.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/efi_loader/efi_boottime.c +3
-0@@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(return EFI_EXIT (EFI_OUT_OF_RESOURCES ); } +if (event ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); +lib/efi_loader/efi_boottime.c static efi_status_t EFIAPI efi_create_event( · line 204
Quoted 10 lines
lib/efi_loader/efi_boottime.c +7
-0+if ((type &EVT_NOTIFY_SIGNAL ) && (type &EVT_NOTIFY_WAIT )) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + +if ((type & (EVT_NOTIFY_SIGNAL |EVT_NOTIFY_WAIT )) && + notify_function ==NULL ) +return EFI_EXIT (EFI_INVALID_PARAMETER ); + efi_event.type = type; efi_event.notify_tpl = notify_tpl; efi_event.notify_function = notify_function;In case of
EVT_NOTIFY_WAITwe should also check if the event is already in the signaled state. But this flag is not implemented yet.
Alexander Graf
AppliedPATCH 2/2 efi_loader: check CreateEvent() parameters
In reply to Jonathan GrayQuoted 6 lines
Add some of the invalid parameter checks described in the UEFI specification for
CreateEvent(). This does not include checking the validity of the type and tpl parameters.Signed-off-by Jonathan Gray <[email protected]>
Thanks, applied to efi-next
Alex
PATCH 1/2 efi_loader: run CreateEvent() notify function based on flags
In reply to Jonathan GrayQuoted 8 lines · Jonathan Gray
The UEFI specification states that the tpl, function and context arguments are to be ignored if neither
EVT_NOTIFY_WAITorEVT_NOTIFY_SIGNALare specified. This matches observed behaviour with an AMI EDK2 based UEFI implementation.Skip calling the notify function if neither flag is present.
Signed-off-by Jonathan Gray <[email protected]>
In case of EVT_NOTIFY_WAIT we should also check if the event is already in the signaled state. But this flag is not implemented yet. Couldn't you implement that flag first?
Quoted 35 lines
--- include/efi_api.h | 3 +++ lib/efi_loader/efi_boottime.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)include/efi_api.h +3
-0@@ -28,6 +28,9 @@ enum efi_event_type {EFI_TIMER_RELATIVE =2 }; +#define EVT_NOTIFY_WAIT 0x00000100 +#define EVT_NOTIFY_SIGNAL 0x00000200 +/* EFI Boot Services table */ struct efi_boot_services {struct efi_table_hdr hdr;lib/efi_loader/efi_boottime.c +3
-1@@ -210,7 +210,9 @@ void efi_timer_check(void)/* Triggering! */ if (efi_event.trigger_type ==EFI_TIMER_PERIODIC ) efi_event.trigger_next += efi_event.trigger_time /10 ; - efi_event.notify_function (&efi_event, efi_event.notify_context); +if (efi_event.type & (EVT_NOTIFY_WAIT |EVT_NOTIFY_SIGNAL )) + efi_event.notify_function (&efi_event, + efi_event.notify_context); }WATCHDOG_RESET ();
Alexander Graf
AppliedPATCH 1/2 efi_loader: run CreateEvent() notify function based on flags
In reply to Jonathan GrayQuoted 9 lines
The UEFI specification states that the tpl, function and context arguments are to be ignored if neither
EVT_NOTIFY_WAITorEVT_NOTIFY_SIGNALare specified. This matches observed behaviour with an AMI EDK2 based UEFI implementation.Skip calling the notify function if neither flag is present.
Signed-off-by Jonathan Gray <[email protected]>
Thanks, applied to efi-next
Alex