Skip to content

Commit beb6c83

Browse files
committed
Merge tag 'uml-for-linux-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux
Pull uml updates from Johannes Berg: "Mostly cleanups, except: - dynamic addition of vfio passthrough devices - implementation of HAVE_SYSCALL_TRACEPOINTS" * tag 'uml-for-linux-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux: um: Replace __ASSEMBLY__ with __ASSEMBLER__ in the usermode headers um: Stop tracking stub's PID via userspace_pid[] um: Remove the pid parameter of handle_trap() um: Use err consistently in userspace() um: vfio: Support adding devices via mconsole um: rtc: Avoid shadowing err in uml_rtc_start() um: Avoid redefining ARCH_HAS_CACHE_LINE_SIZE um: Make mm_list and mm_list_lock static um: Make unscheduled_userspace_iterations static um: Re-evaluate thread flags repeatedly um: simplify syscall header files um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS um/x86: Add system call table to header file um: virt-pci: Switch to msi_create_parent_irq_domain() um: virtio_pcidev: Rename UM_PCI_STAT_WAITING
2 parents 5f5c995 + fc9ed2f commit beb6c83

28 files changed

+153
-153
lines changed

arch/um/Kconfig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config UML
66
bool
77
default y
88
select ARCH_WANTS_DYNAMIC_TASK_STRUCT
9+
select ARCH_HAS_CACHE_LINE_SIZE
910
select ARCH_HAS_CPU_FINALIZE_INIT
1011
select ARCH_HAS_FORTIFY_SOURCE
1112
select ARCH_HAS_GCOV_PROFILE_ALL
@@ -35,6 +36,7 @@ config UML
3536
select HAVE_RUST
3637
select ARCH_HAS_UBSAN
3738
select HAVE_ARCH_TRACEHOOK
39+
select HAVE_SYSCALL_TRACEPOINTS
3840
select THREAD_INFO_IN_TASK
3941

4042
config MMU
@@ -82,9 +84,6 @@ config NR_CPUS
8284
range 1 1
8385
default 1
8486

85-
config ARCH_HAS_CACHE_LINE_SIZE
86-
def_bool y
87-
8887
source "arch/$(HEADER_ARCH)/um/Kconfig"
8988

9089
config MAY_HAVE_RUNTIME_DEPS

arch/um/drivers/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ config UML_RTC
160160
config UML_PCI
161161
bool
162162
select FORCE_PCI
163+
select IRQ_MSI_LIB
163164
select UML_IOMEM_EMULATION
164165
select UML_DMA_EMULATION
165166
select PCI_MSI

arch/um/drivers/rtc_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int uml_rtc_start(bool timetravel)
2828
int err;
2929

3030
if (timetravel) {
31-
int err = os_pipe(uml_rtc_irq_fds, 1, 1);
31+
err = os_pipe(uml_rtc_irq_fds, 1, 1);
3232
if (err)
3333
goto fail;
3434
} else {

arch/um/drivers/vfio_kern.c

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <init.h>
1717
#include <os.h>
1818

19+
#include "mconsole_kern.h"
1920
#include "virt-pci.h"
2021
#include "vfio_user.h"
2122

@@ -60,6 +61,7 @@ static LIST_HEAD(uml_vfio_groups);
6061
static DEFINE_MUTEX(uml_vfio_groups_mtx);
6162

6263
static LIST_HEAD(uml_vfio_devices);
64+
static DEFINE_MUTEX(uml_vfio_devices_mtx);
6365

6466
static int uml_vfio_set_container(int group_fd)
6567
{
@@ -581,32 +583,44 @@ static struct uml_vfio_device *uml_vfio_find_device(const char *device)
581583
return NULL;
582584
}
583585

584-
static int uml_vfio_cmdline_set(const char *device, const struct kernel_param *kp)
586+
static struct uml_vfio_device *uml_vfio_add_device(const char *device)
585587
{
586588
struct uml_vfio_device *dev;
587589
int fd;
588590

591+
guard(mutex)(&uml_vfio_devices_mtx);
592+
589593
if (uml_vfio_container.fd < 0) {
590594
fd = uml_vfio_user_open_container();
591595
if (fd < 0)
592-
return fd;
596+
return ERR_PTR(fd);
593597
uml_vfio_container.fd = fd;
594598
}
595599

596600
if (uml_vfio_find_device(device))
597-
return -EEXIST;
601+
return ERR_PTR(-EEXIST);
598602

599603
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
600604
if (!dev)
601-
return -ENOMEM;
605+
return ERR_PTR(-ENOMEM);
602606

603607
dev->name = kstrdup(device, GFP_KERNEL);
604608
if (!dev->name) {
605609
kfree(dev);
606-
return -ENOMEM;
610+
return ERR_PTR(-ENOMEM);
607611
}
608612

609613
list_add_tail(&dev->list, &uml_vfio_devices);
614+
return dev;
615+
}
616+
617+
static int uml_vfio_cmdline_set(const char *device, const struct kernel_param *kp)
618+
{
619+
struct uml_vfio_device *dev;
620+
621+
dev = uml_vfio_add_device(device);
622+
if (IS_ERR(dev))
623+
return PTR_ERR(dev);
610624
return 0;
611625
}
612626

@@ -629,6 +643,42 @@ __uml_help(uml_vfio_cmdline_param_ops,
629643
" through multiple PCI devices to UML.\n\n"
630644
);
631645

646+
static int uml_vfio_mc_config(char *str, char **error_out)
647+
{
648+
struct uml_vfio_device *dev;
649+
650+
if (*str != '=') {
651+
*error_out = "Invalid config";
652+
return -EINVAL;
653+
}
654+
str += 1;
655+
656+
dev = uml_vfio_add_device(str);
657+
if (IS_ERR(dev))
658+
return PTR_ERR(dev);
659+
uml_vfio_open_device(dev);
660+
return 0;
661+
}
662+
663+
static int uml_vfio_mc_id(char **str, int *start_out, int *end_out)
664+
{
665+
return -EOPNOTSUPP;
666+
}
667+
668+
static int uml_vfio_mc_remove(int n, char **error_out)
669+
{
670+
return -EOPNOTSUPP;
671+
}
672+
673+
static struct mc_device uml_vfio_mc = {
674+
.list = LIST_HEAD_INIT(uml_vfio_mc.list),
675+
.name = "vfio_uml.device",
676+
.config = uml_vfio_mc_config,
677+
.get_config = NULL,
678+
.id = uml_vfio_mc_id,
679+
.remove = uml_vfio_mc_remove,
680+
};
681+
632682
static int __init uml_vfio_init(void)
633683
{
634684
struct uml_vfio_device *dev, *n;
@@ -639,6 +689,8 @@ static int __init uml_vfio_init(void)
639689
list_for_each_entry_safe(dev, n, &uml_vfio_devices, list)
640690
uml_vfio_open_device(dev);
641691

692+
mconsole_register_dev(&uml_vfio_mc);
693+
642694
return 0;
643695
}
644696
late_initcall(uml_vfio_init);

arch/um/drivers/virt-pci.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/pci.h>
88
#include <linux/logic_iomem.h>
99
#include <linux/of_platform.h>
10+
#include <linux/irqchip/irq-msi-lib.h>
1011
#include <linux/irqdomain.h>
1112
#include <linux/msi.h>
1213
#include <linux/unaligned.h>
@@ -29,7 +30,6 @@ static struct um_pci_device *um_pci_platform_device;
2930
static struct um_pci_device_reg um_pci_devices[MAX_DEVICES];
3031
static struct fwnode_handle *um_pci_fwnode;
3132
static struct irq_domain *um_pci_inner_domain;
32-
static struct irq_domain *um_pci_msi_domain;
3333
static unsigned long um_pci_msi_used[BITS_TO_LONGS(MAX_MSI_VECTORS)];
3434

3535
static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
@@ -400,21 +400,24 @@ static void um_pci_inner_domain_free(struct irq_domain *domain,
400400
}
401401

402402
static const struct irq_domain_ops um_pci_inner_domain_ops = {
403+
.select = msi_lib_irq_domain_select,
403404
.alloc = um_pci_inner_domain_alloc,
404405
.free = um_pci_inner_domain_free,
405406
};
406407

407-
static struct irq_chip um_pci_msi_irq_chip = {
408-
.name = "UM virtual PCIe MSI",
409-
.irq_mask = pci_msi_mask_irq,
410-
.irq_unmask = pci_msi_unmask_irq,
411-
};
412-
413-
static struct msi_domain_info um_pci_msi_domain_info = {
414-
.flags = MSI_FLAG_USE_DEF_DOM_OPS |
415-
MSI_FLAG_USE_DEF_CHIP_OPS |
416-
MSI_FLAG_PCI_MSIX,
417-
.chip = &um_pci_msi_irq_chip,
408+
#define UM_PCI_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
409+
MSI_FLAG_USE_DEF_CHIP_OPS | \
410+
MSI_FLAG_NO_AFFINITY)
411+
#define UM_PCI_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
412+
MSI_FLAG_PCI_MSIX)
413+
414+
static const struct msi_parent_ops um_pci_msi_parent_ops = {
415+
.required_flags = UM_PCI_MSI_FLAGS_REQUIRED,
416+
.supported_flags = UM_PCI_MSI_FLAGS_SUPPORTED,
417+
.bus_select_token = DOMAIN_BUS_NEXUS,
418+
.bus_select_mask = MATCH_PCI_MSI,
419+
.prefix = "UM-virtual-",
420+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
418421
};
419422

420423
static struct resource busn_resource = {
@@ -559,17 +562,14 @@ static int __init um_pci_init(void)
559562
goto free;
560563
}
561564

562-
um_pci_inner_domain = irq_domain_create_linear(um_pci_fwnode, MAX_MSI_VECTORS,
563-
&um_pci_inner_domain_ops, NULL);
564-
if (!um_pci_inner_domain) {
565-
err = -ENOMEM;
566-
goto free;
567-
}
565+
struct irq_domain_info info = {
566+
.fwnode = um_pci_fwnode,
567+
.ops = &um_pci_inner_domain_ops,
568+
.size = MAX_MSI_VECTORS,
569+
};
568570

569-
um_pci_msi_domain = pci_msi_create_irq_domain(um_pci_fwnode,
570-
&um_pci_msi_domain_info,
571-
um_pci_inner_domain);
572-
if (!um_pci_msi_domain) {
571+
um_pci_inner_domain = msi_create_parent_irq_domain(&info, &um_pci_msi_parent_ops);
572+
if (!um_pci_inner_domain) {
573573
err = -ENOMEM;
574574
goto free;
575575
}
@@ -611,7 +611,6 @@ device_initcall(um_pci_init);
611611

612612
static void __exit um_pci_exit(void)
613613
{
614-
irq_domain_remove(um_pci_msi_domain);
615614
irq_domain_remove(um_pci_inner_domain);
616615
pci_free_resource_list(&bridge->windows);
617616
pci_free_host_bridge(bridge);

arch/um/drivers/virtio_pcidev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct virtio_pcidev_device {
4242
void *extra_ptrs[VIRTIO_PCIDEV_WRITE_BUFS + 1];
4343
DECLARE_BITMAP(used_bufs, VIRTIO_PCIDEV_WRITE_BUFS);
4444

45-
#define UM_PCI_STAT_WAITING 0
45+
#define VIRTIO_PCIDEV_STAT_WAITING 0
4646
unsigned long status;
4747

4848
bool platform;
@@ -172,7 +172,7 @@ static int virtio_pcidev_send_cmd(struct virtio_pcidev_device *dev,
172172
}
173173

174174
/* kick and poll for getting a response on the queue */
175-
set_bit(UM_PCI_STAT_WAITING, &dev->status);
175+
set_bit(VIRTIO_PCIDEV_STAT_WAITING, &dev->status);
176176
virtqueue_kick(dev->cmd_vq);
177177
ret = 0;
178178

@@ -193,7 +193,7 @@ static int virtio_pcidev_send_cmd(struct virtio_pcidev_device *dev,
193193
}
194194
udelay(1);
195195
}
196-
clear_bit(UM_PCI_STAT_WAITING, &dev->status);
196+
clear_bit(VIRTIO_PCIDEV_STAT_WAITING, &dev->status);
197197

198198
if (bounce_out)
199199
memcpy(out, buf->data, out_size);
@@ -439,7 +439,7 @@ static void virtio_pcidev_cmd_vq_cb(struct virtqueue *vq)
439439
void *cmd;
440440
int len;
441441

442-
if (test_bit(UM_PCI_STAT_WAITING, &dev->status))
442+
if (test_bit(VIRTIO_PCIDEV_STAT_WAITING, &dev->status))
443443
return;
444444

445445
while ((cmd = virtqueue_get_buf(vq, &len)))

arch/um/include/asm/cpufeature.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <asm/processor.h>
66

7-
#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
7+
#if defined(__KERNEL__) && !defined(__ASSEMBLER__)
88

99
#include <asm/asm.h>
1010
#include <linux/bitops.h>
@@ -137,5 +137,5 @@ static __always_inline bool _static_cpu_has(u16 bit)
137137
#define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \
138138
boot_cpu_data.x86_model
139139

140-
#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */
140+
#endif /* defined(__KERNEL__) && !defined(__ASSEMBLER__) */
141141
#endif /* _ASM_UM_CPUFEATURE_H */

arch/um/include/asm/current.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <linux/compiler.h>
66
#include <linux/threads.h>
77

8-
#ifndef __ASSEMBLY__
8+
#ifndef __ASSEMBLER__
99

1010
struct task_struct;
1111
extern struct task_struct *cpu_tasks[NR_CPUS];
@@ -18,6 +18,6 @@ static __always_inline struct task_struct *get_current(void)
1818

1919
#define current get_current()
2020

21-
#endif /* __ASSEMBLY__ */
21+
#endif /* __ASSEMBLER__ */
2222

2323
#endif /* __ASM_CURRENT_H */

arch/um/include/asm/mmu_context.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,16 @@
1616
#define activate_mm activate_mm
1717
static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
1818
{
19-
/*
20-
* This is called by fs/exec.c and sys_unshare()
21-
* when the new ->mm is used for the first time.
22-
*/
23-
__switch_mm(&new->context.id);
2419
}
2520

2621
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
2722
struct task_struct *tsk)
2823
{
2924
unsigned cpu = smp_processor_id();
3025

31-
if(prev != next){
26+
if (prev != next) {
3227
cpumask_clear_cpu(cpu, mm_cpumask(prev));
3328
cpumask_set_cpu(cpu, mm_cpumask(next));
34-
if(next != &init_mm)
35-
__switch_mm(&next->context.id);
3629
}
3730
}
3831

arch/um/include/asm/page.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <vdso/page.h>
1313

14-
#ifndef __ASSEMBLY__
14+
#ifndef __ASSEMBLER__
1515

1616
struct page;
1717

@@ -94,7 +94,7 @@ extern unsigned long uml_physmem;
9494
#include <asm-generic/memory_model.h>
9595
#include <asm-generic/getorder.h>
9696

97-
#endif /* __ASSEMBLY__ */
97+
#endif /* __ASSEMBLER__ */
9898

9999
#ifdef CONFIG_X86_32
100100
#define __HAVE_ARCH_GATE_AREA 1

0 commit comments

Comments
 (0)