From: Anton Blanchard <anton@ozlabs.org>
To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc: Avoid panic during boot due to divide by zero in init_cache_info()
Date: Sun, 5 Mar 2017 10:54:34 +1100 [thread overview]
Message-ID: <1488671674-20833-1-git-send-email-anton@ozlabs.org> (raw)
From: Anton Blanchard <anton@samba.org>
I see a panic in early boot when building with a recent gcc toolchain.
The issue is a divide by zero, which is undefined. Older toolchains
let us get away with it:
int foo(int a) { return a / 0; }
foo:
li 9,0
divw 3,3,9
extsw 3,3
blr
But newer ones catch it:
foo:
trap
Add a check to avoid the divide by zero.
Fixes: bd067f83b084 ("powerpc/64: Fix naming of cache block vs. cache line")
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/kernel/setup_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index adf2084..afd1c26 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -408,7 +408,8 @@ static void init_cache_info(struct ppc_cache_info *info, u32 size, u32 lsize,
info->line_size = lsize;
info->block_size = bsize;
info->log_block_size = __ilog2(bsize);
- info->blocks_per_page = PAGE_SIZE / bsize;
+ if (bsize)
+ info->blocks_per_page = PAGE_SIZE / bsize;
if (sets == 0)
info->assoc = 0xffff;
--
2.7.4
next reply other threads:[~2017-03-04 23:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-04 23:54 Anton Blanchard [this message]
2017-03-05 0:25 ` [PATCH] powerpc: Avoid panic during boot due to divide by zero in init_cache_info() Benjamin Herrenschmidt
2017-03-05 0:27 ` Benjamin Herrenschmidt
2017-03-05 10:26 ` Michael Ellerman
2017-03-05 12:37 ` Segher Boessenkool
2017-03-05 16:58 ` Gabriel Paubert
2017-03-05 17:24 ` Segher Boessenkool
2017-03-05 23:09 ` Benjamin Herrenschmidt
2017-03-06 0:10 ` Segher Boessenkool
2017-03-06 0:20 ` Benjamin Herrenschmidt
2017-03-06 12:03 ` Gabriel Paubert
2017-03-06 14:17 ` Segher Boessenkool
2017-03-06 15:18 ` David Laight
2017-03-05 10:36 ` Michael Ellerman
2017-03-08 7:25 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488671674-20833-1-git-send-email-anton@ozlabs.org \
--to=anton@ozlabs.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).