public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: "Ivan T. Ivanov" <iivanov@suse.de>
Cc: Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Mark Brown <broonie@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
	Dong Aisheng <aisheng.dong@nxp.com>, Frank Li <frank.li@nxp.com>,
	Jason Liu <jason.hui.liu@nxp.com>,
	linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com
Subject: Re: [PATCH v2] arm64: errata: Add NXP iMX8QM workaround for A53 Cache coherency issue
Date: Thu, 8 Jun 2023 16:32:29 +0100	[thread overview]
Message-ID: <ZIH0jWPOp9mmwlDZ@FVFF77S0Q05N> (raw)
In-Reply-To: <bmszrmlpb37t3zn4e3pzcn3qaszgjpkowdx2saqvpecqo77qmi@qvyr5bluif2q>

On Thu, Jun 08, 2023 at 06:05:54PM +0300, Ivan T. Ivanov wrote:
> On 06-08 15:16, Mark Rutland wrote:
> > On Thu, Jun 08, 2023 at 04:39:29PM +0300, Ivan T. Ivanov wrote:
> > > On 06-02 11:34, Will Deacon wrote:
> > > > On Thu, Apr 20, 2023 at 02:29:52PM +0300, Ivan T. Ivanov wrote:

> > > > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> > > > > index 4a79ba100799..265b6334291b 100644
> > > > > --- a/arch/arm64/kernel/traps.c
> > > > > +++ b/arch/arm64/kernel/traps.c
> > > > > @@ -556,6 +556,11 @@ static void user_cache_maint_handler(unsigned long esr, struct pt_regs *regs)
> > > > >  		__user_cache_maint("dc civac", address, ret);
> > > > >  		break;
> > > > >  	case ESR_ELx_SYS64_ISS_CRM_IC_IVAU:	/* IC IVAU */
> > > > > +		if (cpus_have_final_cap(ARM64_WORKAROUND_NXP_ERR050104)) {
> > > > > +			asm volatile("ic ialluis");
> > > > 
> > > > Hmm, one oddity here is that you can pass a faulting address and not see
> > > > the fault. It looks like that's already IMP DEF, so it's probably ok, but
> > > > might be worth a comment.
> > > 
> > > I am not sure what should be expected behavior, but I could
> > > add comment, sure.
> > 
> > Another option is to make this:
> > 
> > 	 case ESR_ELx_SYS64_ISS_CRM_IC_IVAU:     /* IC IVAU */
> > 	 	__user_cache_maint("ic ivau", address, ret)
> > 		if (cpus_have_final_cap(ARM64_WORKAROUND_NXP_ERR050104) && !ret)
> > 			asm volatile("ic ialluis");
> > 		break;
> > 
> > Which'll ensure that if the regular IC IVAU faults we'll handle that, and if
> > not we'll do the IC IALLUIS.
> > 
> > I think that looks a bit cleaner, too.
> 
> What I am afraid is that "ic ivau address" will do cache invalidation of a 
> random address, because of wrong address wiring. So the end result will not
> be what should be expected.

I don't follow:

 - The faulting logic is entirely local (and has to happen before the
   broadcast), so the faulting logic shouldn't be affected by the erratum and
   will use the correct address.

 - We're going to do an IC IALLUIS anyway, so we're going to do invalidation of
   *every* address. So randomly invalidating a random address at the same time
   isn't going to cause a functiona problem because we're going to invaldiate
   it anyway.

> > > > Finally, how come you don't need to upgrade I-cache invalidation by-VA
> > > > in the kernel? It looks like you're only handling operations trapped
> > > > from EL0.
> > > 
> > > Hm, I was thinking that __tlbi() is taking care for this or you mean 
> > > something else, like locations in assembler.h?
> > 
> > The __tlbi macro handles only TLBI instructions.
> > 
> > The trap handler above *only* handles IC instructions trapped from userspace;
> 
> Yep, I get this.
> 
> > we have IC IVAU instructions elsewhere in the kernel (e.g.
> > arch/arm64/mm/cache.S).
> 
> But I have missed this one :-)

Looking again, those all use the common invalidate_icache_by_line macro in
arch/arm64/include/asm/assembler.h

Lukily that seems to be all:

| [mark@lakrids:~/src/linux]% git grep -iw ivau -- arch/arm64 
| arch/arm64/include/asm/assembler.h:     ic      ivau, \tmp2                     // invalidate I line PoU
| arch/arm64/kernel/traps.c:      case ESR_ELx_SYS64_ISS_CRM_IC_IVAU:     /* IC IVAU */
| arch/arm64/kernel/traps.c:              __user_cache_maint("ic ivau", address, ret);

> I think that this is working because these are used only in operations witch
> work up to the Point of Unification, thus not messing up with caches of the
> rest of PE.

I think you have a misunderstanding of the architecture, because that doesn't
make sense. All IC IVAU operations operate to the Point of Unification. That's
what the 'U' in 'IVAU' stands for. The Point of Unification is the point in the
memory system where instruction fetches and data fetches see the same thing.
 
If the VA passed to IC IVAU isn't correctly broadcast, it's broken regardless
of where that IC IVAU is executed from, because it will leave stale
instructions in the I-caches of other PEs.

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-06-08 15:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 11:29 [PATCH v2] arm64: errata: Add NXP iMX8QM workaround for A53 Cache coherency issue Ivan T. Ivanov
2023-05-18 11:59 ` Ivan T. Ivanov
2023-06-02 10:34 ` Will Deacon
2023-06-08 13:39   ` Ivan T. Ivanov
2023-06-08 14:16     ` Mark Rutland
2023-06-08 15:05       ` Ivan T. Ivanov
2023-06-08 15:32         ` Mark Rutland [this message]
2023-06-08 18:22           ` Ivan T. Ivanov
     [not found]             ` <ZIbmNNc6/pfYG92D@FVFF77S0Q05N>
     [not found]               ` <y5lcrztej6th7z3eoihiiazwwlidyhi3t2tkdjrmgcghqwt6bs@dzxxpmwfynj6>
2023-06-26 12:15                 ` Will Deacon
2023-07-13 14:29                   ` Ivan T. Ivanov
2025-12-10  7:45 ` Francesco Dolcini
2025-12-10 11:39   ` Ivan T. Ivanov
2025-12-10 14:55   ` [EXT] " Frank Li
2025-12-11 10:43     ` Francesco Dolcini

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=ZIH0jWPOp9mmwlDZ@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=aisheng.dong@nxp.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=frank.li@nxp.com \
    --cc=iivanov@suse.de \
    --cc=jason.hui.liu@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=will@kernel.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