Skip to content

Commit

Permalink
Merge tag 'uml-for-linus-6.13-rc1' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/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
  ...
  • Loading branch information
Linus Torvalds committed Nov 30, 2024
2 parents 04b43ea + bed2cc4 commit 831c192
Show file tree
Hide file tree
Showing 83 changed files with 1,227 additions and 1,394 deletions.
24 changes: 21 additions & 3 deletions arch/um/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ menu "UML-specific options"
config UML
bool
default y
select ARCH_WANTS_DYNAMIC_TASK_STRUCT
select ARCH_HAS_CPU_FINALIZE_INIT
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
Expand Down Expand Up @@ -32,6 +33,8 @@ config UML
select HAVE_ARCH_VMAP_STACK
select HAVE_RUST
select ARCH_HAS_UBSAN
select HAVE_ARCH_TRACEHOOK
select THREAD_INFO_IN_TASK

config MMU
bool
Expand Down Expand Up @@ -94,7 +97,7 @@ config MAY_HAVE_RUNTIME_DEPS

config STATIC_LINK
bool "Force a static link"
depends on CC_CAN_LINK_STATIC_NO_RUNTIME_DEPS || !MAY_HAVE_RUNTIME_DEPS
depends on !MAY_HAVE_RUNTIME_DEPS
help
This option gives you the ability to force a static link of UML.
Normally, UML is linked as a shared binary. This is inconvenient for
Expand Down Expand Up @@ -209,8 +212,8 @@ config MMAPPER

config PGTABLE_LEVELS
int
default 3 if 3_LEVEL_PGTABLES
default 2
default 4 if 64BIT
default 2 if !64BIT

config UML_TIME_TRAVEL_SUPPORT
bool
Expand All @@ -227,6 +230,21 @@ config UML_TIME_TRAVEL_SUPPORT

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

config UML_MAX_USERSPACE_ITERATIONS
int
prompt "Maximum number of unscheduled userspace iterations"
default 10000
depends on UML_TIME_TRAVEL_SUPPORT
help
In UML inf-cpu and ext time-travel mode userspace can run without being
interrupted. This will eventually overwhelm the kernel and create OOM
situations (mainly RCU not running). This setting specifies the number
of kernel/userspace switches (minor/major page fault, signal or syscall)
for the same userspace thread before the sched_clock is advanced by a
jiffie to trigger scheduling.

Setting it to zero disables the feature.

config KASAN_SHADOW_OFFSET
hex
depends on KASAN
Expand Down
7 changes: 5 additions & 2 deletions arch/um/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
-Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \
-Din6addr_loopback=kernel_in6addr_loopback \
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr \
-D__close_range=kernel__close_range

KBUILD_RUSTFLAGS += -Crelocation-model=pie

Expand All @@ -70,7 +71,9 @@ KBUILD_AFLAGS += $(ARCH_INCLUDE)
USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
$(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \
-include $(srctree)/include/linux/compiler-version.h \
-include $(srctree)/include/linux/kconfig.h

#This will adjust *FLAGS accordingly to the platform.
include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux
Expand Down
14 changes: 7 additions & 7 deletions arch/um/Makefile-skas
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# Licensed under the GPL
#

GPROF_OPT += -pg
export UM_GPROF_OPT += -pg

ifdef CONFIG_CC_IS_CLANG
GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
export UM_GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
else
GCOV_OPT += -fprofile-arcs -ftest-coverage
export UM_GCOV_OPT += -fprofile-arcs -ftest-coverage
endif

CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
CFLAGS-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
CFLAGS-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
LINK-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
LINK-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
1 change: 0 additions & 1 deletion arch/um/configs/i386_defconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_3_LEVEL_PGTABLES=y
# CONFIG_COMPACTION is not set
CONFIG_BINFMT_MISC=m
CONFIG_HOSTFS=y
Expand Down
2 changes: 2 additions & 0 deletions arch/um/drivers/chan_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ static __noreturn int winch_thread(void *arg)
int count;
char c = 1;

os_set_pdeathsig();

pty_fd = data->pty_fd;
pipe_fd = data->pipe_fd;
count = write(pipe_fd, &c, sizeof(c));
Expand Down
2 changes: 2 additions & 0 deletions arch/um/drivers/hostaudio_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ MODULE_PARM_DESC(mixer, MIXER_HELP);
#ifndef MODULE
static int set_dsp(char *name, int *add)
{
*add = 0;
dsp = name;
return 0;
}
Expand All @@ -56,6 +57,7 @@ __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);

static int set_mixer(char *name, int *add)
{
*add = 0;
mixer = name;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static struct platform_driver uml_net_driver = {

static void net_device_release(struct device *dev)
{
struct uml_net *device = dev_get_drvdata(dev);
struct uml_net *device = container_of(dev, struct uml_net, pdev.dev);
struct net_device *netdev = device->dev;
struct uml_net_private *lp = netdev_priv(netdev);

Expand Down
5 changes: 4 additions & 1 deletion arch/um/drivers/ubd_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)

static void ubd_device_release(struct device *dev)
{
struct ubd *ubd_dev = dev_get_drvdata(dev);
struct ubd *ubd_dev = container_of(dev, struct ubd, pdev.dev);

blk_mq_free_tag_set(&ubd_dev->tag_set);
*ubd_dev = ((struct ubd) DEFAULT_UBD);
Expand Down Expand Up @@ -898,6 +898,8 @@ static int ubd_add(int n, char **error_out)
if (err)
goto out_cleanup_disk;

ubd_dev->disk = disk;

return 0;

out_cleanup_disk:
Expand Down Expand Up @@ -1499,6 +1501,7 @@ int io_thread(void *arg)
{
int n, count, written, res;

os_set_pdeathsig();
os_fix_helper_signals();

while(1){
Expand Down
3 changes: 2 additions & 1 deletion arch/um/drivers/vector_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,8 @@ static struct platform_driver uml_net_driver = {

static void vector_device_release(struct device *dev)
{
struct vector_device *device = dev_get_drvdata(dev);
struct vector_device *device =
container_of(dev, struct vector_device, pdev.dev);
struct net_device *netdev = device->dev;

list_del(&device->list);
Expand Down
4 changes: 3 additions & 1 deletion arch/um/drivers/vhost_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/* Feature bits */
#define VHOST_USER_F_PROTOCOL_FEATURES 30
/* Protocol feature bits */
#define VHOST_USER_PROTOCOL_F_MQ 0
#define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
#define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
#define VHOST_USER_PROTOCOL_F_CONFIG 9
Expand All @@ -23,7 +24,8 @@
/* Supported transport features */
#define VHOST_USER_SUPPORTED_F BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)
/* Supported protocol features */
#define VHOST_USER_SUPPORTED_PROTOCOL_F (BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
#define VHOST_USER_SUPPORTED_PROTOCOL_F (BIT_ULL(VHOST_USER_PROTOCOL_F_MQ) | \
BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
BIT_ULL(VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
BIT_ULL(VHOST_USER_PROTOCOL_F_CONFIG) | \
BIT_ULL(VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS))
Expand Down
51 changes: 35 additions & 16 deletions arch/um/drivers/virtio_uml.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct virtio_uml_device {
int sock, req_fd, irq;
u64 features;
u64 protocol_features;
u64 max_vqs;
u8 status;
u8 registered:1;
u8 suspended:1;
Expand All @@ -72,8 +73,6 @@ struct virtio_uml_vq_info {
bool suspended;
};

extern unsigned long long physmem_size, highmem;

#define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, ##__VA_ARGS__)

/* Vhost-user protocol */
Expand Down Expand Up @@ -343,6 +342,17 @@ static int vhost_user_set_protocol_features(struct virtio_uml_device *vu_dev,
protocol_features);
}

static int vhost_user_get_queue_num(struct virtio_uml_device *vu_dev,
u64 *queue_num)
{
int rc = vhost_user_send_no_payload(vu_dev, true,
VHOST_USER_GET_QUEUE_NUM);

if (rc)
return rc;
return vhost_user_recv_u64(vu_dev, queue_num);
}

static void vhost_user_reply(struct virtio_uml_device *vu_dev,
struct vhost_user_msg *msg, int response)
{
Expand Down Expand Up @@ -516,6 +526,15 @@ static int vhost_user_init(struct virtio_uml_device *vu_dev)
return rc;
}

if (vu_dev->protocol_features &
BIT_ULL(VHOST_USER_PROTOCOL_F_MQ)) {
rc = vhost_user_get_queue_num(vu_dev, &vu_dev->max_vqs);
if (rc)
return rc;
} else {
vu_dev->max_vqs = U64_MAX;
}

return 0;
}

Expand Down Expand Up @@ -625,7 +644,7 @@ static int vhost_user_set_mem_table(struct virtio_uml_device *vu_dev)
{
struct vhost_user_msg msg = {
.header.request = VHOST_USER_SET_MEM_TABLE,
.header.size = sizeof(msg.payload.mem_regions),
.header.size = offsetof(typeof(msg.payload.mem_regions), regions[1]),
.payload.mem_regions.num = 1,
};
unsigned long reserved = uml_reserved - uml_physmem;
Expand Down Expand Up @@ -673,13 +692,6 @@ static int vhost_user_set_mem_table(struct virtio_uml_device *vu_dev)

if (rc < 0)
return rc;
if (highmem) {
msg.payload.mem_regions.num++;
rc = vhost_user_init_mem_region(__pa(end_iomem), highmem,
&fds[1], &msg.payload.mem_regions.regions[1]);
if (rc < 0)
return rc;
}

return vhost_user_send(vu_dev, false, &msg, fds,
msg.payload.mem_regions.num);
Expand Down Expand Up @@ -897,7 +909,7 @@ static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev,
{
struct virtio_uml_vq_info *info = vq->priv;
int call_fds[2];
int rc;
int rc, irq;

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

info->call_fd = call_fds[0];
rc = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
vu_interrupt, IRQF_SHARED, info->name, vq);
if (rc < 0)
irq = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
vu_interrupt, IRQF_SHARED, info->name, vq);
if (irq < 0) {
rc = irq;
goto close_both;
}

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

vu_dev->irq = irq;

goto out;

release_irq:
um_free_irq(vu_dev->irq, vq);
um_free_irq(irq, vq);
close_both:
os_close_file(call_fds[0]);
out:
Expand Down Expand Up @@ -1023,7 +1039,9 @@ static int vu_find_vqs(struct virtio_device *vdev, unsigned nvqs,
struct virtqueue *vq;

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

rc = vhost_user_set_mem_table(vu_dev);
Expand Down Expand Up @@ -1210,6 +1228,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
vu_dev->vdev.id.vendor = VIRTIO_DEV_ANY_ID;
vu_dev->pdev = pdev;
vu_dev->req_fd = -1;
vu_dev->irq = UM_IRQ_ALLOC;

time_travel_propagate_time();

Expand Down
1 change: 0 additions & 1 deletion arch/um/include/asm/Kbuild
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
generic-y += bug.h
generic-y += compat.h
generic-y += current.h
generic-y += device.h
generic-y += dma-mapping.h
generic-y += emergency-restart.h
Expand Down
23 changes: 23 additions & 0 deletions arch/um/include/asm/current.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_CURRENT_H
#define __ASM_CURRENT_H

#include <linux/compiler.h>
#include <linux/threads.h>

#ifndef __ASSEMBLY__

struct task_struct;
extern struct task_struct *cpu_tasks[NR_CPUS];

static __always_inline struct task_struct *get_current(void)
{
return cpu_tasks[0];
}


#define current get_current()

#endif /* __ASSEMBLY__ */

#endif /* __ASM_CURRENT_H */
Loading

0 comments on commit 831c192

Please sign in to comment.