aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/xen
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2008-10-16 22:17:53 -0400
committerTony Luck <tony.luck@intel.com>2008-10-17 12:59:40 -0400
commit11d437789d0f35fa2e2ebcb4a983b29587bdfdc5 (patch)
treeecf326dd5ea4db33d33bb1a2f8d4a670b9ab1454 /arch/ia64/xen
parented50bd6096dab96e4c501d600776b75687dd2cf0 (diff)
ia64/xen: implement the arch specific part of xencomm.
On ia64/xen, pointer argument for the hypercall is passed by pseudo physical address (guest physical address.) So it is necessary to convert virtual address into pseudo physical address right before issuing hypercall. The frame work is called xencomm. This patch implements arch specific part. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Cc: Akio Takebe <takebe_akio@jp.fujitsu.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64/xen')
-rw-r--r--arch/ia64/xen/Makefile2
-rw-r--r--arch/ia64/xen/xencomm.c94
2 files changed, 95 insertions, 1 deletions
diff --git a/arch/ia64/xen/Makefile b/arch/ia64/xen/Makefile
index c200704e2333..ad0c9f7ddffa 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
@@ -2,4 +2,4 @@
2# Makefile for Xen components 2# Makefile for Xen components
3# 3#
4 4
5obj-y := hypercall.o 5obj-y := hypercall.o xencomm.o
diff --git a/arch/ia64/xen/xencomm.c b/arch/ia64/xen/xencomm.c
new file mode 100644
index 000000000000..3dc307f0a40d
--- /dev/null
+++ b/arch/ia64/xen/xencomm.c
@@ -0,0 +1,94 @@
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
21static unsigned long kernel_virtual_offset;
22
23void
24xencomm_initialize(void)
25{
26 kernel_virtual_offset = KERNEL_START - ia64_tpa(KERNEL_START);
27}
28
29/* Translate virtual address to physical address. */
30unsigned long
31xencomm_vtop(unsigned long vaddr)
32{
33 struct page *page;
34 struct vm_area_struct *vma;
35
36 if (vaddr == 0)
37 return 0UL;
38
39 if (REGION_NUMBER(vaddr) == 5) {
40 pgd_t *pgd;
41 pud_t *pud;
42 pmd_t *pmd;
43 pte_t *ptep;
44
45 /* On ia64, TASK_SIZE refers to current. It is not initialized
46 during boot.
47 Furthermore the kernel is relocatable and __pa() doesn't
48 work on addresses. */
49 if (vaddr >= KERNEL_START
50 && vaddr < (KERNEL_START + KERNEL_TR_PAGE_SIZE))
51 return vaddr - kernel_virtual_offset;
52
53 /* In kernel area -- virtually mapped. */
54 pgd = pgd_offset_k(vaddr);
55 if (pgd_none(*pgd) || pgd_bad(*pgd))
56 return ~0UL;
57
58 pud = pud_offset(pgd, vaddr);
59 if (pud_none(*pud) || pud_bad(*pud))
60 return ~0UL;
61
62 pmd = pmd_offset(pud, vaddr);
63 if (pmd_none(*pmd) || pmd_bad(*pmd))
64 return ~0UL;
65
66 ptep = pte_offset_kernel(pmd, vaddr);
67 if (!ptep)
68 return ~0UL;
69
70 return (pte_val(*ptep) & _PFN_MASK) | (vaddr & ~PAGE_MASK);
71 }
72
73 if (vaddr > TASK_SIZE) {
74 /* percpu variables */
75 if (REGION_NUMBER(vaddr) == 7 &&
76 REGION_OFFSET(vaddr) >= (1ULL << IA64_MAX_PHYS_BITS))
77 ia64_tpa(vaddr);
78
79 /* kernel address */
80 return __pa(vaddr);
81 }
82
83 /* XXX double-check (lack of) locking */
84 vma = find_extend_vma(current->mm, vaddr);
85 if (!vma)
86 return ~0UL;
87
88 /* We assume the page is modified. */
89 page = follow_page(vma, vaddr, FOLL_WRITE | FOLL_TOUCH);
90 if (!page)
91 return ~0UL;
92
93 return (page_to_pfn(page) << PAGE_SHIFT) | (vaddr & ~PAGE_MASK);
94}