Skip to content

Commit f9bcc61

Browse files
committed
Merge tag 'uml-for-linus-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux
Pull UML updates from Richard Weinberger: - Support for preemption - i386 Rust support - Huge cleanup by Benjamin Berg - UBSAN support - Removal of dead code * tag 'uml-for-linus-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux: (41 commits) um: vector: always reset vp->opened um: vector: remove vp->lock um: register power-off handler um: line: always fill *error_out in setup_one_line() um: remove pcap driver from documentation um: Enable preemption in UML um: refactor TLB update handling um: simplify and consolidate TLB updates um: remove force_flush_all from fork_handler um: Do not flush MM in flush_thread um: Delay flushing syscalls until the thread is restarted um: remove copy_context_skas0 um: remove LDT support um: compress memory related stub syscalls while adding them um: Rework syscall handling um: Add generic stub_syscall6 function um: Create signal stack memory assignment in stub_data um: Remove stub-data.h include from common-offsets.h um: time-travel: fix signal blocking race/hang um: time-travel: remove time_exit() ...
2 parents c2a96b7 + 98ff534 commit f9bcc61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1297
-1956
lines changed

Documentation/rust/arch-support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Architecture Level of support Constraints
1818
``arm64`` Maintained Little Endian only.
1919
``loongarch`` Maintained \-
2020
``riscv`` Maintained ``riscv64`` only.
21-
``um`` Maintained ``x86_64`` only.
21+
``um`` Maintained \-
2222
``x86`` Maintained ``x86_64`` only.
2323
============= ================ ==============================================
2424

Documentation/virt/uml/user_mode_linux_howto_v2.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ remote UML and other VM instances.
223223
+-----------+--------+------------------------------------+------------+
224224
| socket | legacy | none | ~ 450Mbit |
225225
+-----------+--------+------------------------------------+------------+
226-
| pcap | legacy | rx only | ~ 450Mbit |
227-
+-----------+--------+------------------------------------+------------+
228226
| ethertap | legacy | obsolete | ~ 500Mbit |
229227
+-----------+--------+------------------------------------+------------+
230228
| vde | legacy | obsolete | ~ 500Mbit |

arch/um/Kconfig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config UML
1111
select ARCH_HAS_KCOV
1212
select ARCH_HAS_STRNCPY_FROM_USER
1313
select ARCH_HAS_STRNLEN_USER
14-
select ARCH_NO_PREEMPT
14+
select ARCH_NO_PREEMPT_DYNAMIC
1515
select HAVE_ARCH_AUDITSYSCALL
1616
select HAVE_ARCH_KASAN if X86_64
1717
select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN
@@ -31,7 +31,8 @@ config UML
3131
select TRACE_IRQFLAGS_SUPPORT
3232
select TTY # Needed for line.c
3333
select HAVE_ARCH_VMAP_STACK
34-
select HAVE_RUST if X86_64
34+
select HAVE_RUST
35+
select ARCH_HAS_UBSAN
3536

3637
config MMU
3738
bool
@@ -48,12 +49,13 @@ config NO_IOMEM
4849
config UML_IOMEM_EMULATION
4950
bool
5051
select INDIRECT_IOMEM
52+
select HAS_IOPORT
5153
select GENERIC_PCI_IOMAP
5254
select GENERIC_IOMAP
5355
select NO_GENERIC_PCI_IOPORT_MAP
5456

5557
config NO_IOPORT_MAP
56-
def_bool y
58+
def_bool !UML_IOMEM_EMULATION
5759

5860
config ISA
5961
bool

arch/um/drivers/Kconfig

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -297,26 +297,6 @@ config UML_NET_MCAST
297297

298298
If unsure, say N.
299299

300-
config UML_NET_PCAP
301-
bool "pcap transport (obsolete)"
302-
depends on UML_NET
303-
depends on !MODVERSIONS
304-
select MAY_HAVE_RUNTIME_DEPS
305-
help
306-
The pcap transport makes a pcap packet stream on the host look
307-
like an ethernet device inside UML. This is useful for making
308-
UML act as a network monitor for the host. You must have libcap
309-
installed in order to build the pcap transport into UML.
310-
311-
For more information, see
312-
<http://user-mode-linux.sourceforge.net/old/networking.html> That site
313-
has examples of the UML command line to use to enable this option.
314-
315-
NOTE: THIS TRANSPORT IS DEPRECATED AND WILL BE REMOVED SOON!!! Please
316-
migrate to UML_NET_VECTOR.
317-
318-
If unsure, say N.
319-
320300
config UML_NET_SLIRP
321301
bool "SLiRP transport (obsolete)"
322302
depends on UML_NET

arch/um/drivers/Makefile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,9 @@ harddog-objs := harddog_kern.o
2020
harddog-builtin-$(CONFIG_UML_WATCHDOG) := harddog_user.o harddog_user_exp.o
2121
rtc-objs := rtc_kern.o rtc_user.o
2222

23-
LDFLAGS_pcap.o = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a)
24-
2523
LDFLAGS_vde.o = $(shell $(CC) $(CFLAGS) -print-file-name=libvdeplug.a)
2624

27-
targets := pcap_kern.o pcap_user.o vde_kern.o vde_user.o
28-
29-
$(obj)/pcap.o: $(obj)/pcap_kern.o $(obj)/pcap_user.o
30-
$(LD) -r -dp -o $@ $^ $(ld_flags)
25+
targets := vde_kern.o vde_user.o
3126

3227
$(obj)/vde.o: $(obj)/vde_kern.o $(obj)/vde_user.o
3328
$(LD) -r -dp -o $@ $^ $(ld_flags)
@@ -49,7 +44,6 @@ obj-$(CONFIG_UML_NET_DAEMON) += daemon.o
4944
obj-$(CONFIG_UML_NET_VECTOR) += vector.o
5045
obj-$(CONFIG_UML_NET_VDE) += vde.o
5146
obj-$(CONFIG_UML_NET_MCAST) += umcast.o
52-
obj-$(CONFIG_UML_NET_PCAP) += pcap.o
5347
obj-$(CONFIG_UML_NET) += net.o
5448
obj-$(CONFIG_MCONSOLE) += mconsole.o
5549
obj-$(CONFIG_MMAPPER) += mmapper_kern.o
@@ -69,7 +63,7 @@ obj-$(CONFIG_UML_RTC) += rtc.o
6963
obj-$(CONFIG_UML_PCI_OVER_VIRTIO) += virt-pci.o
7064

7165
# pcap_user.o must be added explicitly.
72-
USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o pcap_user.o vde_user.o vector_user.o
66+
USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o vde_user.o vector_user.o
7367
CFLAGS_null.o = -DDEV_NULL=$(DEV_NULL_PATH)
7468

7569
CFLAGS_xterm.o += '-DCONFIG_XTERM_CHAN_DEFAULT_EMULATOR="$(CONFIG_XTERM_CHAN_DEFAULT_EMULATOR)"'

arch/um/drivers/chan.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ struct chan {
2222
unsigned int output:1;
2323
unsigned int opened:1;
2424
unsigned int enabled:1;
25-
int fd;
25+
int fd_in;
26+
int fd_out; /* only different to fd_in if blocking output is needed */
2627
const struct chan_ops *ops;
2728
void *data;
2829
};

arch/um/drivers/chan_kern.c

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ static const struct chan_ops not_configged_ops = {
8181
};
8282
#endif /* CONFIG_NOCONFIG_CHAN */
8383

84+
static inline bool need_output_blocking(void)
85+
{
86+
return time_travel_mode == TT_MODE_INFCPU ||
87+
time_travel_mode == TT_MODE_EXTERNAL;
88+
}
89+
8490
static int open_one_chan(struct chan *chan)
8591
{
8692
int fd, err;
@@ -96,15 +102,43 @@ static int open_one_chan(struct chan *chan)
96102
return fd;
97103

98104
err = os_set_fd_block(fd, 0);
99-
if (err) {
100-
(*chan->ops->close)(fd, chan->data);
101-
return err;
102-
}
105+
if (err)
106+
goto out_close;
107+
108+
chan->fd_in = fd;
109+
chan->fd_out = fd;
110+
111+
/*
112+
* In time-travel modes infinite-CPU and external we need to guarantee
113+
* that any writes to the output succeed immdiately from the point of
114+
* the VM. The best way to do this is to put the FD in blocking mode
115+
* and simply wait/retry until everything is written.
116+
* As every write is guaranteed to complete, we also do not need to
117+
* request an IRQ for the output.
118+
*
119+
* Note that input cannot happen in a time synchronized way. We permit
120+
* it, but time passes very quickly if anything waits for a read.
121+
*/
122+
if (chan->output && need_output_blocking()) {
123+
err = os_dup_file(chan->fd_out);
124+
if (err < 0)
125+
goto out_close;
103126

104-
chan->fd = fd;
127+
chan->fd_out = err;
128+
129+
err = os_set_fd_block(chan->fd_out, 1);
130+
if (err) {
131+
os_close_file(chan->fd_out);
132+
goto out_close;
133+
}
134+
}
105135

106136
chan->opened = 1;
107137
return 0;
138+
139+
out_close:
140+
(*chan->ops->close)(fd, chan->data);
141+
return err;
108142
}
109143

110144
static int open_chan(struct list_head *chans)
@@ -125,7 +159,7 @@ static int open_chan(struct list_head *chans)
125159
void chan_enable_winch(struct chan *chan, struct tty_port *port)
126160
{
127161
if (chan && chan->primary && chan->ops->winch)
128-
register_winch(chan->fd, port);
162+
register_winch(chan->fd_in, port);
129163
}
130164

131165
static void line_timer_cb(struct work_struct *work)
@@ -156,8 +190,9 @@ int enable_chan(struct line *line)
156190

157191
if (chan->enabled)
158192
continue;
159-
err = line_setup_irq(chan->fd, chan->input, chan->output, line,
160-
chan);
193+
err = line_setup_irq(chan->fd_in, chan->input,
194+
chan->output && !need_output_blocking(),
195+
line, chan);
161196
if (err)
162197
goto out_close;
163198

@@ -196,7 +231,8 @@ void free_irqs(void)
196231

197232
if (chan->input && chan->enabled)
198233
um_free_irq(chan->line->read_irq, chan);
199-
if (chan->output && chan->enabled)
234+
if (chan->output && chan->enabled &&
235+
!need_output_blocking())
200236
um_free_irq(chan->line->write_irq, chan);
201237
chan->enabled = 0;
202238
}
@@ -216,15 +252,19 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
216252
} else {
217253
if (chan->input && chan->enabled)
218254
um_free_irq(chan->line->read_irq, chan);
219-
if (chan->output && chan->enabled)
255+
if (chan->output && chan->enabled &&
256+
!need_output_blocking())
220257
um_free_irq(chan->line->write_irq, chan);
221258
chan->enabled = 0;
222259
}
260+
if (chan->fd_out != chan->fd_in)
261+
os_close_file(chan->fd_out);
223262
if (chan->ops->close != NULL)
224-
(*chan->ops->close)(chan->fd, chan->data);
263+
(*chan->ops->close)(chan->fd_in, chan->data);
225264

226265
chan->opened = 0;
227-
chan->fd = -1;
266+
chan->fd_in = -1;
267+
chan->fd_out = -1;
228268
}
229269

230270
void close_chan(struct line *line)
@@ -244,7 +284,7 @@ void close_chan(struct line *line)
244284
void deactivate_chan(struct chan *chan, int irq)
245285
{
246286
if (chan && chan->enabled)
247-
deactivate_fd(chan->fd, irq);
287+
deactivate_fd(chan->fd_in, irq);
248288
}
249289

250290
int write_chan(struct chan *chan, const u8 *buf, size_t len, int write_irq)
@@ -254,7 +294,7 @@ int write_chan(struct chan *chan, const u8 *buf, size_t len, int write_irq)
254294
if (len == 0 || !chan || !chan->ops->write)
255295
return 0;
256296

257-
n = chan->ops->write(chan->fd, buf, len, chan->data);
297+
n = chan->ops->write(chan->fd_out, buf, len, chan->data);
258298
if (chan->primary) {
259299
ret = n;
260300
}
@@ -268,7 +308,7 @@ int console_write_chan(struct chan *chan, const char *buf, int len)
268308
if (!chan || !chan->ops->console_write)
269309
return 0;
270310

271-
n = chan->ops->console_write(chan->fd, buf, len);
311+
n = chan->ops->console_write(chan->fd_out, buf, len);
272312
if (chan->primary)
273313
ret = n;
274314
return ret;
@@ -296,14 +336,14 @@ int chan_window_size(struct line *line, unsigned short *rows_out,
296336
if (chan && chan->primary) {
297337
if (chan->ops->window_size == NULL)
298338
return 0;
299-
return chan->ops->window_size(chan->fd, chan->data,
339+
return chan->ops->window_size(chan->fd_in, chan->data,
300340
rows_out, cols_out);
301341
}
302342
chan = line->chan_out;
303343
if (chan && chan->primary) {
304344
if (chan->ops->window_size == NULL)
305345
return 0;
306-
return chan->ops->window_size(chan->fd, chan->data,
346+
return chan->ops->window_size(chan->fd_in, chan->data,
307347
rows_out, cols_out);
308348
}
309349
return 0;
@@ -319,7 +359,7 @@ static void free_one_chan(struct chan *chan)
319359
(*chan->ops->free)(chan->data);
320360

321361
if (chan->primary && chan->output)
322-
ignore_sigio_fd(chan->fd);
362+
ignore_sigio_fd(chan->fd_in);
323363
kfree(chan);
324364
}
325365

@@ -478,7 +518,8 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
478518
.output = 0,
479519
.opened = 0,
480520
.enabled = 0,
481-
.fd = -1,
521+
.fd_in = -1,
522+
.fd_out = -1,
482523
.ops = ops,
483524
.data = data });
484525
return chan;
@@ -549,7 +590,7 @@ void chan_interrupt(struct line *line, int irq)
549590
schedule_delayed_work(&line->task, 1);
550591
goto out;
551592
}
552-
err = chan->ops->read(chan->fd, &c, chan->data);
593+
err = chan->ops->read(chan->fd_in, &c, chan->data);
553594
if (err > 0)
554595
tty_insert_flip_char(port, c, TTY_NORMAL);
555596
} while (err > 0);

arch/um/drivers/chan_user.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int generic_read(int fd, __u8 *c_out, void *unused)
2323
{
2424
int n;
2525

26-
n = read(fd, c_out, sizeof(*c_out));
26+
CATCH_EINTR(n = read(fd, c_out, sizeof(*c_out)));
2727
if (n > 0)
2828
return n;
2929
else if (n == 0)
@@ -37,11 +37,23 @@ int generic_read(int fd, __u8 *c_out, void *unused)
3737

3838
int generic_write(int fd, const __u8 *buf, size_t n, void *unused)
3939
{
40+
int written = 0;
4041
int err;
4142

42-
err = write(fd, buf, n);
43-
if (err > 0)
44-
return err;
43+
/* The FD may be in blocking mode, as such, need to retry short writes,
44+
* they may have been interrupted by a signal.
45+
*/
46+
do {
47+
errno = 0;
48+
err = write(fd, buf + written, n - written);
49+
if (err > 0) {
50+
written += err;
51+
continue;
52+
}
53+
} while (err < 0 && errno == EINTR);
54+
55+
if (written > 0)
56+
return written;
4557
else if (errno == EAGAIN)
4658
return 0;
4759
else if (err == 0)

arch/um/drivers/harddog_kern.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "mconsole.h"
5050
#include "harddog.h"
5151

52+
MODULE_DESCRIPTION("UML hardware watchdog");
5253
MODULE_LICENSE("GPL");
5354

5455
static DEFINE_MUTEX(harddog_mutex);

arch/um/drivers/line.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ int setup_one_line(struct line *lines, int n, char *init,
383383
parse_chan_pair(NULL, line, n, opts, error_out);
384384
err = 0;
385385
}
386+
*error_out = "configured as 'none'";
386387
} else {
387388
char *new = kstrdup(init, GFP_KERNEL);
388389
if (!new) {
@@ -406,6 +407,7 @@ int setup_one_line(struct line *lines, int n, char *init,
406407
}
407408
}
408409
if (err) {
410+
*error_out = "failed to parse channel pair";
409411
line->init_str = NULL;
410412
line->valid = 0;
411413
kfree(new);

0 commit comments

Comments
 (0)