From owner-svn-src-stable@freebsd.org Sun Aug 11 22:47:00 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 949C5C4EC6; Sun, 11 Aug 2019 22:47:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 466Dch47pDz4VYK; Sun, 11 Aug 2019 22:47:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A88E1D3F2; Sun, 11 Aug 2019 22:47:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7BMl0OC039476; Sun, 11 Aug 2019 22:47:00 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7BMkwIU039466; Sun, 11 Aug 2019 22:46:58 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201908112246.x7BMkwIU039466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 11 Aug 2019 22:46:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350877 - in stable/12: lib/libc/arm lib/libc/arm/gen sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/12: lib/libc/arm lib/libc/arm/gen sys/sys X-SVN-Commit-Revision: 350877 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Aug 2019 22:47:00 -0000 Author: ian Date: Sun Aug 11 22:46:58 2019 New Revision: 350877 URL: https://svnweb.freebsd.org/changeset/base/350877 Log: MFC r349891, r349972 r349891: Reorganize the SRCS lists as one file per line, and then alphabetize them. No functional changes. r349972: Add arm_sync_icache() and arm_drain_writebuf() sysarch syscall wrappers. NetBSD and OpenBSD have libc wrapper functions for the ARM_SYNC_ICACHE and ARM_DRAIN_WRITEBUF sysarch operations. This change adds compatible functions to our library. This should make it easier for various upstream sources to support *BSD operating systems with a single variation of cache maintence code in tools like interpreters and JIT compilers. I consider the argument types passed to arm_sync_icache() to be especially unfortunate, but this is intended to match the other BSDs. Differential Revision: https://reviews.freebsd.org/D20906 Added: stable/12/lib/libc/arm/gen/arm_drain_writebuf.2 - copied unchanged from r349972, head/lib/libc/arm/gen/arm_drain_writebuf.2 stable/12/lib/libc/arm/gen/arm_drain_writebuf.c - copied unchanged from r349972, head/lib/libc/arm/gen/arm_drain_writebuf.c stable/12/lib/libc/arm/gen/arm_sync_icache.2 - copied unchanged from r349972, head/lib/libc/arm/gen/arm_sync_icache.2 stable/12/lib/libc/arm/gen/arm_sync_icache.c - copied unchanged from r349972, head/lib/libc/arm/gen/arm_sync_icache.c Modified: stable/12/lib/libc/arm/Symbol.map stable/12/lib/libc/arm/gen/Makefile.inc stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/arm/Symbol.map ============================================================================== --- stable/12/lib/libc/arm/Symbol.map Sun Aug 11 22:32:52 2019 (r350876) +++ stable/12/lib/libc/arm/Symbol.map Sun Aug 11 22:46:58 2019 (r350877) @@ -41,6 +41,11 @@ FBSD_1.4 { dl_unwind_find_exidx; }; +FBSD_1.6 { + arm_drain_writebuf; + arm_sync_icache; +}; + FBSDprivate_1.0 { /* PSEUDO syscalls */ __sys_getlogin; Modified: stable/12/lib/libc/arm/gen/Makefile.inc ============================================================================== --- stable/12/lib/libc/arm/gen/Makefile.inc Sun Aug 11 22:32:52 2019 (r350876) +++ stable/12/lib/libc/arm/gen/Makefile.inc Sun Aug 11 22:46:58 2019 (r350877) @@ -1,13 +1,37 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # $FreeBSD$ -SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \ - infinity.c ldexp.c makecontext.c \ - __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \ +SRCS+= \ + __aeabi_read_tp.S \ + _ctx_start.S \ + _set_tp.c \ + _setjmp.S \ + alloca.S \ arm_initfini.c \ - getcontextx.c + arm_drain_writebuf.c \ + arm_sync_icache.c \ + fabs.c \ + flt_rounds.c \ + getcontextx.c \ + infinity.c \ + ldexp.c \ + makecontext.c \ + setjmp.S \ + signalcontext.c \ + sigsetjmp.S \ +MAN+= \ + arm_drain_writebuf.2 \ + arm_sync_icache.2 \ + .if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") -SRCS+= fpgetmask_vfp.c fpgetround_vfp.c fpgetsticky_vfp.c fpsetmask_vfp.c \ - fpsetround_vfp.c fpsetsticky_vfp.c + +SRCS+= \ + fpgetmask_vfp.c \ + fpgetround_vfp.c \ + fpgetsticky_vfp.c \ + fpsetmask_vfp.c \ + fpsetround_vfp.c \ + fpsetsticky_vfp.c \ + .endif Copied: stable/12/lib/libc/arm/gen/arm_drain_writebuf.2 (from r349972, head/lib/libc/arm/gen/arm_drain_writebuf.2) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/lib/libc/arm/gen/arm_drain_writebuf.2 Sun Aug 11 22:46:58 2019 (r350877, copy of r349972, head/lib/libc/arm/gen/arm_drain_writebuf.2) @@ -0,0 +1,77 @@ +.\" Copyright (c) 2019 Ian Lepore +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd July 10, 2019 +.Dt ARM_DRAIN_WRITEBUF 2 +.Os +.Sh NAME +.Nm arm_drain_writebuf +.Nd drain pending writes from cores and caches +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In machine/sysarch.h +.Ft int +.Fn arm_drain_writebuf void +.Sh DESCRIPTION +The +.Nm +system call causes all pending writes from ARM cores and caches to be +written out to main memory or memory-mapped I/O registers. +Not all hardware supports buffered writes; on such systems the +.Nm +function is a no-op. +.Pp +On ARMv5 systems, this executes a cp15 coprocessor +.Dq drain write buffer +operation. +On ARMv6 and ARMv7 systems, this executes a +.Dq DSB SY +synchronization barrier, followed by an L2 cache drain on +systems where the DSB does not include L2 automatically. +.Pp +.Nm +attempts to wait for the drain operation to complete, but cannot +guarantee the writes have reached their ultimate destination on all hardware. +For example, on an ARMv7 system, +.Nm +tells the L2 cache controller to drain its buffers, and it waits until +the controller indicates that operation is complete. +However, all the L2 controller knows is that the data was accepted for +delivery by the AXI bus. +If the ultimate destination of the write is a device on a subordinate +bus connected to the AXI bus, more buffering or other delays may occur +on that subordinate bus. +The only way to be certain a pending write has reached its +ultimate destination is to issue a read from that destination after +.Nm +returns. +.Sh RETURN VALUES +The +.Nm +system call cannot fail, and always returns 0. +.Sh AUTHORS +This man page was written by +.An Ian Lepore . Copied: stable/12/lib/libc/arm/gen/arm_drain_writebuf.c (from r349972, head/lib/libc/arm/gen/arm_drain_writebuf.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/lib/libc/arm/gen/arm_drain_writebuf.c Sun Aug 11 22:46:58 2019 (r350877, copy of r349972, head/lib/libc/arm/gen/arm_drain_writebuf.c) @@ -0,0 +1,39 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Ian Lepore + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +int +arm_drain_writebuf(void) +{ + sysarch(ARM_DRAIN_WRITEBUF, NULL); + return (0); +} Copied: stable/12/lib/libc/arm/gen/arm_sync_icache.2 (from r349972, head/lib/libc/arm/gen/arm_sync_icache.2) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/lib/libc/arm/gen/arm_sync_icache.2 Sun Aug 11 22:46:58 2019 (r350877, copy of r349972, head/lib/libc/arm/gen/arm_sync_icache.2) @@ -0,0 +1,79 @@ +.\" Copyright (c) 2019 Ian Lepore +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd July 10, 2019 +.Dt ARM_sync_icache 2 +.Os +.Sh NAME +.Nm arm_sync_icache +.Nd synchronize the data and instruction caches +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In machine/sysarch.h +.Ft int +.Fn arm_sync_icache "u_int addr" "int len" +.Sh DESCRIPTION +The +.Nm +system call synchronizes the contents of any data and instructions caches +with the contents of main memory for the given range. +Use this after loading executable code or modifying existing code in memory, +before attempting to execute that code. +.Pp +The +.Va addr +and +.Va len +arguments do not need to be aligned to any particular boundary, but +cache operations will affect entire cache lines, even those which are only +partially overlapped by the given range. +.Pp +This takes one or more of the following actions, depending on the requirements +of the hardware: +.Bl -bullet +.It +Write dirty data cache lines within the range back to main memory. +.It +Invalidate existing instruction cache contents for the range. +.It +Invalidate branch prediction caches for the range. +.El +.Pp +On hardware which supports multiple synchronization points for cache +operations, the caches are maintained to the point of unification, +making the data in the range coherent amongst all cores. +.Sh RETURN VALUES +The +.Nm +system call always returns 0. +.Sh ERRORS +If a call refers to memory which the calling process does not have rights +to access, or if the +.Va len +argument is negative, a SIGSEGV signal is delivered to the calling thread. +.Sh AUTHORS +This man page was written by +.An Ian Lepore . Copied: stable/12/lib/libc/arm/gen/arm_sync_icache.c (from r349972, head/lib/libc/arm/gen/arm_sync_icache.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/lib/libc/arm/gen/arm_sync_icache.c Sun Aug 11 22:46:58 2019 (r350877, copy of r349972, head/lib/libc/arm/gen/arm_sync_icache.c) @@ -0,0 +1,44 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Ian Lepore + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +int +arm_sync_icache(u_int addr, int len) +{ + struct arm_sync_icache_args args; + + args.addr = addr; + args.len = len; + sysarch(ARM_SYNC_ICACHE, &args); + return (0); +} Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Sun Aug 11 22:32:52 2019 (r350876) +++ stable/12/sys/sys/param.h Sun Aug 11 22:46:58 2019 (r350877) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200514 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200515 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,