aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2017-02-10 17:44:03 -0500
committerJames Hogan <james.hogan@imgtec.com>2017-02-13 13:57:34 -0500
commit4828b5f56f9596f014567ceef0e5c200fb582e13 (patch)
tree4dcad3dc8b9382b4fea9f9cdcaf53c5890822de9
parentf229454d34e000e714280e767811304e29d96bea (diff)
MIPS: Fix cacheinfo overflow
The recently added MIPS cacheinfo support used a macro populate_cache() to populate the cacheinfo structures depending on which caches are present. However the macro contains multiple statements without enclosing them in a do {} while (0) loop, so the L2 and L3 cache conditionals in populate_cache_leaves() only conditionalised the first statement in the macro. This overflows the buffer allocated by detect_cache_attributes(), resulting in boot failures under QEMU where neither the L2 or L2 caches are present. Enclose the macro statements in a do {} while (0) block to keep the whole macro inside the conditionals. Fixes: ef462f3b64e9 ("MIPS: Add cacheinfo support") Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: James Hogan <james.hogan@imgtec.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Justin Chen <justin.chen@broadcom.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: linux-mips@linux-mips.org Cc: bcm-kernel-feedback-list@broadcom.com Patchwork: https://patchwork.linux-mips.org/patch/15276/
-rw-r--r--arch/mips/kernel/cacheinfo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/mips/kernel/cacheinfo.c b/arch/mips/kernel/cacheinfo.c
index a92bbbae969b..97d5239ca47b 100644
--- a/arch/mips/kernel/cacheinfo.c
+++ b/arch/mips/kernel/cacheinfo.c
@@ -17,6 +17,7 @@
17 17
18/* Populates leaf and increments to next leaf */ 18/* Populates leaf and increments to next leaf */
19#define populate_cache(cache, leaf, c_level, c_type) \ 19#define populate_cache(cache, leaf, c_level, c_type) \
20do { \
20 leaf->type = c_type; \ 21 leaf->type = c_type; \
21 leaf->level = c_level; \ 22 leaf->level = c_level; \
22 leaf->coherency_line_size = c->cache.linesz; \ 23 leaf->coherency_line_size = c->cache.linesz; \
@@ -24,7 +25,8 @@
24 leaf->ways_of_associativity = c->cache.ways; \ 25 leaf->ways_of_associativity = c->cache.ways; \
25 leaf->size = c->cache.linesz * c->cache.sets * \ 26 leaf->size = c->cache.linesz * c->cache.sets * \
26 c->cache.ways; \ 27 c->cache.ways; \
27 leaf++; 28 leaf++; \
29} while (0)
28 30
29static int __init_cache_level(unsigned int cpu) 31static int __init_cache_level(unsigned int cpu)
30{ 32{