efi: small hii conformance fix
cover efi: small hii conformance fix
Hi,
The following couple of patches fixes a small UEFI HII conformance issue and adds a selftest demonstrating the issue.
This is sent in this order to avoid breaking `bootefi selftest' in the middle but feel free to apply in any order if preferred.
Best regards,
Vincent.
Vincent Stehlé (2):
efi_loader: fix get_package_list_handle() status
efi_selftest: add hii database protocol test case
lib/efi_loader/efi_hii.c | 2 +- lib/efi_selftest/efi_selftest_hii.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
PATCH 1/2 efi_loader: fix get_package_list_handle() status
When the HII protocol function get_package_list_handle() is called with an invalid package list handle, it returns EFI_NOT_FOUND but this is not in its list of possible status codes as per the EFI specification. Return EFI_INVALID_PARAMETER instead to fix conformance.
--- lib/efi_loader/efi_hii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_hii.c +1 -1
@@ -780,7 +780,7 @@ get_package_list_handle(const struct efi_hii_database_protocol *this, } } -return EFI_EXIT (EFI_NOT_FOUND ); +return EFI_EXIT (EFI_INVALID_PARAMETER ); }const struct efi_hii_database_protocol efi_hii_database = {
Signature · 1 line
2.35.1
Re: [PATCH 1/2] efi_loader: fix get_package_list_handle() status
Quoted 4 lines · Vincent Stehl??
When the HII protocol function
get_package_list_handle()is called with an invalid package list handle, it returnsEFI_NOT_FOUNDbut this is not in its list of possible status codes as per the EFI specification. ReturnEFI_INVALID_PARAMETERinstead to fix conformance.
Thank you for the heads-up.
You're right as far as the EFI specification is concerned.
FYI,
EDK-II also returns EFI_NOT_FOUND if the package list handle is *valid* and yet we cannot find any matching handle in the HII database. See
MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
-Takahiro Akashi
Quoted 23 lines
Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>--- lib/efi_loader/efi_hii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/efi_loader/efi_hii.c +1
-1@@ -780,7 +780,7 @@ get_package_list_handle(const struct efi_hii_database_protocol *this, } } -return EFI_EXIT (EFI_NOT_FOUND ); +return EFI_EXIT (EFI_INVALID_PARAMETER ); }const struct efi_hii_database_protocol efi_hii_database = {Signature · 1 line
2.35.1
Re: [PATCH 1/2] efi_loader: fix get_package_list_handle() status
In reply to Vincent StehléQuoted 8 lines · Vincent Stehlé
When the HII protocol function
get_package_list_handle()is called with an invalid package list handle, it returnsEFI_NOT_FOUNDbut this is not in its list of possible status codes as per the EFI specification. ReturnEFI_INVALID_PARAMETERinstead to fix conformance.Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>
PATCH 2/2 efi_selftest: add hii database protocol test case
In reply to Vincent StehléAdd a test for the case when the HII database protocol get_package_list_handle() function is called with an invalid package list handle.
--- lib/efi_selftest/efi_selftest_hii.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/efi_selftest/efi_selftest_hii.c +10 -0
@@ -605,6 +605,16 @@ static int test_hii_database_get_package_list_handle(void) goto out; } +/* Invalid package list handle. */ + driver_handle =NULL ; + ret = hii_database_protocol->get_package_list_handle ( + hii_database_protocol,NULL , &driver_handle); +if (ret !=EFI_INVALID_PARAMETER ) { +efi_st_error ("get_package_list_handle returned %u not invalid\n" , + (unsigned int )ret); + goto out; + } + result =EFI_ST_SUCCESS ; out:
Signature · 1 line
2.35.1
Re: [PATCH 2/2] efi_selftest: add hii database protocol test case
Quoted 16 lines · Vincent Stehlé
Add a test for the case when the HII database protocol
get_package_list_handle()function is called with an invalid package list handle.Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>--- lib/efi_selftest/efi_selftest_hii.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/efi_selftest/efi_selftest_hii.c +0
-0
lib/efi_selftest/efi_selftest_hii.c static int test_hii_database_get_package_list_handle(void) · line 612
Quoted 8 lines
lib/efi_selftest/efi_selftest_hii.c +5
-0@@ -605,6 +605,16 @@ static int test_hii_database_get_package_list_handle(void) goto out; } +/* Invalid package list handle. */ + driver_handle =NULL ; + ret = hii_database_protocol->get_package_list_handle ( + hii_database_protocol,NULL , &driver_handle); +if (ret !=EFI_INVALID_PARAMETER ) {
Here it is unclear, if you get EFI_INVALID_PARAMETER because the PackageListHandle is invalid or DriverHandle is NULL.
We should test both cases separately.
Best regards
Heinrich
Quoted 8 lines
lib/efi_selftest/efi_selftest_hii.c +5
-0+efi_st_error ("get_package_list_handle returned %u not invalid\n" , + (unsigned int )ret); + goto out; + } + result =EFI_ST_SUCCESS ; out:
Re: [PATCH 2/2] efi_selftest: add hii database protocol test case
On Thu, Dec 22, 2022 at 10:45:22AM +0100, Heinrich Schuchardt wrote:
Hi Heinrich,
Happy new year, and thank you for the reviews.
More comments below.
Quoted 20 lines · Vincent Stehlé
Quoted 19 lines
Add a test for the case when the HII database protocol
get_package_list_handle()function is called with an invalid package list handle.Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>--- lib/efi_selftest/efi_selftest_hii.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/efi_selftest/efi_selftest_hii.c +0
-0@@ -605,6 +605,16 @@ static int test_hii_database_get_package_list_handle(void) goto out; }
Quoted 8 lines
lib/efi_selftest/efi_selftest_hii.c static int test_hii_database_get_package_list_handle(void) · line 612
Quoted 5 lines
lib/efi_selftest/efi_selftest_hii.c +5
-0+/* Invalid package list handle. */ + driver_handle =NULL ; + ret = hii_database_protocol->get_package_list_handle ( + hii_database_protocol,NULL , &driver_handle); +if (ret !=EFI_INVALID_PARAMETER ) {Here it is unclear, if you get
EFI_INVALID_PARAMETERbecause the PackageListHandle is invalid or DriverHandle is NULL.
In principle, the value used to initialize the (output) parameter driver_handle should not affect the test. Also, we are initializing driver_handle in exactly the same way as was done in the previous test, which we know succeeded.
Anyway, if you think it makes the test more readable I can change the initialization to something like the following:
driver_handle = (efi_handle_t)0x23456789; /* dummy */
Quoted 2 lines
We should test both cases separately.
Would you prefer something like the following couple of tests?
/* Invalid package list handle. */ driver_handle = (efi_handle_t)0x23456789; /* dummy */ ret = hii_database_protocol->get_package_list_handle(
hii_database_protocol, NULL, &driver_handle);
/* Invalid driver handle. */
ret = hii_database_protocol->get_package_list_handle(
hii_database_protocol, handle, NULL);
I could verify that EFI_INVALID_PARAMETER is indeed returned in both cases. Just let me know and I will post a v2.
Best regards,
Vincent.
Quoted 14 lines
Best regards
Heinrich
Quoted 8 lines
lib/efi_selftest/efi_selftest_hii.c +5
-0+efi_st_error ("get_package_list_handle returned %u not invalid\n" , + (unsigned int )ret); + goto out; + } + result =EFI_ST_SUCCESS ; out:
Re: [PATCH 2/2] efi_selftest: add hii database protocol test case
Quoted 46 lines · Vincent Stehlé
On Thu, Dec 22, 2022 at 10:45:22AM +0100, Heinrich Schuchardt wrote:
Hi Heinrich,
Happy new year, and thank you for the reviews.
More comments below.Quoted 20 lines · Vincent Stehlé
Quoted 19 lines
Add a test for the case when the HII database protocol
get_package_list_handle()function is called with an invalid package list handle.Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>--- lib/efi_selftest/efi_selftest_hii.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/efi_selftest/efi_selftest_hii.c +0
-0@@ -605,6 +605,16 @@ static int test_hii_database_get_package_list_handle(void) goto out; }Quoted 8 lines
lib/efi_selftest/efi_selftest_hii.c static int test_hii_database_get_package_list_handle(void) · line 612
Quoted 5 lines
lib/efi_selftest/efi_selftest_hii.c +5
-0+/* Invalid package list handle. */ + driver_handle =NULL ; + ret = hii_database_protocol->get_package_list_handle ( + hii_database_protocol,NULL , &driver_handle); +if (ret !=EFI_INVALID_PARAMETER ) {Here it is unclear, if you get
EFI_INVALID_PARAMETERbecause the PackageListHandle is invalid or DriverHandle is NULL.In principle, the value used to initialize the (output) parameter
driver_handleshould not affect the test. Also, we are initializingdriver_handlein exactly the same way as was done in the previous test, which we know succeeded.Anyway, if you think it makes the test more readable I can change the initialization to something like the following:
driver_handle = (efi_handle_t)0x23456789; /* dummy */Quoted 1 line
Quoted 6 lines
Quoted 1 line
We should test both cases separately.
Would you prefer something like the following couple of tests?
/* Invalid package list handle. */ driver_handle = (efi_handle_t)0x23456789; /* dummy */
Let's use an address that never will be allocated. driver_handle = (efi_handle_t)~1UL;
Quoted 9 lines
ret = hii_database_protocol->get_package_list_handle( hii_database_protocol, NULL, &driver_handle); /* Invalid driver handle. */ ret = hii_database_protocol->get_package_list_handle( hii_database_protocol, handle, NULL);I could verify that
EFI_INVALID_PARAMETERis indeed returned in both cases. Just let me know and I will post a v2.
Looks like the right path forward.
Best regards
Heinrich
Quoted 18 lines
Best regards,
Vincent.Quoted 14 lines
Best regards
Heinrich
Quoted 8 lines
lib/efi_selftest/efi_selftest_hii.c +5
-0+efi_st_error ("get_package_list_handle returned %u not invalid\n" , + (unsigned int )ret); + goto out; + } + result =EFI_ST_SUCCESS ; out: