From: pelcan@codeaurora.org (Philip Elcan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: tlbflush: avoid writing RES0 bits
Date: Mon, 26 Mar 2018 20:51:45 -0400 [thread overview]
Message-ID: <9624b762-a26e-36da-b0a2-4087f0a2069c@codeaurora.org> (raw)
In-Reply-To: <20180326100220.zbu4dfojofmbesp4@lakrids.cambridge.arm.com>
On 3/26/2018 6:02 AM, Mark Rutland wrote:
> On Wed, Mar 21, 2018 at 05:02:52PM -0400, Philip Elcan wrote:
>> Bits [47:44] of the TLBI register operand are RES0 for instructions that
>> require a VA, per the ARM ARM spec, so TLBI operations should avoid writing
>> non-zero values to these bits.
>>
>> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
>> ---
>> arch/arm64/include/asm/tlbflush.h | 16 ++++++++++------
>> 1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
>> index 9e82dd7..dbd22a9 100644
>> --- a/arch/arm64/include/asm/tlbflush.h
>> +++ b/arch/arm64/include/asm/tlbflush.h
>> @@ -60,6 +60,9 @@
>> __tlbi(op, (arg) | USER_ASID_FLAG); \
>> } while (0)
>>
>> +/* This macro masks out RES0 bits in the TLBI operand */
>> +#define __TLBI_VADDR(addr) (addr & ~GENMASK_ULL(47, 44))
>
> If we're going to mask the address bits, it would be simpler to keep the
> valid bits than to clear the invalid bits. i.e.
>
> #define __TLBI_VADDR(addr) (addr & GENMASK_ULL(43, 0))
>
> Maybe we want a helper that does all of the addr / asid shifting and
> masking, so we do that in one place rather than spreading it across all
> helpers, e.g.
>
> #define __tlbi_addr(addr, asid) \
> ({ \
> unsigned long __ta = (addr) >> 12; \
> __ta &= GENMASK_ULL(43, 0); \
> __ta |= (asid) << 48; \
> __ta; \
> })
>
> Thanks,
> Mark.
>
That makes sense and addresses Robin's comment as well. I'll send out a
v2 with your suggestion.
Thanks,
Philip
--
Qualcomm Datacenter Technologies as an affiliate of Qualcomm
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
WARNING: multiple messages have this Message-ID (diff)
From: Philip Elcan <pelcan@codeaurora.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org,
Thomas Speier <tspeier@codeaurora.org>,
Shanker Donthineni <shankerd@codeaurora.org>
Subject: Re: [PATCH] arm64: tlbflush: avoid writing RES0 bits
Date: Mon, 26 Mar 2018 20:51:45 -0400 [thread overview]
Message-ID: <9624b762-a26e-36da-b0a2-4087f0a2069c@codeaurora.org> (raw)
In-Reply-To: <20180326100220.zbu4dfojofmbesp4@lakrids.cambridge.arm.com>
On 3/26/2018 6:02 AM, Mark Rutland wrote:
> On Wed, Mar 21, 2018 at 05:02:52PM -0400, Philip Elcan wrote:
>> Bits [47:44] of the TLBI register operand are RES0 for instructions that
>> require a VA, per the ARM ARM spec, so TLBI operations should avoid writing
>> non-zero values to these bits.
>>
>> Signed-off-by: Philip Elcan <pelcan@codeaurora.org>
>> ---
>> arch/arm64/include/asm/tlbflush.h | 16 ++++++++++------
>> 1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
>> index 9e82dd7..dbd22a9 100644
>> --- a/arch/arm64/include/asm/tlbflush.h
>> +++ b/arch/arm64/include/asm/tlbflush.h
>> @@ -60,6 +60,9 @@
>> __tlbi(op, (arg) | USER_ASID_FLAG); \
>> } while (0)
>>
>> +/* This macro masks out RES0 bits in the TLBI operand */
>> +#define __TLBI_VADDR(addr) (addr & ~GENMASK_ULL(47, 44))
>
> If we're going to mask the address bits, it would be simpler to keep the
> valid bits than to clear the invalid bits. i.e.
>
> #define __TLBI_VADDR(addr) (addr & GENMASK_ULL(43, 0))
>
> Maybe we want a helper that does all of the addr / asid shifting and
> masking, so we do that in one place rather than spreading it across all
> helpers, e.g.
>
> #define __tlbi_addr(addr, asid) \
> ({ \
> unsigned long __ta = (addr) >> 12; \
> __ta &= GENMASK_ULL(43, 0); \
> __ta |= (asid) << 48; \
> __ta; \
> })
>
> Thanks,
> Mark.
>
That makes sense and addresses Robin's comment as well. I'll send out a
v2 with your suggestion.
Thanks,
Philip
--
Qualcomm Datacenter Technologies as an affiliate of Qualcomm
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
next prev parent reply other threads:[~2018-03-27 0:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 21:02 [PATCH] arm64: tlbflush: avoid writing RES0 bits Philip Elcan
2018-03-21 21:02 ` Philip Elcan
2018-03-22 18:30 ` Robin Murphy
2018-03-22 18:30 ` Robin Murphy
2018-03-26 10:02 ` Mark Rutland
2018-03-26 10:02 ` Mark Rutland
2018-03-27 0:51 ` Philip Elcan [this message]
2018-03-27 0:51 ` Philip Elcan
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=9624b762-a26e-36da-b0a2-4087f0a2069c@codeaurora.org \
--to=pelcan@codeaurora.org \
--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 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.