Skip to content

Commit 89df6bf

Browse files
Eduard-Gabriel MunteanuLinus Torvalds
authored andcommitted
uml: DEBUG_SHIRQ fixes
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. Signed-off-by: Eduard-Gabriel Munteanu <maxdamage@aladin.ro> Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e18eecb commit 89df6bf

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

arch/um/drivers/chan_user.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,13 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out)
170170
err = -EINVAL;
171171
goto out_close;
172172
}
173-
return err ;
173+
174+
if (os_set_fd_block(*fd_out, 0)) {
175+
printk("winch_tramp: failed to set thread_fd non-blocking.\n");
176+
goto out_close;
177+
}
178+
179+
return err;
174180

175181
out_close:
176182
os_close_file(fds[1]);

arch/um/drivers/mconsole_user.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ int mconsole_get_request(int fd, struct mc_request *req)
8686
int len;
8787

8888
req->originlen = sizeof(req->origin);
89-
req->len = recvfrom(fd, &req->request, sizeof(req->request), 0,
90-
(struct sockaddr *) req->origin, &req->originlen);
89+
req->len = recvfrom(fd, &req->request, sizeof(req->request),
90+
MSG_DONTWAIT, (struct sockaddr *) req->origin,
91+
&req->originlen);
9192
if (req->len < 0)
9293
return 0;
9394

arch/um/drivers/ubd_user.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ int start_io_thread(unsigned long sp, int *fd_out)
4343
kernel_fd = fds[0];
4444
*fd_out = fds[1];
4545

46+
err = os_set_fd_block(*fd_out, 0);
47+
if (err) {
48+
printk("start_io_thread - failed to set nonblocking I/O.\n");
49+
goto out_close;
50+
}
51+
4652
pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
4753
NULL);
4854
if(pid < 0){

arch/um/drivers/xterm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ int xterm_open(int input, int output, int primary, void *d,
151151
goto out;
152152
}
153153

154+
err = os_set_fd_block(new, 0);
155+
if (err) {
156+
printk("xterm_open : failed to set xterm descriptor "
157+
"non-blocking, err = %d\n", -err);
158+
goto out;
159+
}
160+
154161
CATCH_EINTR(err = tcgetattr(new, &data->tt));
155162
if(err){
156163
new = err;

0 commit comments

Comments
 (0)