Skip to contentSkip to conversation

PATCH: xencomm - kernel side

PATCH Tristan Gingold 2 participants 4 messages Aug 23, 2006 – Aug 24, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

taking into account Hollis comments I now submit this patch.

IA64 specific stuff will be posted to xen-ia64-unstable after merge.

Tristan.

# HG changeset patch
# User gingold@virtu10
# Node ID ba96f5f81464dc3db80af0454fb05c73de620637 # Parent cc7a78171c811b9caa5587a0141d8c8477d10ce8 Xencomm support in linux kernel:
* descriptor creation and destruction
* transformation of kernels hypercalls
* transformation of privcmd issued hypercalls.

It must be enabled by architecture config.

linux-2.6-xen-sparse/drivers/xen/Kconfig +3 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/drivers/xen/Kconfig
@@ -257,4 +257,7 @@ config XEN_SMPBOOT
 	default y
 	depends on SMP
 
+config XEN_XENCOMM
+	bool
+	default n
 endif
linux-2.6-xen-sparse/drivers/xen/core/Makefile +1 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/drivers/xen/core/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_XEN_SKBUFF)	+= skbuff.o
 obj-$(CONFIG_XEN_SKBUFF)	+= skbuff.o
 obj-$(CONFIG_XEN_REBOOT)	+= reboot.o
 obj-$(CONFIG_XEN_SMPBOOT)	+= smpboot.o
+obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o xencomm_hcall.o
linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile +2 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile
@@ -1,1 +1,3 @@ obj-y				:= privcmd.o
 obj-y				:= privcmd.o
+
+obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o
linux-2.6-xen-sparse/drivers/xen/core/xencomm.c new file +163 -0

163 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/core/xencomm_hcall.c new file +281 -0

281 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/privcmd/xencomm.c new file +359 -0

359 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-ia64/xen/xencomm.h new file +26 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/include/asm-ia64/xen/xencomm.h
@@ -0,0 +1,26 @@
+#ifndef _ASM_IA64_XEN_XENCOMM_H
+#define _ASM_IA64_XEN_XENCOMM_H
+
+/* Written by Tristan Gingold <[email protected]>
+   Define xen_vaddr_to_paddr.
+   This file is included only by drivers/xen/core/xencomm.c
+*/
+
+extern unsigned long kernel_start_pa;
+
+static unsigned long xen_generic_vaddr_to_paddr(unsigned long vaddr);
+
+static unsigned long xen_vaddr_to_paddr(unsigned long vaddr)
+{
+	/* On ia64, TASK_SIZE refers to current.  It is not initialized
+	   during boot.
+	   Furthermore the kernel is relocatable and __pa() doesn't work on
+	   kernel addresses.  */
+	if (vaddr >= KERNEL_START
+	    && vaddr < (KERNEL_START + KERNEL_TR_PAGE_SIZE)) {
+		return vaddr - kernel_start_pa;
+	}
+	return xen_generic_vaddr_to_paddr(vaddr);
+}
+
+#endif /* _ASM_IA64_XEN_XENCOMM_H */
linux-2.6-xen-sparse/include/xen/xencomm.h new file +36 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/include/xen/xencomm.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Hollis Blanchard <[email protected]>, IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#ifndef _LINUX_XENCOMM_H_
+#define _LINUX_XENCOMM_H_
+
+#include <xen/interface/xencomm.h>
+
+/* To avoid additionnal virt to phys conversion, an opaque structure is
+   presented.  */
+struct xencomm_handle;
+
+extern int xencomm_create(void *buffer, unsigned long bytes,
+			  struct xencomm_handle **desc, gfp_t type);
+extern void xencomm_free(struct xencomm_handle *desc);
+struct xencomm_handle *xencomm_create_inline (void *buffer,
+					      unsigned long bytes);
+
+#define xen_guest_handle(hnd)  ((hnd).p)
+
+#endif /* _LINUX_XENCOMM_H_ */
linux-2.6-xen-sparse/include/xen/xencomm_hcall.h new file +45 -0

45 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 4 lines · Tristan Gingold

taking into account Hollis comments I now submit this patch.

IA64 specific stuff will be posted to xen-ia64-unstable after merge.

NAK pending outcome of other comments.

Also, please let me add my own Signed-off-by line -- that way we'll know that I agree the patch is in fact final (which I don't right now).

There is at least a "/* XXX could we call this from irq context? */" comment that needs removal. I didn't check the rest of the patch to see if you'd followed all my other suggestions.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#2 lore raw
Quoted 5 lines · Hollis Blanchard
Quoted 3 lines · Tristan Gingold

taking into account Hollis comments I now submit this patch.

IA64 specific stuff will be posted to xen-ia64-unstable after merge.

Quoted 8 lines

NAK pending outcome of other comments.

Also, please let me add my own Signed-off-by line -- that way we'll know that I agree the patch is in fact final (which I don't right now).

There is at least a "/* XXX could we call this from irq context? */" comment that needs removal. I didn't check the rest of the patch to see if you'd followed all my other suggestions.

I think the comment could be removed as this is never call during irq.

Here are the full patches (common and ia64). Only the common patches (mainly 11059) was formally submitted.

Tristan.

# HG changeset patch
# User gingold@virtu10
# Node ID 80137e1a97cf27e026e6eb6a51a5757e160e979a # Parent f32793cae274028d939dba4909be280c9df712a5 linux-ia64

linux-2.6-xen-sparse/arch/ia64/Kconfig +3 -0
diff -r f32793cae274 -r 80137e1a97cf linux-2.6-xen-sparse/arch/ia64/Kconfig
@@ -530,6 +530,9 @@ config XEN_REBOOT
 
 config XEN_SMPBOOT
 	default n
+
+config XEN_XENCOMM
+	default y
 endif
 
 source "drivers/xen/Kconfig"
linux-2.6-xen-sparse/arch/ia64/kernel/setup.c +3 -0
diff -r f32793cae274 -r 80137e1a97cf linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
@@ -76,6 +76,8 @@ EXPORT_SYMBOL(__per_cpu_offset);
 #endif
 
 #ifdef CONFIG_XEN
+unsigned long kernel_start_pa;
+
 static int
 xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
@@ -433,6 +435,7 @@ setup_arch (char **cmdline_p)
 
 #ifdef CONFIG_XEN
 	if (is_running_on_xen()) {
+		kernel_start_pa = KERNEL_START - ia64_tpa (KERNEL_START);
 		setup_xen_features();
 		/* Register a call for panic conditions. */
 		notifier_chain_register(&panic_notifier_list, &xen_panic_block);
linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c +2 -26
diff -r f32793cae274 -r 80137e1a97cf linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c
@@ -70,7 +70,7 @@ ia64_xenmem_reservation_op(unsigned long
 		reservation.nr_extents = nr_extents;
 
 		dummy = frame_list[0];// re-install tlb entry before hypercall
-		tmp_ret = ____HYPERVISOR_memory_op(op, &reservation);
+		tmp_ret = xencomm_hypercall_memory_op(op, &reservation);
 		if (tmp_ret < 0) {
 			if (ret == 0) {
 				ret = tmp_ret;
@@ -371,8 +371,6 @@ int
 int
 HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count)
 {
-	__u64 va1, va2, pa1, pa2;
-
 	if (cmd == GNTTABOP_map_grant_ref) {
 		unsigned int i;
 		for (i = 0; i < count; i++) {
@@ -380,29 +378,7 @@ HYPERVISOR_grant_table_op(unsigned int c
 				(struct gnttab_map_grant_ref*)uop + i);
 		}
 	}
-	va1 = (__u64)uop & PAGE_MASK;
-	pa1 = pa2 = 0;
-	if ((REGION_NUMBER(va1) == 5) &&
-	    ((va1 - KERNEL_START) >= KERNEL_TR_PAGE_SIZE)) {
-		pa1 = ia64_tpa(va1);
-		if (cmd <= GNTTABOP_transfer) {
-			static uint32_t uop_size[GNTTABOP_transfer + 1] = {
-				sizeof(struct gnttab_map_grant_ref),
-				sizeof(struct gnttab_unmap_grant_ref),
-				sizeof(struct gnttab_setup_table),
-				sizeof(struct gnttab_dump_table),
-				sizeof(struct gnttab_transfer),
-			};
-			va2 = (__u64)uop + (uop_size[cmd] * count) - 1;
-			va2 &= PAGE_MASK;
-			if (va1 != va2) {
-				/* maximum size of uop is 2pages */
-				BUG_ON(va2 > va1 + PAGE_SIZE);
-				pa2 = ia64_tpa(va2);
-			}
-		}
-	}
-	return ____HYPERVISOR_grant_table_op(cmd, uop, count, pa1, pa2);
+	return xencomm_hypercall_grant_table_op(cmd, uop, count);
 }
 EXPORT_SYMBOL(HYPERVISOR_grant_table_op);
 
linux-2.6-xen-sparse/include/asm-ia64/hypercall.h +60 -80

208 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h +0 -11
diff -r f32793cae274 -r 80137e1a97cf linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
@@ -70,9 +70,6 @@ HYPERVISOR_yield(
 {
 	int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
 
-	if (rc == -ENOSYS)
-		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
-
 	return rc;
 }
 
@@ -81,9 +78,6 @@ HYPERVISOR_block(
 	void)
 {
 	int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
-
-	if (rc == -ENOSYS)
-		rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
 
 	return rc;
 }
@@ -97,9 +91,6 @@ HYPERVISOR_shutdown(
 	};
 
 	int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
-
-	if (rc == -ENOSYS)
-		rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
 
 	return rc;
 }
@@ -117,8 +108,6 @@ HYPERVISOR_poll(
 
 	set_xen_guest_handle(sched_poll.ports, ports);
 	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
-	if (rc == -ENOSYS)
-		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
 
 	return rc;
 }

# HG changeset patch
# User gingold@virtu10
# Node ID dc2d01757b26c9a9648e231bc7c8e5cccf949ad2 # Parent 80137e1a97cf27e026e6eb6a51a5757e160e979a Move CONFIG_XEN_PRIVCMD condition from files to directory.

This allow new conditions on (future) files.

linux-2.6-xen-sparse/drivers/xen/Makefile +1 -1
diff -r 80137e1a97cf -r dc2d01757b26 linux-2.6-xen-sparse/drivers/xen/Makefile
@@ -1,10 +1,10 @@ obj-y	+= core/
 obj-y	+= core/
 obj-y	+= console/
 obj-y	+= evtchn/
-obj-y	+= privcmd/
 obj-y	+= xenbus/
 
 obj-$(CONFIG_XEN_UTIL)			+= util.o
+obj-$(CONFIG_XEN_PRIVCMD)		+= privcmd/
 obj-$(CONFIG_XEN_BALLOON)		+= balloon/
 obj-$(CONFIG_XEN_DEVMEM)		+= char/
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= blkback/
linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile +1 -2
diff -r 80137e1a97cf -r dc2d01757b26 linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile
@@ -1,2 +1,1 @@
-
-obj-$(CONFIG_XEN_PRIVCMD)	:= privcmd.o
+obj-y				:= privcmd.o

# HG changeset patch
# User gingold@virtu10
# Node ID cc7a78171c811b9caa5587a0141d8c8477d10ce8 # Parent dc2d01757b26c9a9648e231bc7c8e5cccf949ad2

Use xencomm on ia64

linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +5 -12
diff -r dc2d01757b26 -r cc7a78171c81 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
@@ -34,6 +34,10 @@
 
 static struct proc_dir_entry *privcmd_intf;
 static struct proc_dir_entry *capabilities_intf;
+
+#ifdef CONFIG_XEN_XENCOMM
+extern int xencomm_privcmd_hypercall(privcmd_hypercall_t *hypercall);
+#endif
 
 #define NR_HYPERCALLS 64
 static DECLARE_BITMAP(hypercall_permission_map, NR_HYPERCALLS);
@@ -92,18 +96,7 @@ static int privcmd_ioctl(struct inode *i
 				: "r8", "r10", "memory" );
 		}
 #elif defined (__ia64__)
-		__asm__ __volatile__ (
-			";; mov r14=%2; mov r15=%3; "
-			"mov r16=%4; mov r17=%5; mov r18=%6;"
-			"mov r2=%1; break 0x1000;; mov %0=r8 ;;"
-			: "=r" (ret)
-			: "r" (hypercall.op),
-			"r" (hypercall.arg[0]),
-			"r" (hypercall.arg[1]),
-			"r" (hypercall.arg[2]),
-			"r" (hypercall.arg[3]),
-			"r" (hypercall.arg[4])
-			: "r14","r15","r16","r17","r18","r2","r8","memory");
+		ret = xencomm_privcmd_hypercall (&hypercall);
 #endif
 	}
 	break;

# HG changeset patch
# User gingold@virtu10
# Node ID ba96f5f81464dc3db80af0454fb05c73de620637 # Parent cc7a78171c811b9caa5587a0141d8c8477d10ce8 Xencomm support in linux kernel:
* descriptor creation and destruction
* transformation of kernels hypercalls
* transformation of privcmd issued hypercalls.

It must be enabled by architecture config.

linux-2.6-xen-sparse/drivers/xen/Kconfig +3 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/drivers/xen/Kconfig
@@ -257,4 +257,7 @@ config XEN_SMPBOOT
 	default y
 	depends on SMP
 
+config XEN_XENCOMM
+	bool
+	default n
 endif
linux-2.6-xen-sparse/drivers/xen/core/Makefile +1 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/drivers/xen/core/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_XEN_SKBUFF)	+= skbuff.o
 obj-$(CONFIG_XEN_SKBUFF)	+= skbuff.o
 obj-$(CONFIG_XEN_REBOOT)	+= reboot.o
 obj-$(CONFIG_XEN_SMPBOOT)	+= smpboot.o
+obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o xencomm_hcall.o
linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile +2 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile
@@ -1,1 +1,3 @@ obj-y				:= privcmd.o
 obj-y				:= privcmd.o
+
+obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o
linux-2.6-xen-sparse/drivers/xen/core/xencomm.c new file +163 -0

163 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/core/xencomm_hcall.c new file +281 -0

281 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/privcmd/xencomm.c new file +359 -0

359 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-ia64/xen/xencomm.h new file +26 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/include/asm-ia64/xen/xencomm.h
@@ -0,0 +1,26 @@
+#ifndef _ASM_IA64_XEN_XENCOMM_H
+#define _ASM_IA64_XEN_XENCOMM_H
+
+/* Written by Tristan Gingold <[email protected]>
+   Define xen_vaddr_to_paddr.
+   This file is included only by drivers/xen/core/xencomm.c
+*/
+
+extern unsigned long kernel_start_pa;
+
+static unsigned long xen_generic_vaddr_to_paddr(unsigned long vaddr);
+
+static unsigned long xen_vaddr_to_paddr(unsigned long vaddr)
+{
+	/* On ia64, TASK_SIZE refers to current.  It is not initialized
+	   during boot.
+	   Furthermore the kernel is relocatable and __pa() doesn't work on
+	   kernel addresses.  */
+	if (vaddr >= KERNEL_START
+	    && vaddr < (KERNEL_START + KERNEL_TR_PAGE_SIZE)) {
+		return vaddr - kernel_start_pa;
+	}
+	return xen_generic_vaddr_to_paddr(vaddr);
+}
+
+#endif /* _ASM_IA64_XEN_XENCOMM_H */
linux-2.6-xen-sparse/include/xen/xencomm.h new file +36 -0
diff -r cc7a78171c81 -r ba96f5f81464 linux-2.6-xen-sparse/include/xen/xencomm.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Hollis Blanchard <[email protected]>, IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#ifndef _LINUX_XENCOMM_H_
+#define _LINUX_XENCOMM_H_
+
+#include <xen/interface/xencomm.h>
+
+/* To avoid additionnal virt to phys conversion, an opaque structure is
+   presented.  */
+struct xencomm_handle;
+
+extern int xencomm_create(void *buffer, unsigned long bytes,
+			  struct xencomm_handle **desc, gfp_t type);
+extern void xencomm_free(struct xencomm_handle *desc);
+struct xencomm_handle *xencomm_create_inline (void *buffer,
+					      unsigned long bytes);
+
+#define xen_guest_handle(hnd)  ((hnd).p)
+
+#endif /* _LINUX_XENCOMM_H_ */
linux-2.6-xen-sparse/include/xen/xencomm_hcall.h new file +45 -0

45 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 4 lines · Tristan Gingold
Quoted 3 lines

There is at least a "/* XXX could we call this from irq context? */" comment that needs removal. I didn't check the rest of the patch to see if you'd followed all my other suggestions.

I think the comment could be removed as this is never call during irq.

Fine, but that's not actually what I was getting at. My point is that the caller passes in gfp_mask, so if the caller is in IRQ context, it can pass in the proper allocator flags, so there is no problem and the comment should be removed.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center