blob: bc6d04a098998b5079a4e5e652d0ce540b0fafba [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Russell King4baa9922008-08-02 10:55:55 +01002 * arch/arm/include/asm/tlb.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 2002 Russell King
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 as
8 * published by the Free Software Foundation.
9 *
10 * Experimentation shows that on a StrongARM, it appears to be faster
11 * to use the "invalidate whole tlb" rather than "invalidate single
12 * tlb" for this.
13 *
14 * This appears true for both the process fork+exit case, as well as
15 * the munmap-large-area case.
16 */
17#ifndef __ASMARM_TLB_H
18#define __ASMARM_TLB_H
19
20#include <asm/cacheflush.h>
Hyok S. Choi01579032006-02-24 21:41:25 +000021
22#ifndef CONFIG_MMU
23
24#include <linux/pagemap.h>
Russell King58e9c472011-02-20 12:27:49 +000025
26#define tlb_flush(tlb) ((void) tlb)
27
Hyok S. Choi01579032006-02-24 21:41:25 +000028#include <asm-generic/tlb.h>
29
30#else /* !CONFIG_MMU */
31
Russell King06824ba2011-02-20 12:16:45 +000032#include <linux/swap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/pgalloc.h>
Russell King06824ba2011-02-20 12:16:45 +000034#include <asm/tlbflush.h>
35
Steve Cappera0ad5492014-10-09 15:29:18 -070036static inline void __tlb_remove_table(void *_table)
37{
38 free_page_and_swap_cache((struct page *)_table);
39}
40
Peter Zijlstrab78180b2018-09-04 14:09:30 +020041#include <asm-generic/tlb.h>
Steve Cappera0ad5492014-10-09 15:29:18 -070042
Peter Zijlstrab78180b2018-09-04 14:09:30 +020043#ifndef CONFIG_HAVE_RCU_TABLE_FREE
44#define tlb_remove_table(tlb, entry) tlb_remove_page(tlb, entry)
Steve Cappera0ad5492014-10-09 15:29:18 -070045#endif
Linus Torvalds1cf35d42014-04-25 16:05:40 -070046
Peter Zijlstra9e14f672011-05-24 17:11:53 -070047static inline void
Peter Zijlstrab78180b2018-09-04 14:09:30 +020048__pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr)
Russell King06824ba2011-02-20 12:16:45 +000049{
50 pgtable_page_dtor(pte);
Catalin Marinas6d3ec1a2012-01-25 11:54:22 +010051
Peter Zijlstrab78180b2018-09-04 14:09:30 +020052#ifndef CONFIG_ARM_LPAE
Catalin Marinas6d3ec1a2012-01-25 11:54:22 +010053 /*
54 * With the classic ARM MMU, a pte page has two corresponding pmd
55 * entries, each covering 1MB.
56 */
Peter Zijlstrab78180b2018-09-04 14:09:30 +020057 addr = (addr & PMD_MASK) + SZ_1M;
58 __tlb_adjust_range(tlb, addr - PAGE_SIZE, 2 * PAGE_SIZE);
Will Deacondf547e02012-08-24 15:23:06 +010059#endif
Catalin Marinas6d3ec1a2012-01-25 11:54:22 +010060
Peter Zijlstrab78180b2018-09-04 14:09:30 +020061 tlb_remove_table(tlb, pte);
Catalin Marinasc9f27f12011-11-22 17:30:29 +000062}
63
Catalin Marinas8d962502012-07-25 14:39:26 +010064static inline void
Peter Zijlstrab78180b2018-09-04 14:09:30 +020065__pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr)
Catalin Marinas8d962502012-07-25 14:39:26 +010066{
Peter Zijlstrab78180b2018-09-04 14:09:30 +020067#ifdef CONFIG_ARM_LPAE
68 struct page *page = virt_to_page(pmdp);
Catalin Marinas8d962502012-07-25 14:39:26 +010069
Peter Zijlstrab78180b2018-09-04 14:09:30 +020070 tlb_remove_table(tlb, page);
71#endif
Anders Roxell063daa82018-07-25 11:55:57 +020072}
73
Hyok S. Choi01579032006-02-24 21:41:25 +000074#endif /* CONFIG_MMU */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#endif