mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 19:31:53 +00:00
1299ef1d88
flush_tlb_single() and flush_tlb_one() sound almost identical, but they really mean "flush one user translation" and "flush one kernel translation". Rename them to flush_tlb_one_user() and flush_tlb_one_kernel() to make the semantics more obvious. [ I was looking at some PTI-related code, and the flush-one-address code is unnecessarily hard to understand because the names of the helpers are uninformative. This came up during PTI review, but no one got around to doing it. ] Signed-off-by: Andy Lutomirski <luto@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Eduardo Valentin <eduval@amazon.com> Cc: Hugh Dickins <hughd@google.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Kees Cook <keescook@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Linux-MM <linux-mm@kvack.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will.deacon@arm.com> Link: http://lkml.kernel.org/r/3303b02e3c3d049dc5235d5651e0ae6d29a34354.1517414378.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
106 lines
2.3 KiB
C
106 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/sched.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/nmi.h>
|
|
#include <linux/swap.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <asm/cpu_entry_area.h>
|
|
#include <asm/pgtable.h>
|
|
#include <asm/pgalloc.h>
|
|
#include <asm/fixmap.h>
|
|
#include <asm/e820/api.h>
|
|
#include <asm/tlb.h>
|
|
#include <asm/tlbflush.h>
|
|
#include <asm/io.h>
|
|
|
|
unsigned int __VMALLOC_RESERVE = 128 << 20;
|
|
|
|
/*
|
|
* Associate a virtual page frame with a given physical page frame
|
|
* and protection flags for that frame.
|
|
*/
|
|
void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
|
|
{
|
|
pgd_t *pgd;
|
|
p4d_t *p4d;
|
|
pud_t *pud;
|
|
pmd_t *pmd;
|
|
pte_t *pte;
|
|
|
|
pgd = swapper_pg_dir + pgd_index(vaddr);
|
|
if (pgd_none(*pgd)) {
|
|
BUG();
|
|
return;
|
|
}
|
|
p4d = p4d_offset(pgd, vaddr);
|
|
if (p4d_none(*p4d)) {
|
|
BUG();
|
|
return;
|
|
}
|
|
pud = pud_offset(p4d, vaddr);
|
|
if (pud_none(*pud)) {
|
|
BUG();
|
|
return;
|
|
}
|
|
pmd = pmd_offset(pud, vaddr);
|
|
if (pmd_none(*pmd)) {
|
|
BUG();
|
|
return;
|
|
}
|
|
pte = pte_offset_kernel(pmd, vaddr);
|
|
if (!pte_none(pteval))
|
|
set_pte_at(&init_mm, vaddr, pte, pteval);
|
|
else
|
|
pte_clear(&init_mm, vaddr, pte);
|
|
|
|
/*
|
|
* It's enough to flush this one mapping.
|
|
* (PGE mappings get flushed as well)
|
|
*/
|
|
__flush_tlb_one_kernel(vaddr);
|
|
}
|
|
|
|
unsigned long __FIXADDR_TOP = 0xfffff000;
|
|
EXPORT_SYMBOL(__FIXADDR_TOP);
|
|
|
|
/*
|
|
* vmalloc=size forces the vmalloc area to be exactly 'size'
|
|
* bytes. This can be used to increase (or decrease) the
|
|
* vmalloc area - the default is 128m.
|
|
*/
|
|
static int __init parse_vmalloc(char *arg)
|
|
{
|
|
if (!arg)
|
|
return -EINVAL;
|
|
|
|
/* Add VMALLOC_OFFSET to the parsed value due to vm area guard hole*/
|
|
__VMALLOC_RESERVE = memparse(arg, &arg) + VMALLOC_OFFSET;
|
|
return 0;
|
|
}
|
|
early_param("vmalloc", parse_vmalloc);
|
|
|
|
/*
|
|
* reservetop=size reserves a hole at the top of the kernel address space which
|
|
* a hypervisor can load into later. Needed for dynamically loaded hypervisors,
|
|
* so relocating the fixmap can be done before paging initialization.
|
|
*/
|
|
static int __init parse_reservetop(char *arg)
|
|
{
|
|
unsigned long address;
|
|
|
|
if (!arg)
|
|
return -EINVAL;
|
|
|
|
address = memparse(arg, &arg);
|
|
reserve_top_address(address);
|
|
early_ioremap_init();
|
|
return 0;
|
|
}
|
|
early_param("reservetop", parse_reservetop);
|