On Tue, 17 Jun 2025 18:09:32 +0530 Neeraj Kumar <[email protected]> wrote:
> slot validation routine validates label slot by calculating label > checksum. It was only validating namespace label. This changeset also > validates region label if present. > > Also validate and calculate lsa v2.1 namespace label checksum > > Signed-off-by: Neeraj Kumar <[email protected]> > diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h > index 1e5a68013735..ca8256b31472 100644 > --- a/drivers/nvdimm/nd.h > +++ b/drivers/nvdimm/nd.h > @@ -331,6 +331,22 @@ static inline bool nsl_region_uuid_equal(struct > nd_namespace_label *ns_label, > return uuid_equal(&tmp, uuid); > } > > +static inline bool is_region_label(struct nvdimm_drvdata *ndd, > + struct nd_lsa_label *nd_label) > +{ > + uuid_t ns_type, region_type; > + > + if (ndd->cxl) { > + uuid_parse(CXL_REGION_UUID, ®ion_type); > + import_uuid(&ns_type, nd_label->ns_label.cxl.type); > + if (uuid_equal(®ion_type, &ns_type)) > + return true; > + else > + return false; return uuid_equal(®_type, &ns_type); > + } else {} for all legs if one needs it. However, if you aren't going to add more code here later, just flip the condition and exit early. if (!ndd->cxl) return false; uuid_parse... > + return false; > +} > + > static inline bool rgl_uuid_equal(struct cxl_region_label *rg_label, > const uuid_t *uuid) > { > @@ -340,6 +356,11 @@ static inline bool rgl_uuid_equal(struct > cxl_region_label *rg_label, > return uuid_equal(&tmp, uuid); > } > > +static inline u32 rgl_get_slot(struct cxl_region_label *rg_label) > +{ > + return __le32_to_cpu(rg_label->slot); > +} > + > static inline u64 rgl_get_checksum(struct cxl_region_label *rg_label) > { > return __le64_to_cpu(rg_label->checksum);

