From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: alternative:flush cache with unpatched code
Date: Mon, 4 Jun 2018 10:01:21 +0100 [thread overview]
Message-ID: <20180604090120.c5lrdpzeannc4p6i@salmiak> (raw)
In-Reply-To: <1527882765869.38555@nvidia.com>
On Fri, Jun 01, 2018 at 07:52:05PM +0000, Rohit Khanna wrote:
> [RK] - Thanks for the comments Mark. Reply inlined.
>
> Thanks
> Rohit
> ________________________________________
> From: Mark Rutland <mark.rutland@arm.com>
> Sent: Friday, June 1, 2018 2:03 AM
> To: Rohit Khanna
> Cc: catalin.marinas at arm.com; robin.murphy at arm.com; Suzuki.Poulose at arm.com; linux-arm-kernel at lists.infradead.org; Alexander Van Brunt; Bo Yan; will.deacon at arm.com
> Subject: Re: [PATCH] arm64: alternative:flush cache with unpatched code
[...]
> > --- a/arch/arm64/include/asm/sysreg.h
> > +++ b/arch/arm64/include/asm/sysreg.h
> > @@ -617,6 +617,9 @@
> > #define MVFR1_FPDNAN_SHIFT 4
> > #define MVFR1_FPFTZ_SHIFT 0
> >
> > +/* SYS_CTR_EL0 */
> > +#define SYS_CTR_ISIZE_SHIFT 0
> > +#define SYS_CTR_DSIZE_SHIFT 16
>
> We already have CTR_DMINLINE_SHIFT in <asm/cache.h>
>
> Can we please add CTR_IMINLIN_SHIFT there too?
>
> Maybe those should be moved into sysreg.h, but that can be a separate cleanup.
>
> [RK] - <asm/cache.h> doesnt contain CTR_DMINLINE_SHIFT.
It's on line 23 of arch/arm64/include/asm/cache.h, looking at v4.17.
[...]
> > + /* use sanitised value of ctr_el0 rather than raw value from CPU */
> > + ctr_el0 = read_sanitised_ftr_reg(SYS_CTR_EL0);
> > + /* size in bytes */
> > + d_size = cpuid_feature_extract_unsigned_field(ctr_el0,
> > + SYS_CTR_DSIZE_SHIFT);
> > + i_size = cpuid_feature_extract_unsigned_field(ctr_el0,
> > + SYS_CTR_ISIZE_SHIFT);
>
> This isn't the size in bytes. Each is log2 the number of (4-byte) words.
>
> i.e. the size in bytes is (xMinLine << 2).
> [RK] - This doesnt seem right. For eg if IMinLine = 4 or 0b100
> then with above formula ICacheSize in Bytes = 4 << 2 = 16
> The correct formula should be (4 << xMinLine).
> So in case IMinLine = 4 or 0b100,
> ICacheSizeBytes = 4 << 4 = 64B
Whoops. You are correct with 4 << xMinLine.
[...]
> > + d_start = (u64)start & ~(d_size - 1);
> > + while (d_start <= (u64)end) {
> > + /* Use civac instead of cvau. This is required
> > + * due to ARM errata 826319, 827319, 824069,
> > + * 819472 on A53
> > + */
> > + asm volatile("dc civac, %0" : : "r" (d_start));
>
> Either this needs a memory clobber, or we need barrier() first, to ensure that
> the compiler doesn't re-order this against some of the patching code, however
> unlikely that may be.
> [RK] - So add barrier() before calling clean_dcache_range_nopatch() ?
I'd put it before the loop here so that it's clearly associated with the DC CIVAC.
Thanks,
Mark.
next prev parent reply other threads:[~2018-06-04 9:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 20:37 [PATCH] arm64: alternative:flush cache with unpatched code Rohit Khanna
2018-06-01 9:03 ` Mark Rutland
2018-06-01 19:52 ` Rohit Khanna
2018-06-01 21:43 ` Rohit Khanna
2018-06-04 9:01 ` Mark Rutland [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-06-02 0:39 Rohit Khanna
2018-05-29 18:11 Rohit Khanna
2018-05-30 9:00 ` Will Deacon
2018-05-31 17:45 ` Rohit Khanna
2018-06-04 9:16 ` Will Deacon
2018-06-04 19:34 ` Alexander Van Brunt
2018-06-05 16:55 ` Will Deacon
2018-06-05 17:07 ` Alexander Van Brunt
2018-06-06 15:44 ` Will Deacon
2018-06-06 16:16 ` Alexander Van Brunt
2018-05-22 18:07 Rohit Khanna
2018-05-23 9:06 ` Will Deacon
2018-05-22 1:27 Rohit Khanna
2018-05-22 15:09 ` Suzuki K Poulose
2018-05-22 18:08 ` Rohit Khanna
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=20180604090120.c5lrdpzeannc4p6i@salmiak \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.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