aboutsummaryrefslogtreecommitdiffstats
path: root/arch/hexagon
diff options
context:
space:
mode:
authorRichard Kuo <rkuo@codeaurora.org>2011-10-31 19:52:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-01 10:34:20 -0400
commit5df87c1556515dfae504da342990821f407a8c99 (patch)
tree9cd922340f301d0ab18cf3280b5c1c9f2df5e4cb /arch/hexagon
parent2d3cbc780437ae4e81f09d0efdd6769852bce5f5 (diff)
Hexagon: Implement basic TLB management routines for Hexagon.
Mostly all stubs, as the TLB is managed by the hypervisor. Signed-off-by: Richard Kuo <rkuo@codeaurora.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/hexagon')
-rw-r--r--arch/hexagon/include/asm/tlb.h39
-rw-r--r--arch/hexagon/include/asm/tlbflush.h58
-rw-r--r--arch/hexagon/mm/vm_tlb.c93
3 files changed, 190 insertions, 0 deletions
diff --git a/arch/hexagon/include/asm/tlb.h b/arch/hexagon/include/asm/tlb.h
new file mode 100644
index 000000000000..473abde01d62
--- /dev/null
+++ b/arch/hexagon/include/asm/tlb.h
@@ -0,0 +1,39 @@
1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301, USA.
17 */
18
19#ifndef _ASM_TLB_H
20#define _ASM_TLB_H
21
22#include <linux/pagemap.h>
23#include <asm/tlbflush.h>
24
25/*
26 * We don't need any special per-pte or per-vma handling...
27 */
28#define tlb_start_vma(tlb, vma) do { } while (0)
29#define tlb_end_vma(tlb, vma) do { } while (0)
30#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
31
32/*
33 * .. because we flush the whole mm when it fills up
34 */
35#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
36
37#include <asm-generic/tlb.h>
38
39#endif
diff --git a/arch/hexagon/include/asm/tlbflush.h b/arch/hexagon/include/asm/tlbflush.h
new file mode 100644
index 000000000000..b89a90251225
--- /dev/null
+++ b/arch/hexagon/include/asm/tlbflush.h
@@ -0,0 +1,58 @@
1/*
2 * TLB flush support for Hexagon
3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21#ifndef _ASM_TLBFLUSH_H
22#define _ASM_TLBFLUSH_H
23
24#include <linux/mm.h>
25#include <asm/processor.h>
26
27/*
28 * TLB flushing -- in "SMP", these routines get defined to be the
29 * ones from smp.c, else they are some local flavors.
30 */
31
32/*
33 * These functions are commonly macros, but in the interests of
34 * VM vs. native implementation and code size, we simply declare
35 * the function prototypes here.
36 */
37extern void tlb_flush_all(void);
38extern void flush_tlb_mm(struct mm_struct *mm);
39extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr);
40extern void flush_tlb_range(struct vm_area_struct *vma,
41 unsigned long start, unsigned long end);
42extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
43extern void flush_tlb_one(unsigned long);
44
45/*
46 * "This is called in munmap when we have freed up some page-table pages.
47 * We don't need to do anything here..."
48 *
49 * The VM kernel doesn't walk page tables, and they are passed to the VMM
50 * by logical address. There doesn't seem to be any possibility that they
51 * could be referenced by the VM kernel based on a stale mapping, since
52 * they would only be located by consulting the mm structure, and they
53 * will have been purged from that structure by the munmap. Seems like
54 * a noop on HVM as well.
55 */
56#define flush_tlb_pgtables(mm, start, end)
57
58#endif
diff --git a/arch/hexagon/mm/vm_tlb.c b/arch/hexagon/mm/vm_tlb.c
new file mode 100644
index 000000000000..c6ff41575461
--- /dev/null
+++ b/arch/hexagon/mm/vm_tlb.c
@@ -0,0 +1,93 @@
1/*
2 * Hexagon Virtual Machine TLB functions
3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21/*
22 * The Hexagon Virtual Machine conceals the real workings of
23 * the TLB, but there are one or two functions that need to
24 * be instantiated for it, differently from a native build.
25 */
26#include <linux/mm.h>
27#include <asm/page.h>
28#include <asm/hexagon_vm.h>
29
30/*
31 * Initial VM implementation has only one map active at a time, with
32 * TLB purgings on changes. So either we're nuking the current map,
33 * or it's a no-op. This operation is messy on true SMPs where other
34 * processors must be induced to flush the copies in their local TLBs,
35 * but Hexagon thread-based virtual processors share the same MMU.
36 */
37void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
38 unsigned long end)
39{
40 struct mm_struct *mm = vma->vm_mm;
41
42 if (mm->context.ptbase == current->active_mm->context.ptbase)
43 __vmclrmap((void *)start, end - start);
44}
45
46/*
47 * Flush a page from the kernel virtual map - used by highmem
48 */
49void flush_tlb_one(unsigned long vaddr)
50{
51 __vmclrmap((void *)vaddr, PAGE_SIZE);
52}
53
54/*
55 * Flush all TLBs across all CPUs, virtual or real.
56 * A single Hexagon core has 6 thread contexts but
57 * only one TLB.
58 */
59void tlb_flush_all(void)
60{
61 /* should probably use that fixaddr end or whateve label */
62 __vmclrmap(0, 0xffff0000);
63}
64
65/*
66 * Flush TLB entries associated with a given mm_struct mapping.
67 */
68void flush_tlb_mm(struct mm_struct *mm)
69{
70 /* Current Virtual Machine has only one map active at a time */
71 if (current->active_mm->context.ptbase == mm->context.ptbase)
72 tlb_flush_all();
73}
74
75/*
76 * Flush TLB state associated with a page of a vma.
77 */
78void flush_tlb_page(struct vm_area_struct *vma, unsigned long vaddr)
79{
80 struct mm_struct *mm = vma->vm_mm;
81
82 if (mm->context.ptbase == current->active_mm->context.ptbase)
83 __vmclrmap((void *)vaddr, PAGE_SIZE);
84}
85
86/*
87 * Flush TLB entries associated with a kernel address range.
88 * Like flush range, but without the check on the vma->vm_mm.
89 */
90void flush_tlb_kernel_range(unsigned long start, unsigned long end)
91{
92 __vmclrmap((void *)start, end - start);
93}