From b6de164e9a84ed2672864778e02613d16b6f9e09 Mon Sep 17 00:00:00 2001 From: "TOIDA,Suguru" Date: Fri, 30 Nov 2018 09:17:54 +0900 Subject: [PATCH] ContiguousPTE[2/12] modify copy_user_pte Change-Id: Ie696245a8c09e87c48426bc3e74a6f049a085471 --- arch/x86_64/kernel/include/arch-memory.h | 86 ++++++++++++++++++++++++ kernel/process.c | 17 ++++- 2 files changed, 101 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/kernel/include/arch-memory.h b/arch/x86_64/kernel/include/arch-memory.h index b3b931cb..79e31ae9 100644 --- a/arch/x86_64/kernel/include/arch-memory.h +++ b/arch/x86_64/kernel/include/arch-memory.h @@ -332,6 +332,92 @@ static inline void pte_set_dirty(pte_t *ptep, size_t pgsize) return; } +static inline int pte_is_contiguous(pte_t *ptep) +{ + return 0; +} + +static inline int pgsize_is_contiguous(size_t pgsize) +{ + return 0; +} + +static inline int pgsize_to_tbllv(size_t pgsize) +{ + switch (pgsize) { + case PTL1_SIZE: return 1; + case PTL2_SIZE: return 2; + case PTL3_SIZE: return 3; + case PTL4_SIZE: return 4; + default: +#if 0 /* XXX: workaround. cannot use panic() here */ + panic("pgsize_to_tbllv"); +#else + return 0; +#endif + } + return 0; +} + +static inline size_t tbllv_to_pgsize(int level) +{ + switch (level) { + case 1: return PTL1_SIZE; + case 2: return PTL2_SIZE; + case 3: return PTL3_SIZE; + case 4: return PTL4_SIZE; + default: +#if 0 /* XXX: workaround. cannot use panic() here */ + panic("tbllv_to_pgsize"); +#else + return 0; +#endif + } + return 0; +} + +static inline size_t tbllv_to_contpgsize(int level) +{ + return 0; +} + +static inline int tbllv_to_contpgshift(int level) +{ + return 0; +} + +static inline pte_t *get_contiguous_head(pte_t *__ptep, size_t __pgsize) +{ + return __ptep; +} + +static inline pte_t *get_contiguous_tail(pte_t *__ptep, size_t __pgsize) +{ + return __ptep; +} + +static inline int split_contiguous_pages(pte_t *ptep, size_t pgsize) +{ + return 0; +} + +static inline int page_is_contiguous_head(pte_t *ptep, size_t pgsize) +{ + return 0; +} + +static inline int page_is_contiguous_tail(pte_t *ptep, size_t pgsize) +{ + return 0; +} + +static inline void arch_adjust_allocate_page_size(uintptr_t fault_addr, + pte_t *ptep, + void **pgaddrp, + size_t *pgsizep) +{ +} + struct page_table; void set_pte(pte_t *ppte, unsigned long phys, enum ihk_mc_pt_attribute attr); pte_t *get_pte(struct page_table *pt, void *virt, enum ihk_mc_pt_attribute attr); diff --git a/kernel/process.c b/kernel/process.c index 387d74b7..90507f23 100644 --- a/kernel/process.c +++ b/kernel/process.c @@ -646,11 +646,11 @@ static int copy_user_pte(void *arg0, page_table_t src_pt, pte_t *src_ptep, void intptr_t src_phys; struct page *src_page; void *src_kvirt; - const size_t pgsize = (size_t)1 << pgshift; + size_t pgsize = (size_t)1 << pgshift; int npages; void *virt = NULL; intptr_t phys; - const int pgalign = pgshift - PAGE_SHIFT; + int pgalign = pgshift - PAGE_SHIFT; enum ihk_mc_pt_attribute attr; if (!pte_is_present(src_ptep)) { @@ -672,6 +672,19 @@ static int copy_user_pte(void *arg0, page_table_t src_pt, pte_t *src_ptep, void attr = pte_get_attr(src_ptep, pgsize); } else { + if (pte_is_contiguous(src_ptep)) { + if (page_is_contiguous_head(src_ptep, pgsize)) { + int level = pgsize_to_tbllv(pgsize); + + pgsize = tbllv_to_contpgsize(level); + pgalign = tbllv_to_contpgshift(level); + pgalign -= PAGE_SHIFT; + } else { + error = 0; + goto out; + } + } + dkprintf("copy_user_pte(): 0x%lx PTE found\n", pgaddr); dkprintf("copy_user_pte(): page size: %d\n", pgsize);