forked from luck/tmp_suning_uos_patched
b2fa47e6bf
Rework the architecture page table functions to access the bits in the page table extension array (pgste). There are a number of changes: 1) Fix missing pgste update if the attach_count for the mm is <= 1. 2) For every operation that affects the invalid bit in the pte or the rcp byte in the pgste the pcl lock needs to be acquired. The function pgste_get_lock gets the pcl lock and returns the current pgste value for a pte pointer. The function pgste_set_unlock stores the pgste and releases the lock. Between these two calls the bits in the pgste can be shuffled. 3) Define two software bits in the pte _PAGE_SWR and _PAGE_SWC to avoid calling SetPageDirty and SetPageReferenced from pgtable.h. If the host reference backup bit or the host change backup bit has been set the dirty/referenced state is transfered to the pte. The common code will pick up the state from the pte. 4) Add ptep_modify_prot_start and ptep_modify_prot_commit for mprotect. 5) Remove pgd_populate_kernel, pud_populate_kernel, pmd_populate_kernel pgd_clear_kernel, pud_clear_kernel, pmd_clear_kernel and ptep_invalidate. 6) Rename kvm_s390_test_and_clear_page_dirty to ptep_test_and_clear_user_dirty and add ptep_test_and_clear_user_young. 7) Define mm_exclusive() and mm_has_pgste() helper to improve readability. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
/*
|
|
* Copyright IBM Corp. 2011
|
|
* Author(s): Jan Glauber <jang@linux.vnet.ibm.com>
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/hugetlb.h>
|
|
#include <asm/pgtable.h>
|
|
|
|
static void change_page_attr(unsigned long addr, int numpages,
|
|
pte_t (*set) (pte_t))
|
|
{
|
|
pte_t *ptep, pte;
|
|
pmd_t *pmdp;
|
|
pud_t *pudp;
|
|
pgd_t *pgdp;
|
|
int i;
|
|
|
|
for (i = 0; i < numpages; i++) {
|
|
pgdp = pgd_offset(&init_mm, addr);
|
|
pudp = pud_offset(pgdp, addr);
|
|
pmdp = pmd_offset(pudp, addr);
|
|
if (pmd_huge(*pmdp)) {
|
|
WARN_ON_ONCE(1);
|
|
continue;
|
|
}
|
|
ptep = pte_offset_kernel(pmdp, addr);
|
|
|
|
pte = *ptep;
|
|
pte = set(pte);
|
|
__ptep_ipte(addr, ptep);
|
|
*ptep = pte;
|
|
addr += PAGE_SIZE;
|
|
}
|
|
}
|
|
|
|
int set_memory_ro(unsigned long addr, int numpages)
|
|
{
|
|
change_page_attr(addr, numpages, pte_wrprotect);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(set_memory_ro);
|
|
|
|
int set_memory_rw(unsigned long addr, int numpages)
|
|
{
|
|
change_page_attr(addr, numpages, pte_mkwrite);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(set_memory_rw);
|
|
|
|
/* not possible */
|
|
int set_memory_nx(unsigned long addr, int numpages)
|
|
{
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(set_memory_nx);
|
|
|
|
int set_memory_x(unsigned long addr, int numpages)
|
|
{
|
|
return 0;
|
|
}
|