From: Paul Burton <paul.burton@mips.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "Ralf Baechle" <ralf@linux-mips.org>,
"James Hogan" <jhogan@kernel.org>,
"Hauke Mehrtens" <hauke@hauke-m.de>,
"Matt Redfearn" <matt.redfearn@mips.com>,
"Michal Hocko" <mhocko@suse.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Mike Rapoport" <rppt@linux.vnet.ibm.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Pravin Shedge" <pravin.shedge4linux@gmail.com>,
"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
"Rafał Miłecki" <rafal@milecki.pl>,
"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>
Subject: Re: [PATCH] MIPS: Workaround bugged BCM4704 & BCM5354 that crash with kmap_coherent()
Date: Thu, 7 Feb 2019 19:42:20 +0000 [thread overview]
Message-ID: <20190207194218.dapt5wz4y7ehzjy2@pburton-laptop> (raw)
In-Reply-To: <20190207155200.16880-1-zajec5@gmail.com>
Hi Rafał,
On Thu, Feb 07, 2019 at 04:52:00PM +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> This workarounds what seems to be a hardware bug present in some early
> Broadcom MIPS CPUs. For some reason using kmap_coherent() for copying a
> memory causes a "Data bus error" or SoC reboot.
>
>%
>
> diff --git a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
> index b23ff47ea475..553505dea60b 100644
> --- a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
> +++ b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
> @@ -80,4 +80,12 @@
> #define cpu_scache_line_size() 0
> #define cpu_has_vz 0
>
> +/*
> + * Workaround for the bugged BCM4704 & BCM5354:
> + * copy_from_user_page() + kmap_coherent() causes "Data bus error"
> + * copy_to_user_page() + kmap_coherent() causes immediate reboot
> + */
> +#define cpu_has_kmap_coherent (cpu_data[0].processor_id != 0x29006 && \
> + cpu_data[0].processor_id != 0x29029)
> +
> #endif /* __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H */
> diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
> index c3b45e248806..67007bf15543 100644
> --- a/arch/mips/mm/init.c
> +++ b/arch/mips/mm/init.c
> @@ -174,7 +174,7 @@ void copy_user_highpage(struct page *to, struct page *from,
> void *vfrom, *vto;
>
> vto = kmap_atomic(to);
> - if (cpu_has_dc_aliases &&
> + if (cpu_has_kmap_coherent && cpu_has_dc_aliases &&
> page_mapcount(from) && !Page_dcache_dirty(from)) {
> vfrom = kmap_coherent(from, vaddr);
> copy_page(vto, vfrom);
Won't this introduce cache aliasing problems?
The reason for using kmap_coherent at all is to ensure we use a mapping
with the same cache colouring as the user's mapping. If the CPU suffers
from dcache aliasing & we don't do that colouring then it seems like
this might lead to us reading/copying stale data?
Thanks,
Paul
parent reply other threads:[~2019-02-07 19:42 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20190207155200.16880-1-zajec5@gmail.com>]
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=20190207194218.dapt5wz4y7ehzjy2@pburton-laptop \
--to=paul.burton@mips.com \
--cc=akpm@linux-foundation.org \
--cc=alexandre.belloni@bootlin.com \
--cc=hauke@hauke-m.de \
--cc=jhogan@kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-mips@vger.kernel.org \
--cc=matt.redfearn@mips.com \
--cc=mhocko@suse.com \
--cc=pravin.shedge4linux@gmail.com \
--cc=rafal@milecki.pl \
--cc=ralf@linux-mips.org \
--cc=rppt@linux.vnet.ibm.com \
--cc=zajec5@gmail.com \
/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).