Skip to contentSkip to conversation

linux: User-space grant table device.

Xen-staging Alex Williamson 2 participants 6 messages Mar 31, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Xen staging patchbot-unstable

# HG changeset patch
# User Keir Fraser <[email protected]>
# Date 1175345604 -3600
# Node ID 5e65a86c8982b9159223b542cc7b7e3af61a06e4 # Parent 7180d2e61f926023e24750c53fd4203a71f2a3ae
linux: User-space grant table device.

A character device for accessing (in user-space) pages that have been granted by other domains.

...

Review

Quoted 6 lines
(quoted diff) +6 -0
+	/* This flag ensures that the page tables are not unpinned before the
+	 * VM area is unmapped. Therefore Xen still recognises the PTE as
+	 * belonging to an L1 pagetable, and the grant unmap operation will
+	 * succeed, even if the process does not exit cleanly.
+	 */
+	vma->vm_mm->context.has_foreign_mappings = 1;

mm_context_t is arch specific, common code shouldn't be poking at it
like this.

Alex

Signature · 1 line
Alex Williamson                             HP Open Source & Linux Org.
#2 lore raw
Quoted 9 lines · Alex Williamson

Review

Quoted 6 lines

+ /* This flag ensures that the page tables are not unpinned before the

(quoted diff) +5 -0
+  * VM area is unmapped. Therefore Xen still recognises the PTE as
+  * belonging to an L1 pagetable, and the grant unmap operation will
+  * succeed, even if the process does not exit cleanly.
+  */
+ vma->vm_mm->context.has_foreign_mappings = 1;

mm_context_t is arch specific, common code shouldn't be poking at it
like this.

Good point. That part is entirely x86-specific. I'll add an ifdef.

-- Keir

#3 lore raw
In reply to a message not in the archive
Quoted 13 lines · Xen staging patchbot-unstable
linux-2.6-xen-sparse/drivers/xen/util.c +7 -0
@@ -4,6 +4,23 @@
 #include <linux/vmalloc.h>
 #include <asm/uaccess.h>
 #include <xen/driver_util.h>
+
+struct class *get_xen_class(void)
+{
+	static struct class *xen_class;
+
+	if (xen_class)
+		return xen_class;

linux-2.6-xen-sparse/drivers/xen/util.c line 23

Quoted 10 lines
linux-2.6-xen-sparse/drivers/xen/util.c +10 -0
+
+	xen_class = class_create(THIS_MODULE, "xen");
+	if (IS_ERR(xen_class)) {
+		printk("Failed to create xen sysfs class.\n");
+		xen_class = NULL;
+	}
+
+	return xen_class;
+}
+EXPORT_SYMBOL_GPL(get_xen_class);

Maybe this could be moved to a more common spot since only x86 builds
with CONFIG_XEN_UTIL? Thanks,

Alex

Signature · 1 line
Alex Williamson                             HP Open Source & Linux Org.
#4 lore raw
Quoted 2 lines · Alex Williamson

Maybe this could be moved to a more common spot since only x86 builds
with CONFIG_XEN_UTIL? Thanks,

You can't get much more generic than a file named 'util.c' at the root of drivers/xen.

Everyone should build it and the x86-specific portions (if there really are any -- it all looks pretty generic to me even if no other architectures currently use the functions defined in there) should be ifdef'ed or perhaps relocated to a new file.

-- Keir

#5 lore raw
Quoted 5 lines · Keir Fraser
Quoted 2 lines · Alex Williamson

Maybe this could be moved to a more common spot since only x86 builds
with CONFIG_XEN_UTIL? Thanks,

Quoted 7 lines

You can't get much more generic than a file named 'util.c' at the root of drivers/xen.

Everyone should build it and the x86-specific portions (if there really are any -- it all looks pretty generic to me even if no other architectures currently use the functions defined in there) should be ifdef'ed or perhaps relocated to a new file.

True, util.c ought to be a good place to dump stuff like this.
Unfortunately we define our own alloc/free_vm_area(), so the existing functions in there are the problems. Maybe those should be moved to arch/i386/mach-xen/util.c, or ifdef out as below. Thanks,

Alex

---

linux-2.6-xen-sparse/arch/ia64/Kconfig +1 -1
diff -r fbe52b559161 linux-2.6-xen-sparse/arch/ia64/Kconfig
@@ -577,7 +577,7 @@ source "crypto/Kconfig"
 #
 if XEN
 config XEN_UTIL
-	default n
+	default y
 
 config XEN_BALLOON
 	default y
linux-2.6-xen-sparse/drivers/xen/util.c +4 -0
diff -r fbe52b559161 linux-2.6-xen-sparse/drivers/xen/util.c
@@ -21,6 +21,8 @@ struct class *get_xen_class(void)
 	return xen_class;
 }
 EXPORT_SYMBOL_GPL(get_xen_class);
+
+#ifndef CONFIG_IA64
 
 static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
 {
@@ -63,3 +65,5 @@ void free_vm_area(struct vm_struct *area
 	kfree(area);
 }
 EXPORT_SYMBOL_GPL(free_vm_area);
+
+#endif /* !CONFIG_IA64 */
#6 lore raw
Quoted 9 lines · Alex Williamson
Quoted 4 lines

Everyone should build it and the x86-specific portions (if there really are any -- it all looks pretty generic to me even if no other architectures currently use the functions defined in there) should be ifdef'ed or perhaps relocated to a new file.

True, util.c ought to be a good place to dump stuff like this.
Unfortunately we define our own alloc/free_vm_area(), so the existing functions in there are the problems. Maybe those should be moved to arch/i386/mach-xen/util.c, or ifdef out as below. Thanks,

Oh I see. Actually I think the difference is not strictly architecture-related, but due to the fact that ia64 uses auto-translate, so you need actual pseudophysical addresses relating to the virtual address that is returned. The right answer here is to have a combined function that tests for auto_translated_physmap. Possibly the interface function should even be modified to do allocate-area-and-map, rather than leaving the mapping to a separate function. Anyhow, for now I'll make the 'generic' versions __attribute__((weak)).

-- Keir