On Mon, 2010-03-08 at 19:25 +0100, Matthias Rieber wrote:
> This happens with 2.6.32.8 and .9 (9 with the fixed rlimit patch). Is 
> this a know issue? Wrong kernel config?
> 
> matthias


Hi Matthias,

Yes, there is an issue with integrity of ubd block operations in kernels
later than v2.6.30-rc1. I made a patch that solved my problems, which
has been running fine for a couple of weeks now.

I just use skas0, which works fine for me. Using your script I get the
following result on uml, with kernel 2.6.33-rc6

50+0 records in
50+0 records out
52428800 bytes (52 MB) copied, 9.24587 s, 5.7 MB/s
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin
9339e16d3b55810e6370ac7903e8d815  ./test.bin

Basically I had to revert a kernel commit. See below.

I have attached a patch for you to test. It is for kernel git
v2.6.33-rc6 which I currently use. (for x64_86). There are couple of
other changes included that I saw on this list.

If this solves it for you as well, I will forward it to uml-devel to
have it included in mainstream.

Regards,

-Janjaap


--------

reverted: commit f81f2f7c9fee307e371f37424577d46f9eaf8692
                  Author: Tejun Heo <t...@kernel.org>
                  Date:   Tue Apr 28 13:06:10 2009 +0900
    
ubd: drop unnecessary rq->sector manipulation

ubd curiously updates rq->sector while issuing the request in multiple
pieces.  Don't do it and simply use local copy of sector.
    [ Impact: cleanup ]

--------------


The reason why these updates are needed was foreseen by Jeff in:

commit 0a6d3a2a3813e7b25267366cfbf9a4a4698dd1c2
Author: Jeff Dike <jd...@addtoit.com>
Date:   Sun Jul 15 23:38:47 2007 -0700
    
uml: fix request->sector update
    
It is theoretically possible for a request to finish and be freed
between writing it to the I/O thread and updating the sector count.  In
this case, the update will dereference a freed pointer.
    
To avoid this, I delay the update until processing the next sg segment,
when the request pointer is known to be good.


diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 6e7ad63..c2e42cc 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -18,7 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
-#include <linux/tracehook.h>
+#include <linux/ptrace.h>
 #include <linux/timer.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
@@ -382,7 +382,7 @@ void __kprobes do_single_step(struct pt_regs *regs)
 					SIGTRAP) == NOTIFY_STOP){
 		return;
 	}
-	if (tracehook_consider_fatal_signal(current, SIGTRAP))
+	if ((current->ptrace & PT_PTRACED) != 0)
 		force_sig(SIGTRAP, current);
 }
 
@@ -483,7 +483,7 @@ static void illegal_op(struct pt_regs * regs, long interruption_code)
 		if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
 			return;
 		if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
-			if (tracehook_consider_fatal_signal(current, SIGTRAP))
+			if (current->ptrace & PT_PTRACED)
 				force_sig(SIGTRAP, current);
 			else
 				signal = SIGILL;
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index cf8a97f..a529c3f 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -305,10 +305,12 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
 		for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++)
 			if (cmd == tty_ioctls[i].cmd)
 				break;
+#ifdef DEBUG
 		if (i == ARRAY_SIZE(tty_ioctls)) {
 			printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n",
 			       __func__, tty->name, cmd);
 		}
+#endif
 		ret = -ENOIOCTLCMD;
 		break;
 	}
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 5ff5546..b58bcb3 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1223,7 +1223,7 @@ static void do_ubd_request(struct request_queue *q)
 	struct io_thread_req *io_req;
 	struct request *req;
 	sector_t sector;
-	int n;
+	int n, last_sectors;
 
 	while(1){
 		struct ubd *dev = q->queuedata;
@@ -1239,9 +1239,12 @@ static void do_ubd_request(struct request_queue *q)
 
 		req = dev->request;
 		sector = blk_rq_pos(req);
+		last_sectors = 0;
 		while(dev->start_sg < dev->end_sg){
 			struct scatterlist *sg = &dev->sg[dev->start_sg];
 
+			sector += last_sectors;
+			last_sectors = 0;
 			io_req = kmalloc(sizeof(struct io_thread_req),
 					 GFP_ATOMIC);
 			if(io_req == NULL){
@@ -1253,7 +1256,7 @@ static void do_ubd_request(struct request_queue *q)
 					(unsigned long long)sector << 9,
 					sg->offset, sg->length, sg_page(sg));
 
-			sector += sg->length >> 9;
+			last_sectors = sg->length >> 9;
 			n = os_write_file(thread_fd, &io_req,
 					  sizeof(struct io_thread_req *));
 			if(n != sizeof(struct io_thread_req *)){
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 7fcad58..0731311 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -50,8 +50,20 @@ SECTIONS
   .rela.got       : { *(.rela.got) }
   .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
   .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
-  .rel.plt        : { *(.rel.plt) }
-  .rela.plt       : { *(.rela.plt) }
+  .rel.plt        :
+  {
+    *(.rel.plt)
+    PROVIDE_HIDDEN (__rel_iplt_start = .);
+    *(.rel.iplt)
+    PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt       :
+  {
+    *(.rela.plt)
+    PROVIDE_HIDDEN (__rela_iplt_start = .);
+    *(.rela.iplt)
+    PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
   .init           : {
     KEEP (*(.init))
   } =0x90909090
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index e7a6cca..a658604 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -36,6 +36,21 @@ SECTIONS
     *(.gnu.linkonce.t*)
   }
 
+  .rel.plt        :
+  {
+    *(.rel.plt)
+    PROVIDE_HIDDEN (__rel_iplt_start = .);
+    *(.rel.iplt)
+    PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt       :
+  {
+    *(.rela.plt)
+    PROVIDE_HIDDEN (__rela_iplt_start = .);
+    *(.rela.iplt)
+    PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
+
   . = ALIGN(PAGE_SIZE);
   .syscall_stub : {
 	__syscall_stub_start = .;
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index f3458d7..1c738c7 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -69,7 +69,7 @@ int poke_user(struct task_struct *child, long addr, long data)
 	else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
 		(addr <= offsetof(struct user, u_debugreg[7]))) {
 		addr -= offsetof(struct user, u_debugreg[0]);
-		addr = addr >> 2;
+		addr = addr >> 3; // long is 8 bytes on x86_64
 		if ((addr == 4) || (addr == 5))
 			return -EIO;
 		child->thread.arch.debugregs[addr] = data;
@@ -114,7 +114,7 @@ int peek_user(struct task_struct *child, long addr, long data)
 	else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
 		(addr <= offsetof(struct user, u_debugreg[7]))) {
 		addr -= offsetof(struct user, u_debugreg[0]);
-		addr = addr >> 2;
+		addr = addr >> 3; // long is 8 bytes on x86_64
 		tmp = child->thread.arch.debugregs[addr];
 	}
 	return put_user(tmp, (unsigned long *) data);
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to