[PATCH AUTOSEL 4.4 4/8] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap 

[ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ]

fs/dax.c uses copy_user_page() but ARC does not provide that interface,
resulting in a build error.

Provide copy_user_page() in .

../fs/dax.c: In function 'copy_cow_page_dax':
../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]

Reported-by: kernel test robot 
Signed-off-by: Randy Dunlap 
Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Cc: Dan Williams 
#Acked-by: Vineet Gupta  # v1
Cc: Andrew Morton 
Cc: Matthew Wilcox 
Cc: Jan Kara 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-nvdimm@lists.01.org
#Reviewed-by: Ira Weiny  # v2
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/include/asm/page.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 8f1145ed0046f..fd2c88ef2e2b8 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -17,6 +17,7 @@
 #define free_user_page(page, addr) free_page(addr)
 
 #define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_user_page(to, from, vaddr, pg)copy_page(to, from)
 #define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
 
 struct vm_area_struct;
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.9 4/8] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap 

[ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ]

fs/dax.c uses copy_user_page() but ARC does not provide that interface,
resulting in a build error.

Provide copy_user_page() in .

../fs/dax.c: In function 'copy_cow_page_dax':
../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]

Reported-by: kernel test robot 
Signed-off-by: Randy Dunlap 
Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Cc: Dan Williams 
#Acked-by: Vineet Gupta  # v1
Cc: Andrew Morton 
Cc: Matthew Wilcox 
Cc: Jan Kara 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-nvdimm@lists.01.org
#Reviewed-by: Ira Weiny  # v2
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/include/asm/page.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index ffb5f33475f19..f0f43eb709d2f 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -13,6 +13,7 @@
 #ifndef __ASSEMBLY__
 
 #define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_user_page(to, from, vaddr, pg)copy_page(to, from)
 #define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
 
 struct vm_area_struct;
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.14 09/13] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap 

[ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ]

fs/dax.c uses copy_user_page() but ARC does not provide that interface,
resulting in a build error.

Provide copy_user_page() in .

../fs/dax.c: In function 'copy_cow_page_dax':
../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]

Reported-by: kernel test robot 
Signed-off-by: Randy Dunlap 
Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Cc: Dan Williams 
#Acked-by: Vineet Gupta  # v1
Cc: Andrew Morton 
Cc: Matthew Wilcox 
Cc: Jan Kara 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-nvdimm@lists.01.org
#Reviewed-by: Ira Weiny  # v2
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/include/asm/page.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 09f71cc50..a70fef79c4055 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -13,6 +13,7 @@
 #ifndef __ASSEMBLY__
 
 #define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_user_page(to, from, vaddr, pg)copy_page(to, from)
 #define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
 
 struct vm_area_struct;
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 11/16] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap 

[ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ]

fs/dax.c uses copy_user_page() but ARC does not provide that interface,
resulting in a build error.

Provide copy_user_page() in .

../fs/dax.c: In function 'copy_cow_page_dax':
../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]

Reported-by: kernel test robot 
Signed-off-by: Randy Dunlap 
Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Cc: Dan Williams 
#Acked-by: Vineet Gupta  # v1
Cc: Andrew Morton 
Cc: Matthew Wilcox 
Cc: Jan Kara 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-nvdimm@lists.01.org
#Reviewed-by: Ira Weiny  # v2
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/include/asm/page.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 09f71cc50..a70fef79c4055 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -13,6 +13,7 @@
 #ifndef __ASSEMBLY__
 
 #define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_user_page(to, from, vaddr, pg)copy_page(to, from)
 #define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
 
 struct vm_area_struct;
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 18/28] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap 

[ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ]

fs/dax.c uses copy_user_page() but ARC does not provide that interface,
resulting in a build error.

Provide copy_user_page() in .

../fs/dax.c: In function 'copy_cow_page_dax':
../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]

Reported-by: kernel test robot 
Signed-off-by: Randy Dunlap 
Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Cc: Dan Williams 
#Acked-by: Vineet Gupta  # v1
Cc: Andrew Morton 
Cc: Matthew Wilcox 
Cc: Jan Kara 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-nvdimm@lists.01.org
#Reviewed-by: Ira Weiny  # v2
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/include/asm/page.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 0a32e8cfd074d..bcd1920ae75a3 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -10,6 +10,7 @@
 #ifndef __ASSEMBLY__
 
 #define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_user_page(to, from, vaddr, pg)copy_page(to, from)
 #define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
 
 struct vm_area_struct;
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.10 34/51] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap 

[ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ]

fs/dax.c uses copy_user_page() but ARC does not provide that interface,
resulting in a build error.

Provide copy_user_page() in .

../fs/dax.c: In function 'copy_cow_page_dax':
../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]

Reported-by: kernel test robot 
Signed-off-by: Randy Dunlap 
Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Cc: Dan Williams 
#Acked-by: Vineet Gupta  # v1
Cc: Andrew Morton 
Cc: Matthew Wilcox 
Cc: Jan Kara 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-nvdimm@lists.01.org
#Reviewed-by: Ira Weiny  # v2
Signed-off-by: Vineet Gupta 
Signed-off-by: Sasha Levin 
---
 arch/arc/include/asm/page.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index b0dfed0f12be0..d9c264dc25fcb 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -10,6 +10,7 @@
 #ifndef __ASSEMBLY__
 
 #define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_user_page(to, from, vaddr, pg)copy_page(to, from)
 #define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
 
 struct vm_area_struct;
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.10 31/31] device-dax: Fix range release

2020-12-30 Thread Sasha Levin
From: Dan Williams 

[ Upstream commit 6268d7da4d192af339f4d688942b9ccb45a65e04 ]

There are multiple locations that open-code the release of the last
range in a device-dax instance. Consolidate this into a new
dev_dax_trim_range() helper.

This also addresses a kmemleak report:

# cat /sys/kernel/debug/kmemleak
[..]
unreferenced object 0x976bd46f6240 (size 64):
   comm "ndctl", pid 23556, jiffies 4299514316 (age 5406.733s)
   hex dump (first 32 bytes):
 00 00 00 00 00 00 00 00 00 00 20 c3 37 00 00 00  .. .7...
 ff ff ff 7f 38 00 00 00 00 00 00 00 00 00 00 00  8...
   backtrace:
 [<064003cf>] __kmalloc_track_caller+0x136/0x379
 [<d85e3c52>] krealloc+0x67/0x92
 [<d7d3ba8a>] __alloc_dev_dax_range+0x73/0x25c
 [<27d58626>] devm_create_dev_dax+0x27d/0x416
 [<434abd43>] __dax_pmem_probe+0x1c9/0x1000 [dax_pmem_core]
 [<83726c1c>] dax_pmem_probe+0x10/0x1f [dax_pmem]
 [<b5f2319c>] nvdimm_bus_probe+0x9d/0x340 [libnvdimm]
 [<c055e544>] really_probe+0x230/0x48d
 [<6cabd38e>] driver_probe_device+0x122/0x13b
 [<29c7b95a>] device_driver_attach+0x5b/0x60
 [<53e5659b>] bind_store+0xb7/0xc3
 [<d3bdaadc>] drv_attr_store+0x27/0x31
 [<949069c5>] sysfs_kf_write+0x4a/0x57
 [<4a8b5adf>] kernfs_fop_write+0x150/0x1e5
 [<bded60f0>] __vfs_write+0x1b/0x34
 [<b92900f0>] vfs_write+0xd8/0x1d1

Reported-by: Jane Chu 
Cc: Zhen Lei 
Link: 
https://lore.kernel.org/r/160834570161.1791850.14911670304441510419.st...@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/dax/bus.c | 44 +---
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 27513d311242e..de7b74505e75e 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -367,19 +367,28 @@ void kill_dev_dax(struct dev_dax *dev_dax)
 }
 EXPORT_SYMBOL_GPL(kill_dev_dax);
 
-static void free_dev_dax_ranges(struct dev_dax *dev_dax)
+static void trim_dev_dax_range(struct dev_dax *dev_dax)
 {
+   int i = dev_dax->nr_range - 1;
+   struct range *range = &dev_dax->ranges[i].range;
struct dax_region *dax_region = dev_dax->region;
-   int i;
 
device_lock_assert(dax_region->dev);
-   for (i = 0; i < dev_dax->nr_range; i++) {
-   struct range *range = &dev_dax->ranges[i].range;
-
-   __release_region(&dax_region->res, range->start,
-   range_len(range));
+   dev_dbg(&dev_dax->dev, "delete range[%d]: %#llx:%#llx\n", i,
+   (unsigned long long)range->start,
+   (unsigned long long)range->end);
+
+   __release_region(&dax_region->res, range->start, range_len(range));
+   if (--dev_dax->nr_range == 0) {
+   kfree(dev_dax->ranges);
+   dev_dax->ranges = NULL;
}
-   dev_dax->nr_range = 0;
+}
+
+static void free_dev_dax_ranges(struct dev_dax *dev_dax)
+{
+   while (dev_dax->nr_range)
+   trim_dev_dax_range(dev_dax);
 }
 
 static void unregister_dev_dax(void *dev)
@@ -804,15 +813,10 @@ static int alloc_dev_dax_range(struct dev_dax *dev_dax, 
u64 start,
return 0;
 
rc = devm_register_dax_mapping(dev_dax, dev_dax->nr_range - 1);
-   if (rc) {
-   dev_dbg(dev, "delete range[%d]: %pa:%pa\n", dev_dax->nr_range - 
1,
-   &alloc->start, &alloc->end);
-   dev_dax->nr_range--;
-   __release_region(res, alloc->start, resource_size(alloc));
-   return rc;
-   }
+   if (rc)
+   trim_dev_dax_range(dev_dax);
 
-   return 0;
+   return rc;
 }
 
 static int adjust_dev_dax_range(struct dev_dax *dev_dax, struct resource *res, 
resource_size_t size)
@@ -885,12 +889,7 @@ static int dev_dax_shrink(struct dev_dax *dev_dax, 
resource_size_t size)
if (shrink >= range_len(range)) {
devm_release_action(dax_region->dev,
unregister_dax_mapping, &mapping->dev);
-   __release_region(&dax_region->res, range->start,
-   range_len(range));
-   dev_dax->nr_range--;
-   dev_dbg(dev, "delete range[%d]: %#llx:%#llx\n", i,
-   (unsigned long long) range->start,
-   (unsigned long long) range->end);
+   trim_dev_dax_range(dev_dax);

[PATCH AUTOSEL 4.9 7/7] ACPI: NFIT: Fix comparison to '-ENXIO'

2020-11-02 Thread Sasha Levin
From: Zhang Qilong 

[ Upstream commit 85f971b65a692b68181438e099b946cc06ed499b ]

Initial value of rc is '-ENXIO', and we should
use the initial value to check it.

Signed-off-by: Zhang Qilong 
Reviewed-by: Pankaj Gupta 
Reviewed-by: Vishal Verma 
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 31a07609f7a23..b7fd8e00b346b 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1219,7 +1219,7 @@ static ssize_t format1_show(struct device *dev,
le16_to_cpu(nfit_dcr->dcr->code));
break;
}
-   if (rc != ENXIO)
+   if (rc != -ENXIO)
break;
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 11/11] ACPI: NFIT: Fix comparison to '-ENXIO'

2020-11-02 Thread Sasha Levin
From: Zhang Qilong 

[ Upstream commit 85f971b65a692b68181438e099b946cc06ed499b ]

Initial value of rc is '-ENXIO', and we should
use the initial value to check it.

Signed-off-by: Zhang Qilong 
Reviewed-by: Pankaj Gupta 
Reviewed-by: Vishal Verma 
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index dd4c7289610ec..cb88f3b43a940 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1535,7 +1535,7 @@ static ssize_t format1_show(struct device *dev,
le16_to_cpu(nfit_dcr->dcr->code));
break;
}
-   if (rc != ENXIO)
+   if (rc != -ENXIO)
break;
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.14 10/10] ACPI: NFIT: Fix comparison to '-ENXIO'

2020-11-02 Thread Sasha Levin
From: Zhang Qilong 

[ Upstream commit 85f971b65a692b68181438e099b946cc06ed499b ]

Initial value of rc is '-ENXIO', and we should
use the initial value to check it.

Signed-off-by: Zhang Qilong 
Reviewed-by: Pankaj Gupta 
Reviewed-by: Vishal Verma 
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 68205002f561e..20fd197ef74cc 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1273,7 +1273,7 @@ static ssize_t format1_show(struct device *dev,
le16_to_cpu(nfit_dcr->dcr->code));
break;
}
-   if (rc != ENXIO)
+   if (rc != -ENXIO)
break;
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 20/24] ACPI: NFIT: Fix comparison to '-ENXIO'

2020-11-02 Thread Sasha Levin
From: Zhang Qilong 

[ Upstream commit 85f971b65a692b68181438e099b946cc06ed499b ]

Initial value of rc is '-ENXIO', and we should
use the initial value to check it.

Signed-off-by: Zhang Qilong 
Reviewed-by: Pankaj Gupta 
Reviewed-by: Vishal Verma 
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 12d980aafc5ff..9d78f29cf9967 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1553,7 +1553,7 @@ static ssize_t format1_show(struct device *dev,
le16_to_cpu(nfit_dcr->dcr->code));
break;
}
-   if (rc != ENXIO)
+   if (rc != -ENXIO)
break;
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.8 25/29] ACPI: NFIT: Fix comparison to '-ENXIO'

2020-11-02 Thread Sasha Levin
From: Zhang Qilong 

[ Upstream commit 85f971b65a692b68181438e099b946cc06ed499b ]

Initial value of rc is '-ENXIO', and we should
use the initial value to check it.

Signed-off-by: Zhang Qilong 
Reviewed-by: Pankaj Gupta 
Reviewed-by: Vishal Verma 
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 1f72ce1a782b5..a296e6d8aeed4 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1552,7 +1552,7 @@ static ssize_t format1_show(struct device *dev,
le16_to_cpu(nfit_dcr->dcr->code));
break;
}
-   if (rc != ENXIO)
+   if (rc != -ENXIO)
break;
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.9 31/35] ACPI: NFIT: Fix comparison to '-ENXIO'

2020-11-02 Thread Sasha Levin
From: Zhang Qilong 

[ Upstream commit 85f971b65a692b68181438e099b946cc06ed499b ]

Initial value of rc is '-ENXIO', and we should
use the initial value to check it.

Signed-off-by: Zhang Qilong 
Reviewed-by: Pankaj Gupta 
Reviewed-by: Vishal Verma 
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 26dd208a0d636..103ae7401f957 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1564,7 +1564,7 @@ static ssize_t format1_show(struct device *dev,
le16_to_cpu(nfit_dcr->dcr->code));
break;
}
-   if (rc != ENXIO)
+   if (rc != -ENXIO)
break;
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.27.0
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH v3 01/11] libnvdimm: Validate command family indices

2020-07-22 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism").

The bot has tested the following trees: v5.7.9, v5.4.52, v4.19.133, v4.14.188, 
v4.9.230.

v5.7.9: Failed to apply! Possible dependencies:
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v5.4.52: Failed to apply! Possible dependencies:
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.19.133: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0ead11181fe0c ("acpi, nfit: Collect shutdown status")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
b3ed2ce024c36 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b5beae5e224f1 ("powerpc/pseries: Add driver for PAPR SCM regions")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.14.188: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0e7f0741450b1 ("acpi, nfit: validate commands against the device type")
1194c4133195d ("nfit: Add Hyper-V NVDIMM DSM command set to white list")
11e1427016095 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
466d1493ea830 ("acpi, nfit: rework NVDIMM leaf method detection")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
b37b3fd33d034 ("acpi nfit: Enable to show what feature is supported via 
ND_CMD_CALL for nfit_test")
b9b1504d3c6d6 ("acpi, nfit: hide unknown commands from nmemX/commands")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")

v4.9.230: Failed to apply! Possible dependencies:
095ab4b39f91b ("acpi, nfit: allow override of built-in bitmasks for nvdimm 
DSMs")
0f817ae696b04 ("usb: dwc3: pci: add a private driver structure")
36daf3aa399c0 ("usb: dwc3: pci: avoid build warning")
3f23df72dc351 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10c ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64d ("libnvdimm: allow a platform to force enable label support")
42b06496407c0 ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
8f078b38dd382 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de9 ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0d ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed9651182 ("libnvdimm: handle locked label storage areas")
b7fe92999a98a ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c107 ("net: hns: Add ACPI support to check SFP present")
ba650cfcf9409 ("acpi, nfit: allow specifying a default DSM family")
c959a6b00ff58 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some 
Intel devices")
d2061f9cc32db ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
fab9288428ec0 ("usb: USB Type-C connector class")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH v2 01/12] libnvdimm: Validate command family indices

2020-07-10 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism").

The bot has tested the following trees: v5.7.7, v5.4.50, v4.19.131, v4.14.187, 
v4.9.229.

v5.7.7: Failed to apply! Possible dependencies:
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v5.4.50: Failed to apply! Possible dependencies:
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.19.131: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0ead11181fe0c ("acpi, nfit: Collect shutdown status")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
b3ed2ce024c36 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b5beae5e224f1 ("powerpc/pseries: Add driver for PAPR SCM regions")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.14.187: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0e7f0741450b1 ("acpi, nfit: validate commands against the device type")
1194c4133195d ("nfit: Add Hyper-V NVDIMM DSM command set to white list")
11e1427016095 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
466d1493ea830 ("acpi, nfit: rework NVDIMM leaf method detection")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
b37b3fd33d034 ("acpi nfit: Enable to show what feature is supported via 
ND_CMD_CALL for nfit_test")
b9b1504d3c6d6 ("acpi, nfit: hide unknown commands from nmemX/commands")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")

v4.9.229: Failed to apply! Possible dependencies:
095ab4b39f91b ("acpi, nfit: allow override of built-in bitmasks for nvdimm 
DSMs")
0f817ae696b04 ("usb: dwc3: pci: add a private driver structure")
36daf3aa399c0 ("usb: dwc3: pci: avoid build warning")
3f23df72dc351 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10c ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64d ("libnvdimm: allow a platform to force enable label support")
42b06496407c0 ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
8f078b38dd382 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de9 ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0d ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed9651182 ("libnvdimm: handle locked label storage areas")
b7fe92999a98a ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c107 ("net: hns: Add ACPI support to check SFP present")
ba650cfcf9409 ("acpi, nfit: allow specifying a default DSM family")
c959a6b00ff58 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some 
Intel devices")
d2061f9cc32db ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
fab9288428ec0 ("usb: USB Type-C connector class")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 01/12] libnvdimm: Validate command family indices

2020-07-10 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism").

The bot has tested the following trees: v5.7.6, v5.4.49, v4.19.130, v4.14.186, 
v4.9.228.

v5.7.6: Failed to apply! Possible dependencies:
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v5.4.49: Failed to apply! Possible dependencies:
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.19.130: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0ead11181fe0c ("acpi, nfit: Collect shutdown status")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
b3ed2ce024c36 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b5beae5e224f1 ("powerpc/pseries: Add driver for PAPR SCM regions")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.14.186: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0e7f0741450b1 ("acpi, nfit: validate commands against the device type")
1194c4133195d ("nfit: Add Hyper-V NVDIMM DSM command set to white list")
11e1427016095 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
466d1493ea830 ("acpi, nfit: rework NVDIMM leaf method detection")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
b37b3fd33d034 ("acpi nfit: Enable to show what feature is supported via 
ND_CMD_CALL for nfit_test")
b9b1504d3c6d6 ("acpi, nfit: hide unknown commands from nmemX/commands")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")

v4.9.228: Failed to apply! Possible dependencies:
095ab4b39f91b ("acpi, nfit: allow override of built-in bitmasks for nvdimm 
DSMs")
0f817ae696b04 ("usb: dwc3: pci: add a private driver structure")
36daf3aa399c0 ("usb: dwc3: pci: avoid build warning")
3f23df72dc351 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10c ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64d ("libnvdimm: allow a platform to force enable label support")
42b06496407c0 ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
8f078b38dd382 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de9 ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0d ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed9651182 ("libnvdimm: handle locked label storage areas")
b7fe92999a98a ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c107 ("net: hns: Add ACPI support to check SFP present")
ba650cfcf9409 ("acpi, nfit: allow specifying a default DSM family")
c959a6b00ff58 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some 
Intel devices")
d2061f9cc32db ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
fab9288428ec0 ("usb: USB Type-C connector class")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 01/12] libnvdimm: Validate command family indices

2020-07-01 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism").

The bot has tested the following trees: v5.7.6, v5.4.49, v4.19.130, v4.14.186, 
v4.9.228.

v5.7.6: Failed to apply! Possible dependencies:
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v5.4.49: Failed to apply! Possible dependencies:
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.19.130: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0ead11181fe0c ("acpi, nfit: Collect shutdown status")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
72c4ebbac476b ("powerpc/papr_scm: Mark papr_scm_ndctl() as static")
b3ed2ce024c36 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b5beae5e224f1 ("powerpc/pseries: Add driver for PAPR SCM regions")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
f517f7925b7b4 ("ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific 
methods")

v4.14.186: Failed to apply! Possible dependencies:
01091c496f920 ("acpi/nfit: improve bounds checking for 'func'")
0e7f0741450b1 ("acpi, nfit: validate commands against the device type")
1194c4133195d ("nfit: Add Hyper-V NVDIMM DSM command set to white list")
11e1427016095 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
466d1493ea830 ("acpi, nfit: rework NVDIMM leaf method detection")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
b37b3fd33d034 ("acpi nfit: Enable to show what feature is supported via 
ND_CMD_CALL for nfit_test")
b9b1504d3c6d6 ("acpi, nfit: hide unknown commands from nmemX/commands")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")

v4.9.228: Failed to apply! Possible dependencies:
095ab4b39f91b ("acpi, nfit: allow override of built-in bitmasks for nvdimm 
DSMs")
0f817ae696b04 ("usb: dwc3: pci: add a private driver structure")
36daf3aa399c0 ("usb: dwc3: pci: avoid build warning")
3f23df72dc351 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10c ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64d ("libnvdimm: allow a platform to force enable label support")
42b06496407c0 ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cdb ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
6f07f86c49407 ("acpi, nfit: Introduce nfit_mem flags")
8f078b38dd382 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de9 ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0d ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed9651182 ("libnvdimm: handle locked label storage areas")
b7fe92999a98a ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c107 ("net: hns: Add ACPI support to check SFP present")
ba650cfcf9409 ("acpi, nfit: allow specifying a default DSM family")
c959a6b00ff58 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some 
Intel devices")
d2061f9cc32db ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
d6548ae4d16dc ("acpi/nfit, libnvdimm: Store dimm id as a member to struct 
nvdimm")
fab9288428ec0 ("usb: USB Type-C connector class")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.7 26/28] nvdimm/region: always show the 'align' attribute

2020-06-23 Thread Sasha Levin
From: Vishal Verma 

[ Upstream commit 543094e19c82b5d171e139d09a1a3ea0a7361117 ]

It is possible that a platform that is capable of 'namespace labels'
comes up without the labels properly initialized. In this case, the
region's 'align' attribute is hidden. Howerver, once the user does
initialize he labels, the 'align' attribute still stays hidden, which is
unexpected.

The sysfs_update_group() API is meant to address this, and could be
called during region probe, but it has entanglements with the device
'lockdep_mutex'. Therefore, simply make the 'align' attribute always
visible. It doesn't matter what it says for label-less namespaces, since
it is not possible to change their allocation anyway.

Suggested-by: Dan Williams 
Signed-off-by: Vishal Verma 
Cc: Dan Williams 
Link: https://lore.kernel.org/r/20200520225026.29426-1-vishal.l.ve...@intel.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/region_devs.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index ccbb5b43b8b2c..4502f9c4708d0 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -679,18 +679,8 @@ static umode_t region_visible(struct kobject *kobj, struct 
attribute *a, int n)
return a->mode;
}
 
-   if (a == &dev_attr_align.attr) {
-   int i;
-
-   for (i = 0; i < nd_region->ndr_mappings; i++) {
-   struct nd_mapping *nd_mapping = &nd_region->mapping[i];
-   struct nvdimm *nvdimm = nd_mapping->nvdimm;
-
-   if (test_bit(NDD_LABELING, &nvdimm->flags))
-   return a->mode;
-   }
-   return 0;
-   }
+   if (a == &dev_attr_align.attr)
+   return a->mode;
 
if (a != &dev_attr_set_cookie.attr
&& a != &dev_attr_available_size.attr)
-- 
2.25.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 186/606] device-dax: don't leak kernel memory to user space after unloading kmem

2020-06-08 Thread Sasha Levin
From: David Hildenbrand 

commit 60858c00e5f018eda711a3aa84cf62214ef62d61 upstream.

Assume we have kmem configured and loaded:

  [root@localhost ~]# cat /proc/iomem
  ...
  14000-33fff : Persistent Memory$
14000-1481f : namespace0.0
15000-33fff : dax0.0
  15000-33fff : System RAM

Assume we try to unload kmem. This force-unloading will work, even if
memory cannot get removed from the system.

  [root@localhost ~]# rmmod kmem
  [   86.380228] removing memory fails, because memory 
[0x00015000-0x000157ff] is onlined
  ...
  [   86.431225] kmem dax0.0: DAX region [mem 0x15000-0x33fff] cannot 
be hotremoved until the next reboot

Now, we can reconfigure the namespace:

  [root@localhost ~]# ndctl create-namespace --force --reconfig=namespace0.0 
--mode=devdax
  [  131.409351] nd_pmem namespace0.0: could not reserve region [mem 
0x14000-0x33fff]dax
  [  131.410147] nd_pmem: probe of namespace0.0 failed with error 
-16namespace0.0 --mode=devdax
  ...

This fails as expected due to the busy memory resource, and the memory
cannot be used.  However, the dax0.0 device is removed, and along its
name.

The name of the memory resource now points at freed memory (name of the
device):

  [root@localhost ~]# cat /proc/iomem
  ...
  14000-33fff : Persistent Memory
14000-1481f : namespace0.0
15000-33fff : �_�^7_��/_��wR��WQ���^��� ...
15000-33fff : System RAM

We have to make sure to duplicate the string.  While at it, remove the
superfluous setting of the name and fixup a stale comment.

Fixes: 9f960da72b25 ("device-dax: "Hotremove" persistent memory that is used 
like normal RAM")
Signed-off-by: David Hildenbrand 
Signed-off-by: Andrew Morton 
Cc: Dan Williams 
Cc: Vishal Verma 
Cc: Dave Jiang 
Cc: Pavel Tatashin 
Cc: Andrew Morton 
Cc: [5.3]
Link: http://lkml.kernel.org/r/20200508084217.9160-2-da...@redhat.com
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/dax/kmem.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index 3d0a7e702c94..1e678bdf5aed 100644
--- a/drivers/dax/kmem.c
+++ b/drivers/dax/kmem.c
@@ -22,6 +22,7 @@ int dev_dax_kmem_probe(struct device *dev)
resource_size_t kmem_size;
resource_size_t kmem_end;
struct resource *new_res;
+   const char *new_res_name;
int numa_node;
int rc;
 
@@ -48,11 +49,16 @@ int dev_dax_kmem_probe(struct device *dev)
kmem_size &= ~(memory_block_size_bytes() - 1);
kmem_end = kmem_start + kmem_size;
 
-   /* Region is permanently reserved.  Hot-remove not yet implemented. */
-   new_res = request_mem_region(kmem_start, kmem_size, dev_name(dev));
+   new_res_name = kstrdup(dev_name(dev), GFP_KERNEL);
+   if (!new_res_name)
+   return -ENOMEM;
+
+   /* Region is permanently reserved if hotremove fails. */
+   new_res = request_mem_region(kmem_start, kmem_size, new_res_name);
if (!new_res) {
dev_warn(dev, "could not reserve region [%pa-%pa]\n",
 &kmem_start, &kmem_end);
+   kfree(new_res_name);
return -EBUSY;
}
 
@@ -63,12 +69,12 @@ int dev_dax_kmem_probe(struct device *dev)
 * unknown to us that will break add_memory() below.
 */
new_res->flags = IORESOURCE_SYSTEM_RAM;
-   new_res->name = dev_name(dev);
 
rc = add_memory(numa_node, new_res->start, resource_size(new_res));
if (rc) {
release_resource(new_res);
kfree(new_res);
+   kfree(new_res_name);
return rc;
}
dev_dax->dax_kmem_res = new_res;
@@ -83,6 +89,7 @@ static int dev_dax_kmem_remove(struct device *dev)
struct resource *res = dev_dax->dax_kmem_res;
resource_size_t kmem_start = res->start;
resource_size_t kmem_size = resource_size(res);
+   const char *res_name = res->name;
int rc;
 
/*
@@ -102,6 +109,7 @@ static int dev_dax_kmem_remove(struct device *dev)
/* Release and free dax resources */
release_resource(res);
kfree(res);
+   kfree(res_name);
dev_dax->dax_kmem_res = NULL;
 
return 0;
-- 
2.25.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.9 17/23] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 5768a4749564a..65ac1d3870f93 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -851,8 +851,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.14 20/28] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 2f1b54fab399f..83e18b367944c 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -951,8 +951,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 27/47] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 54a633e8cb5d2..48a070a37ea9b 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -984,8 +984,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 45/78] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index d47412dcdf38d..5e5c6aafc070b 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1010,8 +1010,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 06/78] acpi/nfit: improve bounds checking for 'func'

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 01091c496f920e634ea84b689f480c39016752a8 ]

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter 
Reviewed-by: Dan Williams 
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 10 ++
 drivers/acpi/nfit/nfit.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 14e68f202f810..12d980aafc5ff 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle 
handle)
 
 static u8 nfit_dsm_revid(unsigned family, unsigned func)
 {
-   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
 
if (family > NVDIMM_FAMILY_MAX)
return 0;
-   if (func > 31)
+   if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
 * Check for a valid command.  For ND_CMD_CALL, we also have to
 * make sure that the DSM function is supported.
 */
-   if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+   if (cmd == ND_CMD_CALL &&
+   (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3499,7 +3500,8 @@ static int acpi_nfit_clear_to_send(struct 
nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
-   if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+   if (func > NVDIMM_CMD_MAX ||
+   (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
 
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181ce..b317f4043705f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
 #define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 18/78] tools/test/nvdimm: Fix out of tree build

2020-04-18 Thread Sasha Levin
From: Santosh Sivaraj 

[ Upstream commit 1f776799628139d0da47e710ad86eb58d987ff66 ]

Out of tree build using

   make M=tools/test/nvdimm O=/tmp/build -C /tmp/build

fails with the following error

make: Entering directory '/tmp/build'
  CC [M]  tools/testing/nvdimm/test/nfit.o
linux/tools/testing/nvdimm/test/nfit.c:19:10: fatal error: nd-core.h: No such 
file or directory
   19 | #include 
  |  ^~~
compilation terminated.

That is because the kbuild file uses $(src) which points to
tools/testing/nvdimm, $(srctree) correctly points to root of the linux
source tree.

Reported-by: Aneesh Kumar K.V 
Signed-off-by: Santosh Sivaraj 
Link: https://lore.kernel.org/r/20200114054051.4115790-1-sant...@fossix.org
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 tools/testing/nvdimm/Kbuild  | 4 ++--
 tools/testing/nvdimm/test/Kbuild | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index c4a9196d794c9..cb80d3b811792 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -21,8 +21,8 @@ DRIVERS := ../../../drivers
 NVDIMM_SRC := $(DRIVERS)/nvdimm
 ACPI_SRC := $(DRIVERS)/acpi/nfit
 DAX_SRC := $(DRIVERS)/dax
-ccflags-y := -I$(src)/$(NVDIMM_SRC)/
-ccflags-y += -I$(src)/$(ACPI_SRC)/
+ccflags-y := -I$(srctree)/drivers/nvdimm/
+ccflags-y += -I$(srctree)/drivers/acpi/nfit/
 
 obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
 obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
diff --git a/tools/testing/nvdimm/test/Kbuild b/tools/testing/nvdimm/test/Kbuild
index fb3c3d7cdb9bd..75baebf8f4ba1 100644
--- a/tools/testing/nvdimm/test/Kbuild
+++ b/tools/testing/nvdimm/test/Kbuild
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-ccflags-y := -I$(src)/../../../../drivers/nvdimm/
-ccflags-y += -I$(src)/../../../../drivers/acpi/nfit/
+ccflags-y := -I$(srctree)/drivers/nvdimm/
+ccflags-y += -I$(srctree)/drivers/acpi/nfit/
 
 obj-m += nfit_test.o
 obj-m += nfit_test_iomap.o
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 02/78] tools/testing/nvdimm: Fix compilation failure without CONFIG_DEV_DAX_PMEM_COMPAT

2020-04-18 Thread Sasha Levin
From: Jan Kara 

[ Upstream commit c0e71d602053e4e7637e4bc7d0bc9603ea77a33f ]

When a kernel is configured without CONFIG_DEV_DAX_PMEM_COMPAT, the
compilation of tools/testing/nvdimm fails with:

  Building modules, stage 2.
  MODPOST 11 modules
ERROR: "dax_pmem_compat_test" [tools/testing/nvdimm/test/nfit_test.ko] 
undefined!

Fix the problem by calling dax_pmem_compat_test() only if the kernel has
the required functionality.

Signed-off-by: Jan Kara 
Link: https://lore.kernel.org/r/20200123154720.12097-1-j...@suse.cz
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 tools/testing/nvdimm/test/nfit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index bf6422a6af7ff..a8ee5c4d41ebb 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -3164,7 +3164,9 @@ static __init int nfit_test_init(void)
mcsafe_test();
dax_pmem_test();
dax_pmem_core_test();
+#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
dax_pmem_compat_test();
+#endif
 
nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
 
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 49/75] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b5159685699..09087c38fabdc 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1042,8 +1042,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 19/75] tools/test/nvdimm: Fix out of tree build

2020-04-18 Thread Sasha Levin
From: Santosh Sivaraj 

[ Upstream commit 1f776799628139d0da47e710ad86eb58d987ff66 ]

Out of tree build using

   make M=tools/test/nvdimm O=/tmp/build -C /tmp/build

fails with the following error

make: Entering directory '/tmp/build'
  CC [M]  tools/testing/nvdimm/test/nfit.o
linux/tools/testing/nvdimm/test/nfit.c:19:10: fatal error: nd-core.h: No such 
file or directory
   19 | #include 
  |  ^~~
compilation terminated.

That is because the kbuild file uses $(src) which points to
tools/testing/nvdimm, $(srctree) correctly points to root of the linux
source tree.

Reported-by: Aneesh Kumar K.V 
Signed-off-by: Santosh Sivaraj 
Link: https://lore.kernel.org/r/20200114054051.4115790-1-sant...@fossix.org
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 tools/testing/nvdimm/Kbuild  | 4 ++--
 tools/testing/nvdimm/test/Kbuild | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index 6aca8d5be1593..0615fa3d9f7e9 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -22,8 +22,8 @@ DRIVERS := ../../../drivers
 NVDIMM_SRC := $(DRIVERS)/nvdimm
 ACPI_SRC := $(DRIVERS)/acpi/nfit
 DAX_SRC := $(DRIVERS)/dax
-ccflags-y := -I$(src)/$(NVDIMM_SRC)/
-ccflags-y += -I$(src)/$(ACPI_SRC)/
+ccflags-y := -I$(srctree)/drivers/nvdimm/
+ccflags-y += -I$(srctree)/drivers/acpi/nfit/
 
 obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
 obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
diff --git a/tools/testing/nvdimm/test/Kbuild b/tools/testing/nvdimm/test/Kbuild
index fb3c3d7cdb9bd..75baebf8f4ba1 100644
--- a/tools/testing/nvdimm/test/Kbuild
+++ b/tools/testing/nvdimm/test/Kbuild
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-ccflags-y := -I$(src)/../../../../drivers/nvdimm/
-ccflags-y += -I$(src)/../../../../drivers/acpi/nfit/
+ccflags-y := -I$(srctree)/drivers/nvdimm/
+ccflags-y += -I$(srctree)/drivers/acpi/nfit/
 
 obj-m += nfit_test.o
 obj-m += nfit_test_iomap.o
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 02/75] tools/testing/nvdimm: Fix compilation failure without CONFIG_DEV_DAX_PMEM_COMPAT

2020-04-18 Thread Sasha Levin
From: Jan Kara 

[ Upstream commit c0e71d602053e4e7637e4bc7d0bc9603ea77a33f ]

When a kernel is configured without CONFIG_DEV_DAX_PMEM_COMPAT, the
compilation of tools/testing/nvdimm fails with:

  Building modules, stage 2.
  MODPOST 11 modules
ERROR: "dax_pmem_compat_test" [tools/testing/nvdimm/test/nfit_test.ko] 
undefined!

Fix the problem by calling dax_pmem_compat_test() only if the kernel has
the required functionality.

Signed-off-by: Jan Kara 
Link: https://lore.kernel.org/r/20200123154720.12097-1-j...@suse.cz
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 tools/testing/nvdimm/test/nfit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index bf6422a6af7ff..a8ee5c4d41ebb 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -3164,7 +3164,9 @@ static __init int nfit_test_init(void)
mcsafe_test();
dax_pmem_test();
dax_pmem_core_test();
+#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
dax_pmem_compat_test();
+#endif
 
nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
 
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 06/75] acpi/nfit: improve bounds checking for 'func'

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 01091c496f920e634ea84b689f480c39016752a8 ]

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter 
Reviewed-by: Dan Williams 
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 10 ++
 drivers/acpi/nfit/nfit.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index a3320f93616de..d0090f71585c4 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle 
handle)
 
 static u8 nfit_dsm_revid(unsigned family, unsigned func)
 {
-   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
 
if (family > NVDIMM_FAMILY_MAX)
return 0;
-   if (func > 31)
+   if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
 * Check for a valid command.  For ND_CMD_CALL, we also have to
 * make sure that the DSM function is supported.
 */
-   if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+   if (cmd == ND_CMD_CALL &&
+   (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3492,7 +3493,8 @@ static int acpi_nfit_clear_to_send(struct 
nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
-   if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+   if (func > NVDIMM_CMD_MAX ||
+   (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
 
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181ce..b317f4043705f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
 #define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 53/73] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b5159685699..09087c38fabdc 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1042,8 +1042,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 06/73] acpi/nfit: improve bounds checking for 'func'

2020-04-18 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 01091c496f920e634ea84b689f480c39016752a8 ]

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter 
Reviewed-by: Dan Williams 
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 10 ++
 drivers/acpi/nfit/nfit.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index a3320f93616de..d0090f71585c4 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle 
handle)
 
 static u8 nfit_dsm_revid(unsigned family, unsigned func)
 {
-   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
 
if (family > NVDIMM_FAMILY_MAX)
return 0;
-   if (func > 31)
+   if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
 * Check for a valid command.  For ND_CMD_CALL, we also have to
 * make sure that the DSM function is supported.
 */
-   if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+   if (cmd == ND_CMD_CALL &&
+   (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3492,7 +3493,8 @@ static int acpi_nfit_clear_to_send(struct 
nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
-   if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+   if (func > NVDIMM_CMD_MAX ||
+   (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
 
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181ce..b317f4043705f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
 #define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 02/73] tools/testing/nvdimm: Fix compilation failure without CONFIG_DEV_DAX_PMEM_COMPAT

2020-04-18 Thread Sasha Levin
From: Jan Kara 

[ Upstream commit c0e71d602053e4e7637e4bc7d0bc9603ea77a33f ]

When a kernel is configured without CONFIG_DEV_DAX_PMEM_COMPAT, the
compilation of tools/testing/nvdimm fails with:

  Building modules, stage 2.
  MODPOST 11 modules
ERROR: "dax_pmem_compat_test" [tools/testing/nvdimm/test/nfit_test.ko] 
undefined!

Fix the problem by calling dax_pmem_compat_test() only if the kernel has
the required functionality.

Signed-off-by: Jan Kara 
Link: https://lore.kernel.org/r/20200123154720.12097-1-j...@suse.cz
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 tools/testing/nvdimm/test/nfit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index bf6422a6af7ff..a8ee5c4d41ebb 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -3164,7 +3164,9 @@ static __init int nfit_test_init(void)
mcsafe_test();
dax_pmem_test();
dax_pmem_core_test();
+#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
dax_pmem_compat_test();
+#endif
 
nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
 
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 21/73] tools/test/nvdimm: Fix out of tree build

2020-04-18 Thread Sasha Levin
From: Santosh Sivaraj 

[ Upstream commit 1f776799628139d0da47e710ad86eb58d987ff66 ]

Out of tree build using

   make M=tools/test/nvdimm O=/tmp/build -C /tmp/build

fails with the following error

make: Entering directory '/tmp/build'
  CC [M]  tools/testing/nvdimm/test/nfit.o
linux/tools/testing/nvdimm/test/nfit.c:19:10: fatal error: nd-core.h: No such 
file or directory
   19 | #include 
  |  ^~~
compilation terminated.

That is because the kbuild file uses $(src) which points to
tools/testing/nvdimm, $(srctree) correctly points to root of the linux
source tree.

Reported-by: Aneesh Kumar K.V 
Signed-off-by: Santosh Sivaraj 
Link: https://lore.kernel.org/r/20200114054051.4115790-1-sant...@fossix.org
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 tools/testing/nvdimm/Kbuild  | 4 ++--
 tools/testing/nvdimm/test/Kbuild | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index dbebf05f59313..47f9cc9dcd94b 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -21,8 +21,8 @@ DRIVERS := ../../../drivers
 NVDIMM_SRC := $(DRIVERS)/nvdimm
 ACPI_SRC := $(DRIVERS)/acpi/nfit
 DAX_SRC := $(DRIVERS)/dax
-ccflags-y := -I$(src)/$(NVDIMM_SRC)/
-ccflags-y += -I$(src)/$(ACPI_SRC)/
+ccflags-y := -I$(srctree)/drivers/nvdimm/
+ccflags-y += -I$(srctree)/drivers/acpi/nfit/
 
 obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
 obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
diff --git a/tools/testing/nvdimm/test/Kbuild b/tools/testing/nvdimm/test/Kbuild
index fb3c3d7cdb9bd..75baebf8f4ba1 100644
--- a/tools/testing/nvdimm/test/Kbuild
+++ b/tools/testing/nvdimm/test/Kbuild
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-ccflags-y := -I$(src)/../../../../drivers/nvdimm/
-ccflags-y += -I$(src)/../../../../drivers/acpi/nfit/
+ccflags-y := -I$(srctree)/drivers/nvdimm/
+ccflags-y += -I$(srctree)/drivers/acpi/nfit/
 
 obj-m += nfit_test.o
 obj-m += nfit_test_iomap.o
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.9 20/21] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 5768a4749564a..65ac1d3870f93 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -851,8 +851,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.14 29/30] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 2f1b54fab399f..83e18b367944c 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -951,8 +951,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 38/40] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 54a633e8cb5d2..48a070a37ea9b 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -984,8 +984,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 81/84] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index d47412dcdf38d..5e5c6aafc070b 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1010,8 +1010,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 82/84] acpi/nfit: improve bounds checking for 'func'

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 01091c496f920e634ea84b689f480c39016752a8 ]

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter 
Reviewed-by: Dan Williams 
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 10 ++
 drivers/acpi/nfit/nfit.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 14e68f202f810..12d980aafc5ff 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle 
handle)
 
 static u8 nfit_dsm_revid(unsigned family, unsigned func)
 {
-   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
 
if (family > NVDIMM_FAMILY_MAX)
return 0;
-   if (func > 31)
+   if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
 * Check for a valid command.  For ND_CMD_CALL, we also have to
 * make sure that the DSM function is supported.
 */
-   if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+   if (cmd == ND_CMD_CALL &&
+   (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3499,7 +3500,8 @@ static int acpi_nfit_clear_to_send(struct 
nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
-   if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+   if (func > NVDIMM_CMD_MAX ||
+   (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
 
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181ce..b317f4043705f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
 #define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 103/106] acpi/nfit: improve bounds checking for 'func'

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 01091c496f920e634ea84b689f480c39016752a8 ]

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter 
Reviewed-by: Dan Williams 
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 10 ++
 drivers/acpi/nfit/nfit.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index a3320f93616de..d0090f71585c4 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle 
handle)
 
 static u8 nfit_dsm_revid(unsigned family, unsigned func)
 {
-   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
 
if (family > NVDIMM_FAMILY_MAX)
return 0;
-   if (func > 31)
+   if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
 * Check for a valid command.  For ND_CMD_CALL, we also have to
 * make sure that the DSM function is supported.
 */
-   if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+   if (cmd == ND_CMD_CALL &&
+   (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3492,7 +3493,8 @@ static int acpi_nfit_clear_to_send(struct 
nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
-   if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+   if (func > NVDIMM_CMD_MAX ||
+   (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
 
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181ce..b317f4043705f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
 #define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 102/106] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b5159685699..09087c38fabdc 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1042,8 +1042,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 124/129] libnvdimm: Out of bounds read in __nd_ioctl()

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
Signed-off-by: Dan Carpenter 
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b5159685699..09087c38fabdc 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1042,8 +1042,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, 
struct nvdimm *nvdimm,
return -EFAULT;
}
 
-   if (!desc || (desc->out_num + desc->in_num == 0) ||
-   !test_bit(cmd, &cmd_mask))
+   if (!desc ||
+   (desc->out_num + desc->in_num == 0) ||
+   cmd > ND_CMD_CALL ||
+   !test_bit(cmd, &cmd_mask))
return -ENOTTY;
 
/* fail write commands (when read-only) */
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.6 125/129] acpi/nfit: improve bounds checking for 'func'

2020-04-15 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 01091c496f920e634ea84b689f480c39016752a8 ]

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter 
Reviewed-by: Dan Williams 
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 10 ++
 drivers/acpi/nfit/nfit.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index a3320f93616de..d0090f71585c4 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle 
handle)
 
 static u8 nfit_dsm_revid(unsigned family, unsigned func)
 {
-   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+   static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
 
if (family > NVDIMM_FAMILY_MAX)
return 0;
-   if (func > 31)
+   if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
 * Check for a valid command.  For ND_CMD_CALL, we also have to
 * make sure that the DSM function is supported.
 */
-   if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+   if (cmd == ND_CMD_CALL &&
+   (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3492,7 +3493,8 @@ static int acpi_nfit_clear_to_send(struct 
nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
-   if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+   if (func > NVDIMM_CMD_MAX ||
+   (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
 
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181ce..b317f4043705f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
 #define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.14 03/21] dax: pass NOWAIT flag to iomap_apply

2020-02-22 Thread Sasha Levin
From: Jeff Moyer 

[ Upstream commit 96222d53842dfe54869ec4e1b9d4856daf9105a2 ]

fstests generic/471 reports a failure when run with MOUNT_OPTIONS="-o
dax".  The reason is that the initial pwrite to an empty file with the
RWF_NOWAIT flag set does not return -EAGAIN.  It turns out that
dax_iomap_rw doesn't pass that flag through to iomap_apply.

With this patch applied, generic/471 passes for me.

Signed-off-by: Jeff Moyer 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/x49r1z86e1d@segfault.boston.devel.redhat.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 fs/dax.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/dax.c b/fs/dax.c
index ddb4981ae32eb..34a55754164f4 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1057,6 +1057,9 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
lockdep_assert_held(&inode->i_rwsem);
}
 
+   if (iocb->ki_flags & IOCB_NOWAIT)
+   flags |= IOMAP_NOWAIT;
+
while (iov_iter_count(iter)) {
ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
iter, dax_iomap_actor);
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 04/25] dax: pass NOWAIT flag to iomap_apply

2020-02-22 Thread Sasha Levin
From: Jeff Moyer 

[ Upstream commit 96222d53842dfe54869ec4e1b9d4856daf9105a2 ]

fstests generic/471 reports a failure when run with MOUNT_OPTIONS="-o
dax".  The reason is that the initial pwrite to an empty file with the
RWF_NOWAIT flag set does not return -EAGAIN.  It turns out that
dax_iomap_rw doesn't pass that flag through to iomap_apply.

With this patch applied, generic/471 passes for me.

Signed-off-by: Jeff Moyer 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/x49r1z86e1d@segfault.boston.devel.redhat.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 fs/dax.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/dax.c b/fs/dax.c
index f0d932fa39c20..d09701aa6f2f4 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1301,6 +1301,9 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
lockdep_assert_held(&inode->i_rwsem);
}
 
+   if (iocb->ki_flags & IOCB_NOWAIT)
+   flags |= IOMAP_NOWAIT;
+
while (iov_iter_count(iter)) {
ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
iter, dax_iomap_actor);
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 06/50] dax: pass NOWAIT flag to iomap_apply

2020-02-22 Thread Sasha Levin
From: Jeff Moyer 

[ Upstream commit 96222d53842dfe54869ec4e1b9d4856daf9105a2 ]

fstests generic/471 reports a failure when run with MOUNT_OPTIONS="-o
dax".  The reason is that the initial pwrite to an empty file with the
RWF_NOWAIT flag set does not return -EAGAIN.  It turns out that
dax_iomap_rw doesn't pass that flag through to iomap_apply.

With this patch applied, generic/471 passes for me.

Signed-off-by: Jeff Moyer 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/x49r1z86e1d@segfault.boston.devel.redhat.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 fs/dax.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/dax.c b/fs/dax.c
index 2cc43cd914eb8..cc56313c6b3b9 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1207,6 +1207,9 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
lockdep_assert_held(&inode->i_rwsem);
}
 
+   if (iocb->ki_flags & IOCB_NOWAIT)
+   flags |= IOMAP_NOWAIT;
+
while (iov_iter_count(iter)) {
ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
iter, dax_iomap_actor);
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.5 06/58] dax: pass NOWAIT flag to iomap_apply

2020-02-22 Thread Sasha Levin
From: Jeff Moyer 

[ Upstream commit 96222d53842dfe54869ec4e1b9d4856daf9105a2 ]

fstests generic/471 reports a failure when run with MOUNT_OPTIONS="-o
dax".  The reason is that the initial pwrite to an empty file with the
RWF_NOWAIT flag set does not return -EAGAIN.  It turns out that
dax_iomap_rw doesn't pass that flag through to iomap_apply.

With this patch applied, generic/471 passes for me.

Signed-off-by: Jeff Moyer 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/x49r1z86e1d@segfault.boston.devel.redhat.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 fs/dax.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/dax.c b/fs/dax.c
index 1f1f0201cad18..0b0d8819cb1bb 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1207,6 +1207,9 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
lockdep_assert_held(&inode->i_rwsem);
}
 
+   if (iocb->ki_flags & IOCB_NOWAIT)
+   flags |= IOMAP_NOWAIT;
+
while (iov_iter_count(iter)) {
ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
iter, dax_iomap_actor);
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.14 35/58] libnvdimm/btt: fix variable 'rc' set but not used

2019-12-11 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit 4e24e37d5313edca8b4ab86f240c046c731e28d6 ]

drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
[-Wunused-but-set-variable]
int rc;
^~

Add a ratelimited message in case a storm of errors is encountered.

Fixes: d9b83c756953 ("libnvdimm, btt: rework error clearing")
Signed-off-by: Qian Cai 
Reviewed-by: Vishal Verma 
Link: https://lore.kernel.org/r/1572530719-32161-1-git-send-email-...@lca.pw
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index b2feda35966b1..471498469d0aa 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1259,11 +1259,11 @@ static int btt_read_pg(struct btt *btt, struct 
bio_integrity_payload *bip,
 
ret = btt_data_read(arena, page, off, postmap, cur_len);
if (ret) {
-   int rc;
-
/* Media error - set the e_flag */
-   rc = btt_map_write(arena, premap, postmap, 0, 1,
-   NVDIMM_IO_ATOMIC);
+   if (btt_map_write(arena, premap, postmap, 0, 1, 
NVDIMM_IO_ATOMIC))
+   dev_warn_ratelimited(to_dev(arena),
+   "Error persistently tracking bad blocks 
at %#x\n",
+   premap);
goto out_rtt;
}
 
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 51/79] libnvdimm/btt: fix variable 'rc' set but not used

2019-12-11 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit 4e24e37d5313edca8b4ab86f240c046c731e28d6 ]

drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
[-Wunused-but-set-variable]
int rc;
^~

Add a ratelimited message in case a storm of errors is encountered.

Fixes: d9b83c756953 ("libnvdimm, btt: rework error clearing")
Signed-off-by: Qian Cai 
Reviewed-by: Vishal Verma 
Link: https://lore.kernel.org/r/1572530719-32161-1-git-send-email-...@lca.pw
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 0360c015f6580..75ae2c508a044 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1260,11 +1260,11 @@ static int btt_read_pg(struct btt *btt, struct 
bio_integrity_payload *bip,
 
ret = btt_data_read(arena, page, off, postmap, cur_len);
if (ret) {
-   int rc;
-
/* Media error - set the e_flag */
-   rc = btt_map_write(arena, premap, postmap, 0, 1,
-   NVDIMM_IO_ATOMIC);
+   if (btt_map_write(arena, premap, postmap, 0, 1, 
NVDIMM_IO_ATOMIC))
+   dev_warn_ratelimited(to_dev(arena),
+   "Error persistently tracking bad blocks 
at %#x\n",
+   premap);
goto out_rtt;
}
 
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.4 081/134] libnvdimm/btt: fix variable 'rc' set but not used

2019-12-11 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit 4e24e37d5313edca8b4ab86f240c046c731e28d6 ]

drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
[-Wunused-but-set-variable]
int rc;
^~

Add a ratelimited message in case a storm of errors is encountered.

Fixes: d9b83c756953 ("libnvdimm, btt: rework error clearing")
Signed-off-by: Qian Cai 
Reviewed-by: Vishal Verma 
Link: https://lore.kernel.org/r/1572530719-32161-1-git-send-email-...@lca.pw
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 3e9f45aec8d18..5129543a04739 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1261,11 +1261,11 @@ static int btt_read_pg(struct btt *btt, struct 
bio_integrity_payload *bip,
 
ret = btt_data_read(arena, page, off, postmap, cur_len);
if (ret) {
-   int rc;
-
/* Media error - set the e_flag */
-   rc = btt_map_write(arena, premap, postmap, 0, 1,
-   NVDIMM_IO_ATOMIC);
+   if (btt_map_write(arena, premap, postmap, 0, 1, 
NVDIMM_IO_ATOMIC))
+   dev_warn_ratelimited(to_dev(arena),
+   "Error persistently tracking bad blocks 
at %#x\n",
+   premap);
goto out_rtt;
}
 
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 4.19 26/43] libnvdimm/region: Initialize bad block for volatile namespaces

2019-10-01 Thread Sasha Levin
From: "Aneesh Kumar K.V" 

[ Upstream commit c42adf87e4e7ed77f6ffe288dc90f980d07d68df ]

We do check for a bad block during namespace init and that use
region bad block list. We need to initialize the bad block
for volatile regions for this to work. We also observe a lockdep
warning as below because the lock is not initialized correctly
since we skip bad block init for volatile regions.

 INFO: trying to register non-static key.
 the code is fine but needs lockdep annotation.
 turning off the locking correctness validator.
 CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc1-15699-g3dee241c937e #149
 Call Trace:
 [c000f95cb250] [c147dd84] dump_stack+0xe8/0x164 (unreliable)
 [c000f95cb2a0] [c022ccd8] register_lock_class+0x308/0xa60
 [c000f95cb3a0] [c0229cc0] __lock_acquire+0x170/0x1ff0
 [c000f95cb4c0] [c022c740] lock_acquire+0x220/0x270
 [c000f95cb580] [c0a93230] badblocks_check+0xc0/0x290
 [c000f95cb5f0] [c0d97540] nd_pfn_validate+0x5c0/0x7f0
 [c000f95cb6d0] [c0d98300] nd_dax_probe+0xd0/0x1f0
 [c000f95cb760] [c0d9b66c] nd_pmem_probe+0x10c/0x160
 [c000f95cb790] [c0d7f5ec] nvdimm_bus_probe+0x10c/0x240
 [c000f95cb820] [c0d0f844] really_probe+0x254/0x4e0
 [c000f95cb8b0] [c0d0fdfc] driver_probe_device+0x16c/0x1e0
 [c000f95cb930] [c0d10238] device_driver_attach+0x68/0xa0
 [c000f95cb970] [c0d1040c] __driver_attach+0x19c/0x1c0
 [c000f95cb9f0] [c0d0c4c4] bus_for_each_dev+0x94/0x130
 [c000f95cba50] [c0d0f014] driver_attach+0x34/0x50
 [c000f95cba70] [c0d0e208] bus_add_driver+0x178/0x2f0
 [c000f95cbb00] [c0d117c8] driver_register+0x108/0x170
 [c000f95cbb70] [c0d7edb0] __nd_driver_register+0xe0/0x100
 [c000f95cbbd0] [c1a6baa4] nd_pmem_driver_init+0x34/0x48
 [c000f95cbbf0] [c00106f4] do_one_initcall+0x1d4/0x4b0
 [c000f95cbcd0] [c19f499c] kernel_init_freeable+0x544/0x65c
 [c000f95cbdb0] [c0010d6c] kernel_init+0x2c/0x180
 [c000f95cbe20] [c000b954] ret_from_kernel_thread+0x5c/0x68

Signed-off-by: Aneesh Kumar K.V 
Link: 
https://lore.kernel.org/r/20190919083355.26340-1-aneesh.ku...@linux.ibm.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 2 +-
 drivers/nvdimm/region.c  | 4 ++--
 drivers/nvdimm/region_devs.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 2ba22cd1331b0..54a633e8cb5d2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -189,7 +189,7 @@ static int nvdimm_clear_badblocks_region(struct device 
*dev, void *data)
sector_t sector;
 
/* make sure device is a region */
-   if (!is_nd_pmem(dev))
+   if (!is_memory(dev))
return 0;
 
nd_region = to_nd_region(dev);
diff --git a/drivers/nvdimm/region.c b/drivers/nvdimm/region.c
index f9130cc157e83..4b21c34df 100644
--- a/drivers/nvdimm/region.c
+++ b/drivers/nvdimm/region.c
@@ -42,7 +42,7 @@ static int nd_region_probe(struct device *dev)
if (rc)
return rc;
 
-   if (is_nd_pmem(&nd_region->dev)) {
+   if (is_memory(&nd_region->dev)) {
struct resource ndr_res;
 
if (devm_init_badblocks(dev, &nd_region->bb))
@@ -131,7 +131,7 @@ static void nd_region_notify(struct device *dev, enum 
nvdimm_event event)
struct nd_region *nd_region = to_nd_region(dev);
struct resource res;
 
-   if (is_nd_pmem(&nd_region->dev)) {
+   if (is_memory(&nd_region->dev)) {
res.start = nd_region->ndr_start;
res.end = nd_region->ndr_start +
nd_region->ndr_size - 1;
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 0303296e6d5b6..609fc450522a1 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -633,11 +633,11 @@ static umode_t region_visible(struct kobject *kobj, 
struct attribute *a, int n)
if (!is_memory(dev) && a == &dev_attr_dax_seed.attr)
return 0;
 
-   if (!is_nd_pmem(dev) && a == &dev_attr_badblocks.attr)
+   if (!is_memory(dev) && a == &dev_attr_badblocks.attr)
return 0;
 
if (a == &dev_attr_resource.attr) {
-   if (is_nd_pmem(dev))
+   if (is_memory(dev))
return 0400;
else
return 0;
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.2 33/63] libnvdimm/region: Initialize bad block for volatile namespaces

2019-10-01 Thread Sasha Levin
From: "Aneesh Kumar K.V" 

[ Upstream commit c42adf87e4e7ed77f6ffe288dc90f980d07d68df ]

We do check for a bad block during namespace init and that use
region bad block list. We need to initialize the bad block
for volatile regions for this to work. We also observe a lockdep
warning as below because the lock is not initialized correctly
since we skip bad block init for volatile regions.

 INFO: trying to register non-static key.
 the code is fine but needs lockdep annotation.
 turning off the locking correctness validator.
 CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc1-15699-g3dee241c937e #149
 Call Trace:
 [c000f95cb250] [c147dd84] dump_stack+0xe8/0x164 (unreliable)
 [c000f95cb2a0] [c022ccd8] register_lock_class+0x308/0xa60
 [c000f95cb3a0] [c0229cc0] __lock_acquire+0x170/0x1ff0
 [c000f95cb4c0] [c022c740] lock_acquire+0x220/0x270
 [c000f95cb580] [c0a93230] badblocks_check+0xc0/0x290
 [c000f95cb5f0] [c0d97540] nd_pfn_validate+0x5c0/0x7f0
 [c000f95cb6d0] [c0d98300] nd_dax_probe+0xd0/0x1f0
 [c000f95cb760] [c0d9b66c] nd_pmem_probe+0x10c/0x160
 [c000f95cb790] [c0d7f5ec] nvdimm_bus_probe+0x10c/0x240
 [c000f95cb820] [c0d0f844] really_probe+0x254/0x4e0
 [c000f95cb8b0] [c0d0fdfc] driver_probe_device+0x16c/0x1e0
 [c000f95cb930] [c0d10238] device_driver_attach+0x68/0xa0
 [c000f95cb970] [c0d1040c] __driver_attach+0x19c/0x1c0
 [c000f95cb9f0] [c0d0c4c4] bus_for_each_dev+0x94/0x130
 [c000f95cba50] [c0d0f014] driver_attach+0x34/0x50
 [c000f95cba70] [c0d0e208] bus_add_driver+0x178/0x2f0
 [c000f95cbb00] [c0d117c8] driver_register+0x108/0x170
 [c000f95cbb70] [c0d7edb0] __nd_driver_register+0xe0/0x100
 [c000f95cbbd0] [c1a6baa4] nd_pmem_driver_init+0x34/0x48
 [c000f95cbbf0] [c00106f4] do_one_initcall+0x1d4/0x4b0
 [c000f95cbcd0] [c19f499c] kernel_init_freeable+0x544/0x65c
 [c000f95cbdb0] [c0010d6c] kernel_init+0x2c/0x180
 [c000f95cbe20] [c000b954] ret_from_kernel_thread+0x5c/0x68

Signed-off-by: Aneesh Kumar K.V 
Link: 
https://lore.kernel.org/r/20190919083355.26340-1-aneesh.ku...@linux.ibm.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 2 +-
 drivers/nvdimm/region.c  | 4 ++--
 drivers/nvdimm/region_devs.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index df41f3571dc97..0d97158e7ac3f 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -176,7 +176,7 @@ static int nvdimm_clear_badblocks_region(struct device 
*dev, void *data)
sector_t sector;
 
/* make sure device is a region */
-   if (!is_nd_pmem(dev))
+   if (!is_memory(dev))
return 0;
 
nd_region = to_nd_region(dev);
diff --git a/drivers/nvdimm/region.c b/drivers/nvdimm/region.c
index 488c47ac4c4ae..0c618e478e65e 100644
--- a/drivers/nvdimm/region.c
+++ b/drivers/nvdimm/region.c
@@ -34,7 +34,7 @@ static int nd_region_probe(struct device *dev)
if (rc)
return rc;
 
-   if (is_nd_pmem(&nd_region->dev)) {
+   if (is_memory(&nd_region->dev)) {
struct resource ndr_res;
 
if (devm_init_badblocks(dev, &nd_region->bb))
@@ -123,7 +123,7 @@ static void nd_region_notify(struct device *dev, enum 
nvdimm_event event)
struct nd_region *nd_region = to_nd_region(dev);
struct resource res;
 
-   if (is_nd_pmem(&nd_region->dev)) {
+   if (is_memory(&nd_region->dev)) {
res.start = nd_region->ndr_start;
res.end = nd_region->ndr_start +
nd_region->ndr_size - 1;
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index a15276cdec7d4..0a02b2b308f6f 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -630,11 +630,11 @@ static umode_t region_visible(struct kobject *kobj, 
struct attribute *a, int n)
if (!is_memory(dev) && a == &dev_attr_dax_seed.attr)
return 0;
 
-   if (!is_nd_pmem(dev) && a == &dev_attr_badblocks.attr)
+   if (!is_memory(dev) && a == &dev_attr_badblocks.attr)
return 0;
 
if (a == &dev_attr_resource.attr) {
-   if (is_nd_pmem(dev))
+   if (is_memory(dev))
return 0400;
else
return 0;
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.2 36/63] libnvdimm: Fix endian conversion issues 

2019-10-01 Thread Sasha Levin
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.ku...@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 a434a5964cb93..d1a062d6ff705 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
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.3 40/71] libnvdimm: Fix endian conversion issues 

2019-10-01 Thread Sasha Levin
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.ku...@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
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.3 36/71] libnvdimm/region: Initialize bad block for volatile namespaces

2019-10-01 Thread Sasha Levin
From: "Aneesh Kumar K.V" 

[ Upstream commit c42adf87e4e7ed77f6ffe288dc90f980d07d68df ]

We do check for a bad block during namespace init and that use
region bad block list. We need to initialize the bad block
for volatile regions for this to work. We also observe a lockdep
warning as below because the lock is not initialized correctly
since we skip bad block init for volatile regions.

 INFO: trying to register non-static key.
 the code is fine but needs lockdep annotation.
 turning off the locking correctness validator.
 CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc1-15699-g3dee241c937e #149
 Call Trace:
 [c000f95cb250] [c147dd84] dump_stack+0xe8/0x164 (unreliable)
 [c000f95cb2a0] [c022ccd8] register_lock_class+0x308/0xa60
 [c000f95cb3a0] [c0229cc0] __lock_acquire+0x170/0x1ff0
 [c000f95cb4c0] [c022c740] lock_acquire+0x220/0x270
 [c000f95cb580] [c0a93230] badblocks_check+0xc0/0x290
 [c000f95cb5f0] [c0d97540] nd_pfn_validate+0x5c0/0x7f0
 [c000f95cb6d0] [c0d98300] nd_dax_probe+0xd0/0x1f0
 [c000f95cb760] [c0d9b66c] nd_pmem_probe+0x10c/0x160
 [c000f95cb790] [c0d7f5ec] nvdimm_bus_probe+0x10c/0x240
 [c000f95cb820] [c0d0f844] really_probe+0x254/0x4e0
 [c000f95cb8b0] [c0d0fdfc] driver_probe_device+0x16c/0x1e0
 [c000f95cb930] [c0d10238] device_driver_attach+0x68/0xa0
 [c000f95cb970] [c0d1040c] __driver_attach+0x19c/0x1c0
 [c000f95cb9f0] [c0d0c4c4] bus_for_each_dev+0x94/0x130
 [c000f95cba50] [c0d0f014] driver_attach+0x34/0x50
 [c000f95cba70] [c0d0e208] bus_add_driver+0x178/0x2f0
 [c000f95cbb00] [c0d117c8] driver_register+0x108/0x170
 [c000f95cbb70] [c0d7edb0] __nd_driver_register+0xe0/0x100
 [c000f95cbbd0] [c1a6baa4] nd_pmem_driver_init+0x34/0x48
 [c000f95cbbf0] [c00106f4] do_one_initcall+0x1d4/0x4b0
 [c000f95cbcd0] [c19f499c] kernel_init_freeable+0x544/0x65c
 [c000f95cbdb0] [c0010d6c] kernel_init+0x2c/0x180
 [c000f95cbe20] [c000b954] ret_from_kernel_thread+0x5c/0x68

Signed-off-by: Aneesh Kumar K.V 
Link: 
https://lore.kernel.org/r/20190919083355.26340-1-aneesh.ku...@linux.ibm.com
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c | 2 +-
 drivers/nvdimm/region.c  | 4 ++--
 drivers/nvdimm/region_devs.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 798c5c4aea9ca..bb3f20ebc276d 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -182,7 +182,7 @@ static int nvdimm_clear_badblocks_region(struct device 
*dev, void *data)
sector_t sector;
 
/* make sure device is a region */
-   if (!is_nd_pmem(dev))
+   if (!is_memory(dev))
return 0;
 
nd_region = to_nd_region(dev);
diff --git a/drivers/nvdimm/region.c b/drivers/nvdimm/region.c
index 37bf8719a2a44..0f6978e72e7cd 100644
--- a/drivers/nvdimm/region.c
+++ b/drivers/nvdimm/region.c
@@ -34,7 +34,7 @@ static int nd_region_probe(struct device *dev)
if (rc)
return rc;
 
-   if (is_nd_pmem(&nd_region->dev)) {
+   if (is_memory(&nd_region->dev)) {
struct resource ndr_res;
 
if (devm_init_badblocks(dev, &nd_region->bb))
@@ -123,7 +123,7 @@ static void nd_region_notify(struct device *dev, enum 
nvdimm_event event)
struct nd_region *nd_region = to_nd_region(dev);
struct resource res;
 
-   if (is_nd_pmem(&nd_region->dev)) {
+   if (is_memory(&nd_region->dev)) {
res.start = nd_region->ndr_start;
res.end = nd_region->ndr_start +
nd_region->ndr_size - 1;
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index af30cbe7a8ea2..47b48800fb758 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -632,11 +632,11 @@ static umode_t region_visible(struct kobject *kobj, 
struct attribute *a, int n)
if (!is_memory(dev) && a == &dev_attr_dax_seed.attr)
return 0;
 
-   if (!is_nd_pmem(dev) && a == &dev_attr_badblocks.attr)
+   if (!is_memory(dev) && a == &dev_attr_badblocks.attr)
return 0;
 
if (a == &dev_attr_resource.attr) {
-   if (is_nd_pmem(dev))
+   if (is_memory(dev))
return 0400;
else
return 0;
-- 
2.20.1
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


[PATCH AUTOSEL 5.2 67/85] device-dax: fix memory and resource leak if hotplug fails

2019-07-26 Thread Sasha Levin
From: Pavel Tatashin 

[ Upstream commit 31e4ca92a7dd4cdebd7fe1456b3b0b6ace9a816f ]

Patch series ""Hotremove" persistent memory", v6.

Recently, adding a persistent memory to be used like a regular RAM was
added to Linux.  This work extends this functionality to also allow hot
removing persistent memory.

We (Microsoft) have an important use case for this functionality.

The requirement is for physical machines with small amount of RAM (~8G)
to be able to reboot in a very short period of time (<1s).  Yet, there
is a userland state that is expensive to recreate (~2G).

The solution is to boot machines with 2G preserved for persistent
memory.

Copy the state, and hotadd the persistent memory so machine still has
all 8G available for runtime.  Before reboot, offline and hotremove
device-dax 2G, copy the memory that is needed to be preserved to pmem0
device, and reboot.

The series of operations look like this:

1. After boot restore /dev/pmem0 to ramdisk to be consumed by apps.
   and free ramdisk.
2. Convert raw pmem0 to devdax
   ndctl create-namespace --mode devdax --map mem -e namespace0.0 -f
3. Hotadd to System RAM
   echo dax0.0 > /sys/bus/dax/drivers/device_dax/unbind
   echo dax0.0 > /sys/bus/dax/drivers/kmem/new_id
   echo online_movable > /sys/devices/system/memoryXXX/state
4. Before reboot hotremove device-dax memory from System RAM
   echo offline > /sys/devices/system/memoryXXX/state
   echo dax0.0 > /sys/bus/dax/drivers/kmem/unbind
5. Create raw pmem0 device
   ndctl create-namespace --mode raw  -e namespace0.0 -f
6. Copy the state that was stored by apps to ramdisk to pmem device
7. Do kexec reboot or reboot through firmware if firmware does not
   zero memory in pmem0 region (These machines have only regular
   volatile memory). So to have pmem0 device either memmap kernel
   parameter is used, or devices nodes in dtb are specified.

This patch (of 3):

When add_memory() fails, the resource and the memory should be freed.

Link: http://lkml.kernel.org/r/20190517215438.6487-2-pasha.tatas...@soleen.com
Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like 
normal RAM")
Signed-off-by: Pavel Tatashin 
Reviewed-by: Dave Hansen 
Cc: Bjorn Helgaas 
Cc: Borislav Petkov 
Cc: Dan Williams 
Cc: Dave Hansen 
Cc: Dave Jiang 
Cc: David Hildenbrand 
Cc: Fengguang Wu 
Cc: Huang Ying 
Cc: James Morris 
Cc: Jérôme Glisse 
Cc: Keith Busch 
Cc: Michal Hocko 
Cc: Ross Zwisler 
Cc: Sasha Levin 
Cc: Takashi Iwai 
Cc: Tom Lendacky 
Cc: Vishal Verma 
Cc: Yaowei Bai 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 drivers/dax/kmem.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index a02318c6d28a..4c0131857133 100644
--- a/drivers/dax/kmem.c
+++ b/drivers/dax/kmem.c
@@ -66,8 +66,11 @@ int dev_dax_kmem_probe(struct device *dev)
new_res->name = dev_name(dev);
 
rc = add_memory(numa_node, new_res->start, resource_size(new_res));
-   if (rc)
+   if (rc) {
+   release_resource(new_res);
+   kfree(new_res);
return rc;
+   }
 
return 0;
 }
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v2 1/7] drivers/base: Introduce kill_device()

2019-07-18 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 4d88a97aa9e8 libnvdimm, nvdimm: dimm driver and base libnvdimm 
device-driver infrastructure.

The bot has tested the following trees: v5.2.1, v5.1.18, v4.19.59, v4.14.133, 
v4.9.185, v4.4.185.

v5.2.1: Build OK!
v5.1.18: Build OK!
v4.19.59: Failed to apply! Possible dependencies:
3451a495ef24 ("driver core: Establish order of operations for device_add 
and device_del via bitflag")

v4.14.133: Failed to apply! Possible dependencies:
3451a495ef24 ("driver core: Establish order of operations for device_add 
and device_del via bitflag")

v4.9.185: Failed to apply! Possible dependencies:
3451a495ef24 ("driver core: Establish order of operations for device_add 
and device_del via bitflag")

v4.4.185: Failed to apply! Possible dependencies:
3451a495ef24 ("driver core: Establish order of operations for device_add 
and device_del via bitflag")
656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from 
bus_type.match()")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v2 6/7] libnvdimm/bus: Fix wait_nvdimm_bus_probe_idle() ABBA deadlock

2019-07-17 Thread Sasha Levin

On Wed, Jul 17, 2019 at 06:08:21PM -0700, Dan Williams wrote:

A multithreaded namespace creation/destruction stress test currently
deadlocks with the following lockup signature:

   INFO: task ndctl:2924 blocked for more than 122 seconds.
 Tainted: G   OE 5.2.0-rc4+ #3382
   "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
   ndctl   D0  2924   1176 0x
   Call Trace:
? __schedule+0x27e/0x780
schedule+0x30/0xb0
wait_nvdimm_bus_probe_idle+0x8a/0xd0 [libnvdimm]
? finish_wait+0x80/0x80
uuid_store+0xe6/0x2e0 [libnvdimm]
kernfs_fop_write+0xf0/0x1a0
vfs_write+0xb7/0x1b0
ksys_write+0x5c/0xd0
do_syscall_64+0x60/0x240

INFO: task ndctl:2923 blocked for more than 122 seconds.
  Tainted: G   OE 5.2.0-rc4+ #3382
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
ndctl   D0  2923   1175 0x
Call Trace:
 ? __schedule+0x27e/0x780
 ? __mutex_lock+0x489/0x910
 schedule+0x30/0xb0
 schedule_preempt_disabled+0x11/0x20
 __mutex_lock+0x48e/0x910
 ? nvdimm_namespace_common_probe+0x95/0x4d0 [libnvdimm]
 ? __lock_acquire+0x23f/0x1710
 ? nvdimm_namespace_common_probe+0x95/0x4d0 [libnvdimm]
 nvdimm_namespace_common_probe+0x95/0x4d0 [libnvdimm]
 __dax_pmem_probe+0x5e/0x210 [dax_pmem_core]
 ? nvdimm_bus_probe+0x1d0/0x2c0 [libnvdimm]
 dax_pmem_probe+0xc/0x20 [dax_pmem]
 nvdimm_bus_probe+0x90/0x2c0 [libnvdimm]
 really_probe+0xef/0x390
 driver_probe_device+0xb4/0x100

In this sequence an 'nd_dax' device is being probed and trying to take
the lock on its backing namespace to validate that the 'nd_dax' device
indeed has exclusive access to the backing namespace. Meanwhile, another
thread is trying to update the uuid property of that same backing
namespace. So one thread is in the probe path trying to acquire the
lock, and the other thread has acquired the lock and tries to flush the
probe path.

Fix this deadlock by not holding the namespace device_lock over the
wait_nvdimm_bus_probe_idle() synchronization step. In turn this requires
the device_lock to be held on entry to wait_nvdimm_bus_probe_idle() and
subsequently dropped internally to wait_nvdimm_bus_probe_idle().

Cc: 
Fixes: bf9bccc14c05 ("libnvdimm: pmem label sets and namespace instantiation")
Cc: Vishal Verma 
Tested-by: Jane Chu 
Signed-off-by: Dan Williams 


Hi Dan,

The way these patches are split, when we take them to stable this patch
won't apply because it wants "libnvdimm/bus: Prepare the nd_ioctl() path
to be re-entrant".

If you were to send another iteration of this patchset, could you please
re-order the patches so they will apply cleanly to stable? this will
help with reducing mail exchanges later on and possibly a mis-merge into
stable.

If not, this should serve as a reference for future us to double check
the backport.

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.14 19/24] libnvdimm: Fix compilation warnings with W=1

2019-06-04 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit c01dafad77fea8d64c4fdca0a6031c980842ad65 ]

Several places (dimm_devs.c, core.c etc) include label.h but only
label.c uses NSINDEX_SIGNATURE, so move its definition to label.c
instead.

In file included from drivers/nvdimm/dimm_devs.c:23:
drivers/nvdimm/label.h:41:19: warning: 'NSINDEX_SIGNATURE' defined but
not used [-Wunused-const-variable=]

Also, some places abuse "/**" which is only reserved for the kernel-doc.

drivers/nvdimm/bus.c:648: warning: cannot understand function prototype:
'struct attribute_group nd_device_attribute_group = '
drivers/nvdimm/bus.c:677: warning: cannot understand function prototype:
'struct attribute_group nd_numa_attribute_group = '

Those are just some member assignments for the "struct attribute_group"
instances and it can't be expressed in the kernel-doc.

Reviewed-by: Vishal Verma 
Signed-off-by: Qian Cai 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c   | 4 ++--
 drivers/nvdimm/label.c | 2 ++
 drivers/nvdimm/label.h | 2 --
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a6746a1f20ae..2f1b54fab399 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -608,7 +608,7 @@ static struct attribute *nd_device_attributes[] = {
NULL,
 };
 
-/**
+/*
  * nd_device_attribute_group - generic attributes for all devices on an nd bus
  */
 struct attribute_group nd_device_attribute_group = {
@@ -637,7 +637,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, 
struct attribute *a,
return a->mode;
 }
 
-/**
+/*
  * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
  */
 struct attribute_group nd_numa_attribute_group = {
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 6a16017cc0d9..1fb3a2491131 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -25,6 +25,8 @@ static guid_t nvdimm_btt2_guid;
 static guid_t nvdimm_pfn_guid;
 static guid_t nvdimm_dax_guid;
 
+static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
+
 static u32 best_seq(u32 a, u32 b)
 {
a &= NSINDEX_SEQ_MASK;
diff --git a/drivers/nvdimm/label.h b/drivers/nvdimm/label.h
index 1ebf4d3d01ba..9ed772db6900 100644
--- a/drivers/nvdimm/label.h
+++ b/drivers/nvdimm/label.h
@@ -38,8 +38,6 @@ enum {
ND_NSINDEX_INIT = 0x1,
 };
 
-static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
-
 /**
  * struct nd_namespace_index - label set superblock
  * @sig: NAMESPACE_INDEX\0
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 25/36] libnvdimm: Fix compilation warnings with W=1

2019-06-04 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit c01dafad77fea8d64c4fdca0a6031c980842ad65 ]

Several places (dimm_devs.c, core.c etc) include label.h but only
label.c uses NSINDEX_SIGNATURE, so move its definition to label.c
instead.

In file included from drivers/nvdimm/dimm_devs.c:23:
drivers/nvdimm/label.h:41:19: warning: 'NSINDEX_SIGNATURE' defined but
not used [-Wunused-const-variable=]

Also, some places abuse "/**" which is only reserved for the kernel-doc.

drivers/nvdimm/bus.c:648: warning: cannot understand function prototype:
'struct attribute_group nd_device_attribute_group = '
drivers/nvdimm/bus.c:677: warning: cannot understand function prototype:
'struct attribute_group nd_numa_attribute_group = '

Those are just some member assignments for the "struct attribute_group"
instances and it can't be expressed in the kernel-doc.

Reviewed-by: Vishal Verma 
Signed-off-by: Qian Cai 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c   | 4 ++--
 drivers/nvdimm/label.c | 2 ++
 drivers/nvdimm/label.h | 2 --
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 9148015ed803..a3132a9eb91c 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -612,7 +612,7 @@ static struct attribute *nd_device_attributes[] = {
NULL,
 };
 
-/**
+/*
  * nd_device_attribute_group - generic attributes for all devices on an nd bus
  */
 struct attribute_group nd_device_attribute_group = {
@@ -641,7 +641,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, 
struct attribute *a,
return a->mode;
 }
 
-/**
+/*
  * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
  */
 struct attribute_group nd_numa_attribute_group = {
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 452ad379ed70..9f1b7e3153f9 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -25,6 +25,8 @@ static guid_t nvdimm_btt2_guid;
 static guid_t nvdimm_pfn_guid;
 static guid_t nvdimm_dax_guid;
 
+static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
+
 static u32 best_seq(u32 a, u32 b)
 {
a &= NSINDEX_SEQ_MASK;
diff --git a/drivers/nvdimm/label.h b/drivers/nvdimm/label.h
index 18bbe183b3a9..52f9fcada00a 100644
--- a/drivers/nvdimm/label.h
+++ b/drivers/nvdimm/label.h
@@ -38,8 +38,6 @@ enum {
ND_NSINDEX_INIT = 0x1,
 };
 
-static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
-
 /**
  * struct nd_namespace_index - label set superblock
  * @sig: NAMESPACE_INDEX\0
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.1 39/60] libnvdimm: Fix compilation warnings with W=1

2019-06-04 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit c01dafad77fea8d64c4fdca0a6031c980842ad65 ]

Several places (dimm_devs.c, core.c etc) include label.h but only
label.c uses NSINDEX_SIGNATURE, so move its definition to label.c
instead.

In file included from drivers/nvdimm/dimm_devs.c:23:
drivers/nvdimm/label.h:41:19: warning: 'NSINDEX_SIGNATURE' defined but
not used [-Wunused-const-variable=]

Also, some places abuse "/**" which is only reserved for the kernel-doc.

drivers/nvdimm/bus.c:648: warning: cannot understand function prototype:
'struct attribute_group nd_device_attribute_group = '
drivers/nvdimm/bus.c:677: warning: cannot understand function prototype:
'struct attribute_group nd_numa_attribute_group = '

Those are just some member assignments for the "struct attribute_group"
instances and it can't be expressed in the kernel-doc.

Reviewed-by: Vishal Verma 
Signed-off-by: Qian Cai 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/bus.c   | 4 ++--
 drivers/nvdimm/label.c | 2 ++
 drivers/nvdimm/label.h | 2 --
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 7bbff0af29b2..99d5892ea98a 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -642,7 +642,7 @@ static struct attribute *nd_device_attributes[] = {
NULL,
 };
 
-/**
+/*
  * nd_device_attribute_group - generic attributes for all devices on an nd bus
  */
 struct attribute_group nd_device_attribute_group = {
@@ -671,7 +671,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, 
struct attribute *a,
return a->mode;
 }
 
-/**
+/*
  * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
  */
 struct attribute_group nd_numa_attribute_group = {
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 2030805aa216..edf278067e72 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -25,6 +25,8 @@ static guid_t nvdimm_btt2_guid;
 static guid_t nvdimm_pfn_guid;
 static guid_t nvdimm_dax_guid;
 
+static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
+
 static u32 best_seq(u32 a, u32 b)
 {
a &= NSINDEX_SEQ_MASK;
diff --git a/drivers/nvdimm/label.h b/drivers/nvdimm/label.h
index e9a2ad3c2150..4bb7add39580 100644
--- a/drivers/nvdimm/label.h
+++ b/drivers/nvdimm/label.h
@@ -38,8 +38,6 @@ enum {
ND_NSINDEX_INIT = 0x1,
 };
 
-static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
-
 /**
  * struct nd_namespace_index - label set superblock
  * @sig: NAMESPACE_INDEX\0
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 013/141] mm: page_mkclean vs MADV_DONTNEED race

2019-06-01 Thread Sasha Levin
From: "Aneesh Kumar K.V" 

[ Upstream commit 024eee0e83f0df52317be607ca521e0fc572aa07 ]

MADV_DONTNEED is handled with mmap_sem taken in read mode.  We call
page_mkclean without holding mmap_sem.

MADV_DONTNEED implies that pages in the region are unmapped and subsequent
access to the pages in that range is handled as a new page fault.  This
implies that if we don't have parallel access to the region when
MADV_DONTNEED is run we expect those range to be unallocated.

w.r.t page_mkclean() we need to make sure that we don't break the
MADV_DONTNEED semantics.  MADV_DONTNEED check for pmd_none without holding
pmd_lock.  This implies we skip the pmd if we temporarily mark pmd none.
Avoid doing that while marking the page clean.

Keep the sequence same for dax too even though we don't support
MADV_DONTNEED for dax mapping

The bug was noticed by code review and I didn't observe any failures w.r.t
test run.  This is similar to

commit 58ceeb6bec86d9140f9d91d71a710e963523d063
Author: Kirill A. Shutemov 
Date:   Thu Apr 13 14:56:26 2017 -0700

thp: fix MADV_DONTNEED vs. MADV_FREE race

commit ced108037c2aa542b3ed8b7afd1576064ad1362a
Author: Kirill A. Shutemov 
Date:   Thu Apr 13 14:56:20 2017 -0700

thp: fix MADV_DONTNEED vs. numa balancing race

Link: http://lkml.kernel.org/r/20190321040610.14226-1-aneesh.ku...@linux.ibm.com
Signed-off-by: Aneesh Kumar K.V 
Reviewed-by: Andrew Morton 
Cc: Dan Williams 
Cc:"Kirill A . Shutemov" 
Cc: Andrea Arcangeli 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 fs/dax.c  | 2 +-
 mm/rmap.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 004c8ac1117c4..75a289c31c7e5 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -908,7 +908,7 @@ static void dax_mapping_entry_mkclean(struct address_space 
*mapping,
goto unlock_pmd;
 
flush_cache_page(vma, address, pfn);
-   pmd = pmdp_huge_clear_flush(vma, address, pmdp);
+   pmd = pmdp_invalidate(vma, address, pmdp);
pmd = pmd_wrprotect(pmd);
pmd = pmd_mkclean(pmd);
set_pmd_at(vma->vm_mm, address, pmdp, pmd);
diff --git a/mm/rmap.c b/mm/rmap.c
index 85b7f94233526..f048c2651954b 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -926,7 +926,7 @@ static bool page_mkclean_one(struct page *page, struct 
vm_area_struct *vma,
continue;
 
flush_cache_page(vma, address, page_to_pfn(page));
-   entry = pmdp_huge_clear_flush(vma, address, pmd);
+   entry = pmdp_invalidate(vma, address, pmd);
entry = pmd_wrprotect(entry);
entry = pmd_mkclean(entry);
set_pmd_at(vma->vm_mm, address, pmd, entry);
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 018/173] mm: page_mkclean vs MADV_DONTNEED race

2019-06-01 Thread Sasha Levin
From: "Aneesh Kumar K.V" 

[ Upstream commit 024eee0e83f0df52317be607ca521e0fc572aa07 ]

MADV_DONTNEED is handled with mmap_sem taken in read mode.  We call
page_mkclean without holding mmap_sem.

MADV_DONTNEED implies that pages in the region are unmapped and subsequent
access to the pages in that range is handled as a new page fault.  This
implies that if we don't have parallel access to the region when
MADV_DONTNEED is run we expect those range to be unallocated.

w.r.t page_mkclean() we need to make sure that we don't break the
MADV_DONTNEED semantics.  MADV_DONTNEED check for pmd_none without holding
pmd_lock.  This implies we skip the pmd if we temporarily mark pmd none.
Avoid doing that while marking the page clean.

Keep the sequence same for dax too even though we don't support
MADV_DONTNEED for dax mapping

The bug was noticed by code review and I didn't observe any failures w.r.t
test run.  This is similar to

commit 58ceeb6bec86d9140f9d91d71a710e963523d063
Author: Kirill A. Shutemov 
Date:   Thu Apr 13 14:56:26 2017 -0700

thp: fix MADV_DONTNEED vs. MADV_FREE race

commit ced108037c2aa542b3ed8b7afd1576064ad1362a
Author: Kirill A. Shutemov 
Date:   Thu Apr 13 14:56:20 2017 -0700

thp: fix MADV_DONTNEED vs. numa balancing race

Link: http://lkml.kernel.org/r/20190321040610.14226-1-aneesh.ku...@linux.ibm.com
Signed-off-by: Aneesh Kumar K.V 
Reviewed-by: Andrew Morton 
Cc: Dan Williams 
Cc:"Kirill A . Shutemov" 
Cc: Andrea Arcangeli 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 fs/dax.c  | 2 +-
 mm/rmap.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 8eb3e8c2b4bdc..163ebd6cc0d1c 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -814,7 +814,7 @@ static void dax_entry_mkclean(struct address_space 
*mapping, pgoff_t index,
goto unlock_pmd;
 
flush_cache_page(vma, address, pfn);
-   pmd = pmdp_huge_clear_flush(vma, address, pmdp);
+   pmd = pmdp_invalidate(vma, address, pmdp);
pmd = pmd_wrprotect(pmd);
pmd = pmd_mkclean(pmd);
set_pmd_at(vma->vm_mm, address, pmdp, pmd);
diff --git a/mm/rmap.c b/mm/rmap.c
index 0454ecc29537a..e0710b258c417 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -928,7 +928,7 @@ static bool page_mkclean_one(struct page *page, struct 
vm_area_struct *vma,
continue;
 
flush_cache_page(vma, address, page_to_pfn(page));
-   entry = pmdp_huge_clear_flush(vma, address, pmd);
+   entry = pmdp_invalidate(vma, address, pmd);
entry = pmd_wrprotect(entry);
entry = pmd_mkclean(entry);
set_pmd_at(vma->vm_mm, address, pmd, entry);
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.1 020/186] mm: page_mkclean vs MADV_DONTNEED race

2019-06-01 Thread Sasha Levin
From: "Aneesh Kumar K.V" 

[ Upstream commit 024eee0e83f0df52317be607ca521e0fc572aa07 ]

MADV_DONTNEED is handled with mmap_sem taken in read mode.  We call
page_mkclean without holding mmap_sem.

MADV_DONTNEED implies that pages in the region are unmapped and subsequent
access to the pages in that range is handled as a new page fault.  This
implies that if we don't have parallel access to the region when
MADV_DONTNEED is run we expect those range to be unallocated.

w.r.t page_mkclean() we need to make sure that we don't break the
MADV_DONTNEED semantics.  MADV_DONTNEED check for pmd_none without holding
pmd_lock.  This implies we skip the pmd if we temporarily mark pmd none.
Avoid doing that while marking the page clean.

Keep the sequence same for dax too even though we don't support
MADV_DONTNEED for dax mapping

The bug was noticed by code review and I didn't observe any failures w.r.t
test run.  This is similar to

commit 58ceeb6bec86d9140f9d91d71a710e963523d063
Author: Kirill A. Shutemov 
Date:   Thu Apr 13 14:56:26 2017 -0700

thp: fix MADV_DONTNEED vs. MADV_FREE race

commit ced108037c2aa542b3ed8b7afd1576064ad1362a
Author: Kirill A. Shutemov 
Date:   Thu Apr 13 14:56:20 2017 -0700

thp: fix MADV_DONTNEED vs. numa balancing race

Link: http://lkml.kernel.org/r/20190321040610.14226-1-aneesh.ku...@linux.ibm.com
Signed-off-by: Aneesh Kumar K.V 
Reviewed-by: Andrew Morton 
Cc: Dan Williams 
Cc:"Kirill A . Shutemov" 
Cc: Andrea Arcangeli 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 fs/dax.c  | 2 +-
 mm/rmap.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 83009875308c5..f74386293632d 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -814,7 +814,7 @@ static void dax_entry_mkclean(struct address_space 
*mapping, pgoff_t index,
goto unlock_pmd;
 
flush_cache_page(vma, address, pfn);
-   pmd = pmdp_huge_clear_flush(vma, address, pmdp);
+   pmd = pmdp_invalidate(vma, address, pmdp);
pmd = pmd_wrprotect(pmd);
pmd = pmd_mkclean(pmd);
set_pmd_at(vma->vm_mm, address, pmdp, pmd);
diff --git a/mm/rmap.c b/mm/rmap.c
index b30c7c71d1d92..76c8dfd3ae1cd 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -928,7 +928,7 @@ static bool page_mkclean_one(struct page *page, struct 
vm_area_struct *vma,
continue;
 
flush_cache_page(vma, address, page_to_pfn(page));
-   entry = pmdp_huge_clear_flush(vma, address, pmd);
+   entry = pmdp_invalidate(vma, address, pmd);
entry = pmd_wrprotect(entry);
entry = pmd_mkclean(entry);
set_pmd_at(vma->vm_mm, address, pmd, entry);
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v2] libnvdimm/pmem: Bypass CONFIG_HARDENED_USERCOPY overhead

2019-05-21 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 0aed55af8834 x86, uaccess: introduce copy_from_iter_flushcache 
for pmem / cache-bypass operations.

The bot has tested the following trees: v5.1.3, v5.0.17, v4.19.44, v4.14.120.

v5.1.3: Build OK!
v5.0.17: Build OK!
v4.19.44: Build OK!
v4.14.120: Failed to apply! Possible dependencies:
6dfdb2b6d877 ("pmem: Switch to copy_to_iter_mcsafe()")
976431b02c2e ("dax, dm: allow device-mapper to operate without dax support")
98d82f48f198 ("dm log writes: add support for DAX")
b3a9a0c36e1f ("dax: Introduce a ->copy_to_iter dax operation")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.4 04/14] libnvdimm/btt: Fix a kmemdup failure check

2019-05-06 Thread Sasha Levin
From: Aditya Pakki 

[ Upstream commit 486fa92df4707b5df58d6508728bdb9321a59766 ]

In case kmemdup fails, the fix releases resources and returns to
avoid the NULL pointer dereference.

Signed-off-by: Aditya Pakki 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt_devs.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index cb477518dd0e..4c129450495d 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -170,14 +170,15 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
 
nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
-   if (nd_btt->id < 0) {
-   kfree(nd_btt);
-   return NULL;
-   }
+   if (nd_btt->id < 0)
+   goto out_nd_btt;
 
nd_btt->lbasize = lbasize;
-   if (uuid)
+   if (uuid) {
uuid = kmemdup(uuid, 16, GFP_KERNEL);
+   if (!uuid)
+   goto out_put_id;
+   }
nd_btt->uuid = uuid;
dev = &nd_btt->dev;
dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
@@ -192,6 +193,13 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
}
return dev;
+
+out_put_id:
+   ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
+
+out_nd_btt:
+   kfree(nd_btt);
+   return NULL;
 }
 
 struct device *nd_btt_create(struct nd_region *nd_region)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.9 02/25] libnvdimm/namespace: Fix a potential NULL pointer dereference

2019-05-06 Thread Sasha Levin
From: Kangjie Lu 

[ Upstream commit 55c1fc0af29a6c1b92f217b7eb7581a882e0c07c ]

In case kmemdup fails, the fix goes to blk_err to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/namespace_devs.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 9bc5f555ee68..cf4a90b50f8b 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2028,9 +2028,12 @@ struct device *create_namespace_blk(struct nd_region 
*nd_region,
if (!nsblk->uuid)
goto blk_err;
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
-   if (name[0])
+   if (name[0]) {
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
GFP_KERNEL);
+   if (!nsblk->alt_name)
+   goto blk_err;
+   }
res = nsblk_add_resource(nd_region, ndd, nsblk,
__le64_to_cpu(nd_label->dpa));
if (!res)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.9 06/25] libnvdimm/btt: Fix a kmemdup failure check

2019-05-06 Thread Sasha Levin
From: Aditya Pakki 

[ Upstream commit 486fa92df4707b5df58d6508728bdb9321a59766 ]

In case kmemdup fails, the fix releases resources and returns to
avoid the NULL pointer dereference.

Signed-off-by: Aditya Pakki 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt_devs.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 97dd2925ed6e..5d2c76682848 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -190,14 +190,15 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
 
nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
-   if (nd_btt->id < 0) {
-   kfree(nd_btt);
-   return NULL;
-   }
+   if (nd_btt->id < 0)
+   goto out_nd_btt;
 
nd_btt->lbasize = lbasize;
-   if (uuid)
+   if (uuid) {
uuid = kmemdup(uuid, 16, GFP_KERNEL);
+   if (!uuid)
+   goto out_put_id;
+   }
nd_btt->uuid = uuid;
dev = &nd_btt->dev;
dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
@@ -212,6 +213,13 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
}
return dev;
+
+out_put_id:
+   ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
+
+out_nd_btt:
+   kfree(nd_btt);
+   return NULL;
 }
 
 struct device *nd_btt_create(struct nd_region *nd_region)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.14 06/95] libnvdimm/btt: Fix a kmemdup failure check

2019-05-06 Thread Sasha Levin
From: Aditya Pakki 

[ Upstream commit 486fa92df4707b5df58d6508728bdb9321a59766 ]

In case kmemdup fails, the fix releases resources and returns to
avoid the NULL pointer dereference.

Signed-off-by: Aditya Pakki 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt_devs.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index d58925295aa7..e610dd890263 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -190,14 +190,15 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
 
nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
-   if (nd_btt->id < 0) {
-   kfree(nd_btt);
-   return NULL;
-   }
+   if (nd_btt->id < 0)
+   goto out_nd_btt;
 
nd_btt->lbasize = lbasize;
-   if (uuid)
+   if (uuid) {
uuid = kmemdup(uuid, 16, GFP_KERNEL);
+   if (!uuid)
+   goto out_put_id;
+   }
nd_btt->uuid = uuid;
dev = &nd_btt->dev;
dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
@@ -212,6 +213,13 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
}
return dev;
+
+out_put_id:
+   ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
+
+out_nd_btt:
+   kfree(nd_btt);
+   return NULL;
 }
 
 struct device *nd_btt_create(struct nd_region *nd_region)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.14 02/95] libnvdimm/namespace: Fix a potential NULL pointer dereference

2019-05-06 Thread Sasha Levin
From: Kangjie Lu 

[ Upstream commit 55c1fc0af29a6c1b92f217b7eb7581a882e0c07c ]

In case kmemdup fails, the fix goes to blk_err to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/namespace_devs.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 50b01d3eadd9..e3f228af59d1 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2234,9 +2234,12 @@ struct device *create_namespace_blk(struct nd_region 
*nd_region,
if (!nsblk->uuid)
goto blk_err;
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
-   if (name[0])
+   if (name[0]) {
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
GFP_KERNEL);
+   if (!nsblk->alt_name)
+   goto blk_err;
+   }
res = nsblk_add_resource(nd_region, ndd, nsblk,
__le64_to_cpu(nd_label->dpa));
if (!res)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 04/81] acpi/nfit: Always dump _DSM output payload

2019-05-06 Thread Sasha Levin
From: Dan Williams 

[ Upstream commit 351f339faa308c1c1461314a18c832239a841ca0 ]

The dynamic-debug statements for command payload output only get emitted
when the command is not ND_CMD_CALL. Move the output payload dumping
ahead of the early return path for ND_CMD_CALL.

Fixes: 31eca76ba2fc9 ("...whitelisted dimm command marshaling mechanism")
Reported-by: Vishal Verma 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 925dbc751322..8340c81b258b 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -542,6 +542,12 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
goto out;
}
 
+   dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
+   cmd_name, out_obj->buffer.length);
+   print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
+   out_obj->buffer.pointer,
+   min_t(u32, 128, out_obj->buffer.length), true);
+
if (call_pkg) {
call_pkg->nd_fw_size = out_obj->buffer.length;
memcpy(call_pkg->nd_payload + call_pkg->nd_size_in,
@@ -560,12 +566,6 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
return 0;
}
 
-   dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
-   cmd_name, out_obj->buffer.length);
-   print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
-   out_obj->buffer.pointer,
-   min_t(u32, 128, out_obj->buffer.length), true);
-
for (i = 0, offset = 0; i < desc->out_num; i++) {
u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf,
(u32 *) out_obj->buffer.pointer,
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 17/81] libnvdimm/pmem: fix a possible OOB access when read and write pmem

2019-05-06 Thread Sasha Levin
From: Li RongQing 

[ Upstream commit 9dc6488e84b0f64df17672271664752488cd6a25 ]

If offset is not zero and length is bigger than PAGE_SIZE,
this will cause to out of boundary access to a page memory

Fixes: 98cc093cba1e ("block, THP: make block_device_operations.rw_page support 
THP")
Co-developed-by: Liang ZhiCheng 
Signed-off-by: Liang ZhiCheng 
Signed-off-by: Li RongQing 
Reviewed-by: Ira Weiny 
Reviewed-by: Jeff Moyer 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/pmem.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 1d432c5ed275..cff027fc2676 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -113,13 +113,13 @@ static void write_pmem(void *pmem_addr, struct page *page,
 
while (len) {
mem = kmap_atomic(page);
-   chunk = min_t(unsigned int, len, PAGE_SIZE);
+   chunk = min_t(unsigned int, len, PAGE_SIZE - off);
memcpy_flushcache(pmem_addr, mem + off, chunk);
kunmap_atomic(mem);
len -= chunk;
off = 0;
page++;
-   pmem_addr += PAGE_SIZE;
+   pmem_addr += chunk;
}
 }
 
@@ -132,7 +132,7 @@ static blk_status_t read_pmem(struct page *page, unsigned 
int off,
 
while (len) {
mem = kmap_atomic(page);
-   chunk = min_t(unsigned int, len, PAGE_SIZE);
+   chunk = min_t(unsigned int, len, PAGE_SIZE - off);
rem = memcpy_mcsafe(mem + off, pmem_addr, chunk);
kunmap_atomic(mem);
if (rem)
@@ -140,7 +140,7 @@ static blk_status_t read_pmem(struct page *page, unsigned 
int off,
len -= chunk;
off = 0;
page++;
-   pmem_addr += PAGE_SIZE;
+   pmem_addr += chunk;
}
return BLK_STS_OK;
 }
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 05/81] libnvdimm/namespace: Fix a potential NULL pointer dereference

2019-05-06 Thread Sasha Levin
From: Kangjie Lu 

[ Upstream commit 55c1fc0af29a6c1b92f217b7eb7581a882e0c07c ]

In case kmemdup fails, the fix goes to blk_err to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/namespace_devs.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 54d79837f7c6..73a444c41cde 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2251,9 +2251,12 @@ static struct device *create_namespace_blk(struct 
nd_region *nd_region,
if (!nsblk->uuid)
goto blk_err;
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
-   if (name[0])
+   if (name[0]) {
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
GFP_KERNEL);
+   if (!nsblk->alt_name)
+   goto blk_err;
+   }
res = nsblk_add_resource(nd_region, ndd, nsblk,
__le64_to_cpu(nd_label->dpa));
if (!res)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 09/81] libnvdimm/btt: Fix a kmemdup failure check

2019-05-06 Thread Sasha Levin
From: Aditya Pakki 

[ Upstream commit 486fa92df4707b5df58d6508728bdb9321a59766 ]

In case kmemdup fails, the fix releases resources and returns to
avoid the NULL pointer dereference.

Signed-off-by: Aditya Pakki 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt_devs.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 795ad4ff35ca..e341498876ca 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -190,14 +190,15 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
 
nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
-   if (nd_btt->id < 0) {
-   kfree(nd_btt);
-   return NULL;
-   }
+   if (nd_btt->id < 0)
+   goto out_nd_btt;
 
nd_btt->lbasize = lbasize;
-   if (uuid)
+   if (uuid) {
uuid = kmemdup(uuid, 16, GFP_KERNEL);
+   if (!uuid)
+   goto out_put_id;
+   }
nd_btt->uuid = uuid;
dev = &nd_btt->dev;
dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
@@ -212,6 +213,13 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
}
return dev;
+
+out_put_id:
+   ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
+
+out_nd_btt:
+   kfree(nd_btt);
+   return NULL;
 }
 
 struct device *nd_btt_create(struct nd_region *nd_region)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 18/99] libnvdimm/pmem: fix a possible OOB access when read and write pmem

2019-05-06 Thread Sasha Levin
From: Li RongQing 

[ Upstream commit 9dc6488e84b0f64df17672271664752488cd6a25 ]

If offset is not zero and length is bigger than PAGE_SIZE,
this will cause to out of boundary access to a page memory

Fixes: 98cc093cba1e ("block, THP: make block_device_operations.rw_page support 
THP")
Co-developed-by: Liang ZhiCheng 
Signed-off-by: Liang ZhiCheng 
Signed-off-by: Li RongQing 
Reviewed-by: Ira Weiny 
Reviewed-by: Jeff Moyer 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/pmem.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index bc2f700feef8..0279eb1da3ef 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -113,13 +113,13 @@ static void write_pmem(void *pmem_addr, struct page *page,
 
while (len) {
mem = kmap_atomic(page);
-   chunk = min_t(unsigned int, len, PAGE_SIZE);
+   chunk = min_t(unsigned int, len, PAGE_SIZE - off);
memcpy_flushcache(pmem_addr, mem + off, chunk);
kunmap_atomic(mem);
len -= chunk;
off = 0;
page++;
-   pmem_addr += PAGE_SIZE;
+   pmem_addr += chunk;
}
 }
 
@@ -132,7 +132,7 @@ static blk_status_t read_pmem(struct page *page, unsigned 
int off,
 
while (len) {
mem = kmap_atomic(page);
-   chunk = min_t(unsigned int, len, PAGE_SIZE);
+   chunk = min_t(unsigned int, len, PAGE_SIZE - off);
rem = memcpy_mcsafe(mem + off, pmem_addr, chunk);
kunmap_atomic(mem);
if (rem)
@@ -140,7 +140,7 @@ static blk_status_t read_pmem(struct page *page, unsigned 
int off,
len -= chunk;
off = 0;
page++;
-   pmem_addr += PAGE_SIZE;
+   pmem_addr += chunk;
}
return BLK_STS_OK;
 }
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 09/99] libnvdimm/btt: Fix a kmemdup failure check

2019-05-06 Thread Sasha Levin
From: Aditya Pakki 

[ Upstream commit 486fa92df4707b5df58d6508728bdb9321a59766 ]

In case kmemdup fails, the fix releases resources and returns to
avoid the NULL pointer dereference.

Signed-off-by: Aditya Pakki 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/btt_devs.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 795ad4ff35ca..e341498876ca 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -190,14 +190,15 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
 
nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
-   if (nd_btt->id < 0) {
-   kfree(nd_btt);
-   return NULL;
-   }
+   if (nd_btt->id < 0)
+   goto out_nd_btt;
 
nd_btt->lbasize = lbasize;
-   if (uuid)
+   if (uuid) {
uuid = kmemdup(uuid, 16, GFP_KERNEL);
+   if (!uuid)
+   goto out_put_id;
+   }
nd_btt->uuid = uuid;
dev = &nd_btt->dev;
dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
@@ -212,6 +213,13 @@ static struct device *__nd_btt_create(struct nd_region 
*nd_region,
return NULL;
}
return dev;
+
+out_put_id:
+   ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
+
+out_nd_btt:
+   kfree(nd_btt);
+   return NULL;
 }
 
 struct device *nd_btt_create(struct nd_region *nd_region)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 04/99] acpi/nfit: Always dump _DSM output payload

2019-05-06 Thread Sasha Levin
From: Dan Williams 

[ Upstream commit 351f339faa308c1c1461314a18c832239a841ca0 ]

The dynamic-debug statements for command payload output only get emitted
when the command is not ND_CMD_CALL. Move the output payload dumping
ahead of the early return path for ND_CMD_CALL.

Fixes: 31eca76ba2fc9 ("...whitelisted dimm command marshaling mechanism")
Reported-by: Vishal Verma 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 4be4dc3e8aa6..38ec79bb3edd 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -563,6 +563,12 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
goto out;
}
 
+   dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
+   cmd_name, out_obj->buffer.length);
+   print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
+   out_obj->buffer.pointer,
+   min_t(u32, 128, out_obj->buffer.length), true);
+
if (call_pkg) {
call_pkg->nd_fw_size = out_obj->buffer.length;
memcpy(call_pkg->nd_payload + call_pkg->nd_size_in,
@@ -581,12 +587,6 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, 
struct nvdimm *nvdimm,
return 0;
}
 
-   dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
-   cmd_name, out_obj->buffer.length);
-   print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
-   out_obj->buffer.pointer,
-   min_t(u32, 128, out_obj->buffer.length), true);
-
for (i = 0, offset = 0; i < desc->out_num; i++) {
u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf,
(u32 *) out_obj->buffer.pointer,
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 05/99] libnvdimm/namespace: Fix a potential NULL pointer dereference

2019-05-06 Thread Sasha Levin
From: Kangjie Lu 

[ Upstream commit 55c1fc0af29a6c1b92f217b7eb7581a882e0c07c ]

In case kmemdup fails, the fix goes to blk_err to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/namespace_devs.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 33a3b23b3db7..e761b29f7160 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2249,9 +2249,12 @@ static struct device *create_namespace_blk(struct 
nd_region *nd_region,
if (!nsblk->uuid)
goto blk_err;
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
-   if (name[0])
+   if (name[0]) {
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
GFP_KERNEL);
+   if (!nsblk->alt_name)
+   goto blk_err;
+   }
res = nsblk_add_resource(nd_region, ndd, nsblk,
__le64_to_cpu(nd_label->dpa));
if (!res)
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 16/99] libnvdimm/security: provide fix for secure-erase to use zero-key

2019-05-06 Thread Sasha Levin
From: Dave Jiang 

[ Upstream commit 037c8489ade669e0f09ad40d5b91e5e1159a14b1 ]

Add a zero key in order to standardize hardware that want a key of 0's to
be passed. Some platforms defaults to a zero-key with security enabled
rather than allow the OS to enable the security. The zero key would allow
us to manage those platform as well. This also adds a fix to secure erase
so it can use the zero key to do crypto erase. Some other security commands
already use zero keys. This introduces a standard zero-key to allow
unification of semantics cross nvdimm security commands.

Signed-off-by: Dave Jiang 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/security.c| 17 -
 tools/testing/nvdimm/test/nfit.c | 11 +--
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
index f8bb746a549f..6bea6852bf27 100644
--- a/drivers/nvdimm/security.c
+++ b/drivers/nvdimm/security.c
@@ -22,6 +22,8 @@ static bool key_revalidate = true;
 module_param(key_revalidate, bool, 0444);
 MODULE_PARM_DESC(key_revalidate, "Require key validation at init.");
 
+static const char zero_key[NVDIMM_PASSPHRASE_LEN];
+
 static void *key_data(struct key *key)
 {
struct encrypted_key_payload *epayload = dereference_key_locked(key);
@@ -286,8 +288,9 @@ int nvdimm_security_erase(struct nvdimm *nvdimm, unsigned 
int keyid,
 {
struct device *dev = &nvdimm->dev;
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
-   struct key *key;
+   struct key *key = NULL;
int rc;
+   const void *data;
 
/* The bus lock should be held at the top level of the call stack */
lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
@@ -319,11 +322,15 @@ int nvdimm_security_erase(struct nvdimm *nvdimm, unsigned 
int keyid,
return -EOPNOTSUPP;
}
 
-   key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY);
-   if (!key)
-   return -ENOKEY;
+   if (keyid != 0) {
+   key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY);
+   if (!key)
+   return -ENOKEY;
+   data = key_data(key);
+   } else
+   data = zero_key;
 
-   rc = nvdimm->sec.ops->erase(nvdimm, key_data(key), pass_type);
+   rc = nvdimm->sec.ops->erase(nvdimm, data, pass_type);
dev_dbg(dev, "key: %d erase%s: %s\n", key_serial(key),
pass_type == NVDIMM_MASTER ? "(master)" : "(user)",
rc == 0 ? "success" : "fail");
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index b579f962451d..cad719876ef4 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -225,6 +225,8 @@ static struct workqueue_struct *nfit_wq;
 
 static struct gen_pool *nfit_pool;
 
+static const char zero_key[NVDIMM_PASSPHRASE_LEN];
+
 static struct nfit_test *to_nfit_test(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
@@ -1059,8 +1061,7 @@ static int nd_intel_test_cmd_secure_erase(struct 
nfit_test *t,
struct device *dev = &t->pdev.dev;
struct nfit_test_sec *sec = &dimm_sec_info[dimm];
 
-   if (!(sec->state & ND_INTEL_SEC_STATE_ENABLED) ||
-   (sec->state & ND_INTEL_SEC_STATE_FROZEN)) {
+   if (sec->state & ND_INTEL_SEC_STATE_FROZEN) {
nd_cmd->status = ND_INTEL_STATUS_INVALID_STATE;
dev_dbg(dev, "secure erase: wrong security state\n");
} else if (memcmp(nd_cmd->passphrase, sec->passphrase,
@@ -1068,6 +1069,12 @@ static int nd_intel_test_cmd_secure_erase(struct 
nfit_test *t,
nd_cmd->status = ND_INTEL_STATUS_INVALID_PASS;
dev_dbg(dev, "secure erase: wrong passphrase\n");
} else {
+   if (!(sec->state & ND_INTEL_SEC_STATE_ENABLED)
+   && (memcmp(nd_cmd->passphrase, zero_key,
+   ND_INTEL_PASSPHRASE_SIZE) != 0)) {
+   dev_dbg(dev, "invalid zero key\n");
+   return 0;
+   }
memset(sec->passphrase, 0, ND_INTEL_PASSPHRASE_SIZE);
memset(sec->master_passphrase, 0, ND_INTEL_PASSPHRASE_SIZE);
sec->state = 0;
-- 
2.20.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [v4 2/2] device-dax: "Hotremove" persistent memory that is used like normal RAM

2019-05-02 Thread Sasha Levin

On Wed, May 01, 2019 at 03:18:46PM -0400, Pavel Tatashin wrote:

It is now allowed to use persistent memory like a regular RAM, but
currently there is no way to remove this memory until machine is
rebooted.

This work expands the functionality to also allows hotremoving
previously hotplugged persistent memory, and recover the device for use
for other purposes.

To hotremove persistent memory, the management software must first
offline all memory blocks of dax region, and than unbind it from
device-dax/kmem driver. So, operations should look like this:

echo offline > echo offline > /sys/devices/system/memory/memoryN/state


This looks wrong :)

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [4.19, 5.0 stable PATCH 1/4] nfit/ars: Remove ars_start_flags

2019-04-23 Thread Sasha Levin

On Mon, Apr 22, 2019 at 04:08:10PM -0700, Dan Williams wrote:

commit 317a992ab9266b86b774b9f6b0f87eb4f59879a1 upstream.

The ars_start_flags property of 'struct acpi_nfit_desc' is no longer
used since ARS_REQ_SHORT and ARS_REQ_LONG were added.

Reviewed-by: Toshi Kani 
Signed-off-by: Dan Williams 


I've queued this series for both 4.19 and 5.0, thanks!

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] libnvdimm/namespace: Fix label tracking error

2019-04-19 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: bf9bccc14c05 libnvdimm: pmem label sets and namespace 
instantiation..

The bot has tested the following trees: v5.0.8, v4.19.35, v4.14.112, v4.9.169, 
v4.4.178, 

v5.0.8: Build OK!
v4.19.35: Build OK!
v4.14.112: Failed to apply! Possible dependencies:
426824d63b77 ("libnvdimm: remove redundant __func__ in dev_dbg")

v4.9.169: Failed to apply! Possible dependencies:
006358b35c73 ("libnvdimm: add support for clear poison list and badblocks 
for device dax")
355d838878e1 ("libnvdimm, label: add v1.2 label checksum support")
426824d63b77 ("libnvdimm: remove redundant __func__ in dev_dbg")
53b85a449b15 ("libnvdimm: passthru functions clear to send")
564e871aa66f ("libnvdimm, label: add v1.2 nvdimm label definitions")
b3fde74ea195 ("libnvdimm, label: add address abstraction identifiers")
c12c48ce869d ("libnvdimm, label: add v1.2 interleave-set-cookie algorithm")
f979b13c3cc5 ("libnvdimm, label: honor the lba size specified in v1.2 
labels")
faec6f8a1cd2 ("libnvdimm, label: populate the type_guid property for v1.2 
namespaces")

v4.4.178: Failed to apply! Possible dependencies:
0731de0dd95b ("libnvdimm, pfn: move 'memory mode' indication to sysfs")
0bfb8dd3edd6 ("libnvdimm: cleanup nvdimm_namespace_common_probe(), kill 
'host'")
0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations")
2dc43331e34f ("libnvdimm, pfn: fix pfn seed creation")
315c562536c4 ("libnvdimm, pfn: add 'align' attribute, default to 
HPAGE_SIZE")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
4b94ffdc4163 ("x86, mm: introduce vmem_altmap to augment 
vmemmap_populate()")
52db400fcd50 ("pmem, dax: clean up clear_pmem()")
87ba05dff351 ("libnvdimm: don't fail init for full badblocks list")
9476df7d80df ("mm: introduce find_dev_pagemap()")
9c41242817f4 ("libnvdimm: fix mode determination for e820 devices")
ad9a8bde2cb1 ("libnvdimm, pmem: move definition of 
nvdimm_namespace_add_poison to nd.h")
b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with 
dax_map_atomic()")
b3fde74ea195 ("libnvdimm, label: add address abstraction identifiers")
b95f5f4391fa ("libnvdimm: convert to statically allocated badblocks")
bd032943b5b2 ("libnvdimm, pfn, convert nd_pfn_probe() to devm")
c5ed9268643c ("libnvdimm, dax: autodetect support")
cd03412a51ac ("libnvdimm, dax: introduce device-dax infrastructure")
cfe30b872058 ("libnvdimm, pmem: adjust for section collisions with 'System 
RAM'")
d2c0f041e1bb ("libnvdimm, pfn, pmem: allocate memmap array in persistent 
memory")
d9cbe09d39aa ("libnvdimm, pmem: fix 'pfn' support for section-misaligned 
namespaces")
f6ed58c70d14 ("libnvdimm, pfn: 'resource'-address and 'size' attributes for 
pfn devices")
f7c6ab80fa5f ("libnvdimm, pfn: clean up pfn create parameters")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v2] mm: Fix modifying of page protection by insert_pfn_pmd()

2019-04-03 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.0.5, v4.19.32, v4.14.109, v4.9.166, 
v4.4.177, v3.18.137.

v5.0.5: Build OK!
v4.19.32: Build OK!
v4.14.109: Failed to apply! Possible dependencies:
b4e98d9ac775 ("mm: account pud page tables")
c4812909f5d5 ("mm: introduce wrappers to access mm->nr_ptes")

v4.9.166: Failed to apply! Possible dependencies:
166f61b9435a ("mm: codgin-style fixes")
505a60e22560 ("asm-generic: introduce 5level-fixup.h")
5c6a84a3f455 ("mm/kasan: Switch to using __pa_symbol and lm_alias")
82b0f8c39a38 ("mm: join struct fault_env and vm_fault")
953c66c2b22a ("mm: THP page cache support for ppc64")
b279ddc33824 ("mm: clarify mm_struct.mm_{users,count} documentation")
b4e98d9ac775 ("mm: account pud page tables")
c2febafc6773 ("mm: convert generic code to 5-level paging")
c4812909f5d5 ("mm: introduce wrappers to access mm->nr_ptes")

v4.4.177: Failed to apply! Possible dependencies:
01871e59af5c ("mm, dax: fix livelock, allow dax pmd mappings to become 
writeable")
01c8f1c44b83 ("mm, dax, gpu: convert vm_insert_mixed to pfn_t")
0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations")
1bdb2d4ee05f ("ARM: split off core mapping logic from create_mapping")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
3ed3a4f0ddff ("mm: cleanup *pte_alloc* interfaces")
52db400fcd50 ("pmem, dax: clean up clear_pmem()")
7bc3777ca19c ("sparc64: Trim page tables for 8M hugepages")
b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with 
dax_map_atomic()")
c4812909f5d5 ("mm: introduce wrappers to access mm->nr_ptes")
c7936206b971 ("ARM: implement create_mapping_late() for EFI use")
f25748e3c34e ("mm, dax: convert vmf_insert_pfn_pmd() to pfn_t")
f579b2b10412 ("ARM: factor out allocation routine from __create_mapping()")

v3.18.137: Failed to apply! Possible dependencies:
047fc8a1f9a6 ("libnvdimm, nfit, nd_blk: driver for BLK-mode access 
persistent memory")
2a3746984c98 ("x86: Use new cache mode type in track_pfn_remap() and 
track_pfn_insert()")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
4c1eaa2344fb ("drivers/block/pmem: Fix 32-bit build warning in 
pmem_alloc()")
5cad465d7fa6 ("mm: add vmf_insert_pfn_pmd()")
61031952f4c8 ("arch, x86: pmem api for ensuring durability of persistent 
memory updates")
62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
83e0abae ("staging: android: binder: move to the "real" part of the 
kernel")
957e3facd147 ("gcov: enable GCOV_PROFILE_ALL from ARCH Kconfigs")
9e853f2313e5 ("drivers/block/pmem: Add a driver for persistent memory")
9f53f9fa4ad1 ("libnvdimm, pmem: add libnvdimm support to the pmem driver")
b94d5230d06e ("libnvdimm, nfit: initial libnvdimm infrastructure and NFIT 
support")
cb389b9c0e00 ("dax: drop size parameter to ->direct_access()")
dd22f551ac0a ("block: Change direct_access calling convention")
e2e05394e4a3 ("pmem, dax: have direct_access use __pmem annotation")
ec776ef6bbe1 ("x86/mm: Add support for the non-standard protected e820 
type")
f0dc089ce217 ("libnvdimm: enable iostat")
f25748e3c34e ("mm, dax: convert vmf_insert_pfn_pmd() to pfn_t")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] mm: Fix modifying of page protection by insert_pfn_pmd()

2019-04-01 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.0.5, v4.19.32, v4.14.109, v4.9.166, 
v4.4.177, v3.18.137.

v5.0.5: Build OK!
v4.19.32: Build OK!
v4.14.109: Build OK!
v4.9.166: Failed to apply! Possible dependencies:
82b0f8c39a38 ("mm: join struct fault_env and vm_fault")
953c66c2b22a ("mm: THP page cache support for ppc64")
a00cc7d9dd93 ("mm, x86: add support for PUD-sized transparent hugepages")
b5bc66b71310 ("mm: update mmu_gather range correctly")
fd60775aea80 ("mm, thp: avoid unlikely branches for split_huge_pmd")

v4.4.177: Failed to apply! Possible dependencies:
01871e59af5c ("mm, dax: fix livelock, allow dax pmd mappings to become 
writeable")
01c8f1c44b83 ("mm, dax, gpu: convert vm_insert_mixed to pfn_t")
0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
52db400fcd50 ("pmem, dax: clean up clear_pmem()")
606b5908 ("bpf: split HAVE_BPF_JIT into cBPF and eBPF variant")
a00cc7d9dd93 ("mm, x86: add support for PUD-sized transparent hugepages")
b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with 
dax_map_atomic()")
b329f95d70f3 ("ARM: 8479/2: add implementation for arm-smccc")
e37e43a497d5 ("x86/mm/64: Enable vmapped stacks 
(CONFIG_HAVE_ARCH_VMAP_STACK=y)")
f25748e3c34e ("mm, dax: convert vmf_insert_pfn_pmd() to pfn_t")

v3.18.137: Failed to apply! Possible dependencies:
047fc8a1f9a6 ("libnvdimm, nfit, nd_blk: driver for BLK-mode access 
persistent memory")
2a3746984c98 ("x86: Use new cache mode type in track_pfn_remap() and 
track_pfn_insert()")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
4c1eaa2344fb ("drivers/block/pmem: Fix 32-bit build warning in 
pmem_alloc()")
5cad465d7fa6 ("mm: add vmf_insert_pfn_pmd()")
61031952f4c8 ("arch, x86: pmem api for ensuring durability of persistent 
memory updates")
62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and 
nvdimm devices")
83e0abae ("staging: android: binder: move to the "real" part of the 
kernel")
957e3facd147 ("gcov: enable GCOV_PROFILE_ALL from ARCH Kconfigs")
9e853f2313e5 ("drivers/block/pmem: Add a driver for persistent memory")
9f53f9fa4ad1 ("libnvdimm, pmem: add libnvdimm support to the pmem driver")
b94d5230d06e ("libnvdimm, nfit: initial libnvdimm infrastructure and NFIT 
support")
cb389b9c0e00 ("dax: drop size parameter to ->direct_access()")
dd22f551ac0a ("block: Change direct_access calling convention")
e2e05394e4a3 ("pmem, dax: have direct_access use __pmem annotation")
ec776ef6bbe1 ("x86/mm: Add support for the non-standard protected e820 
type")
f0dc089ce217 ("libnvdimm: enable iostat")
f25748e3c34e ("mm, dax: convert vmf_insert_pfn_pmd() to pfn_t")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 5.0 061/262] mm/resource: Return real error codes from walk failures

2019-03-27 Thread Sasha Levin
From: Dave Hansen 

[ Upstream commit 5cd401ace914dc68556c6d2fcae0c349444d5f86 ]

walk_system_ram_range() can return an error code either becuase
*it* failed, or because the 'func' that it calls returned an
error.  The memory hotplug does the following:

ret = walk_system_ram_range(..., func);
if (ret)
return ret;

and 'ret' makes it out to userspace, eventually.  The problem
s, walk_system_ram_range() failues that result from *it* failing
(as opposed to 'func') return -1.  That leads to a very odd
-EPERM (-1) return code out to userspace.

Make walk_system_ram_range() return -EINVAL for internal
failures to keep userspace less confused.

This return code is compatible with all the callers that I
audited.

Signed-off-by: Dave Hansen 
Reviewed-by: Bjorn Helgaas 
Acked-by: Michael Ellerman  (powerpc)
Cc: Dan Williams 
Cc: Dave Jiang 
Cc: Ross Zwisler 
Cc: Vishal Verma 
Cc: Tom Lendacky 
Cc: Andrew Morton 
Cc: Michal Hocko 
Cc: linux-nvdimm@lists.01.org
Cc: linux-ker...@vger.kernel.org
Cc: linux...@kvack.org
Cc: Huang Ying 
Cc: Fengguang Wu 
Cc: Borislav Petkov 
Cc: Yaowei Bai 
Cc: Takashi Iwai 
Cc: Jerome Glisse 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: linuxppc-...@lists.ozlabs.org
Cc: Keith Busch 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 kernel/resource.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 915c02e8e5dd..ca7ed5158cff 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -382,7 +382,7 @@ static int __walk_iomem_res_desc(resource_size_t start, 
resource_size_t end,
 int (*func)(struct resource *, void *))
 {
struct resource res;
-   int ret = -1;
+   int ret = -EINVAL;
 
while (start < end &&
   !find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) {
@@ -462,7 +462,7 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned 
long nr_pages,
unsigned long flags;
struct resource res;
unsigned long pfn, end_pfn;
-   int ret = -1;
+   int ret = -EINVAL;
 
start = (u64) start_pfn << PAGE_SHIFT;
end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
-- 
2.19.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH 2/7] libnvdimm/pmem: Honor force_raw for legacy pmem regions

2019-02-18 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 004f1afbe199 libnvdimm, pmem: direct map legacy pmem by default.

The bot has tested the following trees: v4.20.8, v4.19.21, v4.14.99, v4.9.156, 
v4.4.174.

v4.20.8: Build OK!
v4.19.21: Build OK!
v4.14.99: Build OK!
v4.9.156: Build OK!
v4.4.174: Failed to apply! Possible dependencies:
0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
4b94ffdc4163 ("x86, mm: introduce vmem_altmap to augment 
vmemmap_populate()")
52db400fcd50 ("pmem, dax: clean up clear_pmem()")
87ba05dff351 ("libnvdimm: don't fail init for full badblocks list")
9476df7d80df ("mm: introduce find_dev_pagemap()")
ad9a8bde2cb1 ("libnvdimm, pmem: move definition of 
nvdimm_namespace_add_poison to nd.h")
b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with 
dax_map_atomic()")
b95f5f4391fa ("libnvdimm: convert to statically allocated badblocks")
cfe30b872058 ("libnvdimm, pmem: adjust for section collisions with 'System 
RAM'")
d2c0f041e1bb ("libnvdimm, pfn, pmem: allocate memmap array in persistent 
memory")
d9cbe09d39aa ("libnvdimm, pmem: fix 'pfn' support for section-misaligned 
namespaces")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH 2/7] libnvdimm/pmem: Honor force_raw for legacy pmem regions

2019-02-15 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 004f1afbe199 libnvdimm, pmem: direct map legacy pmem by default.

The bot has tested the following trees: v4.20.8, v4.19.21, v4.14.99, v4.9.156, 
v4.4.174.

v4.20.8: Build OK!
v4.19.21: Build OK!
v4.14.99: Build OK!
v4.9.156: Build OK!
v4.4.174: Failed to apply! Possible dependencies:
0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations")
34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
4b94ffdc4163 ("x86, mm: introduce vmem_altmap to augment 
vmemmap_populate()")
52db400fcd50 ("pmem, dax: clean up clear_pmem()")
87ba05dff351 ("libnvdimm: don't fail init for full badblocks list")
9476df7d80df ("mm: introduce find_dev_pagemap()")
ad9a8bde2cb1 ("libnvdimm, pmem: move definition of 
nvdimm_namespace_add_poison to nd.h")
b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with 
dax_map_atomic()")
b95f5f4391fa ("libnvdimm: convert to statically allocated badblocks")
cfe30b872058 ("libnvdimm, pmem: adjust for section collisions with 'System 
RAM'")
d2c0f041e1bb ("libnvdimm, pfn, pmem: allocate memmap array in persistent 
memory")
d9cbe09d39aa ("libnvdimm, pmem: fix 'pfn' support for section-misaligned 
namespaces")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 44/83] acpi/nfit: Fix race accessing memdev in nfit_get_smbios_id()

2019-02-12 Thread Sasha Levin
From: Tony Luck 

[ Upstream commit 0919871ac37fdcf46c7657da0f1742efe096b399 ]

Possible race accessing memdev structures after dropping the
mutex. Dan Williams says this could race against another thread
that is doing:

 # echo "ACPI0012:00" > /sys/bus/acpi/drivers/nfit/unbind

Reported-by: Jane Chu 
Fixes: 23222f8f8dce ("acpi, nfit: Add function to look up nvdimm...")
Signed-off-by: Tony Luck 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index ea59c01ce8db..f530d3541242 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -719,6 +719,7 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags)
struct acpi_nfit_memory_map *memdev;
struct acpi_nfit_desc *acpi_desc;
struct nfit_mem *nfit_mem;
+   u16 physical_id;
 
mutex_lock(&acpi_desc_lock);
list_for_each_entry(acpi_desc, &acpi_descs, list) {
@@ -726,10 +727,11 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags)
list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) {
memdev = __to_nfit_memdev(nfit_mem);
if (memdev->device_handle == device_handle) {
+   *flags = memdev->flags;
+   physical_id = memdev->physical_id;
mutex_unlock(&acpi_desc->init_mutex);
mutex_unlock(&acpi_desc_lock);
-   *flags = memdev->flags;
-   return memdev->physical_id;
+   return physical_id;
}
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.19.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.20 052/105] acpi/nfit: Fix race accessing memdev in nfit_get_smbios_id()

2019-02-12 Thread Sasha Levin
From: Tony Luck 

[ Upstream commit 0919871ac37fdcf46c7657da0f1742efe096b399 ]

Possible race accessing memdev structures after dropping the
mutex. Dan Williams says this could race against another thread
that is doing:

 # echo "ACPI0012:00" > /sys/bus/acpi/drivers/nfit/unbind

Reported-by: Jane Chu 
Fixes: 23222f8f8dce ("acpi, nfit: Add function to look up nvdimm...")
Signed-off-by: Tony Luck 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 8535e7999769..2a2d7ec77252 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -724,6 +724,7 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags)
struct acpi_nfit_memory_map *memdev;
struct acpi_nfit_desc *acpi_desc;
struct nfit_mem *nfit_mem;
+   u16 physical_id;
 
mutex_lock(&acpi_desc_lock);
list_for_each_entry(acpi_desc, &acpi_descs, list) {
@@ -731,10 +732,11 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags)
list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) {
memdev = __to_nfit_memdev(nfit_mem);
if (memdev->device_handle == device_handle) {
+   *flags = memdev->flags;
+   physical_id = memdev->physical_id;
mutex_unlock(&acpi_desc->init_mutex);
mutex_unlock(&acpi_desc_lock);
-   *flags = memdev->flags;
-   return memdev->physical_id;
+   return physical_id;
}
}
mutex_unlock(&acpi_desc->init_mutex);
-- 
2.19.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] acpi/nfit: Fix bus command validation

2019-02-11 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 11189c1089da acpi/nfit: Fix command-supported detection.

The bot has tested the following trees: v4.20.7, v4.19.20, v4.14.98, v4.9.155.

v4.20.7: Build OK!
v4.19.20: Build OK!
v4.14.98: Build failed! Errors:
drivers/acpi/nfit/core.c:261:21: error: ‘nfit_mem’ undeclared (first 
use in this function)

v4.9.155: Failed to apply! Possible dependencies:
37d74841b9d4 ("acpi, nfit: Enable DSM pass thru for root functions.")
7db5bb33add5 ("libnvdimm, acpi, nfit: Add bus level dsm mask for pass 
thru.")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v4] acpi/nfit: Fix command-supported detection

2019-01-22 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 31eca76ba2fc nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism.

The bot has tested the following trees: v4.20.3, v4.19.16, v4.14.94, v4.9.151.

v4.20.3: Failed to apply! Possible dependencies:
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")

v4.19.16: Failed to apply! Possible dependencies:
0ead11181fe0 ("acpi, nfit: Collect shutdown status")
6f07f86c4940 ("acpi, nfit: Introduce nfit_mem flags")
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")

v4.14.94: Build OK!
v4.9.151: Failed to apply! Possible dependencies:
0f817ae696b0 ("usb: dwc3: pci: add a private driver structure")
11e142701609 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
23222f8f8dce ("acpi, nfit: Add function to look up nvdimm device and 
provide SMBIOS handle")
36daf3aa399c ("usb: dwc3: pci: avoid build warning")
3f23df72dc35 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10 ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64 ("libnvdimm: allow a platform to force enable label support")
42b06496407c ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cd ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
8f078b38dd38 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0 ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed965118 ("libnvdimm: handle locked label storage areas")
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b7fe92999a98 ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c10 ("net: hns: Add ACPI support to check SFP present")
c959a6b00ff5 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel 
devices")
d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
fab9288428ec ("usb: USB Type-C connector class")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v4] acpi/nfit: Fix command-supported detection

2019-01-22 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 31eca76ba2fc nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism.

The bot has tested the following trees: v4.20.3, v4.19.16, v4.14.94, v4.9.151.

v4.20.3: Failed to apply! Possible dependencies:
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")

v4.19.16: Failed to apply! Possible dependencies:
0ead11181fe0 ("acpi, nfit: Collect shutdown status")
6f07f86c4940 ("acpi, nfit: Introduce nfit_mem flags")
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")

v4.14.94: Build OK!
v4.9.151: Failed to apply! Possible dependencies:
0f817ae696b0 ("usb: dwc3: pci: add a private driver structure")
11e142701609 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
23222f8f8dce ("acpi, nfit: Add function to look up nvdimm device and 
provide SMBIOS handle")
36daf3aa399c ("usb: dwc3: pci: avoid build warning")
3f23df72dc35 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10 ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64 ("libnvdimm: allow a platform to force enable label support")
42b06496407c ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cd ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
8f078b38dd38 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0 ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed965118 ("libnvdimm: handle locked label storage areas")
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b7fe92999a98 ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c10 ("net: hns: Add ACPI support to check SFP present")
c959a6b00ff5 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel 
devices")
d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
fab9288428ec ("usb: USB Type-C connector class")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] libnvdimm/label: Clear 'updating' flag after label-set update

2019-01-18 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: f524bf271a5c libnvdimm: write pmem label set.

The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150, 
v4.4.170.

v4.20.2: Build OK!
v4.19.15: Build OK!
v4.14.93: Build OK!
v4.9.150: Build OK!
v4.4.170: Failed to apply! Possible dependencies:
0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
16660eaea0cc ("libnvdimm, namespace: update label implementation for 
multi-pmem")
1cf03c00e7c1 ("nfit: scrub and register regions in a workqueue")
31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command marshaling 
mechanism")
44c462eb9e19 ("libnvdimm, region: move region-mapping input-paramters to 
nd_mapping_desc")
4577b0665515 ("nfit: update address range scrub commands to the acpi 6.1 
format")
6e2452dff444 ("nfit: Continue init even if ARS commands are unimplemented")
747ffe11b440 ("libnvdimm, tools/testing/nvdimm: fix 'ars_status' output 
buffer sizing")
7ae0fa439faf ("nfit, libnvdimm: async region scrub workqueue")
a61fe6f7902e ("nfit, tools/testing/nvdimm: unify common init for 
acpi_nfit_desc")
ad9ac5e19575 ("nfit: always associate flush hints")
ae8219f186d8 ("libnvdimm, label: convert label tracking to a linked list")
aef253382266 ("libnvdimm, nfit: centralize command status translation")
d26f73f083ed ("nfit_test: Enable DSMs for all test NFITs")
e3654eca70d6 ("nfit, libnvdimm: clarify "commands" vs "_DSMs"")
e5ae3b252c67 ("libnvdimm, nfit: move flush hint mapping to region-device 
driver-data")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] libnvdimm/label: Clear 'updating' flag after label-set update

2019-01-18 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: f524bf271a5c libnvdimm: write pmem label set.

The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150, 
v4.4.170.

v4.20.2: Build OK!
v4.19.15: Build OK!
v4.14.93: Build failed! Errors:

v4.9.150: Build OK!
v4.4.170: Failed to apply! Possible dependencies:
0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
16660eaea0cc ("libnvdimm, namespace: update label implementation for 
multi-pmem")
1cf03c00e7c1 ("nfit: scrub and register regions in a workqueue")
31eca76ba2fc ("nfit, libnvdimm: limited/whitelisted dimm command marshaling 
mechanism")
44c462eb9e19 ("libnvdimm, region: move region-mapping input-paramters to 
nd_mapping_desc")
4577b0665515 ("nfit: update address range scrub commands to the acpi 6.1 
format")
6e2452dff444 ("nfit: Continue init even if ARS commands are unimplemented")
747ffe11b440 ("libnvdimm, tools/testing/nvdimm: fix 'ars_status' output 
buffer sizing")
7ae0fa439faf ("nfit, libnvdimm: async region scrub workqueue")
a61fe6f7902e ("nfit, tools/testing/nvdimm: unify common init for 
acpi_nfit_desc")
ad9ac5e19575 ("nfit: always associate flush hints")
ae8219f186d8 ("libnvdimm, label: convert label tracking to a linked list")
aef253382266 ("libnvdimm, nfit: centralize command status translation")
d26f73f083ed ("nfit_test: Enable DSMs for all test NFITs")
e3654eca70d6 ("nfit, libnvdimm: clarify "commands" vs "_DSMs"")
e5ae3b252c67 ("libnvdimm, nfit: move flush hint mapping to region-device 
driver-data")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH v2 1/2] acpi/nfit: Block function zero DSMs

2019-01-18 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: e02fb7264d8a nfit: add Microsoft NVDIMM DSM command set to white 
list.

The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150.

v4.20.2: Build OK!
v4.19.15: Build OK!
v4.14.93: Build OK!
v4.9.150: Failed to apply! Possible dependencies:
41c8bdb3ab10 ("acpi, nfit: Switch to use new generic UUID API")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] acpi/nfit: Fix command-supported detection

2019-01-16 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 31eca76ba2fc nfit, libnvdimm: limited/whitelisted dimm command 
marshaling mechanism.

The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150.

v4.20.2: Failed to apply! Possible dependencies:
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")

v4.19.15: Failed to apply! Possible dependencies:
0ead11181fe0 ("acpi, nfit: Collect shutdown status")
6f07f86c4940 ("acpi, nfit: Introduce nfit_mem flags")
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")

v4.14.93: Build OK!
v4.9.150: Failed to apply! Possible dependencies:
0f817ae696b0 ("usb: dwc3: pci: add a private driver structure")
11e142701609 ("acpi, nfit: add support for NVDIMM_FAMILY_INTEL v1.6 DSMs")
23222f8f8dce ("acpi, nfit: Add function to look up nvdimm device and 
provide SMBIOS handle")
36daf3aa399c ("usb: dwc3: pci: avoid build warning")
3f23df72dc35 ("mmc: sdhci-pci: Use ACPI to get max frequency for Intel NI 
byt sdio")
41c8bdb3ab10 ("acpi, nfit: Switch to use new generic UUID API")
42237e393f64 ("libnvdimm: allow a platform to force enable label support")
42b06496407c ("mmc: sdhci-pci: Add PCI ID for Intel NI byt sdio")
4b27db7e26cd ("acpi, nfit: add support for the _LSI, _LSR, and _LSW label 
methods")
8f078b38dd38 ("libnvdimm: convert NDD_ flags to use bitops, introduce 
NDD_LOCKED")
94116f8126de ("ACPI: Switch to use generic guid_t in acpi_evaluate_dsm()")
9cecca75b5a0 ("usb: dwc3: pci: call _DSM for suspend/resume")
9d62ed965118 ("libnvdimm: handle locked label storage areas")
b3ed2ce024c3 ("acpi/nfit: Add support for Intel DSM 1.8 commands")
b7fe92999a98 ("ACPI / extlog: Switch to use new generic UUID API")
b917078c1c10 ("net: hns: Add ACPI support to check SFP present")
c959a6b00ff5 ("mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel 
devices")
d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB 
Type-C PHY")
fab9288428ec ("usb: USB Type-C connector class")


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: FAILED: patch "[PATCH] dax: Don't access a freed inode" failed to apply to 4.19-stable tree

2018-12-22 Thread Sasha Levin

On Fri, Dec 21, 2018 at 12:31:02PM -0800, Dan Williams wrote:

On Thu, Dec 13, 2018 at 11:14 PM Greg KH  wrote:


On Tue, Dec 11, 2018 at 07:23:49AM -0800, Matthew Wilcox wrote:
> On Tue, Dec 11, 2018 at 03:00:09PM +0100, gre...@linuxfoundation.org wrote:
> >
> > The patch below does not apply to the 4.19-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to .
>
> I have only compile-tested this backport.  Dan, do you want to run it
> through some tests before Greg applies it?

Thanks for the backport, I'll wait to hear from Dan before queueing this
up.


Tested-by: Dan Williams 

However, on the upstream version of this fix Linus pointed out an
additional fixup. Once that goes upstream [1] I'll circle back to
provide a fixed up version of this backport to keep -stable and
mainline more aligned.

[1]: https://marc.info/?l=linux-fsdevel&m=154542184202064&w=2


Okay, I guess it makes sense to wait for the fixup before we pull this
backport in?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


[PATCH AUTOSEL 4.19 61/73] acpi/nfit: Fix user-initiated ARS to be "ARS-long" rather than "ARS-short"

2018-12-12 Thread Sasha Levin
From: Dan Williams 

[ Upstream commit b5fd2e00a60248902315fb32210550ac3cb9f44c ]

A "short" ARS (address range scrub) instructs the platform firmware to
return known errors. In contrast, a "long" ARS instructs platform
firmware to arrange every data address on the DIMM to be read / checked
for poisoned data.

The conversion of the flags in commit d3abaf43bab8 "acpi, nfit: Fix
Address Range Scrub completion tracking", changed the meaning of passing
'0' to acpi_nfit_ars_rescan(). Previously '0' meant "not short", now '0'
is ARS_REQ_SHORT. Pass ARS_REQ_LONG to restore the expected scrub-type
behavior of user-initiated ARS sessions.

Fixes: d3abaf43bab8 ("acpi, nfit: Fix Address Range Scrub completion tracking")
Reported-by: Jacek Zloch 
Cc: Vishal Verma 
Reviewed-by: Dave Jiang 
Reviewed-by: Vishal Verma 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/acpi/nfit/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index c5d15752dfb3..75b331f8a16a 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1303,7 +1303,7 @@ static ssize_t scrub_store(struct device *dev,
if (nd_desc) {
struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);
 
-   rc = acpi_nfit_ars_rescan(acpi_desc, 0);
+   rc = acpi_nfit_ars_rescan(acpi_desc, ARS_REQ_LONG);
}
device_unlock(dev);
if (rc)
-- 
2.19.1

___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH 2/2] libnvdimm, pfn: Pad pfn namespaces relative to other regions

2018-11-24 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: cfe30b872058 libnvdimm, pmem: adjust for section collisions with 
'System RAM'.

The bot has tested the following trees: v4.19.4, v4.14.83, v4.9.140.

v4.19.4: Build OK!
v4.14.83: Build OK!
v4.9.140: Failed to apply! Possible dependencies:
Unable to calculate


How should we proceed with this patch?

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH 1/6] nfit: fix region registration vs block-data-window ranges

2018-04-06 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 1cf03c00e7c1 nfit: scrub and register regions in a workqueue.

The bot has also determined it's probably a bug fixing patch. (score: 80.4079)

The bot has tested the following trees: v4.16, v4.15.15, v4.14.32, v4.9.92.

v4.16: Build OK!
v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!

--
Thanks,
Sasha
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


  1   2   >