Merge tag 'for-linus-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Oct 2022 01:14:48 +0000 (18:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Oct 2022 01:14:48 +0000 (18:14 -0700)
Pull UML updates from Richard Weinberger:

 - Move to strscpy()

 - Improve panic notifiers

 - Fix NR_CPUS usage

 - Fixes for various comments

 - Fixes for virtio driver

* tag 'for-linus-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux:
  uml: Remove the initialization of statics to 0
  um: Do not initialise statics to 0.
  um: Fix comment typo
  um: Improve panic notifiers consistency and ordering
  um: remove unused reactivate_chan() declaration
  um: mmaper: add __exit annotations to module exit funcs
  um: virt-pci: add __init/__exit annotations to module init/exit funcs
  hostfs: move from strlcpy with unused retval to strscpy
  um: move from strlcpy with unused retval to strscpy
  um: increase default virtual physical memory to 64 MiB
  UM: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK
  um: read multiple msg from virtio slave request fd

14 files changed:
arch/um/drivers/chan.h
arch/um/drivers/mconsole_kern.c
arch/um/drivers/mmapper_kern.c
arch/um/drivers/net_kern.c
arch/um/drivers/ssl.c
arch/um/drivers/stdio_console.c
arch/um/drivers/ubd_kern.c
arch/um/drivers/vector_kern.c
arch/um/drivers/virt-pci.c
arch/um/drivers/virtio_uml.c
arch/um/kernel/physmem.c
arch/um/kernel/um_arch.c
arch/um/kernel/umid.c
fs/hostfs/hostfs_kern.c

index c37cc4f26f91c7e592978337352a1c8e60a4b7cf..3fec3b8406e98a2bad48c19630ce0cd801f738b4 100644 (file)
@@ -36,7 +36,6 @@ extern int console_write_chan(struct chan *chan, const char *buf,
                              int len);
 extern int console_open_chan(struct line *line, struct console *co);
 extern void deactivate_chan(struct chan *chan, int irq);
-extern void reactivate_chan(struct chan *chan, int irq);
 extern void chan_enable_winch(struct chan *chan, struct tty_port *port);
 extern int enable_chan(struct line *line);
 extern void close_chan(struct line *line);
index 8ca67a69268306c8c3ca17857d5efcd9c380e0e6..5026e7b9adfe54960544600244e5b6b59cc15c7e 100644 (file)
@@ -283,7 +283,7 @@ struct unplugged_pages {
 };
 
 static DEFINE_MUTEX(plug_mem_mutex);
-static unsigned long long unplugged_pages_count = 0;
+static unsigned long long unplugged_pages_count;
 static LIST_HEAD(unplugged_pages);
 static int unplug_index = UNPLUGGED_PER_PAGE;
 
@@ -846,13 +846,12 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1,
 
        mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
                        strlen(message) + 1);
-       return 0;
+       return NOTIFY_DONE;
 }
 
 static struct notifier_block panic_exit_notifier = {
-       .notifier_call          = notify_panic,
-       .next                   = NULL,
-       .priority               = 1
+       .notifier_call  = notify_panic,
+       .priority       = INT_MAX, /* run as soon as possible */
 };
 
 static int add_notifier(void)
index 0bf78ff8901102f55c19369fce6f030932b0ef2d..807cd33587405f47648dd8a37de184df3931b67b 100644 (file)
@@ -122,7 +122,7 @@ static int __init mmapper_init(void)
        return 0;
 }
 
-static void mmapper_exit(void)
+static void __exit mmapper_exit(void)
 {
        misc_deregister(&mmapper_dev);
 }
index 59331384c2d38914ac811356e832ee9ed2f1fa26..3d7836c46507010b03f057873665a090e3afa40d 100644 (file)
@@ -265,7 +265,7 @@ static void uml_net_poll_controller(struct net_device *dev)
 static void uml_net_get_drvinfo(struct net_device *dev,
                                struct ethtool_drvinfo *info)
 {
-       strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
+       strscpy(info->driver, DRIVER_NAME, sizeof(info->driver));
 }
 
 static const struct ethtool_ops uml_net_ethtool_ops = {
index 8514966778d5376ff4a209ee4ecff11f8a1234e7..277cea3d30eb5946d55628ad4d91d8b49d73dfcc 100644 (file)
@@ -106,7 +106,7 @@ static const struct tty_operations ssl_ops = {
 /* Changed by ssl_init and referenced by ssl_exit, which are both serialized
  * by being an initcall and exitcall, respectively.
  */
-static int ssl_init_done = 0;
+static int ssl_init_done;
 
 static void ssl_console_write(struct console *c, const char *string,
                              unsigned len)
index 489d5a746ed3363ce90c6a8e698ba718b0981ae5..1c239737d88ec75644151f19341f9362103952ce 100644 (file)
@@ -88,7 +88,7 @@ static int con_remove(int n, char **error_out)
 }
 
 /* Set in an initcall, checked in an exitcall */
-static int con_init_done = 0;
+static int con_init_done;
 
 static int con_install(struct tty_driver *driver, struct tty_struct *tty)
 {
index eb2d2f0f0bccace7c6095b629f5acc667610146a..f4c1e6e97ad520ef0e5cdabd622ec473862c7b72 100644 (file)
@@ -1555,7 +1555,7 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
 int kernel_fd = -1;
 
 /* Only changed by the io thread. XXX: currently unused. */
-static int io_count = 0;
+static int io_count;
 
 int io_thread(void *arg)
 {
index 54826531274366fc0d98e9cd8a99855da7610c53..ded7c47d2fbe5a87da2ff550224694baa95d6053 100644 (file)
@@ -1372,7 +1372,7 @@ static void vector_net_poll_controller(struct net_device *dev)
 static void vector_net_get_drvinfo(struct net_device *dev,
                                struct ethtool_drvinfo *info)
 {
-       strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
+       strscpy(info->driver, DRIVER_NAME, sizeof(info->driver));
 }
 
 static int vector_net_load_bpf_flash(struct net_device *dev,
index 02784702318419227156d7a0b199171bc4abcb79..acb55b302b14c34d7dfe14fb6ace9067d5441308 100644 (file)
@@ -857,7 +857,7 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
        return um_pci_fwnode;
 }
 
-static int um_pci_init(void)
+static int __init um_pci_init(void)
 {
        int err, i;
 
@@ -940,7 +940,7 @@ free:
 }
 module_init(um_pci_init);
 
-static void um_pci_exit(void)
+static void __exit um_pci_exit(void)
 {
        unregister_virtio_driver(&um_pci_virtio_driver);
        irq_domain_remove(um_pci_msi_domain);
index e719af8bdf56d3e9b6f98e0cf685f1ef0a78715d..588930a0ced17d8ae1026e62474e15cc41b7f881 100644 (file)
@@ -374,45 +374,48 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev,
                u8 extra_payload[512];
        } msg;
        int rc;
+       irqreturn_t irq_rc = IRQ_NONE;
 
-       rc = vhost_user_recv_req(vu_dev, &msg.msg,
-                                sizeof(msg.msg.payload) +
-                                sizeof(msg.extra_payload));
-
-       vu_dev->recv_rc = rc;
-       if (rc)
-               return IRQ_NONE;
-
-       switch (msg.msg.header.request) {
-       case VHOST_USER_SLAVE_CONFIG_CHANGE_MSG:
-               vu_dev->config_changed_irq = true;
-               response = 0;
-               break;
-       case VHOST_USER_SLAVE_VRING_CALL:
-               virtio_device_for_each_vq((&vu_dev->vdev), vq) {
-                       if (vq->index == msg.msg.payload.vring_state.index) {
-                               response = 0;
-                               vu_dev->vq_irq_vq_map |= BIT_ULL(vq->index);
-                               break;
+       while (1) {
+               rc = vhost_user_recv_req(vu_dev, &msg.msg,
+                                        sizeof(msg.msg.payload) +
+                                        sizeof(msg.extra_payload));
+               if (rc)
+                       break;
+
+               switch (msg.msg.header.request) {
+               case VHOST_USER_SLAVE_CONFIG_CHANGE_MSG:
+                       vu_dev->config_changed_irq = true;
+                       response = 0;
+                       break;
+               case VHOST_USER_SLAVE_VRING_CALL:
+                       virtio_device_for_each_vq((&vu_dev->vdev), vq) {
+                               if (vq->index == msg.msg.payload.vring_state.index) {
+                                       response = 0;
+                                       vu_dev->vq_irq_vq_map |= BIT_ULL(vq->index);
+                                       break;
+                               }
                        }
+                       break;
+               case VHOST_USER_SLAVE_IOTLB_MSG:
+                       /* not supported - VIRTIO_F_ACCESS_PLATFORM */
+               case VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG:
+                       /* not supported - VHOST_USER_PROTOCOL_F_HOST_NOTIFIER */
+               default:
+                       vu_err(vu_dev, "unexpected slave request %d\n",
+                              msg.msg.header.request);
                }
-               break;
-       case VHOST_USER_SLAVE_IOTLB_MSG:
-               /* not supported - VIRTIO_F_ACCESS_PLATFORM */
-       case VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG:
-               /* not supported - VHOST_USER_PROTOCOL_F_HOST_NOTIFIER */
-       default:
-               vu_err(vu_dev, "unexpected slave request %d\n",
-                      msg.msg.header.request);
-       }
-
-       if (ev && !vu_dev->suspended)
-               time_travel_add_irq_event(ev);
 
-       if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY)
-               vhost_user_reply(vu_dev, &msg.msg, response);
+               if (ev && !vu_dev->suspended)
+                       time_travel_add_irq_event(ev);
 
-       return IRQ_HANDLED;
+               if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY)
+                       vhost_user_reply(vu_dev, &msg.msg, response);
+               irq_rc = IRQ_HANDLED;
+       };
+       /* mask EAGAIN as we try non-blocking read until socket is empty */
+       vu_dev->recv_rc = (rc == -EAGAIN) ? 0 : rc;
+       return irq_rc;
 }
 
 static irqreturn_t vu_req_interrupt(int irq, void *data)
index e7c7b53a1435bacc8a118cfc2f7d1499534ed501..91485119ae67a7f6282e1792b8b93974e63ce332 100644 (file)
@@ -169,7 +169,7 @@ __uml_setup("iomem=", parse_iomem,
 );
 
 /*
- * This list is constructed in parse_iomem and addresses filled in in
+ * This list is constructed in parse_iomem and addresses filled in
  * setup_iomem, both of which run during early boot.  Afterwards, it's
  * unchanged.
  */
index d9e023c78f568fe8c22eb9f7ae07f0cba0a716df..8adf8e89b25588763799f12a676958a3f99e75ae 100644 (file)
@@ -96,7 +96,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
-       return *pos < NR_CPUS ? cpu_data + *pos : NULL;
+       return *pos < nr_cpu_ids ? cpu_data + *pos : NULL;
 }
 
 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
@@ -132,7 +132,7 @@ static int have_root __initdata;
 static int have_console __initdata;
 
 /* Set in uml_mem_setup and modified in linux_main */
-long long physmem_size = 32 * 1024 * 1024;
+long long physmem_size = 64 * 1024 * 1024;
 EXPORT_SYMBOL(physmem_size);
 
 static const char *usage_string =
@@ -247,13 +247,13 @@ static int panic_exit(struct notifier_block *self, unsigned long unused1,
        bust_spinlocks(0);
        uml_exitcode = 1;
        os_dump_core();
-       return 0;
+
+       return NOTIFY_DONE;
 }
 
 static struct notifier_block panic_exit_notifier = {
-       .notifier_call          = panic_exit,
-       .next                   = NULL,
-       .priority               = 0
+       .notifier_call  = panic_exit,
+       .priority       = INT_MAX - 1, /* run as 2nd notifier, won't return */
 };
 
 void uml_finishsetup(void)
@@ -416,7 +416,7 @@ void __init setup_arch(char **cmdline_p)
        read_initrd();
 
        paging_init();
-       strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
+       strscpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
        *cmdline_p = command_line;
        setup_hostinfo(host_info, sizeof host_info);
 
index 8031a038eb5889b35da5582ceceba7688c13f1c9..72bc60ade347bc5cd029601aeb5b6e54ddfe1d20 100644 (file)
@@ -9,7 +9,7 @@
 #include <os.h>
 
 /* Changed by set_umid_arg */
-static int umid_inited = 0;
+static int umid_inited;
 
 static int __init set_umid_arg(char *name, int *add)
 {
index 07881b76d42f99070c146c4e28972d94f61856af..277468783feeecbe8199da3d4ab7df924ff3e2e6 100644 (file)
@@ -103,7 +103,7 @@ static char *__dentry_name(struct dentry *dentry, char *name)
         */
        BUG_ON(p + strlen(p) + 1 != name + PATH_MAX);
 
-       strlcpy(name, root, PATH_MAX);
+       strscpy(name, root, PATH_MAX);
        if (len > p - name) {
                __putname(name);
                return NULL;