From richard at nod.at  Sat Jan  1 13:58:10 2022
From: richard at nod.at (Richard Weinberger)
Date: Sat,  1 Jan 2022 22:58:10 +0100
Subject: [PATCH 4/4] um: irq: Restore O_ASYNC upon exit
In-Reply-To: <20220101215810.13260-1-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
Message-ID: <20220101215810.13260-5-richard@nod.at>

Just like with O_NONBLOCK, make sure UML clears O_ASYNC
upon exit when it set it.

Signed-off-by: Richard Weinberger <richard at nod.at>
---
 arch/um/kernel/irq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index a8873d9bc28b..e020bdccfa23 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -342,6 +342,7 @@ static void free_irq_by_irq_and_dev(unsigned int irq, void *dev)
 				continue;
 
 			os_del_epoll_fd(entry->fd);
+			os_clear_fd_async(entry->fd);
 			reg->events = 0;
 			update_or_free_irq_entry(entry);
 			goto out;
@@ -396,8 +397,10 @@ int deactivate_all_fds(void)
 	os_set_ioignore();
 
 	/* we can no longer call kfree() here so just deactivate */
-	list_for_each_entry(entry, &active_fds, list)
+	list_for_each_entry(entry, &active_fds, list) {
 		os_del_epoll_fd(entry->fd);
+		os_clear_fd_async(entry->fd);
+	}
 	os_close_epoll_fd();
 	return 0;
 }
-- 
2.26.2



From richard at nod.at  Sat Jan  1 13:58:06 2022
From: richard at nod.at (Richard Weinberger)
Date: Sat,  1 Jan 2022 22:58:06 +0100
Subject: [PATCH 0/4] um: Assorted console related fixes
Message-ID: <20220101215810.13260-1-richard@nod.at>

When UML terminates (gracefully or panic) it does not always
cleanup on the host side.
Especially when fd:0,fd:1 is used as console it can leave a misconfigured
stdin/out on the host side.
Also stale processes such as port-helper can left behind.

This series fixes the console exit code to make sure UML
undoes everything it changed on the host side.

Richard Weinberger (4):
  um: Run console exit code also upon kernel panic
  um: os_set_fd_block: Return old blocking mode
  um: chan: Restore blocking mode upon exit
  um: irq: Restore O_ASYNC upon exit

 arch/um/drivers/chan.h               |  1 +
 arch/um/drivers/chan_kern.c          | 11 +++++++----
 arch/um/drivers/chan_user.c          |  2 +-
 arch/um/drivers/mconsole_kern.c      |  2 +-
 arch/um/drivers/stdio_console.c      |  4 ++--
 arch/um/drivers/ubd_user.c           |  2 +-
 arch/um/drivers/xterm.c              |  2 +-
 arch/um/include/shared/uml_console.h | 11 +++++++++++
 arch/um/kernel/irq.c                 |  5 ++++-
 arch/um/kernel/um_arch.c             |  8 +++++---
 arch/um/os-Linux/file.c              |  5 ++++-
 11 files changed, 38 insertions(+), 15 deletions(-)
 create mode 100644 arch/um/include/shared/uml_console.h

-- 
2.26.2



From richard at nod.at  Sat Jan  1 13:58:09 2022
From: richard at nod.at (Richard Weinberger)
Date: Sat,  1 Jan 2022 22:58:09 +0100
Subject: [PATCH 3/4] um: chan: Restore blocking mode upon exit
In-Reply-To: <20220101215810.13260-1-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
Message-ID: <20220101215810.13260-4-richard@nod.at>

Make sure that O_NONBLOCK is cleared upon exit if UML sets it.
Otherwise stdin/out behaves strange after UML terminates.

Signed-off-by: Richard Weinberger <richard at nod.at>
---
 arch/um/drivers/chan.h      | 1 +
 arch/um/drivers/chan_kern.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h
index c37cc4f26f91..6b8c462f146e 100644
--- a/arch/um/drivers/chan.h
+++ b/arch/um/drivers/chan.h
@@ -22,6 +22,7 @@ struct chan {
 	unsigned int output:1;
 	unsigned int opened:1;
 	unsigned int enabled:1;
+	unsigned int fd_blocking:1;
 	int fd;
 	const struct chan_ops *ops;
 	void *data;
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 86be115b5890..6d512589fa50 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -102,6 +102,7 @@ static int open_one_chan(struct chan *chan)
 	}
 
 	chan->fd = fd;
+	chan->fd_blocking = ret;
 
 	chan->opened = 1;
 	return 0;
@@ -223,6 +224,8 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
 	if (chan->ops->close != NULL)
 		(*chan->ops->close)(chan->fd, chan->data);
 
+	os_set_fd_block(chan->fd, chan->fd_blocking);
+
 	chan->opened = 0;
 	chan->fd = -1;
 }
-- 
2.26.2



From richard at nod.at  Sat Jan  1 13:58:07 2022
From: richard at nod.at (Richard Weinberger)
Date: Sat,  1 Jan 2022 22:58:07 +0100
Subject: [PATCH 1/4] um: Run console exit code also upon kernel panic
In-Reply-To: <20220101215810.13260-1-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
Message-ID: <20220101215810.13260-2-richard@nod.at>

Make sure that UML's console exit handler run also when the kernel
crashes.
That way settings and resources can get restored.

Signed-off-by: Richard Weinberger <richard at nod.at>
---
 arch/um/drivers/stdio_console.c      |  4 ++--
 arch/um/include/shared/uml_console.h | 11 +++++++++++
 arch/um/kernel/um_arch.c             |  8 +++++---
 3 files changed, 18 insertions(+), 5 deletions(-)
 create mode 100644 arch/um/include/shared/uml_console.h

diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index e8b762f4d8c2..06612c3b6240 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -180,13 +180,13 @@ static int stdio_init(void)
 }
 late_initcall(stdio_init);
 
-static void console_exit(void)
+void uml_console_exit(void)
 {
 	if (!con_init_done)
 		return;
 	close_lines(vts, ARRAY_SIZE(vts));
 }
-__uml_exitcall(console_exit);
+__uml_exitcall(uml_console_exit);
 
 static int console_chan_setup(char *str)
 {
diff --git a/arch/um/include/shared/uml_console.h b/arch/um/include/shared/uml_console.h
new file mode 100644
index 000000000000..aa8d02fe5e90
--- /dev/null
+++ b/arch/um/include/shared/uml_console.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022 Richard Weinberger <richard at nod.at>
+ */
+
+#ifndef UML_CONSOLE_H
+#define UML_CONSOLE_H
+
+extern void uml_console_exit(void);
+
+#endif /* UML_CONSOLE_H */
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index abceeabe29b9..0bdae61929ef 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -17,17 +17,18 @@
 #include <linux/kmsg_dump.h>
 #include <linux/suspend.h>
 
-#include <asm/processor.h>
+#include <arch.h>
+#include <as-layout.h>
 #include <asm/cpufeature.h>
+#include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
-#include <as-layout.h>
-#include <arch.h>
 #include <init.h>
 #include <kern.h>
 #include <kern_util.h>
 #include <mem_user.h>
 #include <os.h>
+#include <uml_console.h>
 
 #include "um_arch.h"
 
@@ -245,6 +246,7 @@ static int panic_exit(struct notifier_block *self, unsigned long unused1,
 	bust_spinlocks(1);
 	bust_spinlocks(0);
 	uml_exitcode = 1;
+	uml_console_exit();
 	os_dump_core();
 	return 0;
 }
-- 
2.26.2



From richard at nod.at  Sat Jan  1 13:58:08 2022
From: richard at nod.at (Richard Weinberger)
Date: Sat,  1 Jan 2022 22:58:08 +0100
Subject: [PATCH 2/4] um: os_set_fd_block: Return old blocking mode
In-Reply-To: <20220101215810.13260-1-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
Message-ID: <20220101215810.13260-3-richard@nod.at>

This will be needed when we restore the old mode upon exit.
The function now returns < 0 in case of an error, 1 if O_NONBLOCK
was set, 0 otherwise.

Signed-off-by: Richard Weinberger <richard at nod.at>
---
 arch/um/drivers/chan_kern.c     | 8 ++++----
 arch/um/drivers/chan_user.c     | 2 +-
 arch/um/drivers/mconsole_kern.c | 2 +-
 arch/um/drivers/ubd_user.c      | 2 +-
 arch/um/drivers/xterm.c         | 2 +-
 arch/um/os-Linux/file.c         | 5 ++++-
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 62997055c454..86be115b5890 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -83,7 +83,7 @@ static const struct chan_ops not_configged_ops = {
 
 static int open_one_chan(struct chan *chan)
 {
-	int fd, err;
+	int fd, ret;
 
 	if (chan->opened)
 		return 0;
@@ -95,10 +95,10 @@ static int open_one_chan(struct chan *chan)
 	if (fd < 0)
 		return fd;
 
-	err = os_set_fd_block(fd, 0);
-	if (err) {
+	ret = os_set_fd_block(fd, 0);
+	if (ret < 0) {
 		(*chan->ops->close)(fd, chan->data);
-		return err;
+		return ret;
 	}
 
 	chan->fd = fd;
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
index 6040817c036f..b449656cd5f8 100644
--- a/arch/um/drivers/chan_user.c
+++ b/arch/um/drivers/chan_user.c
@@ -257,7 +257,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
 	}
 
 	err = os_set_fd_block(*fd_out, 0);
-	if (err) {
+	if (err < 0) {
 		printk(UM_KERN_ERR "winch_tramp: failed to set thread_fd "
 		       "non-blocking.\n");
 		goto out_close;
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 6ead1e240457..8000914f9cd4 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -732,7 +732,7 @@ static int __init mconsole_init(void)
 		printk(KERN_ERR "Failed to initialize management console\n");
 		return 1;
 	}
-	if (os_set_fd_block(sock, 0))
+	if (os_set_fd_block(sock, 0) < 0)
 		goto out;
 
 	register_reboot_notifier(&reboot_notifier);
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
index a1afe414ce48..a930a254826b 100644
--- a/arch/um/drivers/ubd_user.c
+++ b/arch/um/drivers/ubd_user.c
@@ -42,7 +42,7 @@ int start_io_thread(unsigned long sp, int *fd_out)
 
 	err = os_set_fd_block(*fd_out, 0);
 	err = os_set_fd_block(kernel_fd, 0);
-	if (err) {
+	if (err < 0) {
 		printk("start_io_thread - failed to set nonblocking I/O.\n");
 		goto out_close;
 	}
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index 87ca4a47cd66..01be81c25266 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -161,7 +161,7 @@ static int xterm_open(int input, int output, int primary, void *d,
 	}
 
 	err = os_set_fd_block(new, 0);
-	if (err) {
+	if (err < 0) {
 		printk(UM_KERN_ERR "xterm_open : failed to set xterm "
 		       "descriptor non-blocking, err = %d\n", -err);
 		goto out_close2;
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index e4421dbc4c36..af2b3cba2c93 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -445,11 +445,14 @@ int os_clear_fd_async(int fd)
 int os_set_fd_block(int fd, int blocking)
 {
 	int flags;
+	int oldmode;
 
 	flags = fcntl(fd, F_GETFL);
 	if (flags < 0)
 		return -errno;
 
+	oldmode = !!(flags & O_NONBLOCK);
+
 	if (blocking)
 		flags &= ~O_NONBLOCK;
 	else
@@ -458,7 +461,7 @@ int os_set_fd_block(int fd, int blocking)
 	if (fcntl(fd, F_SETFL, flags) < 0)
 		return -errno;
 
-	return 0;
+	return oldmode;
 }
 
 int os_accept_connection(int fd)
-- 
2.26.2



From rdunlap at infradead.org  Sat Jan  1 23:06:09 2022
From: rdunlap at infradead.org (Randy Dunlap)
Date: Sat,  1 Jan 2022 23:06:09 -0800
Subject: [PATCH 1/2] IB/qib: don't use qib_wc_x86_64 for UML
Message-ID: <20220102070609.22783-1-rdunlap@infradead.org>

When building qib_wc_x86_64.c on ARCH=um, references to some cpuinfo
fields cause build errors since cpuinfo does not contain x86-specific
fields.

This source file is x86_64-specific, so don't include it in the
target object file when CONFIG_UML is set/enabled.

Prevents these build errors:

../drivers/infiniband/hw/qib/qib_wc_x86_64.c: In function ?qib_unordered_wc?:
../drivers/infiniband/hw/qib/qib_wc_x86_64.c:149:22: error: ?struct cpuinfo_um? has no member named ?x86_vendor?
  return boot_cpu_data.x86_vendor != X86_VENDOR_AMD;
                      ^
../drivers/infiniband/hw/qib/qib_wc_x86_64.c:149:37: error: ?X86_VENDOR_AMD? undeclared (first use in this function); did you mean ?X86_VENDOR_ANY??
  return boot_cpu_data.x86_vendor != X86_VENDOR_AMD;
                                     ^~~~~~~~~~~~~~
../drivers/infiniband/hw/qib/qib_wc_x86_64.c:150:1: error: control reaches end of non-void function [-Werror=return-type]

Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
---
 drivers/infiniband/hw/qib/Makefile |    2 ++
 1 file changed, 2 insertions(+)

--- linux-next-20211224.orig/drivers/infiniband/hw/qib/Makefile
+++ linux-next-20211224/drivers/infiniband/hw/qib/Makefile
@@ -12,6 +12,8 @@ ib_qib-y := qib_diag.o qib_driver.o qib_
 # 6120 has no fallback if no MSI interrupts, others can do INTx
 ib_qib-$(CONFIG_PCI_MSI) += qib_iba6120.o
 
+ifeq ($(CONFIG_UML),)
 ib_qib-$(CONFIG_X86_64) += qib_wc_x86_64.o
+endif
 ib_qib-$(CONFIG_PPC64) += qib_wc_ppc64.o
 ib_qib-$(CONFIG_DEBUG_FS) += qib_debugfs.o


From rdunlap at infradead.org  Sat Jan  1 23:06:23 2022
From: rdunlap at infradead.org (Randy Dunlap)
Date: Sat,  1 Jan 2022 23:06:23 -0800
Subject: [PATCH 2/2] IB/rdmavt: modify rdmavt/qp.c for UML
Message-ID: <20220102070623.24009-1-rdunlap@infradead.org>

When building rdmavt for ARCH=um, qp.c has a build error on a reference
to the x86-specific cpuinfo field 'x86_cache_size'. This value is then
used to determine whether to use cacheless_memcpy() or not.
Provide a fake value to LLC for CONFIG_UML. Then provide a separate
verison of cacheless_memcpy() for CONFIG_UML that is just a plain
memcpy(), like the calling code uses.

Prevents these build errors:

../drivers/infiniband/sw/rdmavt/qp.c: In function ?rvt_wss_llc_size?:
../drivers/infiniband/sw/rdmavt/qp.c:88:23: error: ?struct cpuinfo_um? has no member named ?x86_cache_size?; did you mean ?x86_capability??
  return boot_cpu_data.x86_cache_size;

../drivers/infiniband/sw/rdmavt/qp.c: In function ?cacheless_memcpy?:
../drivers/infiniband/sw/rdmavt/qp.c:100:2: error: implicit declaration of function ?__copy_user_nocache?; did you mean ?copy_user_page?? [-Werror=implicit-function-declaration]
  __copy_user_nocache(dst, (void __user *)src, n, 0);

Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
---
 drivers/infiniband/sw/rdmavt/qp.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- linux-next-20211224.orig/drivers/infiniband/sw/rdmavt/qp.c
+++ linux-next-20211224/drivers/infiniband/sw/rdmavt/qp.c
@@ -84,10 +84,15 @@ EXPORT_SYMBOL(ib_rvt_state_ops);
 /* platform specific: return the last level cache (llc) size, in KiB */
 static int rvt_wss_llc_size(void)
 {
+#if !defined(CONFIG_UML)
 	/* assume that the boot CPU value is universal for all CPUs */
 	return boot_cpu_data.x86_cache_size;
+#else /* CONFIG_UML */
+	return 1024;	/* fake 1 MB LLC size */
+#endif
 }
 
+#if !defined(CONFIG_UML)
 /* platform specific: cacheless copy */
 static void cacheless_memcpy(void *dst, void *src, size_t n)
 {
@@ -99,6 +104,13 @@ static void cacheless_memcpy(void *dst,
 	 */
 	__copy_user_nocache(dst, (void __user *)src, n, 0);
 }
+#else
+/* for CONFIG_UML, this is just a plain memcpy() */
+static void cacheless_memcpy(void *dst, void *src, size_t n)
+{
+	memcpy(dst, src, n);
+}
+#endif
 
 void rvt_wss_exit(struct rvt_dev_info *rdi)
 {


From johannes at sipsolutions.net  Mon Jan  3 07:40:15 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Mon,  3 Jan 2022 16:40:15 +0100
Subject: [PATCH] lib/logic_iomem: correct fallback config references
Message-ID: <20220103164015.6bfbac3b1010.I44342c6303ec35d688631ce9cfb6cfa9b4537006@changeid>

From: Johannes Berg <johannes.berg at intel.com>

Due to some renaming, we ended up with the "indirect iomem"
naming in Kconfig, following INDIRECT_PIO. However, clearly
I missed following through on that in the ifdefs, but so far
INDIRECT_IOMEM_FALLBACK isn't used by any architecture.

Reported-by: Lukas Bulwahn <lukas.bulwahn at gmail.com>
Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 lib/logic_iomem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
index 9bdfde0c0f86..8cafe4a9e874 100644
--- a/lib/logic_iomem.c
+++ b/lib/logic_iomem.c
@@ -68,7 +68,7 @@ int logic_iomem_add_region(struct resource *resource,
 }
 EXPORT_SYMBOL(logic_iomem_add_region);
 
-#ifndef CONFIG_LOGIC_IOMEM_FALLBACK
+#ifndef CONFIG_INDIRECT_IOMEM_FALLBACK
 static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
 {
 	WARN(1, "invalid ioremap(0x%llx, 0x%zx)\n",
@@ -81,7 +81,7 @@ static void real_iounmap(void __iomem *addr)
 	WARN(1, "invalid iounmap for addr 0x%llx\n",
 	     (unsigned long long __force)addr);
 }
-#endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
+#endif /* CONFIG_INDIRECT_IOMEM_FALLBACK */
 
 void __iomem *ioremap(phys_addr_t offset, size_t size)
 {
@@ -168,7 +168,7 @@ void iounmap(void __iomem *addr)
 }
 EXPORT_SYMBOL(iounmap);
 
-#ifndef CONFIG_LOGIC_IOMEM_FALLBACK
+#ifndef CONFIG_INDIRECT_IOMEM_FALLBACK
 #define MAKE_FALLBACK(op, sz) 						\
 static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
 {									\
@@ -212,7 +212,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
 	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
 	     (unsigned long long __force)addr);
 }
-#endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
+#endif /* CONFIG_INDIRECT_IOMEM_FALLBACK */
 
 #define MAKE_OP(op, sz) 						\
 u##sz __raw_read ## op(const volatile void __iomem *addr)		\
-- 
2.33.1



From jgg at nvidia.com  Mon Jan  3 15:04:45 2022
From: jgg at nvidia.com (Jason Gunthorpe)
Date: Mon, 3 Jan 2022 19:04:45 -0400
Subject: [PATCH 2/2] IB/rdmavt: modify rdmavt/qp.c for UML
In-Reply-To: <20220102070623.24009-1-rdunlap@infradead.org>
References: <20220102070623.24009-1-rdunlap@infradead.org>
Message-ID: <20220103230445.GA2592848@nvidia.com>

On Sat, Jan 01, 2022 at 11:06:23PM -0800, Randy Dunlap wrote:
> When building rdmavt for ARCH=um, qp.c has a build error on a reference
> to the x86-specific cpuinfo field 'x86_cache_size'. This value is then
> used to determine whether to use cacheless_memcpy() or not.
> Provide a fake value to LLC for CONFIG_UML. Then provide a separate
> verison of cacheless_memcpy() for CONFIG_UML that is just a plain
> memcpy(), like the calling code uses.
> 
> Prevents these build errors:
> 
> ../drivers/infiniband/sw/rdmavt/qp.c: In function ?rvt_wss_llc_size?:
> ../drivers/infiniband/sw/rdmavt/qp.c:88:23: error: ?struct cpuinfo_um? has no member named ?x86_cache_size?; did you mean ?x86_capability??
>   return boot_cpu_data.x86_cache_size;
> 
> ../drivers/infiniband/sw/rdmavt/qp.c: In function ?cacheless_memcpy?:
> ../drivers/infiniband/sw/rdmavt/qp.c:100:2: error: implicit declaration of function ?__copy_user_nocache?; did you mean ?copy_user_page?? [-Werror=implicit-function-declaration]
>   __copy_user_nocache(dst, (void __user *)src, n, 0);
> 
> Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
> Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
>  drivers/infiniband/sw/rdmavt/qp.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> +++ linux-next-20211224/drivers/infiniband/sw/rdmavt/qp.c
> @@ -84,10 +84,15 @@ EXPORT_SYMBOL(ib_rvt_state_ops);
>  /* platform specific: return the last level cache (llc) size, in KiB */
>  static int rvt_wss_llc_size(void)
>  {
> +#if !defined(CONFIG_UML)
>  	/* assume that the boot CPU value is universal for all CPUs */
>  	return boot_cpu_data.x86_cache_size;
> +#else /* CONFIG_UML */
> +	return 1024;	/* fake 1 MB LLC size */
> +#endif
>  }
>  
> +#if !defined(CONFIG_UML)
>  /* platform specific: cacheless copy */
>  static void cacheless_memcpy(void *dst, void *src, size_t n)
>  {
> @@ -99,6 +104,13 @@ static void cacheless_memcpy(void *dst,
>  	 */
>  	__copy_user_nocache(dst, (void __user *)src, n, 0);
>  }
> +#else
> +/* for CONFIG_UML, this is just a plain memcpy() */
> +static void cacheless_memcpy(void *dst, void *src, size_t n)
> +{
> +	memcpy(dst, src, n);
> +}
> +#endif

memcpy is not the same thing as __copy_user - the hint is in the
__user cast..

It should by copy_from_user(), I think, and this is all just somehow
broken to not check the return code.

Why are you trying to make a HW driver compile on UML? Is there any
way to even use a driver like this in a UML environment?

Jason


From rdunlap at infradead.org  Mon Jan  3 17:00:53 2022
From: rdunlap at infradead.org (Randy Dunlap)
Date: Mon, 3 Jan 2022 17:00:53 -0800
Subject: [PATCH 2/2] IB/rdmavt: modify rdmavt/qp.c for UML
In-Reply-To: <20220103230445.GA2592848@nvidia.com>
References: <20220102070623.24009-1-rdunlap@infradead.org>
 <20220103230445.GA2592848@nvidia.com>
Message-ID: <50fa4eca-ce74-431f-8497-273d2c5956f2@infradead.org>



On 1/3/22 15:04, Jason Gunthorpe wrote:
> On Sat, Jan 01, 2022 at 11:06:23PM -0800, Randy Dunlap wrote:
>> When building rdmavt for ARCH=um, qp.c has a build error on a reference
>> to the x86-specific cpuinfo field 'x86_cache_size'. This value is then
>> used to determine whether to use cacheless_memcpy() or not.
>> Provide a fake value to LLC for CONFIG_UML. Then provide a separate
>> verison of cacheless_memcpy() for CONFIG_UML that is just a plain
>> memcpy(), like the calling code uses.
>>
>> Prevents these build errors:
>>
>> ../drivers/infiniband/sw/rdmavt/qp.c: In function ?rvt_wss_llc_size?:
>> ../drivers/infiniband/sw/rdmavt/qp.c:88:23: error: ?struct cpuinfo_um? has no member named ?x86_cache_size?; did you mean ?x86_capability??
>>   return boot_cpu_data.x86_cache_size;
>>
>> ../drivers/infiniband/sw/rdmavt/qp.c: In function ?cacheless_memcpy?:
>> ../drivers/infiniband/sw/rdmavt/qp.c:100:2: error: implicit declaration of function ?__copy_user_nocache?; did you mean ?copy_user_page?? [-Werror=implicit-function-declaration]
>>   __copy_user_nocache(dst, (void __user *)src, n, 0);
>>
>> Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
>> Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
>>  drivers/infiniband/sw/rdmavt/qp.c |   12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> +++ linux-next-20211224/drivers/infiniband/sw/rdmavt/qp.c
>> @@ -84,10 +84,15 @@ EXPORT_SYMBOL(ib_rvt_state_ops);
>>  /* platform specific: return the last level cache (llc) size, in KiB */
>>  static int rvt_wss_llc_size(void)
>>  {
>> +#if !defined(CONFIG_UML)
>>  	/* assume that the boot CPU value is universal for all CPUs */
>>  	return boot_cpu_data.x86_cache_size;
>> +#else /* CONFIG_UML */
>> +	return 1024;	/* fake 1 MB LLC size */
>> +#endif
>>  }
>>  
>> +#if !defined(CONFIG_UML)
>>  /* platform specific: cacheless copy */
>>  static void cacheless_memcpy(void *dst, void *src, size_t n)
>>  {
>> @@ -99,6 +104,13 @@ static void cacheless_memcpy(void *dst,
>>  	 */
>>  	__copy_user_nocache(dst, (void __user *)src, n, 0);
>>  }
>> +#else
>> +/* for CONFIG_UML, this is just a plain memcpy() */
>> +static void cacheless_memcpy(void *dst, void *src, size_t n)
>> +{
>> +	memcpy(dst, src, n);
>> +}
>> +#endif
> 
> memcpy is not the same thing as __copy_user - the hint is in the
> __user cast..
> 
> It should by copy_from_user(), I think, and this is all just somehow
> broken to not check the return code.

Thanks.

> Why are you trying to make a HW driver compile on UML? Is there any
> way to even use a driver like this in a UML environment?

I'm just trying to clean up lots of UML build errors.
I'm quite happy just making the driver depend on !UML.

UML maintainers, what do you think?

Thanks again.

-- 
~Randy


From hch at infradead.org  Mon Jan  3 23:43:39 2022
From: hch at infradead.org (Christoph Hellwig)
Date: Mon, 3 Jan 2022 23:43:39 -0800
Subject: [PATCH 2/2] IB/rdmavt: modify rdmavt/qp.c for UML
In-Reply-To: <20220102070623.24009-1-rdunlap@infradead.org>
References: <20220102070623.24009-1-rdunlap@infradead.org>
Message-ID: <YdP6qx0G7ICcBu3f@infradead.org>

Yikes, this rdmavt code is completely fucked up and a very good example
why people should not use __user casts or random internal helpers.

The right fix is to remove this crap entirely, and if the rdmavt
maintainer think that they absolutely need a non-temporal memcpy they
need to work to add a core API for it.


From anton.ivanov at cambridgegreys.com  Tue Jan  4 00:03:58 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Tue, 4 Jan 2022 08:03:58 +0000
Subject: [PATCH 2/2] IB/rdmavt: modify rdmavt/qp.c for UML
In-Reply-To: <50fa4eca-ce74-431f-8497-273d2c5956f2@infradead.org>
References: <20220102070623.24009-1-rdunlap@infradead.org>
 <20220103230445.GA2592848@nvidia.com>
 <50fa4eca-ce74-431f-8497-273d2c5956f2@infradead.org>
Message-ID: <6c083f0d-4fea-6339-71ca-6e8fb524e1c0@cambridgegreys.com>



On 04/01/2022 01:00, Randy Dunlap wrote:
> 
> 
> On 1/3/22 15:04, Jason Gunthorpe wrote:
>> On Sat, Jan 01, 2022 at 11:06:23PM -0800, Randy Dunlap wrote:
>>> When building rdmavt for ARCH=um, qp.c has a build error on a reference
>>> to the x86-specific cpuinfo field 'x86_cache_size'. This value is then
>>> used to determine whether to use cacheless_memcpy() or not.
>>> Provide a fake value to LLC for CONFIG_UML. Then provide a separate
>>> verison of cacheless_memcpy() for CONFIG_UML that is just a plain
>>> memcpy(), like the calling code uses.
>>>
>>> Prevents these build errors:
>>>
>>> ../drivers/infiniband/sw/rdmavt/qp.c: In function ?rvt_wss_llc_size?:
>>> ../drivers/infiniband/sw/rdmavt/qp.c:88:23: error: ?struct cpuinfo_um? has no member named ?x86_cache_size?; did you mean ?x86_capability??
>>>    return boot_cpu_data.x86_cache_size;
>>>
>>> ../drivers/infiniband/sw/rdmavt/qp.c: In function ?cacheless_memcpy?:
>>> ../drivers/infiniband/sw/rdmavt/qp.c:100:2: error: implicit declaration of function ?__copy_user_nocache?; did you mean ?copy_user_page?? [-Werror=implicit-function-declaration]
>>>    __copy_user_nocache(dst, (void __user *)src, n, 0);
>>>
>>> Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
>>> Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
>>>   drivers/infiniband/sw/rdmavt/qp.c |   12 ++++++++++++
>>>   1 file changed, 12 insertions(+)
>>>
>>> +++ linux-next-20211224/drivers/infiniband/sw/rdmavt/qp.c
>>> @@ -84,10 +84,15 @@ EXPORT_SYMBOL(ib_rvt_state_ops);
>>>   /* platform specific: return the last level cache (llc) size, in KiB */
>>>   static int rvt_wss_llc_size(void)
>>>   {
>>> +#if !defined(CONFIG_UML)
>>>   	/* assume that the boot CPU value is universal for all CPUs */
>>>   	return boot_cpu_data.x86_cache_size;
>>> +#else /* CONFIG_UML */
>>> +	return 1024;	/* fake 1 MB LLC size */
>>> +#endif
>>>   }
>>>   
>>> +#if !defined(CONFIG_UML)
>>>   /* platform specific: cacheless copy */
>>>   static void cacheless_memcpy(void *dst, void *src, size_t n)
>>>   {
>>> @@ -99,6 +104,13 @@ static void cacheless_memcpy(void *dst,
>>>   	 */
>>>   	__copy_user_nocache(dst, (void __user *)src, n, 0);
>>>   }
>>> +#else
>>> +/* for CONFIG_UML, this is just a plain memcpy() */
>>> +static void cacheless_memcpy(void *dst, void *src, size_t n)
>>> +{
>>> +	memcpy(dst, src, n);
>>> +}
>>> +#endif
>>
>> memcpy is not the same thing as __copy_user - the hint is in the
>> __user cast..
>>
>> It should by copy_from_user(), I think, and this is all just somehow
>> broken to not check the return code.
> 
> Thanks.
> 
>> Why are you trying to make a HW driver compile on UML? Is there any
>> way to even use a driver like this in a UML environment?
> 
> I'm just trying to clean up lots of UML build errors.
> I'm quite happy just making the driver depend on !UML.
> 
> UML maintainers, what do you think?
> 
> Thanks again.
> 

I would suggest that we just !UML this driver.

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From johannes at sipsolutions.net  Tue Jan  4 00:43:17 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 09:43:17 +0100
Subject: [PATCH 2/2] IB/rdmavt: modify rdmavt/qp.c for UML
In-Reply-To: <6c083f0d-4fea-6339-71ca-6e8fb524e1c0@cambridgegreys.com>
References: <20220102070623.24009-1-rdunlap@infradead.org>
 <20220103230445.GA2592848@nvidia.com>
 <50fa4eca-ce74-431f-8497-273d2c5956f2@infradead.org>
 <6c083f0d-4fea-6339-71ca-6e8fb524e1c0@cambridgegreys.com>
Message-ID: <21fc9b66d15300b19e74b7992baa152173a19162.camel@sipsolutions.net>

On Tue, 2022-01-04 at 08:03 +0000, Anton Ivanov wrote:
> > 
> > > Why are you trying to make a HW driver compile on UML? Is there any
> > > way to even use a driver like this in a UML environment?
> > 
> > I'm just trying to clean up lots of UML build errors.
> > I'm quite happy just making the driver depend on !UML.
> > 
> > UML maintainers, what do you think?
> > 
> > Thanks again.
> > 
> 
> I would suggest that we just !UML this driver.
> 
Agree, unless some of the maintainers of this driver actually wants to
build simulation for it for testing or something, it's almost certainly
completely useless.

After all, the reason I enabled PCI on UML was to be able to test - in
simulation - PCI driver code in UML... Most certainly nobody wants to do
that here, so it's pointless to let the driver be compiled.

OTOH, as Christoph points out, that seems like a band-aid for some
really strange code, but it's probably the easiest way to get the build
issue fixed in the short term.

johannes


From johannes at sipsolutions.net  Tue Jan  4 00:56:07 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 09:56:07 +0100
Subject: [PATCH 1/4] um: Run console exit code also upon kernel panic
In-Reply-To: <20220101215810.13260-2-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
 <20220101215810.13260-2-richard@nod.at>
Message-ID: <6fad9c06ac08b60d9bfea703552712daf150a4f7.camel@sipsolutions.net>

On Sat, 2022-01-01 at 22:58 +0100, Richard Weinberger wrote:
> 
> diff --git a/arch/um/include/shared/uml_console.h b/arch/um/include/shared/uml_console.h
> new file mode 100644
> index 000000000000..aa8d02fe5e90
> --- /dev/null
> +++ b/arch/um/include/shared/uml_console.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2022 Richard Weinberger <richard at nod.at>
> + */
> +
> +#ifndef UML_CONSOLE_H
> +#define UML_CONSOLE_H
> +
> +extern void uml_console_exit(void);
> 

Not sure it's worth adding a whole new file just for this, but also
doesn't really matter :)

johannes


From johannes at sipsolutions.net  Tue Jan  4 01:00:25 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 10:00:25 +0100
Subject: [PATCH 2/4] um: os_set_fd_block: Return old blocking mode
In-Reply-To: <20220101215810.13260-3-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
 <20220101215810.13260-3-richard@nod.at>
Message-ID: <5fdb10e93535d83d208682e2eb5514fa1d5b6240.camel@sipsolutions.net>

On Sat, 2022-01-01 at 22:58 +0100, Richard Weinberger wrote:
> This will be needed when we restore the old mode upon exit.
> The function now returns < 0 in case of an error, 1 if O_NONBLOCK
> was set, 0 otherwise.
> 
> +++ b/arch/um/drivers/chan_user.c
> @@ -257,7 +257,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
>  	}
>  
>  	err = os_set_fd_block(*fd_out, 0);
> -	if (err) {
> +	if (err < 0) {
>  		printk(UM_KERN_ERR "winch_tramp: failed to set thread_fd "
>  		       "non-blocking.\n");
>  		goto out_close;

This does 'return err' afterwards, which then changes the logic from 0
to 1, which seems wrong - especially given that it gets passed further
elsewhere as a pid, which seems very questionable in the first place,
but at least 1 would be valid pid unlike 0?

IOW, I think you need

-	return err;
+	return 0;

a couple of lines later.

johannes


From johannes at sipsolutions.net  Tue Jan  4 01:02:41 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 10:02:41 +0100
Subject: [PATCH 4/4] um: irq: Restore O_ASYNC upon exit
In-Reply-To: <20220101215810.13260-5-richard@nod.at>
References: <20220101215810.13260-1-richard@nod.at>
 <20220101215810.13260-5-richard@nod.at>
Message-ID: <25e9d4e4f8655bee5dc5e8a017c83d743effa4e7.camel@sipsolutions.net>

On Sat, 2022-01-01 at 22:58 +0100, Richard Weinberger wrote:
> Just like with O_NONBLOCK, make sure UML clears O_ASYNC
> upon exit when it set it.
> 

"when it set it" isn't really quite true - you always clear it, should
it be similar to the O_NONBLOCK version to see the old mode?

johannes


From johannes at sipsolutions.net  Tue Jan  4 01:04:03 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 10:04:03 +0100
Subject: Build regressions/improvements in v5.16-rc7
In-Reply-To: <alpine.DEB.2.22.394.2112271142250.1704790@ramsan.of.borg>
References: <20211227083126.1153239-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2112271142250.1704790@ramsan.of.borg>
Message-ID: <0523cc8788bfe47ffba185d0436a7c77c85c6e4c.camel@sipsolutions.net>

On Mon, 2021-12-27 at 11:44 +0100, Geert Uytterhoeven wrote:
> 
> sparc64-gcc11/sparc-allmodconfig
> 
>    + /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c: error: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 1439:10, 1414:10
> 

This should be fixed by

commit 5f174ec3c1d62013f86db6597249174d8cb227b2
Author: Al Viro <viro at zeniv.linux.org.uk>
Date:   Mon Sep 20 21:32:49 2021 +0000

    logic_io instance of iounmap() needs volatile on argument


when it lands.

johannes


From anton.ivanov at cambridgegreys.com  Tue Jan  4 02:44:57 2022
From: anton.ivanov at cambridgegreys.com (anton.ivanov at cambridgegreys.com)
Date: Tue,  4 Jan 2022 10:44:57 +0000
Subject: [PATCH] um: Document dtb command line option
In-Reply-To: <1118129237.194759.1640202076897.JavaMail.zimbra@nod.at>
References: <1118129237.194759.1640202076897.JavaMail.zimbra@nod.at>
Message-ID: <20220104104457.282828-1-anton.ivanov@cambridgegreys.com>

From: Anton Ivanov <anton.ivanov at cambridgegreys.com>

Add documentation for the dtb command line option and the
ability to load/parse device trees.

Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
---
 .../virt/uml/user_mode_linux_howto_v2.rst     | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/virt/uml/user_mode_linux_howto_v2.rst b/Documentation/virt/uml/user_mode_linux_howto_v2.rst
index 2cafd3c3c6cb..81986fe014d4 100644
--- a/Documentation/virt/uml/user_mode_linux_howto_v2.rst
+++ b/Documentation/virt/uml/user_mode_linux_howto_v2.rst
@@ -1189,6 +1189,26 @@ E.g. ``os_close_file()`` is just a wrapper around ``close()``
 which ensures that the userspace function close does not clash
 with similarly named function(s) in the kernel part.
 
+Using UML as a Test Platform
+============================
+
+UML is an excellent test platform for device driver development. As
+with most things UML, "some user assembly may be required". It is
+up to the user to build their emulation environment. UML at present
+provides only the kernel infrastructure.
+
+Part of this infrastructure is the ability to load and parse fdt
+device tree blobs as used in Arm or Open Firmware platforms. These
+are supplied as an optional extra argument to the kernel command
+line::
+
+    dtb=filename
+
+The device tree is loaded and parsed at boottime and is accessible by
+drivers which query it. At this moment in time this facility is
+intended solely for development purposes. UML's own devices do not
+query the device tree.
+
 Security Considerations
 -----------------------
 
-- 
2.30.2



From anton.ivanov at cambridgegreys.com  Tue Jan  4 06:13:25 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Tue, 4 Jan 2022 14:13:25 +0000
Subject: [PATCH] um: virtio_uml: allow probing from devicetree
In-Reply-To: <20211222103417.GB25135@axis.com>
References: <20211221090447.1567-1-vincent.whitchurch@axis.com>
 <5f104044649ec60ba93648e68c3df2183e032072.camel@sipsolutions.net>
 <20211222103417.GB25135@axis.com>
Message-ID: <a862c00c-0db4-e2b7-4ee7-958f3bdd856e@cambridgegreys.com>



On 22/12/2021 10:34, Vincent Whitchurch wrote:
> On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
>> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
>>> Allow the virtio_uml device to be probed from the devicetree so that
>>> sub-devices can be specified using the standard virtio bindings, for
>>> example:
>>>
>>>    virtio at 1 {
>>>      compatible = "virtio,uml";
>>>      socket-path = "i2c.sock";
>>>      virtio-device-id = <0x22>;
>>>
>>
>> Given this, maybe it should modify
>> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
>> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
>>
>> +Rob, because I'm not really into any of this.
>>
>> Also, I'm not even sure we should/need to document the DT bits that are
>> basically only used for testing in the first place?

If we start adding the UML devices themselves to the DT, we might as well add all of them.

In the doc patch have described the DT support as mostly for development at this point.

It can be a good alternative to the endless command line (especially for complex devices like f.e. l2tpv3).


> 
> I wasn't sure either, but Rob was OK with not documenting some other
> bindings which are only used for testing[0], so I assumed that that
> applied here too:
> 
>   [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1 at mx.google.com/
> 
> Also, DT bindings are supposed to be generic and based on what the
> hardware has, but here we have no hardware and something very Linux and
> UML-specific.
> 
>> Code looks good to me.
> 
> Thanks!
> 

Brgds,

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From walter.lozano at collabora.com  Tue Jan  4 10:10:06 2022
From: walter.lozano at collabora.com (Walter Lozano)
Date: Tue, 4 Jan 2022 15:10:06 -0300
Subject: Occasional hung with UM after enable VMAP_STACK
Message-ID: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>

Hi all,

I noticed that after "um: enable VMAP_STACK" [1] I experienced some 
occasional hung in my Gitlab CI jobs that use user-mode-linux to build 
distro images. The configuration use for the building is the one 
available from Debian, see [2] and [3]. Unfortunately I don't have much 
information, when the issue arises the job seems to hang and it is 
cancelled by Gitlab due to a job timeout.

So far I did some bisect to get the commit which introduces the issue 
and a quick check with latest Linux stable branch master to confirm the 
issue is still present. I know this is not a proper bug report but I 
thought it will be better to at least raise a comment.

Thanks in advance,

Walter

[1] http://lists.infradead.org/pipermail/linux-um/2021-August/001657.html

[2] https://packages.debian.org/bookworm/user-mode-linux

[3] https://salsa.debian.org/uml-team/user-mode-linux

-- 
Walter Lozano
Collabora Ltd.



From johannes at sipsolutions.net  Tue Jan  4 11:04:24 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 20:04:24 +0100
Subject: Occasional hung with UM after enable VMAP_STACK
In-Reply-To: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
References: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
Message-ID: <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>

On Tue, 2022-01-04 at 15:10 -0300, Walter Lozano wrote:
> Hi all,
> 
> I noticed that after "um: enable VMAP_STACK" [1] I experienced some 
> occasional hung in my Gitlab CI jobs that use user-mode-linux to build 
> distro images.
> 

Did you actually *enable* VMAP_STACK in the config as well? The commit
just makes it *possible* to enable it, you still have to set it
yourself. So you should be able to easily check with/without that
setting.

johannes


From walter.lozano at collabora.com  Tue Jan  4 11:26:57 2022
From: walter.lozano at collabora.com (Walter Lozano)
Date: Tue, 4 Jan 2022 16:26:57 -0300
Subject: Occasional hung with UM after enable VMAP_STACK
In-Reply-To: <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>
References: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
 <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>
Message-ID: <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>

Hi Johannes,

On 1/4/22 16:04, Johannes Berg wrote:
> On Tue, 2022-01-04 at 15:10 -0300, Walter Lozano wrote:
>> Hi all,
>>
>> I noticed that after "um: enable VMAP_STACK" [1] I experienced some
>> occasional hung in my Gitlab CI jobs that use user-mode-linux to build
>> distro images.
>>
> Did you actually *enable* VMAP_STACK in the config as well? The commit
> just makes it *possible* to enable it, you still have to set it
> yourself. So you should be able to easily check with/without that
> setting.

Thank you for your quick response. The Debian configuration on package 
user-mode-linux have these settings

CONFIG_HAVE_ARCH_VMAP_STACK=y
CONFIG_VMAP_STACK=y


as you can see in [1]. I did run some tests disabling those settings, 
which passed without any hung.

Unfortunately the "occasional" behavior makes this issue a bit tricky to 
debug.

Regards,

Walter

[1] 
https://salsa.debian.org/uml-team/user-mode-linux/-/blob/master/config.amd64#L321 


-- 
Walter Lozano
Collabora Ltd.



From johannes at sipsolutions.net  Tue Jan  4 11:49:05 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 04 Jan 2022 20:49:05 +0100
Subject: Occasional hung with UM after enable VMAP_STACK
In-Reply-To: <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>
References: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
 <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>
 <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>
Message-ID: <41fe09354fc736fb1ff2cb429e035633f24176ce.camel@sipsolutions.net>

On Tue, 2022-01-04 at 16:26 -0300, Walter Lozano wrote:
> 
> Thank you for your quick response. The Debian configuration on package 
> user-mode-linux have these settings
> 
> CONFIG_HAVE_ARCH_VMAP_STACK=y
> CONFIG_VMAP_STACK=y

OK, so it actually _is_ enabled.

> as you can see in [1]. I did run some tests disabling those settings, 
> which passed without any hung.
> 
> Unfortunately the "occasional" behavior makes this issue a bit tricky to 
> debug.
> 

Right.

Hm. I've been running our tests with it for about three months and
haven't observed any hangs, but I guess that doesn't mean much.

To be honest, I have no particular reason to even want it, other than
that it catches accidental DMA from stack more easily ... so I guess if
we can't find anything, we might as well revert it.

Feels like it _should_ work though, since it's just a different location
for the stack.

johannes


From anton.ivanov at kot-begemot.co.uk  Tue Jan  4 13:39:15 2022
From: anton.ivanov at kot-begemot.co.uk (Anton Ivanov)
Date: Tue, 4 Jan 2022 21:39:15 +0000
Subject: Occasional hung with UM after enable VMAP_STACK
In-Reply-To: <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>
References: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
 <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>
 <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>
Message-ID: <94613ccb-ab4d-851d-01d0-dfa72b73fdb0@kot-begemot.co.uk>

On 04/01/2022 19:26, Walter Lozano wrote:
> Hi Johannes,
> 
> On 1/4/22 16:04, Johannes Berg wrote:
>> On Tue, 2022-01-04 at 15:10 -0300, Walter Lozano wrote:
>>> Hi all,
>>>
>>> I noticed that after "um: enable VMAP_STACK" [1] I experienced some
>>> occasional hung in my Gitlab CI jobs that use user-mode-linux to build
>>> distro images.
>>>
>> Did you actually *enable* VMAP_STACK in the config as well? The commit
>> just makes it *possible* to enable it, you still have to set it
>> yourself. So you should be able to easily check with/without that
>> setting.
> 
> Thank you for your quick response. The Debian configuration on package 
> user-mode-linux have these settings
> 
> CONFIG_HAVE_ARCH_VMAP_STACK=y
> CONFIG_VMAP_STACK=y
> 
> 
> as you can see in [1]. I did run some tests disabling those settings, 
> which passed without any hung.
> 
> Unfortunately the "occasional" behavior makes this issue a bit tricky to 
> debug.
> 
> Regards,
> 
> Walter
> 
> [1] 
> https://salsa.debian.org/uml-team/user-mode-linux/-/blob/master/config.amd64#L321 
> 
> 

Just to narrow things down - 64 bit or 32 bit?

-- 
Anton R. Ivanov
https://www.kot-begemot.co.uk/


From walter.lozano at collabora.com  Wed Jan  5 04:58:36 2022
From: walter.lozano at collabora.com (Walter Lozano)
Date: Wed, 5 Jan 2022 09:58:36 -0300
Subject: Occasional hung with UM after enable VMAP_STACK
In-Reply-To: <41fe09354fc736fb1ff2cb429e035633f24176ce.camel@sipsolutions.net>
References: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
 <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>
 <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>
 <41fe09354fc736fb1ff2cb429e035633f24176ce.camel@sipsolutions.net>
Message-ID: <7a228120-f8fa-53ce-8857-32330968eebb@collabora.com>

Hi Johannes,

On 1/4/22 16:49, Johannes Berg wrote:
> On Tue, 2022-01-04 at 16:26 -0300, Walter Lozano wrote:
>> Thank you for your quick response. The Debian configuration on package
>> user-mode-linux have these settings
>>
>> CONFIG_HAVE_ARCH_VMAP_STACK=y
>> CONFIG_VMAP_STACK=y
> OK, so it actually _is_ enabled.
>
>> as you can see in [1]. I did run some tests disabling those settings,
>> which passed without any hung.
>>
>> Unfortunately the "occasional" behavior makes this issue a bit tricky to
>> debug.
>>
> Right.
>
> Hm. I've been running our tests with it for about three months and
> haven't observed any hangs, but I guess that doesn't mean much.

The issue is very rare at least in my setup, I had to prepare a test 
environment to stress the system in order to be able to reproduce it 
more or less consistently. I will continue investigating and share any 
useful information.

> To be honest, I have no particular reason to even want it, other than
> that it catches accidental DMA from stack more easily ... so I guess if
> we can't find anything, we might as well revert it.

I hope we will be able to find the root cause of the issue.

> Feels like it _should_ work though, since it's just a different location
> for the stack.


I see. Thank you again for your quick reply, I will keep you updated.

Regards,

Walter

-- 
Walter Lozano
Collabora Ltd.



From walter.lozano at collabora.com  Wed Jan  5 04:59:25 2022
From: walter.lozano at collabora.com (Walter Lozano)
Date: Wed, 5 Jan 2022 09:59:25 -0300
Subject: Occasional hung with UM after enable VMAP_STACK
In-Reply-To: <94613ccb-ab4d-851d-01d0-dfa72b73fdb0@kot-begemot.co.uk>
References: <be290dc3-db9c-2940-91bb-c91bf42fd8f6@collabora.com>
 <d80e4e760171de3813895e3cbfcadf96aa6c8fb6.camel@sipsolutions.net>
 <8c26a869-0cbe-a38c-8a8d-9f3f171f7e72@collabora.com>
 <94613ccb-ab4d-851d-01d0-dfa72b73fdb0@kot-begemot.co.uk>
Message-ID: <5c9b8e61-1158-1004-8280-04cc3c921ad1@collabora.com>

Hi Anton,

On 1/4/22 18:39, Anton Ivanov wrote:
> On 04/01/2022 19:26, Walter Lozano wrote:
>> Hi Johannes,
>>
>> On 1/4/22 16:04, Johannes Berg wrote:
>>> On Tue, 2022-01-04 at 15:10 -0300, Walter Lozano wrote:
>>>> Hi all,
>>>>
>>>> I noticed that after "um: enable VMAP_STACK" [1] I experienced some
>>>> occasional hung in my Gitlab CI jobs that use user-mode-linux to build
>>>> distro images.
>>>>
>>> Did you actually *enable* VMAP_STACK in the config as well? The commit
>>> just makes it *possible* to enable it, you still have to set it
>>> yourself. So you should be able to easily check with/without that
>>> setting.
>>
>> Thank you for your quick response. The Debian configuration on 
>> package user-mode-linux have these settings
>>
>> CONFIG_HAVE_ARCH_VMAP_STACK=y
>> CONFIG_VMAP_STACK=y
>>
>>
>> as you can see in [1]. I did run some tests disabling those settings, 
>> which passed without any hung.
>>
>> Unfortunately the "occasional" behavior makes this issue a bit tricky 
>> to debug.
>>
>> Regards,
>>
>> Walter
>>
>> [1] 
>> https://salsa.debian.org/uml-team/user-mode-linux/-/blob/master/config.amd64#L321 
>>
>>
>
> Just to narrow things down - 64 bit or 32 bit?
>
Thank you for commenting on this thread. All my tests were done with 64 
bits.

Regards,

-- 
Walter Lozano
Collabora Ltd.



From richard at nod.at  Mon Jan 10 23:52:49 2022
From: richard at nod.at (Richard Weinberger)
Date: Tue, 11 Jan 2022 08:52:49 +0100 (CET)
Subject: [GIT PULL] UML updates for 5.17
Message-ID: <10132756.248426.1641887569979.JavaMail.zimbra@nod.at>

Linus,

The following changes since commit 1c3e979bf3e225e5b4b810b24712b16254d608b6:

  Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid (2021-12-21 09:30:32 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml.git tags/for-linus-5.17-rc1

for you to fetch changes up to db0dd9cee82270e032123169ceff659eced5115d:

  um: virtio_uml: Allow probing from devicetree (2021-12-22 20:40:05 +0100)

----------------------------------------------------------------
This pull request contains the following changes for UML:

- set_fs removal
- Devicetree support
- Many cleanups from Al
- Various virtio and build related fixes

----------------------------------------------------------------
Al Viro (15):
      uml: trim unused junk from arch/x86/um/sys_call_table_*.c
      um: move amd64 variant of mmap(2) to arch/x86/um/syscalls_64.c
      logic_io instance of iounmap() needs volatile on argument
      um: stop polluting the namespace with registers.h contents
      uml/i386: missing include in barrier.h
      um: kill unused cpu()
      um: remove a dangling extern of syscall_trace()
      um: unexport handle_page_fault()
      um, x86: bury crypto_tfm_ctx_offset
      um: common-offsets.h debriding...
      um: header debriding - activate_ipi()
      um: header debriding - mem_user.h
      um: header debriding - net_*.h
      um: header debriding - os.h
      um: header debriding - sigio.h

Changcheng Deng (1):
      um: Replace if (cond) BUG() with BUG_ON()

Christoph Hellwig (1):
      um: remove set_fs

Johannes Berg (8):
      um: fix ndelay/udelay defines
      um: rename set_signals() to um_set_signals()
      uml: x86: add FORCE to user_constants.h
      um: gitignore: Add kernel/capflags.c
      um: virt-pci: Fix 32-bit compile
      lib/logic_iomem: Fix 32-bit build
      lib/logic_iomem: Fix operation on 32-bit
      um: virtio_uml: Fix time-travel external time propagation

Randy Dunlap (1):
      um: registers: Rename function names to avoid conflicts and build problems

Sjoerd Simons (1):
      hostfs: Fix writeback of dirty pages

Vincent Whitchurch (3):
      um: Extract load file helper from initrd.c
      um: Add devicetree support
      um: virtio_uml: Allow probing from devicetree

Yang Guang (1):
      um: Use swap() to make code cleaner

 arch/um/.gitignore                      |  1 +
 arch/um/Kconfig                         |  2 +-
 arch/um/drivers/virt-pci.c              |  8 ++---
 arch/um/drivers/virtio_uml.c            | 54 +++++++++++++++++++++++++++--
 arch/um/include/asm/delay.h             |  4 +--
 arch/um/include/asm/irqflags.h          |  4 +--
 arch/um/include/asm/processor-generic.h |  2 +-
 arch/um/include/asm/thread_info.h       |  4 ---
 arch/um/include/asm/uaccess.h           | 21 ++++++++++--
 arch/um/include/shared/common-offsets.h | 15 --------
 arch/um/include/shared/irq_user.h       |  1 -
 arch/um/include/shared/kern_util.h      |  2 --
 arch/um/include/shared/longjmp.h        |  2 +-
 arch/um/include/shared/mem_user.h       |  5 ---
 arch/um/include/shared/net_kern.h       |  2 --
 arch/um/include/shared/net_user.h       |  1 -
 arch/um/include/shared/os.h             | 17 ++-------
 arch/um/include/shared/registers.h      |  6 ++--
 arch/um/include/shared/sigio.h          |  1 -
 arch/um/kernel/Makefile                 |  4 ++-
 arch/um/kernel/dtb.c                    | 41 ++++++++++++++++++++++
 arch/um/kernel/exec.c                   |  1 +
 arch/um/kernel/initrd.c                 | 48 +++-----------------------
 arch/um/kernel/ksyms.c                  |  2 +-
 arch/um/kernel/load_file.c              | 61 +++++++++++++++++++++++++++++++++
 arch/um/kernel/mem.c                    |  3 +-
 arch/um/kernel/process.c                |  6 +---
 arch/um/kernel/skas/uaccess.c           | 25 --------------
 arch/um/kernel/syscall.c                | 28 ---------------
 arch/um/kernel/trap.c                   |  1 -
 arch/um/kernel/um_arch.c                |  3 ++
 arch/um/kernel/um_arch.h                | 14 ++++++++
 arch/um/os-Linux/registers.c            |  4 +--
 arch/um/os-Linux/sigio.c                | 13 ++++---
 arch/um/os-Linux/signal.c               |  8 ++---
 arch/um/os-Linux/start_up.c             |  2 +-
 arch/x86/kernel/asm-offsets.c           |  3 --
 arch/x86/um/Makefile                    |  2 +-
 arch/x86/um/asm/barrier.h               |  1 +
 arch/x86/um/asm/segment.h               |  8 -----
 arch/x86/um/os-Linux/registers.c        |  1 +
 arch/x86/um/ptrace_32.c                 |  1 +
 arch/x86/um/ptrace_64.c                 |  1 +
 arch/x86/um/shared/sysdep/syscalls_64.h |  3 --
 arch/x86/um/signal.c                    |  1 +
 arch/x86/um/sys_call_table_32.c         |  4 ---
 arch/x86/um/sys_call_table_64.c         | 17 ---------
 arch/x86/um/syscalls_64.c               | 14 +++++++-
 fs/hostfs/hostfs_kern.c                 |  3 ++
 include/asm-generic/logic_io.h          |  2 +-
 lib/logic_iomem.c                       | 23 +++++++------
 51 files changed, 265 insertions(+), 235 deletions(-)
 create mode 100644 arch/um/kernel/dtb.c
 create mode 100644 arch/um/kernel/load_file.c
 delete mode 100644 arch/um/kernel/syscall.c
 create mode 100644 arch/um/kernel/um_arch.h


From benjamin.beichler at uni-rostock.de  Tue Jan 11 12:05:06 2022
From: benjamin.beichler at uni-rostock.de (Benjamin Beichler)
Date: Tue, 11 Jan 2022 20:05:06 +0000
Subject: [PATCH] um: fix and optimize xor select template for CONFIG64 and
 timetravel mode
Message-ID: <20220111200507.1445489-1-benjamin.beichler@uni-rostock.de>

Due to dropped inclusion of asm-generic/xor.h, xor_block_8regs symbol is
missing with CONFIG64 and break compilation, as the asm/xor_64.h also did
not include it. The patch recreate the logic from arch/x86, which check
whether AVX is available and add fallbacks for 32bit and 64bit config of
um.

A very minor additional "fix" is, the return of the macro parameter
instead of NULL, as this is the original intent of the macro, but
this does not change the actual behavior.

Fixes: c0ecca6604b8 ("um: enable the use of optimized xor routines in UML")
Signed-off-by: Benjamin Beichler <benjamin.beichler at uni-rostock.de>
---
 arch/um/include/asm/xor.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/um/include/asm/xor.h b/arch/um/include/asm/xor.h
index f512704a9ec7..22b39de73c24 100644
--- a/arch/um/include/asm/xor.h
+++ b/arch/um/include/asm/xor.h
@@ -4,8 +4,10 @@
 
 #ifdef CONFIG_64BIT
 #undef CONFIG_X86_32
+#define TT_CPU_INF_XOR_DEFAULT (AVX_SELECT(&xor_block_sse_pf64))
 #else
 #define CONFIG_X86_32 1
+#define TT_CPU_INF_XOR_DEFAULT (AVX_SELECT(&xor_block_8regs))
 #endif
 
 #include <asm/cpufeature.h>
@@ -16,7 +18,7 @@
 #undef XOR_SELECT_TEMPLATE
 /* pick an arbitrary one - measuring isn't possible with inf-cpu */
 #define XOR_SELECT_TEMPLATE(x)	\
-	(time_travel_mode == TT_MODE_INFCPU ? &xor_block_8regs : NULL)
+	(time_travel_mode == TT_MODE_INFCPU ? TT_CPU_INF_XOR_DEFAULT : x))
 #endif
 
 #endif
-- 
2.25.1


From benjamin.beichler at uni-rostock.de  Tue Jan 11 14:23:53 2022
From: benjamin.beichler at uni-rostock.de (Benjamin Beichler)
Date: Tue, 11 Jan 2022 22:23:53 +0000
Subject: [PATCH] um: add generated capflags.c to gitignore
Message-ID: <20220111222353.1501350-1-benjamin.beichler@uni-rostock.de>

Signed-off-by: Benjamin Beichler <benjamin.beichler at uni-rostock.de>
---
 arch/um/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/.gitignore b/arch/um/.gitignore
index 6323e5571887..8168b3bc08b8 100644
--- a/arch/um/.gitignore
+++ b/arch/um/.gitignore
@@ -2,3 +2,4 @@
 kernel/config.c
 kernel/config.tmp
 kernel/vmlinux.lds
+capflags.c
\ No newline at end of file
-- 
2.25.1


From pr-tracker-bot at kernel.org  Tue Jan 11 16:13:46 2022
From: pr-tracker-bot at kernel.org (pr-tracker-bot at kernel.org)
Date: Wed, 12 Jan 2022 00:13:46 +0000
Subject: [GIT PULL] UML updates for 5.17
In-Reply-To: <10132756.248426.1641887569979.JavaMail.zimbra@nod.at>
References: <10132756.248426.1641887569979.JavaMail.zimbra@nod.at>
Message-ID: <164194642620.21161.4424766424927690878.pr-tracker-bot@kernel.org>

The pull request you sent on Tue, 11 Jan 2022 08:52:49 +0100 (CET):

> git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml.git tags/for-linus-5.17-rc1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/f69212114220edf8372867088b97b47760b6839d

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


From anton.ivanov at cambridgegreys.com  Tue Jan 11 23:59:03 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Wed, 12 Jan 2022 07:59:03 +0000
Subject: [PATCH] um: add generated capflags.c to gitignore
In-Reply-To: <20220111222353.1501350-1-benjamin.beichler@uni-rostock.de>
References: <20220111222353.1501350-1-benjamin.beichler@uni-rostock.de>
Message-ID: <4ae59d27-6778-0376-58db-a67899ac125d@cambridgegreys.com>



On 11/01/2022 22:23, Benjamin Beichler wrote:
> Signed-off-by: Benjamin Beichler <benjamin.beichler at uni-rostock.de>
> ---
>   arch/um/.gitignore | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/um/.gitignore b/arch/um/.gitignore
> index 6323e5571887..8168b3bc08b8 100644
> --- a/arch/um/.gitignore
> +++ b/arch/um/.gitignore
> @@ -2,3 +2,4 @@
>   kernel/config.c
>   kernel/config.tmp
>   kernel/vmlinux.lds
> +capflags.c
> \ No newline at end of file
> 

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Wed Jan 12 02:03:28 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Wed, 12 Jan 2022 10:03:28 +0000
Subject: [PATCH] um: fix and optimize xor select template for CONFIG64 and
 timetravel mode
In-Reply-To: <20220111200507.1445489-1-benjamin.beichler@uni-rostock.de>
References: <20220111200507.1445489-1-benjamin.beichler@uni-rostock.de>
Message-ID: <1b6de9af-905c-1416-1fd3-f22748befa60@cambridgegreys.com>



On 11/01/2022 20:05, Benjamin Beichler wrote:
> Due to dropped inclusion of asm-generic/xor.h, xor_block_8regs symbol is
> missing with CONFIG64 and break compilation, as the asm/xor_64.h also did
> not include it. The patch recreate the logic from arch/x86, which check
> whether AVX is available and add fallbacks for 32bit and 64bit config of
> um.
> 
> A very minor additional "fix" is, the return of the macro parameter
> instead of NULL, as this is the original intent of the macro, but
> this does not change the actual behavior.
> 
> Fixes: c0ecca6604b8 ("um: enable the use of optimized xor routines in UML")
> Signed-off-by: Benjamin Beichler <benjamin.beichler at uni-rostock.de>
> ---
>   arch/um/include/asm/xor.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/um/include/asm/xor.h b/arch/um/include/asm/xor.h
> index f512704a9ec7..22b39de73c24 100644
> --- a/arch/um/include/asm/xor.h
> +++ b/arch/um/include/asm/xor.h
> @@ -4,8 +4,10 @@
>   
>   #ifdef CONFIG_64BIT
>   #undef CONFIG_X86_32
> +#define TT_CPU_INF_XOR_DEFAULT (AVX_SELECT(&xor_block_sse_pf64))
>   #else
>   #define CONFIG_X86_32 1
> +#define TT_CPU_INF_XOR_DEFAULT (AVX_SELECT(&xor_block_8regs))
>   #endif
>   
>   #include <asm/cpufeature.h>
> @@ -16,7 +18,7 @@
>   #undef XOR_SELECT_TEMPLATE
>   /* pick an arbitrary one - measuring isn't possible with inf-cpu */
>   #define XOR_SELECT_TEMPLATE(x)	\
> -	(time_travel_mode == TT_MODE_INFCPU ? &xor_block_8regs : NULL)
> +	(time_travel_mode == TT_MODE_INFCPU ? TT_CPU_INF_XOR_DEFAULT : x))
>   #endif
>   
>   #endif
> 
Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>
-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From vincent.whitchurch at axis.com  Thu Jan 13 07:09:38 2022
From: vincent.whitchurch at axis.com (Vincent Whitchurch)
Date: Thu, 13 Jan 2022 16:09:38 +0100
Subject: [PATCH] um: Document dtb command line option
In-Reply-To: <20220104104457.282828-1-anton.ivanov@cambridgegreys.com>
References: <1118129237.194759.1640202076897.JavaMail.zimbra@nod.at>
 <20220104104457.282828-1-anton.ivanov@cambridgegreys.com>
Message-ID: <20220113150938.GA12384@axis.com>

On Tue, Jan 04, 2022 at 11:44:57AM +0100, anton.ivanov at cambridgegreys.com wrote:
> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
> 
> Add documentation for the dtb command line option and the
> ability to load/parse device trees.
> 
> Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>

LGTM, thanks.

Reviewed-by: Vincent Whitchurch <vincent.whitchurch at axis.com>


From robh at kernel.org  Fri Jan 14 05:49:09 2022
From: robh at kernel.org (Rob Herring)
Date: Fri, 14 Jan 2022 07:49:09 -0600
Subject: [PATCH 2/2] um: Add devicetree support
In-Reply-To: <20211208151123.29313-3-vincent.whitchurch@axis.com>
References: <20211208151123.29313-1-vincent.whitchurch@axis.com>
 <20211208151123.29313-3-vincent.whitchurch@axis.com>
Message-ID: <YeF/Vbxo6fAt0WLp@robh.at.kernel.org>

On Wed, Dec 08, 2021 at 04:11:23PM +0100, Vincent Whitchurch wrote:
> Add a dtb=<filename> option to boot UML with a devicetree blob.  This
> can be used for testing driver code using UML.

Neat!

> Signed-off-by: Vincent Whitchurch <vincent.whitchurch at axis.com>
> ---
>  arch/um/Kconfig          |  1 +
>  arch/um/kernel/Makefile  |  1 +
>  arch/um/kernel/dtb.c     | 41 ++++++++++++++++++++++++++++++++++++++++
>  arch/um/kernel/um_arch.c |  3 +++
>  arch/um/kernel/um_arch.h |  6 ++++++
>  5 files changed, 52 insertions(+)
>  create mode 100644 arch/um/kernel/dtb.c
> 
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index c18b45f75d41..1cf7ef3a2b81 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -18,6 +18,7 @@ config UML
>  	select HAVE_DEBUG_KMEMLEAK
>  	select HAVE_DEBUG_BUGVERBOSE
>  	select NO_DMA if !UML_DMA_EMULATION
> +	select OF_EARLY_FLATTREE
>  	select GENERIC_IRQ_SHOW
>  	select GENERIC_CPU_DEVICES
>  	select HAVE_GCC_PLUGINS
> diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
> index 92692bfef7ae..ebd0cca3ff26 100644
> --- a/arch/um/kernel/Makefile
> +++ b/arch/um/kernel/Makefile
> @@ -22,6 +22,7 @@ obj-y += load_file.o
>  
>  obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
>  obj-$(CONFIG_GPROF)	+= gprof_syms.o
> +obj-$(CONFIG_OF) += dtb.o
>  obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
>  obj-$(CONFIG_STACKTRACE) += stacktrace.o
>  obj-$(CONFIG_GENERIC_PCI_IOMAP) += ioport.o
> diff --git a/arch/um/kernel/dtb.c b/arch/um/kernel/dtb.c
> new file mode 100644
> index 000000000000..ca69d72025f3
> --- /dev/null
> +++ b/arch/um/kernel/dtb.c
> @@ -0,0 +1,41 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/init.h>
> +#include <linux/of_fdt.h>
> +#include <linux/printk.h>
> +#include <linux/memblock.h>
> +#include <init.h>
> +
> +#include "um_arch.h"
> +
> +static char *dtb __initdata;
> +
> +void uml_dtb_init(void)
> +{
> +	long long size;
> +	void *area;
> +
> +	area = uml_load_file(dtb, &size);
> +	if (!area)
> +		return;
> +
> +	if (!early_init_dt_scan(area)) {
> +		pr_err("invalid DTB %s\n", dtb);
> +		memblock_free(area, size);
> +		return;
> +	}
> +
> +	unflatten_device_tree();
> +	early_init_fdt_scan_reserved_mem();

These should be reversed. early_init_fdt_scan_reserved_mem() works on 
the flat tree. Reserved memory needs to be reserved before 
unflatten_device_tree() starts allocating memory. Though I imagine that 
doesn't really matter for UML.

Also, does the dtb end up in permanently allocated memory (i.e. not 
init)? It needs to be if not.

Rob


From sashal at kernel.org  Mon Jan 17 18:18:54 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 21:18:54 -0500
Subject: [PATCH AUTOSEL 5.16 171/217] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org>
References: <20220118021940.1942199-1-sashal@kernel.org>
Message-ID: <20220118021940.1942199-171-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 8a72c99994eb1..e3ee4db58b40d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -368,7 +368,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From sashal at kernel.org  Mon Jan 17 18:31:09 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 21:31:09 -0500
Subject: [PATCH AUTOSEL 5.15 145/188] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118023152.1948105-1-sashal@kernel.org>
References: <20220118023152.1948105-1-sashal@kernel.org>
Message-ID: <20220118023152.1948105-145-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 8a72c99994eb1..e3ee4db58b40d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -368,7 +368,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From sashal at kernel.org  Mon Jan 17 18:39:35 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 21:39:35 -0500
Subject: [PATCH AUTOSEL 5.10 084/116] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118024007.1950576-1-sashal@kernel.org>
References: <20220118024007.1950576-1-sashal@kernel.org>
Message-ID: <20220118024007.1950576-84-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index f79dc338279e6..b28373a2b8d2d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From sashal at kernel.org  Mon Jan 17 18:44:11 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 21:44:11 -0500
Subject: [PATCH AUTOSEL 5.4 52/73] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118024432.1952028-1-sashal@kernel.org>
References: <20220118024432.1952028-1-sashal@kernel.org>
Message-ID: <20220118024432.1952028-52-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index f79dc338279e6..b28373a2b8d2d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From sashal at kernel.org  Mon Jan 17 18:46:41 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 21:46:41 -0500
Subject: [PATCH AUTOSEL 4.19 40/59] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118024701.1952911-1-sashal@kernel.org>
References: <20220118024701.1952911-1-sashal@kernel.org>
Message-ID: <20220118024701.1952911-40-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index a74449b5b0e31..12ad7c435e97f 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 82bf5f8442ba4..2c75f2d638681 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From sashal at kernel.org  Mon Jan 17 18:48:53 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 21:48:53 -0500
Subject: [PATCH AUTOSEL 4.14 41/56] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118024908.1953673-1-sashal@kernel.org>
References: <20220118024908.1953673-1-sashal@kernel.org>
Message-ID: <20220118024908.1953673-41-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index a74449b5b0e31..12ad7c435e97f 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 82bf5f8442ba4..2c75f2d638681 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From sashal at kernel.org  Mon Jan 17 19:08:12 2022
From: sashal at kernel.org (Sasha Levin)
Date: Mon, 17 Jan 2022 22:08:12 -0500
Subject: [PATCH AUTOSEL 4.4 19/29] um: registers: Rename function names to
 avoid conflicts and build problems
In-Reply-To: <20220118030822.1955469-1-sashal@kernel.org>
References: <20220118030822.1955469-1-sashal@kernel.org>
Message-ID: <20220118030822.1955469-19-sashal@kernel.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index f5b76355ad71a..089f979e112e3 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -14,8 +14,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 22a358ef1b0cd..dc06933ba63d9 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -334,7 +334,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index e6552275320bc..40ecacb2c54b3 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -9,6 +9,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 {
@@ -32,7 +33,7 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 	switch (code) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1



From johannes at sipsolutions.net  Tue Jan 18 00:04:24 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Tue, 18 Jan 2022 09:04:24 +0100
Subject: [PATCH AUTOSEL 4.4 19/29] um: registers: Rename function names
 to avoid conflicts and build problems
In-Reply-To: <20220118030822.1955469-19-sashal@kernel.org>
References: <20220118030822.1955469-1-sashal@kernel.org>
 <20220118030822.1955469-19-sashal@kernel.org>
Message-ID: <06a7e64e62bf8191be5004dac52f84d711e0e9a0.camel@sipsolutions.net>

On Mon, 2022-01-17 at 22:08 -0500, Sasha Levin wrote:
> From: Randy Dunlap <rdunlap at infradead.org>
> 
> [ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]
> 
> The function names init_registers() and restore_registers() are used
> in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
> calls to UML functions), so rename them.
> 
> This fixes multiple build errors.

FWIW, this is certainly fine to backport, but also almost certainly not
necessary: most likely all those drivers cannot be built before 5.14
(commit 68f5d3f3b654 ("um: add PCI over virtio emulation driver"))
anyway.

johannes


From vincent.whitchurch at axis.com  Tue Jan 18 06:20:13 2022
From: vincent.whitchurch at axis.com (Vincent Whitchurch)
Date: Tue, 18 Jan 2022 15:20:13 +0100
Subject: [PATCH 2/2] um: Add devicetree support
In-Reply-To: <YeF/Vbxo6fAt0WLp@robh.at.kernel.org>
References: <20211208151123.29313-1-vincent.whitchurch@axis.com>
 <20211208151123.29313-3-vincent.whitchurch@axis.com>
 <YeF/Vbxo6fAt0WLp@robh.at.kernel.org>
Message-ID: <20220118142013.GA556@axis.com>

On Fri, Jan 14, 2022 at 02:49:09PM +0100, Rob Herring wrote:
> On Wed, Dec 08, 2021 at 04:11:23PM +0100, Vincent Whitchurch wrote:
> > --- /dev/null
> > +++ b/arch/um/kernel/dtb.c
> > @@ -0,0 +1,41 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +
> > +#include <linux/init.h>
> > +#include <linux/of_fdt.h>
> > +#include <linux/printk.h>
> > +#include <linux/memblock.h>
> > +#include <init.h>
> > +
> > +#include "um_arch.h"
> > +
> > +static char *dtb __initdata;
> > +
> > +void uml_dtb_init(void)
> > +{
> > +	long long size;
> > +	void *area;
> > +
> > +	area = uml_load_file(dtb, &size);
> > +	if (!area)
> > +		return;
> > +
> > +	if (!early_init_dt_scan(area)) {
> > +		pr_err("invalid DTB %s\n", dtb);
> > +		memblock_free(area, size);
> > +		return;
> > +	}
> > +
> > +	unflatten_device_tree();
> > +	early_init_fdt_scan_reserved_mem();
> 
> These should be reversed. early_init_fdt_scan_reserved_mem() works on 
> the flat tree. Reserved memory needs to be reserved before 
> unflatten_device_tree() starts allocating memory. Though I imagine that 
> doesn't really matter for UML.

I only tested dynamic allocation of reserved memory, and that,
unsuprisingly, works regardless of the order.  But I'll send a patch to
change it.

> Also, does the dtb end up in permanently allocated memory (i.e. not 
> init)? It needs to be if not.

The dtb is allocated with memblock_alloc() in arch/um/kernel/load_file.c
and is never freed (except on an error from early_init_dt_scan() as in
the above hunk), so I think this is already taken care of.


From vincent.whitchurch at axis.com  Wed Jan 19 01:29:34 2022
From: vincent.whitchurch at axis.com (Vincent Whitchurch)
Date: Wed, 19 Jan 2022 10:29:34 +0100
Subject: [PATCH] um: Fix order of dtb unflatten/early init
Message-ID: <20220119092934.5285-1-vincent.whitchurch@axis.com>

Scan the tree for reserved memory before unflattening it.  As Rob
Herring said:
| These should be reversed. early_init_fdt_scan_reserved_mem() works on
| the flat tree. Reserved memory needs to be reserved before
| unflatten_device_tree() starts allocating memory. Though I imagine that
| doesn't really matter for UML.

Suggested-by: Rob Herring <robh at kernel.org>
Link: https://lore.kernel.org/lkml/YeF%2FVbxo6fAt0WLp at robh.at.kernel.org/
Signed-off-by: Vincent Whitchurch <vincent.whitchurch at axis.com>
---
 arch/um/kernel/dtb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/um/kernel/dtb.c b/arch/um/kernel/dtb.c
index ca69d72025f3..484141b06938 100644
--- a/arch/um/kernel/dtb.c
+++ b/arch/um/kernel/dtb.c
@@ -25,8 +25,8 @@ void uml_dtb_init(void)
 		return;
 	}
 
-	unflatten_device_tree();
 	early_init_fdt_scan_reserved_mem();
+	unflatten_device_tree();
 }
 
 static int __init uml_dtb_setup(char *line, int *add)
-- 
2.34.1



From anton.ivanov at cambridgegreys.com  Fri Jan 21 00:55:57 2022
From: anton.ivanov at cambridgegreys.com (anton.ivanov at cambridgegreys.com)
Date: Fri, 21 Jan 2022 08:55:57 +0000
Subject: [PATCH] um: Migrate vector drivers to NAPI
Message-ID: <20220121085557.1250299-1-anton.ivanov@cambridgegreys.com>

From: Anton Ivanov <anton.ivanov at cambridgegreys.com>

Migrate UML vector drivers from a bespoke scheduling mechanism
to NAPI.

Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
---
 arch/um/drivers/vector_kern.c | 99 ++++++++++++++++-------------------
 arch/um/drivers/vector_kern.h |  3 +-
 2 files changed, 48 insertions(+), 54 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 4fc1a5d70dcf..1bad55cb116b 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -67,6 +67,7 @@ static LIST_HEAD(vector_devices);
 static int driver_registered;
 
 static void vector_eth_configure(int n, struct arglist *def);
+static int vector_mmsg_rx(struct vector_private *vp);
 
 /* Argument accessors to set variables (and/or set default values)
  * mtu, buffer sizing, default headroom, etc
@@ -458,7 +459,6 @@ static int vector_send(struct vector_queue *qi)
 					vp->estats.tx_queue_running_average =
 						(vp->estats.tx_queue_running_average + result) >> 1;
 				}
-				netif_trans_update(qi->dev);
 				netif_wake_queue(qi->dev);
 				/* if TX is busy, break out of the send loop,
 				 *  poll write IRQ will reschedule xmit for us
@@ -470,8 +470,6 @@ static int vector_send(struct vector_queue *qi)
 			}
 		}
 		spin_unlock(&qi->head_lock);
-	} else {
-		tasklet_schedule(&vp->tx_poll);
 	}
 	return queue_depth;
 }
@@ -608,7 +606,7 @@ static struct vector_queue *create_queue(
 
 /*
  * We do not use the RX queue as a proper wraparound queue for now
- * This is not necessary because the consumption via netif_rx()
+ * This is not necessary because the consumption via napi_gro_receive()
  * happens in-line. While we can try using the return code of
  * netif_rx() for flow control there are no drivers doing this today.
  * For this RX specific use we ignore the tail/head locks and
@@ -896,7 +894,7 @@ static int vector_legacy_rx(struct vector_private *vp)
 			skb->protocol = eth_type_trans(skb, skb->dev);
 			vp->dev->stats.rx_bytes += skb->len;
 			vp->dev->stats.rx_packets++;
-			netif_rx(skb);
+			napi_gro_receive(&vp->napi, skb);
 		} else {
 			dev_kfree_skb_irq(skb);
 		}
@@ -1021,7 +1019,7 @@ static int vector_mmsg_rx(struct vector_private *vp)
 			 */
 			vp->dev->stats.rx_bytes += skb->len;
 			vp->dev->stats.rx_packets++;
-			netif_rx(skb);
+			napi_gro_receive(&vp->napi, skb);
 		} else {
 			/* Overlay header too short to do anything - discard.
 			 * We can actually keep this skb and reuse it,
@@ -1044,23 +1042,6 @@ static int vector_mmsg_rx(struct vector_private *vp)
 	return packet_count;
 }
 
-static void vector_rx(struct vector_private *vp)
-{
-	int err;
-	int iter = 0;
-
-	if ((vp->options & VECTOR_RX) > 0)
-		while (((err = vector_mmsg_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
-			iter++;
-	else
-		while (((err = vector_legacy_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
-			iter++;
-	if ((err != 0) && net_ratelimit())
-		netdev_err(vp->dev, "vector_rx: error(%d)\n", err);
-	if (iter == MAX_ITERATIONS)
-		netdev_err(vp->dev, "vector_rx: device stuck, remote end may have closed the connection\n");
-}
-
 static int vector_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct vector_private *vp = netdev_priv(dev);
@@ -1085,25 +1066,15 @@ static int vector_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	netdev_sent_queue(vp->dev, skb->len);
 	queue_depth = vector_enqueue(vp->tx_queue, skb);
 
-	/* if the device queue is full, stop the upper layers and
-	 * flush it.
-	 */
-
-	if (queue_depth >= vp->tx_queue->max_depth - 1) {
-		vp->estats.tx_kicks++;
-		netif_stop_queue(dev);
-		vector_send(vp->tx_queue);
-		return NETDEV_TX_OK;
-	}
-	if (netdev_xmit_more()) {
+	if (queue_depth < vp->tx_queue->max_depth && netdev_xmit_more()) {
 		mod_timer(&vp->tl, vp->coalesce);
 		return NETDEV_TX_OK;
+	} else {
+		queue_depth = vector_send(vp->tx_queue);
+		if (queue_depth > 0)
+			napi_schedule(&vp->napi);
 	}
-	if (skb->len < TX_SMALL_PACKET) {
-		vp->estats.tx_kicks++;
-		vector_send(vp->tx_queue);
-	} else
-		tasklet_schedule(&vp->tx_poll);
+
 	return NETDEV_TX_OK;
 }
 
@@ -1114,7 +1085,7 @@ static irqreturn_t vector_rx_interrupt(int irq, void *dev_id)
 
 	if (!netif_running(dev))
 		return IRQ_NONE;
-	vector_rx(vp);
+	napi_schedule(&vp->napi);
 	return IRQ_HANDLED;
 
 }
@@ -1133,8 +1104,7 @@ static irqreturn_t vector_tx_interrupt(int irq, void *dev_id)
 	 * tweaking the IRQ mask less costly
 	 */
 
-	if (vp->in_write_poll)
-		tasklet_schedule(&vp->tx_poll);
+	napi_schedule(&vp->napi);
 	return IRQ_HANDLED;
 
 }
@@ -1161,7 +1131,7 @@ static int vector_net_close(struct net_device *dev)
 		um_free_irq(vp->tx_irq, dev);
 		vp->tx_irq = 0;
 	}
-	tasklet_kill(&vp->tx_poll);
+	netif_napi_del(&vp->napi);
 	if (vp->fds->rx_fd > 0) {
 		if (vp->bpf)
 			uml_vector_detach_bpf(vp->fds->rx_fd, vp->bpf);
@@ -1193,15 +1163,32 @@ static int vector_net_close(struct net_device *dev)
 	return 0;
 }
 
-/* TX tasklet */
-
-static void vector_tx_poll(struct tasklet_struct *t)
+static int vector_poll(struct napi_struct *napi, int budget)
 {
-	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
+	struct vector_private *vp = container_of(napi, struct vector_private, napi);
+	int work_done = 0;
+	int err;
+	bool tx_enqueued = false;
 
-	vp->estats.tx_kicks++;
-	vector_send(vp->tx_queue);
+	if ((vp->options & VECTOR_TX) != 0)
+		tx_enqueued = (vector_send(vp->tx_queue) > 0);
+	if ((vp->options & VECTOR_RX) > 0)
+		err = vector_mmsg_rx(vp);
+	else {
+		err = vector_legacy_rx(vp);
+		if (err > 0)
+			err = 1;
+	}
+	if (err > 0)
+		work_done += err;
+
+	if (tx_enqueued || err > 0)
+		napi_schedule(napi);
+	if (work_done < budget)
+		napi_complete_done(napi, work_done);
+	return work_done;
 }
+
 static void vector_reset_tx(struct work_struct *work)
 {
 	struct vector_private *vp =
@@ -1264,6 +1251,10 @@ static int vector_net_open(struct net_device *dev)
 		if (vp->header_txbuffer == NULL)
 			goto out_close;
 	}
+	/* NAPI */
+
+	netif_napi_add(vp->dev, &vp->napi, vector_poll, 64);
+	napi_enable(&vp->napi);
 
 	/* READ IRQ */
 	err = um_request_irq(
@@ -1312,9 +1303,11 @@ static int vector_net_open(struct net_device *dev)
 	 * SIGIOs never arrive, and the net never works.
 	 */
 
-	vector_rx(vp);
 
 	vector_reset_stats(vp);
+
+	napi_schedule(&vp->napi);
+
 	vdevice = find_device(vp->unit);
 	vdevice->opened = 1;
 
@@ -1543,15 +1536,16 @@ static const struct net_device_ops vector_netdev_ops = {
 #endif
 };
 
-
 static void vector_timer_expire(struct timer_list *t)
 {
 	struct vector_private *vp = from_timer(vp, t, tl);
 
 	vp->estats.tx_kicks++;
-	vector_send(vp->tx_queue);
+	napi_schedule(&vp->napi);
 }
 
+
+
 static void vector_eth_configure(
 		int n,
 		struct arglist *def
@@ -1634,7 +1628,6 @@ static void vector_eth_configure(
 	});
 
 	dev->features = dev->hw_features = (NETIF_F_SG | NETIF_F_FRAGLIST);
-	tasklet_setup(&vp->tx_poll, vector_tx_poll);
 	INIT_WORK(&vp->reset_tx, vector_reset_tx);
 
 	timer_setup(&vp->tl, vector_timer_expire, 0);
diff --git a/arch/um/drivers/vector_kern.h b/arch/um/drivers/vector_kern.h
index 8fff93a75a92..2a1fa8e0f3e1 100644
--- a/arch/um/drivers/vector_kern.h
+++ b/arch/um/drivers/vector_kern.h
@@ -14,6 +14,7 @@
 #include <linux/ctype.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
+
 #include "vector_user.h"
 
 /* Queue structure specially adapted for multiple enqueue/dequeue
@@ -72,6 +73,7 @@ struct vector_private {
 	struct list_head list;
 	spinlock_t lock;
 	struct net_device *dev;
+	struct napi_struct		napi	____cacheline_aligned;
 
 	int unit;
 
@@ -115,7 +117,6 @@ struct vector_private {
 
 	spinlock_t stats_lock;
 
-	struct tasklet_struct tx_poll;
 	bool rexmit_scheduled;
 	bool opened;
 	bool in_write_poll;
-- 
2.30.2



From johannes at sipsolutions.net  Fri Jan 21 01:29:51 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Fri, 21 Jan 2022 10:29:51 +0100
Subject: [PATCH] um: Migrate vector drivers to NAPI
In-Reply-To: <20220121085557.1250299-1-anton.ivanov@cambridgegreys.com>
References: <20220121085557.1250299-1-anton.ivanov@cambridgegreys.com>
Message-ID: <1d4806fe15c70bdfa5fa5d50d63ef1208f6e40a8.camel@sipsolutions.net>

On Fri, 2022-01-21 at 08:55 +0000, anton.ivanov at cambridgegreys.com
wrote:
> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
> 
> Migrate UML vector drivers from a bespoke scheduling mechanism
> to NAPI.

Nice :)

> -static void vector_rx(struct vector_private *vp)
> -{
> -	int err;
> -	int iter = 0;
> -
> -	if ((vp->options & VECTOR_RX) > 0)
> -		while (((err = vector_mmsg_rx(vp)) > 0) && (iter < MAX_ITERATIONS))

You can remove the MAX_ITERATIONS define now.


> +static int vector_poll(struct napi_struct *napi, int budget)
>  {
> -	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
> +	struct vector_private *vp = container_of(napi, struct vector_private, napi);
> +	int work_done = 0;
> +	int err;
> +	bool tx_enqueued = false;
>  
> -	vp->estats.tx_kicks++;
> -	vector_send(vp->tx_queue);
> +	if ((vp->options & VECTOR_TX) != 0)
> +		tx_enqueued = (vector_send(vp->tx_queue) > 0);
> +	if ((vp->options & VECTOR_RX) > 0)
> +		err = vector_mmsg_rx(vp);
> +	else {
> +		err = vector_legacy_rx(vp);

It feels like you should honour the NAPI and pass the budget down, using
it to limit the number of packets processed for TX/RX, something like

tx_enqueued = vector_send(..., budget);
budget -= tx_enqueued;

if (budget > 0)
	err = vector_mmsg_rx(vp, budget);

etc.

> @@ -1264,6 +1251,10 @@ static int vector_net_open(struct net_device *dev)
>  		if (vp->header_txbuffer == NULL)
>  			goto out_close;
>  	}
> +	/* NAPI */
> +

That comment feels a bit pointless, but whatever :)

> +	netif_napi_add(vp->dev, &vp->napi, vector_poll, 64);
> +	napi_enable(&vp->napi);

I think this should only be done once when you create the netdev?


> @@ -1312,9 +1303,11 @@ static int vector_net_open(struct net_device *dev)
>  	 * SIGIOs never arrive, and the net never works.
>  	 */
>  
> -	vector_rx(vp);
>  
>  	vector_reset_stats(vp);
> +
> +	napi_schedule(&vp->napi);
> 

The comment should probably move with this?

johannes


From anton.ivanov at cambridgegreys.com  Fri Jan 21 01:56:27 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 21 Jan 2022 09:56:27 +0000
Subject: [PATCH] um: Migrate vector drivers to NAPI
In-Reply-To: <1d4806fe15c70bdfa5fa5d50d63ef1208f6e40a8.camel@sipsolutions.net>
References: <20220121085557.1250299-1-anton.ivanov@cambridgegreys.com>
 <1d4806fe15c70bdfa5fa5d50d63ef1208f6e40a8.camel@sipsolutions.net>
Message-ID: <f81dd671-9e29-f458-eb34-d205f0496238@cambridgegreys.com>



On 21/01/2022 09:29, Johannes Berg wrote:
> On Fri, 2022-01-21 at 08:55 +0000, anton.ivanov at cambridgegreys.com
> wrote:
>> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
>>
>> Migrate UML vector drivers from a bespoke scheduling mechanism
>> to NAPI.
> 
> Nice :)
> 
>> -static void vector_rx(struct vector_private *vp)
>> -{
>> -	int err;
>> -	int iter = 0;
>> -
>> -	if ((vp->options & VECTOR_RX) > 0)
>> -		while (((err = vector_mmsg_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
> 
> You can remove the MAX_ITERATIONS define now.

Thanks, missed that.

> 
> 
>> +static int vector_poll(struct napi_struct *napi, int budget)
>>   {
>> -	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
>> +	struct vector_private *vp = container_of(napi, struct vector_private, napi);
>> +	int work_done = 0;
>> +	int err;
>> +	bool tx_enqueued = false;
>>   
>> -	vp->estats.tx_kicks++;
>> -	vector_send(vp->tx_queue);
>> +	if ((vp->options & VECTOR_TX) != 0)
>> +		tx_enqueued = (vector_send(vp->tx_queue) > 0);
>> +	if ((vp->options & VECTOR_RX) > 0)
>> +		err = vector_mmsg_rx(vp);
>> +	else {
>> +		err = vector_legacy_rx(vp);
> 
> It feels like you should honour the NAPI and pass the budget down, using
> it to limit the number of packets processed for TX/RX, something like
> 
> tx_enqueued = vector_send(..., budget);
> budget -= tx_enqueued;

Good idea :)

> 
> if (budget > 0)
> 	err = vector_mmsg_rx(vp, budget);
> 
> etc.
> 
>> @@ -1264,6 +1251,10 @@ static int vector_net_open(struct net_device *dev)
>>   		if (vp->header_txbuffer == NULL)
>>   			goto out_close;
>>   	}
>> +	/* NAPI */
>> +
> 
> That comment feels a bit pointless, but whatever :)

Thanks, I used that to make my life easier editing it. Forgot to remove it.

> 
>> +	netif_napi_add(vp->dev, &vp->napi, vector_poll, 64);
>> +	napi_enable(&vp->napi);
> 
> I think this should only be done once when you create the netdev?

I need to have a look around the kernel and think on this one. Historically, UML does a few things in open() which are closer to device instantiation for real hardware.

> 
> 
>> @@ -1312,9 +1303,11 @@ static int vector_net_open(struct net_device *dev)
>>   	 * SIGIOs never arrive, and the net never works.
>>   	 */
>>   
>> -	vector_rx(vp);
>>   
>>   	vector_reset_stats(vp);
>> +
>> +	napi_schedule(&vp->napi);
>>
> 
> The comment should probably move with this?

Yes. Well spotted.

> 
> johannes
> 

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Fri Jan 21 02:08:14 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 21 Jan 2022 10:08:14 +0000
Subject: [PATCH] um: Migrate vector drivers to NAPI
In-Reply-To: <f81dd671-9e29-f458-eb34-d205f0496238@cambridgegreys.com>
References: <20220121085557.1250299-1-anton.ivanov@cambridgegreys.com>
 <1d4806fe15c70bdfa5fa5d50d63ef1208f6e40a8.camel@sipsolutions.net>
 <f81dd671-9e29-f458-eb34-d205f0496238@cambridgegreys.com>
Message-ID: <0db95b1f-12cb-0035-a192-07dd77dcd107@cambridgegreys.com>



On 21/01/2022 09:56, Anton Ivanov wrote:
> 
> 
> On 21/01/2022 09:29, Johannes Berg wrote:
>> On Fri, 2022-01-21 at 08:55 +0000, anton.ivanov at cambridgegreys.com
>> wrote:
>>> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
>>>
>>> Migrate UML vector drivers from a bespoke scheduling mechanism
>>> to NAPI.
>>
>> Nice :)
>>
>>> -static void vector_rx(struct vector_private *vp)
>>> -{
>>> -??? int err;
>>> -??? int iter = 0;
>>> -
>>> -??? if ((vp->options & VECTOR_RX) > 0)
>>> -??????? while (((err = vector_mmsg_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
>>
>> You can remove the MAX_ITERATIONS define now.
> 
> Thanks, missed that.
> 
>>
>>
>>> +static int vector_poll(struct napi_struct *napi, int budget)
>>> ? {
>>> -??? struct vector_private *vp = from_tasklet(vp, t, tx_poll);
>>> +??? struct vector_private *vp = container_of(napi, struct vector_private, napi);
>>> +??? int work_done = 0;
>>> +??? int err;
>>> +??? bool tx_enqueued = false;
>>> -??? vp->estats.tx_kicks++;
>>> -??? vector_send(vp->tx_queue);
>>> +??? if ((vp->options & VECTOR_TX) != 0)
>>> +??????? tx_enqueued = (vector_send(vp->tx_queue) > 0);
>>> +??? if ((vp->options & VECTOR_RX) > 0)
>>> +??????? err = vector_mmsg_rx(vp);
>>> +??? else {
>>> +??????? err = vector_legacy_rx(vp);
>>
>> It feels like you should honour the NAPI and pass the budget down, using
>> it to limit the number of packets processed for TX/RX, something like
>>
>> tx_enqueued = vector_send(..., budget);
>> budget -= tx_enqueued;
> 
> Good idea :)
> 
>>
>> if (budget > 0)
>> ????err = vector_mmsg_rx(vp, budget);
>>
>> etc.
>>
>>> @@ -1264,6 +1251,10 @@ static int vector_net_open(struct net_device *dev)
>>> ????????? if (vp->header_txbuffer == NULL)
>>> ????????????? goto out_close;
>>> ????? }
>>> +??? /* NAPI */
>>> +
>>
>> That comment feels a bit pointless, but whatever :)
> 
> Thanks, I used that to make my life easier editing it. Forgot to remove it.
> 
>>
>>> +??? netif_napi_add(vp->dev, &vp->napi, vector_poll, 64);
>>> +??? napi_enable(&vp->napi);
>>
>> I think this should only be done once when you create the netdev?
> 
> I need to have a look around the kernel and think on this one. Historically, UML does a few things in open() which are closer to device instantiation for real hardware.

There are quite a few  drivers which do it in open and disable it in close.

Example: Atheros AR71xx

So this looks OK in terms of where it is and how vector_kern is using it.

> 
>>
>>
>>> @@ -1312,9 +1303,11 @@ static int vector_net_open(struct net_device *dev)
>>> ?????? * SIGIOs never arrive, and the net never works.
>>> ?????? */
>>> -??? vector_rx(vp);
>>> ????? vector_reset_stats(vp);
>>> +
>>> +??? napi_schedule(&vp->napi);
>>>
>>
>> The comment should probably move with this?
> 
> Yes. Well spotted.
> 
>>
>> johannes
>>
> 

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Fri Jan 21 03:11:05 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Fri, 21 Jan 2022 11:11:05 +0000
Subject: [PATCH] um: Migrate vector drivers to NAPI
In-Reply-To: <1d4806fe15c70bdfa5fa5d50d63ef1208f6e40a8.camel@sipsolutions.net>
References: <20220121085557.1250299-1-anton.ivanov@cambridgegreys.com>
 <1d4806fe15c70bdfa5fa5d50d63ef1208f6e40a8.camel@sipsolutions.net>
Message-ID: <f1eaf186-ce50-172c-d2c8-1f69701c2f40@cambridgegreys.com>



On 21/01/2022 09:29, Johannes Berg wrote:
> On Fri, 2022-01-21 at 08:55 +0000, anton.ivanov at cambridgegreys.com
> wrote:
>> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
>>
>> Migrate UML vector drivers from a bespoke scheduling mechanism
>> to NAPI.
> 
> Nice :)
> 
>> -static void vector_rx(struct vector_private *vp)
>> -{
>> -	int err;
>> -	int iter = 0;
>> -
>> -	if ((vp->options & VECTOR_RX) > 0)
>> -		while (((err = vector_mmsg_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
> 
> You can remove the MAX_ITERATIONS define now.
> 
> 
>> +static int vector_poll(struct napi_struct *napi, int budget)
>>   {
>> -	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
>> +	struct vector_private *vp = container_of(napi, struct vector_private, napi);
>> +	int work_done = 0;
>> +	int err;
>> +	bool tx_enqueued = false;
>>   
>> -	vp->estats.tx_kicks++;
>> -	vector_send(vp->tx_queue);
>> +	if ((vp->options & VECTOR_TX) != 0)
>> +		tx_enqueued = (vector_send(vp->tx_queue) > 0);
>> +	if ((vp->options & VECTOR_RX) > 0)
>> +		err = vector_mmsg_rx(vp);
>> +	else {
>> +		err = vector_legacy_rx(vp);
> 
> It feels like you should honour the NAPI and pass the budget down, using
> it to limit the number of packets processed for TX/RX, something like
> 
> tx_enqueued = vector_send(..., budget);
> budget -= tx_enqueued;

Looking through the source of other drivers - they do not account tx in budget.

It tried to add it as an experiment - this incurs quite a performance penalty.

> 
> if (budget > 0)
> 	err = vector_mmsg_rx(vp, budget);

This one works as advertised it will be in v2 which will hit the mailing list shortly.


> 
> etc.
> 
>> @@ -1264,6 +1251,10 @@ static int vector_net_open(struct net_device *dev)
>>   		if (vp->header_txbuffer == NULL)
>>   			goto out_close;
>>   	}
>> +	/* NAPI */
>> +
> 
> That comment feels a bit pointless, but whatever :)
> 
>> +	netif_napi_add(vp->dev, &vp->napi, vector_poll, 64);
>> +	napi_enable(&vp->napi);
> 
> I think this should only be done once when you create the netdev?
> 
> 
>> @@ -1312,9 +1303,11 @@ static int vector_net_open(struct net_device *dev)
>>   	 * SIGIOs never arrive, and the net never works.
>>   	 */
>>   
>> -	vector_rx(vp);
>>   
>>   	vector_reset_stats(vp);
>> +
>> +	napi_schedule(&vp->napi);
>>
> 
> The comment should probably move with this?
> 
> johannes
> 
> _______________________________________________
> linux-um mailing list
> linux-um at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-um
> 

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Fri Jan 21 03:11:49 2022
From: anton.ivanov at cambridgegreys.com (anton.ivanov at cambridgegreys.com)
Date: Fri, 21 Jan 2022 11:11:49 +0000
Subject: [PATCH v2] um: Migrate vector drivers to NAPI
Message-ID: <20220121111149.1287874-1-anton.ivanov@cambridgegreys.com>

From: Anton Ivanov <anton.ivanov at cambridgegreys.com>

Migrate UML vector drivers from a bespoke scheduling mechanism
to NAPI.

Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
---
 arch/um/drivers/vector_kern.c | 105 ++++++++++++++++------------------
 arch/um/drivers/vector_kern.h |   3 +-
 2 files changed, 51 insertions(+), 57 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 4fc1a5d70dcf..1d6f6a66766c 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -67,6 +67,7 @@ static LIST_HEAD(vector_devices);
 static int driver_registered;
 
 static void vector_eth_configure(int n, struct arglist *def);
+static int vector_mmsg_rx(struct vector_private *vp, int budget);
 
 /* Argument accessors to set variables (and/or set default values)
  * mtu, buffer sizing, default headroom, etc
@@ -77,7 +78,6 @@ static void vector_eth_configure(int n, struct arglist *def);
 #define DEFAULT_VECTOR_SIZE 64
 #define TX_SMALL_PACKET 128
 #define MAX_IOV_SIZE (MAX_SKB_FRAGS + 1)
-#define MAX_ITERATIONS 64
 
 static const struct {
 	const char string[ETH_GSTRING_LEN];
@@ -458,7 +458,6 @@ static int vector_send(struct vector_queue *qi)
 					vp->estats.tx_queue_running_average =
 						(vp->estats.tx_queue_running_average + result) >> 1;
 				}
-				netif_trans_update(qi->dev);
 				netif_wake_queue(qi->dev);
 				/* if TX is busy, break out of the send loop,
 				 *  poll write IRQ will reschedule xmit for us
@@ -470,8 +469,6 @@ static int vector_send(struct vector_queue *qi)
 			}
 		}
 		spin_unlock(&qi->head_lock);
-	} else {
-		tasklet_schedule(&vp->tx_poll);
 	}
 	return queue_depth;
 }
@@ -608,7 +605,7 @@ static struct vector_queue *create_queue(
 
 /*
  * We do not use the RX queue as a proper wraparound queue for now
- * This is not necessary because the consumption via netif_rx()
+ * This is not necessary because the consumption via napi_gro_receive()
  * happens in-line. While we can try using the return code of
  * netif_rx() for flow control there are no drivers doing this today.
  * For this RX specific use we ignore the tail/head locks and
@@ -896,7 +893,7 @@ static int vector_legacy_rx(struct vector_private *vp)
 			skb->protocol = eth_type_trans(skb, skb->dev);
 			vp->dev->stats.rx_bytes += skb->len;
 			vp->dev->stats.rx_packets++;
-			netif_rx(skb);
+			napi_gro_receive(&vp->napi, skb);
 		} else {
 			dev_kfree_skb_irq(skb);
 		}
@@ -955,7 +952,7 @@ static int writev_tx(struct vector_private *vp, struct sk_buff *skb)
  * mmsg vector matched to an skb vector which we prepared earlier.
  */
 
-static int vector_mmsg_rx(struct vector_private *vp)
+static int vector_mmsg_rx(struct vector_private *vp, int budget)
 {
 	int packet_count, i;
 	struct vector_queue *qi = vp->rx_queue;
@@ -972,6 +969,9 @@ static int vector_mmsg_rx(struct vector_private *vp)
 
 	/* Fire the Lazy Gun - get as many packets as we can in one go. */
 
+	if (budget > qi->max_depth)
+		budget = qi->max_depth;
+
 	packet_count = uml_vector_recvmmsg(
 		vp->fds->rx_fd, qi->mmsg_vector, qi->max_depth, 0);
 
@@ -1021,7 +1021,7 @@ static int vector_mmsg_rx(struct vector_private *vp)
 			 */
 			vp->dev->stats.rx_bytes += skb->len;
 			vp->dev->stats.rx_packets++;
-			netif_rx(skb);
+			napi_gro_receive(&vp->napi, skb);
 		} else {
 			/* Overlay header too short to do anything - discard.
 			 * We can actually keep this skb and reuse it,
@@ -1044,23 +1044,6 @@ static int vector_mmsg_rx(struct vector_private *vp)
 	return packet_count;
 }
 
-static void vector_rx(struct vector_private *vp)
-{
-	int err;
-	int iter = 0;
-
-	if ((vp->options & VECTOR_RX) > 0)
-		while (((err = vector_mmsg_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
-			iter++;
-	else
-		while (((err = vector_legacy_rx(vp)) > 0) && (iter < MAX_ITERATIONS))
-			iter++;
-	if ((err != 0) && net_ratelimit())
-		netdev_err(vp->dev, "vector_rx: error(%d)\n", err);
-	if (iter == MAX_ITERATIONS)
-		netdev_err(vp->dev, "vector_rx: device stuck, remote end may have closed the connection\n");
-}
-
 static int vector_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct vector_private *vp = netdev_priv(dev);
@@ -1085,25 +1068,15 @@ static int vector_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	netdev_sent_queue(vp->dev, skb->len);
 	queue_depth = vector_enqueue(vp->tx_queue, skb);
 
-	/* if the device queue is full, stop the upper layers and
-	 * flush it.
-	 */
-
-	if (queue_depth >= vp->tx_queue->max_depth - 1) {
-		vp->estats.tx_kicks++;
-		netif_stop_queue(dev);
-		vector_send(vp->tx_queue);
-		return NETDEV_TX_OK;
-	}
-	if (netdev_xmit_more()) {
+	if (queue_depth < vp->tx_queue->max_depth && netdev_xmit_more()) {
 		mod_timer(&vp->tl, vp->coalesce);
 		return NETDEV_TX_OK;
+	} else {
+		queue_depth = vector_send(vp->tx_queue);
+		if (queue_depth > 0)
+			napi_schedule(&vp->napi);
 	}
-	if (skb->len < TX_SMALL_PACKET) {
-		vp->estats.tx_kicks++;
-		vector_send(vp->tx_queue);
-	} else
-		tasklet_schedule(&vp->tx_poll);
+
 	return NETDEV_TX_OK;
 }
 
@@ -1114,7 +1087,7 @@ static irqreturn_t vector_rx_interrupt(int irq, void *dev_id)
 
 	if (!netif_running(dev))
 		return IRQ_NONE;
-	vector_rx(vp);
+	napi_schedule(&vp->napi);
 	return IRQ_HANDLED;
 
 }
@@ -1133,8 +1106,7 @@ static irqreturn_t vector_tx_interrupt(int irq, void *dev_id)
 	 * tweaking the IRQ mask less costly
 	 */
 
-	if (vp->in_write_poll)
-		tasklet_schedule(&vp->tx_poll);
+	napi_schedule(&vp->napi);
 	return IRQ_HANDLED;
 
 }
@@ -1161,7 +1133,8 @@ static int vector_net_close(struct net_device *dev)
 		um_free_irq(vp->tx_irq, dev);
 		vp->tx_irq = 0;
 	}
-	tasklet_kill(&vp->tx_poll);
+	napi_disable(&vp->napi);
+	netif_napi_del(&vp->napi);
 	if (vp->fds->rx_fd > 0) {
 		if (vp->bpf)
 			uml_vector_detach_bpf(vp->fds->rx_fd, vp->bpf);
@@ -1193,15 +1166,32 @@ static int vector_net_close(struct net_device *dev)
 	return 0;
 }
 
-/* TX tasklet */
-
-static void vector_tx_poll(struct tasklet_struct *t)
+static int vector_poll(struct napi_struct *napi, int budget)
 {
-	struct vector_private *vp = from_tasklet(vp, t, tx_poll);
+	struct vector_private *vp = container_of(napi, struct vector_private, napi);
+	int work_done = 0;
+	int err;
+	bool tx_enqueued = false;
 
-	vp->estats.tx_kicks++;
-	vector_send(vp->tx_queue);
+	if ((vp->options & VECTOR_TX) != 0)
+		tx_enqueued = (vector_send(vp->tx_queue) > 0);
+	if ((vp->options & VECTOR_RX) > 0)
+		err = vector_mmsg_rx(vp, budget);
+	else {
+		err = vector_legacy_rx(vp);
+		if (err > 0)
+			err = 1;
+	}
+	if (err > 0)
+		work_done += err;
+
+	if (tx_enqueued || err > 0)
+		napi_schedule(napi);
+	if (work_done < budget)
+		napi_complete_done(napi, work_done);
+	return work_done;
 }
+
 static void vector_reset_tx(struct work_struct *work)
 {
 	struct vector_private *vp =
@@ -1265,6 +1255,9 @@ static int vector_net_open(struct net_device *dev)
 			goto out_close;
 	}
 
+	netif_napi_add(vp->dev, &vp->napi, vector_poll, get_depth(vp->parsed));
+	napi_enable(&vp->napi);
+
 	/* READ IRQ */
 	err = um_request_irq(
 		irq_rr + VECTOR_BASE_IRQ, vp->fds->rx_fd,
@@ -1306,15 +1299,15 @@ static int vector_net_open(struct net_device *dev)
 		uml_vector_attach_bpf(vp->fds->rx_fd, vp->bpf);
 
 	netif_start_queue(dev);
+	vector_reset_stats(vp);
 
 	/* clear buffer - it can happen that the host side of the interface
 	 * is full when we get here. In this case, new data is never queued,
 	 * SIGIOs never arrive, and the net never works.
 	 */
 
-	vector_rx(vp);
+	napi_schedule(&vp->napi);
 
-	vector_reset_stats(vp);
 	vdevice = find_device(vp->unit);
 	vdevice->opened = 1;
 
@@ -1543,15 +1536,16 @@ static const struct net_device_ops vector_netdev_ops = {
 #endif
 };
 
-
 static void vector_timer_expire(struct timer_list *t)
 {
 	struct vector_private *vp = from_timer(vp, t, tl);
 
 	vp->estats.tx_kicks++;
-	vector_send(vp->tx_queue);
+	napi_schedule(&vp->napi);
 }
 
+
+
 static void vector_eth_configure(
 		int n,
 		struct arglist *def
@@ -1634,7 +1628,6 @@ static void vector_eth_configure(
 	});
 
 	dev->features = dev->hw_features = (NETIF_F_SG | NETIF_F_FRAGLIST);
-	tasklet_setup(&vp->tx_poll, vector_tx_poll);
 	INIT_WORK(&vp->reset_tx, vector_reset_tx);
 
 	timer_setup(&vp->tl, vector_timer_expire, 0);
diff --git a/arch/um/drivers/vector_kern.h b/arch/um/drivers/vector_kern.h
index 8fff93a75a92..2a1fa8e0f3e1 100644
--- a/arch/um/drivers/vector_kern.h
+++ b/arch/um/drivers/vector_kern.h
@@ -14,6 +14,7 @@
 #include <linux/ctype.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
+
 #include "vector_user.h"
 
 /* Queue structure specially adapted for multiple enqueue/dequeue
@@ -72,6 +73,7 @@ struct vector_private {
 	struct list_head list;
 	spinlock_t lock;
 	struct net_device *dev;
+	struct napi_struct		napi	____cacheline_aligned;
 
 	int unit;
 
@@ -115,7 +117,6 @@ struct vector_private {
 
 	spinlock_t stats_lock;
 
-	struct tasklet_struct tx_poll;
 	bool rexmit_scheduled;
 	bool opened;
 	bool in_write_poll;
-- 
2.30.2



From geert at linux-m68k.org  Sun Jan 23 23:55:40 2022
From: geert at linux-m68k.org (Geert Uytterhoeven)
Date: Mon, 24 Jan 2022 08:55:40 +0100 (CET)
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <20220123125737.2658758-1-geert@linux-m68k.org>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
Message-ID: <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>

On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
> Below is the list of build error/warning regressions/improvements in
> v5.17-rc1[1] compared to v5.16[2].
>
> Summarized:
>  - build errors: +17/-2
>  - build warnings: +23/-25
>
> Note that there may be false regressions, as some logs are incomplete.
> Still, they're build errors/warnings.
>
> Happy fixing! ;-)
>
> Thanks to the linux-next team for providing the build service.
>
> [1] http://kisskb.ellerman.id.au/kisskb/branch/linus/head/e783362eb54cd99b2cac8b3a9aeac942e6f6ac07/ (all 99 configs)
> [2] http://kisskb.ellerman.id.au/kisskb/branch/linus/head/df0cc57e057f18e44dac8e6c18aba47ab53202f9/ (98 out of 99 configs)
>
>
> *** ERRORS ***
>
> 17 error regressions:
>  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit declaration of function 'nmi_cpu_backtrace' [-Werror=implicit-function-declaration]:  => 171:2
>  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit declaration of function 'nmi_trigger_cpumask_backtrace' [-Werror=implicit-function-declaration]:  => 226:2

powerpc-gcc5/skiroot_defconfig

>  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1756:13, 1639:13
>  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct mm_struct *)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1674:29, 1662:29
>  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct mm_struct *, long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1767:21
>  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct vm_area_struct *, long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1741:29, 1726:29
>  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct vm_area_struct *, long unsigned int,  long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1694:29, 1711:29

sparc64-gcc11/sparc-allmodconfig

>  + /kisskb/src/arch/um/include/asm/processor-generic.h: error: called object is not a function or function pointer:  => 103:18
>  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]:  => 324:9, 317:9
>  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: implicit declaration of function 'ioport_map' [-Werror=implicit-function-declaration]:  => 317:11
>  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: implicit declaration of function 'ioport_unmap' [-Werror=implicit-function-declaration]:  => 338:15

um-x86_64/um-allyesconfig

>  + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: error: control reaches end of non-void function [-Werror=return-type]:  => 1560:1

um-x86_64/um-all{mod,yes}config

>  + /kisskb/src/drivers/net/ethernet/freescale/fec_mpc52xx.c: error: passing argument 2 of 'mpc52xx_fec_set_paddr' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 659:29

powerpc-gcc5/ppc32_allmodconfig

>  + /kisskb/src/drivers/pinctrl/pinctrl-thunderbay.c: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 815:8, 815:29

arm64-gcc5.4/arm64-allmodconfig
arm64-gcc8/arm64-allmodconfig

>  + /kisskb/src/lib/test_printf.c: error: "PTR" redefined [-Werror]:  => 247:0, 247
>  + /kisskb/src/sound/pci/ca0106/ca0106.h: error: "PTR" redefined [-Werror]:  => 62, 62:0

mips-gcc8/mips-allmodconfig
mipsel/mips-allmodconfig

>  + error: arch/powerpc/kvm/book3s_64_entry.o: relocation truncated to fit: R_PPC64_REL14 (stub) against symbol `machine_check_common' defined in .text section in arch/powerpc/kernel/head_64.o:  => (.text+0x3e4)

powerpc-gcc5/powerpc-allyesconfig

Gr{oetje,eeting}s,

 						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
 							    -- Linus Torvalds


From anshuman.khandual at arm.com  Mon Jan 24 04:57:00 2022
From: anshuman.khandual at arm.com (Anshuman Khandual)
Date: Mon, 24 Jan 2022 18:27:00 +0530
Subject: [RFC V1 23/31] um/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT
In-Reply-To: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com>
References: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com>
Message-ID: <1643029028-12710-24-git-send-email-anshuman.khandual@arm.com>

This defines and exports a platform specific custom vm_get_page_prot() via
subscribing ARCH_HAS_VM_GET_PAGE_PROT. Subsequently all __SXXX and __PXXX
macros can be dropped which are no longer needed.

Cc: Jeff Dike <jdike at addtoit.com>
Cc: linux-um at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual at arm.com>
---
 arch/um/Kconfig               |  1 +
 arch/um/include/asm/pgtable.h | 17 ---------------
 arch/um/kernel/mem.c          | 41 +++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 4d398b80aea8..5836296868a8 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -9,6 +9,7 @@ config UML
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_STRNCPY_FROM_USER
 	select ARCH_HAS_STRNLEN_USER
+	select ARCH_HAS_VM_GET_PAGE_PROT
 	select ARCH_NO_PREEMPT
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
index b9e20bbe2f75..d982622c0708 100644
--- a/arch/um/include/asm/pgtable.h
+++ b/arch/um/include/asm/pgtable.h
@@ -68,23 +68,6 @@ extern unsigned long end_iomem;
  * Also, write permissions imply read permissions. This is the closest we can
  * get..
  */
-#define __P000	PAGE_NONE
-#define __P001	PAGE_READONLY
-#define __P010	PAGE_COPY
-#define __P011	PAGE_COPY
-#define __P100	PAGE_READONLY
-#define __P101	PAGE_READONLY
-#define __P110	PAGE_COPY
-#define __P111	PAGE_COPY
-
-#define __S000	PAGE_NONE
-#define __S001	PAGE_READONLY
-#define __S010	PAGE_SHARED
-#define __S011	PAGE_SHARED
-#define __S100	PAGE_READONLY
-#define __S101	PAGE_READONLY
-#define __S110	PAGE_SHARED
-#define __S111	PAGE_SHARED
 
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 15295c3237a0..1f53584ac361 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -197,3 +197,44 @@ void *uml_kmalloc(int size, int flags)
 {
 	return kmalloc(size, flags);
 }
+
+pgprot_t vm_get_page_prot(unsigned long vm_flags)
+{
+	switch (vm_flags & (VM_READ | VM_WRITE | VM_EXEC | VM_SHARED)) {
+	case VM_NONE:
+		return PAGE_NONE;
+	case VM_READ:
+		return PAGE_READONLY;
+	case VM_WRITE:
+		return PAGE_COPY;
+	case VM_READ | VM_WRITE:
+		return PAGE_COPY;
+	case VM_EXEC:
+		return PAGE_READONLY;
+	case VM_EXEC | VM_READ:
+		return PAGE_READONLY;
+	case VM_EXEC | VM_WRITE:
+		return PAGE_COPY;
+	case VM_EXEC | VM_READ | VM_WRITE:
+		return PAGE_COPY;
+	case VM_SHARED:
+		return PAGE_NONE;
+	case VM_SHARED | VM_READ:
+		return PAGE_READONLY;
+	case VM_SHARED | VM_WRITE:
+		return PAGE_SHARED;
+	case VM_SHARED | VM_READ | VM_WRITE:
+		return PAGE_SHARED;
+	case VM_SHARED | VM_EXEC:
+		return PAGE_READONLY;
+	case VM_SHARED | VM_EXEC | VM_READ:
+		return PAGE_READONLY;
+	case VM_SHARED | VM_EXEC | VM_WRITE:
+		return PAGE_SHARED;
+	case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE:
+		return PAGE_SHARED;
+	default:
+		BUILD_BUG();
+	}
+}
+EXPORT_SYMBOL(vm_get_page_prot);
-- 
2.25.1



From kuba at kernel.org  Mon Jan 24 09:04:33 2022
From: kuba at kernel.org (Jakub Kicinski)
Date: Mon, 24 Jan 2022 09:04:33 -0800
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
Message-ID: <20220124090433.1951e2ea@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>

On Mon, 24 Jan 2022 08:55:40 +0100 (CET) Geert Uytterhoeven wrote:
> >  + /kisskb/src/drivers/net/ethernet/freescale/fec_mpc52xx.c: error: passing argument 2 of 'mpc52xx_fec_set_paddr' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 659:29  
> 
> powerpc-gcc5/ppc32_allmodconfig
> 
> >  + /kisskb/src/drivers/pinctrl/pinctrl-thunderbay.c: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 815:8, 815:29  
> 
> arm64-gcc5.4/arm64-allmodconfig
> arm64-gcc8/arm64-allmodconfig

Let me take care of these in net.


From kuba at kernel.org  Mon Jan 24 09:23:37 2022
From: kuba at kernel.org (Jakub Kicinski)
Date: Mon, 24 Jan 2022 09:23:37 -0800
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <20220124090433.1951e2ea@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
 <20220124090433.1951e2ea@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Message-ID: <20220124092337.5ecadd71@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>

On Mon, 24 Jan 2022 09:04:33 -0800 Jakub Kicinski wrote:
> On Mon, 24 Jan 2022 08:55:40 +0100 (CET) Geert Uytterhoeven wrote:
> > >  + /kisskb/src/drivers/net/ethernet/freescale/fec_mpc52xx.c: error: passing argument 2 of 'mpc52xx_fec_set_paddr' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 659:29    
> > 
> > powerpc-gcc5/ppc32_allmodconfig

Sent:
https://lore.kernel.org/r/20220124172249.2827138-1-kuba at kernel.org/

> > >  + /kisskb/src/drivers/pinctrl/pinctrl-thunderbay.c: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 815:8, 815:29    
> > 
> > arm64-gcc5.4/arm64-allmodconfig
> > arm64-gcc8/arm64-allmodconfig  

I take this one back, that's not me.


From gregkh at linuxfoundation.org  Mon Jan 24 10:42:48 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:42:48 +0100
Subject: [PATCH 4.4 073/114] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124183927.095545464@linuxfoundation.org>
References: <20220124183927.095545464@linuxfoundation.org>
Message-ID: <20220124183929.351144409@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index f5b76355ad71a..089f979e112e3 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -14,8 +14,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 22a358ef1b0cd..dc06933ba63d9 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -334,7 +334,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index e6552275320bc..40ecacb2c54b3 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -9,6 +9,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 {
@@ -32,7 +33,7 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 	switch (code) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From alexdeucher at gmail.com  Mon Jan 24 10:51:48 2022
From: alexdeucher at gmail.com (Alex Deucher)
Date: Mon, 24 Jan 2022 13:51:48 -0500
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
Message-ID: <CADnq5_MUq0fX7wMLJyUUxxa+2xoRinonL-TzD8tUhXALRfY8-A@mail.gmail.com>

On Mon, Jan 24, 2022 at 5:25 AM Geert Uytterhoeven <geert at linux-m68k.org> wrote:
>
> On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
> > Below is the list of build error/warning regressions/improvements in
> > v5.17-rc1[1] compared to v5.16[2].
> >
> > Summarized:
> >  - build errors: +17/-2
> >  - build warnings: +23/-25
> >
> > Note that there may be false regressions, as some logs are incomplete.
> > Still, they're build errors/warnings.
> >
> > Happy fixing! ;-)
> >
> > Thanks to the linux-next team for providing the build service.
> >
> > [1] http://kisskb.ellerman.id.au/kisskb/branch/linus/head/e783362eb54cd99b2cac8b3a9aeac942e6f6ac07/ (all 99 configs)
> > [2] http://kisskb.ellerman.id.au/kisskb/branch/linus/head/df0cc57e057f18e44dac8e6c18aba47ab53202f9/ (98 out of 99 configs)
> >
> >
> > *** ERRORS ***
> >
> > 17 error regressions:
> >  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit declaration of function 'nmi_cpu_backtrace' [-Werror=implicit-function-declaration]:  => 171:2
> >  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit declaration of function 'nmi_trigger_cpumask_backtrace' [-Werror=implicit-function-declaration]:  => 226:2
>
> powerpc-gcc5/skiroot_defconfig
>
> >  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1756:13, 1639:13
> >  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct mm_struct *)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1674:29, 1662:29
> >  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct mm_struct *, long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1767:21
> >  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct vm_area_struct *, long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1741:29, 1726:29
> >  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible function types from 'void (*)(struct vm_area_struct *, long unsigned int,  long unsigned int)' to 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:  => 1694:29, 1711:29
>
> sparc64-gcc11/sparc-allmodconfig
>
> >  + /kisskb/src/arch/um/include/asm/processor-generic.h: error: called object is not a function or function pointer:  => 103:18
> >  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]:  => 324:9, 317:9
> >  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: implicit declaration of function 'ioport_map' [-Werror=implicit-function-declaration]:  => 317:11
> >  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: implicit declaration of function 'ioport_unmap' [-Werror=implicit-function-declaration]:  => 338:15
>
> um-x86_64/um-allyesconfig
>
> >  + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: error: control reaches end of non-void function [-Werror=return-type]:  => 1560:1

I don't really see what's going on here:

#ifdef CONFIG_X86_64
return cpu_data(first_cpu_of_numa_node).apicid;
#else
return first_cpu_of_numa_node;
#endif

Alex

>
> um-x86_64/um-all{mod,yes}config
>
> >  + /kisskb/src/drivers/net/ethernet/freescale/fec_mpc52xx.c: error: passing argument 2 of 'mpc52xx_fec_set_paddr' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 659:29
>
> powerpc-gcc5/ppc32_allmodconfig
>
> >  + /kisskb/src/drivers/pinctrl/pinctrl-thunderbay.c: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]:  => 815:8, 815:29
>
> arm64-gcc5.4/arm64-allmodconfig
> arm64-gcc8/arm64-allmodconfig
>
> >  + /kisskb/src/lib/test_printf.c: error: "PTR" redefined [-Werror]:  => 247:0, 247
> >  + /kisskb/src/sound/pci/ca0106/ca0106.h: error: "PTR" redefined [-Werror]:  => 62, 62:0
>
> mips-gcc8/mips-allmodconfig
> mipsel/mips-allmodconfig
>
> >  + error: arch/powerpc/kvm/book3s_64_entry.o: relocation truncated to fit: R_PPC64_REL14 (stub) against symbol `machine_check_common' defined in .text section in arch/powerpc/kernel/head_64.o:  => (.text+0x3e4)
>
> powerpc-gcc5/powerpc-allyesconfig
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds


From geert at linux-m68k.org  Mon Jan 24 10:55:32 2022
From: geert at linux-m68k.org (Geert Uytterhoeven)
Date: Mon, 24 Jan 2022 19:55:32 +0100
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <CADnq5_MUq0fX7wMLJyUUxxa+2xoRinonL-TzD8tUhXALRfY8-A@mail.gmail.com>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
 <CADnq5_MUq0fX7wMLJyUUxxa+2xoRinonL-TzD8tUhXALRfY8-A@mail.gmail.com>
Message-ID: <CAMuHMdWUWqHYbbavtMT-XAD_sarDPC5xnc3c0pX1ZAh3Wuzuzg@mail.gmail.com>

Hi Alex,

On Mon, Jan 24, 2022 at 7:52 PM Alex Deucher <alexdeucher at gmail.com> wrote:
> On Mon, Jan 24, 2022 at 5:25 AM Geert Uytterhoeven <geert at linux-m68k.org> wrote:
> > On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
> > >  + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: error: control reaches end of non-void function [-Werror=return-type]:  => 1560:1
>
> I don't really see what's going on here:
>
> #ifdef CONFIG_X86_64
> return cpu_data(first_cpu_of_numa_node).apicid;
> #else
> return first_cpu_of_numa_node;
> #endif

Ah, the actual failure causing this was not included:

In file included from /kisskb/src/arch/x86/um/asm/processor.h:41:0,
                 from /kisskb/src/include/linux/mutex.h:19,
                 from /kisskb/src/include/linux/kernfs.h:11,
                 from /kisskb/src/include/linux/sysfs.h:16,
                 from /kisskb/src/include/linux/kobject.h:20,
                 from /kisskb/src/include/linux/pci.h:35,
                 from
/kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:25:
/kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In
function 'kfd_cpumask_to_apic_id':
/kisskb/src/arch/um/include/asm/processor-generic.h:103:18: error:
called object is not a function or function pointer
 #define cpu_data (&boot_cpu_data)
                  ^
/kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9:
note: in expansion of macro 'cpu_data'
  return cpu_data(first_cpu_of_numa_node).apicid;
         ^
/kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1:
error: control reaches end of non-void function [-Werror=return-type]
 }
 ^

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


From gregkh at linuxfoundation.org  Mon Jan 24 10:43:03 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:43:03 +0100
Subject: [PATCH 4.9 093/157] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124183932.787526760@linuxfoundation.org>
References: <20220124183932.787526760@linuxfoundation.org>
Message-ID: <20220124183935.730425818@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index a74449b5b0e31..12ad7c435e97f 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 22a358ef1b0cd..dc06933ba63d9 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -334,7 +334,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index e6552275320bc..40ecacb2c54b3 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -9,6 +9,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 {
@@ -32,7 +33,7 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 	switch (code) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From gregkh at linuxfoundation.org  Mon Jan 24 10:43:11 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:43:11 +0100
Subject: [PATCH 4.14 116/186] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124183937.101330125@linuxfoundation.org>
References: <20220124183937.101330125@linuxfoundation.org>
Message-ID: <20220124183940.841533562@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index a74449b5b0e31..12ad7c435e97f 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 82bf5f8442ba4..2c75f2d638681 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From rdunlap at infradead.org  Mon Jan 24 11:11:56 2022
From: rdunlap at infradead.org (Randy Dunlap)
Date: Mon, 24 Jan 2022 11:11:56 -0800
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <CAMuHMdWUWqHYbbavtMT-XAD_sarDPC5xnc3c0pX1ZAh3Wuzuzg@mail.gmail.com>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
 <CADnq5_MUq0fX7wMLJyUUxxa+2xoRinonL-TzD8tUhXALRfY8-A@mail.gmail.com>
 <CAMuHMdWUWqHYbbavtMT-XAD_sarDPC5xnc3c0pX1ZAh3Wuzuzg@mail.gmail.com>
Message-ID: <aca104cf-5f5f-b696-754a-35e62dbe64c3@infradead.org>



On 1/24/22 10:55, Geert Uytterhoeven wrote:
> Hi Alex,
> 
> On Mon, Jan 24, 2022 at 7:52 PM Alex Deucher <alexdeucher at gmail.com> wrote:
>> On Mon, Jan 24, 2022 at 5:25 AM Geert Uytterhoeven <geert at linux-m68k.org> wrote:
>>> On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
>>>>  + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: error: control reaches end of non-void function [-Werror=return-type]:  => 1560:1
>>
>> I don't really see what's going on here:
>>
>> #ifdef CONFIG_X86_64
>> return cpu_data(first_cpu_of_numa_node).apicid;
>> #else
>> return first_cpu_of_numa_node;
>> #endif
> 
> Ah, the actual failure causing this was not included:
> 
> In file included from /kisskb/src/arch/x86/um/asm/processor.h:41:0,
>                  from /kisskb/src/include/linux/mutex.h:19,
>                  from /kisskb/src/include/linux/kernfs.h:11,
>                  from /kisskb/src/include/linux/sysfs.h:16,
>                  from /kisskb/src/include/linux/kobject.h:20,
>                  from /kisskb/src/include/linux/pci.h:35,
>                  from
> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:25:
> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In
> function 'kfd_cpumask_to_apic_id':
> /kisskb/src/arch/um/include/asm/processor-generic.h:103:18: error:
> called object is not a function or function pointer
>  #define cpu_data (&boot_cpu_data)
>                   ^
> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9:
> note: in expansion of macro 'cpu_data'
>   return cpu_data(first_cpu_of_numa_node).apicid;
>          ^
> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1:
> error: control reaches end of non-void function [-Werror=return-type]
>  }
>  ^

ah yes, UML.
I have a bunch of UML fixes that I have been hesitant to post.

This is one of them.
What do people think about this?

thanks.

---
From: Randy Dunlap <rdunlap at infradead.org>


../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9: note: in expansion of macro ?cpu_data?
  return cpu_data(first_cpu_of_numa_node).apicid;
         ^~~~~~~~
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1: error: control reaches end of non-void function [-Werror=return-type]

../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c: In function ?kfd_fill_iolink_info_for_cpu?:
../arch/um/include/asm/processor-generic.h:103:19: error: called object is not a function or function pointer
 #define cpu_data (&boot_cpu_data)
                  ~^~~~~~~~~~~~~~~
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1688:27: note: in expansion of macro ?cpu_data?
  struct cpuinfo_x86 *c = &cpu_data(0);
                           ^~~~~~~~
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1691:7: error: dereferencing pointer to incomplete type ?struct cpuinfo_x86?
  if (c->x86_vendor == X86_VENDOR_AMD)
       ^~
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1691:23: error: ?X86_VENDOR_AMD? undeclared (first use in this function); did you mean ?X86_VENDOR_ANY??
  if (c->x86_vendor == X86_VENDOR_AMD)
                       ^~~~~~~~~~~~~~
                       X86_VENDOR_ANY

../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c: In function ?kfd_create_vcrat_image_cpu?:
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1742:11: warning: unused variable ?entries? [-Wunused-variable]
  uint32_t entries = 0;

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c     |    6 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

--- linux-next-20220107.orig/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ linux-next-20220107/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -1552,7 +1552,7 @@ static int kfd_cpumask_to_apic_id(const
 	first_cpu_of_numa_node = cpumask_first(cpumask);
 	if (first_cpu_of_numa_node >= nr_cpu_ids)
 		return -1;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 	return cpu_data(first_cpu_of_numa_node).apicid;
 #else
 	return first_cpu_of_numa_node;
--- linux-next-20220107.orig/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ linux-next-20220107/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -1679,7 +1679,7 @@ static int kfd_fill_mem_info_for_cpu(int
 	return 0;
 }
 
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
 				uint32_t *num_entries,
 				struct crat_subtype_iolink *sub_type_hdr)
@@ -1738,7 +1738,7 @@ static int kfd_create_vcrat_image_cpu(vo
 	struct crat_subtype_generic *sub_type_hdr;
 	int avail_size = *size;
 	int numa_node_id;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 	uint32_t entries = 0;
 #endif
 	int ret = 0;
@@ -1803,7 +1803,7 @@ static int kfd_create_vcrat_image_cpu(vo
 			sub_type_hdr->length);
 
 		/* Fill in Subtype: IO Link */
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 		ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
 				&entries,
 				(struct crat_subtype_iolink *)sub_type_hdr);




From gregkh at linuxfoundation.org  Mon Jan 24 10:43:16 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:43:16 +0100
Subject: [PATCH 4.19 158/239] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124183943.102762895@linuxfoundation.org>
References: <20220124183943.102762895@linuxfoundation.org>
Message-ID: <20220124183948.120592624@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index a74449b5b0e31..12ad7c435e97f 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2ff8d4fe83c4f..34a5963bd7efd 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 82bf5f8442ba4..2c75f2d638681 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From gregkh at linuxfoundation.org  Mon Jan 24 10:43:06 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:43:06 +0100
Subject: [PATCH 5.4 202/320] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124183953.750177707@linuxfoundation.org>
References: <20220124183953.750177707@linuxfoundation.org>
Message-ID: <20220124184000.509506732@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index f79dc338279e6..b28373a2b8d2d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From gregkh at linuxfoundation.org  Mon Jan 24 10:42:24 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:42:24 +0100
Subject: [PATCH 5.10 379/563] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124184024.407936072@linuxfoundation.org>
References: <20220124184024.407936072@linuxfoundation.org>
Message-ID: <20220124184037.530599766@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index f79dc338279e6..b28373a2b8d2d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -336,7 +336,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From gregkh at linuxfoundation.org  Mon Jan 24 10:41:39 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:41:39 +0100
Subject: [PATCH 5.15 582/846] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124184100.867127425@linuxfoundation.org>
References: <20220124184100.867127425@linuxfoundation.org>
Message-ID: <20220124184121.128025849@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 8a72c99994eb1..e3ee4db58b40d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -368,7 +368,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From gregkh at linuxfoundation.org  Mon Jan 24 10:41:17 2022
From: gregkh at linuxfoundation.org (Greg Kroah-Hartman)
Date: Mon, 24 Jan 2022 19:41:17 +0100
Subject: [PATCH 5.16 0688/1039] um: registers: Rename function names to avoid
 conflicts and build problems
In-Reply-To: <20220124184125.121143506@linuxfoundation.org>
References: <20220124184125.121143506@linuxfoundation.org>
Message-ID: <20220124184148.478052926@linuxfoundation.org>

From: Randy Dunlap <rdunlap at infradead.org>

[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]

The function names init_registers() and restore_registers() are used
in several net/ethernet/ and gpu/drm/ drivers for other purposes (not
calls to UML functions), so rename them.

This fixes multiple build errors.

Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
Cc: Jeff Dike <jdike at addtoit.com>
Cc: Richard Weinberger <richard at nod.at>
Cc: Anton Ivanov <anton.ivanov at cambridgegreys.com>
Cc: linux-um at lists.infradead.org
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
 arch/um/include/shared/registers.h | 4 ++--
 arch/um/os-Linux/registers.c       | 4 ++--
 arch/um/os-Linux/start_up.c        | 2 +-
 arch/x86/um/syscalls_64.c          | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h
index 0c50fa6e8a55b..fbb709a222839 100644
--- a/arch/um/include/shared/registers.h
+++ b/arch/um/include/shared/registers.h
@@ -16,8 +16,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
 extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
 extern int save_registers(int pid, struct uml_pt_regs *regs);
-extern int restore_registers(int pid, struct uml_pt_regs *regs);
-extern int init_registers(int pid);
+extern int restore_pid_registers(int pid, struct uml_pt_regs *regs);
+extern int init_pid_registers(int pid);
 extern void get_safe_registers(unsigned long *regs, unsigned long *fp_regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 extern int get_fp_registers(int pid, unsigned long *regs);
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
index 2d9270508e156..b123955be7acc 100644
--- a/arch/um/os-Linux/registers.c
+++ b/arch/um/os-Linux/registers.c
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)
 	return 0;
 }
 
-int restore_registers(int pid, struct uml_pt_regs *regs)
+int restore_pid_registers(int pid, struct uml_pt_regs *regs)
 {
 	int err;
 
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)
 static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[FP_SIZE];
 
-int init_registers(int pid)
+int init_pid_registers(int pid)
 {
 	int err;
 
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 8a72c99994eb1..e3ee4db58b40d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -368,7 +368,7 @@ void __init os_early_checks(void)
 	check_tmpexec();
 
 	pid = start_ptraced_child();
-	if (init_registers(pid))
+	if (init_pid_registers(pid))
 		fatal("Failed to initialize default registers");
 	stop_ptraced_child(pid, 1, 1);
 }
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4b..8249685b40960 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <asm/prctl.h> /* XXX This should get the constants from libc */
 #include <os.h>
+#include <registers.h>
 
 long arch_prctl(struct task_struct *task, int option,
 		unsigned long __user *arg2)
@@ -35,7 +36,7 @@ long arch_prctl(struct task_struct *task, int option,
 	switch (option) {
 	case ARCH_SET_FS:
 	case ARCH_SET_GS:
-		ret = restore_registers(pid, &current->thread.regs.regs);
+		ret = restore_pid_registers(pid, &current->thread.regs.regs);
 		if (ret)
 			return ret;
 		break;
-- 
2.34.1





From felix.kuehling at amd.com  Mon Jan 24 17:23:56 2022
From: felix.kuehling at amd.com (Felix Kuehling)
Date: Mon, 24 Jan 2022 20:23:56 -0500
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <aca104cf-5f5f-b696-754a-35e62dbe64c3@infradead.org>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
 <CADnq5_MUq0fX7wMLJyUUxxa+2xoRinonL-TzD8tUhXALRfY8-A@mail.gmail.com>
 <CAMuHMdWUWqHYbbavtMT-XAD_sarDPC5xnc3c0pX1ZAh3Wuzuzg@mail.gmail.com>
 <aca104cf-5f5f-b696-754a-35e62dbe64c3@infradead.org>
Message-ID: <500a3aa0-f51e-92ac-82d6-7ffc7f603e2c@amd.com>


Am 2022-01-24 um 14:11 schrieb Randy Dunlap:
> On 1/24/22 10:55, Geert Uytterhoeven wrote:
>> Hi Alex,
>>
>> On Mon, Jan 24, 2022 at 7:52 PM Alex Deucher <alexdeucher at gmail.com> wrote:
>>> On Mon, Jan 24, 2022 at 5:25 AM Geert Uytterhoeven <geert at linux-m68k.org> wrote:
>>>> On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
>>>>>   + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: error: control reaches end of non-void function [-Werror=return-type]:  => 1560:1
>>> I don't really see what's going on here:
>>>
>>> #ifdef CONFIG_X86_64
>>> return cpu_data(first_cpu_of_numa_node).apicid;
>>> #else
>>> return first_cpu_of_numa_node;
>>> #endif
>> Ah, the actual failure causing this was not included:
>>
>> In file included from /kisskb/src/arch/x86/um/asm/processor.h:41:0,
>>                   from /kisskb/src/include/linux/mutex.h:19,
>>                   from /kisskb/src/include/linux/kernfs.h:11,
>>                   from /kisskb/src/include/linux/sysfs.h:16,
>>                   from /kisskb/src/include/linux/kobject.h:20,
>>                   from /kisskb/src/include/linux/pci.h:35,
>>                   from
>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:25:
>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In
>> function 'kfd_cpumask_to_apic_id':
>> /kisskb/src/arch/um/include/asm/processor-generic.h:103:18: error:
>> called object is not a function or function pointer
>>   #define cpu_data (&boot_cpu_data)
>>                    ^
>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9:
>> note: in expansion of macro 'cpu_data'
>>    return cpu_data(first_cpu_of_numa_node).apicid;
>>           ^
>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1:
>> error: control reaches end of non-void function [-Werror=return-type]
>>   }
>>   ^
> ah yes, UML.
> I have a bunch of UML fixes that I have been hesitant to post.
>
> This is one of them.
> What do people think about this?

Does it make sense to configure a UML kernel with a real device driver 
in the first place? Or should we just prevent enabling amdgpu for UML 
with a Kconfig dependency?

Regards,
 ? Felix


>
> thanks.
>
> ---
> From: Randy Dunlap <rdunlap at infradead.org>
>
>
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9: note: in expansion of macro ?cpu_data?
>    return cpu_data(first_cpu_of_numa_node).apicid;
>           ^~~~~~~~
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1: error: control reaches end of non-void function [-Werror=return-type]
>
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c: In function ?kfd_fill_iolink_info_for_cpu?:
> ../arch/um/include/asm/processor-generic.h:103:19: error: called object is not a function or function pointer
>   #define cpu_data (&boot_cpu_data)
>                    ~^~~~~~~~~~~~~~~
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1688:27: note: in expansion of macro ?cpu_data?
>    struct cpuinfo_x86 *c = &cpu_data(0);
>                             ^~~~~~~~
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1691:7: error: dereferencing pointer to incomplete type ?struct cpuinfo_x86?
>    if (c->x86_vendor == X86_VENDOR_AMD)
>         ^~
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1691:23: error: ?X86_VENDOR_AMD? undeclared (first use in this function); did you mean ?X86_VENDOR_ANY??
>    if (c->x86_vendor == X86_VENDOR_AMD)
>                         ^~~~~~~~~~~~~~
>                         X86_VENDOR_ANY
>
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c: In function ?kfd_create_vcrat_image_cpu?:
> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1742:11: warning: unused variable ?entries? [-Wunused-variable]
>    uint32_t entries = 0;
>
> Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_crat.c     |    6 +++---
>   drivers/gpu/drm/amd/amdkfd/kfd_topology.c |    2 +-
>   2 files changed, 4 insertions(+), 4 deletions(-)
>
> --- linux-next-20220107.orig/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ linux-next-20220107/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -1552,7 +1552,7 @@ static int kfd_cpumask_to_apic_id(const
>   	first_cpu_of_numa_node = cpumask_first(cpumask);
>   	if (first_cpu_of_numa_node >= nr_cpu_ids)
>   		return -1;
> -#ifdef CONFIG_X86_64
> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>   	return cpu_data(first_cpu_of_numa_node).apicid;
>   #else
>   	return first_cpu_of_numa_node;
> --- linux-next-20220107.orig/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> +++ linux-next-20220107/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> @@ -1679,7 +1679,7 @@ static int kfd_fill_mem_info_for_cpu(int
>   	return 0;
>   }
>   
> -#ifdef CONFIG_X86_64
> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>   static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
>   				uint32_t *num_entries,
>   				struct crat_subtype_iolink *sub_type_hdr)
> @@ -1738,7 +1738,7 @@ static int kfd_create_vcrat_image_cpu(vo
>   	struct crat_subtype_generic *sub_type_hdr;
>   	int avail_size = *size;
>   	int numa_node_id;
> -#ifdef CONFIG_X86_64
> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>   	uint32_t entries = 0;
>   #endif
>   	int ret = 0;
> @@ -1803,7 +1803,7 @@ static int kfd_create_vcrat_image_cpu(vo
>   			sub_type_hdr->length);
>   
>   		/* Fill in Subtype: IO Link */
> -#ifdef CONFIG_X86_64
> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>   		ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
>   				&entries,
>   				(struct crat_subtype_iolink *)sub_type_hdr);
>
>


From rdunlap at infradead.org  Mon Jan 24 17:29:17 2022
From: rdunlap at infradead.org (Randy Dunlap)
Date: Mon, 24 Jan 2022 17:29:17 -0800
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <500a3aa0-f51e-92ac-82d6-7ffc7f603e2c@amd.com>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
 <CADnq5_MUq0fX7wMLJyUUxxa+2xoRinonL-TzD8tUhXALRfY8-A@mail.gmail.com>
 <CAMuHMdWUWqHYbbavtMT-XAD_sarDPC5xnc3c0pX1ZAh3Wuzuzg@mail.gmail.com>
 <aca104cf-5f5f-b696-754a-35e62dbe64c3@infradead.org>
 <500a3aa0-f51e-92ac-82d6-7ffc7f603e2c@amd.com>
Message-ID: <0ddcd3d8-6fca-dc6a-d9d8-f8df8715be95@infradead.org>



On 1/24/22 17:23, Felix Kuehling wrote:
> 
> Am 2022-01-24 um 14:11 schrieb Randy Dunlap:
>> On 1/24/22 10:55, Geert Uytterhoeven wrote:
>>> Hi Alex,
>>>
>>> On Mon, Jan 24, 2022 at 7:52 PM Alex Deucher <alexdeucher at gmail.com> wrote:
>>>> On Mon, Jan 24, 2022 at 5:25 AM Geert Uytterhoeven <geert at linux-m68k.org> wrote:
>>>>> On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
>>>>>> ? + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: error: control reaches end of non-void function [-Werror=return-type]:? => 1560:1
>>>> I don't really see what's going on here:
>>>>
>>>> #ifdef CONFIG_X86_64
>>>> return cpu_data(first_cpu_of_numa_node).apicid;
>>>> #else
>>>> return first_cpu_of_numa_node;
>>>> #endif
>>> Ah, the actual failure causing this was not included:
>>>
>>> In file included from /kisskb/src/arch/x86/um/asm/processor.h:41:0,
>>> ????????????????? from /kisskb/src/include/linux/mutex.h:19,
>>> ????????????????? from /kisskb/src/include/linux/kernfs.h:11,
>>> ????????????????? from /kisskb/src/include/linux/sysfs.h:16,
>>> ????????????????? from /kisskb/src/include/linux/kobject.h:20,
>>> ????????????????? from /kisskb/src/include/linux/pci.h:35,
>>> ????????????????? from
>>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:25:
>>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In
>>> function 'kfd_cpumask_to_apic_id':
>>> /kisskb/src/arch/um/include/asm/processor-generic.h:103:18: error:
>>> called object is not a function or function pointer
>>> ? #define cpu_data (&boot_cpu_data)
>>> ?????????????????? ^
>>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9:
>>> note: in expansion of macro 'cpu_data'
>>> ?? return cpu_data(first_cpu_of_numa_node).apicid;
>>> ????????? ^
>>> /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1:
>>> error: control reaches end of non-void function [-Werror=return-type]
>>> ? }
>>> ? ^
>> ah yes, UML.
>> I have a bunch of UML fixes that I have been hesitant to post.
>>
>> This is one of them.
>> What do people think about this?
> 
> Does it make sense to configure a UML kernel with a real device driver in the first place? Or should we just prevent enabling amdgpu for UML with a Kconfig dependency?
> 

Hi,

Your option IMO. I have seen both opinions given.
I also meant to reply that someone could just add
	depends on !UML
for this device, like you are suggesting.

I'm fine with it either way.

thanks.

> 
>>
>> thanks.
>>
>> ---
>> From: Randy Dunlap <rdunlap at infradead.org>
>>
>>
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1556:9: note: in expansion of macro ?cpu_data?
>> ?? return cpu_data(first_cpu_of_numa_node).apicid;
>> ????????? ^~~~~~~~
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1560:1: error: control reaches end of non-void function [-Werror=return-type]
>>
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c: In function ?kfd_fill_iolink_info_for_cpu?:
>> ../arch/um/include/asm/processor-generic.h:103:19: error: called object is not a function or function pointer
>> ? #define cpu_data (&boot_cpu_data)
>> ?????????????????? ~^~~~~~~~~~~~~~~
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1688:27: note: in expansion of macro ?cpu_data?
>> ?? struct cpuinfo_x86 *c = &cpu_data(0);
>> ??????????????????????????? ^~~~~~~~
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1691:7: error: dereferencing pointer to incomplete type ?struct cpuinfo_x86?
>> ?? if (c->x86_vendor == X86_VENDOR_AMD)
>> ??????? ^~
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1691:23: error: ?X86_VENDOR_AMD? undeclared (first use in this function); did you mean ?X86_VENDOR_ANY??
>> ?? if (c->x86_vendor == X86_VENDOR_AMD)
>> ??????????????????????? ^~~~~~~~~~~~~~
>> ??????????????????????? X86_VENDOR_ANY
>>
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c: In function ?kfd_create_vcrat_image_cpu?:
>> ../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_crat.c:1742:11: warning: unused variable ?entries? [-Wunused-variable]
>> ?? uint32_t entries = 0;
>>
>> Signed-off-by: Randy Dunlap <rdunlap at infradead.org>
>> ---
>> ? drivers/gpu/drm/amd/amdkfd/kfd_crat.c???? |??? 6 +++---
>> ? drivers/gpu/drm/amd/amdkfd/kfd_topology.c |??? 2 +-
>> ? 2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> --- linux-next-20220107.orig/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> +++ linux-next-20220107/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> @@ -1552,7 +1552,7 @@ static int kfd_cpumask_to_apic_id(const
>> ????? first_cpu_of_numa_node = cpumask_first(cpumask);
>> ????? if (first_cpu_of_numa_node >= nr_cpu_ids)
>> ????????? return -1;
>> -#ifdef CONFIG_X86_64
>> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>> ????? return cpu_data(first_cpu_of_numa_node).apicid;
>> ? #else
>> ????? return first_cpu_of_numa_node;
>> --- linux-next-20220107.orig/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
>> +++ linux-next-20220107/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
>> @@ -1679,7 +1679,7 @@ static int kfd_fill_mem_info_for_cpu(int
>> ????? return 0;
>> ? }
>> ? -#ifdef CONFIG_X86_64
>> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>> ? static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
>> ????????????????? uint32_t *num_entries,
>> ????????????????? struct crat_subtype_iolink *sub_type_hdr)
>> @@ -1738,7 +1738,7 @@ static int kfd_create_vcrat_image_cpu(vo
>> ????? struct crat_subtype_generic *sub_type_hdr;
>> ????? int avail_size = *size;
>> ????? int numa_node_id;
>> -#ifdef CONFIG_X86_64
>> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>> ????? uint32_t entries = 0;
>> ? #endif
>> ????? int ret = 0;
>> @@ -1803,7 +1803,7 @@ static int kfd_create_vcrat_image_cpu(vo
>> ????????????? sub_type_hdr->length);
>> ? ????????? /* Fill in Subtype: IO Link */
>> -#ifdef CONFIG_X86_64
>> +#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
>> ????????? ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
>> ????????????????? &entries,
>> ????????????????? (struct crat_subtype_iolink *)sub_type_hdr);
>>
>>

-- 
~Randy


From lakshmi.sowjanya.d at intel.com  Tue Jan 25 04:56:50 2022
From: lakshmi.sowjanya.d at intel.com (D, Lakshmi Sowjanya)
Date: Tue, 25 Jan 2022 12:56:50 +0000
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
Message-ID: <DM6PR11MB3660804C821D7CA7329B6CAFC45F9@DM6PR11MB3660.namprd11.prod.outlook.com>



> -----Original Message-----
> From: Geert Uytterhoeven <geert at linux-m68k.org>
> Sent: Monday, January 24, 2022 1:26 PM
> To: linux-kernel at vger.kernel.org
> Cc: linuxppc-dev at lists.ozlabs.org; sparclinux at vger.kernel.org; linux-
> um at lists.infradead.org; D, Lakshmi Sowjanya
> <lakshmi.sowjanya.d at intel.com>; kvm at vger.kernel.org; linux-
> mips at vger.kernel.org; Tobin C. Harding <me at tobin.cc>; alsa-devel at alsa-
> project.org; amd-gfx at lists.freedesktop.org; netdev at vger.kernel.org
> Subject: Re: Build regressions/improvements in v5.17-rc1
> 
> On Sun, 23 Jan 2022, Geert Uytterhoeven wrote:
> > Below is the list of build error/warning regressions/improvements in
> > v5.17-rc1[1] compared to v5.16[2].
> >
> > Summarized:
> >  - build errors: +17/-2
> >  - build warnings: +23/-25
> >
> > Note that there may be false regressions, as some logs are incomplete.
> > Still, they're build errors/warnings.
> >
> > Happy fixing! ;-)
> >
> > Thanks to the linux-next team for providing the build service.
> >
> > [1]
> > http://kisskb.ellerman.id.au/kisskb/branch/linus/head/e783362eb54cd99b
> > 2cac8b3a9aeac942e6f6ac07/ (all 99 configs) [2]
> > http://kisskb.ellerman.id.au/kisskb/branch/linus/head/df0cc57e057f18e4
> > 4dac8e6c18aba47ab53202f9/ (98 out of 99 configs)
> >
> >
> > *** ERRORS ***
> >
> > 17 error regressions:
> >  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit
> > declaration of function 'nmi_cpu_backtrace'
> > [-Werror=implicit-function-declaration]:  => 171:2  +
> > /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit
> > declaration of function 'nmi_trigger_cpumask_backtrace'
> > [-Werror=implicit-function-declaration]:  => 226:2
> 
> powerpc-gcc5/skiroot_defconfig
> 
> >  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible
> > function types from 'void (*)(long unsigned int)' to 'void (*)(long
> > unsigned int,  long unsigned int,  long unsigned int,  long unsigned
> > int,  long unsigned int)' [-Werror=cast-function-type]:  => 1756:13,
> > 1639:13  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between
> > incompatible function types from 'void (*)(struct mm_struct *)' to
> > 'void (*)(long unsigned int,  long unsigned int,  long unsigned int,
> > long unsigned int,  long unsigned int)' [-Werror=cast-function-type]:
> > => 1674:29, 1662:29  + /kisskb/src/arch/sparc/mm/srmmu.c: error: cast
> > between incompatible function types from 'void (*)(struct mm_struct *,
> > long unsigned int)' to 'void (*)(long unsigned int,  long unsigned
> > int,  long unsigned int,  long unsigned int,  long unsigned int)'
> > [-Werror=cast-function-type]:  => 1767:21  +
> > /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible
> > function types from 'void (*)(struct vm_area_struct *, long unsigned
> > int)' to 'void (*)(long unsigned int,  long unsigned int,  long
> > unsigned int,  long unsigned int,  long unsigned int)'
> > [-Werror=cast-function-type]:  => 1741:29, 1726:29  +
> > /kisskb/src/arch/sparc/mm/srmmu.c: error: cast between incompatible
> > function types from 'void (*)(struct vm_area_struct *, long unsigned
> > int,  long unsigned int)' to 'void (*)(long unsigned int,  long
> > unsigned int,  long unsigned int,  long unsigned int,  long unsigned
> > int)' [-Werror=cast-function-type]:  => 1694:29, 1711:29
> 
> sparc64-gcc11/sparc-allmodconfig
> 
> >  + /kisskb/src/arch/um/include/asm/processor-generic.h: error: called
> > object is not a function or function pointer:  => 103:18  +
> > /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: assignment makes
> > pointer from integer without a cast [-Werror=int-conversion]:  =>
> > 324:9, 317:9  + /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error:
> > implicit declaration of function 'ioport_map'
> > [-Werror=implicit-function-declaration]:  => 317:11  +
> > /kisskb/src/drivers/vfio/pci/vfio_pci_rdwr.c: error: implicit
> > declaration of function 'ioport_unmap'
> > [-Werror=implicit-function-declaration]:  => 338:15
> 
> um-x86_64/um-allyesconfig
> 
> >  + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:
> > error: control reaches end of non-void function [-Werror=return-type]:
> > => 1560:1
> 
> um-x86_64/um-all{mod,yes}config
> 
> >  + /kisskb/src/drivers/net/ethernet/freescale/fec_mpc52xx.c: error:
> > passing argument 2 of 'mpc52xx_fec_set_paddr' discards 'const'
> > qualifier from pointer target type [-Werror=discarded-qualifiers]:  =>
> > 659:29
> 
> powerpc-gcc5/ppc32_allmodconfig
> 
> >  + /kisskb/src/drivers/pinctrl/pinctrl-thunderbay.c: error: assignment
> > discards 'const' qualifier from pointer target type
> > [-Werror=discarded-qualifiers]:  => 815:8, 815:29
> 
> arm64-gcc5.4/arm64-allmodconfig
> arm64-gcc8/arm64-allmodconfig
> 

These errors are fixed with the patch set by Rafa? Mi?ecki: 
https://lore.kernel.org/all/CACRpkdYbR-hpLTcvN1_LuxEH_mgHLqDmopDqo1ddui9o8ZvSPQ at mail.gmail.com/t/

Regards,
Lakshmi Sowjanya

> >  + /kisskb/src/lib/test_printf.c: error: "PTR" redefined [-Werror]:
> > => 247:0, 247  + /kisskb/src/sound/pci/ca0106/ca0106.h: error: "PTR"
> > redefined [-Werror]:  => 62, 62:0
> 
> mips-gcc8/mips-allmodconfig
> mipsel/mips-allmodconfig
> 
> >  + error: arch/powerpc/kvm/book3s_64_entry.o: relocation truncated to
> > fit: R_PPC64_REL14 (stub) against symbol `machine_check_common'
> > defined in .text section in arch/powerpc/kernel/head_64.o:  =>
> > (.text+0x3e4)
> 
> powerpc-gcc5/powerpc-allyesconfig
> 
> Gr{oetje,eeting}s,
> 
>  						Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But when
> I'm talking to journalists I just say "programmer" or something like that.
>  							    -- Linus Torvalds


From tsbogend at alpha.franken.de  Tue Jan 25 06:20:02 2022
From: tsbogend at alpha.franken.de (Thomas Bogendoerfer)
Date: Tue, 25 Jan 2022 15:20:02 +0100
Subject: Build regressions/improvements in v5.17-rc1
In-Reply-To: <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
References: <20220123125737.2658758-1-geert@linux-m68k.org>
 <alpine.DEB.2.22.394.2201240851560.2674757@ramsan.of.borg>
Message-ID: <20220125142002.GA26778@alpha.franken.de>

On Mon, Jan 24, 2022 at 08:55:40AM +0100, Geert Uytterhoeven wrote:
> >  + /kisskb/src/lib/test_printf.c: error: "PTR" redefined [-Werror]:  => 247:0, 247
> >  + /kisskb/src/sound/pci/ca0106/ca0106.h: error: "PTR" redefined [-Werror]:  => 62, 62:0
> 
> mips-gcc8/mips-allmodconfig
> mipsel/mips-allmodconfig

fixing patch sent.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]


From frederic.danis at collabora.com  Tue Jan 25 09:14:05 2022
From: frederic.danis at collabora.com (=?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?=)
Date: Tue, 25 Jan 2022 18:14:05 +0100
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
Message-ID: <20220125171405.163362-1-frederic.danis@collabora.com>

Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a sparse
file can end up by missing data, zeroes data range, if the underlying file
is used with a tool like bmaptool which will referenced only used spaces.

Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
---
 arch/um/drivers/ubd_kern.c  | 8 +++++++-
 arch/um/include/shared/os.h | 1 +
 arch/um/os-Linux/file.c     | 9 +++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 69d2d0049a61..b03269faef71 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
 			}
 			break;
 		case REQ_OP_DISCARD:
-		case REQ_OP_WRITE_ZEROES:
 			n = os_falloc_punch(req->fds[bit], off, len);
 			if (n) {
 				req->error = map_error(-n);
 				return;
 			}
 			break;
+		case REQ_OP_WRITE_ZEROES:
+			n = os_falloc_zeroes(req->fds[bit], off, len);
+			if (n) {
+				req->error = map_error(-n);
+				return;
+			}
+			break;
 		default:
 			WARN_ON_ONCE(1);
 			req->error = BLK_STS_NOTSUPP;
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index 00214059d9ec..fafde1d5416e 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
@@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
 extern unsigned os_minor(unsigned long long dev);
 extern unsigned long long os_makedev(unsigned major, unsigned minor);
 extern int os_falloc_punch(int fd, unsigned long long offset, int count);
+extern int os_falloc_zeroes(int fd, unsigned long long offset, int count);
 extern int os_eventfd(unsigned int initval, int flags);
 extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
 			  const int *fds, unsigned int fds_num);
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index e4421dbc4c36..fc4450db59bd 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long offset, int len)
 	return n;
 }
 
+int os_falloc_zeroes(int fd, unsigned long long offset, int len)
+{
+	int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len);
+
+	if (n < 0)
+		return -errno;
+	return n;
+}
+
 int os_eventfd(unsigned int initval, int flags)
 {
 	int fd = eventfd(initval, flags);
-- 
2.25.1



From anton.ivanov at cambridgegreys.com  Tue Jan 25 09:56:17 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Tue, 25 Jan 2022 17:56:17 +0000
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
In-Reply-To: <20220125171405.163362-1-frederic.danis@collabora.com>
References: <20220125171405.163362-1-frederic.danis@collabora.com>
Message-ID: <8de3a6c3-b2fd-648e-ac5f-a27da2d326db@cambridgegreys.com>

On 25/01/2022 17:14, Fr?d?ric Danis wrote:
> Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a sparse
> file can end up by missing data, zeroes data range, if the underlying file
> is used with a tool like bmaptool which will referenced only used spaces.

Can you elaborate on when do you miss data.

A file with a hole created using FALLOC_FL_PUNCH_HOLE when reading from 
the hole should return zeroes.

If it returns anything else or if the zeroed range exceeds the one 
specified in falloc - that is an underlying fs bug.

>
> Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
> ---
>   arch/um/drivers/ubd_kern.c  | 8 +++++++-
>   arch/um/include/shared/os.h | 1 +
>   arch/um/os-Linux/file.c     | 9 +++++++++
>   3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 69d2d0049a61..b03269faef71 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
>   			}
>   			break;
>   		case REQ_OP_DISCARD:
> -		case REQ_OP_WRITE_ZEROES:
>   			n = os_falloc_punch(req->fds[bit], off, len);
>   			if (n) {
>   				req->error = map_error(-n);
>   				return;
>   			}
>   			break;
> +		case REQ_OP_WRITE_ZEROES:
> +			n = os_falloc_zeroes(req->fds[bit], off, len);
> +			if (n) {
> +				req->error = map_error(-n);
> +				return;
> +			}
> +			break;
>   		default:
>   			WARN_ON_ONCE(1);
>   			req->error = BLK_STS_NOTSUPP;
> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
> index 00214059d9ec..fafde1d5416e 100644
> --- a/arch/um/include/shared/os.h
> +++ b/arch/um/include/shared/os.h
> @@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
>   extern unsigned os_minor(unsigned long long dev);
>   extern unsigned long long os_makedev(unsigned major, unsigned minor);
>   extern int os_falloc_punch(int fd, unsigned long long offset, int count);
> +extern int os_falloc_zeroes(int fd, unsigned long long offset, int count);
>   extern int os_eventfd(unsigned int initval, int flags);
>   extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
>   			  const int *fds, unsigned int fds_num);
> diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
> index e4421dbc4c36..fc4450db59bd 100644
> --- a/arch/um/os-Linux/file.c
> +++ b/arch/um/os-Linux/file.c
> @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long offset, int len)
>   	return n;
>   }
>   
> +int os_falloc_zeroes(int fd, unsigned long long offset, int len)
> +{
> +	int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len);
> +
> +	if (n < 0)
> +		return -errno;
> +	return n;
> +}
> +
>   int os_eventfd(unsigned int initval, int flags)
>   {
>   	int fd = eventfd(initval, flags);


-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/



From frederic.danis at collabora.com  Tue Jan 25 10:50:52 2022
From: frederic.danis at collabora.com (=?UTF-8?Q?Fr=c3=a9d=c3=a9ric_Danis?=)
Date: Tue, 25 Jan 2022 19:50:52 +0100
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
In-Reply-To: <8de3a6c3-b2fd-648e-ac5f-a27da2d326db@cambridgegreys.com>
References: <20220125171405.163362-1-frederic.danis@collabora.com>
 <8de3a6c3-b2fd-648e-ac5f-a27da2d326db@cambridgegreys.com>
Message-ID: <6706ba52-04ed-718e-b0b7-1296f95783da@collabora.com>

Hi Anton,

On 25/01/2022 18:56, Anton Ivanov wrote:
> On 25/01/2022 17:14, Fr?d?ric Danis wrote:
>> Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a 
>> sparse
>> file can end up by missing data, zeroes data range, if the underlying 
>> file
>> is used with a tool like bmaptool which will referenced only used spaces.
>
> Can you elaborate on when do you miss data.
>
> A file with a hole created using FALLOC_FL_PUNCH_HOLE when reading 
> from the hole should return zeroes.
>
> If it returns anything else or if the zeroed range exceeds the one 
> specified in falloc - that is an underlying fs bug.

I use bmaptool to create a block map of the used part of a raw system 
image file, then compress the file and at the end use again bmaptool to 
flash the file to a SDCard.

iiuc fallocate() call with FALLOC_FL_PUNCH_HOLE doesn't "register" the 
space, as it is zeroed, so when bmaptool creates the block map it 
doesn't reference the "used holes", and when I flash the SDCard those 
parts are missing, so the filesystem on the SDCard is corrupted.

>
>>
>> Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
>> ---
>> ? arch/um/drivers/ubd_kern.c? | 8 +++++++-
>> ? arch/um/include/shared/os.h | 1 +
>> ? arch/um/os-Linux/file.c???? | 9 +++++++++
>> ? 3 files changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
>> index 69d2d0049a61..b03269faef71 100644
>> --- a/arch/um/drivers/ubd_kern.c
>> +++ b/arch/um/drivers/ubd_kern.c
>> @@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req *req, 
>> struct io_desc *desc)
>> ????????????? }
>> ????????????? break;
>> ????????? case REQ_OP_DISCARD:
>> -??????? case REQ_OP_WRITE_ZEROES:
>> ????????????? n = os_falloc_punch(req->fds[bit], off, len);
>> ????????????? if (n) {
>> ????????????????? req->error = map_error(-n);
>> ????????????????? return;
>> ????????????? }
>> ????????????? break;
>> +??????? case REQ_OP_WRITE_ZEROES:
>> +??????????? n = os_falloc_zeroes(req->fds[bit], off, len);
>> +??????????? if (n) {
>> +??????????????? req->error = map_error(-n);
>> +??????????????? return;
>> +??????????? }
>> +??????????? break;
>> ????????? default:
>> ????????????? WARN_ON_ONCE(1);
>> ????????????? req->error = BLK_STS_NOTSUPP;
>> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
>> index 00214059d9ec..fafde1d5416e 100644
>> --- a/arch/um/include/shared/os.h
>> +++ b/arch/um/include/shared/os.h
>> @@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
>> ? extern unsigned os_minor(unsigned long long dev);
>> ? extern unsigned long long os_makedev(unsigned major, unsigned minor);
>> ? extern int os_falloc_punch(int fd, unsigned long long offset, int 
>> count);
>> +extern int os_falloc_zeroes(int fd, unsigned long long offset, int 
>> count);
>> ? extern int os_eventfd(unsigned int initval, int flags);
>> ? extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
>> ??????????????? const int *fds, unsigned int fds_num);
>> diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
>> index e4421dbc4c36..fc4450db59bd 100644
>> --- a/arch/um/os-Linux/file.c
>> +++ b/arch/um/os-Linux/file.c
>> @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long 
>> offset, int len)
>> ????? return n;
>> ? }
>> ? +int os_falloc_zeroes(int fd, unsigned long long offset, int len)
>> +{
>> +??? int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, 
>> offset, len);
>> +
>> +??? if (n < 0)
>> +??????? return -errno;
>> +??? return n;
>> +}
>> +
>> ? int os_eventfd(unsigned int initval, int flags)
>> ? {
>> ????? int fd = eventfd(initval, flags);
>
>

-- 
Fr?d?ric Danis
Senior Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, United Kingdom
Registered in England & Wales, no. 5513718



From anton.ivanov at cambridgegreys.com  Wed Jan 26 01:47:05 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Wed, 26 Jan 2022 09:47:05 +0000
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
In-Reply-To: <6706ba52-04ed-718e-b0b7-1296f95783da@collabora.com>
References: <20220125171405.163362-1-frederic.danis@collabora.com>
 <8de3a6c3-b2fd-648e-ac5f-a27da2d326db@cambridgegreys.com>
 <6706ba52-04ed-718e-b0b7-1296f95783da@collabora.com>
Message-ID: <5582155e-32b8-4caf-8353-455c6893af91@cambridgegreys.com>



On 25/01/2022 18:50, Fr?d?ric Danis wrote:
> Hi Anton,
> 
> On 25/01/2022 18:56, Anton Ivanov wrote:
>> On 25/01/2022 17:14, Fr?d?ric Danis wrote:
>>> Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a sparse
>>> file can end up by missing data, zeroes data range, if the underlying file
>>> is used with a tool like bmaptool which will referenced only used spaces.
>>
>> Can you elaborate on when do you miss data.
>>
>> A file with a hole created using FALLOC_FL_PUNCH_HOLE when reading from the hole should return zeroes.
>>
>> If it returns anything else or if the zeroed range exceeds the one specified in falloc - that is an underlying fs bug.
> 
> I use bmaptool to create a block map of the used part of a raw system image file, then compress the file and at the end use again bmaptool to flash the file to a SDCard.
> 
> iiuc fallocate() call with FALLOC_FL_PUNCH_HOLE doesn't "register" the space, as it is zeroed, so when bmaptool creates the block map it doesn't reference the "used holes", and when I flash the SDCard those parts are missing, so the filesystem on the SDCard is corrupted.

I can see what you are doing and I will OK the patch.

However, I still do not understand why it does not work.

bmaptool creates a map of the used blocks.

When copying, it should create the "missing" as sparse, right?

A sparse "hole" when read should be always read as zero. If it is not being read as zero when compressing - bug. Ditto at the next stage when flashing.

IMHO there is an underlying bug outside UML here somewhere.

A

> 
>>
>>>
>>> Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
>>> ---
>>> ? arch/um/drivers/ubd_kern.c? | 8 +++++++-
>>> ? arch/um/include/shared/os.h | 1 +
>>> ? arch/um/os-Linux/file.c???? | 9 +++++++++
>>> ? 3 files changed, 17 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
>>> index 69d2d0049a61..b03269faef71 100644
>>> --- a/arch/um/drivers/ubd_kern.c
>>> +++ b/arch/um/drivers/ubd_kern.c
>>> @@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
>>> ????????????? }
>>> ????????????? break;
>>> ????????? case REQ_OP_DISCARD:
>>> -??????? case REQ_OP_WRITE_ZEROES:
>>> ????????????? n = os_falloc_punch(req->fds[bit], off, len);
>>> ????????????? if (n) {
>>> ????????????????? req->error = map_error(-n);
>>> ????????????????? return;
>>> ????????????? }
>>> ????????????? break;
>>> +??????? case REQ_OP_WRITE_ZEROES:
>>> +??????????? n = os_falloc_zeroes(req->fds[bit], off, len);
>>> +??????????? if (n) {
>>> +??????????????? req->error = map_error(-n);
>>> +??????????????? return;
>>> +??????????? }
>>> +??????????? break;
>>> ????????? default:
>>> ????????????? WARN_ON_ONCE(1);
>>> ????????????? req->error = BLK_STS_NOTSUPP;
>>> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
>>> index 00214059d9ec..fafde1d5416e 100644
>>> --- a/arch/um/include/shared/os.h
>>> +++ b/arch/um/include/shared/os.h
>>> @@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
>>> ? extern unsigned os_minor(unsigned long long dev);
>>> ? extern unsigned long long os_makedev(unsigned major, unsigned minor);
>>> ? extern int os_falloc_punch(int fd, unsigned long long offset, int count);
>>> +extern int os_falloc_zeroes(int fd, unsigned long long offset, int count);
>>> ? extern int os_eventfd(unsigned int initval, int flags);
>>> ? extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
>>> ??????????????? const int *fds, unsigned int fds_num);
>>> diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
>>> index e4421dbc4c36..fc4450db59bd 100644
>>> --- a/arch/um/os-Linux/file.c
>>> +++ b/arch/um/os-Linux/file.c
>>> @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long offset, int len)
>>> ????? return n;
>>> ? }
>>> ? +int os_falloc_zeroes(int fd, unsigned long long offset, int len)
>>> +{
>>> +??? int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len);
>>> +
>>> +??? if (n < 0)
>>> +??????? return -errno;
>>> +??? return n;
>>> +}
>>> +
>>> ? int os_eventfd(unsigned int initval, int flags)
>>> ? {
>>> ????? int fd = eventfd(initval, flags);
>>
>>
> 

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From anton.ivanov at cambridgegreys.com  Wed Jan 26 01:47:43 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Wed, 26 Jan 2022 09:47:43 +0000
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
In-Reply-To: <20220125171405.163362-1-frederic.danis@collabora.com>
References: <20220125171405.163362-1-frederic.danis@collabora.com>
Message-ID: <243f77b8-0c16-2069-5ac4-f3eb734db59a@cambridgegreys.com>



On 25/01/2022 17:14, Fr?d?ric Danis wrote:
> Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a sparse
> file can end up by missing data, zeroes data range, if the underlying file
> is used with a tool like bmaptool which will referenced only used spaces.
> 
> Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
> ---
>   arch/um/drivers/ubd_kern.c  | 8 +++++++-
>   arch/um/include/shared/os.h | 1 +
>   arch/um/os-Linux/file.c     | 9 +++++++++
>   3 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 69d2d0049a61..b03269faef71 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
>   			}
>   			break;
>   		case REQ_OP_DISCARD:
> -		case REQ_OP_WRITE_ZEROES:
>   			n = os_falloc_punch(req->fds[bit], off, len);
>   			if (n) {
>   				req->error = map_error(-n);
>   				return;
>   			}
>   			break;
> +		case REQ_OP_WRITE_ZEROES:
> +			n = os_falloc_zeroes(req->fds[bit], off, len);
> +			if (n) {
> +				req->error = map_error(-n);
> +				return;
> +			}
> +			break;
>   		default:
>   			WARN_ON_ONCE(1);
>   			req->error = BLK_STS_NOTSUPP;
> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
> index 00214059d9ec..fafde1d5416e 100644
> --- a/arch/um/include/shared/os.h
> +++ b/arch/um/include/shared/os.h
> @@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
>   extern unsigned os_minor(unsigned long long dev);
>   extern unsigned long long os_makedev(unsigned major, unsigned minor);
>   extern int os_falloc_punch(int fd, unsigned long long offset, int count);
> +extern int os_falloc_zeroes(int fd, unsigned long long offset, int count);
>   extern int os_eventfd(unsigned int initval, int flags);
>   extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
>   			  const int *fds, unsigned int fds_num);
> diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
> index e4421dbc4c36..fc4450db59bd 100644
> --- a/arch/um/os-Linux/file.c
> +++ b/arch/um/os-Linux/file.c
> @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long offset, int len)
>   	return n;
>   }
>   
> +int os_falloc_zeroes(int fd, unsigned long long offset, int len)
> +{
> +	int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len);
> +
> +	if (n < 0)
> +		return -errno;
> +	return n;
> +}
> +
>   int os_eventfd(unsigned int initval, int flags)
>   {
>   	int fd = eventfd(initval, flags);
> 

Acked-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


From frederic.danis at collabora.com  Wed Jan 26 02:02:51 2022
From: frederic.danis at collabora.com (=?UTF-8?Q?Fr=c3=a9d=c3=a9ric_Danis?=)
Date: Wed, 26 Jan 2022 11:02:51 +0100
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
In-Reply-To: <5582155e-32b8-4caf-8353-455c6893af91@cambridgegreys.com>
References: <20220125171405.163362-1-frederic.danis@collabora.com>
 <8de3a6c3-b2fd-648e-ac5f-a27da2d326db@cambridgegreys.com>
 <6706ba52-04ed-718e-b0b7-1296f95783da@collabora.com>
 <5582155e-32b8-4caf-8353-455c6893af91@cambridgegreys.com>
Message-ID: <c2081076-98f5-2cbf-2a39-70e930fe16bf@collabora.com>

Hi Anton,

On 26/01/2022 10:47, Anton Ivanov wrote:
>
>
> On 25/01/2022 18:50, Fr?d?ric Danis wrote:
>> Hi Anton,
>>
>> On 25/01/2022 18:56, Anton Ivanov wrote:
>>> On 25/01/2022 17:14, Fr?d?ric Danis wrote:
>>>> Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a 
>>>> sparse
>>>> file can end up by missing data, zeroes data range, if the 
>>>> underlying file
>>>> is used with a tool like bmaptool which will referenced only used 
>>>> spaces.
>>>
>>> Can you elaborate on when do you miss data.
>>>
>>> A file with a hole created using FALLOC_FL_PUNCH_HOLE when reading 
>>> from the hole should return zeroes.
>>>
>>> If it returns anything else or if the zeroed range exceeds the one 
>>> specified in falloc - that is an underlying fs bug.
>>
>> I use bmaptool to create a block map of the used part of a raw system 
>> image file, then compress the file and at the end use again bmaptool 
>> to flash the file to a SDCard.
>>
>> iiuc fallocate() call with FALLOC_FL_PUNCH_HOLE doesn't "register" 
>> the space, as it is zeroed, so when bmaptool creates the block map it 
>> doesn't reference the "used holes", and when I flash the SDCard those 
>> parts are missing, so the filesystem on the SDCard is corrupted.
>
> I can see what you are doing and I will OK the patch.
>
> However, I still do not understand why it does not work.
>
> bmaptool creates a map of the used blocks.
>
> When copying, it should create the "missing" as sparse, right?

It depends:
- if you're creating a file, in this case there's no problem as bmaptool 
will create holes which will be seen as zeroed spaces,
- or if you're flashing a device like a SDCard, in this case it only 
writes the referenced blocks and let untouched the other parts which are 
certainly not full of zeroes, this is why it needs that intentional 
zeroed parts are not just holes.

I'm not sure to be clear :(, bmaptool is better explained at 
https://github.com/intel/bmap-tools/

>
> A sparse "hole" when read should be always read as zero. If it is not 
> being read as zero when compressing - bug. Ditto at the next stage 
> when flashing.

Compression is optional, I have the same problem if I use bmaptool to 
flash the uncompressed file as it will copy to device only the 
referenced blocks in the block map.

>
> IMHO there is an underlying bug outside UML here somewhere.
>
> A

Regards,

Fred
>
>>
>>>
>>>>
>>>> Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
>>>> ---
>>>> ? arch/um/drivers/ubd_kern.c? | 8 +++++++-
>>>> ? arch/um/include/shared/os.h | 1 +
>>>> ? arch/um/os-Linux/file.c???? | 9 +++++++++
>>>> ? 3 files changed, 17 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
>>>> index 69d2d0049a61..b03269faef71 100644
>>>> --- a/arch/um/drivers/ubd_kern.c
>>>> +++ b/arch/um/drivers/ubd_kern.c
>>>> @@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req 
>>>> *req, struct io_desc *desc)
>>>> ????????????? }
>>>> ????????????? break;
>>>> ????????? case REQ_OP_DISCARD:
>>>> -??????? case REQ_OP_WRITE_ZEROES:
>>>> ????????????? n = os_falloc_punch(req->fds[bit], off, len);
>>>> ????????????? if (n) {
>>>> ????????????????? req->error = map_error(-n);
>>>> ????????????????? return;
>>>> ????????????? }
>>>> ????????????? break;
>>>> +??????? case REQ_OP_WRITE_ZEROES:
>>>> +??????????? n = os_falloc_zeroes(req->fds[bit], off, len);
>>>> +??????????? if (n) {
>>>> +??????????????? req->error = map_error(-n);
>>>> +??????????????? return;
>>>> +??????????? }
>>>> +??????????? break;
>>>> ????????? default:
>>>> ????????????? WARN_ON_ONCE(1);
>>>> ????????????? req->error = BLK_STS_NOTSUPP;
>>>> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
>>>> index 00214059d9ec..fafde1d5416e 100644
>>>> --- a/arch/um/include/shared/os.h
>>>> +++ b/arch/um/include/shared/os.h
>>>> @@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
>>>> ? extern unsigned os_minor(unsigned long long dev);
>>>> ? extern unsigned long long os_makedev(unsigned major, unsigned 
>>>> minor);
>>>> ? extern int os_falloc_punch(int fd, unsigned long long offset, int 
>>>> count);
>>>> +extern int os_falloc_zeroes(int fd, unsigned long long offset, int 
>>>> count);
>>>> ? extern int os_eventfd(unsigned int initval, int flags);
>>>> ? extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
>>>> ??????????????? const int *fds, unsigned int fds_num);
>>>> diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
>>>> index e4421dbc4c36..fc4450db59bd 100644
>>>> --- a/arch/um/os-Linux/file.c
>>>> +++ b/arch/um/os-Linux/file.c
>>>> @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long 
>>>> offset, int len)
>>>> ????? return n;
>>>> ? }
>>>> ? +int os_falloc_zeroes(int fd, unsigned long long offset, int len)
>>>> +{
>>>> +??? int n = fallocate(fd, 
>>>> FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len);
>>>> +
>>>> +??? if (n < 0)
>>>> +??????? return -errno;
>>>> +??? return n;
>>>> +}
>>>> +
>>>> ? int os_eventfd(unsigned int initval, int flags)
>>>> ? {
>>>> ????? int fd = eventfd(initval, flags);
>>>
>>>
>>
>

-- 
Fr?d?ric Danis
Senior Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, United Kingdom
Registered in England & Wales, no. 5513718



From anton.ivanov at cambridgegreys.com  Wed Jan 26 02:35:07 2022
From: anton.ivanov at cambridgegreys.com (Anton Ivanov)
Date: Wed, 26 Jan 2022 10:35:07 +0000
Subject: [PATCH] um: Fix WRITE_ZEROES in the UBD Driver
In-Reply-To: <c2081076-98f5-2cbf-2a39-70e930fe16bf@collabora.com>
References: <20220125171405.163362-1-frederic.danis@collabora.com>
 <8de3a6c3-b2fd-648e-ac5f-a27da2d326db@cambridgegreys.com>
 <6706ba52-04ed-718e-b0b7-1296f95783da@collabora.com>
 <5582155e-32b8-4caf-8353-455c6893af91@cambridgegreys.com>
 <c2081076-98f5-2cbf-2a39-70e930fe16bf@collabora.com>
Message-ID: <3ebb88d7-39ec-8dda-dbc6-acde88c7acad@cambridgegreys.com>


On 26/01/2022 10:02, Fr?d?ric Danis wrote:
> Hi Anton,
>
> On 26/01/2022 10:47, Anton Ivanov wrote:
>>
>>
>> On 25/01/2022 18:50, Fr?d?ric Danis wrote:
>>> Hi Anton,
>>>
>>> On 25/01/2022 18:56, Anton Ivanov wrote:
>>>> On 25/01/2022 17:14, Fr?d?ric Danis wrote:
>>>>> Call to fallocate with FALLOC_FL_PUNCH_HOLE on a device backed by a sparse
>>>>> file can end up by missing data, zeroes data range, if the underlying file
>>>>> is used with a tool like bmaptool which will referenced only used spaces.
>>>>
>>>> Can you elaborate on when do you miss data.
>>>>
>>>> A file with a hole created using FALLOC_FL_PUNCH_HOLE when reading from the hole should return zeroes.
>>>>
>>>> If it returns anything else or if the zeroed range exceeds the one specified in falloc - that is an underlying fs bug.
>>>
>>> I use bmaptool to create a block map of the used part of a raw system image file, then compress the file and at the end use again bmaptool to flash the file to a SDCard.
>>>
>>> iiuc fallocate() call with FALLOC_FL_PUNCH_HOLE doesn't "register" the space, as it is zeroed, so when bmaptool creates the block map it doesn't reference the "used holes", and when I flash the SDCard those parts are missing, so the filesystem on the SDCard is corrupted.
>>
>> I can see what you are doing and I will OK the patch.
>>
>> However, I still do not understand why it does not work.
>>
>> bmaptool creates a map of the used blocks.
>>
>> When copying, it should create the "missing" as sparse, right?
>
> It depends:
> - if you're creating a file, in this case there's no problem as bmaptool will create holes which will be seen as zeroed spaces,
> - or if you're flashing a device like a SDCard, in this case it only writes the referenced blocks and let untouched the other parts which are certainly not full of zeroes, this is why it needs that intentional zeroed parts are not just holes.

OK, I understood it now.

>
> I'm not sure to be clear :(, bmaptool is better explained at https://github.com/intel/bmap-tools/
>
>>
>> A sparse "hole" when read should be always read as zero. If it is not being read as zero when compressing - bug. Ditto at the next stage when flashing.
>
> Compression is optional, I have the same problem if I use bmaptool to flash the uncompressed file as it will copy to device only the referenced blocks in the block map.

OK, got it.

>
>>
>> IMHO there is an underlying bug outside UML here somewhere.
>>
>> A
>
> Regards,
>
> Fred
>>
>>>
>>>>
>>>>>
>>>>> Signed-off-by: Fr?d?ric Danis <frederic.danis at collabora.com>
>>>>> ---
>>>>> ? arch/um/drivers/ubd_kern.c? | 8 +++++++-
>>>>> ? arch/um/include/shared/os.h | 1 +
>>>>> ? arch/um/os-Linux/file.c???? | 9 +++++++++
>>>>> ? 3 files changed, 17 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
>>>>> index 69d2d0049a61..b03269faef71 100644
>>>>> --- a/arch/um/drivers/ubd_kern.c
>>>>> +++ b/arch/um/drivers/ubd_kern.c
>>>>> @@ -1526,13 +1526,19 @@ static void do_io(struct io_thread_req *req, struct io_desc *desc)
>>>>> ????????????? }
>>>>> ????????????? break;
>>>>> ????????? case REQ_OP_DISCARD:
>>>>> -??????? case REQ_OP_WRITE_ZEROES:
>>>>> ????????????? n = os_falloc_punch(req->fds[bit], off, len);
>>>>> ????????????? if (n) {
>>>>> ????????????????? req->error = map_error(-n);
>>>>> ????????????????? return;
>>>>> ????????????? }
>>>>> ????????????? break;
>>>>> +??????? case REQ_OP_WRITE_ZEROES:
>>>>> +??????????? n = os_falloc_zeroes(req->fds[bit], off, len);
>>>>> +??????????? if (n) {
>>>>> +??????????????? req->error = map_error(-n);
>>>>> +??????????????? return;
>>>>> +??????????? }
>>>>> +??????????? break;
>>>>> ????????? default:
>>>>> ????????????? WARN_ON_ONCE(1);
>>>>> ????????????? req->error = BLK_STS_NOTSUPP;
>>>>> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
>>>>> index 00214059d9ec..fafde1d5416e 100644
>>>>> --- a/arch/um/include/shared/os.h
>>>>> +++ b/arch/um/include/shared/os.h
>>>>> @@ -168,6 +168,7 @@ extern unsigned os_major(unsigned long long dev);
>>>>> ? extern unsigned os_minor(unsigned long long dev);
>>>>> ? extern unsigned long long os_makedev(unsigned major, unsigned minor);
>>>>> ? extern int os_falloc_punch(int fd, unsigned long long offset, int count);
>>>>> +extern int os_falloc_zeroes(int fd, unsigned long long offset, int count);
>>>>> ? extern int os_eventfd(unsigned int initval, int flags);
>>>>> ? extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len,
>>>>> ??????????????? const int *fds, unsigned int fds_num);
>>>>> diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
>>>>> index e4421dbc4c36..fc4450db59bd 100644
>>>>> --- a/arch/um/os-Linux/file.c
>>>>> +++ b/arch/um/os-Linux/file.c
>>>>> @@ -625,6 +625,15 @@ int os_falloc_punch(int fd, unsigned long long offset, int len)
>>>>> ????? return n;
>>>>> ? }
>>>>> ? +int os_falloc_zeroes(int fd, unsigned long long offset, int len)
>>>>> +{
>>>>> +??? int n = fallocate(fd, FALLOC_FL_ZERO_RANGE|FALLOC_FL_KEEP_SIZE, offset, len);
>>>>> +
>>>>> +??? if (n < 0)
>>>>> +??????? return -errno;
>>>>> +??? return n;
>>>>> +}
>>>>> +
>>>>> ? int os_eventfd(unsigned int initval, int flags)
>>>>> ? {
>>>>> ????? int fd = eventfd(initval, flags);
>>>>
>>>>
>>>
>>
>
-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/



From viro at zeniv.linux.org.uk  Sun Jan 30 18:29:06 2022
From: viro at zeniv.linux.org.uk (Al Viro)
Date: Mon, 31 Jan 2022 02:29:06 +0000
Subject: [tip:x86/core 1/1] arch/x86/um/../lib/csum-partial_64.c:98:12:
 error: implicit declaration of function 'load_unaligned_zeropad'
In-Reply-To: <Ycv5mF+gfGxlmmQL@zeniv-ca.linux.org.uk>
References: <202111180219.YkyoBMpf-lkp@intel.com>
 <CANn89iJfh+x-s4GtWJcyRFpMmSvvyq-r1TGV4sDLXy3F50zD6w@mail.gmail.com>
 <CANn89iJj4zeNUiXCmG=rSejbHAwPhBEPKUv1tPL9ig=e4vg7pQ@mail.gmail.com>
 <YZZ4upqWGMOY+r56@hirez.programming.kicks-ass.net>
 <Ycv5mF+gfGxlmmQL@zeniv-ca.linux.org.uk>
Message-ID: <YfdJcu1xE1kv55Up@zeniv-ca.linux.org.uk>

On Wed, Dec 29, 2021 at 06:00:56AM +0000, Al Viro wrote:
> On Thu, Nov 18, 2021 at 05:00:58PM +0100, Peter Zijlstra wrote:
> 
> > Dear um folks, is this indeed the best solution? It's a bit sad to have
> > to add this to x86_64, but if that's the way it is...
> 
> Something like this, perhaps? (absolutely untested)

[snip]
AFAICS, this (on top of current mainline) does the right thing.

commit 6692531df62d812de5d22c8bca0d90edc163aa84
Author: Al Viro <viro at zeniv.linux.org.uk>
Date:   Sun Jan 30 21:25:53 2022 -0500

    uml/x86: use x86 load_unaligned_zeropad()
    
    allows, among other things, to drop !DCACHE_WORD_ACCESS mess in
    x86 csum-partial_64.c
    
    Signed-off-by: Al Viro <viro at zeniv.linux.org.uk>

diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index e5a7b552bb384..a58b67ec8119d 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -23,7 +23,6 @@ generic-y += softirq_stack.h
 generic-y += switch_to.h
 generic-y += topology.h
 generic-y += trace_clock.h
-generic-y += word-at-a-time.h
 generic-y += kprobes.h
 generic-y += mm_hooks.h
 generic-y += vga.h
diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
index 1f8a8f8951738..50734a23034c4 100644
--- a/arch/x86/lib/csum-partial_64.c
+++ b/arch/x86/lib/csum-partial_64.c
@@ -93,7 +93,6 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 		buff += 8;
 	}
 	if (len & 7) {
-#ifdef CONFIG_DCACHE_WORD_ACCESS
 		unsigned int shift = (8 - (len & 7)) * 8;
 		unsigned long trail;
 
@@ -103,31 +102,6 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 		    "adcq $0,%[res]"
 			: [res] "+r" (temp64)
 			: [trail] "r" (trail));
-#else
-		if (len & 4) {
-			asm("addq %[val],%[res]\n\t"
-			    "adcq $0,%[res]"
-				: [res] "+r" (temp64)
-				: [val] "r" ((u64)*(u32 *)buff)
-				: "memory");
-			buff += 4;
-		}
-		if (len & 2) {
-			asm("addq %[val],%[res]\n\t"
-			    "adcq $0,%[res]"
-				: [res] "+r" (temp64)
-				: [val] "r" ((u64)*(u16 *)buff)
-				: "memory");
-			buff += 2;
-		}
-		if (len & 1) {
-			asm("addq %[val],%[res]\n\t"
-			    "adcq $0,%[res]"
-				: [res] "+r" (temp64)
-				: [val] "r" ((u64)*(u8 *)buff)
-				: "memory");
-		}
-#endif
 	}
 	result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
 	if (unlikely(odd)) {
diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index 40d6a06e41c81..4eb47d3ba6250 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -8,6 +8,7 @@ endmenu
 
 config UML_X86
 	def_bool y
+	select DCACHE_WORD_ACCESS
 
 config 64BIT
 	bool "64-bit kernel" if "$(SUBARCH)" = "x86"


From johannes at sipsolutions.net  Mon Jan 31 06:35:27 2022
From: johannes at sipsolutions.net (Johannes Berg)
Date: Mon, 31 Jan 2022 15:35:27 +0100
Subject: [PATCH] uml: net: vector: fix const issue
Message-ID: <20220131153527.3a3b22daa521.I68e88e5d49d37c0005e4fd5ef6a3c43be5876b91@changeid>

From: Johannes Berg <johannes.berg at intel.com>

Since the constification of MAC addresses, the argument
to uml_vector_default_bpf() must be const.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 arch/um/drivers/vector_user.c | 2 +-
 arch/um/drivers/vector_user.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
index e4ffeb9a1fa4..c650e428432b 100644
--- a/arch/um/drivers/vector_user.c
+++ b/arch/um/drivers/vector_user.c
@@ -771,7 +771,7 @@ int uml_vector_detach_bpf(int fd, void *bpf)
 		printk(KERN_ERR BPF_DETACH_FAIL, prog->len, prog->filter, fd, -errno);
 	return err;
 }
-void *uml_vector_default_bpf(void *mac)
+void *uml_vector_default_bpf(const void *mac)
 {
 	struct sock_filter *bpf;
 	uint32_t *mac1 = (uint32_t *)(mac + 2);
diff --git a/arch/um/drivers/vector_user.h b/arch/um/drivers/vector_user.h
index d29d5fdd98fa..3a73d17a0161 100644
--- a/arch/um/drivers/vector_user.h
+++ b/arch/um/drivers/vector_user.h
@@ -97,7 +97,7 @@ extern int uml_vector_recvmmsg(
 	unsigned int vlen,
 	unsigned int flags
 );
-extern void *uml_vector_default_bpf(void *mac);
+extern void *uml_vector_default_bpf(const void *mac);
 extern void *uml_vector_user_bpf(char *filename);
 extern int uml_vector_attach_bpf(int fd, void *bpf);
 extern int uml_vector_detach_bpf(int fd, void *bpf);
-- 
2.34.1



From anton.ivanov at kot-begemot.co.uk  Mon Jan 31 06:49:42 2022
From: anton.ivanov at kot-begemot.co.uk (Anton Ivanov)
Date: Mon, 31 Jan 2022 14:49:42 +0000
Subject: [PATCH] uml: net: vector: fix const issue
In-Reply-To: <20220131153527.3a3b22daa521.I68e88e5d49d37c0005e4fd5ef6a3c43be5876b91@changeid>
References: <20220131153527.3a3b22daa521.I68e88e5d49d37c0005e4fd5ef6a3c43be5876b91@changeid>
Message-ID: <1e2f80d8-3e8d-c367-4ee7-24f1d3874aaf@kot-begemot.co.uk>


On 31/01/2022 14:35, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
>
> Since the constification of MAC addresses, the argument
> to uml_vector_default_bpf() must be const.
>
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   arch/um/drivers/vector_user.c | 2 +-
>   arch/um/drivers/vector_user.h | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
> index e4ffeb9a1fa4..c650e428432b 100644
> --- a/arch/um/drivers/vector_user.c
> +++ b/arch/um/drivers/vector_user.c
> @@ -771,7 +771,7 @@ int uml_vector_detach_bpf(int fd, void *bpf)
>   		printk(KERN_ERR BPF_DETACH_FAIL, prog->len, prog->filter, fd, -errno);
>   	return err;
>   }
> -void *uml_vector_default_bpf(void *mac)
> +void *uml_vector_default_bpf(const void *mac)
>   {
>   	struct sock_filter *bpf;
>   	uint32_t *mac1 = (uint32_t *)(mac + 2);
> diff --git a/arch/um/drivers/vector_user.h b/arch/um/drivers/vector_user.h
> index d29d5fdd98fa..3a73d17a0161 100644
> --- a/arch/um/drivers/vector_user.h
> +++ b/arch/um/drivers/vector_user.h
> @@ -97,7 +97,7 @@ extern int uml_vector_recvmmsg(
>   	unsigned int vlen,
>   	unsigned int flags
>   );
> -extern void *uml_vector_default_bpf(void *mac);
> +extern void *uml_vector_default_bpf(const void *mac);
>   extern void *uml_vector_user_bpf(char *filename);
>   extern int uml_vector_attach_bpf(int fd, void *bpf);
>   extern int uml_vector_detach_bpf(int fd, void *bpf);

Acked-By: anton ivanov <anton.ivanov at cambridgegreys.com>
-- 
Anton R. Ivanov
https://www.kot-begemot.co.uk/



