Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.
This was found by code audit.
Cc: stable@vger.kernel.org Signed-off-by: Aneesh Kumar K.V aneesh.kumar@linux.ibm.com --- arch/powerpc/include/asm/drmem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h index 17ccc6474ab6..d719cbac34b2 100644 --- a/arch/powerpc/include/asm/drmem.h +++ b/arch/powerpc/include/asm/drmem.h @@ -21,7 +21,7 @@ struct drmem_lmb { struct drmem_lmb_info { struct drmem_lmb *lmbs; int n_lmbs; - u32 lmb_size; + u64 lmb_size; };
extern struct drmem_lmb_info *drmem_info; @@ -67,7 +67,7 @@ struct of_drconf_cell_v2 { #define DRCONF_MEM_RESERVED 0x00000080 #define DRCONF_MEM_HOTREMOVABLE 0x00000100
-static inline u32 drmem_lmb_size(void) +static inline u64 drmem_lmb_size(void) { return drmem_info->lmb_size; }
Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.
This was found by code audit.
Cc: stable@vger.kernel.org Signed-off-by: Aneesh Kumar K.V aneesh.kumar@linux.ibm.com --- .../platforms/pseries/hotplug-memory.c | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 5d545b78111f..1fe3204c843a 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -277,7 +277,7 @@ static int dlpar_offline_lmb(struct drmem_lmb *lmb) return dlpar_change_lmb_state(lmb, false); }
-static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size) +static int pseries_remove_memblock(unsigned long base, unsigned long memblock_size) { unsigned long block_sz, start_pfn; int sections_per_block; @@ -308,9 +308,9 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
static int pseries_remove_mem_node(struct device_node *np) { - const __be32 *regs; + const __be32 *prop; unsigned long base; - unsigned int lmb_size; + unsigned long lmb_size; int ret = -EINVAL;
/* @@ -322,12 +322,16 @@ static int pseries_remove_mem_node(struct device_node *np) /* * Find the base address and size of the memblock */ - regs = of_get_property(np, "reg", NULL); - if (!regs) + prop = of_get_property(np, "reg", NULL); + if (!prop) return ret;
- base = be64_to_cpu(*(unsigned long *)regs); - lmb_size = be32_to_cpu(regs[3]); + /* + * "reg" property represents (addr,size) tuple. + */ + base = of_read_number(prop, mem_addr_cells); + prop += mem_addr_cells; + lmb_size = of_read_number(prop, mem_size_cells);
pseries_remove_memblock(base, lmb_size); return 0; @@ -557,7 +561,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
#else static inline int pseries_remove_memblock(unsigned long base, - unsigned int memblock_size) + unsigned long memblock_size) { return -EOPNOTSUPP; } @@ -878,9 +882,9 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
static int pseries_add_mem_node(struct device_node *np) { - const __be32 *regs; + const __be32 *prop; unsigned long base; - unsigned int lmb_size; + unsigned long lmb_size; int ret = -EINVAL;
/* @@ -892,12 +896,15 @@ static int pseries_add_mem_node(struct device_node *np) /* * Find the base and size of the memblock */ - regs = of_get_property(np, "reg", NULL); - if (!regs) + prop = of_get_property(np, "reg", NULL); + if (!prop) return ret; - - base = be64_to_cpu(*(unsigned long *)regs); - lmb_size = be32_to_cpu(regs[3]); + /* + * "reg" property represents (addr,size) tuple. + */ + base = of_read_number(prop, mem_addr_cells); + prop += mem_addr_cells; + lmb_size = of_read_number(prop, mem_size_cells);
/* * Update memory region to represent the memory add
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.8, v5.7.14, v5.4.57, v4.19.138, v4.14.193, v4.9.232, v4.4.232.
v5.8: Build OK! v5.7.14: Build OK! v5.4.57: Build OK! v4.19.138: Failed to apply! Possible dependencies: Unable to calculate
v4.14.193: Failed to apply! Possible dependencies: Unable to calculate
v4.9.232: Failed to apply! Possible dependencies: 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n")
v4.4.232: Failed to apply! Possible dependencies: 183deeea5871 ("powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c") 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 1dc759566636 ("powerpc/pseries: Use kernel hotplug queue for PowerVM hotplug events") 1f859adb9253 ("powerpc/pseries: Verify CPU doesn't exist before adding") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 4a4bdfea7cb7 ("powerpc/pseries: Refactor dlpar_add_lmb() code") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 9054619ef54a ("powerpc/pseries: Add pseries hotplug workqueue") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") 9dc512819e4b ("powerpc: Fix unused function warning 'lmb_to_memblock'") bdf5fc633804 ("powerpc/pseries: Update LMB associativity index during DLPAR add/remove") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") e9d764f80396 ("powerpc/pseries: Enable kernel CPU dlpar from sysfs") ec999072442a ("powerpc/pseries: Auto-online hotplugged memory") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n") fdb4f6e99ffa ("powerpc/pseries: Remove call to memblock_add()")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
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.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.
v5.8.1: Build OK! v5.7.15: Build OK! v5.4.58: Build OK! v4.19.139: Failed to apply! Possible dependencies: Unable to calculate
v4.14.193: Failed to apply! Possible dependencies: Unable to calculate
v4.9.232: Failed to apply! Possible dependencies: 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n")
v4.4.232: Failed to apply! Possible dependencies: 183deeea5871 ("powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c") 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 1dc759566636 ("powerpc/pseries: Use kernel hotplug queue for PowerVM hotplug events") 1f859adb9253 ("powerpc/pseries: Verify CPU doesn't exist before adding") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 4a4bdfea7cb7 ("powerpc/pseries: Refactor dlpar_add_lmb() code") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 9054619ef54a ("powerpc/pseries: Add pseries hotplug workqueue") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") 9dc512819e4b ("powerpc: Fix unused function warning 'lmb_to_memblock'") bdf5fc633804 ("powerpc/pseries: Update LMB associativity index during DLPAR add/remove") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") e9d764f80396 ("powerpc/pseries: Enable kernel CPU dlpar from sysfs") ec999072442a ("powerpc/pseries: Auto-online hotplugged memory") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n") fdb4f6e99ffa ("powerpc/pseries: Remove call to memblock_add()")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
"Aneesh Kumar K.V" aneesh.kumar@linux.ibm.com writes:
@@ -322,12 +322,16 @@ static int pseries_remove_mem_node(struct device_node *np) /* * Find the base address and size of the memblock */
- regs = of_get_property(np, "reg", NULL);
- if (!regs)
- prop = of_get_property(np, "reg", NULL);
- if (!prop) return ret;
- base = be64_to_cpu(*(unsigned long *)regs);
- lmb_size = be32_to_cpu(regs[3]);
- /*
* "reg" property represents (addr,size) tuple.
*/
- base = of_read_number(prop, mem_addr_cells);
- prop += mem_addr_cells;
- lmb_size = of_read_number(prop, mem_size_cells);
Would of_n_size_cells() and of_n_addr_cells() work here?
Nathan Lynch nathanl@linux.ibm.com writes:
"Aneesh Kumar K.V" aneesh.kumar@linux.ibm.com writes:
@@ -322,12 +322,16 @@ static int pseries_remove_mem_node(struct device_node *np) /* * Find the base address and size of the memblock */
- regs = of_get_property(np, "reg", NULL);
- if (!regs)
- prop = of_get_property(np, "reg", NULL);
- if (!prop) return ret;
- base = be64_to_cpu(*(unsigned long *)regs);
- lmb_size = be32_to_cpu(regs[3]);
- /*
* "reg" property represents (addr,size) tuple.
*/
- base = of_read_number(prop, mem_addr_cells);
- prop += mem_addr_cells;
- lmb_size = of_read_number(prop, mem_size_cells);
Would of_n_size_cells() and of_n_addr_cells() work here?
Yes that should work and be cleaner.
cheers
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.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.
v5.8.2: Build OK! v5.7.16: Build OK! v5.4.59: Build OK! v4.19.140: Failed to apply! Possible dependencies: Unable to calculate
v4.14.193: Failed to apply! Possible dependencies: Unable to calculate
v4.9.232: Failed to apply! Possible dependencies: 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n")
v4.4.232: Failed to apply! Possible dependencies: 183deeea5871 ("powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c") 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 1dc759566636 ("powerpc/pseries: Use kernel hotplug queue for PowerVM hotplug events") 1f859adb9253 ("powerpc/pseries: Verify CPU doesn't exist before adding") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 4a4bdfea7cb7 ("powerpc/pseries: Refactor dlpar_add_lmb() code") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 9054619ef54a ("powerpc/pseries: Add pseries hotplug workqueue") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") 9dc512819e4b ("powerpc: Fix unused function warning 'lmb_to_memblock'") bdf5fc633804 ("powerpc/pseries: Update LMB associativity index during DLPAR add/remove") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") e9d764f80396 ("powerpc/pseries: Enable kernel CPU dlpar from sysfs") ec999072442a ("powerpc/pseries: Auto-online hotplugged memory") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n") fdb4f6e99ffa ("powerpc/pseries: Remove call to memblock_add()")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
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.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.
v5.8.1: Build OK! v5.7.15: Build OK! v5.4.58: Build OK! v4.19.139: Build OK! v4.14.193: Failed to apply! Possible dependencies: 22508f3dc985 ("powerpc/numa: Look up device node in of_get_usable_memory()") 2c77721552e5 ("powerpc: Move of_drconf_cell struct to asm/drmem.h") 35f80debaef0 ("powerpc/numa: Look up device node in of_get_assoc_arrays()") 514a9cb3316a ("powerpc/numa: Update numa code use walk_drmem_lmbs") 6195a5001f1d ("powerpc/pseries: Update memory hotplug code to use drmem LMB array") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") b6eca183e23e ("powerpc/kernel: Enables memory hot-remove after reboot on pseries guests") b88fc309d6ad ("powerpc/numa: Look up associativity array in of_drconf_to_nid_single")
v4.9.232: Failed to apply! Possible dependencies: 3a2df3798d4d ("powerpc/mm: Make switch_mm_irqs_off() out of line") 43ed84a891b7 ("powerpc/mm: Move pgdir setting into a helper") 5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d451a87e5eb ("powerpc/64: Retrieve number of L1 cache sets from device-tree") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") 70cd4c10b290 ("KVM: PPC: Book3S HV: Fix software walk of guest process page tables") 9b081e10805c ("powerpc: port 64 bits pgtable_cache to 32 bits") a25bd72badfa ("powerpc/mm/radix: Workaround prefetch issue with KVM") bd067f83b084 ("powerpc/64: Fix naming of cache block vs. cache line") dbcbfee0c81c ("powerpc/64: More definitions for POWER9") e2827fe5c156 ("powerpc/64: Clean up ppc64_caches using a struct per cache") f4329f2ecb14 ("powerpc/64s: Reduce exception alignment")
v4.4.232: Failed to apply! Possible dependencies: 11a6f6abd74a ("powerpc/mm: Move radix/hash common data structures to book3s64 headers") 26b6a3d9bb48 ("powerpc/mm: move pte headers to book3s directory") 3808a88985b4 ("powerpc: Move FW feature probing out of pseries probe()") 3dfcb315d81e ("powerpc/mm: make a separate copy for book3s") 5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d31a96e6c01 ("powerpc/livepatch: Add livepatch stack to struct thread_info") 6574ba950bbe ("powerpc/kernel: Convert cpu_has_feature() to returning bool") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") a141cca3892b ("powerpc/mm: Add early_[cpu|mmu]_has_feature()") a8ed87c92adf ("powerpc/mm/radix: Add MMU_FTR_RADIX") b92a226e5284 ("powerpc: Move cpu_has_feature() to a separate file") da6a97bf12d5 ("powerpc: Move epapr_paravirt_early_init() to early_init_devtree()") f63e6d898760 ("powerpc/livepatch: Add livepatch header")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
"Aneesh Kumar K.V" aneesh.kumar@linux.ibm.com writes:
Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.
This was found by code audit.
Cc: stable@vger.kernel.org Signed-off-by: Aneesh Kumar K.V aneesh.kumar@linux.ibm.com
arch/powerpc/include/asm/drmem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h index 17ccc6474ab6..d719cbac34b2 100644 --- a/arch/powerpc/include/asm/drmem.h +++ b/arch/powerpc/include/asm/drmem.h @@ -21,7 +21,7 @@ struct drmem_lmb { struct drmem_lmb_info { struct drmem_lmb *lmbs; int n_lmbs;
- u32 lmb_size;
- u64 lmb_size;
}; extern struct drmem_lmb_info *drmem_info; @@ -67,7 +67,7 @@ struct of_drconf_cell_v2 { #define DRCONF_MEM_RESERVED 0x00000080 #define DRCONF_MEM_HOTREMOVABLE 0x00000100 -static inline u32 drmem_lmb_size(void) +static inline u64 drmem_lmb_size(void) { return drmem_info->lmb_size; }
Looks fine. Acked-by: Nathan Lynch nathanl@linux.ibm.com
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.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.
v5.8.2: Build OK! v5.7.16: Build OK! v5.4.59: Build OK! v4.19.140: Build OK! v4.14.193: Failed to apply! Possible dependencies: 22508f3dc985 ("powerpc/numa: Look up device node in of_get_usable_memory()") 2c77721552e5 ("powerpc: Move of_drconf_cell struct to asm/drmem.h") 35f80debaef0 ("powerpc/numa: Look up device node in of_get_assoc_arrays()") 514a9cb3316a ("powerpc/numa: Update numa code use walk_drmem_lmbs") 6195a5001f1d ("powerpc/pseries: Update memory hotplug code to use drmem LMB array") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") b6eca183e23e ("powerpc/kernel: Enables memory hot-remove after reboot on pseries guests") b88fc309d6ad ("powerpc/numa: Look up associativity array in of_drconf_to_nid_single")
v4.9.232: Failed to apply! Possible dependencies: 3a2df3798d4d ("powerpc/mm: Make switch_mm_irqs_off() out of line") 43ed84a891b7 ("powerpc/mm: Move pgdir setting into a helper") 5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d451a87e5eb ("powerpc/64: Retrieve number of L1 cache sets from device-tree") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") 70cd4c10b290 ("KVM: PPC: Book3S HV: Fix software walk of guest process page tables") 9b081e10805c ("powerpc: port 64 bits pgtable_cache to 32 bits") a25bd72badfa ("powerpc/mm/radix: Workaround prefetch issue with KVM") bd067f83b084 ("powerpc/64: Fix naming of cache block vs. cache line") dbcbfee0c81c ("powerpc/64: More definitions for POWER9") e2827fe5c156 ("powerpc/64: Clean up ppc64_caches using a struct per cache") f4329f2ecb14 ("powerpc/64s: Reduce exception alignment")
v4.4.232: Failed to apply! Possible dependencies: 11a6f6abd74a ("powerpc/mm: Move radix/hash common data structures to book3s64 headers") 26b6a3d9bb48 ("powerpc/mm: move pte headers to book3s directory") 3808a88985b4 ("powerpc: Move FW feature probing out of pseries probe()") 3dfcb315d81e ("powerpc/mm: make a separate copy for book3s") 5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d31a96e6c01 ("powerpc/livepatch: Add livepatch stack to struct thread_info") 6574ba950bbe ("powerpc/kernel: Convert cpu_has_feature() to returning bool") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") a141cca3892b ("powerpc/mm: Add early_[cpu|mmu]_has_feature()") a8ed87c92adf ("powerpc/mm/radix: Add MMU_FTR_RADIX") b92a226e5284 ("powerpc: Move cpu_has_feature() to a separate file") da6a97bf12d5 ("powerpc: Move epapr_paravirt_early_init() to early_init_devtree()") f63e6d898760 ("powerpc/livepatch: Add livepatch header")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
linux-stable-mirror@lists.linaro.org