2017-07-11 08:02:19 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation, version 2.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_RISCV_TLBFLUSH_H
|
|
|
|
#define _ASM_RISCV_TLBFLUSH_H
|
|
|
|
|
2017-10-26 04:30:32 +07:00
|
|
|
#include <linux/mm_types.h>
|
2018-10-03 02:15:05 +07:00
|
|
|
#include <asm/smp.h>
|
2017-10-26 04:30:32 +07:00
|
|
|
|
2017-11-29 05:06:17 +07:00
|
|
|
/*
|
|
|
|
* Flush entire local TLB. 'sfence.vma' implicitly fences with the instruction
|
|
|
|
* cache as well, so a 'fence.i' is not necessary.
|
|
|
|
*/
|
2017-07-11 08:02:19 +07:00
|
|
|
static inline void local_flush_tlb_all(void)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ ("sfence.vma" : : : "memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flush one page from local TLB */
|
|
|
|
static inline void local_flush_tlb_page(unsigned long addr)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
|
|
|
|
#define flush_tlb_all() local_flush_tlb_all()
|
|
|
|
#define flush_tlb_page(vma, addr) local_flush_tlb_page(addr)
|
2017-10-26 15:53:40 +07:00
|
|
|
|
|
|
|
static inline void flush_tlb_range(struct vm_area_struct *vma,
|
|
|
|
unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
local_flush_tlb_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define flush_tlb_mm(mm) flush_tlb_all()
|
2017-07-11 08:02:19 +07:00
|
|
|
|
|
|
|
#else /* CONFIG_SMP */
|
|
|
|
|
|
|
|
#include <asm/sbi.h>
|
|
|
|
|
2018-10-03 02:15:05 +07:00
|
|
|
static inline void remote_sfence_vma(struct cpumask *cmask, unsigned long start,
|
|
|
|
unsigned long size)
|
|
|
|
{
|
|
|
|
struct cpumask hmask;
|
|
|
|
|
|
|
|
cpumask_clear(&hmask);
|
|
|
|
riscv_cpuid_to_hartid_mask(cmask, &hmask);
|
|
|
|
sbi_remote_sfence_vma(hmask.bits, start, size);
|
|
|
|
}
|
|
|
|
|
2018-06-01 22:21:21 +07:00
|
|
|
#define flush_tlb_all() sbi_remote_sfence_vma(NULL, 0, -1)
|
2017-07-11 08:02:19 +07:00
|
|
|
#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0)
|
|
|
|
#define flush_tlb_range(vma, start, end) \
|
2018-10-03 02:15:05 +07:00
|
|
|
remote_sfence_vma(mm_cpumask((vma)->vm_mm), start, (end) - (start))
|
2017-10-26 15:53:40 +07:00
|
|
|
#define flush_tlb_mm(mm) \
|
2018-10-03 02:15:05 +07:00
|
|
|
remote_sfence_vma(mm_cpumask(mm), 0, -1)
|
2017-07-11 08:02:19 +07:00
|
|
|
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
|
|
|
/* Flush a range of kernel pages */
|
|
|
|
static inline void flush_tlb_kernel_range(unsigned long start,
|
|
|
|
unsigned long end)
|
|
|
|
{
|
|
|
|
flush_tlb_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _ASM_RISCV_TLBFLUSH_H */
|