All of lore.kernel.org
 help / color / mirror / Atom feed
From: Justin Chen <justin.chen@broadcom.com>
To: James Hogan <james.hogan@imgtec.com>, linux-mips@linux-mips.org
Cc: Guenter Roeck <linux@roeck-us.net>,
	Ralf Baechle <ralf@linux-mips.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	bcm-kernel-feedback-list@broadcom.com
Subject: Re: [PATCH] MIPS: Fix cacheinfo overflow
Date: Fri, 10 Feb 2017 15:10:47 -0800	[thread overview]
Message-ID: <d63e0019-5861-ccca-7959-631916e6c882@broadcom.com> (raw)
In-Reply-To: <20170210230120.21588-1-james.hogan@imgtec.com>

Hello,

Thanks for the catch!

I actually submitted a v2 of the patch sometime back located here:
https://patchwork.linux-mips.org/patch/15107/

The v2 had some code review changes from Matt Redfearn. These changes 
indirectly got rid of the error, which was why I wasn't running into the 
crash.

Either way, whatever makes more sense, we can drop the other v1 patch 
and add v2 or just add this patch on top.

Thanks,
Justin

On 02/10/2017 03:01 PM, James Hogan wrote:
> 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>
> 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
> ---
>  arch/mips/kernel/cacheinfo.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> 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 @@
>
>  /* Populates leaf and increments to next leaf */
>  #define populate_cache(cache, leaf, c_level, c_type)		\
> +do {								\
>  	leaf->type = c_type;					\
>  	leaf->level = c_level;					\
>  	leaf->coherency_line_size = c->cache.linesz;		\
> @@ -24,7 +25,8 @@
>  	leaf->ways_of_associativity = c->cache.ways;		\
>  	leaf->size = c->cache.linesz * c->cache.sets *		\
>  		c->cache.ways;					\
> -	leaf++;
> +	leaf++;							\
> +} while (0)
>
>  static int __init_cache_level(unsigned int cpu)
>  {
>

  reply	other threads:[~2017-02-10 23:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 23:45 Crash in -next due to 'MIPS: Add cacheinfo support' Guenter Roeck
2017-02-10  0:01 ` Justin Chen
2017-02-10  4:50   ` Guenter Roeck
2017-02-10  9:40     ` James Hogan
2017-02-10  9:40       ` James Hogan
2017-02-10 10:39       ` James Hogan
2017-02-10 10:39         ` James Hogan
2017-02-10 17:46         ` Guenter Roeck
2017-02-10 19:15           ` Florian Fainelli
2017-02-10 22:11             ` Guenter Roeck
2017-02-10 22:39               ` James Hogan
2017-02-10 22:39                 ` James Hogan
2017-02-10 22:43                 ` Florian Fainelli
2017-02-10 22:48                 ` Guenter Roeck
2017-02-10 13:30       ` Guenter Roeck
2017-02-10 23:01 ` [PATCH] MIPS: Fix cacheinfo overflow James Hogan
2017-02-10 23:01   ` James Hogan
2017-02-10 23:10   ` Justin Chen [this message]
2017-02-10 23:44     ` James Hogan
2017-02-10 23:44       ` James Hogan
2017-02-10 23:48       ` Justin Chen
2017-02-11  1:25   ` Guenter Roeck

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=d63e0019-5861-ccca-7959-631916e6c882@broadcom.com \
    --to=justin.chen@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=f.fainelli@gmail.com \
    --cc=james.hogan@imgtec.com \
    --cc=linux-mips@linux-mips.org \
    --cc=linux@roeck-us.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.