nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: NFIT: Fix support for virtual SPA ranges
@ 2021-07-30 16:45 Dan Williams
  2021-08-04 16:54 ` Jeff Moyer
  2021-08-11 18:53 ` [PATCH v2] " Dan Williams
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Williams @ 2021-07-30 16:45 UTC (permalink / raw)
  To: nvdimm
  Cc: Jacek Zloch, Lukasz Sobieraj, Lee, Chun-Yi, stable,
	Krzysztof Rusocki, Damian Bassa, vishal.l.verma

Fix the NFIT parsing code to treat a 0 index in a SPA Range Structure as
a special case and not match Region Mapping Structures that use 0 to
indicate that they are not mapped. Without this fix some platform BIOS
descriptions of "virtual disk" ranges do not result in the pmem driver
attaching to the range.

Details:
In addition to typical persistent memory ranges, the ACPI NFIT may also
convey "virtual" ranges. These ranges are indicated by a UUID in the SPA
Range Structure of UUID_VOLATILE_VIRTUAL_DISK, UUID_VOLATILE_VIRTUAL_CD,
UUID_PERSISTENT_VIRTUAL_DISK, or UUID_PERSISTENT_VIRTUAL_CD. The
critical difference between virtual ranges and UUID_PERSISTENT_MEMORY, is
that virtual do not support associations with Region Mapping Structures.
For this reason the "index" value of virtual SPA Range Structures is
allowed to be 0. If a platform BIOS decides to represent unmapped
NVDIMMs with a 0 index in their "SPA Range Structure Index" the driver
falsely matches them and may falsely require labels where "virtual
disks" are expected to be label-less. I.e. label-less is where the
namespace-range == region-range and the pmem driver attaches with no
user action to create a namespace.

Cc: Jacek Zloch <jacek.zloch@intel.com>
Cc: Lukasz Sobieraj <lukasz.sobieraj@intel.com>
Cc: "Lee, Chun-Yi" <jlee@suse.com>
Cc: <stable@vger.kernel.org>
Fixes: c2f32acdf848 ("acpi, nfit: treat virtual ramdisk SPA as pmem region")
Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
Reported-by: Damian Bassa <damian.bassa@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/acpi/nfit/core.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 23d9a09d7060..6f15e56ef955 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -3021,6 +3021,8 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
 		struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev;
 		struct nd_mapping_desc *mapping;
 
+		if (memdev->range_index == 0 || spa->range_index == 0)
+			continue;
 		if (memdev->range_index != spa->range_index)
 			continue;
 		if (count >= ND_MAX_MAPPINGS) {


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI: NFIT: Fix support for virtual SPA ranges
  2021-07-30 16:45 [PATCH] ACPI: NFIT: Fix support for virtual SPA ranges Dan Williams
@ 2021-08-04 16:54 ` Jeff Moyer
  2021-08-11 18:53 ` [PATCH v2] " Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2021-08-04 16:54 UTC (permalink / raw)
  To: Dan Williams
  Cc: nvdimm, Jacek Zloch, Lukasz Sobieraj, Lee, Chun-Yi, stable,
	Krzysztof Rusocki, Damian Bassa, vishal.l.verma

Dan Williams <dan.j.williams@intel.com> writes:

> Fix the NFIT parsing code to treat a 0 index in a SPA Range Structure as
> a special case and not match Region Mapping Structures that use 0 to
> indicate that they are not mapped. Without this fix some platform BIOS
> descriptions of "virtual disk" ranges do not result in the pmem driver
> attaching to the range.
>
> Details:
> In addition to typical persistent memory ranges, the ACPI NFIT may also
> convey "virtual" ranges. These ranges are indicated by a UUID in the SPA
> Range Structure of UUID_VOLATILE_VIRTUAL_DISK, UUID_VOLATILE_VIRTUAL_CD,
> UUID_PERSISTENT_VIRTUAL_DISK, or UUID_PERSISTENT_VIRTUAL_CD. The
> critical difference between virtual ranges and UUID_PERSISTENT_MEMORY, is
> that virtual do not support associations with Region Mapping Structures.
> For this reason the "index" value of virtual SPA Range Structures is
> allowed to be 0. If a platform BIOS decides to represent unmapped
                                                           ^^^^^^^^
> NVDIMMs with a 0 index in their "SPA Range Structure Index" the driver
  ^^^^^^^

That language confused me.  I thought you were talking about a separate
issue, whereby NVDIMMs which are not mapped (probably due to some errors
with the dimms themselves) would get an index of 0.  But upon
re-reading, I think you just meant that the virtual media is not mapped
via a region mapping structure.

> falsely matches them and may falsely require labels where "virtual
> disks" are expected to be label-less. I.e. label-less is where the
> namespace-range == region-range and the pmem driver attaches with no
> user action to create a namespace.


> Cc: Jacek Zloch <jacek.zloch@intel.com>
> Cc: Lukasz Sobieraj <lukasz.sobieraj@intel.com>
> Cc: "Lee, Chun-Yi" <jlee@suse.com>
> Cc: <stable@vger.kernel.org>
> Fixes: c2f32acdf848 ("acpi, nfit: treat virtual ramdisk SPA as pmem region")
> Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
> Reported-by: Damian Bassa <damian.bassa@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/acpi/nfit/core.c |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 23d9a09d7060..6f15e56ef955 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -3021,6 +3021,8 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
>  		struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev;
>  		struct nd_mapping_desc *mapping;
>  
> +		if (memdev->range_index == 0 || spa->range_index == 0)
> +			continue;
>  		if (memdev->range_index != spa->range_index)
>  			continue;
>  		if (count >= ND_MAX_MAPPINGS) {

The change looks good, but can you add a comment to the code?  With
that, you can add my:

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

Thanks!
Jeff


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] ACPI: NFIT: Fix support for virtual SPA ranges
  2021-07-30 16:45 [PATCH] ACPI: NFIT: Fix support for virtual SPA ranges Dan Williams
  2021-08-04 16:54 ` Jeff Moyer
@ 2021-08-11 18:53 ` Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2021-08-11 18:53 UTC (permalink / raw)
  To: nvdimm
  Cc: Jacek Zloch, Lukasz Sobieraj, Lee, Chun-Yi, stable,
	Krzysztof Rusocki, Damian Bassa, Jeff Moyer

Fix the NFIT parsing code to treat a 0 index in a SPA Range Structure as
a special case and not match Region Mapping Structures that use 0 to
indicate that they are not mapped. Without this fix some platform BIOS
descriptions of "virtual disk" ranges do not result in the pmem driver
attaching to the range.

Details:
In addition to typical persistent memory ranges, the ACPI NFIT may also
convey "virtual" ranges. These ranges are indicated by a UUID in the SPA
Range Structure of UUID_VOLATILE_VIRTUAL_DISK, UUID_VOLATILE_VIRTUAL_CD,
UUID_PERSISTENT_VIRTUAL_DISK, or UUID_PERSISTENT_VIRTUAL_CD. The
critical difference between virtual ranges and UUID_PERSISTENT_MEMORY,
is that virtual do not support associations with Region Mapping
Structures.  For this reason the "index" value of virtual SPA Range
Structures is allowed to be 0. If a platform BIOS decides to represent
NVDIMMs with disconnected "Region Mapping Structures" (range-index ==
0), the kernel may falsely associate them with standalone ranges where
the "SPA Range Structure Index" is also zero. When this happens the
driver may falsely require labels where "virtual disks" are expected to
be label-less. I.e. "label-less" is where the namespace-range ==
region-range and the pmem driver attaches with no user action to create
a namespace.

Cc: Jacek Zloch <jacek.zloch@intel.com>
Cc: Lukasz Sobieraj <lukasz.sobieraj@intel.com>
Cc: "Lee, Chun-Yi" <jlee@suse.com>
Cc: <stable@vger.kernel.org>
Fixes: c2f32acdf848 ("acpi, nfit: treat virtual ramdisk SPA as pmem region")
Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
Reported-by: Damian Bassa <damian.bassa@intel.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Changes since v1:
- Clarify the changelog (Jeff)
- Add a comment about why range_index is checked (Jeff)

 drivers/acpi/nfit/core.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 23d9a09d7060..a3ef6cce644c 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -3021,6 +3021,9 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
 		struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev;
 		struct nd_mapping_desc *mapping;
 
+		/* range index 0 == unmapped in SPA or invalid-SPA */
+		if (memdev->range_index == 0 || spa->range_index == 0)
+			continue;
 		if (memdev->range_index != spa->range_index)
 			continue;
 		if (count >= ND_MAX_MAPPINGS) {


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-11 18:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 16:45 [PATCH] ACPI: NFIT: Fix support for virtual SPA ranges Dan Williams
2021-08-04 16:54 ` Jeff Moyer
2021-08-11 18:53 ` [PATCH v2] " Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).