All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue
@ 2021-05-12 10:05 Jan Kiszka
  2021-05-12 10:05 ` [PATCH 1/7] cobalt/memory: fix __vmalloc() calls Jan Kiszka
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

This prepares drivers for kernel 5.10 and removes the obsolete x32 ABI
as well as support for 32-bit x86 kernels.

After this, the dovetail queue should only contain directly
dovetail-related changes, nothing that could affect older kernels with
I-pipe.

Jan


CC: Philippe Gerum <rpm@xenomai.org>

Philippe Gerum (7):
  cobalt/memory: fix __vmalloc() calls
  drivers/net: checksum: convert to memcpy+csum
  drivers/net: cfg: fix config file load up
  drivers/testing: headcheck: remove variable-length array
  testsuite/smokey: trace test startup with verbose=2
  cobalt/x86: remove support for the x32 ABI
  cobalt/x86: remove kernel support for x86_32

 .../x86/include/asm/xenomai/uapi/syscall.h    |  8 +-
 .../x86/ipipe/include/asm/xenomai/machine.h   |  4 -
 .../x86/ipipe/include/asm/xenomai/syscall.h   |  4 +-
 .../include/asm/xenomai/syscall32-table.h     | 16 ----
 .../x86/ipipe/include/asm/xenomai/syscall32.h | 90 +-----------------
 kernel/cobalt/arch/x86/ipipe/thread.c         | 91 +------------------
 .../include/asm-generic/xenomai/wrappers.h    | 21 +++++
 kernel/cobalt/posix/syscall.c                 | 44 +++++----
 kernel/cobalt/posix/syscall32.c               | 26 ------
 kernel/cobalt/posix/syscall32.h               |  6 --
 kernel/cobalt/trace/cobalt-posix.h            |  7 --
 .../net/stack/include/rtnet_checksum.h        | 19 ++++
 kernel/drivers/net/stack/ipv4/icmp.c          | 19 ++--
 kernel/drivers/net/stack/ipv4/tcp/tcp.c       |  7 +-
 kernel/drivers/net/stack/ipv4/udp/udp.c       | 10 +-
 kernel/drivers/net/stack/rtcfg/rtcfg_ioctl.c  | 74 +++++++--------
 kernel/drivers/net/stack/rtskb.c              |  5 +-
 kernel/drivers/testing/heapcheck.c            | 18 ++--
 testsuite/smokey/main.c                       |  1 +
 19 files changed, 134 insertions(+), 336 deletions(-)
 create mode 100644 kernel/drivers/net/stack/include/rtnet_checksum.h

-- 
2.26.2



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] cobalt/memory: fix __vmalloc() calls
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  2021-05-12 10:05 ` [PATCH 2/7] drivers/net: checksum: convert to memcpy+csum Jan Kiszka
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Since kernel v5.8, __vmalloc() does not take protection bits as
PROT_KERNEL is now wired in. Therefore we cannot disable the cache for
the UMM segment via the allocation call directly anymore.

This said, we don't support any CPU architecture exhibiting cache
aliasing braindamage anymore either (was armv4/v5), so let's convert
to the new __vmalloc() call format without bothering for cache
settings.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/cobalt/include/asm-generic/xenomai/wrappers.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 930e6364e5..652a04759f 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -210,4 +210,10 @@ devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
 #define old_timeval32     compat_timeval
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0)
+#define vmalloc_kernel(__size, __flags)	__vmalloc(__size, GFP_KERNEL|__flags, PAGE_KERNEL)
+#else
+#define vmalloc_kernel(__size, __flags)	__vmalloc(__size, GFP_KERNEL|__flags)
+#endif
+
 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/7] drivers/net: checksum: convert to memcpy+csum
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
  2021-05-12 10:05 ` [PATCH 1/7] cobalt/memory: fix __vmalloc() calls Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  2021-05-12 10:05 ` [PATCH 3/7] drivers/net: cfg: fix config file load up Jan Kiszka
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Since v5.9-rc1, csum_partial_copy_nocheck() forces a zero seed as its
last argument to csum_partial(). According to #cc44c17baf7f3, passing
a non-zero value would not even yield the proper result on some
architectures. However, other locations still expect a non-zero csum
seed to be used in the next computation.

Meanwhile, some benchmarking (*) revealed that folding copy and
checksum operations may not be as optimal as one would have thought
when the caches are under pressure, so we switch to a split version,
first memcpy() then csum_partial(), so as to always benefit from
memcpy() optimizations. As a bonus, we don't have to wrap calls to
csum_partial_copy_nocheck() to follow the kernel API change. Instead
we can provide a single implementation based on csum_partial() which
works with any kernel version.

(*) Below are benchmark figures of the csum_copy (folded) vs csum+copy
(split) performances in idle vs busy scenarios. Busy means
hackbench+dd loop streaming 128M in the background from zero -> null,
in order to badly trash the D-caches while the test runs. Three
different packet sizes are submitted to checksumming (32, 1024, 1500
bytes), all figures in nanosecs.

iMX6QP (Cortex A9)
------------------

=== idle

CSUM_COPY 32b: min=333, max=1333, avg=439
CSUM_COPY 1024b: min=1000, max=2000, avg=1045
CSUM_COPY 1500b: min=1333, max=2000, avg=1333
COPY+CSUM 32b: min=333, max=1333, avg=443
COPY+CSUM 1024b: min=1000, max=2334, avg=1345
COPY+CSUM 1500b: min=1666, max=2667, avg=1737

=== busy

CSUM_COPY 32b: min=333, max=4333, avg=466
CSUM_COPY 1024b: min=1000, max=5000, avg=1088
CSUM_COPY 1500b: min=1333, max=5667, avg=1393
COPY+CSUM 32b: min=333, max=1334, avg=454
COPY+CSUM 1024b: min=1000, max=2000, avg=1341
COPY+CSUM 1500b: min=1666, max=2666, avg=1745

C4 (Cortex A55)
---------------

=== idle

CSUM_COPY 32b: min=125, max=791, avg=130
CSUM_COPY 1024b: min=541, max=834, avg=550
CSUM_COPY 1500b: min=708, max=1875, avg=740
COPY+CSUM 32b: min=125, max=167, avg=133
COPY+CSUM 1024b: min=541, max=625, avg=553
COPY+CSUM 1500b: min=708, max=750, avg=730

=== busy

CSUM_COPY 32b: min=125, max=792, avg=133
CSUM_COPY 1024b: min=500, max=2000, avg=552
CSUM_COPY 1500b: min=708, max=1542, avg=744
COPY+CSUM 32b: min=125, max=375, avg=133
COPY+CSUM 1024b: min=500, max=709, avg=553
COPY+CSUM 1500b: min=708, max=916, avg=743

x86 (atom x5)
-------------

=== idle

CSUM_COPY 32b: min=67, max=590, avg=70
CSUM_COPY 1024b: min=245, max=385, avg=251
CSUM_COPY 1500b: min=343, max=521, avg=350
COPY+CSUM 32b: min=101, max=679, avg=117
COPY+CSUM 1024b: min=296, max=379, avg=298
COPY+CSUM 1500b: min=399, max=502, avg=404

== busy

CSUM_COPY 32b: min=65, max=709, avg=71
CSUM_COPY 1024b: min=243, max=702, avg=252
CSUM_COPY 1500b: min=340, max=1055, avg=351
COPY+CSUM 32b: min=100, max=665, avg=120
COPY+CSUM 1024b: min=295, max=669, avg=298
COPY+CSUM 1500b: min=399, max=686, avg=403

arm64 which has no folded csum_copy implementation makes the best of
using the split copy+csum path. All architectures seem to benefit from
optimized memcpy under load when it comes to the worst case execution
time. x86 is less prone to jittery under cache trashing than others as
usual, but even there, the max. figures for csum+copy in busy context
look pretty much on par with the csum_copy version. Therefore,
converting all users to csum+copy makes sense.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../net/stack/include/rtnet_checksum.h        | 19 +++++++++++++++++++
 kernel/drivers/net/stack/ipv4/icmp.c          | 19 ++++++++++---------
 kernel/drivers/net/stack/ipv4/tcp/tcp.c       |  7 ++++---
 kernel/drivers/net/stack/ipv4/udp/udp.c       | 10 +++++-----
 kernel/drivers/net/stack/rtskb.c              |  5 ++---
 5 files changed, 40 insertions(+), 20 deletions(-)
 create mode 100644 kernel/drivers/net/stack/include/rtnet_checksum.h

diff --git a/kernel/drivers/net/stack/include/rtnet_checksum.h b/kernel/drivers/net/stack/include/rtnet_checksum.h
new file mode 100644
index 0000000000..7c18413a8e
--- /dev/null
+++ b/kernel/drivers/net/stack/include/rtnet_checksum.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef __RTNET_CHECKSUM_H_
+#define __RTNET_CHECKSUM_H_
+
+#include <linux/string.h>
+#include <net/checksum.h>
+
+#define rtnet_csum(__buf, __len, __csum)				\
+	({								\
+		csum_partial(__buf, __len, (__force __wsum)__csum);	\
+	})
+
+#define rtnet_csum_copy(__src, __dst, __len, __csum)			\
+	({								\
+		memcpy(__dst, __src, __len);				\
+		csum_partial(__dst, __len, (__force __wsum)__csum);	\
+	})
+
+#endif /* !__RTNET_CHECKSUM_H_ */
diff --git a/kernel/drivers/net/stack/ipv4/icmp.c b/kernel/drivers/net/stack/ipv4/icmp.c
index 7f2248515f..8485614eca 100644
--- a/kernel/drivers/net/stack/ipv4/icmp.c
+++ b/kernel/drivers/net/stack/ipv4/icmp.c
@@ -33,6 +33,7 @@
 
 #include <rtskb.h>
 #include <rtnet_socket.h>
+#include <rtnet_checksum.h>
 #include <ipv4_chrdev.h>
 #include <ipv4/icmp.h>
 #include <ipv4/ip_fragment.h>
@@ -142,9 +143,9 @@ static int rt_icmp_glue_reply_bits(const void *p, unsigned char *to,
 	if (offset != 0)
 		return -EMSGSIZE;
 
-	csum = csum_partial_copy_nocheck((void *)&icmp_param->head, to,
-					 icmp_param->head_len,
-					 icmp_param->csum);
+	csum = rtnet_csum_copy((void *)&icmp_param->head, to,
+			       icmp_param->head_len,
+			       icmp_param->csum);
 
 	csum = rtskb_copy_and_csum_bits(icmp_param->data.skb,
 					icmp_param->offset,
@@ -259,13 +260,13 @@ static int rt_icmp_glue_request_bits(const void *p, unsigned char *to,
 			    __FUNCTION__);
 		return -1;);
 
-	csum = csum_partial_copy_nocheck((void *)&icmp_param->head, to,
-					 icmp_param->head_len,
-					 icmp_param->csum);
+	csum = rtnet_csum_copy((void *)&icmp_param->head, to,
+			       icmp_param->head_len,
+			       icmp_param->csum);
 
-	csum = csum_partial_copy_nocheck(icmp_param->data.buf,
-					 to + icmp_param->head_len,
-					 fraglen - icmp_param->head_len, csum);
+	csum = rtnet_csum_copy(icmp_param->data.buf,
+			       to + icmp_param->head_len,
+			       fraglen - icmp_param->head_len, csum);
 
 	icmph = (struct icmphdr *)to;
 
diff --git a/kernel/drivers/net/stack/ipv4/tcp/tcp.c b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
index 08753e48ab..71628ba039 100644
--- a/kernel/drivers/net/stack/ipv4/tcp/tcp.c
+++ b/kernel/drivers/net/stack/ipv4/tcp/tcp.c
@@ -34,6 +34,7 @@
 #include <rtskb.h>
 #include <rtdev.h>
 #include <rtnet_port.h>
+#include <rtnet_checksum.h>
 #include <ipv4/tcp.h>
 #include <ipv4/ip_sock.h>
 #include <ipv4/ip_output.h>
@@ -637,10 +638,10 @@ static void rt_tcp_build_header(struct tcp_socket *ts, struct rtskb *skb,
 	th->urg_ptr = 0;
 
 	/* compute checksum */
-	wcheck = csum_partial(th, tcphdrlen, 0);
+	wcheck = rtnet_csum(th, tcphdrlen, 0);
 
 	if (skb->len - tcphdrlen - iphdrlen) {
-		wcheck = csum_partial(skb->data + tcphdrlen + iphdrlen,
+		wcheck = rtnet_csum(skb->data + tcphdrlen + iphdrlen,
 				      skb->len - tcphdrlen - iphdrlen, wcheck);
 	}
 
@@ -831,7 +832,7 @@ static struct rtsocket *rt_tcp_dest_socket(struct rtskb *skb)
 	u32 data_len;
 
 	if (tcp_v4_check(skb->len, saddr, daddr,
-			 csum_partial(skb->data, skb->len, 0))) {
+			 rtnet_csum(skb->data, skb->len, 0))) {
 		rtdm_printk("rttcp: invalid TCP packet checksum, dropped\n");
 		return NULL; /* Invalid checksum, drop the packet */
 	}
diff --git a/kernel/drivers/net/stack/ipv4/udp/udp.c b/kernel/drivers/net/stack/ipv4/udp/udp.c
index 56cc35c7e4..6fe1aeb12e 100644
--- a/kernel/drivers/net/stack/ipv4/udp/udp.c
+++ b/kernel/drivers/net/stack/ipv4/udp/udp.c
@@ -29,11 +29,11 @@
 #include <linux/err.h>
 #include <linux/udp.h>
 #include <linux/tcp.h>
-#include <net/checksum.h>
 #include <linux/list.h>
 
 #include <rtskb.h>
 #include <rtnet_internal.h>
+#include <rtnet_checksum.h>
 #include <rtnet_port.h>
 #include <rtnet_iovec.h>
 #include <rtnet_socket.h>
@@ -548,12 +548,12 @@ static int rt_udp_getfrag(const void *p, unsigned char *to, unsigned int offset,
 
 	/* Checksum of the complete data part of the UDP message: */
 	ufh->wcheck =
-		csum_partial(to + sizeof(struct udphdr),
-			     fraglen - sizeof(struct udphdr), ufh->wcheck);
+		rtnet_csum(to + sizeof(struct udphdr),
+			   fraglen - sizeof(struct udphdr), ufh->wcheck);
 
 	/* Checksum of the udp header: */
-	ufh->wcheck = csum_partial((unsigned char *)ufh, sizeof(struct udphdr),
-				   ufh->wcheck);
+	ufh->wcheck = rtnet_csum((unsigned char *)ufh, sizeof(struct udphdr),
+				 ufh->wcheck);
 
 	ufh->uh.check =
 		csum_tcpudp_magic(ufh->saddr, ufh->daddr, ntohs(ufh->uh.len),
diff --git a/kernel/drivers/net/stack/rtskb.c b/kernel/drivers/net/stack/rtskb.c
index 84d021d245..c9042db93c 100644
--- a/kernel/drivers/net/stack/rtskb.c
+++ b/kernel/drivers/net/stack/rtskb.c
@@ -23,7 +23,7 @@
 
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
-#include <net/checksum.h>
+#include <rtnet_checksum.h>
 
 #include <rtdev.h>
 #include <rtnet_internal.h>
@@ -69,8 +69,7 @@ unsigned int rtskb_copy_and_csum_bits(const struct rtskb *skb, int offset,
 	if ((copy = skb->len - offset) > 0) {
 		if (copy > len)
 			copy = len;
-		csum = csum_partial_copy_nocheck(skb->data + offset, to, copy,
-						 csum);
+		csum = rtnet_csum_copy(skb->data + offset, to, copy, csum);
 		if ((len -= copy) == 0)
 			return csum;
 		offset += copy;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/7] drivers/net: cfg: fix config file load up
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
  2021-05-12 10:05 ` [PATCH 1/7] cobalt/memory: fix __vmalloc() calls Jan Kiszka
  2021-05-12 10:05 ` [PATCH 2/7] drivers/net: checksum: convert to memcpy+csum Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  2021-05-12 10:05 ` [PATCH 4/7] drivers/testing: headcheck: remove variable-length array Jan Kiszka
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

set_fs() is on its way out, so we cannot open code a file read
operation by calling the VFS handler directly anymore, faking a user
address space.

We do have kernel interfaces for loading files though, particularly
kernel_read_file(). So let's use that one for loading the
configuration file contents. Unfortunately, the signature of this
service changed during the 5.9-rc cycle, so we have to resort to an
ugly wrapper to cope with all supported kernels once again. Sigh.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../include/asm-generic/xenomai/wrappers.h    | 15 ++++
 kernel/drivers/net/stack/rtcfg/rtcfg_ioctl.c  | 74 +++++++++----------
 2 files changed, 52 insertions(+), 37 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 652a04759f..54fdc8b05e 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -216,4 +216,19 @@ devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
 #define vmalloc_kernel(__size, __flags)	__vmalloc(__size, GFP_KERNEL|__flags)
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0)
+#define read_file_from_kernel(__file, __buf, __buf_size, __file_size, __id) \
+	({								\
+		loff_t ___file_size;					\
+		int __ret;						\
+		__ret = kernel_read_file(__file, __buf, &___file_size,	\
+				__buf_size, __id);			\
+		(*__file_size) = ___file_size;				\
+		__ret;							\
+	})
+#else
+#define read_file_from_kernel(__file, __buf, __buf_size, __file_size, __id) \
+	kernel_read_file(__file, 0, __buf, __buf_size, __file_size, __id)
+#endif
+
 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */
diff --git a/kernel/drivers/net/stack/rtcfg/rtcfg_ioctl.c b/kernel/drivers/net/stack/rtcfg/rtcfg_ioctl.c
index 769b4e143c..158d7118f2 100644
--- a/kernel/drivers/net/stack/rtcfg/rtcfg_ioctl.c
+++ b/kernel/drivers/net/stack/rtcfg/rtcfg_ioctl.c
@@ -22,6 +22,7 @@
  *
  */
 
+#include <linux/fs.h>
 #include <linux/file.h>
 #include <linux/vmalloc.h>
 
@@ -196,6 +197,40 @@ void cleanup_cmd_detach(void *priv_data)
 		kfree_rtskb(cmd->args.detach.stage2_chain);
 }
 
+static int load_cfg_file(struct rtcfg_file *cfgfile, struct rtcfg_cmd *cmd)
+{
+	size_t file_size = 0;
+	struct file *filp;
+	loff_t i_size;
+	int ret;
+
+	filp = filp_open(cfgfile->name, O_RDONLY, 0);
+	if (IS_ERR(filp))
+		return PTR_ERR(filp);
+
+	i_size = i_size_read(file_inode(filp));
+	if (i_size <= 0) {
+		/* allocate buffer even for empty files */
+		cfgfile->buffer = vmalloc(1);
+	} else {
+		cfgfile->buffer = NULL; /* Leave allocation to the kernel. */
+		ret = read_file_from_kernel(filp, &cfgfile->buffer,
+					i_size_read(file_inode(filp)),
+					&file_size, READING_UNKNOWN);
+		if (ret < 0) {
+			fput(filp);
+			return ret;
+		}
+	}
+
+	fput(filp);
+	cfgfile->size = file_size;
+
+	/* dispatch again, this time with new file attached */
+	return rtpc_dispatch_call(rtcfg_event_handler, 0, cmd,
+				sizeof(*cmd), NULL, cleanup_cmd_add);
+}
+
 int rtcfg_ioctl_add(struct rtnet_device *rtdev, struct rtcfg_cmd *cmd)
 {
 	struct rtcfg_connection *conn_buf;
@@ -264,46 +299,11 @@ int rtcfg_ioctl_add(struct rtnet_device *rtdev, struct rtcfg_cmd *cmd)
 
 	/* load file if missing */
 	if (ret > 0) {
-		struct file *filp;
-		mm_segment_t oldfs;
-
-		filp = filp_open(file->name, O_RDONLY, 0);
-		if (IS_ERR(filp)) {
+		ret = load_cfg_file(file, cmd);
+		if (ret) {
 			rtcfg_unlockwr_proc(cmd->internal.data.ifindex);
-			ret = PTR_ERR(filp);
 			goto err;
 		}
-
-		file->size = filp->f_path.dentry->d_inode->i_size;
-
-		/* allocate buffer even for empty files */
-		file->buffer = vmalloc((file->size) ? file->size : 1);
-		if (file->buffer == NULL) {
-			rtcfg_unlockwr_proc(cmd->internal.data.ifindex);
-			fput(filp);
-			ret = -ENOMEM;
-			goto err;
-		}
-
-		oldfs = get_fs();
-		set_fs(KERNEL_DS);
-		filp->f_pos = 0;
-
-		ret = filp->f_op->read(filp, file->buffer, file->size,
-				       &filp->f_pos);
-
-		set_fs(oldfs);
-		fput(filp);
-
-		if (ret != (int)file->size) {
-			rtcfg_unlockwr_proc(cmd->internal.data.ifindex);
-			ret = -EIO;
-			goto err;
-		}
-
-		/* dispatch again, this time with new file attached */
-		ret = rtpc_dispatch_call(rtcfg_event_handler, 0, cmd,
-					 sizeof(*cmd), NULL, cleanup_cmd_add);
 	}
 
 	return ret;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/7] drivers/testing: headcheck: remove variable-length array
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
                   ` (2 preceding siblings ...)
  2021-05-12 10:05 ` [PATCH 3/7] drivers/net: cfg: fix config file load up Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  2021-05-12 10:05 ` [PATCH 5/7] testsuite/smokey: trace test startup with verbose=2 Jan Kiszka
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/drivers/testing/heapcheck.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/kernel/drivers/testing/heapcheck.c b/kernel/drivers/testing/heapcheck.c
index 023a06ca64..207f20921f 100644
--- a/kernel/drivers/testing/heapcheck.c
+++ b/kernel/drivers/testing/heapcheck.c
@@ -59,19 +59,19 @@ static inline void breathe(int loops)
 		rtdm_task_sleep(300000ULL);
 }
 
-static inline void do_swap(void *left, void *right, const size_t size)
+static inline void do_swap(void *left, void *right)
 {
-	char trans[size];
+	char trans[sizeof(struct chunk)];
 
-	memcpy(trans, left, size);
-	memcpy(left, right, size);
-	memcpy(right, trans, size);
+	memcpy(trans, left, sizeof(struct chunk));
+	memcpy(left, right, sizeof(struct chunk));
+	memcpy(right, trans, sizeof(struct chunk));
 }
 
-static void random_shuffle(void *vbase, size_t nmemb, const size_t size)
+static void random_shuffle(void *vbase, size_t nmemb)
 {
 	struct {
-		char x[size];
+		char x[sizeof(struct chunk)];
 	} __attribute__((packed)) *base = vbase;
 	unsigned int j, k;
 
@@ -79,7 +79,7 @@ static void random_shuffle(void *vbase, size_t nmemb, const size_t size)
 		k = (unsigned int)(prandom_u32() % nmemb) + 1;
 		if (j == k)
 			continue;
-		do_swap(&base[j - 1], &base[k - 1], size);
+		do_swap(&base[j - 1], &base[k - 1]);
 	}
 }
 
@@ -259,7 +259,7 @@ static int test_seq(size_t heap_size, size_t block_size, int flags)
 	}
 	
 	if (flags & RTTST_HEAPCHECK_SHUFFLE)
-		random_shuffle(chunks, nrblocks, sizeof(*chunks));
+		random_shuffle(chunks, nrblocks);
 
 	/*
 	 * Release all blocks.
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/7] testsuite/smokey: trace test startup with verbose=2
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
                   ` (3 preceding siblings ...)
  2021-05-12 10:05 ` [PATCH 4/7] drivers/testing: headcheck: remove variable-length array Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  2021-05-12 10:05 ` [PATCH 6/7] cobalt/x86: remove support for the x32 ABI Jan Kiszka
  2021-05-12 10:05 ` [PATCH 7/7] cobalt/x86: remove kernel support for x86_32 Jan Kiszka
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 testsuite/smokey/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testsuite/smokey/main.c b/testsuite/smokey/main.c
index 5702e825a0..f24c1e990b 100644
--- a/testsuite/smokey/main.c
+++ b/testsuite/smokey/main.c
@@ -31,6 +31,7 @@ int main(int argc, char *const argv[])
 
 	for_each_smokey_test(t) {
 		pthread_setschedparam(pthread_self(), SCHED_OTHER, &param);
+		smokey_trace("\n===  running %s ===\n", t->name);
 		ret = t->run(t, argc, argv);
 		if (ret) {
 			if (ret == -ENOSYS) {
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/7] cobalt/x86: remove support for the x32 ABI
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
                   ` (4 preceding siblings ...)
  2021-05-12 10:05 ` [PATCH 5/7] testsuite/smokey: trace test startup with verbose=2 Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  2021-05-12 10:05 ` [PATCH 7/7] cobalt/x86: remove kernel support for x86_32 Jan Kiszka
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

After raising the topic of (dis)continuing support for the x32 ABI
multiple times on the mailing list, it turned out that Xenomai has no
known users of this dying ABI. So let's remove it.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../x86/include/asm/xenomai/uapi/syscall.h    |  8 +-
 .../x86/ipipe/include/asm/xenomai/syscall.h   |  4 +-
 .../include/asm/xenomai/syscall32-table.h     | 16 ----
 .../x86/ipipe/include/asm/xenomai/syscall32.h | 90 +------------------
 kernel/cobalt/posix/syscall.c                 | 44 +++++----
 kernel/cobalt/posix/syscall32.c               | 26 ------
 kernel/cobalt/posix/syscall32.h               |  6 --
 kernel/cobalt/trace/cobalt-posix.h            |  7 --
 8 files changed, 25 insertions(+), 176 deletions(-)

diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/syscall.h b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/syscall.h
index aa9936dfd1..500d169368 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/syscall.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/syscall.h
@@ -18,12 +18,6 @@
 #ifndef _COBALT_X86_ASM_UAPI_SYSCALL_H
 #define _COBALT_X86_ASM_UAPI_SYSCALL_H
 
-#ifdef __ILP32__
-#define __xn_syscall_base  __COBALT_X32_BASE
-#else
-#define __xn_syscall_base  0
-#endif
-
-#define __xn_syscode(__nr)	(__COBALT_SYSCALL_BIT | (__nr + __xn_syscall_base))
+#define __xn_syscode(__nr)	(__COBALT_SYSCALL_BIT | __nr)
 
 #endif /* !_COBALT_X86_ASM_UAPI_SYSCALL_H */
diff --git a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall.h b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall.h
index ea0e6fcb16..f3f1b476f7 100644
--- a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall.h
@@ -25,9 +25,7 @@
 
 /*
  * Cobalt and Linux syscall numbers can be fetched from ORIG_AX,
- * masking out the __COBALT_SYSCALL_BIT marker. Make sure to offset
- * the number by __COBALT_X32_BASE for Cobalt 32-bit compat syscalls
- * only.
+ * masking out the __COBALT_SYSCALL_BIT marker.
  */
 #define __xn_reg_sys(regs)    ((regs)->orig_ax)
 #define __xn_reg_rval(regs)   ((regs)->ax)
diff --git a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32-table.h b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32-table.h
index 4784377b06..fb55d8863a 100644
--- a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32-table.h
+++ b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32-table.h
@@ -29,7 +29,6 @@ __COBALT_CALL32emu_THUNK(thread_setschedparam_ex)
 __COBALT_CALL32emu_THUNK(thread_getschedparam_ex)
 __COBALT_CALL32emu_THUNK(thread_setschedprio)
 __COBALT_CALL32emu_THUNK(sem_open)
-__COBALT_CALL32x_THUNK(sem_open)
 __COBALT_CALL32emu_THUNK(sem_timedwait)
 __COBALT_CALL32emu_THUNK(clock_getres)
 __COBALT_CALL32emu_THUNK(clock_gettime)
@@ -38,46 +37,31 @@ __COBALT_CALL32emu_THUNK(clock_nanosleep)
 __COBALT_CALL32emu_THUNK(mutex_timedlock)
 __COBALT_CALL32emu_THUNK(cond_wait_prologue)
 __COBALT_CALL32emu_THUNK(mq_open)
-__COBALT_CALL32x_THUNK(mq_open)
 __COBALT_CALL32emu_THUNK(mq_getattr)
-__COBALT_CALL32x_THUNK(mq_getattr)
 __COBALT_CALL32emu_THUNK(mq_timedsend)
 __COBALT_CALL32emu_THUNK(mq_timedreceive)
-__COBALT_CALL32x_pure_THUNK(mq_timedreceive)
 __COBALT_CALL32emu_THUNK(mq_notify)
-__COBALT_CALL32x_THUNK(mq_notify)
 __COBALT_CALL32emu_THUNK(sched_weightprio)
 __COBALT_CALL32emu_THUNK(sched_setconfig_np)
 __COBALT_CALL32emu_THUNK(sched_getconfig_np)
 __COBALT_CALL32emu_THUNK(sched_setscheduler_ex)
 __COBALT_CALL32emu_THUNK(sched_getscheduler_ex)
 __COBALT_CALL32emu_THUNK(timer_create)
-__COBALT_CALL32x_THUNK(timer_create)
 __COBALT_CALL32emu_THUNK(timer_settime)
 __COBALT_CALL32emu_THUNK(timer_gettime)
 __COBALT_CALL32emu_THUNK(timerfd_settime)
 __COBALT_CALL32emu_THUNK(timerfd_gettime)
 __COBALT_CALL32emu_THUNK(sigwait)
-__COBALT_CALL32x_THUNK(sigwait)
 __COBALT_CALL32emu_THUNK(sigtimedwait)
-__COBALT_CALL32x_THUNK(sigtimedwait)
 __COBALT_CALL32emu_THUNK(sigwaitinfo)
-__COBALT_CALL32x_THUNK(sigwaitinfo)
 __COBALT_CALL32emu_THUNK(sigpending)
-__COBALT_CALL32x_THUNK(sigpending)
 __COBALT_CALL32emu_THUNK(sigqueue)
-__COBALT_CALL32x_THUNK(sigqueue)
 __COBALT_CALL32emu_THUNK(monitor_wait)
 __COBALT_CALL32emu_THUNK(event_wait)
 __COBALT_CALL32emu_THUNK(select)
-__COBALT_CALL32x_THUNK(select)
 __COBALT_CALL32emu_THUNK(recvmsg)
-__COBALT_CALL32x_THUNK(recvmsg)
 __COBALT_CALL32emu_THUNK(sendmsg)
-__COBALT_CALL32x_THUNK(sendmsg)
 __COBALT_CALL32emu_THUNK(mmap)
-__COBALT_CALL32x_THUNK(mmap)
 __COBALT_CALL32emu_THUNK(backtrace)
-__COBALT_CALL32x_THUNK(backtrace)
 
 #endif /* !_COBALT_X86_ASM_SYSCALL32_TABLE_H */
diff --git a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32.h b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32.h
index 35a7b0d101..a0395e1872 100644
--- a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32.h
+++ b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/syscall32.h
@@ -21,76 +21,6 @@
 
 #include <asm/unistd.h>
 
-#ifdef CONFIG_X86_X32
-
-#define __COBALT_X32_BASE		128
-
-#define __COBALT_SYSNR32x(__reg)			\
-	({						\
-		long __nr = __reg;			\
-		if (__nr & __X32_SYSCALL_BIT) {		\
-			__nr &= ~__X32_SYSCALL_BIT;	\
-			__nr += __COBALT_X32_BASE;	\
-		}					\
-		__nr;					\
-	})
-
-#define __COBALT_COMPAT32x(__reg)			\
-	(((__reg) & __X32_SYSCALL_BIT) ? __COBALT_COMPATX_BIT : 0)
-
-#if __NR_COBALT_SYSCALLS > __COBALT_X32_BASE
-#error "__NR_COBALT_SYSCALLS > __COBALT_X32_BASE"
-#endif
-
-#define __syshand32x__(__name)	((cobalt_syshand)(CoBaLt32x_ ## __name))
-
-#define __COBALT_CALL32x_INITHAND(__handler)	\
-	[__COBALT_X32_BASE ... __COBALT_X32_BASE + __NR_COBALT_SYSCALLS-1] = __handler,
-
-#define __COBALT_CALL32x_INITMODE(__mode)	\
-	[__COBALT_X32_BASE ... __COBALT_X32_BASE + __NR_COBALT_SYSCALLS-1] = __mode,
-
-/* x32 default entry (no thunk) */
-#define __COBALT_CALL32x_ENTRY(__name, __handler)		\
-	[sc_cobalt_ ## __name + __COBALT_X32_BASE] = __handler,
-
-/* x32 thunk installation */
-#define __COBALT_CALL32x_pure_THUNK(__name)	\
-	__COBALT_CALL32x_ENTRY(__name, __syshand32x__(__name))
-
-#define __COBALT_CALL32x_THUNK(__name)	\
-	__COBALT_CALL32x_ENTRY(__name, __syshand32emu__(__name))
-
-/* x32 thunk implementation. */
-#define COBALT_SYSCALL32x(__name, __mode, __args)	\
-	long CoBaLt32x_ ## __name __args
-
-/* x32 thunk declaration. */
-#define COBALT_SYSCALL32x_DECL(__name, __args)	\
-	long CoBaLt32x_ ## __name __args
-
-#else /* !CONFIG_X86_X32 */
-
-/* x32 support disabled. */
-
-#define __COBALT_SYSNR32x(__reg)	(__reg)
-
-#define __COBALT_COMPAT32x(__reg)	0
-
-#define __COBALT_CALL32x_INITHAND(__handler)
-
-#define __COBALT_CALL32x_INITMODE(__mode)
-
-#define __COBALT_CALL32x_ENTRY(__name, __handler)
-
-#define __COBALT_CALL32x_pure_THUNK(__name)
-
-#define __COBALT_CALL32x_THUNK(__name)
-
-#define COBALT_SYSCALL32x_DECL(__name, __args)
-
-#endif /* !CONFIG_X86_X32 */
-
 #ifdef CONFIG_IA32_EMULATION
 
 #define __COBALT_IA32_BASE		256 /* Power of two. */
@@ -155,33 +85,17 @@
 #endif /* !CONFIG_IA32_EMULATION */
 
 #define __COBALT_CALL32_ENTRY(__name, __handler)	\
-	__COBALT_CALL32x_ENTRY(__name, __handler)	\
 	__COBALT_CALL32emu_ENTRY(__name, __handler)
 
 #define __COBALT_CALL32_INITHAND(__handler)	\
-  	__COBALT_CALL32x_INITHAND(__handler)	\
 	__COBALT_CALL32emu_INITHAND(__handler)
 
 #define __COBALT_CALL32_INITMODE(__mode)	\
-  	__COBALT_CALL32x_INITMODE(__mode)	\
 	__COBALT_CALL32emu_INITMODE(__mode)
 
 /* Already checked for __COBALT_SYSCALL_BIT */
-#define __COBALT_CALL32_SYSNR(__reg)				\
-	({							\
-		long __nr;					\
-		__nr = __COBALT_SYSNR32x(__reg);		\
-		if (__nr == (__reg))				\
-			__nr = __COBALT_SYSNR32emu(__reg);	\
-		__nr;						\
-	})
+#define __COBALT_CALL32_SYSNR(__reg)	__COBALT_SYSNR32emu(__reg)
 
-#define __COBALT_CALL_COMPAT(__reg)				\
-	({							\
-		int __ret = __COBALT_COMPAT32x(__reg);		\
-		if (__ret == 0)					\
-			__ret = __COBALT_COMPAT32emu(__reg);	\
-		__ret;						\
-	})
+#define __COBALT_CALL_COMPAT(__reg)	__COBALT_COMPAT32emu(__reg)
 
 #endif /* !_COBALT_X86_ASM_SYSCALL32_H */
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index b9f33953a9..c6fe737e63 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -363,49 +363,47 @@ static int CoBaLt_ni(void)
 
 /*
  * We have a single syscall table for all ABI models, i.e. 64bit
- * native + 32bit) or plain 32bit. In the former case, we may want to
- * support several models with a single build (e.g. ia32 and x32 for
- * x86_64).
+ * native + 32bit emulation) or plain 32bit.
  *
  * The syscall table is set up in a single step, based on three
  * subsequent sources of initializers:
  *
  * - first, all syscall entries are defaulted to a placeholder
- * returning -ENOSYS, as the table may be sparse.
+ * returning -ENOSYS (__COBALT_CALL_NI), as the table may be sparse.
  *
  * - then __COBALT_CALL_ENTRY() produces a native call entry
- * (e.g. pure 64bit call handler for a 64bit architecture), optionally
- * followed by a set of 32bit syscall entries offset by an
- * arch-specific base index, which default to the native calls. These
- * nitty-gritty details are defined by
- * <asm/xenomai/syscall32.h>. 32bit architectures - or 64bit ones for
- * which we don't support any 32bit ABI model - will simply define
+ * (e.g. pure 64bit call handler for a 64bit architecture, 32bit
+ * handler for a 32bit architecture), optionally followed by a set of
+ * 32bit syscall entries offset by an arch-specific base index, which
+ * default to the native calls. These nitty-gritty details are defined
+ * by <asm/xenomai/syscall32.h>. 32bit architectures - or 64bit ones
+ * for which we don't support any 32bit ABI model - will simply define
  * __COBALT_CALL32_ENTRY() as an empty macro.
  *
- * - finally, 32bit thunk entries are generated per-architecture, by
- * including <asm/xenomai/syscall32-table.h>, overriding the default
- * handlers installed during the previous step.
+ * - finally, 32bit thunk entries are generated by including
+ * <asm/xenomai/syscall32-table.h>, overriding the default handlers
+ * installed during the previous step.
  *
- * For instance, with CONFIG_X86_X32 support enabled in an x86_64
- * kernel, sc_cobalt_mq_timedreceive would appear twice in the table,
- * as:
+ * For instance, with CONFIG_IA32_EMULATION support enabled in an
+ * x86_64 kernel, sc_cobalt_mq_timedreceive would appear twice in the
+ * table, as:
  *
- * [sc_cobalt_mq_timedreceive] = cobalt_mq_timedreceive,
+ * [sc_cobalt_mq_timedreceive] = CoBaLt_mq_timedreceive,
  * ...
- * [sc_cobalt_mq_timedreceive + __COBALT_X32_BASE] = cobalt32x_mq_timedreceive,
+ * [sc_cobalt_mq_timedreceive + __COBALT_IA32_BASE] = CoBaLt32emu_mq_timedreceive,
  *
- * cobalt32x_mq_timedreceive() would do the required thunking for
+ * CoBaLt32emu_mq_timedreceive() would do the required thunking for
  * dealing with the 32<->64bit conversion of arguments. On the other
  * hand, sc_cobalt_sched_yield - which do not require any thunk -
  * would also appear twice, but both entries would point at the native
  * syscall implementation:
  *
- * [sc_cobalt_sched_yield] = cobalt_sched_yield,
+ * [sc_cobalt_sched_yield] = CoBaLt_sched_yield,
  * ...
- * [sc_cobalt_sched_yield + __COBALT_X32_BASE] = cobalt_sched_yield,
+ * [sc_cobalt_sched_yield + __COBALT_IA32_BASE] = CoBaLt_sched_yield,
  *
- * Accordingly, applications targeting the x32 model (-mx32) issue
- * syscalls in the range [__COBALT_X32_BASE..__COBALT_X32_BASE +
+ * Accordingly, applications targeting the ia32 model issue syscalls
+ * in the range [__COBALT_IA32_BASE..__COBALT_IA32_BASE +
  * __NR_COBALT_SYSCALLS-1], whilst native (32/64bit) ones issue
  * syscalls in the range [0..__NR_COBALT_SYSCALLS-1].
  *
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index a5dc6e48f9..8bc74e9974 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -928,29 +928,3 @@ COBALT_SYSCALL32emu(backtrace, current,
 
 	return 0;
 }
-
-#ifdef COBALT_SYSCALL32x
-
-COBALT_SYSCALL32x(mq_timedreceive, primary,
-		  (mqd_t uqd, void __user *u_buf,
-		   compat_ssize_t __user *u_len,
-		   unsigned int __user *u_prio,
-		   const struct __user_old_timespec __user *u_ts))
-{
-	compat_ssize_t clen;
-	ssize_t len;
-	int ret;
-
-	ret = cobalt_copy_from_user(&clen, u_len, sizeof(*u_len));
-	if (ret)
-		return ret;
-
-	len = clen;
-	ret = __cobalt_mq_timedreceive(uqd, u_buf, &len, u_prio,
-				       u_ts, u_ts ? mq_fetch_timeout : NULL);
-	clen = len;
-
-	return ret ?: cobalt_copy_to_user(u_len, &clen, sizeof(*u_len));
-}
-
-#endif /* COBALT_SYSCALL32x */
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index bb62875ad0..d380c2d8e3 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -101,12 +101,6 @@ COBALT_SYSCALL32emu_DECL(mq_timedreceive,
 			  unsigned int __user *u_prio,
 			  const struct old_timespec32 __user *u_ts));
 
-COBALT_SYSCALL32x_DECL(mq_timedreceive,
-		       (mqd_t uqd, void __user *u_buf,
-			compat_ssize_t __user *u_len,
-			unsigned int __user *u_prio,
-			const struct __user_old_timespec __user *u_ts));
-
 COBALT_SYSCALL32emu_DECL(mq_notify,
 			 (mqd_t fd, const struct compat_sigevent *__user u_cev));
 
diff --git a/kernel/cobalt/trace/cobalt-posix.h b/kernel/cobalt/trace/cobalt-posix.h
index cff1bd9b71..a3713e9c9d 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -42,12 +42,6 @@
 #define __timespec_args(__name)					\
 	(long long)__entry->tv_sec_##__name, __entry->tv_nsec_##__name
 
-#ifdef CONFIG_X86_X32
-#define __sc_x32(__name)	, { sc_cobalt_##__name + __COBALT_X32_BASE, "x32-" #__name }
-#else
-#define __sc_x32(__name)
-#endif
-
 #ifdef CONFIG_IA32_EMULATION
 #define __sc_compat(__name)	, { sc_cobalt_##__name + __COBALT_IA32_BASE, "compat-" #__name }
 #else
@@ -56,7 +50,6 @@
 
 #define __cobalt_symbolic_syscall(__name)				\
 	{ sc_cobalt_##__name, #__name }					\
-	__sc_x32(__name)						\
 	__sc_compat(__name)						\
 
 #define __cobalt_syscall_name(__nr)					\
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 7/7] cobalt/x86: remove kernel support for x86_32
  2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
                   ` (5 preceding siblings ...)
  2021-05-12 10:05 ` [PATCH 6/7] cobalt/x86: remove support for the x32 ABI Jan Kiszka
@ 2021-05-12 10:05 ` Jan Kiszka
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-05-12 10:05 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

The legacy x86_32 architecture is on its way out, with no support from
Dovetail. Besides, it went untested with I-pipe configurations for
many moons.

We still keep 32bit compat mode available for building the user-space
libraries and executables though, along with IA32_EMULATION support in
kernel space to cope with legacy applications.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../x86/ipipe/include/asm/xenomai/machine.h   |  4 -
 kernel/cobalt/arch/x86/ipipe/thread.c         | 91 +------------------
 2 files changed, 1 insertion(+), 94 deletions(-)

diff --git a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/machine.h b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/machine.h
index bb5ccc1178..aad700fb67 100644
--- a/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/x86/ipipe/include/asm/xenomai/machine.h
@@ -23,11 +23,7 @@
 
 static inline __attribute_const__ unsigned long ffnz(unsigned long ul)
 {
-#ifdef __i386__
-	__asm__("bsfl %1, %0":"=r,r" (ul) : "r,?m" (ul));
-#else
 	__asm__("bsfq %1, %0":"=r" (ul) : "rm" (ul));
-#endif
 	return ul;
 }
 
diff --git a/kernel/cobalt/arch/x86/ipipe/thread.c b/kernel/cobalt/arch/x86/ipipe/thread.c
index f1f81b7503..dd97a5d32c 100644
--- a/kernel/cobalt/arch/x86/ipipe/thread.c
+++ b/kernel/cobalt/arch/x86/ipipe/thread.c
@@ -82,66 +82,6 @@ static inline void x86_fpregs_activate(struct task_struct *t)
  * This is obsolete context switch code uselessly duplicating
  * mainline's.
  */
-#ifdef CONFIG_X86_32
-
-#ifdef CONFIG_CC_STACKPROTECTOR
-
-#define __CANARY_OUTPUT							\
-	, [stack_canary] "=m" (stack_canary.canary)
-
-#define __CANARY_INPUT							\
-	, [task_canary] "i" (offsetof(struct task_struct, stack_canary))
-
-#define __CANARY_SWITCH							\
-	"movl %P[task_canary](%%edx), %%ebx\n\t"			\
-	"movl %%ebx, "__percpu_arg([stack_canary])"\n\t"
-
-#else /* !CONFIG_CC_STACKPROTECTOR */
-
-#define __CANARY_OUTPUT
-#define __CANARY_INPUT
-#define __CANARY_SWITCH
-
-#endif /* !CONFIG_CC_STACKPROTECTOR */
-
-static inline void do_switch_threads(struct xnarchtcb *out_tcb,
-				     struct xnarchtcb *in_tcb,
-				     struct task_struct *outproc,
-				     struct task_struct *inproc)
-{
-	long ebx_out, ecx_out, edi_out, esi_out;
-
-	__asm__ __volatile__("pushfl\n\t"
-			     "pushl %%ebp\n\t"
-			     "movl %[spp_out_ptr],%%ecx\n\t"
-			     "movl %%esp,(%%ecx)\n\t"
-			     "movl %[ipp_out_ptr],%%ecx\n\t"
-			     "movl $1f,(%%ecx)\n\t"
-			     "movl %[spp_in_ptr],%%ecx\n\t"
-			     "movl %[ipp_in_ptr],%%edi\n\t"
-			     "movl (%%ecx),%%esp\n\t"
-			     "pushl (%%edi)\n\t"
-			     __CANARY_SWITCH
-			     "jmp  __switch_to\n\t"
-			     "1: popl %%ebp\n\t"
-			     "popfl\n\t"
-			     : "=b"(ebx_out),
-			       "=&c"(ecx_out),
-			       "=S"(esi_out),
-			       "=D"(edi_out),
-			       "+a"(outproc),
-			       "+d"(inproc)
-			       __CANARY_OUTPUT
-			     : [spp_out_ptr] "m"(out_tcb->spp),
-			       [ipp_out_ptr] "m"(out_tcb->ipp),
-			       [spp_in_ptr] "m"(in_tcb->spp),
-			       [ipp_in_ptr] "m"(in_tcb->ipp)
-			       __CANARY_INPUT
-			     : "memory");
-}
-
-#else /* CONFIG_X86_64 */
-
 #define __SWITCH_CLOBBER_LIST  , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
 
 #ifdef CONFIG_CC_STACKPROTECTOR
@@ -192,8 +132,6 @@ static inline void do_switch_threads(struct xnarchtcb *out_tcb,
 			     : "memory", "cc" __SWITCH_CLOBBER_LIST);	\
 	})
 
-#endif /* CONFIG_X86_64 */
-
 #else /* LINUX_VERSION_CODE >= 4.8 */
 
 #include <asm/switch_to.h>
@@ -260,13 +198,9 @@ void xnarch_switch_to(struct xnthread *out, struct xnthread *in)
 	}
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
-#ifdef CONFIG_X86_32
-	do_switch_threads(out_tcb, in_tcb, prev, next);
-#else /* CONFIG_X86_64 */
 	do_switch_threads(prev, next,
 			  out_tcb->spp, in_tcb->spp,
 			  out_tcb->ipp, in_tcb->ipp);
-#endif /* CONFIG_X86_64 */
 	(void)last;
 #else /* LINUX_VERSION_CODE >= 4.8 */
 	switch_to(prev, next, last);
@@ -302,13 +236,8 @@ void xnarch_switch_to(struct xnthread *out, struct xnthread *in)
 
 #ifndef IPIPE_X86_FPU_EAGER
 
-#ifdef CONFIG_X86_64
 #define XSAVE_PREFIX	"0x48,"
 #define XSAVE_SUFFIX	"q"
-#else
-#define XSAVE_PREFIX
-#define XSAVE_SUFFIX
-#endif
 
 static inline void __do_save_fpu_state(x86_fpustate *fpup)
 {
@@ -327,12 +256,6 @@ static inline void __do_save_fpu_state(x86_fpustate *fpup)
 		return;
 	}
 #endif /* cpu_has_xsave */
-#ifdef CONFIG_X86_32
-	if (cpu_has_fxsr)
-		__asm__ __volatile__("fxsave %0; fnclex":"=m"(*fpup));
-	else
-		__asm__ __volatile__("fnsave %0; fwait":"=m"(*fpup));
-#else /* CONFIG_X86_64 */
 #ifdef CONFIG_AS_FXSAVEQ
 	__asm __volatile__("fxsaveq %0" : "=m" (fpup->fxsave));
 #else /* !CONFIG_AS_FXSAVEQ */
@@ -340,7 +263,6 @@ static inline void __do_save_fpu_state(x86_fpustate *fpup)
 		     : "=m" (fpup->fxsave)
 		     : [fx] "R" (&fpup->fxsave));
 #endif /* !CONFIG_AS_FXSAVEQ */
-#endif /* CONFIG_X86_64 */
 }
 
 static inline void __do_restore_fpu_state(x86_fpustate *fpup)
@@ -360,19 +282,12 @@ static inline void __do_restore_fpu_state(x86_fpustate *fpup)
 		return;
 	}
 #endif /* cpu_has_xsave */
-#ifdef CONFIG_X86_32
-	if (cpu_has_fxsr)
-		__asm__ __volatile__("fxrstor %0": /* no output */ :"m"(*fpup));
-	else
-		__asm__ __volatile__("frstor %0": /* no output */ :"m"(*fpup));
-#else /* CONFIG_X86_64 */
 #ifdef CONFIG_AS_FXSAVEQ
 	__asm__ __volatile__("fxrstorq %0" : : "m" (fpup->fxsave));
 #else /* !CONFIG_AS_FXSAVEQ */
 	__asm__ __volatile__("rex64/fxrstor (%0)"
 		     : : "R" (&fpup->fxsave), "m" (fpup->fxsave));
 #endif /* !CONFIG_AS_FXSAVEQ */
-#endif /* CONFIG_X86_64 */
 }
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
@@ -434,7 +349,7 @@ void xnarch_leave_root(struct xnthread *root)
 	struct task_struct *const p = current;
 	x86_fpustate *const current_task_fpup = x86_fpustate_ptr(&p->thread);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) && defined(CONFIG_X86_64)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
 	rootcb->spp = &p->thread.sp;
 	rootcb->ipp = &p->thread.rip;
 #endif
@@ -564,12 +479,8 @@ void xnarch_init_shadow_tcb(struct xnthread *thread)
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
 	tcb->sp = 0;
 	tcb->spp = &p->thread.sp;
-#ifdef CONFIG_X86_32
-	tcb->ipp = &p->thread.ip;
-#else
 	tcb->ipp = &p->thread.rip; /* <!> raw naming intended. */
 #endif
-#endif
 #ifndef IPIPE_X86_FPU_EAGER
 	tcb->fpup = x86_fpustate_ptr(&p->thread);
 	tcb->kfpu_state = NULL;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-12 10:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 10:05 [PATCH 0/7] Assorted improvements and 5.10-preparations from dovetail queue Jan Kiszka
2021-05-12 10:05 ` [PATCH 1/7] cobalt/memory: fix __vmalloc() calls Jan Kiszka
2021-05-12 10:05 ` [PATCH 2/7] drivers/net: checksum: convert to memcpy+csum Jan Kiszka
2021-05-12 10:05 ` [PATCH 3/7] drivers/net: cfg: fix config file load up Jan Kiszka
2021-05-12 10:05 ` [PATCH 4/7] drivers/testing: headcheck: remove variable-length array Jan Kiszka
2021-05-12 10:05 ` [PATCH 5/7] testsuite/smokey: trace test startup with verbose=2 Jan Kiszka
2021-05-12 10:05 ` [PATCH 6/7] cobalt/x86: remove support for the x32 ABI Jan Kiszka
2021-05-12 10:05 ` [PATCH 7/7] cobalt/x86: remove kernel support for x86_32 Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.