Hi Heinrich, On Sat, 9 Dec 2023 at 23:51, Heinrich Schuchardt <xypron.g...@gmx.de> wrote: > > On 11/14/23 10:25, Masahisa Kojima wrote: > > FMP versioning uses the image_index argument of > > EFI_FIRMWARE_MANAGEMENT_PROTOCOL.SetImage() service. > > When CONFIG_FWU_MULTI_BANK_UPDATE is enabled, image_index > > is updated by fwu_get_image_index() function. This commit > > saves the original image_index argument and use it for > > FMP versioning. > > Why should we call fwu_get_image_index() here if we don't use the new > value? Maybe the call should be placed somewhere else? > > Should the call really be needed here, please add a new local variable > inside the if block and add a comment describing why the call is needed.
fwu_get_image_index() aims to convert image_index in FMP.SetImage() to dfu_alt_num passed to dfu_write_by_alt() function. I think fwu_get_image_index() should be renamed and does not update original image_index. I will send the next version. Thanks, Masahisa Kojima > > Best regards > > Heinrich > > > > > Signed-off-by: Masahisa Kojima <masahisa.koj...@linaro.org> > > --- > > lib/efi_loader/efi_firmware.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c > > index 9abb29f1df..9c1a273926 100644 > > --- a/lib/efi_loader/efi_firmware.c > > +++ b/lib/efi_loader/efi_firmware.c > > @@ -612,6 +612,8 @@ efi_status_t EFIAPI efi_firmware_raw_set_image( > > { > > int ret; > > efi_status_t status; > > + u8 original_image_index = image_index; > > + > > struct fmp_state state = { 0 }; > > > > EFI_ENTRY("%p %d %p %zu %p %p %p\n", this, image_index, image, > > @@ -641,7 +643,7 @@ efi_status_t EFIAPI efi_firmware_raw_set_image( > > NULL, NULL)) > > return EFI_EXIT(EFI_DEVICE_ERROR); > > > > - efi_firmware_set_fmp_state_var(&state, image_index); > > + efi_firmware_set_fmp_state_var(&state, original_image_index); > > > > return EFI_EXIT(EFI_SUCCESS); > > } >