Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Govindraj Raja <Govindraj.Raja@imgtec.com>
Cc: <linux-mips@linux-mips.org>, Ralf Baechle <ralf@linux-mips.org>,
	"Markos Chandras" <markos.chandras@imgtec.com>,
	Paul Burton <paul.burton@imgtec.com>,
	Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>,
	James Hartley <James.Hartley@imgtec.com>
Subject: Re: [PATCH] mips: scache: fix scache init with invalid line size.
Date: Mon, 18 Jan 2016 15:05:19 +0000	[thread overview]
Message-ID: <20160118150519.GC25510@jhogan-linux.le.imgtec.org> (raw)
In-Reply-To: <1453126706-24299-1-git-send-email-Govindraj.Raja@imgtec.com>

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

Hi Govindraj,

On Mon, Jan 18, 2016 at 02:18:26PM +0000, Govindraj Raja wrote:
> 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.
> 
> Signed-off-by: Govindraj Raja <Govindraj.Raja@imgtec.com>
> ---
>  arch/mips/mm/sc-mips.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
> index 3bd0597..6e422bc 100644
> --- a/arch/mips/mm/sc-mips.c
> +++ b/arch/mips/mm/sc-mips.c
> @@ -168,7 +168,8 @@ static int __init mips_sc_probe_cm3(void)
>  
>  	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;

It seems wrong to clear MIPS_CACHE_NOT_PRESENT if we know there isn't a
cache actually present.

Cheers
James

>  
>  	assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK;
>  	assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF;
> -- 
> 2.5.0
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@imgtec.com>
To: Govindraj Raja <Govindraj.Raja@imgtec.com>
Cc: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>,
	Markos Chandras <markos.chandras@imgtec.com>,
	Paul Burton <paul.burton@imgtec.com>,
	Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>,
	James Hartley <James.Hartley@imgtec.com>
Subject: Re: [PATCH] mips: scache: fix scache init with invalid line size.
Date: Mon, 18 Jan 2016 15:05:19 +0000	[thread overview]
Message-ID: <20160118150519.GC25510@jhogan-linux.le.imgtec.org> (raw)
Message-ID: <20160118150519.zwzwV14OQDNDB4oLOV96bdlTw6TWdkGXWm6ANYnq18M@z> (raw)
In-Reply-To: <1453126706-24299-1-git-send-email-Govindraj.Raja@imgtec.com>

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

Hi Govindraj,

On Mon, Jan 18, 2016 at 02:18:26PM +0000, Govindraj Raja wrote:
> 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.
> 
> Signed-off-by: Govindraj Raja <Govindraj.Raja@imgtec.com>
> ---
>  arch/mips/mm/sc-mips.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
> index 3bd0597..6e422bc 100644
> --- a/arch/mips/mm/sc-mips.c
> +++ b/arch/mips/mm/sc-mips.c
> @@ -168,7 +168,8 @@ static int __init mips_sc_probe_cm3(void)
>  
>  	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;

It seems wrong to clear MIPS_CACHE_NOT_PRESENT if we know there isn't a
cache actually present.

Cheers
James

>  
>  	assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK;
>  	assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF;
> -- 
> 2.5.0
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-01-18 15:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 14:18 [PATCH] mips: scache: fix scache init with invalid line size Govindraj Raja
2016-01-18 14:18 ` Govindraj Raja
2016-01-18 15:05 ` James Hogan [this message]
2016-01-18 15:05   ` James Hogan
2016-01-19 15:34   ` Govindraj Raja
2016-01-19 15:34     ` Govindraj Raja

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=20160118150519.GC25510@jhogan-linux.le.imgtec.org \
    --to=james.hogan@imgtec.com \
    --cc=Govindraj.Raja@imgtec.com \
    --cc=James.Hartley@imgtec.com \
    --cc=Leonid.Yegoshin@imgtec.com \
    --cc=linux-mips@linux-mips.org \
    --cc=markos.chandras@imgtec.com \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.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