LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Zhenyu Ye <yezhenyu2@huawei.com>
To: <mark.rutland@arm.com>, <catalin.marinas@arm.com>,
<will@kernel.org>, <aneesh.kumar@linux.ibm.com>, <maz@kernel.org>,
<steven.price@arm.com>, <broonie@kernel.org>,
<guohanjun@huawei.com>
Cc: <yezhenyu2@huawei.com>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-arch@vger.kernel.org>,
<linux-mm@kvack.org>, <arm@kernel.org>, <xiexiangyou@huawei.com>,
<prime.zeng@hisilicon.com>
Subject: [RFC PATCH v1 2/3] arm64: tlb: use mm_struct.context.flags to indicate TTL
Date: Wed, 11 Mar 2020 10:53:08 +0800 [thread overview]
Message-ID: <20200311025309.1743-3-yezhenyu2@huawei.com> (raw)
In-Reply-To: <20200311025309.1743-1-yezhenyu2@huawei.com>
Use Architecture-specific MM context to indicate the level of page
table walk. This avoids lots of changes to common-interface.
Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>
---
arch/arm64/include/asm/mmu.h | 11 +++++++++++
arch/arm64/include/asm/tlbflush.h | 8 +++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index e4d862420bb4..7410d2997c2a 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -8,6 +8,10 @@
#include <asm/cputype.h>
#define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */
+#define TLBI_LEVEL_1 0x10 /* mm context flag for the level of ptw */
+#define TLBI_LEVEL_2 0x20
+#define TLBI_LEVEL_3 0x30
+
#define USER_ASID_BIT 48
#define USER_ASID_FLAG (UL(1) << USER_ASID_BIT)
#define TTBR_ASID_MASK (UL(0xffff) << 48)
@@ -19,6 +23,10 @@
typedef struct {
atomic64_t id;
void *vdso;
+ /*
+ * flags[3:0]: AArch32 executables
+ * flags[7:4]: the level of page table walk
+ */
unsigned long flags;
} mm_context_t;
@@ -29,6 +37,9 @@ typedef struct {
*/
#define ASID(mm) ((mm)->context.id.counter & 0xffff)
+/* This macro is only used by TLBI TTL */
+#define TLBI_LEVEL(mm) ((mm)->context.flags >> 4 & 0xf)
+
extern bool arm64_use_ng_mappings;
static inline bool arm64_kernel_unmapped_at_el0(void)
diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
index 10b12710b7cc..9f02a5383ac3 100644
--- a/arch/arm64/include/asm/tlbflush.h
+++ b/arch/arm64/include/asm/tlbflush.h
@@ -172,7 +172,8 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
static inline void flush_tlb_page_nosync(struct vm_area_struct *vma,
unsigned long uaddr)
{
- unsigned long addr = __TLBI_VADDR(uaddr, ASID(vma->vm_mm), 0);
+ unsigned long ttl = (__TLB_TG << 2) + TLBI_LEVEL(vma->vm_mm);
+ unsigned long addr = __TLBI_VADDR(uaddr, ASID(vma->vm_mm), ttl);
dsb(ishst);
__tlbi(vale1is, addr);
@@ -197,6 +198,7 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma,
unsigned long stride, bool last_level)
{
unsigned long asid = ASID(vma->vm_mm);
+ unsigned long ttl = (__TLB_TG << 2) + TLBI_LEVEL(vma->vm_mm);
unsigned long addr;
start = round_down(start, stride);
@@ -210,8 +212,8 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma,
/* Convert the stride into units of 4k */
stride >>= 12;
- start = __TLBI_VADDR(start, asid, 0);
- end = __TLBI_VADDR(end, asid, 0);
+ start = __TLBI_VADDR(start, asid, ttl);
+ end = __TLBI_VADDR(end, asid, ttl);
dsb(ishst);
for (addr = start; addr < end; addr += stride) {
--
2.19.1
next prev parent reply other threads:[~2020-03-11 2:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 2:53 [RFC PATCH v1 0/3] arm64: tlb: add support for TTL field Zhenyu Ye
2020-03-11 2:53 ` [RFC PATCH v1 1/3] arm64: tlb: add TTL field to __TLBI_ADDR Zhenyu Ye
2020-03-11 2:53 ` Zhenyu Ye [this message]
2020-03-11 2:53 ` [RFC PATCH v1 3/3] arm64: tlb: add support for TTL in some functions Zhenyu Ye
2020-03-11 9:12 ` [RFC PATCH v1 0/3] arm64: tlb: add support for TTL field Marc Zyngier
2020-03-11 11:29 ` yezhenyu (A)
2020-03-17 10:59 ` yezhenyu (A)
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=20200311025309.1743-3-yezhenyu2@huawei.com \
--to=yezhenyu2@huawei.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=arm@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=guohanjun@huawei.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=prime.zeng@hisilicon.com \
--cc=steven.price@arm.com \
--cc=will@kernel.org \
--cc=xiexiangyou@huawei.com \
--subject='Re: [RFC PATCH v1 2/3] arm64: tlb: use mm_struct.context.flags to indicate TTL' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).