xen-devel
[Xen-devel] [patch 21/34] Xen-pv_ops: Allocate and free vmalloc areas
To: |
Andi Kleen <ak@xxxxxx> |
Subject: |
[Xen-devel] [patch 21/34] Xen-pv_ops: Allocate and free vmalloc areas |
From: |
Jeremy Fitzhardinge <jeremy@xxxxxxxx> |
Date: |
Tue, 13 Mar 2007 16:30:38 -0700 |
Cc: |
Zachary Amsden <zach@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Pratt <ian.pratt@xxxxxxxxxxxxx>, Rusty Russell <rusty@xxxxxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, Jan Beulich <JBeulich@xxxxxxxxxx>, Chris Wright <chrisw@xxxxxxxxxxxx>, virtualization@xxxxxxxxxxxxxx, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Christian Limpach <Christian.Limpach@xxxxxxxxxxxx> |
Delivery-date: |
Tue, 13 Mar 2007 16:40:48 -0700 |
Envelope-to: |
www-data@xxxxxxxxxxxxxxxxxx |
List-help: |
<mailto:xen-devel-request@lists.xensource.com?subject=help> |
List-id: |
Xen developer discussion <xen-devel.lists.xensource.com> |
List-post: |
<mailto:xen-devel@lists.xensource.com> |
List-subscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
List-unsubscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
References: |
<20070313233017.933601256@xxxxxxxx> |
Sender: |
xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
User-agent: |
quilt/0.46-1 |
Allocate/destroy a 'vmalloc' VM area: alloc_vm_area and free_vm_area
The alloc function ensures that page tables are constructed for the
region of kernel virtual address space and mapped into init_mm.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx>
Signed-off-by: Ian Pratt <ian.pratt@xxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxxxx>
Cc: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Cc: "Andi Kleen" <ak@xxxxxx>
---
arch/i386/mm/fault.c | 43 +++++++++++++++++++++++++++++++++++++++++++
include/linux/vmalloc.h | 4 ++++
2 files changed, 47 insertions(+)
===================================================================
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -23,6 +23,7 @@
#include <linux/module.h>
#include <linux/kprobes.h>
#include <linux/uaccess.h>
+#include <linux/vmalloc.h>
#include <asm/system.h>
#include <asm/desc.h>
@@ -624,3 +625,45 @@ void _vmalloc_sync_all(void)
start = address + PGDIR_SIZE;
}
}
+
+
+static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
+{
+ /* apply_to_page_range() does all the hard work. */
+ return 0;
+}
+
+struct vm_struct *alloc_vm_area(unsigned long size)
+{
+ struct vm_struct *area;
+
+ area = get_vm_area(size, VM_IOREMAP);
+ if (area == NULL)
+ return NULL;
+
+ /*
+ * This ensures that page tables are constructed for this region
+ * of kernel virtual address space and mapped into init_mm.
+ */
+ if (apply_to_page_range(&init_mm, (unsigned long)area->addr,
+ area->size, f, NULL)) {
+ free_vm_area(area);
+ return NULL;
+ }
+
+ /* Make sure the pagetables are constructed in process kernel
+ mappings */
+ vmalloc_sync_all();
+
+ return area;
+}
+EXPORT_SYMBOL_GPL(alloc_vm_area);
+
+void free_vm_area(struct vm_struct *area)
+{
+ struct vm_struct *ret;
+ ret = remove_vm_area(area->addr);
+ BUG_ON(ret != area);
+ kfree(area);
+}
+EXPORT_SYMBOL_GPL(free_vm_area);
===================================================================
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -68,6 +68,10 @@ extern int map_vm_area(struct vm_struct
struct page ***pages);
extern void unmap_vm_area(struct vm_struct *area);
+/* Allocate/destroy a 'vmalloc' VM area. */
+extern struct vm_struct *alloc_vm_area(unsigned long size);
+extern void free_vm_area(struct vm_struct *area);
+
/*
* Internals. Dont't use..
*/
--
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [patch 08/34] Xen-pv_ops: Allow paravirt backend to choose kernel PMD sharing, (continued)
- [Xen-devel] [patch 08/34] Xen-pv_ops: Allow paravirt backend to choose kernel PMD sharing, Jeremy Fitzhardinge
- [Xen-devel] [patch 09/34] Xen-pv_ops: add hooks to intercept mm creation and destruction, Jeremy Fitzhardinge
- [Xen-devel] [patch 06/34] Xen-pv_ops: Hooks to set up initial pagetable, Jeremy Fitzhardinge
- [Xen-devel] [patch 07/34] Xen-pv_ops: Allocate a fixmap slot, Jeremy Fitzhardinge
- [Xen-devel] [patch 11/34] Xen-pv_ops: Add smp_ops interface, Jeremy Fitzhardinge
- [Xen-devel] [patch 14/34] Xen-pv_ops: Fix patch site clobbers to include return register, Jeremy Fitzhardinge
- [Xen-devel] [patch 12/34] Xen-pv_ops: rename struct paravirt_patch to paravirt_patch_site for clarity, Jeremy Fitzhardinge
- [Xen-devel] [patch 13/34] Xen-pv_ops: Use patch site IDs computed from offset in paravirt_ops structure, Jeremy Fitzhardinge
- [Xen-devel] [patch 16/34] Xen-pv_ops: add common patching machinery, Jeremy Fitzhardinge
- [Xen-devel] [patch 17/34] Xen-pv_ops: add flush_tlb_others paravirt_op, Jeremy Fitzhardinge
- [Xen-devel] [patch 21/34] Xen-pv_ops: Allocate and free vmalloc areas,
Jeremy Fitzhardinge <=
- [Xen-devel] [patch 15/34] Xen-pv_ops: Consistently wrap paravirt ops callsites to make them patchable, Jeremy Fitzhardinge
- [Xen-devel] [patch 23/34] Xen-pv_ops: Add XEN config options, Jeremy Fitzhardinge
- [Xen-devel] [patch 22/34] Xen-pv_ops: Add nosegneg capability to the vsyscall page notes, Jeremy Fitzhardinge
- [Xen-devel] [patch 18/34] Xen-pv_ops: revert map_pt_hook., Jeremy Fitzhardinge
- [Xen-devel] [patch 20/34] Xen-pv_ops: Add apply_to_page_range() which applies a function to a pte range., Jeremy Fitzhardinge
- [Xen-devel] [patch 19/34] Xen-pv_ops: add kmap_atomic_pte for mapping highpte pages, Jeremy Fitzhardinge
- [Xen-devel] [patch 27/34] Xen-pv_ops: Implement Xen clockevent device, Jeremy Fitzhardinge
- [Xen-devel] [patch 31/34] Xen-pv_ops: Add Xen grant table support, Jeremy Fitzhardinge
- [Xen-devel] [patch 29/34] Xen-pv_ops: Use the hvc console infrastructure for Xen console, Jeremy Fitzhardinge
- [Xen-devel] [patch 30/34] Xen-pv_ops: Add early printk support via hvc console, Jeremy Fitzhardinge
|
|
|