From: Catalin Marinas <catalin.marinas@arm.com>
To: Yicong Yang <yangyicong@huawei.com>
Cc: Will Deacon <will@kernel.org>,
yangyicong@hisilicon.com, maz@kernel.org, mark.rutland@arm.com,
linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev,
broonie@kernel.org, ryan.roberts@arm.com, linuxarm@huawei.com,
jonathan.cameron@huawei.com,
shameerali.kolothum.thodi@huawei.com, prime.zeng@hisilicon.com,
xuwei5@huawei.com, wangkefeng.wang@huawei.com
Subject: Re: [PATCH v2 1/2] arm64: Add support for FEAT_HAFT
Date: Thu, 19 Sep 2024 19:58:42 +0100 [thread overview]
Message-ID: <Zux0YgdVpbmAJWrT@arm.com> (raw)
In-Reply-To: <6a240d93-f818-c486-2603-05f651658277@huawei.com>
On Thu, Aug 29, 2024 at 02:29:41PM +0800, Yicong Yang wrote:
> On 2024/8/21 0:18, Will Deacon wrote:
> > On Wed, Aug 14, 2024 at 05:23:32PM +0800, Yicong Yang wrote:
> >> +static void cpu_enable_haft(struct arm64_cpu_capabilities const *cap)
> >> +{
> >> + sysreg_clear_set_s(SYS_TCR2_EL1, 0, TCR2_EL1x_HAFT);
> >> + isb();
> >> + local_flush_tlb_all();
> >> +}
> >
> > As this isn't a per-TTBR enable, should we be initialising the kernel
> > table entries in TTBR1 as YOUNG to avoid potential races with the
> > hardware update? It looks like the bit is ignored on CPUs without HAFT,
> > so we can just do this unconditionally.
>
> I'm a bit uncertain about the race here, is it because of the access fault
> or the inconsistent observation of table entries' AF status when enable the
> HAFT? and...
Linux doesn't use this mechanism on kernel page tables. The hardware
update of the access bit is atomic and, while it could race with a
non-atomic entry update, it shouldn't matter since no-one checks this
bit. However, I'd still set the AF bit when creating the kernel page
table, it saves the hardware from having to update them at run-time.
> > At the very least, we should be able to enable HAFT in __cpu_setup(),
> > like we do for HA.
> >
>
> ...if we enable this in __cpu_setup() as suggested we should have no race problem,
> since this is enabled before MMU on?
I suspect Will was referring to the actual page tables. But it makes
sense to enable this in __cpu_setup(), it saves us from having to do the
TLBI.
> > It's a bit of a pity that we can't handle this mismatch. After all,
> > access flag data is imprecise (unlike the dirty bit) and so you could
> > envisage a mechanism for falling back to leaf-level AF at runtime rather
> > than refusing to online a CPU.
>
> ok. I suppose enable this should be ok if no users. So it's possible to just
> try to enable this at each CPU's startup, but don't advertise this feature to
> the upper users if not all the CPUs in the system support this. This won't
> affect leaf-level AF since leaf-level AF has its own detection and enabling
> and doesn't depend on HAFT.
Yes, I think this should work as long as arch_has_hw_pte_young() returns
false if one of the CPUs doesn't support it. I had a quick grep through
the kernel and all (most?) cases where the non-leaf pmd is checked or
the AF bit cleared are conditional on should_clear_pmd_young().
Personally I'd have introduced pmd_nonleaf_young() etc. functions in the
core code to make it more explicit. I guess, if we really want, we could
add a VM_WARN_ON if pmd_young() or pmdp_test_and_clear_young() is called
on a non-leaf pmd and FEAT_HAFT is disabled.
--
Catalin
next prev parent reply other threads:[~2024-09-19 19:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 9:23 [PATCH v2 0/2] Support Armv8.9/v9.4 FEAT_HAFT Yicong Yang
2024-08-14 9:23 ` [PATCH v2 1/2] arm64: Add support for FEAT_HAFT Yicong Yang
2024-08-14 12:07 ` Mark Brown
2024-08-15 7:03 ` Yicong Yang
2024-08-20 16:18 ` Will Deacon
2024-08-29 6:29 ` Yicong Yang
2024-09-19 18:58 ` Catalin Marinas [this message]
2024-08-14 9:23 ` [PATCH v2 2/2] arm64: Enable ARCH_HAS_NONLEAF_PMD_YOUNG Yicong Yang
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=Zux0YgdVpbmAJWrT@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=prime.zeng@hisilicon.com \
--cc=ryan.roberts@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=xuwei5@huawei.com \
--cc=yangyicong@hisilicon.com \
--cc=yangyicong@huawei.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 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.