* [PATCH] imsm: support for third Sata controller
@ 2021-03-17 12:01 Mariusz Tkaczyk
2021-03-18 15:20 ` Jes Sorensen
0 siblings, 1 reply; 2+ messages in thread
From: Mariusz Tkaczyk @ 2021-03-17 12:01 UTC (permalink / raw)
To: jes; +Cc: linux-raid
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@linux.intel.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] imsm: support for third Sata controller
2021-03-17 12:01 [PATCH] imsm: support for third Sata controller Mariusz Tkaczyk
@ 2021-03-18 15:20 ` Jes Sorensen
0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2021-03-18 15:20 UTC (permalink / raw)
To: Mariusz Tkaczyk; +Cc: linux-raid
On 3/17/21 8:01 AM, Mariusz Tkaczyk wrote:
> 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@linux.intel.com>
> ---
> platform-intel.c | 58 ++++++++++++++++++++++++++----------------------
> 1 file changed, 31 insertions(+), 27 deletions(-)
>
Applied!
Thanks,
Jes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-18 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-17 12:01 [PATCH] imsm: support for third Sata controller Mariusz Tkaczyk
2021-03-18 15:20 ` Jes Sorensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox