From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CEC423183C; Mon, 23 Jun 2025 09:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750670036; cv=none; b=IBPfHEbiD831MsgysXAIAhTgr7He2VEJfSckrk+jtpjRgaYpAe7j1HsZJr8I+W349XCHT2LdWo/J0iDFIHp2Xc2VHehRGlQEo12JsljLQ/LPz72rPDjkMTTal79Z2mQWJ28YAHQPezeFZEOPfpLnBTUIFNU4QY0gB0dLt6gwe6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750670036; c=relaxed/simple; bh=JysO40ZAFUS1sTNcaKwvVhL7fQmMi1O3qbD6rXGu7e8=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lucnwlOGbSPJ/suL1FG1PpeoxpKGaYX69GN81XaMEiOwDBHpVBOiBELsjCD6HdBNWtQ2pQUZz6iqS0vp1jR97mxNFGlQeuxTQNPDmBJkJofX1nuA+6OtbaR/96sLUxwy1fw9AJFZnJi5szMTtkqicwhXGJoqefDKuKLh/RBs6v8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bQj1f45p1z6L5WZ; Mon, 23 Jun 2025 17:08:54 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 3579A140446; Mon, 23 Jun 2025 17:13:50 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 23 Jun 2025 11:13:49 +0200 Date: Mon, 23 Jun 2025 10:13:47 +0100 From: Jonathan Cameron To: Neeraj Kumar CC: , , , , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH 08/20] nvdimm/label: Include region label in slot validation Message-ID: <20250623101347.00003d7a@huawei.com> In-Reply-To: <148912029.181750165204802.JavaMail.epsvc@epcpadp1new> References: <20250617123944.78345-1-s.neeraj@samsung.com> <148912029.181750165204802.JavaMail.epsvc@epcpadp1new> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500011.china.huawei.com (7.191.174.215) To frapeml500008.china.huawei.com (7.182.85.71) On Tue, 17 Jun 2025 18:09:32 +0530 Neeraj Kumar 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 > 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);