Skip to contentSkip to conversation

ACPI/nfit: correct the badrange to be reported in nfit_handle_mce()

PATCH In review Zhen Lei 3 participants 7 messages Nov 18, 2020 – Nov 19, 2020

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 ACPI/nfit: correct the badrange to be reported in nfit_handle_mce()

The badrange to be reported should always cover mce->addr.

---
 drivers/acpi/nfit/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/nfit/mce.c +1 -1
index ee8d9973f60b..053e719c7bea 100644
@@ -63,7 +63,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
 
 		/* If this fails due to an -ENOMEM, there is little we can do */
 		nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus,
-				ALIGN(mce->addr, L1_CACHE_BYTES),
+				ALIGN_DOWN(mce->addr, L1_CACHE_BYTES),
 				L1_CACHE_BYTES);
 		nvdimm_region_notify(nfit_spa->nd_region,
 				NVDIMM_REVALIDATE_POISON);
Signature · 5 lines
2.26.0.106.g9fadedd

_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#1 lore raw
Quoted 1 line · Zhen Lei

The badrange to be reported should always cover mce->addr.

Maybe I should change this description to:
Make sure the badrange to be reported can always cover mce->addr.

Quoted 20 lines
---
 drivers/acpi/nfit/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/nfit/mce.c +1 -1
index ee8d9973f60b..053e719c7bea 100644
@@ -63,7 +63,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
 
 		/* If this fails due to an -ENOMEM, there is little we can do */
 		nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus,
-				ALIGN(mce->addr, L1_CACHE_BYTES),
+				ALIGN_DOWN(mce->addr, L1_CACHE_BYTES),
 				L1_CACHE_BYTES);
 		nvdimm_region_notify(nfit_spa->nd_region,
 				NVDIMM_REVALIDATE_POISON);
#2 lore raw
Quoted 7 lines · Leizhen (ThunderTown)
Quoted 1 line · Zhen Lei

The badrange to be reported should always cover mce->addr.

Maybe I should change this description to:
Make sure the badrange to be reported can always cover mce->addr.

Yes, I like that better. Can you also say a bit more about how you found this bug? As far as I can see this looks like -stable material.

#3 lore raw
Quoted 5 lines · Dan Williams
Quoted 3 lines · Leizhen (ThunderTown)
Quoted 7 lines
Quoted 4 lines · Zhen Lei
Quoted 1 line

The badrange to be reported should always cover mce->addr.

Maybe I should change this description to:
Make sure the badrange to be reported can always cover mce->addr.

Yes, I like that better. Can you also say a bit more about how you found this bug? As far as I can see this looks like -stable material.

I found it when I was learning the code. I'm looking at it carefully.

Quoted 2 lines
#4 lore raw
Quoted 10 lines · Leizhen (ThunderTown)
Quoted 6 lines · Dan Williams
Quoted 4 lines · Leizhen (ThunderTown)

On 2020/11/18 16:41, Zhen Lei wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

The badrange to be reported should always cover mce->addr.

Maybe I should change this description to:
Make sure the badrange to be reported can always cover mce->addr.

Yes, I like that better. Can you also say a bit more about how you found this bug? As far as I can see this looks like -stable material.

I found it when I was learning the code. I'm looking at it carefully.

Ok, good eye.

The impact of this one is somewhat mitigated by the fact that errors are expanded to 512 byte blast radius, and error consumption maps 4k around errors. I suspect few are trying to use the badblock list to do fine grained recovery so this bug went unnoticed.
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

maintainer Reviewed-by on v1 1/1
#5 lore raw
In reply to Zhen Lei
Quoted 6 lines · Zhen Lei

The badrange to be reported should always cover mce->addr.

---
 drivers/acpi/nfit/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Ah good find, agreed with Dan that this is stable material. Minor nit, I'd recommend rewording the subject line to something like:

"acpi/nfit: fix badrange insertion in nfit_handle_mce()"

Otherwise, looks good to me.

Quoted 6 lines
drivers/acpi/nfit/mce.c +0 -0
index ee8d9973f60b..053e719c7bea 100644

drivers/acpi/nfit/mce.c static int nfit_handle_mce(struct notifier_block *nb, unsigned long val, · line 69

Quoted 8 lines
drivers/acpi/nfit/mce.c +1 -1
@@ -63,7 +63,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
 
 		/* If this fails due to an -ENOMEM, there is little we can do */
 		nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus,
-				ALIGN(mce->addr, L1_CACHE_BYTES),
+				ALIGN_DOWN(mce->addr, L1_CACHE_BYTES),
 				L1_CACHE_BYTES);
 		nvdimm_region_notify(nfit_spa->nd_region,
 				NVDIMM_REVALIDATE_POISON);

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

#6 lore raw
Quoted 8 lines · Vishal L
Quoted 6 lines · Zhen Lei

The badrange to be reported should always cover mce->addr.

---
 drivers/acpi/nfit/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

Ah good find, agreed with Dan that this is stable material. Minor nit, I'd recommend rewording the subject line to something like:

"acpi/nfit: fix badrange insertion in nfit_handle_mce()"

OK, I will send v2.

Quoted 19 lines

Otherwise, looks good to me.

Quoted 14 lines
drivers/acpi/nfit/mce.c +1 -1
index ee8d9973f60b..053e719c7bea 100644
@@ -63,7 +63,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
 
 		/* If this fails due to an -ENOMEM, there is little we can do */
 		nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus,
-				ALIGN(mce->addr, L1_CACHE_BYTES),
+				ALIGN_DOWN(mce->addr, L1_CACHE_BYTES),
 				L1_CACHE_BYTES);
 		nvdimm_region_notify(nfit_spa->nd_region,
 				NVDIMM_REVALIDATE_POISON);