* [PATCH v3] mips: scache: fix scache init with invalid line size.
@ 2016-02-29 11:41 Govindraj Raja
2016-02-29 14:47 ` Ralf Baechle
0 siblings, 1 reply; 3+ messages in thread
From: Govindraj Raja @ 2016-02-29 11:41 UTC (permalink / raw)
To: Ralf Baechle
Cc: Govindraj Raja, stable, Paul Burton, James Hogan, James Hartley,
linux-mips
In current scache init cache line_size is determined from
cpu config register, however if there there no scache
then mips_sc_probe_cm3 function populates a invalid line_size of 2.
The invalid line_size can cause a NULL pointer deference
during r4k_dma_cache_inv as r4k_blast_scache is populated
based on line_size. Scache line_size of 2 is invalid option in
r4k_blast_scache_setup.
This issue was faced during a MIPS I6400 based virtual platform bring up
where scache was not available in virtual platform model.
Changes from v2:
https://patchwork.linux-mips.org/patch/12243/
Fix return value, ensure function returns true only if
scache is identified.
Changes from v1:
https://patchwork.linux-mips.org/patch/12126/
Avoid clearing of MIPS_CACHE_NOT_PRESENT if scache is absent
Fixes: 7d53e9c4cd21("MIPS: CM3: Add support for CM3 L2 cache.")
Cc: <stable@vger.kernel.org> # v4.2+
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hartley <James.Hartley@imgtec.com>
Cc: linux-mips@linux-mips.org
Signed-off-by: Govindraj Raja <Govindraj.Raja@imgtec.com>
---
arch/mips/mm/sc-mips.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 2496475..91dec32 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -164,11 +164,13 @@ static int __init mips_sc_probe_cm3(void)
sets = cfg & CM_GCR_L2_CONFIG_SET_SIZE_MSK;
sets >>= CM_GCR_L2_CONFIG_SET_SIZE_SHF;
- c->scache.sets = 64 << sets;
+ if (sets)
+ c->scache.sets = 64 << sets;
line_sz = cfg & CM_GCR_L2_CONFIG_LINE_SIZE_MSK;
line_sz >>= CM_GCR_L2_CONFIG_LINE_SIZE_SHF;
- c->scache.linesz = 2 << line_sz;
+ if (line_sz)
+ c->scache.linesz = 2 << line_sz;
assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK;
assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF;
@@ -176,9 +178,12 @@ static int __init mips_sc_probe_cm3(void)
c->scache.waysize = c->scache.sets * c->scache.linesz;
c->scache.waybit = __ffs(c->scache.waysize);
- c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
+ if (c->scache.linesz) {
+ c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
+ return 1;
+ }
- return 1;
+ return 0;
}
static inline int __init mips_sc_probe(void)
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] mips: scache: fix scache init with invalid line size.
2016-02-29 11:41 [PATCH v3] mips: scache: fix scache init with invalid line size Govindraj Raja
@ 2016-02-29 14:47 ` Ralf Baechle
2016-02-29 14:51 ` Govindraj Raja
0 siblings, 1 reply; 3+ messages in thread
From: Ralf Baechle @ 2016-02-29 14:47 UTC (permalink / raw)
To: Govindraj Raja
Cc: stable, Paul Burton, James Hogan, James Hartley, linux-mips
On Mon, Feb 29, 2016 at 11:41:20AM +0000, Govindraj Raja wrote:
> Cc: <stable@vger.kernel.org> # v4.2+
You meant 4.3+; 4.2 doesn't have a mips_sc_probe_cm3 function. Other
than that, ok & applied.
Ralf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] mips: scache: fix scache init with invalid line size.
2016-02-29 14:47 ` Ralf Baechle
@ 2016-02-29 14:51 ` Govindraj Raja
0 siblings, 0 replies; 3+ messages in thread
From: Govindraj Raja @ 2016-02-29 14:51 UTC (permalink / raw)
To: Ralf Baechle; +Cc: stable, Paul Burton, James Hogan, James Hartley, linux-mips
On 29/02/16 14:47, Ralf Baechle wrote:
> On Mon, Feb 29, 2016 at 11:41:20AM +0000, Govindraj Raja wrote:
>
>> Cc: <stable@vger.kernel.org> # v4.2+
> You meant 4.3+; 4.2 doesn't have a mips_sc_probe_cm3 function. Other
> than that, ok & applied.
>
Yes it was supposed to be 4.3+
thanks
--
Thanks,
Govindraj.R
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-29 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-29 11:41 [PATCH v3] mips: scache: fix scache init with invalid line size Govindraj Raja
2016-02-29 14:47 ` Ralf Baechle
2016-02-29 14:51 ` Govindraj Raja
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).