From: Ryan Roberts <ryan.roberts@arm.com>
To: "Mikołaj Lenczewski" <miko.lenczewski@arm.com>
Cc: suzuki.poulose@arm.com, yang@os.amperecomputing.com,
corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org,
jean-philippe@linaro.org, robin.murphy@arm.com, joro@8bytes.org,
akpm@linux-foundation.org, mark.rutland@arm.com,
joey.gouly@arm.com, maz@kernel.org, james.morse@arm.com,
broonie@kernel.org, anshuman.khandual@arm.com,
oliver.upton@linux.dev, ioworker0@gmail.com, baohua@kernel.org,
david@redhat.com, jgg@ziepe.ca,
shameerali.kolothum.thodi@huawei.com, nicolinc@nvidia.com,
mshavit@google.com, jsnitsel@redhat.com, smostafa@google.com,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev
Subject: Re: [PATCH v3 1/3] arm64: Add BBM Level 2 cpu feature
Date: Fri, 14 Mar 2025 09:26:56 +0000 [thread overview]
Message-ID: <d3a15aaf-16a6-4a88-a6c5-9b9afaa5f370@arm.com> (raw)
In-Reply-To: <20250313180833.GA40525@mazurka.cambridge.arm.com>
On 13/03/2025 18:08, Mikołaj Lenczewski wrote:
> On Thu, Mar 13, 2025 at 04:13:22PM +0000, Ryan Roberts wrote:
>> On 13/03/2025 10:41, Mikołaj Lenczewski wrote:
>>> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
>>> index d561cf3b8ac7..b936e0805161 100644
>>> --- a/arch/arm64/kernel/cpufeature.c
>>> +++ b/arch/arm64/kernel/cpufeature.c
>>> @@ -2176,6 +2176,76 @@ static bool hvhe_possible(const struct arm64_cpu_capabilities *entry,
>>> return arm64_test_sw_feature_override(ARM64_SW_FEATURE_OVERRIDE_HVHE);
>>> }
>>>
>>> +static inline bool bbml2_possible(void)
>>> +{
>>> + return !arm64_test_sw_feature_override(ARM64_SW_FEATURE_OVERRIDE_NOBBML2);
>>
>> If you're going to keep this helper, I think it really needs to be:
>>
>> return IS_ENABLED(CONFIG_ARM64_BBML2_NOABORT) &&
>> !arm64_test_sw_feature_override(ARM64_SW_FEATURE_OVERRIDE_NOBBML2);
>>
>> Then you would simplify the caller to remove it's own
>> IS_ENABLED(CONFIG_ARM64_BBML2_NOABORT) check.
>>
>> But personally I would remove the helper and just fold the test into
>> has_bbml2_noabort().
>>
>> Thanks,
>> Ryan
>
> I was debating folding it into has_bbml2_noabort(), but went ahead and
> implemented it separately to match hvhe_possible(), which was another sw
> feature helper.
hvhe_possible() is a .matches function, so there is nothing to fold it into.
>
> But I agree, folding it will be simpler and read just as easily (if not
> easier). Will do so.
>
>>> +}
>>> +
>>> +static bool cpu_has_bbml2_noabort(unsigned int cpu_midr)
>>> +{
>>> + /* We want to allow usage of bbml2 in as wide a range of kernel contexts
>>> + * as possible. This list is therefore an allow-list of known-good
>>> + * implementations that both support bbml2 and additionally, fulfill the
>>> + * extra constraint of never generating TLB conflict aborts when using
>>> + * the relaxed bbml2 semantics (such aborts make use of bbml2 in certain
>>> + * kernel contexts difficult to prove safe against recursive aborts).
>>> + *
>>> + * Note that implementations can only be considered "known-good" if their
>>> + * implementors attest to the fact that the implementation never raises
>>> + * TLBI conflict aborts for bbml2 mapping granularity changes.
>>> + */
>>> + static const struct midr_range supports_bbml2_noabort_list[] = {
>>> + MIDR_REV_RANGE(MIDR_CORTEX_X4, 0, 3, 0xf),
>>> + MIDR_REV_RANGE(MIDR_NEOVERSE_V3, 0, 2, 0xf),
>>> + {}
>>> + };
>>> +
>>> + return is_midr_in_range_list(cpu_midr, supports_bbml2_noabort_list);
>>> +}
>>> +
>>> +static inline unsigned int __cpu_read_midr(int cpu)
>>
>> nit: why the double underscrore prefix?
>
> Again copying other helpers I saw that seemed to do similar things.
> Didn't know if this was the expected style, so did as other helpers did.
> Will remove.
Often those double underscores are used when you have a public function wrapping
into a private function, like this:
static void __do_a_thing(bool modify_behaviour_in_some_way);
void do_a_thing(void)
{
__do_a_thing(false);
}
I'm sure the coding style offers a better explanation.
Thanks,
Ryan
>
> Thank you for the review.
>
next prev parent reply other threads:[~2025-03-14 9:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 10:41 [PATCH v3 0/3] Initial BBML2 support for contpte_convert() Mikołaj Lenczewski
2025-03-13 10:41 ` [PATCH v3 1/3] arm64: Add BBM Level 2 cpu feature Mikołaj Lenczewski
2025-03-13 16:13 ` Ryan Roberts
2025-03-13 18:08 ` Mikołaj Lenczewski
2025-03-14 9:26 ` Ryan Roberts [this message]
2025-03-13 17:21 ` Yang Shi
2025-03-13 18:13 ` Mikołaj Lenczewski
2025-03-13 18:17 ` Ryan Roberts
2025-03-13 17:34 ` Marc Zyngier
2025-03-13 18:20 ` Mikołaj Lenczewski
2025-03-13 18:39 ` Marc Zyngier
2025-03-13 18:22 ` Ryan Roberts
2025-03-13 18:36 ` Marc Zyngier
2025-03-14 9:18 ` Ryan Roberts
2025-03-14 10:11 ` Marc Zyngier
2025-03-14 12:33 ` Suzuki K Poulose
2025-03-14 13:12 ` Ryan Roberts
2025-03-13 10:41 ` [PATCH v3 2/3] iommu/arm: Add BBM Level 2 smmu feature Mikołaj Lenczewski
2025-03-13 11:39 ` Robin Murphy
2025-03-13 16:18 ` Ryan Roberts
2025-03-13 10:41 ` [PATCH v3 3/3] arm64/mm: Elide tlbi in contpte_convert() under BBML2 Mikołaj Lenczewski
2025-03-13 16:28 ` Ryan Roberts
2025-03-13 11:22 ` [PATCH v3 0/3] Initial BBML2 support for contpte_convert() Suzuki K Poulose
2025-03-13 11:30 ` Mikołaj Lenczewski
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=d3a15aaf-16a6-4a88-a6c5-9b9afaa5f370@arm.com \
--to=ryan.roberts@arm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=baohua@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=ioworker0@gmail.com \
--cc=james.morse@arm.com \
--cc=jean-philippe@linaro.org \
--cc=jgg@ziepe.ca \
--cc=joey.gouly@arm.com \
--cc=joro@8bytes.org \
--cc=jsnitsel@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=miko.lenczewski@arm.com \
--cc=mshavit@google.com \
--cc=nicolinc@nvidia.com \
--cc=oliver.upton@linux.dev \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=smostafa@google.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yang@os.amperecomputing.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
all inboxes | Powered by JetHome®