mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 23:33:22 +07:00
981bbf274b
In our stress test, we found some crash problem caused by: if (!(vma->vm_flags & VM_EXEC)) return; in update_mmu_cache(). Seems current update_mmu_cache implementation is wrong and we retread to the conservative implementation. Also the usage of kmap_atomic in update_mmu_cache is risky, page-virtual may be scheduled out and changed, so we must use preempt_disable & pagefault_disable which is called by kmap_atomic(). Signed-off-by: Guo Ren <ren_guo@c-sky.com> Cc: Arnd Bergmann <arnd@arndb.de>
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
|
|
|
|
#include <linux/cache.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/mm.h>
|
|
#include <asm/cache.h>
|
|
|
|
void flush_icache_page(struct vm_area_struct *vma, struct page *page)
|
|
{
|
|
unsigned long start;
|
|
|
|
start = (unsigned long) kmap_atomic(page);
|
|
|
|
cache_wbinv_range(start, start + PAGE_SIZE);
|
|
|
|
kunmap_atomic((void *)start);
|
|
}
|
|
|
|
void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
|
|
unsigned long vaddr, int len)
|
|
{
|
|
unsigned long kaddr;
|
|
|
|
kaddr = (unsigned long) kmap_atomic(page) + (vaddr & ~PAGE_MASK);
|
|
|
|
cache_wbinv_range(kaddr, kaddr + len);
|
|
|
|
kunmap_atomic((void *)kaddr);
|
|
}
|
|
|
|
void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
|
|
pte_t *pte)
|
|
{
|
|
unsigned long addr, pfn;
|
|
struct page *page;
|
|
|
|
pfn = pte_pfn(*pte);
|
|
if (unlikely(!pfn_valid(pfn)))
|
|
return;
|
|
|
|
page = pfn_to_page(pfn);
|
|
if (page == ZERO_PAGE(0))
|
|
return;
|
|
|
|
addr = (unsigned long) kmap_atomic(page);
|
|
|
|
cache_wbinv_range(addr, addr + PAGE_SIZE);
|
|
|
|
kunmap_atomic((void *) addr);
|
|
}
|