From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: jes@trained-monkey.org
Cc: linux-raid@vger.kernel.org
Subject: [PATCH] imsm: support for third Sata controller
Date: Wed, 17 Mar 2021 13:01:54 +0100 [thread overview]
Message-ID: <20210317120154.30806-1-mariusz.tkaczyk@linux.intel.com> (raw)
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
next reply other threads:[~2021-03-17 12:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 12:01 Mariusz Tkaczyk [this message]
2021-03-18 15:20 ` [PATCH] imsm: support for third Sata controller Jes Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210317120154.30806-1-mariusz.tkaczyk@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=jes@trained-monkey.org \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox