Skip to content

Commit 64e8516

Browse files
committed
Merge tag 'uml-for-linus-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux
Pull UML updates from Richard Weinberger: - Add support for rust (yay!) - Add support for LTO - Add platform bus support to virtio-pci - Various virtio fixes - Coding style, spelling cleanups * tag 'uml-for-linus-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux: (27 commits) Documentation: rust: Fix arch support table uml: vector: Remove unused definitions VECTOR_{WRITE,HEADERS} um: virt-pci: properly remove PCI device from bus um: virtio_uml: move device breaking into workqueue um: virtio_uml: mark device as unregistered when breaking it um: virtio_uml: free command if adding to virtqueue failed UML: define RUNTIME_DISCARD_EXIT virt-pci: add platform bus support um-virt-pci: Make max delay configurable um: virt-pci: implement pcibios_get_phb_of_node() um: Support LTO um: put power options in a menu um: Use CFLAGS_vmlinux um: Prevent building modules incompatible with MODVERSIONS um: Avoid pcap multiple definition errors um: Make the definition of cpu_data more compatible x86: um: vdso: Add '%rcx' and '%r11' to the syscall clobber list rust: arch/um: Add support for CONFIG_RUST under x86_64 UML rust: arch/um: Disable FP/SIMD instruction to match x86 rust: arch/um: Use 'pie' relocation mode under UML ...
2 parents e31b283 + 04df97e commit 64e8516

File tree

21 files changed

+268
-111
lines changed

21 files changed

+268
-111
lines changed

Documentation/rust/arch-support.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
1616
Architecture Level of support Constraints
1717
============ ================ ==============================================
1818
``x86`` Maintained ``x86_64`` only.
19+
``um`` Maintained ``x86_64`` only.
1920
============ ================ ==============================================
21+

arch/um/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ config UML
2525
select GENERIC_IRQ_SHOW
2626
select GENERIC_CPU_DEVICES
2727
select HAVE_GCC_PLUGINS
28+
select ARCH_SUPPORTS_LTO_CLANG
29+
select ARCH_SUPPORTS_LTO_CLANG_THIN
2830
select TRACE_IRQFLAGS_SUPPORT
2931
select TTY # Needed for line.c
3032
select HAVE_ARCH_VMAP_STACK
33+
select HAVE_RUST if X86_64
3134

3235
config MMU
3336
bool
@@ -242,4 +245,8 @@ source "arch/um/drivers/Kconfig"
242245
config ARCH_SUSPEND_POSSIBLE
243246
def_bool y
244247

248+
menu "Power management options"
249+
245250
source "kernel/power/Kconfig"
251+
252+
endmenu

arch/um/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
6868
-Din6addr_loopback=kernel_in6addr_loopback \
6969
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
7070

71+
KBUILD_RUSTFLAGS += -Crelocation-model=pie
72+
7173
KBUILD_AFLAGS += $(ARCH_INCLUDE)
7274

7375
USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
@@ -139,11 +141,10 @@ ifeq ($(CONFIG_LD_IS_BFD),y)
139141
LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments)
140142
endif
141143

142-
LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt))
144+
LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt))
143145

144146
# Used by link-vmlinux.sh which has special support for um link
145-
export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
146-
export LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK)
147+
export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_LTO)
147148

148149
# When cleaning we don't include .config, so we don't include
149150
# TT or skas makefiles and don't clean skas_ptregs.h.

arch/um/drivers/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ config UML_NET_VECTOR
261261
config UML_NET_VDE
262262
bool "VDE transport (obsolete)"
263263
depends on UML_NET
264+
depends on !MODVERSIONS
264265
select MAY_HAVE_RUNTIME_DEPS
265266
help
266267
This User-Mode Linux network transport allows one or more running
@@ -309,6 +310,7 @@ config UML_NET_MCAST
309310
config UML_NET_PCAP
310311
bool "pcap transport (obsolete)"
311312
depends on UML_NET
313+
depends on !MODVERSIONS
312314
select MAY_HAVE_RUNTIME_DEPS
313315
help
314316
The pcap transport makes a pcap packet stream on the host look

arch/um/drivers/pcap_kern.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct pcap_init {
1515
char *filter;
1616
};
1717

18-
void pcap_init(struct net_device *dev, void *data)
18+
void pcap_init_kern(struct net_device *dev, void *data)
1919
{
2020
struct uml_net_private *pri;
2121
struct pcap_data *ppri;
@@ -44,7 +44,7 @@ static int pcap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
4444
}
4545

4646
static const struct net_kern_info pcap_kern_info = {
47-
.init = pcap_init,
47+
.init = pcap_init_kern,
4848
.protocol = eth_protocol,
4949
.read = pcap_read,
5050
.write = pcap_write,

arch/um/drivers/vector_kern.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ static int vector_config(char *str, char **error_out)
767767

768768
if (parsed == NULL) {
769769
*error_out = "vector_config failed to parse parameters";
770+
kfree(params);
770771
return -EINVAL;
771772
}
772773

arch/um/drivers/vector_user.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ struct vector_fds {
6868
};
6969

7070
#define VECTOR_READ 1
71-
#define VECTOR_WRITE (1 < 1)
72-
#define VECTOR_HEADERS (1 < 2)
7371

7472
extern struct arglist *uml_parse_vector_ifspec(char *arg);
7573

arch/um/drivers/virt-pci.c

Lines changed: 132 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/virtio.h>
99
#include <linux/virtio_config.h>
1010
#include <linux/logic_iomem.h>
11+
#include <linux/of_platform.h>
1112
#include <linux/irqdomain.h>
1213
#include <linux/virtio_pcidev.h>
1314
#include <linux/virtio-uml.h>
@@ -39,6 +40,8 @@ struct um_pci_device {
3940
unsigned long status;
4041

4142
int irq;
43+
44+
bool platform;
4245
};
4346

4447
struct um_pci_device_reg {
@@ -48,13 +51,15 @@ struct um_pci_device_reg {
4851

4952
static struct pci_host_bridge *bridge;
5053
static DEFINE_MUTEX(um_pci_mtx);
54+
static struct um_pci_device *um_pci_platform_device;
5155
static struct um_pci_device_reg um_pci_devices[MAX_DEVICES];
5256
static struct fwnode_handle *um_pci_fwnode;
5357
static struct irq_domain *um_pci_inner_domain;
5458
static struct irq_domain *um_pci_msi_domain;
5559
static unsigned long um_pci_msi_used[BITS_TO_LONGS(MAX_MSI_VECTORS)];
5660

57-
#define UM_VIRT_PCI_MAXDELAY 40000
61+
static unsigned int um_pci_max_delay_us = 40000;
62+
module_param_named(max_delay_us, um_pci_max_delay_us, uint, 0644);
5863

5964
struct um_pci_message_buffer {
6065
struct virtio_pcidev_msg hdr;
@@ -132,8 +137,11 @@ static int um_pci_send_cmd(struct um_pci_device *dev,
132137
out ? 1 : 0,
133138
posted ? cmd : HANDLE_NO_FREE(cmd),
134139
GFP_ATOMIC);
135-
if (ret)
140+
if (ret) {
141+
if (posted)
142+
kfree(cmd);
136143
goto out;
144+
}
137145

138146
if (posted) {
139147
virtqueue_kick(dev->cmd_vq);
@@ -155,7 +163,7 @@ static int um_pci_send_cmd(struct um_pci_device *dev,
155163
kfree(completed);
156164

157165
if (WARN_ONCE(virtqueue_is_broken(dev->cmd_vq) ||
158-
++delay_count > UM_VIRT_PCI_MAXDELAY,
166+
++delay_count > um_pci_max_delay_us,
159167
"um virt-pci delay: %d", delay_count)) {
160168
ret = -EIO;
161169
break;
@@ -480,6 +488,9 @@ static void um_pci_handle_irq_message(struct virtqueue *vq,
480488
struct virtio_device *vdev = vq->vdev;
481489
struct um_pci_device *dev = vdev->priv;
482490

491+
if (!dev->irq)
492+
return;
493+
483494
/* we should properly chain interrupts, but on ARCH=um we don't care */
484495

485496
switch (msg->op) {
@@ -533,6 +544,25 @@ static void um_pci_irq_vq_cb(struct virtqueue *vq)
533544
}
534545
}
535546

547+
/* Copied from arch/x86/kernel/devicetree.c */
548+
struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
549+
{
550+
struct device_node *np;
551+
552+
for_each_node_by_type(np, "pci") {
553+
const void *prop;
554+
unsigned int bus_min;
555+
556+
prop = of_get_property(np, "bus-range", NULL);
557+
if (!prop)
558+
continue;
559+
bus_min = be32_to_cpup(prop);
560+
if (bus->number == bus_min)
561+
return np;
562+
}
563+
return NULL;
564+
}
565+
536566
static int um_pci_init_vqs(struct um_pci_device *dev)
537567
{
538568
struct virtqueue *vqs[2];
@@ -561,6 +591,55 @@ static int um_pci_init_vqs(struct um_pci_device *dev)
561591
return 0;
562592
}
563593

594+
static void __um_pci_virtio_platform_remove(struct virtio_device *vdev,
595+
struct um_pci_device *dev)
596+
{
597+
virtio_reset_device(vdev);
598+
vdev->config->del_vqs(vdev);
599+
600+
mutex_lock(&um_pci_mtx);
601+
um_pci_platform_device = NULL;
602+
mutex_unlock(&um_pci_mtx);
603+
604+
kfree(dev);
605+
}
606+
607+
static int um_pci_virtio_platform_probe(struct virtio_device *vdev,
608+
struct um_pci_device *dev)
609+
{
610+
int ret;
611+
612+
dev->platform = true;
613+
614+
mutex_lock(&um_pci_mtx);
615+
616+
if (um_pci_platform_device) {
617+
mutex_unlock(&um_pci_mtx);
618+
ret = -EBUSY;
619+
goto out_free;
620+
}
621+
622+
ret = um_pci_init_vqs(dev);
623+
if (ret) {
624+
mutex_unlock(&um_pci_mtx);
625+
goto out_free;
626+
}
627+
628+
um_pci_platform_device = dev;
629+
630+
mutex_unlock(&um_pci_mtx);
631+
632+
ret = of_platform_default_populate(vdev->dev.of_node, NULL, &vdev->dev);
633+
if (ret)
634+
__um_pci_virtio_platform_remove(vdev, dev);
635+
636+
return ret;
637+
638+
out_free:
639+
kfree(dev);
640+
return ret;
641+
}
642+
564643
static int um_pci_virtio_probe(struct virtio_device *vdev)
565644
{
566645
struct um_pci_device *dev;
@@ -574,6 +653,9 @@ static int um_pci_virtio_probe(struct virtio_device *vdev)
574653
dev->vdev = vdev;
575654
vdev->priv = dev;
576655

656+
if (of_device_is_compatible(vdev->dev.of_node, "simple-bus"))
657+
return um_pci_virtio_platform_probe(vdev, dev);
658+
577659
mutex_lock(&um_pci_mtx);
578660
for (i = 0; i < MAX_DEVICES; i++) {
579661
if (um_pci_devices[i].dev)
@@ -623,22 +705,39 @@ static void um_pci_virtio_remove(struct virtio_device *vdev)
623705
struct um_pci_device *dev = vdev->priv;
624706
int i;
625707

626-
/* Stop all virtqueues */
627-
virtio_reset_device(vdev);
628-
vdev->config->del_vqs(vdev);
708+
if (dev->platform) {
709+
of_platform_depopulate(&vdev->dev);
710+
__um_pci_virtio_platform_remove(vdev, dev);
711+
return;
712+
}
629713

630714
device_set_wakeup_enable(&vdev->dev, false);
631715

632716
mutex_lock(&um_pci_mtx);
633717
for (i = 0; i < MAX_DEVICES; i++) {
634718
if (um_pci_devices[i].dev != dev)
635719
continue;
720+
636721
um_pci_devices[i].dev = NULL;
637722
irq_free_desc(dev->irq);
723+
724+
break;
638725
}
639726
mutex_unlock(&um_pci_mtx);
640727

641-
um_pci_rescan();
728+
if (i < MAX_DEVICES) {
729+
struct pci_dev *pci_dev;
730+
731+
pci_dev = pci_get_slot(bridge->bus, i);
732+
if (pci_dev)
733+
pci_stop_and_remove_bus_device_locked(pci_dev);
734+
}
735+
736+
/* Stop all virtqueues */
737+
virtio_reset_device(vdev);
738+
dev->cmd_vq = NULL;
739+
dev->irq_vq = NULL;
740+
vdev->config->del_vqs(vdev);
642741

643742
kfree(dev);
644743
}
@@ -860,6 +959,30 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
860959
return um_pci_fwnode;
861960
}
862961

962+
static long um_pci_map_platform(unsigned long offset, size_t size,
963+
const struct logic_iomem_ops **ops,
964+
void **priv)
965+
{
966+
if (!um_pci_platform_device)
967+
return -ENOENT;
968+
969+
*ops = &um_pci_device_bar_ops;
970+
*priv = &um_pci_platform_device->resptr[0];
971+
972+
return 0;
973+
}
974+
975+
static const struct logic_iomem_region_ops um_pci_platform_ops = {
976+
.map = um_pci_map_platform,
977+
};
978+
979+
static struct resource virt_platform_resource = {
980+
.name = "platform",
981+
.start = 0x10000000,
982+
.end = 0x1fffffff,
983+
.flags = IORESOURCE_MEM,
984+
};
985+
863986
static int __init um_pci_init(void)
864987
{
865988
int err, i;
@@ -868,6 +991,8 @@ static int __init um_pci_init(void)
868991
&um_pci_cfgspace_ops));
869992
WARN_ON(logic_iomem_add_region(&virt_iomem_resource,
870993
&um_pci_iomem_ops));
994+
WARN_ON(logic_iomem_add_region(&virt_platform_resource,
995+
&um_pci_platform_ops));
871996

872997
if (WARN(CONFIG_UML_PCI_OVER_VIRTIO_DEVICE_ID < 0,
873998
"No virtio device ID configured for PCI - no PCI support\n"))

arch/um/drivers/virtio_uml.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ static void vhost_user_check_reset(struct virtio_uml_device *vu_dev,
168168
if (!vu_dev->registered)
169169
return;
170170

171-
virtio_break_device(&vu_dev->vdev);
171+
vu_dev->registered = 0;
172+
172173
schedule_work(&pdata->conn_broken_wk);
173174
}
174175

@@ -412,7 +413,7 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev,
412413
if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY)
413414
vhost_user_reply(vu_dev, &msg.msg, response);
414415
irq_rc = IRQ_HANDLED;
415-
};
416+
}
416417
/* mask EAGAIN as we try non-blocking read until socket is empty */
417418
vu_dev->recv_rc = (rc == -EAGAIN) ? 0 : rc;
418419
return irq_rc;
@@ -1136,6 +1137,15 @@ void virtio_uml_set_no_vq_suspend(struct virtio_device *vdev,
11361137

11371138
static void vu_of_conn_broken(struct work_struct *wk)
11381139
{
1140+
struct virtio_uml_platform_data *pdata;
1141+
struct virtio_uml_device *vu_dev;
1142+
1143+
pdata = container_of(wk, struct virtio_uml_platform_data, conn_broken_wk);
1144+
1145+
vu_dev = platform_get_drvdata(pdata->pdev);
1146+
1147+
virtio_break_device(&vu_dev->vdev);
1148+
11391149
/*
11401150
* We can't remove the device from the devicetree so the only thing we
11411151
* can do is warn.
@@ -1266,8 +1276,14 @@ static int vu_unregister_cmdline_device(struct device *dev, void *data)
12661276
static void vu_conn_broken(struct work_struct *wk)
12671277
{
12681278
struct virtio_uml_platform_data *pdata;
1279+
struct virtio_uml_device *vu_dev;
12691280

12701281
pdata = container_of(wk, struct virtio_uml_platform_data, conn_broken_wk);
1282+
1283+
vu_dev = platform_get_drvdata(pdata->pdev);
1284+
1285+
virtio_break_device(&vu_dev->vdev);
1286+
12711287
vu_unregister_cmdline_device(&pdata->pdev->dev, NULL);
12721288
}
12731289

0 commit comments

Comments
 (0)