~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/ia64/xen/xencomm.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2006 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License as published by
  6  * the Free Software Foundation; either version 2 of the License, or
  7  * (at your option) any later version.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  * GNU General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public License
 15  * along with this program; if not, write to the Free Software
 16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 17  */
 18 
 19 #include <linux/mm.h>
 20 #include <linux/err.h>
 21 
 22 static unsigned long kernel_virtual_offset;
 23 static int is_xencomm_initialized;
 24 
 25 /* for xen early printk. It uses console io hypercall which uses xencomm.
 26  * However early printk may use it before xencomm initialization.
 27  */
 28 int
 29 xencomm_is_initialized(void)
 30 {
 31         return is_xencomm_initialized;
 32 }
 33 
 34 void
 35 xencomm_initialize(void)
 36 {
 37         kernel_virtual_offset = KERNEL_START - ia64_tpa(KERNEL_START);
 38         is_xencomm_initialized = 1;
 39 }
 40 
 41 /* Translate virtual address to physical address.  */
 42 unsigned long
 43 xencomm_vtop(unsigned long vaddr)
 44 {
 45         struct page *page;
 46         struct vm_area_struct *vma;
 47 
 48         if (vaddr == 0)
 49                 return 0UL;
 50 
 51         if (REGION_NUMBER(vaddr) == 5) {
 52                 pgd_t *pgd;
 53                 pud_t *pud;
 54                 pmd_t *pmd;
 55                 pte_t *ptep;
 56 
 57                 /* On ia64, TASK_SIZE refers to current.  It is not initialized
 58                    during boot.
 59                    Furthermore the kernel is relocatable and __pa() doesn't
 60                    work on  addresses.  */
 61                 if (vaddr >= KERNEL_START
 62                     && vaddr < (KERNEL_START + KERNEL_TR_PAGE_SIZE))
 63                         return vaddr - kernel_virtual_offset;
 64 
 65                 /* In kernel area -- virtually mapped.  */
 66                 pgd = pgd_offset_k(vaddr);
 67                 if (pgd_none(*pgd) || pgd_bad(*pgd))
 68                         return ~0UL;
 69 
 70                 pud = pud_offset(pgd, vaddr);
 71                 if (pud_none(*pud) || pud_bad(*pud))
 72                         return ~0UL;
 73 
 74                 pmd = pmd_offset(pud, vaddr);
 75                 if (pmd_none(*pmd) || pmd_bad(*pmd))
 76                         return ~0UL;
 77 
 78                 ptep = pte_offset_kernel(pmd, vaddr);
 79                 if (!ptep)
 80                         return ~0UL;
 81 
 82                 return (pte_val(*ptep) & _PFN_MASK) | (vaddr & ~PAGE_MASK);
 83         }
 84 
 85         if (vaddr > TASK_SIZE) {
 86                 /* percpu variables */
 87                 if (REGION_NUMBER(vaddr) == 7 &&
 88                     REGION_OFFSET(vaddr) >= (1ULL << IA64_MAX_PHYS_BITS))
 89                         ia64_tpa(vaddr);
 90 
 91                 /* kernel address */
 92                 return __pa(vaddr);
 93         }
 94 
 95         /* XXX double-check (lack of) locking */
 96         vma = find_extend_vma(current->mm, vaddr);
 97         if (!vma)
 98                 return ~0UL;
 99 
100         /* We assume the page is modified.  */
101         page = follow_page(vma, vaddr, FOLL_WRITE | FOLL_TOUCH);
102         if (IS_ERR_OR_NULL(page))
103                 return ~0UL;
104 
105         return (page_to_pfn(page) << PAGE_SHIFT) | (vaddr & ~PAGE_MASK);
106 }
107 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp