Commit Graph

45 Commits

Author SHA1 Message Date
Mariusz Tkaczyk 8662f92d71 imsm: Limit support to the lowest namespace
First namespace existence is not quaranted by NVMe specification.
Instead first the smallest one shall be chosen.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-05-26 07:26:32 -04:00
Mariusz Tkaczyk fcebeb77b1 imsm: add devpath_to_char method
Add method for reading sysfs attributes and propagate it across IMSM code.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-05-26 07:26:30 -04:00
Mariusz Tkaczyk 7c798f8709 imsm: add generic method to resolve "device" links
Each virtual device is linked with parent by "device". This patch adds
possibility to get previous device in sysfs tree.

Depending on device type, there is a different amount of virutal
layers. The best we can do is allow to directly specify how many
"device" links need to be resolved. This approach also allows to get
previous virtual device, which may contain some attributes.

Simplify fd2devname, this function doesn't require new functionality and
shall use generic fd2kname.

For nvme drives represented via nvme-subystem when path to block
device if requested, then return it without translation.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-05-26 07:26:21 -04:00
Mariusz Tkaczyk f94df5cf83 imsm: support for third Sata controller
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>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-03-18 10:50:53 -04:00
Blazej Kucman d835518b6b imsm: nvme multipath support
Add support for nvme devices which are represented
via nvme-subsystem.
Print warning when multi-path disk is added to RAID.

Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@intel.com>
Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-03-16 16:22:39 -04:00
Mariusz Tkaczyk a8f3cfd54e imsm: limit support to first NVMe namespace
Due to metadata limitations NVMe multinamespace support has to be removed.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
2020-11-25 18:09:47 -05:00
Roman Sobanski 5c4cc0c820 imsm: Avoid duplicate entries in --detail-platform
In some scenarios mdadm --detail-platform shows duplicated info about one
of controllers. Block it.

Signed-off-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-09-27 10:28:35 -04:00
Jes Sorensen d7be7d8736 mdadm: Fixup more broken logical operator formatting
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 13:59:43 -04:00
Alexey Obitotskiy d3c1141658 imsm: count arrays under VMD HBAs correctly
OROM defines maximum number of arrays supported. On array creation mdadm
checks if number of arrays doesn't exceed that limit, however it is not
calculated correctly for VMD now.

The current code performs a lookup of HBA using the id. VMD HBAs have
the same id so each lookup returns the same structure (first
encountered). Take a different approach for VMD HBAs. As id is not
unique and cannot be used for lookups, iterate over all VMD HBAs and
compare both id and HBA path.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-01-09 07:48:55 -05:00
Alexey Obitotskiy 30730cb8c4 Don't assume VMD sysfs path ends with a disk entry
When VMD is enabled but no drive is attached to the PCIe port, mdadm
crashes trying to parse the path. Skip entry if valid path has not been
returned. Do it early to avoid unnecessary memory allocation.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2017-01-04 08:26:50 -05:00
Jes Sorensen b913501173 {platform,super}-intel: Fix two resource leaks
The code did not free 'dir' allocated by opendir(). An additional
benefit is that this simplifies the for() loops.

Fixes: 60f0f54d ("IMSM: Add support for VMD")
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2016-03-09 11:35:34 -05:00
NeilBrown 7071320a18 Assorted fixed for a "make everything" build
Signed-off-by: NeilBrown <neilb@suse.com>
2016-01-28 13:28:58 +11:00
Pawel Baldysiak 60f0f54d6f IMSM: Add support for VMD
The Intel Volume Management Device (VMD) is an integrated
endpoint on the platform's PCIe root complex that acts
as a host bridge to a secondary PCIe domain.

This patch adds proper handling of NVMe devices attached to VMD domain.
Each VMD domain is treated as a separate controller (HBA).
Spanning between domains is forbidden.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2016-01-06 12:22:57 +11:00
Pawel Baldysiak 72a4577704 IMSM: Count arrays per orom
Active arrays with IMSM metadata are counted per hba so far.
This is bad due to new functionality of orom shared between multiple
controllers i.e. more arrays can be created than is supported by orom.
This patch changes the way of counting arrays, so the result will be
sum of arrays under every hba supported by specific orom.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-04-09 09:06:23 +10:00
Pawel Baldysiak f666bcc652 IMSM-orom: make sure, that device list is supported
Devices list in PCI Data Structure is supported only in
3 and above revision. Make sure that this is checked.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-03-04 15:59:53 +11:00
Artur Paszkiewicz 5e1d612824 imsm: simplified multiple OROMs support
Replaced oroms array with list, add_orom() now only appends to this list
and add_orom_device_id() only appends devid_list node to an orom_entry.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-03-04 15:56:56 +11:00
Artur Paszkiewicz 88605db99c imsm: use efivarfs interface for reading UEFI variables
Read UEFI variables using the new efivarfs interface, fallback to
sysfs-efivars if that fails.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-11-25 11:37:38 +11:00
Artur Paszkiewicz 0858eccf86 imsm: detail-platform improvements
Print platform details per OROM, not per controller, differentiate
RST(e) platforms from legacy IMSM, print NVMe device paths, adjust port
printing to newer sysfs path.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-11-25 11:37:38 +11:00
Pawel Baldysiak 614902f64e imsm: add support for NVMe devices
Recognize Intel(R) NVMe devices as IMSM-capable.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-11-25 11:37:38 +11:00
Artur Paszkiewicz 81188ef870 imsm: support for second and combined AHCI controllers in UEFI mode
Grantly platform introduces a second AHCI controller (sSATA) and two new
UEFI variables for the RSTe firmware. This patch adds support for those
variables in order to correctly determine IMSM platform capabilities in
UEFI mode.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-11-25 11:37:38 +11:00
Artur Paszkiewicz 6b781d331b imsm: support for OROMs shared by multiple HBAs
The IMSM platform code was based on an assumption that the OROM or UEFI
capability structure (represented by struct imsm_orom) always belongs to
only one HBA. This assumption is no longer valid, because of newer
platforms with dual AHCI HBAs. Each HBA can have a separate OROM, but
some versions have a combined OROM for both HBAs.

This patch implements this HBA-OROM relationship in struct orom_entry,
which matches an OROM with a list of HBA PCI ids. All the detected
orom_entries are stored and retrieved using a global array and the
functions add_orom(), add_orom_device_id() and get_orom_by_device_id().
This replaces the arrays: imsm_orom, populated_orom, imsm_efi,
populated_efi.

The scan() function is extended to find all HBAs for an OROM. The list
of their device ids is retrieved from the PCI Expansion ROM Data
Structure, hence the additional field devListOffset in struct
pciExpDataStructFormat.

In UEFI mode we can't read the PCI Expansion ROM Data Structure and the
imsm_orom structures are stored in UEFI variables. They do not provide a
similar device id list, so we also check the HBA PCI class to make sure
that the HBA has RAID mode enabled.

In super-intel.c there are changes which allow spanning of IMSM
containers over HBAs of the same type, but only if the HBAs share the
same OROM.  This is done by comparing imsm_orom pointers, which (outside
of platform-intel.c) always point to the global array containing all the
detected oroms. Additional warnings are added to
validate_container_imsm() to warn about potentially dangerous operations
in all the possible cases, e.g. when an array is assembled using disks
attached to HBAs with separate OROMs.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-11-25 11:34:02 +11:00
NeilBrown 1011e8344a Remove lots of unnecessary white space.
Now that I am using white-space mode in Emacs I can see all of this,
and I don't like it :-)

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-19 12:31:45 +10:00
John Spencer e3635eee64 platform-intel: canonicalize_file_name() is not portable
this is a GLIBC specific feature and should not be used.

according to its manpage:
"The call canonicalize_file_name(path) is equivalent
to the call realpath(path, NULL)."

thus, we use realpath so it works everywhere.

Signed-off-by: John Spencer <maillist-mdadm@barfooze.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-02-10 15:40:47 +11:00
NeilBrown 9bc4ae77e4 platform-intel - cache 'intel_devices' for a few seconds.
find_intel_devices() has take a little while to run as it scans
some directory tree, and the result isn't likely to change
often.
So cache the value and only discard it after 10 seconds.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-01-07 10:34:43 +11:00
NeilBrown 5d5002289c Replace a lot of leading spaces with tabs.
Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-10 18:33:26 +11:00
NeilBrown 503975b9d5 Remove scattered checks for malloc success.
malloc should never fail, and if it does it is unlikely
that anything else useful can be done.  Best approach is to
abort and let some super-daemon restart.

So define xmalloc, xcalloc, xrealloc, xstrdup which don't
fail but just print a message and exit.  Then use those
removing all the tests for failure.

Also replace all "malloc;memset" sequences with 'xcalloc'.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:14:16 +10:00
Hawrylewicz Czarnowski, Przemyslaw aae4c11166 imsm: reading of UEFI variables needs an update
Content of EFI variable is stored in "data" file. Moreover size of data
provided by given variable can be initially validated by reading value of
"size" file.
Function read_efi_variable() has been introduced to simplify the code.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-28 10:42:07 +11:00
Hawrylewicz Czarnowski, Przemyslaw 96687b797f imsm: remove OEM table from detection of OROM and EFI.
OEM table does not suit our needs so it cannot be used.
This patch removes feature added in commit 8a0bf4f378.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-28 10:41:35 +11:00
Labun, Marcin 8a0bf4f378 platform_intel: support EFI SCU OEM variable
RstScuV and RstScuO variable names are supported.
First try reading from RstScuV, when it fails try RstScuO.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Tested-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-20 15:47:33 +11:00
Labun, Marcin 9c747fa0ff platfrom_intel: find OROM based on Intel AHCI and SAS driver device id
We use PCI device id exposed by AHCI and ISCU drivers (SAS controller)
to find OROM version table.
In this way there is no need to maintain AHCI and ISCU device id list
in mdadm. The consequence is that the OROM properties can be found by mdadm when AHCI or
SAS drivers are loaded in the system.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-14 18:18:46 +11:00
Labun, Marcin d0bc5190d7 platform_intel: support for OROM OEM capabilities
Scan memory to match $VER and $OEM.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:52:22 +11:00
Labun, Marcin 5a6baf6653 read platform capabilities from EFI
If operating system is installed using efi, IMSM platform capabilities are
 not available via option ROM, but are stored as efi variables. New
 mechanism has been introduced to obtain capabilities by variables.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:45:35 +11:00
Labun, Marcin 1a90147116 Some guid manipulation utilities has been added.
It will be used for reading efi variables with capabilities.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:45:15 +11:00
Labun, Marcin fc13853f4e Platform-intel: support for OROM SAS and AHCI controller
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:44:21 +11:00
Labun, Marcin 3c8bfb5ddd probe_roms: allow to probe expansion ROMs using vendor and device id.
Adds data offset to PCI expansion ROM Data Structure in resource
describing Expansion ROMs. This allows AHCI OROM scanning function
to identify AHCI OROM by device id 0x2822 and vendor id 0x8086.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:41:46 +11:00
Labun Marcin a8e5382a54 imsm platform: support for Intel(R) SAS controller.
This patch adds platform support for SAS controller(s) built in Intel(R) Patsburg
chipset.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 11:06:55 +10:00
NeilBrown f21e18ca89 Compile with -Wextra by default
This produced lots of warning, some of which pointed to actual bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 13:13:02 +10:00
Artur Wojcik 5dbb8c8d76 Fix for buffer overflow defect.
Array index of 'path' may be out of bounds. Array
'path' of size 256 may use index value(s) 0..284.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 37f0e1e025 Fix for buffer overflow error.
Array index of 'device' may be out of bounds. Array 'device'
of size 40 may use index value(s) 0..43.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 5a1920f2c2 Fix for buffer overflow defect in 'link'.
Potential buffer overflow of 'link' caused by user input may occur,
due to non null-terminated string 'link'.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 11:52:23 -07:00
NeilBrown 2a17c77bdb Add a missing 'closedir'.
Thanks to David Binderman for finding and reporting it.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-09-11 16:10:24 +10:00
Dan Williams 969c255511 platform: relax rom scanning alignment for ahci platforms
The PCI-3.0 Firmware specification allows for option-roms to have
512-byte alignment rather than 2048-byte.  As there does not appear to
be a reliable method to detect a PCI-3.0 compliant BIOS from userspace
we allow the imsm platform detection code to presume that a system
modern enough to have an Intel AHCI controller does not have
dangerous/legacy ISA regions in the option-ROM memory space.

An environment variable to disable this behaviour, IMSM_SAFE_OROM_SCAN,
is added in case this presumption is ever proven wrong.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams cceebc67f1 imsm: provide a simulated option-rom for regression tests
IMSM_NO_PLATFORM turns off checks that should be tested, so provide a
IMSM_TEST_OROM variable to allow testing the orom constraints in the
mdadm regression suite.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 14:26:10 -07:00
Dan Williams 25921536da imsm: sysfs support routines for determining device connectivity
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams b390f61061 imsm: detect option-rom capabilities
The option-rom advertises its capabilities in a data structure located in
the platform ROM region 0xc0000-0xf0000.  Attempt to detect the option-rom
and limit array creation to the platform's capabilities.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00