[PATCH v2 7/7] efi_selftest: Enhance MBR test for PARTITION_INFO_PROTOCOL

Ilias Apalodimas ilias.apalodimas at linaro.org
Fri Feb 13 09:46:58 CET 2026


On Thu, 12 Feb 2026 at 22:45, Javier Martinez Canillas
<javierm at redhat.com> wrote:
>
> The EFI_PARTITION_INFO_PROTOCOL test was added before the protocol fully
> supported MBR partitions. As a result, it lacked specific checks for the
> content of the raw MBR partition record.
>
> Now that MBR support has been implemented, enhance the selftest to provide
> coverage for the MBR entries too.
>
> This verifies that the protocol correctly reads and exposes MBR partition
> records and prevents this functionality to regress due future changes.
>
> Signed-off-by: Javier Martinez Canillas <javierm at redhat.com>
> ---

Acked-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>

>
> (no changes since v1)
>
>  lib/efi_selftest/efi_selftest_block_device.c | 26 ++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c
> index f145e58a267a..9c4be834eebb 100644
> --- a/lib/efi_selftest/efi_selftest_block_device.c
> +++ b/lib/efi_selftest/efi_selftest_block_device.c
> @@ -19,6 +19,7 @@
>  #include "efi_selftest_disk_image.h"
>  #include <asm/cache.h>
>  #include <part_efi.h>
> +#include <part.h>
>
>  /* Block size of compressed disk image */
>  #define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8
> @@ -319,6 +320,25 @@ static int execute(void)
>         u64 pos;
>         char block_io_aligned[1 << LB_BLOCK_SIZE] __aligned(1 << LB_BLOCK_SIZE);
>
> +       /*
> +        * The test disk image is defined in efi_selftest_disk_image.h,
> +        * it contains a single FAT12 partition of 127 sectors size.
> +        */
> +       static const dos_partition_t mbr_expected = {
> +               .boot_ind = 0x00,
> +               .head = 0x00,
> +               .sector = 0x02,
> +               .cyl = 0x00,
> +               .sys_ind = 0x01, /* FAT12 */
> +               .end_head = 0x02,
> +               .end_sector = 0x02,
> +               .end_cyl = 0x00,
> +               /* LBA 1 */
> +               .start_sect = cpu_to_le32(1),
> +               /* Size 127 sectors (0x7f) */
> +               .nr_sects = cpu_to_le32(127),
> +       };
> +
>         /* Connect controller to virtual disk */
>         ret = boottime->connect_controller(disk_handle, NULL, NULL, 1);
>         if (ret != EFI_SUCCESS) {
> @@ -405,6 +425,12 @@ static int execute(void)
>                 return EFI_ST_FAILURE;
>         }
>
> +       /* Compare the obtained MBR with the expected one for the test partition */
> +       if (memcmp(&part_info->info.mbr, &mbr_expected, sizeof(mbr_expected))) {
> +               efi_st_error("MBR partition record mismatch\n");
> +               return EFI_ST_FAILURE;
> +       }
> +
>         /* Open the simple file system protocol */
>         ret = boottime->open_protocol(handle_partition,
>                                       &guid_simple_file_system_protocol,
> --
> 2.53.0
>


More information about the U-Boot mailing list