Skip to content

Commit 831c192

Browse files
committed
Merge tag 'uml-for-linus-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux
Pull UML updates from Richard Weinberger: - Lots of cleanups, mostly from Benjamin Berg and Tiwei Bie - Removal of unused code - Fix for sparse warnings - Cleanup around stub_exe() * tag 'uml-for-linus-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux: (68 commits) hostfs: Fix the NULL vs IS_ERR() bug for __filemap_get_folio() um: move thread info into task um: Always dump trace for specified task in show_stack um: vector: Do not use drvdata in release um: net: Do not use drvdata in release um: ubd: Do not use drvdata in release um: ubd: Initialize ubd's disk pointer in ubd_add um: virtio_uml: query the number of vqs if supported um: virtio_uml: fix call_fd IRQ allocation um: virtio_uml: send SET_MEM_TABLE message with the exact size um: remove broken double fault detection um: remove duplicate UM_NSEC_PER_SEC definition um: remove file sync for stub data um: always include kconfig.h and compiler-version.h um: set DONTDUMP and DONTFORK flags on KASAN shadow memory um: fix sparse warnings in signal code um: fix sparse warnings from regset refactor um: Remove double zero check um: fix stub exe build with CONFIG_GCOV um: Use os_set_pdeathsig helper in winch thread/process ...
2 parents 04b43ea + bed2cc4 commit 831c192

Some content is hidden

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

83 files changed

+1227
-1394
lines changed

arch/um/Kconfig

+21-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ menu "UML-specific options"
55
config UML
66
bool
77
default y
8+
select ARCH_WANTS_DYNAMIC_TASK_STRUCT
89
select ARCH_HAS_CPU_FINALIZE_INIT
910
select ARCH_HAS_FORTIFY_SOURCE
1011
select ARCH_HAS_GCOV_PROFILE_ALL
@@ -32,6 +33,8 @@ config UML
3233
select HAVE_ARCH_VMAP_STACK
3334
select HAVE_RUST
3435
select ARCH_HAS_UBSAN
36+
select HAVE_ARCH_TRACEHOOK
37+
select THREAD_INFO_IN_TASK
3538

3639
config MMU
3740
bool
@@ -94,7 +97,7 @@ config MAY_HAVE_RUNTIME_DEPS
9497

9598
config STATIC_LINK
9699
bool "Force a static link"
97-
depends on CC_CAN_LINK_STATIC_NO_RUNTIME_DEPS || !MAY_HAVE_RUNTIME_DEPS
100+
depends on !MAY_HAVE_RUNTIME_DEPS
98101
help
99102
This option gives you the ability to force a static link of UML.
100103
Normally, UML is linked as a shared binary. This is inconvenient for
@@ -209,8 +212,8 @@ config MMAPPER
209212

210213
config PGTABLE_LEVELS
211214
int
212-
default 3 if 3_LEVEL_PGTABLES
213-
default 2
215+
default 4 if 64BIT
216+
default 2 if !64BIT
214217

215218
config UML_TIME_TRAVEL_SUPPORT
216219
bool
@@ -227,6 +230,21 @@ config UML_TIME_TRAVEL_SUPPORT
227230

228231
It is safe to say Y, but you probably don't need this.
229232

233+
config UML_MAX_USERSPACE_ITERATIONS
234+
int
235+
prompt "Maximum number of unscheduled userspace iterations"
236+
default 10000
237+
depends on UML_TIME_TRAVEL_SUPPORT
238+
help
239+
In UML inf-cpu and ext time-travel mode userspace can run without being
240+
interrupted. This will eventually overwhelm the kernel and create OOM
241+
situations (mainly RCU not running). This setting specifies the number
242+
of kernel/userspace switches (minor/major page fault, signal or syscall)
243+
for the same userspace thread before the sched_clock is advanced by a
244+
jiffie to trigger scheduling.
245+
246+
Setting it to zero disables the feature.
247+
230248
config KASAN_SHADOW_OFFSET
231249
hex
232250
depends on KASAN

arch/um/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
6161
$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
6262
-Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \
6363
-Din6addr_loopback=kernel_in6addr_loopback \
64-
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
64+
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr \
65+
-D__close_range=kernel__close_range
6566

6667
KBUILD_RUSTFLAGS += -Crelocation-model=pie
6768

@@ -70,7 +71,9 @@ KBUILD_AFLAGS += $(ARCH_INCLUDE)
7071
USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
7172
$(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
7273
-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
73-
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__
74+
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \
75+
-include $(srctree)/include/linux/compiler-version.h \
76+
-include $(srctree)/include/linux/kconfig.h
7477

7578
#This will adjust *FLAGS accordingly to the platform.
7679
include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux

arch/um/Makefile-skas

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# Licensed under the GPL
44
#
55

6-
GPROF_OPT += -pg
6+
export UM_GPROF_OPT += -pg
77

88
ifdef CONFIG_CC_IS_CLANG
9-
GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
9+
export UM_GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
1010
else
11-
GCOV_OPT += -fprofile-arcs -ftest-coverage
11+
export UM_GCOV_OPT += -fprofile-arcs -ftest-coverage
1212
endif
1313

14-
CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
15-
CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
16-
LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
17-
LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
14+
CFLAGS-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
15+
CFLAGS-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
16+
LINK-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
17+
LINK-$(CONFIG_GPROF) += $(UM_GPROF_OPT)

arch/um/configs/i386_defconfig

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
CONFIG_3_LEVEL_PGTABLES=y
21
# CONFIG_COMPACTION is not set
32
CONFIG_BINFMT_MISC=m
43
CONFIG_HOSTFS=y

arch/um/drivers/chan_user.c

+2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static __noreturn int winch_thread(void *arg)
161161
int count;
162162
char c = 1;
163163

164+
os_set_pdeathsig();
165+
164166
pty_fd = data->pty_fd;
165167
pipe_fd = data->pipe_fd;
166168
count = write(pipe_fd, &c, sizeof(c));

arch/um/drivers/hostaudio_kern.c

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ MODULE_PARM_DESC(mixer, MIXER_HELP);
4848
#ifndef MODULE
4949
static int set_dsp(char *name, int *add)
5050
{
51+
*add = 0;
5152
dsp = name;
5253
return 0;
5354
}
@@ -56,6 +57,7 @@ __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
5657

5758
static int set_mixer(char *name, int *add)
5859
{
60+
*add = 0;
5961
mixer = name;
6062
return 0;
6163
}

arch/um/drivers/net_kern.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static struct platform_driver uml_net_driver = {
336336

337337
static void net_device_release(struct device *dev)
338338
{
339-
struct uml_net *device = dev_get_drvdata(dev);
339+
struct uml_net *device = container_of(dev, struct uml_net, pdev.dev);
340340
struct net_device *netdev = device->dev;
341341
struct uml_net_private *lp = netdev_priv(netdev);
342342

arch/um/drivers/ubd_kern.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)
779779

780780
static void ubd_device_release(struct device *dev)
781781
{
782-
struct ubd *ubd_dev = dev_get_drvdata(dev);
782+
struct ubd *ubd_dev = container_of(dev, struct ubd, pdev.dev);
783783

784784
blk_mq_free_tag_set(&ubd_dev->tag_set);
785785
*ubd_dev = ((struct ubd) DEFAULT_UBD);
@@ -898,6 +898,8 @@ static int ubd_add(int n, char **error_out)
898898
if (err)
899899
goto out_cleanup_disk;
900900

901+
ubd_dev->disk = disk;
902+
901903
return 0;
902904

903905
out_cleanup_disk:
@@ -1499,6 +1501,7 @@ int io_thread(void *arg)
14991501
{
15001502
int n, count, written, res;
15011503

1504+
os_set_pdeathsig();
15021505
os_fix_helper_signals();
15031506

15041507
while(1){

arch/um/drivers/vector_kern.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,8 @@ static struct platform_driver uml_net_driver = {
815815

816816
static void vector_device_release(struct device *dev)
817817
{
818-
struct vector_device *device = dev_get_drvdata(dev);
818+
struct vector_device *device =
819+
container_of(dev, struct vector_device, pdev.dev);
819820
struct net_device *netdev = device->dev;
820821

821822
list_del(&device->list);

arch/um/drivers/vhost_user.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/* Feature bits */
1111
#define VHOST_USER_F_PROTOCOL_FEATURES 30
1212
/* Protocol feature bits */
13+
#define VHOST_USER_PROTOCOL_F_MQ 0
1314
#define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
1415
#define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
1516
#define VHOST_USER_PROTOCOL_F_CONFIG 9
@@ -23,7 +24,8 @@
2324
/* Supported transport features */
2425
#define VHOST_USER_SUPPORTED_F BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)
2526
/* Supported protocol features */
26-
#define VHOST_USER_SUPPORTED_PROTOCOL_F (BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
27+
#define VHOST_USER_SUPPORTED_PROTOCOL_F (BIT_ULL(VHOST_USER_PROTOCOL_F_MQ) | \
28+
BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
2729
BIT_ULL(VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
2830
BIT_ULL(VHOST_USER_PROTOCOL_F_CONFIG) | \
2931
BIT_ULL(VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS))

arch/um/drivers/virtio_uml.c

+35-16
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct virtio_uml_device {
5656
int sock, req_fd, irq;
5757
u64 features;
5858
u64 protocol_features;
59+
u64 max_vqs;
5960
u8 status;
6061
u8 registered:1;
6162
u8 suspended:1;
@@ -72,8 +73,6 @@ struct virtio_uml_vq_info {
7273
bool suspended;
7374
};
7475

75-
extern unsigned long long physmem_size, highmem;
76-
7776
#define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, ##__VA_ARGS__)
7877

7978
/* Vhost-user protocol */
@@ -343,6 +342,17 @@ static int vhost_user_set_protocol_features(struct virtio_uml_device *vu_dev,
343342
protocol_features);
344343
}
345344

345+
static int vhost_user_get_queue_num(struct virtio_uml_device *vu_dev,
346+
u64 *queue_num)
347+
{
348+
int rc = vhost_user_send_no_payload(vu_dev, true,
349+
VHOST_USER_GET_QUEUE_NUM);
350+
351+
if (rc)
352+
return rc;
353+
return vhost_user_recv_u64(vu_dev, queue_num);
354+
}
355+
346356
static void vhost_user_reply(struct virtio_uml_device *vu_dev,
347357
struct vhost_user_msg *msg, int response)
348358
{
@@ -516,6 +526,15 @@ static int vhost_user_init(struct virtio_uml_device *vu_dev)
516526
return rc;
517527
}
518528

529+
if (vu_dev->protocol_features &
530+
BIT_ULL(VHOST_USER_PROTOCOL_F_MQ)) {
531+
rc = vhost_user_get_queue_num(vu_dev, &vu_dev->max_vqs);
532+
if (rc)
533+
return rc;
534+
} else {
535+
vu_dev->max_vqs = U64_MAX;
536+
}
537+
519538
return 0;
520539
}
521540

@@ -625,7 +644,7 @@ static int vhost_user_set_mem_table(struct virtio_uml_device *vu_dev)
625644
{
626645
struct vhost_user_msg msg = {
627646
.header.request = VHOST_USER_SET_MEM_TABLE,
628-
.header.size = sizeof(msg.payload.mem_regions),
647+
.header.size = offsetof(typeof(msg.payload.mem_regions), regions[1]),
629648
.payload.mem_regions.num = 1,
630649
};
631650
unsigned long reserved = uml_reserved - uml_physmem;
@@ -673,13 +692,6 @@ static int vhost_user_set_mem_table(struct virtio_uml_device *vu_dev)
673692

674693
if (rc < 0)
675694
return rc;
676-
if (highmem) {
677-
msg.payload.mem_regions.num++;
678-
rc = vhost_user_init_mem_region(__pa(end_iomem), highmem,
679-
&fds[1], &msg.payload.mem_regions.regions[1]);
680-
if (rc < 0)
681-
return rc;
682-
}
683695

684696
return vhost_user_send(vu_dev, false, &msg, fds,
685697
msg.payload.mem_regions.num);
@@ -897,7 +909,7 @@ static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev,
897909
{
898910
struct virtio_uml_vq_info *info = vq->priv;
899911
int call_fds[2];
900-
int rc;
912+
int rc, irq;
901913

902914
/* no call FD needed/desired in this case */
903915
if (vu_dev->protocol_features &
@@ -914,19 +926,23 @@ static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev,
914926
return rc;
915927

916928
info->call_fd = call_fds[0];
917-
rc = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
918-
vu_interrupt, IRQF_SHARED, info->name, vq);
919-
if (rc < 0)
929+
irq = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
930+
vu_interrupt, IRQF_SHARED, info->name, vq);
931+
if (irq < 0) {
932+
rc = irq;
920933
goto close_both;
934+
}
921935

922936
rc = vhost_user_set_vring_call(vu_dev, vq->index, call_fds[1]);
923937
if (rc)
924938
goto release_irq;
925939

940+
vu_dev->irq = irq;
941+
926942
goto out;
927943

928944
release_irq:
929-
um_free_irq(vu_dev->irq, vq);
945+
um_free_irq(irq, vq);
930946
close_both:
931947
os_close_file(call_fds[0]);
932948
out:
@@ -1023,7 +1039,9 @@ static int vu_find_vqs(struct virtio_device *vdev, unsigned nvqs,
10231039
struct virtqueue *vq;
10241040

10251041
/* not supported for now */
1026-
if (WARN_ON(nvqs > 64))
1042+
if (WARN(nvqs > 64 || nvqs > vu_dev->max_vqs,
1043+
"%d VQs requested, only up to 64 or %lld supported\n",
1044+
nvqs, vu_dev->max_vqs))
10271045
return -EINVAL;
10281046

10291047
rc = vhost_user_set_mem_table(vu_dev);
@@ -1210,6 +1228,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
12101228
vu_dev->vdev.id.vendor = VIRTIO_DEV_ANY_ID;
12111229
vu_dev->pdev = pdev;
12121230
vu_dev->req_fd = -1;
1231+
vu_dev->irq = UM_IRQ_ALLOC;
12131232

12141233
time_travel_propagate_time();
12151234

arch/um/include/asm/Kbuild

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
generic-y += bug.h
33
generic-y += compat.h
4-
generic-y += current.h
54
generic-y += device.h
65
generic-y += dma-mapping.h
76
generic-y += emergency-restart.h

arch/um/include/asm/current.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __ASM_CURRENT_H
3+
#define __ASM_CURRENT_H
4+
5+
#include <linux/compiler.h>
6+
#include <linux/threads.h>
7+
8+
#ifndef __ASSEMBLY__
9+
10+
struct task_struct;
11+
extern struct task_struct *cpu_tasks[NR_CPUS];
12+
13+
static __always_inline struct task_struct *get_current(void)
14+
{
15+
return cpu_tasks[0];
16+
}
17+
18+
19+
#define current get_current()
20+
21+
#endif /* __ASSEMBLY__ */
22+
23+
#endif /* __ASM_CURRENT_H */

0 commit comments

Comments
 (0)