Add new UEFI TSata variable. Remove CSata variable. This variable has been never exposed by UEFI. Remove vulnerability to match different hbas with SATA variable. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@xxxxxxxxxxxxxxx> --- platform-intel.c | 58 ++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/platform-intel.c b/platform-intel.c index f1f6d4cd..5ae2d453 100644 --- a/platform-intel.c +++ b/platform-intel.c @@ -486,7 +486,7 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) #define SCU_PROP "RstScuV" #define AHCI_PROP "RstSataV" #define AHCI_SSATA_PROP "RstsSatV" -#define AHCI_CSATA_PROP "RstCSatV" +#define AHCI_TSATA_PROP "RsttSatV" #define VMD_PROP "RstUefiV" #define VENDOR_GUID \ @@ -494,7 +494,8 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) #define PCI_CLASS_RAID_CNTRL 0x010400 -static int read_efi_var(void *buffer, ssize_t buf_size, char *variable_name, struct efi_guid guid) +static int read_efi_var(void *buffer, ssize_t buf_size, + const char *variable_name, struct efi_guid guid) { char path[PATH_MAX]; char buf[GUID_STR_MAX]; @@ -523,7 +524,8 @@ static int read_efi_var(void *buffer, ssize_t buf_size, char *variable_name, str return 0; } -static int read_efi_variable(void *buffer, ssize_t buf_size, char *variable_name, struct efi_guid guid) +static int read_efi_variable(void *buffer, ssize_t buf_size, + const char *variable_name, struct efi_guid guid) { char path[PATH_MAX]; char buf[GUID_STR_MAX]; @@ -576,7 +578,9 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) { struct imsm_orom orom; struct orom_entry *ret; - int err; + static const char * const sata_efivars[] = {AHCI_PROP, AHCI_SSATA_PROP, + AHCI_TSATA_PROP}; + unsigned long i; if (check_env("IMSM_TEST_AHCI_EFI") || check_env("IMSM_TEST_SCU_EFI")) return imsm_platform_test(hba); @@ -585,35 +589,35 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) if (check_env("IMSM_TEST_OROM")) return NULL; - if (hba->type == SYS_DEV_SATA && hba->class != PCI_CLASS_RAID_CNTRL) - return NULL; - - err = read_efi_variable(&orom, sizeof(orom), hba->type == SYS_DEV_SAS ? SCU_PROP : AHCI_PROP, VENDOR_GUID); + switch (hba->type) { + case SYS_DEV_SAS: + if (!read_efi_variable(&orom, sizeof(orom), SCU_PROP, + VENDOR_GUID)) + break; - /* try to read variable for second AHCI controller */ - if (err && hba->type == SYS_DEV_SATA) - err = read_efi_variable(&orom, sizeof(orom), AHCI_SSATA_PROP, VENDOR_GUID); + return NULL; + case SYS_DEV_SATA: + if (hba->class != PCI_CLASS_RAID_CNTRL) + return NULL; - /* try to read variable for combined AHCI controllers */ - if (err && hba->type == SYS_DEV_SATA) { - static struct orom_entry *csata; + for (i = 0; i < ARRAY_SIZE(sata_efivars); i++) { + if (!read_efi_variable(&orom, sizeof(orom), + sata_efivars[i], VENDOR_GUID)) + break; - err = read_efi_variable(&orom, sizeof(orom), AHCI_CSATA_PROP, VENDOR_GUID); - if (!err) { - if (!csata) - csata = add_orom(&orom); - add_orom_device_id(csata, hba->dev_id); - csata->type = hba->type; - return &csata->orom; } - } + if (i == ARRAY_SIZE(sata_efivars)) + return NULL; - if (hba->type == SYS_DEV_VMD) { - err = read_efi_variable(&orom, sizeof(orom), VMD_PROP, VENDOR_GUID); - } - - if (err) + break; + case SYS_DEV_VMD: + if (!read_efi_variable(&orom, sizeof(orom), VMD_PROP, + VENDOR_GUID)) + break; return NULL; + default: + return NULL; + } ret = add_orom(&orom); add_orom_device_id(ret, hba->dev_id); -- 2.26.2