Message ID | 20240325213623.747590-1-papaluri@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [kvm-unit-tests,RFC,1/3] x86 EFI: Bypass call to fdt_check_header() | expand |
On Mon, Mar 25, 2024 at 04:36:21PM -0500, Pavan Kumar Paluri wrote: > Issuing a call to fdt_check_header() prevents running any of x86 UEFI > enabled tests. Bypass this call for x86 in order to enable UEFI > supported tests for KUT x86 arch. Ouch! Sorry about that. I think I prefer something like below, though. Thanks, drew diff --git a/lib/efi.c b/lib/efi.c index 5314eaa81e66..335b66d26092 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -312,6 +312,7 @@ static void* efi_get_var(efi_handle_t handle, struct efi_loaded_image_64 *image, return val; } +#if defined(__aarch64__) || defined(__riscv) static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) { efi_char16_t var[] = ENV_VARNAME_DTBFILE; @@ -330,6 +331,12 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) return fdt_check_header(fdt) == 0 ? fdt : NULL; } +#else +static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) +{ + return NULL; +} +#endif static const struct { struct efi_vendor_dev_path vendor; > > Fixes: 9632ce446b8f ("arm64: efi: Improve device tree discovery") > Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> > --- > lib/efi.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lib/efi.c b/lib/efi.c > index 5314eaa81e66..124e77685230 100644 > --- a/lib/efi.c > +++ b/lib/efi.c > @@ -328,6 +328,10 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > return NULL; > } > > +#ifdef __x86_64__ > + return fdt; > +#endif > + > return fdt_check_header(fdt) == 0 ? fdt : NULL; > } > > -- > 2.34.1 >
On 3/26/2024 3:51 AM, Andrew Jones wrote: > On Mon, Mar 25, 2024 at 04:36:21PM -0500, Pavan Kumar Paluri wrote: >> Issuing a call to fdt_check_header() prevents running any of x86 UEFI >> enabled tests. Bypass this call for x86 in order to enable UEFI >> supported tests for KUT x86 arch. > > Ouch! Sorry about that. I think I prefer something like below, though. > > Thanks, > drew > > diff --git a/lib/efi.c b/lib/efi.c > index 5314eaa81e66..335b66d26092 100644 > --- a/lib/efi.c > +++ b/lib/efi.c > @@ -312,6 +312,7 @@ static void* efi_get_var(efi_handle_t handle, struct efi_loaded_image_64 *image, > return val; > } > > +#if defined(__aarch64__) || defined(__riscv) > static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > { > efi_char16_t var[] = ENV_VARNAME_DTBFILE; > @@ -330,6 +331,12 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > > return fdt_check_header(fdt) == 0 ? fdt : NULL; > } > +#else > +static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > +{ > + return NULL; > +} > +#endif > > static const struct { > struct efi_vendor_dev_path vendor; > Thanks for the review, this looks better. I will soon send out a v2 with the changes. Thanks, Pavan >> >> Fixes: 9632ce446b8f ("arm64: efi: Improve device tree discovery") >> Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> >> --- >> lib/efi.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/lib/efi.c b/lib/efi.c >> index 5314eaa81e66..124e77685230 100644 >> --- a/lib/efi.c >> +++ b/lib/efi.c >> @@ -328,6 +328,10 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) >> return NULL; >> } >> >> +#ifdef __x86_64__ >> + return fdt; >> +#endif >> + >> return fdt_check_header(fdt) == 0 ? fdt : NULL; >> } >> >> -- >> 2.34.1 >>
On 3/26/2024 3:51 AM, Andrew Jones wrote: > On Mon, Mar 25, 2024 at 04:36:21PM -0500, Pavan Kumar Paluri wrote: >> Issuing a call to fdt_check_header() prevents running any of x86 UEFI >> enabled tests. Bypass this call for x86 in order to enable UEFI >> supported tests for KUT x86 arch. > > Ouch! Sorry about that. I think I prefer something like below, though. > > Thanks, > drew > > diff --git a/lib/efi.c b/lib/efi.c > index 5314eaa81e66..335b66d26092 100644 > --- a/lib/efi.c > +++ b/lib/efi.c > @@ -312,6 +312,7 @@ static void* efi_get_var(efi_handle_t handle, struct efi_loaded_image_64 *image, > return val; > } > > +#if defined(__aarch64__) || defined(__riscv) I just realized, I had to move this line all the way upto efi_get_var in order to avoid the following compilation warnings/errors (for x86 build): lib/efi.c:299:14: error: ‘efi_get_var’ defined but not used [-Werror=unused-function] 299 | static void* efi_get_var(efi_handle_t handle, struct efi_loaded_image_64 *image, efi_char16_t *var) | ^~~~~~~~~~~ lib/efi.c:210:13: error: ‘efi_load_image’ defined but not used [-Werror=unused-function] 210 | static void efi_load_image(efi_handle_t handle, struct efi_loaded_image_64 *image, void **data, | ^~~~~~~~~~~~~~ cc1: all warnings being treated as errors Diff after applying the change below: diff --git a/lib/efi.c b/lib/efi.c index 5314eaa81e66..8a74a22834a4 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -204,6 +204,7 @@ static char *efi_convert_cmdline(struct efi_loaded_image_64 *image, int *cmd_lin return (char *)cmdline_addr; } +#if defined(__aarch64__) || defined(__riscv) /* * Open the file and read it into a buffer. */ @@ -330,6 +331,12 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) return fdt_check_header(fdt) == 0 ? fdt : NULL; } +#else +static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) +{ + return NULL; +} +#endif static const struct { struct efi_vendor_dev_path vendor; > static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > { > efi_char16_t var[] = ENV_VARNAME_DTBFILE; > @@ -330,6 +331,12 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > > return fdt_check_header(fdt) == 0 ? fdt : NULL; > } > +#else > +static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) > +{ > + return NULL; > +} > +#endif > > static const struct { > struct efi_vendor_dev_path vendor; > Thanks, Pavan
diff --git a/lib/efi.c b/lib/efi.c index 5314eaa81e66..124e77685230 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -328,6 +328,10 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) return NULL; } +#ifdef __x86_64__ + return fdt; +#endif + return fdt_check_header(fdt) == 0 ? fdt : NULL; }
Issuing a call to fdt_check_header() prevents running any of x86 UEFI enabled tests. Bypass this call for x86 in order to enable UEFI supported tests for KUT x86 arch. Fixes: 9632ce446b8f ("arm64: efi: Improve device tree discovery") Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> --- lib/efi.c | 4 ++++ 1 file changed, 4 insertions(+)