This pull request contains the following changes for UML:

- Move to strscpy()
 - Improve panic notifiers
 - Fix NR_CPUS usage
 - Fixes for various comments
 - Fixes for virtio driver
 -----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCAA0FiEEdgfidid8lnn52cLTZvlZhesYu8EFAmNJy+8WHHJpY2hhcmRA
 c2lnbWEtc3Rhci5hdAAKCRBm+VmF6xi7wS8ZEADnEH5M4Igf2vUkBp6cGapYuLM3
 ADfDqRfJuKYOLEBSHcQ5cV6opYebPF6BJ/xvFGZyB5h5TogYAeZPHNWx6mh5PjmK
 NJjhZwwNJJakwmVPieOqS1LlDdxDW+YaWjF+tU+3kB7u5ACnaZ/bFDKoifDIvNo8
 nbFsTDXLVHYUr4b5zer9DRov4bniamn0cEMOm8FAxC9g2z/lacRAJWchzdAdyi8i
 HKctwhi4HYl3pfecwJZn5WS1aHCo3AlWovAQPY0aTZd+zUeRJBI0IerJbgxyrBfZ
 Gzr32w/DSMXEsCM3dvsRhMzkosqJSjkFdO6hnjwZVMhxFKGltMFx1wk5MFtveMmF
 FCfRgVW58AfFPst/6wWcSINnK75PgIBoetnk5RtwfiGDDYlk8foj/8wCnIFIyp6I
 PafrpqaV+KH7bs8U4upCjJFVGmgS4e1P/+W5evoPGxvc878sWa92JbFRJfImybpz
 VE8WbS+NjJs+p6rVwvzjmuF49jdEnAHHg7S7xfj+MU3/yKzTeaUwCJQdEvhUrmP/
 4gmGjSoHuFfUGu0yXA3zpJx/F4y+k8kQeVacB4t+CNAOcA93qvKxMZtXUrmfYA/9
 5nOo+TUx3dcxU7nAtcjSqh5GBCr/X0Aj2RYnERzXr1QkKf1BK3MZtxySYtQAGZvb
 sKvbGtYQi50pa006Vg==
 =YfF1
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux

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
This commit is contained in:
Linus Torvalds 2022-10-14 18:14:48 -07:00
commit 91080ab38f
14 changed files with 58 additions and 57 deletions

View File

@ -36,7 +36,6 @@ extern int console_write_chan(struct chan *chan, const char *buf,
int len); int len);
extern int console_open_chan(struct line *line, struct console *co); extern int console_open_chan(struct line *line, struct console *co);
extern void deactivate_chan(struct chan *chan, int irq); 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 void chan_enable_winch(struct chan *chan, struct tty_port *port);
extern int enable_chan(struct line *line); extern int enable_chan(struct line *line);
extern void close_chan(struct line *line); extern void close_chan(struct line *line);

View File

@ -283,7 +283,7 @@ struct unplugged_pages {
}; };
static DEFINE_MUTEX(plug_mem_mutex); 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 LIST_HEAD(unplugged_pages);
static int unplug_index = UNPLUGGED_PER_PAGE; 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, mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
strlen(message) + 1); strlen(message) + 1);
return 0; return NOTIFY_DONE;
} }
static struct notifier_block panic_exit_notifier = { static struct notifier_block panic_exit_notifier = {
.notifier_call = notify_panic, .notifier_call = notify_panic,
.next = NULL, .priority = INT_MAX, /* run as soon as possible */
.priority = 1
}; };
static int add_notifier(void) static int add_notifier(void)

View File

@ -122,7 +122,7 @@ static int __init mmapper_init(void)
return 0; return 0;
} }
static void mmapper_exit(void) static void __exit mmapper_exit(void)
{ {
misc_deregister(&mmapper_dev); misc_deregister(&mmapper_dev);
} }

View 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, static void uml_net_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info) 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 = { static const struct ethtool_ops uml_net_ethtool_ops = {

View 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 /* Changed by ssl_init and referenced by ssl_exit, which are both serialized
* by being an initcall and exitcall, respectively. * 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, static void ssl_console_write(struct console *c, const char *string,
unsigned len) unsigned len)

View File

@ -88,7 +88,7 @@ static int con_remove(int n, char **error_out)
} }
/* Set in an initcall, checked in an exitcall */ /* 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) static int con_install(struct tty_driver *driver, struct tty_struct *tty)
{ {

View File

@ -1555,7 +1555,7 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
int kernel_fd = -1; int kernel_fd = -1;
/* Only changed by the io thread. XXX: currently unused. */ /* Only changed by the io thread. XXX: currently unused. */
static int io_count = 0; static int io_count;
int io_thread(void *arg) int io_thread(void *arg)
{ {

View 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, static void vector_net_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info) 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, static int vector_net_load_bpf_flash(struct net_device *dev,

View File

@ -857,7 +857,7 @@ void *pci_root_bus_fwnode(struct pci_bus *bus)
return um_pci_fwnode; return um_pci_fwnode;
} }
static int um_pci_init(void) static int __init um_pci_init(void)
{ {
int err, i; int err, i;
@ -940,7 +940,7 @@ free:
} }
module_init(um_pci_init); 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); unregister_virtio_driver(&um_pci_virtio_driver);
irq_domain_remove(um_pci_msi_domain); irq_domain_remove(um_pci_msi_domain);

View File

@ -374,45 +374,48 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev,
u8 extra_payload[512]; u8 extra_payload[512];
} msg; } msg;
int rc; int rc;
irqreturn_t irq_rc = IRQ_NONE;
rc = vhost_user_recv_req(vu_dev, &msg.msg, while (1) {
sizeof(msg.msg.payload) + rc = vhost_user_recv_req(vu_dev, &msg.msg,
sizeof(msg.extra_payload)); sizeof(msg.msg.payload) +
sizeof(msg.extra_payload));
if (rc)
break;
vu_dev->recv_rc = rc; switch (msg.msg.header.request) {
if (rc) case VHOST_USER_SLAVE_CONFIG_CHANGE_MSG:
return IRQ_NONE; vu_dev->config_changed_irq = true;
response = 0;
switch (msg.msg.header.request) { break;
case VHOST_USER_SLAVE_CONFIG_CHANGE_MSG: case VHOST_USER_SLAVE_VRING_CALL:
vu_dev->config_changed_irq = true; virtio_device_for_each_vq((&vu_dev->vdev), vq) {
response = 0; if (vq->index == msg.msg.payload.vring_state.index) {
break; response = 0;
case VHOST_USER_SLAVE_VRING_CALL: vu_dev->vq_irq_vq_map |= BIT_ULL(vq->index);
virtio_device_for_each_vq((&vu_dev->vdev), vq) { break;
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) if (ev && !vu_dev->suspended)
time_travel_add_irq_event(ev); time_travel_add_irq_event(ev);
if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY) if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY)
vhost_user_reply(vu_dev, &msg.msg, response); vhost_user_reply(vu_dev, &msg.msg, response);
irq_rc = IRQ_HANDLED;
return 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) static irqreturn_t vu_req_interrupt(int irq, void *data)

View 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 * setup_iomem, both of which run during early boot. Afterwards, it's
* unchanged. * unchanged.
*/ */

View 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) 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) 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; static int have_console __initdata;
/* Set in uml_mem_setup and modified in linux_main */ /* 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); EXPORT_SYMBOL(physmem_size);
static const char *usage_string = static const char *usage_string =
@ -247,13 +247,13 @@ static int panic_exit(struct notifier_block *self, unsigned long unused1,
bust_spinlocks(0); bust_spinlocks(0);
uml_exitcode = 1; uml_exitcode = 1;
os_dump_core(); os_dump_core();
return 0;
return NOTIFY_DONE;
} }
static struct notifier_block panic_exit_notifier = { static struct notifier_block panic_exit_notifier = {
.notifier_call = panic_exit, .notifier_call = panic_exit,
.next = NULL, .priority = INT_MAX - 1, /* run as 2nd notifier, won't return */
.priority = 0
}; };
void uml_finishsetup(void) void uml_finishsetup(void)
@ -416,7 +416,7 @@ void __init setup_arch(char **cmdline_p)
read_initrd(); read_initrd();
paging_init(); paging_init();
strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); strscpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line; *cmdline_p = command_line;
setup_hostinfo(host_info, sizeof host_info); setup_hostinfo(host_info, sizeof host_info);

View File

@ -9,7 +9,7 @@
#include <os.h> #include <os.h>
/* Changed by set_umid_arg */ /* Changed by set_umid_arg */
static int umid_inited = 0; static int umid_inited;
static int __init set_umid_arg(char *name, int *add) static int __init set_umid_arg(char *name, int *add)
{ {

View File

@ -103,7 +103,7 @@ static char *__dentry_name(struct dentry *dentry, char *name)
*/ */
BUG_ON(p + strlen(p) + 1 != name + PATH_MAX); BUG_ON(p + strlen(p) + 1 != name + PATH_MAX);
strlcpy(name, root, PATH_MAX); strscpy(name, root, PATH_MAX);
if (len > p - name) { if (len > p - name) {
__putname(name); __putname(name);
return NULL; return NULL;