NetBSD Problem Report #58106

From www@netbsd.org  Tue Apr  2 20:21:32 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E4A811A9239
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  2 Apr 2024 20:21:32 +0000 (UTC)
Message-Id: <20240402202131.4D44F1A923B@mollari.NetBSD.org>
Date: Tue,  2 Apr 2024 20:21:31 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: rump cpu_info doesn't work with cpu cache management function
X-Send-Pr-Version: www-1.0

>Number:         58106
>Category:       port-arm
>Synopsis:       rump cpu_info doesn't work with cpu cache management function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 02 20:25:00 +0000 2024
>Last-Modified:  Thu Apr 18 15:25:05 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetCPU Funcdation
>Environment:
>Description:
rump machine/cpu.h provides its own struct cpu_info, which has no ci_cpufuncs member.

Consequently, the kernel cpu cache management functions like cpu_icache_sync_range don't work:

In file included from ./arm/cpufunc.h:445,
                 from ./aarch64/sljit_machdep.h:37,
                 from ./machine/sljit_machdep.h:4,
                 from /home/riastradh/netbsd/10/src/sys/rump/kern/lib/libsljit/../../../../external/bsd/sljit/dist/sljit_src/sljitConfig.h:60,
                 from /home/riastradh/netbsd/10/src/sys/rump/kern/lib/libsljit/../../../../external/bsd/sljit/dist/sljit_src/sljitLir.h:76,
                 from /home/riastradh/netbsd/10/src/sys/rump/kern/lib/libsljit/../../../../external/bsd/sljit/dist/sljit_src/sljitLir.c:29:
/home/riastradh/netbsd/10/src/sys/rump/kern/lib/libsljit/../../../../external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c: In function 'sljit_generate_code':
./aarch64/cpufunc.h:105:10: error: 'struct cpu_info' has no member named 'ci_cpufuncs'
  105 |  curcpu()->ci_cpufuncs.cf_icache_sync_range((v),(s))
      |          ^~
./aarch64/sljit_machdep.h:48:2: note: in expansion of macro 'cpu_icache_sync_range'
   48 |  cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from)))
      |  ^~~~~~~~~~~~~~~~~~~~~

>How-To-Repeat:
Try to compile kernel code that uses cpu_icache_sync_range, like sljit, in rump.
>Fix:
Add ci_cpufuncs to rump's struct cpu_info with compatible definitions, maybe implemented in terms of __builtin___clear_cache.

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58106 CVS commit: src
Date: Tue, 2 Apr 2024 22:37:34 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Apr  2 22:37:34 UTC 2024

 Modified Files:
 	src/share/mk: bsd.own.mk
 	src/sys/arch/aarch64/include: sljit_machdep.h
 	src/sys/modules: Makefile

 Log Message:
 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


 To generate a diff of this commit:
 cvs rdiff -u -r1.1364 -r1.1365 src/share/mk/bsd.own.mk
 cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/include/sljit_machdep.h
 cvs rdiff -u -r1.284 -r1.285 src/sys/modules/Makefile

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58106 CVS commit: [netbsd-10] src
Date: Thu, 18 Apr 2024 15:21:56 +0000

 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.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58106 CVS commit: [netbsd-9] src
Date: Thu, 18 Apr 2024 15:24:21 +0000

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

 Modified Files:
 	src/share/mk [netbsd-9]: bsd.own.mk
 	src/sys/arch/aarch64/include [netbsd-9]: sljit_machdep.h
 	src/sys/external/bsd/sljit/dist/sljit_src [netbsd-9]:
 	    sljitNativeARM_64.c
 	src/sys/modules [netbsd-9]: 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
 	(all via patch)

 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.1149.2.6 -r1.1149.2.7 src/share/mk/bsd.own.mk
 cvs rdiff -u -r1.2 -r1.2.6.1 src/sys/arch/aarch64/include/sljit_machdep.h
 cvs rdiff -u -r1.4 -r1.4.4.1 \
     src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
 cvs rdiff -u -r1.222.2.1 -r1.222.2.2 src/sys/modules/Makefile

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

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.