Skip to contentSkip to conversation

UML - DEBUG_SHIRQ fixes

PATCH New Jeff Dike 1 participant 1 message Jun 13, 2007 User-mode Linux (UML)

lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 1/2 UML - DEBUG_SHIRQ fixes

From: Eduard-Gabriel Munteanu <[email protected]>

DEBUG_SHIRQ generates spurious interrupts, triggering handlers such as mconsole_interrupt() or line_interrupt(). They expect data to be available to be read from their sockets/pipes, but in the case of spurious interrupts, the host didn't actually send anything, so UML hangs in read() and friends. Setting those fd's as O_NONBLOCK makes DEBUG_SHIRQ-enabled UML kernels boot and run correctly.

The patch was written and tested on Linux 2.6.22-rc2-mm1.

I have also included a couple of short/minor fixes for potential problems.

--

 arch/um/drivers/chan_user.c     |    8 +++++++-
 arch/um/drivers/mconsole_user.c |    5 +++--
 arch/um/drivers/ubd_user.c      |    6 ++++++
 arch/um/drivers/xterm.c         |    7 +++++++
 4 files changed, 23 insertions(+), 3 deletions(-)
arch/um/drivers/chan_user.c +7 -1
Index: linux-2.6.21-mm/arch/um/drivers/chan_user.c
===================================================================
@@ -170,7 +170,13 @@ static int winch_tramp(int fd, struct tt
                 err = -EINVAL;
 		goto out_close;
 	}
-	return err ;
+
+	if (os_set_fd_block(*fd_out, 0)) {
+		printk("winch_tramp: failed to set thread_fd non-blocking.\n");
+		goto out_close;
+	}
+
+	return err;
 
  out_close:
 	os_close_file(fds[1]);
arch/um/drivers/mconsole_user.c +3 -2
Index: linux-2.6.21-mm/arch/um/drivers/mconsole_user.c
===================================================================
@@ -86,8 +86,9 @@ int mconsole_get_request(int fd, struct 
 	int len;
 
 	req->originlen = sizeof(req->origin);
-	req->len = recvfrom(fd, &req->request, sizeof(req->request), 0,
-			    (struct sockaddr *) req->origin, &req->originlen);
+	req->len = recvfrom(fd, &req->request, sizeof(req->request),
+			    MSG_DONTWAIT, (struct sockaddr *) req->origin,
+			    &req->originlen);
 	if (req->len < 0)
 		return 0;
 
arch/um/drivers/ubd_user.c +6 -0
Index: linux-2.6.21-mm/arch/um/drivers/ubd_user.c
===================================================================
@@ -43,6 +43,12 @@ int start_io_thread(unsigned long sp, in
 	kernel_fd = fds[0];
 	*fd_out = fds[1];
 
+	err = os_set_fd_block(*fd_out, 0);
+	if (err) {
+		printk("start_io_thread - failed to set nonblocking I/O.\n");
+		goto out_close;
+	}
+
 	pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
 		    NULL);
 	if(pid < 0){
arch/um/drivers/xterm.c +7 -0
Index: linux-2.6.21-mm/arch/um/drivers/xterm.c
===================================================================
@@ -151,6 +151,13 @@ int xterm_open(int input, int output, in
 		goto out;
 	}
 
+	err = os_set_fd_block(new, 0);
+	if (err) {
+		printk("xterm_open : failed to set xterm descriptor "
+		       "non-blocking, err = %d\n", -err);
+		goto out;
+	}
+
 	CATCH_EINTR(err = tcgetattr(new, &data->tt));
 	if(err){
 		new = err;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel