Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2075472ybp; Thu, 10 Oct 2019 01:44:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCKNEGsR3lOemovyyN6SL66xzYPXbVgyYm4bn6qyAx07vl+yeuneuy+/d/QNLGTl4G4dub X-Received: by 2002:aa7:d888:: with SMTP id u8mr6785255edq.144.1570697082624; Thu, 10 Oct 2019 01:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697082; cv=none; d=google.com; s=arc-20160816; b=R8tg5mYn87uQZnAHo40L4aD0InnXcK793l2OFEn0wExZ7N3UhwxhPutY96vXBuQC4/ /uHV4N52jOvKZ9kY35XgBAAAyImwiTTr+IPoaUtX4UOiQkAqGOfeAmPUMm6upn0189k8 QaOF34uBeWHpWsdsnQY++x96VXInGV2xNRrBBcvxGFlRBU5t8isbbc423RNDQWBdFKV1 Zfv1y2PrjThKWv6a8fAw7fuQQHMywK6cGgbs8clFl7Lb5IIhdqwyWNAglnZLhNZQqoFR ZRvItROnXZkFxqWQTs5F9gN44c4WMiHLb4n62sdH3ZSgiE3qKoCiNmHl7rcyF5/N1rq5 2AfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R3waPTd9B2E35KJ01Vxd412t1t8lXaR1NfrUXMLEiEA=; b=YHxRu5YCSm55aMSVI1jMP3pgAaLDIGNeqo0HKZGbcc7OITLVUqaaHbt5mIr89ZGwEa OM8vDXOcDuN2sMDWOcxjn35A7hRd1XKMndrARFTxpgdRBwthUWp81+OnYtrbXAcbdYGo shGlLXzASAJUEl7tAw5ADzpnIkeMTE0JjPjEeh8tCF7iUaiC+yfXt0itQyzxSdQRjN3g gpwSjKaIz07oYZN6m+59FdL7ikdlPqlAWQuBZbZu/z+mYrQvJKquSVSBVD7PxVhHVZAG 0nU15jf8sFtWTELD9qYNNBcn29Lk2QQgl50quKB5HtPhW3dx3DKF0f31UXDpVw/tUQeL AM6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gWnPikS/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si2795848eja.290.2019.10.10.01.44.19; Thu, 10 Oct 2019 01:44:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gWnPikS/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388625AbfJJImv (ORCPT + 99 others); Thu, 10 Oct 2019 04:42:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:47442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388614AbfJJImr (ORCPT ); Thu, 10 Oct 2019 04:42:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04D432190F; Thu, 10 Oct 2019 08:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696966; bh=1aRzyPI+xk3fHa5V0gSMAabkms8B0IJ+eUeGtqcGjLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gWnPikS/bLww19e4p4w+eQX7Hk8eDe11K8XOti7luWAnTxaJqlHIWToDhqPc5WC+0 MCytpgSrngoAl+qvSuZJlVpml3yewPN3FjT4m4iucPNzWH5XUG0C0vN2PISVtM6BVn Gv+zqoYXDS5HGhqfwqs4P3bCDb/xsVLjWPYn0r4w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vishal Verma , "Aneesh Kumar K.V" , Dan Williams , Sasha Levin Subject: [PATCH 5.3 117/148] =?UTF-8?q?libnvdimm:=20Fix=20endian=20conversion=20issues=C2=A0?= Date: Thu, 10 Oct 2019 10:36:18 +0200 Message-Id: <20191010083618.171367540@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aneesh Kumar K.V [ Upstream commit 86aa66687442ef45909ff9814b82b4d2bb892294 ] nd_label->dpa issue was observed when trying to enable the namespace created with little-endian kernel on a big-endian kernel. That made me run `sparse` on the rest of the code and other changes are the result of that. Fixes: d9b83c756953 ("libnvdimm, btt: rework error clearing") Fixes: 9dedc73a4658 ("libnvdimm/btt: Fix LBA masking during 'free list' population") Reviewed-by: Vishal Verma Signed-off-by: Aneesh Kumar K.V Link: https://lore.kernel.org/r/20190809074726.27815-1-aneesh.kumar@linux.ibm.com Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- drivers/nvdimm/btt.c | 8 ++++---- drivers/nvdimm/namespace_devs.c | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index a8d56887ec881..3e9f45aec8d18 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -392,9 +392,9 @@ static int btt_flog_write(struct arena_info *arena, u32 lane, u32 sub, arena->freelist[lane].sub = 1 - arena->freelist[lane].sub; if (++(arena->freelist[lane].seq) == 4) arena->freelist[lane].seq = 1; - if (ent_e_flag(ent->old_map)) + if (ent_e_flag(le32_to_cpu(ent->old_map))) arena->freelist[lane].has_err = 1; - arena->freelist[lane].block = le32_to_cpu(ent_lba(ent->old_map)); + arena->freelist[lane].block = ent_lba(le32_to_cpu(ent->old_map)); return ret; } @@ -560,8 +560,8 @@ static int btt_freelist_init(struct arena_info *arena) * FIXME: if error clearing fails during init, we want to make * the BTT read-only */ - if (ent_e_flag(log_new.old_map) && - !ent_normal(log_new.old_map)) { + if (ent_e_flag(le32_to_cpu(log_new.old_map)) && + !ent_normal(le32_to_cpu(log_new.old_map))) { arena->freelist[i].has_err = 1; ret = arena_clear_freelist_error(arena, i); if (ret) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index a16e52251a305..102c9d5141ee8 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -1987,7 +1987,7 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region, nd_mapping = &nd_region->mapping[i]; label_ent = list_first_entry_or_null(&nd_mapping->labels, typeof(*label_ent), list); - label0 = label_ent ? label_ent->label : 0; + label0 = label_ent ? label_ent->label : NULL; if (!label0) { WARN_ON(1); @@ -2322,8 +2322,9 @@ static struct device **scan_labels(struct nd_region *nd_region) continue; /* skip labels that describe extents outside of the region */ - if (nd_label->dpa < nd_mapping->start || nd_label->dpa > map_end) - continue; + if (__le64_to_cpu(nd_label->dpa) < nd_mapping->start || + __le64_to_cpu(nd_label->dpa) > map_end) + continue; i = add_namespace_resource(nd_region, nd_label, devs, count); if (i < 0) -- 2.20.1