Module Name:    src
Committed By:   martin
Date:           Thu Apr 18 15:21:55 UTC 2024

Modified Files:
        src/share/mk [netbsd-10]: bsd.own.mk
        src/sys/arch/aarch64/include [netbsd-10]: sljit_machdep.h
        src/sys/external/bsd/sljit/dist/sljit_src [netbsd-10]:
            sljitNativeARM_64.c
        src/sys/modules [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #655):

        sys/modules/Makefile: revision 1.285
        share/mk/bsd.own.mk: revision 1.1365
        share/mk/bsd.own.mk: revision 1.1366
        sys/arch/aarch64/include/sljit_machdep.h: revision 1.4
        sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c: revision 1.5

sljit: Pacify -Wsign-compare.

If these sizes are negative, we're probably in trouble anyway, so
assert nonnegative here.
Needed to resolve PR 58103.

bsd.own.mk: Enable MKLSJIT on aarch64.

Make sure there's only one copy of the conditional, in bsd.own.mk;
just make sys/modules/Makefile conditional on MKSLJIT so we don't
have to keep these in sync.

As a workaround for PR 58106, tweak the conditional definition of
SLJIT_CACHE_FLUSH to use cpu_icache_sync_range only in _HARDKERNEL,
and use __builtin___clear_cache in userland and in rump kernels.

PR 58103: bpfjit.kmod is not built on aarch64
bsd.own.mk: No need for MKSLJIT to be set differently from others.
- Use ?=, not =, so mk.conf setting wins.
- Write out per-architecture tabular settings, not a conditional.
- Add comments for the architectures that look like they should have
  sljit but don't.  (XXX Missing comments about powerpc and mips --
  not sure why, is this because modules don't yet work on those
  architectures, or what?)

Tidying for PR 58103: bpfjit.kmod is not built on aarch64.


To generate a diff of this commit:
cvs rdiff -u -r1.1289.2.2 -r1.1289.2.3 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.3 -r1.3.18.1 src/sys/arch/aarch64/include/sljit_machdep.h
cvs rdiff -u -r1.4 -r1.4.30.1 \
    src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
cvs rdiff -u -r1.274.2.2 -r1.274.2.3 src/sys/modules/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1289.2.2 src/share/mk/bsd.own.mk:1.1289.2.3
--- src/share/mk/bsd.own.mk:1.1289.2.2	Fri Oct 20 16:04:59 2023
+++ src/share/mk/bsd.own.mk	Thu Apr 18 15:21:55 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1289.2.2 2023/10/20 16:04:59 martin Exp $
+#	$NetBSD: bsd.own.mk,v 1.1289.2.3 2024/04/18 15:21:55 martin Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -1285,6 +1285,21 @@ MKLLVMRT.i386=		yes
 MKLLVMRT.aarch64=	yes
 .endif
 
+# Just-in-time compiler for bpf, npf acceleration
+MKSLJIT.aarch64=	yes
+MKSLJIT.i386=		yes
+MKSLJIT.sparc=		yes
+#MKSLJIT.sparc64=	yes	# not suppored in sljit (yet?)
+MKSLJIT.x86_64=		yes
+#MKSLJIT.powerpc=	yes	# XXX
+#MKSLJIT.powerpc64=	yes	# XXX
+#MKSLJIT.mipsel=	yes	# XXX
+#MKSLJIT.mipseb=	yes	# XXX
+#MKSLJIT.mips64el=	yes	# XXX
+#MKSLJIT.mips64eb=	yes	# XXX
+#MKSLJIT.riscv32=	yes	# not until we update sljit
+#MKSLJIT.riscv64=	yes	# not until we update sljit
+
 # compat with old names
 MKDEBUGKERNEL?=${MKKDEBUG:Uno}
 MKDEBUGTOOLS?=${MKTOOLSDEBUG:Uno}
@@ -1318,12 +1333,6 @@ _MKVARS.no= \
 ${var}?=	${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uno}}
 .endfor
 
-.if ${MACHINE_ARCH} == "i386" || \
-    ${MACHINE_ARCH} == "x86_64" || \
-    ${MACHINE_ARCH} == "sparc"
-MKSLJIT=	yes
-.endif
-
 #
 # Which platforms build the xorg-server drivers (as opposed
 # to just Xnest and Xvfb.)

Index: src/sys/arch/aarch64/include/sljit_machdep.h
diff -u src/sys/arch/aarch64/include/sljit_machdep.h:1.3 src/sys/arch/aarch64/include/sljit_machdep.h:1.3.18.1
--- src/sys/arch/aarch64/include/sljit_machdep.h:1.3	Fri Dec 11 18:03:33 2020
+++ src/sys/arch/aarch64/include/sljit_machdep.h	Thu Apr 18 15:21:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljit_machdep.h,v 1.3 2020/12/11 18:03:33 skrll Exp $	*/
+/*	$NetBSD: sljit_machdep.h,v 1.3.18.1 2024/04/18 15:21:55 martin Exp $	*/
 
 /*-
  * Copyright (c) 2014 Alexander Nasonov.
@@ -43,7 +43,12 @@
 
 #define SLJIT_CONFIG_ARM_64 1
 
-#ifdef _KERNEL
+#ifdef _HARDKERNEL
+/*
+ * XXX Currently sys/rump/include/machine/cpu.h doesn't have
+ * ci_cpufuncs for cpu_icache_sync_range, so we do this only for
+ * non-rump kernels for now.
+ */
 #define SLJIT_CACHE_FLUSH(from, to) \
 	cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from)))
 #else

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c:1.4 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c:1.4.30.1
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c:1.4	Sun Jan 20 23:14:16 2019
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c	Thu Apr 18 15:21:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitNativeARM_64.c,v 1.4 2019/01/20 23:14:16 alnsn Exp $	*/
+/*	$NetBSD: sljitNativeARM_64.c,v 1.4.30.1 2024/04/18 15:21:55 martin Exp $	*/
 
 /*
  *    Stack-less Just-In-Time compiler
@@ -1079,7 +1079,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 	local_size = (local_size + 15) & ~0xf;
 	compiler->local_size = local_size;
 
-	if (local_size <= (63 * sizeof(sljit_sw))) {
+	SLJIT_ASSERT(local_size >= 0);
+	if ((size_t)local_size <= (63 * sizeof(sljit_sw))) {
 		FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
 			| RN(TMP_SP) | ((-(local_size >> 3) & 0x7f) << 15)));
 		FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
@@ -1129,7 +1130,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 
 	SLJIT_ASSERT(prev == -1);
 
-	if (compiler->local_size > (63 * sizeof(sljit_sw))) {
+	SLJIT_ASSERT(compiler->local_size >= 0);
+	if ((size_t)compiler->local_size > (63 * sizeof(sljit_sw))) {
 		/* The local_size is already adjusted by the saved registers. */
 		if (local_size > 0xfff) {
 			FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
@@ -1179,7 +1181,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 	local_size = compiler->local_size;
 
 	saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0);
-	if (local_size <= (63 * sizeof(sljit_sw)))
+	SLJIT_ASSERT(local_size >= 0);
+	if ((size_t)local_size <= (63 * sizeof(sljit_sw)))
 		offs = (local_size - saved_regs_size) << (15 - 3);
 	else {
 		FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
@@ -1232,7 +1235,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit
 
 	SLJIT_ASSERT(prev == -1);
 
-	if (compiler->local_size <= (63 * sizeof(sljit_sw))) {
+	SLJIT_ASSERT(compiler->local_size >= 0);
+	if ((size_t)compiler->local_size <= (63 * sizeof(sljit_sw))) {
 		FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
 			| RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
 	} else if (saved_regs_size > 0) {

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.274.2.2 src/sys/modules/Makefile:1.274.2.3
--- src/sys/modules/Makefile:1.274.2.2	Sat Dec 30 19:13:50 2023
+++ src/sys/modules/Makefile	Thu Apr 18 15:21:55 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.274.2.2 2023/12/30 19:13:50 martin Exp $
+#	$NetBSD: Makefile,v 1.274.2.3 2024/04/18 15:21:55 martin Exp $
 
 .include <bsd.own.mk>
 
@@ -258,15 +258,9 @@ SUBDIR+=	ubsec
 .endif
 
 .if ${MKSLJIT} != "no"
-# No modules for 32-bit arm, mips and powerpc yet.
-.if ${MACHINE_ARCH} == "aarch64" || \
-    ${MACHINE_ARCH} == "i386"    || \
-    ${MACHINE_ARCH} == "sparc"   || \
-    ${MACHINE_ARCH} == "x86_64"
 SUBDIR+=	bpfjit
 SUBDIR+=	sljit
 .endif
-.endif
 
 #
 # ACPI modules

Reply via email to