lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251217150909.00003f98@huawei.com>
Date: Wed, 17 Dec 2025 15:09:09 +0000
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Neeraj Kumar <s.neeraj@...sung.com>
CC: <linux-cxl@...r.kernel.org>, <nvdimm@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>, <gost.dev@...sung.com>,
	<a.manzanares@...sung.com>, <vishak.g@...sung.com>, <neeraj.kernel@...il.com>
Subject: Re: [PATCH V4 08/17] nvdimm/label: Preserve cxl region information
 from region label

On Wed, 19 Nov 2025 13:22:46 +0530
Neeraj Kumar <s.neeraj@...sung.com> wrote:

> Preserve region information from region label during nvdimm_probe. This
> preserved region information is used for creating cxl region to achieve
> region persistency across reboot.
> 
> Signed-off-by: Neeraj Kumar <s.neeraj@...sung.com>
Trivial comments inline.  As Dave asked, what's the plan for multiple?
Add some brief notes to the patch description on this.

Thanks,

Jonathan

> ---
>  drivers/nvdimm/dimm.c     |  4 ++++
>  drivers/nvdimm/label.c    | 40 +++++++++++++++++++++++++++++++++++++++
>  drivers/nvdimm/nd-core.h  |  2 ++
>  drivers/nvdimm/nd.h       |  1 +
>  include/linux/libnvdimm.h | 14 ++++++++++++++
>  5 files changed, 61 insertions(+)
> 
> diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
> index 07f5c5d5e537..590ec883903d 100644
> --- a/drivers/nvdimm/dimm.c
> +++ b/drivers/nvdimm/dimm.c
> @@ -107,6 +107,10 @@ static int nvdimm_probe(struct device *dev)
>  	if (rc)
>  		goto err;
>  
> +	/* Preserve cxl region info if available */
> +	if (ndd->cxl)
> +		nvdimm_cxl_region_preserve(ndd);
> +
>  	return 0;
>  
>   err:
> diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
> index da55ecd95e2f..0f8aea61b504 100644
> --- a/drivers/nvdimm/label.c
> +++ b/drivers/nvdimm/label.c
> @@ -490,6 +490,46 @@ int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd)
>  	return 0;
>  }
>  
> +int nvdimm_cxl_region_preserve(struct nvdimm_drvdata *ndd)
> +{
> +	struct nvdimm *nvdimm = to_nvdimm(ndd->dev);
> +	struct cxl_pmem_region_params *p = &nvdimm->cxl_region_params;
> +	struct nd_namespace_index *nsindex;
> +	unsigned long *free;
> +	u32 nslot, slot;
> +
> +	if (!preamble_current(ndd, &nsindex, &free, &nslot))
> +		return 0; /* no label, nothing to preserve */
> +
> +	for_each_clear_bit_le(slot, free, nslot) {
> +		union nd_lsa_label *lsa_label;
> +		struct cxl_region_label *region_label;
> +		uuid_t *region_uuid;
> +
> +		lsa_label = to_lsa_label(ndd, slot);
> +		region_label = &lsa_label->region_label;
> +		region_uuid = (uuid_t *) &region_label->type;
> +
		union nd_lsa_label *lsa_label = to_lsa_label(ndd, slot);
		struct cxl_region_label *region_label = &lsa_label->region_label;
//I'd go long on thi sone as only just over 80 and helps readability.
		uuid_t *region_uuid = (uuid_t *)&region_label->type;

Saves a fine lines and there doesn't seem to be an obvious reason
not to do so.

> +		/* TODO: Currently preserving only one region */
> +		if (uuid_equal(&cxl_region_uuid, region_uuid)) {
> +			nvdimm->is_region_label = true;
> +			import_uuid(&p->uuid, region_label->uuid);
> +			p->flags = __le32_to_cpu(region_label->flags);
> +			p->nlabel = __le16_to_cpu(region_label->nlabel);
> +			p->position = __le16_to_cpu(region_label->position);
> +			p->dpa = __le64_to_cpu(region_label->dpa);
> +			p->rawsize = __le64_to_cpu(region_label->rawsize);
> +			p->hpa = __le64_to_cpu(region_label->hpa);
> +			p->slot = __le32_to_cpu(region_label->slot);
> +			p->ig = __le32_to_cpu(region_label->ig);
> +			p->align = __le32_to_cpu(region_label->align);
> +			break;
> +		}
> +	}
> +
> +	return 0;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ