Skip to contentSkip to conversation

powerpc/hotplug-mem: Fix aa_index match bug for hotplug

PATCH Applied Michael Bringmann 4 participants 5 messages May 22, 2017 – Jun 1, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/hotplug-mem: Fix aa_index match bug for hotplug

When adding or removing memory, the aa_index (affinity value) for the memblock must also be converted to match the endianness of the rest of the 'ibm,dynamic-memory' property. Otherwise, subsequent retrieval of the attribute will likely lead to non-existent nodes, followed by using the default node in the code inappropriately.

---
 arch/powerpc/platforms/pseries/hotplug-memory.c |    2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/platforms/pseries/hotplug-memory.c +2 -0
index e104c71..1fb162b 100644
@@ -124,6 +124,7 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 	for (i = 0; i < num_lmbs; i++) {
 		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
 		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
+		lmbs[i].aa_index = be32_to_cpu(lmbs[i].aa_index);
 		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
 	}
 
@@ -147,6 +148,7 @@ static void dlpar_update_drconf_property(struct device_node *dn,
 	for (i = 0; i < num_lmbs; i++) {
 		lmbs[i].base_addr = cpu_to_be64(lmbs[i].base_addr);
 		lmbs[i].drc_index = cpu_to_be32(lmbs[i].drc_index);
+		lmbs[i].aa_index = cpu_to_be32(lmbs[i].aa_index);
 		lmbs[i].flags = cpu_to_be32(lmbs[i].flags);
 	}
#1 lore raw
Quoted 13 lines · Michael Bringmann

When adding or removing memory, the aa_index (affinity value) for the memblock must also be converted to match the endianness of the rest of the 'ibm,dynamic-memory' property. Otherwise, subsequent retrieval of the attribute will likely lead to non-existent nodes, followed by using the default node in the code inappropriately.

arch/powerpc/platforms/pseries/hotplug-memory.c +0 -0
index e104c71..1fb162b 100644

arch/powerpc/platforms/pseries/hotplug-memory.c static struct property *dlpar_clone_drconf_property(struct device_node *dn) · line 130

Quoted 7 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +1 -0
@@ -124,6 +124,7 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 	for (i = 0; i < num_lmbs; i++) {
 		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
 		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
+		lmbs[i].aa_index = be32_to_cpu(lmbs[i].aa_index);
 		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
 	}
 

AFAICS this code was added in commit 5f97b2a0d176 ("powerpc/pseries:
Implement memory hotplug add in the kernel").

So this should probably be marked:

Fixes 5f97b2a0d176 ("powerpc/pseries: Implement memory hotplug add in the kernel")

And it seems like a bug we'd want fixed in stable, so:

Am I right?

cheers

#2 lore raw
Quoted 28 lines · Michael Ellerman
Quoted 13 lines · Michael Bringmann

When adding or removing memory, the aa_index (affinity value) for the memblock must also be converted to match the endianness of the rest of the 'ibm,dynamic-memory' property. Otherwise, subsequent retrieval of the attribute will likely lead to non-existent nodes, followed by using the default node in the code inappropriately.

arch/powerpc/platforms/pseries/hotplug-memory.c +0 -0
index e104c71..1fb162b 100644

arch/powerpc/platforms/pseries/hotplug-memory.c static struct property *dlpar_clone_drconf_property(struct device_node *dn) · line 130

Quoted 7 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +1 -0
@@ -124,6 +124,7 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 	for (i = 0; i < num_lmbs; i++) {
 		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
 		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
+		lmbs[i].aa_index = be32_to_cpu(lmbs[i].aa_index);
 		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
 	}
 

AFAICS this code was added in commit 5f97b2a0d176 ("powerpc/pseries:
Implement memory hotplug add in the kernel").

So this should probably be marked:

Quoted 8 lines
Fixes 5f97b2a0d176 ("powerpc/pseries: Implement memory hotplug add in the kernel")

And it seems like a bug we'd want fixed in stable, so:

Am I right?

Yes, that is correct.

-Nathan

#3 lore raw
Quoted 30 lines · Nathan Fontenot
Quoted 29 lines · Michael Ellerman
Quoted 13 lines · Michael Bringmann

When adding or removing memory, the aa_index (affinity value) for the memblock must also be converted to match the endianness of the rest of the 'ibm,dynamic-memory' property. Otherwise, subsequent retrieval of the attribute will likely lead to non-existent nodes, followed by using the default node in the code inappropriately.

arch/powerpc/platforms/pseries/hotplug-memory.c +0 -0
index e104c71..1fb162b 100644

arch/powerpc/platforms/pseries/hotplug-memory.c static struct property *dlpar_clone_drconf_property(struct device_node *dn) · line 130

Quoted 7 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +1 -0
@@ -124,6 +124,7 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 	for (i = 0; i < num_lmbs; i++) {
 		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
 		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
+		lmbs[i].aa_index = be32_to_cpu(lmbs[i].aa_index);
 		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
 	}
 

AFAICS this code was added in commit 5f97b2a0d176 ("powerpc/pseries:
Implement memory hotplug add in the kernel").

So this should probably be marked:

Fixes 5f97b2a0d176 ("powerpc/pseries: Implement memory hotplug add in the kernel")
Quoted 7 lines
Quoted 5 lines

And it seems like a bug we'd want fixed in stable, so:

Am I right?

Yes, that is correct.

Thanks.

cheers

#4 lore raw
In reply to Michael Bringmann
Quoted 7 lines · Michael Bringmann

When adding or removing memory, the aa_index (affinity value) for the memblock must also be converted to match the endianness of the rest of the 'ibm,dynamic-memory' property. Otherwise, subsequent retrieval of the attribute will likely lead to non-existent nodes, followed by using the default node in the code inappropriately.

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/dc421b200f91930c9c6a9586810ff8

cheers