Pull UML updates from Richard Weinberger: - Various cleanups and fixes: xterm, serial line, time travel - Set ARCH_HAS_GCOV_PROFILE_ALL * tag 'for-linus-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml: um: Fix out-of-bounds read in LDT setup um: chan_user: Fix winch_tramp() return value um: virtio_uml: Fix broken device handling in time-travel um: line: Use separate IRQs per line um: Enable ARCH_HAS_GCOV_PROFILE_ALL um: Use asm-generic/dma-mapping.h um: daemon: Make default socket configurable um: xterm: Make default terminal emulator configurable
Unified · Split
| @@ -6,6 +6,7 @@ config UML · 5 unmodified lines | ||
| 6 | 6 | bool |
| 7 | 7 | default y |
| 8 | 8 | select ARCH_EPHEMERAL_INODES |
| 9 | + select ARCH_HAS_GCOV_PROFILE_ALL | |
| 9 | 10 | select ARCH_HAS_KCOV |
| 10 | 11 | select ARCH_HAS_STRNCPY_FROM_USER |
| 11 | 12 | select ARCH_HAS_STRNLEN_USER |
| @@ -64,6 +64,13 @@ config XTERM_CHAN · 63 unmodified lines | ||
| 64 | 64 | its own xterm. |
| 65 | 65 | It is safe to say 'Y' here. |
| 66 | 66 | |
| 67 | +config XTERM_CHAN_DEFAULT_EMULATOR | |
| 68 | + string "xterm channel default terminal emulator" | |
| 69 | + depends on XTERM_CHAN | |
| 70 | + default "xterm" | |
| 71 | + help | |
| 72 | + This option allows changing the default terminal emulator. | |
| 73 | + | |
| 67 | 74 | config NOCONFIG_CHAN |
| 68 | 75 | bool |
| 69 | 76 | default !(XTERM_CHAN && TTY_CHAN && PTY_CHAN && PORT_CHAN && NULL_CHAN) |
| @@ -231,6 +238,14 @@ config UML_NET_DAEMON · 161 unmodified lines | ||
| 231 | 238 | |
| 232 | 239 | If unsure, say N. |
| 233 | 240 | |
| 241 | +config UML_NET_DAEMON_DEFAULT_SOCK | |
| 242 | + string "Default socket for daemon transport" | |
| 243 | + default "/tmp/uml.ctl" | |
| 244 | + depends on UML_NET_DAEMON | |
| 245 | + help | |
| 246 | + This option allows setting the default socket for the daemon | |
| 247 | + transport, normally it defaults to /tmp/uml.ctl. | |
| 248 | + | |
| 234 | 249 | config UML_NET_VECTOR |
| 235 | 250 | bool "Vector I/O high performance network devices" |
| 236 | 251 | depends on UML_NET |
| @@ -70,4 +70,6 @@ obj-$(CONFIG_UML_PCI_OVER_VIRTIO) += virt-pci.o · 69 unmodified lines | ||
| 70 | 70 | USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o pcap_user.o vde_user.o vector_user.o |
| 71 | 71 | CFLAGS_null.o = -DDEV_NULL=$(DEV_NULL_PATH) |
| 72 | 72 | |
| 73 | +CFLAGS_xterm.o += '-DCONFIG_XTERM_CHAN_DEFAULT_EMULATOR="$(CONFIG_XTERM_CHAN_DEFAULT_EMULATOR)"' | |
| 74 | + | |
| 73 | 75 | include arch/um/scripts/Makefile.rules |
| @@ -133,7 +133,7 @@ static void line_timer_cb(struct work_struct *work) · 132 unmodified lines | ||
| 133 | 133 | struct line *line = container_of(work, struct line, task.work); |
| 134 | 134 | |
| 135 | 135 | if (!line->throttled) |
| 136 | − chan_interrupt(line, line->driver->read_irq); | |
| 136 | + chan_interrupt(line, line->read_irq); | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | int enable_chan(struct line *line) |
| @@ -195,9 +195,9 @@ void free_irqs(void) · 55 unmodified lines | ||
| 195 | 195 | chan = list_entry(ele, struct chan, free_list); |
| 196 | 196 | |
| 197 | 197 | if (chan->input && chan->enabled) |
| 198 | − um_free_irq(chan->line->driver->read_irq, chan); | |
| 198 | + um_free_irq(chan->line->read_irq, chan); | |
| 199 | 199 | if (chan->output && chan->enabled) |
| 200 | − um_free_irq(chan->line->driver->write_irq, chan); | |
| 200 | + um_free_irq(chan->line->write_irq, chan); | |
| 201 | 201 | chan->enabled = 0; |
| 202 | 202 | } |
| 203 | 203 | } |
| @@ -215,9 +215,9 @@ static void close_one_chan(struct chan *chan, int delay_free_irq) · 11 unmodified lines | ||
| 215 | 215 | spin_unlock_irqrestore(&irqs_to_free_lock, flags); |
| 216 | 216 | } else { |
| 217 | 217 | if (chan->input && chan->enabled) |
| 218 | − um_free_irq(chan->line->driver->read_irq, chan); | |
| 218 | + um_free_irq(chan->line->read_irq, chan); | |
| 219 | 219 | if (chan->output && chan->enabled) |
| 220 | − um_free_irq(chan->line->driver->write_irq, chan); | |
| 220 | + um_free_irq(chan->line->write_irq, chan); | |
| 221 | 221 | chan->enabled = 0; |
| 222 | 222 | } |
| 223 | 223 | if (chan->ops->close != NULL) |
| @@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, · 219 unmodified lines | ||
| 220 | 220 | unsigned long *stack_out) |
| 221 | 221 | { |
| 222 | 222 | struct winch_data data; |
| 223 | − int fds[2], n, err; | |
| 223 | + int fds[2], n, err, pid; | |
| 224 | 224 | char c; |
| 225 | 225 | |
| 226 | 226 | err = os_pipe(fds, 1, 1); |
| @@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, · 11 unmodified lines | ||
| 238 | 238 | * problem with /dev/net/tun, which if held open by this |
| 239 | 239 | * thread, prevents the TUN/TAP device from being reused. |
| 240 | 240 | */ |
| 241 | − err = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out); | |
| 242 | − if (err < 0) { | |
| 241 | + pid = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out); | |
| 242 | + if (pid < 0) { | |
| 243 | + err = pid; | |
| 243 | 244 | printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n", |
| 244 | 245 | -err); |
| 245 | 246 | goto out_close; |
| @@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, · 17 unmodified lines | ||
| 263 | 264 | goto out_close; |
| 264 | 265 | } |
| 265 | 266 | |
| 266 | − return err; | |
| 267 | + return pid; | |
| 267 | 268 | |
| 268 | 269 | out_close: |
| 269 | 270 | close(fds[1]); |
| @@ -65,7 +65,7 @@ static int daemon_setup(char *str, char **mac_out, void *data) · 64 unmodified lines | ||
| 65 | 65 | |
| 66 | 66 | *init = ((struct daemon_init) |
| 67 | 67 | { .sock_type = "unix", |
| 68 | − .ctl_sock = "/tmp/uml.ctl" }); | |
| 68 | + .ctl_sock = CONFIG_UML_NET_DAEMON_DEFAULT_SOCK }); | |
| 69 | 69 | |
| 70 | 70 | remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock, |
| 71 | 71 | NULL); |
| @@ -139,7 +139,7 @@ static int flush_buffer(struct line *line) · 138 unmodified lines | ||
| 139 | 139 | count = line->buffer + LINE_BUFSIZE - line->head; |
| 140 | 140 | |
| 141 | 141 | n = write_chan(line->chan_out, line->head, count, |
| 142 | − line->driver->write_irq); | |
| 142 | + line->write_irq); | |
| 143 | 143 | if (n < 0) |
| 144 | 144 | return n; |
| 145 | 145 | if (n == count) { |
| @@ -156,7 +156,7 @@ static int flush_buffer(struct line *line) · 10 unmodified lines | ||
| 156 | 156 | |
| 157 | 157 | count = line->tail - line->head; |
| 158 | 158 | n = write_chan(line->chan_out, line->head, count, |
| 159 | − line->driver->write_irq); | |
| 159 | + line->write_irq); | |
| 160 | 160 | |
| 161 | 161 | if (n < 0) |
| 162 | 162 | return n; |
| @@ -195,7 +195,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len) · 32 unmodified lines | ||
| 195 | 195 | ret = buffer_data(line, buf, len); |
| 196 | 196 | else { |
| 197 | 197 | n = write_chan(line->chan_out, buf, len, |
| 198 | − line->driver->write_irq); | |
| 198 | + line->write_irq); | |
| 199 | 199 | if (n < 0) { |
| 200 | 200 | ret = n; |
| 201 | 201 | goto out_up; |
| @@ -215,7 +215,7 @@ void line_throttle(struct tty_struct *tty) · 13 unmodified lines | ||
| 215 | 215 | { |
| 216 | 216 | struct line *line = tty->driver_data; |
| 217 | 217 | |
| 218 | − deactivate_chan(line->chan_in, line->driver->read_irq); | |
| 218 | + deactivate_chan(line->chan_in, line->read_irq); | |
| 219 | 219 | line->throttled = 1; |
| 220 | 220 | } |
| 221 | 221 | |
| @@ -224,7 +224,7 @@ void line_unthrottle(struct tty_struct *tty) · 2 unmodified lines | ||
| 224 | 224 | struct line *line = tty->driver_data; |
| 225 | 225 | |
| 226 | 226 | line->throttled = 0; |
| 227 | − chan_interrupt(line, line->driver->read_irq); | |
| 227 | + chan_interrupt(line, line->read_irq); | |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | static irqreturn_t line_write_interrupt(int irq, void *data) |
| @@ -260,19 +260,23 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data) · 29 unmodified lines | ||
| 260 | 260 | int err; |
| 261 | 261 | |
| 262 | 262 | if (input) { |
| 263 | − err = um_request_irq(driver->read_irq, fd, IRQ_READ, | |
| 264 | − line_interrupt, IRQF_SHARED, | |
| 263 | + err = um_request_irq(UM_IRQ_ALLOC, fd, IRQ_READ, | |
| 264 | + line_interrupt, 0, | |
| 265 | 265 | driver->read_irq_name, data); |
| 266 | 266 | if (err < 0) |
| 267 | 267 | return err; |
| 268 | + | |
| 269 | + line->read_irq = err; | |
| 268 | 270 | } |
| 269 | 271 | |
| 270 | 272 | if (output) { |
| 271 | − err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, | |
| 272 | − line_write_interrupt, IRQF_SHARED, | |
| 273 | + err = um_request_irq(UM_IRQ_ALLOC, fd, IRQ_WRITE, | |
| 274 | + line_write_interrupt, 0, | |
| 273 | 275 | driver->write_irq_name, data); |
| 274 | 276 | if (err < 0) |
| 275 | 277 | return err; |
| 278 | + | |
| 279 | + line->write_irq = err; | |
| 276 | 280 | } |
| 277 | 281 | |
| 278 | 282 | return 0; |
| @@ -23,9 +23,7 @@ struct line_driver { · 22 unmodified lines | ||
| 23 | 23 | const short minor_start; |
| 24 | 24 | const short type; |
| 25 | 25 | const short subtype; |
| 26 | − const int read_irq; | |
| 27 | 26 | const char *read_irq_name; |
| 28 | − const int write_irq; | |
| 29 | 27 | const char *write_irq_name; |
| 30 | 28 | struct mc_device mc; |
| 31 | 29 | struct tty_driver *driver; |
| @@ -35,6 +33,8 @@ struct line { · 3 unmodified lines | ||
| 35 | 33 | struct tty_port port; |
| 36 | 34 | int valid; |
| 37 | 35 | |
| 36 | + int read_irq, write_irq; | |
| 37 | + | |
| 38 | 38 | char *init_str; |
| 39 | 39 | struct list_head chan_list; |
| 40 | 40 | struct chan *chan_in, *chan_out; |
| @@ -47,9 +47,7 @@ static struct line_driver driver = { · 46 unmodified lines | ||
| 47 | 47 | .minor_start = 64, |
| 48 | 48 | .type = TTY_DRIVER_TYPE_SERIAL, |
| 49 | 49 | .subtype = 0, |
| 50 | − .read_irq = SSL_IRQ, | |
| 51 | 50 | .read_irq_name = "ssl", |
| 52 | − .write_irq = SSL_WRITE_IRQ, | |
| 53 | 51 | .write_irq_name = "ssl-write", |
| 54 | 52 | .mc = { |
| 55 | 53 | .list = LIST_HEAD_INIT(driver.mc.list), |
| @@ -53,9 +53,7 @@ static struct line_driver driver = { · 52 unmodified lines | ||
| 53 | 53 | .minor_start = 0, |
| 54 | 54 | .type = TTY_DRIVER_TYPE_CONSOLE, |
| 55 | 55 | .subtype = SYSTEM_TYPE_CONSOLE, |
| 56 | − .read_irq = CONSOLE_IRQ, | |
| 57 | 56 | .read_irq_name = "console", |
| 58 | − .write_irq = CONSOLE_WRITE_IRQ, | |
| 59 | 57 | .write_irq_name = "console-write", |
| 60 | 58 | .mc = { |
| 61 | 59 | .list = LIST_HEAD_INIT(driver.mc.list), |
| @@ -63,6 +63,7 @@ struct virtio_uml_device { · 62 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | u8 config_changed_irq:1; |
| 65 | 65 | uint64_t vq_irq_vq_map; |
| 66 | + int recv_rc; | |
| 66 | 67 | }; |
| 67 | 68 | |
| 68 | 69 | struct virtio_uml_vq_info { |
| @@ -148,14 +149,6 @@ static int vhost_user_recv(struct virtio_uml_device *vu_dev, · 79 unmodified lines | ||
| 148 | 149 | |
| 149 | 150 | rc = vhost_user_recv_header(fd, msg); |
| 150 | 151 | |
| 151 | − if (rc == -ECONNRESET && vu_dev->registered) { | |
| 152 | − struct virtio_uml_platform_data *pdata; | |
| 153 | − | |
| 154 | − pdata = vu_dev->pdata; | |
| 155 | − | |
| 156 | − virtio_break_device(&vu_dev->vdev); | |
| 157 | − schedule_work(&pdata->conn_broken_wk); | |
| 158 | − } | |
| 159 | 152 | if (rc) |
| 160 | 153 | return rc; |
| 161 | 154 | size = msg->header.size; |
| @@ -164,6 +157,21 @@ static int vhost_user_recv(struct virtio_uml_device *vu_dev, · 2 unmodified lines | ||
| 164 | 157 | return full_read(fd, &msg->payload, size, false); |
| 165 | 158 | } |
| 166 | 159 | |
| 160 | +static void vhost_user_check_reset(struct virtio_uml_device *vu_dev, | |
| 161 | + int rc) | |
| 162 | +{ | |
| 163 | + struct virtio_uml_platform_data *pdata = vu_dev->pdata; | |
| 164 | + | |
| 165 | + if (rc != -ECONNRESET) | |
| 166 | + return; | |
| 167 | + | |
| 168 | + if (!vu_dev->registered) | |
| 169 | + return; | |
| 170 | + | |
| 171 | + virtio_break_device(&vu_dev->vdev); | |
| 172 | + schedule_work(&pdata->conn_broken_wk); | |
| 173 | +} | |
| 174 | + | |
| 167 | 175 | static int vhost_user_recv_resp(struct virtio_uml_device *vu_dev, |
| 168 | 176 | struct vhost_user_msg *msg, |
| 169 | 177 | size_t max_payload_size) |
| @@ -171,8 +179,10 @@ static int vhost_user_recv_resp(struct virtio_uml_device *vu_dev, · 1 unmodified line | ||
| 171 | 179 | int rc = vhost_user_recv(vu_dev, vu_dev->sock, msg, |
| 172 | 180 | max_payload_size, true); |
| 173 | 181 | |
| 174 | − if (rc) | |
| 182 | + if (rc) { | |
| 183 | + vhost_user_check_reset(vu_dev, rc); | |
| 175 | 184 | return rc; |
| 185 | + } | |
| 176 | 186 | |
| 177 | 187 | if (msg->header.flags != (VHOST_USER_FLAG_REPLY | VHOST_USER_VERSION)) |
| 178 | 188 | return -EPROTO; |
| @@ -369,6 +379,7 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev, · 190 unmodified lines | ||
| 369 | 379 | sizeof(msg.msg.payload) + |
| 370 | 380 | sizeof(msg.extra_payload)); |
| 371 | 381 | |
| 382 | + vu_dev->recv_rc = rc; | |
| 372 | 383 | if (rc) |
| 373 | 384 | return IRQ_NONE; |
| 374 | 385 | |
| @@ -412,7 +423,9 @@ static irqreturn_t vu_req_interrupt(int irq, void *data) · 37 unmodified lines | ||
| 412 | 423 | if (!um_irq_timetravel_handler_used()) |
| 413 | 424 | ret = vu_req_read_message(vu_dev, NULL); |
| 414 | 425 | |
| 415 | − if (vu_dev->vq_irq_vq_map) { | |
| 426 | + if (vu_dev->recv_rc) { | |
| 427 | + vhost_user_check_reset(vu_dev, vu_dev->recv_rc); | |
| 428 | + } else if (vu_dev->vq_irq_vq_map) { | |
| 416 | 429 | struct virtqueue *vq; |
| 417 | 430 | |
| 418 | 431 | virtio_device_for_each_vq((&vu_dev->vdev), vq) { |
| @@ -42,7 +42,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts) · 41 unmodified lines | ||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /* Only changed by xterm_setup, which is a setup */ |
| 45 | −static char *terminal_emulator = "xterm"; | |
| 45 | +static char *terminal_emulator = CONFIG_XTERM_CHAN_DEFAULT_EMULATOR; | |
| 46 | 46 | static char *title_switch = "-T"; |
| 47 | 47 | static char *exec_switch = "-e"; |
| 48 | 48 | |
| @@ -79,8 +79,9 @@ __uml_setup("xterm=", xterm_setup, · 30 unmodified lines | ||
| 79 | 79 | " respectively. The title switch must have the form '<switch> title',\n" |
| 80 | 80 | " not '<switch>=title'. Similarly, the exec switch must have the form\n" |
| 81 | 81 | " '<switch> command arg1 arg2 ...'.\n" |
| 82 | −" The default values are 'xterm=xterm,-T,-e'. Values for gnome-terminal\n" | |
| 83 | −" are 'xterm=gnome-terminal,-t,-x'.\n\n" | |
| 82 | +" The default values are 'xterm=" CONFIG_XTERM_CHAN_DEFAULT_EMULATOR | |
| 83 | + ",-T,-e'.\n" | |
| 84 | +" Values for gnome-terminal are 'xterm=gnome-terminal,-t,-x'.\n\n" | |
| 84 | 85 | ); |
| 85 | 86 | |
| 86 | 87 | static int xterm_open(int input, int output, int primary, void *d, |
| @@ -4,6 +4,7 @@ generic-y += bug.h · 3 unmodified lines | ||
| 4 | 4 | generic-y += compat.h |
| 5 | 5 | generic-y += current.h |
| 6 | 6 | generic-y += device.h |
| 7 | +generic-y += dma-mapping.h | |
| 7 | 8 | generic-y += emergency-restart.h |
| 8 | 9 | generic-y += exec.h |
| 9 | 10 | generic-y += extable.h |
| @@ -4,19 +4,15 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | #define TIMER_IRQ 0 |
| 6 | 6 | #define UMN_IRQ 1 |
| 7 | −#define CONSOLE_IRQ 2 | |
| 8 | −#define CONSOLE_WRITE_IRQ 3 | |
| 9 | −#define UBD_IRQ 4 | |
| 10 | −#define UM_ETH_IRQ 5 | |
| 11 | −#define SSL_IRQ 6 | |
| 12 | −#define SSL_WRITE_IRQ 7 | |
| 13 | −#define ACCEPT_IRQ 8 | |
| 14 | −#define MCONSOLE_IRQ 9 | |
| 15 | −#define WINCH_IRQ 10 | |
| 16 | −#define SIGIO_WRITE_IRQ 11 | |
| 17 | −#define TELNETD_IRQ 12 | |
| 18 | −#define XTERM_IRQ 13 | |
| 19 | −#define RANDOM_IRQ 14 | |
| 7 | +#define UBD_IRQ 2 | |
| 8 | +#define UM_ETH_IRQ 3 | |
| 9 | +#define ACCEPT_IRQ 4 | |
| 10 | +#define MCONSOLE_IRQ 5 | |
| 11 | +#define WINCH_IRQ 6 | |
| 12 | +#define SIGIO_WRITE_IRQ 7 | |
| 13 | +#define TELNETD_IRQ 8 | |
| 14 | +#define XTERM_IRQ 9 | |
| 15 | +#define RANDOM_IRQ 10 | |
| 20 | 16 | |
| 21 | 17 | #ifdef CONFIG_UML_NET_VECTOR |
| 22 | 18 | |
| @@ -23,9 +23,11 @@ static long write_ldt_entry(struct mm_id *mm_idp, int func, · 22 unmodified lines | ||
| 23 | 23 | { |
| 24 | 24 | long res; |
| 25 | 25 | void *stub_addr; |
| 26 | + | |
| 27 | + BUILD_BUG_ON(sizeof(*desc) % sizeof(long)); | |
| 28 | + | |
| 26 | 29 | res = syscall_stub_data(mm_idp, (unsigned long *)desc, |
| 27 | − (sizeof(*desc) + sizeof(long) - 1) & | |
| 28 | − ~(sizeof(long) - 1), | |
| 30 | + sizeof(*desc) / sizeof(long), | |
| 29 | 31 | addr, &stub_addr); |
| 30 | 32 | if (!res) { |
| 31 | 33 | unsigned long args[] = { func, |