From owner-svn-src-vendor@freebsd.org Wed Apr 29 16:24:34 2020 Return-Path: Delivered-To: svn-src-vendor@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 998102BAC71; Wed, 29 Apr 2020 16:24:34 +0000 (UTC) (envelope-from jceel@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 49C3kV3vfZz4Tqm; Wed, 29 Apr 2020 16:24:34 +0000 (UTC) (envelope-from jceel@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 80C668595; Wed, 29 Apr 2020 16:24:34 +0000 (UTC) (envelope-from jceel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03TGOYkN023540; Wed, 29 Apr 2020 16:24:34 GMT (envelope-from jceel@FreeBSD.org) Received: (from jceel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03TGOXsf023532; Wed, 29 Apr 2020 16:24:33 GMT (envelope-from jceel@FreeBSD.org) Message-Id: <202004291624.03TGOXsf023532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jceel set sender to jceel@FreeBSD.org using -f From: Jakub Wojciech Klama Date: Wed, 29 Apr 2020 16:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r360470 - in vendor/lib9p: . dist dist/backend dist/example dist/pytest dist/sbuf dist/transport X-SVN-Group: vendor X-SVN-Commit-Author: jceel X-SVN-Commit-Paths: in vendor/lib9p: . dist dist/backend dist/example dist/pytest dist/sbuf dist/transport X-SVN-Commit-Revision: 360470 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Apr 2020 16:24:34 -0000 Author: jceel Date: Wed Apr 29 16:24:32 2020 New Revision: 360470 URL: https://svnweb.freebsd.org/changeset/base/360470 Log: Import lib9p 7ddb1164407da19b9b1afb83df83ae65a71a9a66. Approved by: trasz (mentor) MFC after: 1 month Sponsored by: Conclusive Engineering Added: vendor/lib9p/ vendor/lib9p/dist/ vendor/lib9p/dist/.gitignore vendor/lib9p/dist/COPYRIGHT vendor/lib9p/dist/GNUmakefile vendor/lib9p/dist/Makefile (contents, props changed) vendor/lib9p/dist/README.md vendor/lib9p/dist/apple_endian.h (contents, props changed) vendor/lib9p/dist/backend/ vendor/lib9p/dist/backend/backend.h (contents, props changed) vendor/lib9p/dist/backend/fs.c (contents, props changed) vendor/lib9p/dist/backend/fs.h (contents, props changed) vendor/lib9p/dist/connection.c (contents, props changed) vendor/lib9p/dist/example/ vendor/lib9p/dist/example/Makefile (contents, props changed) vendor/lib9p/dist/example/server.c (contents, props changed) vendor/lib9p/dist/fcall.h (contents, props changed) vendor/lib9p/dist/fid.h (contents, props changed) vendor/lib9p/dist/genacl.c (contents, props changed) vendor/lib9p/dist/genacl.h (contents, props changed) vendor/lib9p/dist/hashtable.c (contents, props changed) vendor/lib9p/dist/hashtable.h (contents, props changed) vendor/lib9p/dist/lib9p.h (contents, props changed) vendor/lib9p/dist/lib9p_impl.h (contents, props changed) vendor/lib9p/dist/linux_errno.h (contents, props changed) vendor/lib9p/dist/log.c (contents, props changed) vendor/lib9p/dist/log.h (contents, props changed) vendor/lib9p/dist/pack.c (contents, props changed) vendor/lib9p/dist/pytest/ vendor/lib9p/dist/pytest/.gitignore vendor/lib9p/dist/pytest/Makefile (contents, props changed) vendor/lib9p/dist/pytest/README vendor/lib9p/dist/pytest/client.py (contents, props changed) vendor/lib9p/dist/pytest/lerrno.py (contents, props changed) vendor/lib9p/dist/pytest/numalloc.py (contents, props changed) vendor/lib9p/dist/pytest/p9conn.py (contents, props changed) vendor/lib9p/dist/pytest/p9err.py (contents, props changed) vendor/lib9p/dist/pytest/pfod.py (contents, props changed) vendor/lib9p/dist/pytest/protocol.py (contents, props changed) vendor/lib9p/dist/pytest/sequencer.py (contents, props changed) vendor/lib9p/dist/pytest/testconf.ini.sample vendor/lib9p/dist/request.c (contents, props changed) vendor/lib9p/dist/rfuncs.c (contents, props changed) vendor/lib9p/dist/rfuncs.h (contents, props changed) vendor/lib9p/dist/sbuf/ vendor/lib9p/dist/sbuf/sbuf.c (contents, props changed) vendor/lib9p/dist/sbuf/sbuf.h (contents, props changed) vendor/lib9p/dist/threadpool.c (contents, props changed) vendor/lib9p/dist/threadpool.h (contents, props changed) vendor/lib9p/dist/transport/ vendor/lib9p/dist/transport/socket.c (contents, props changed) vendor/lib9p/dist/transport/socket.h (contents, props changed) vendor/lib9p/dist/utils.c (contents, props changed) Added: vendor/lib9p/dist/.gitignore ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/.gitignore Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,37 @@ +# Object files +*.o +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +/build/ + +*.po +*.pico +*.depend Added: vendor/lib9p/dist/COPYRIGHT ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/COPYRIGHT Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,47 @@ +Copyright 2016 Jakub Klama +All rights reserved + +Redistribution and use in source and binary forms, with or without +modification, are permitted providing 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 ``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 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. + +Some parts of the code are based on libixp (http://libs.suckless.org/libixp) +library code released under following license: + +© 2005-2006 Anselm R. Garbe +© 2006-2010 Kris Maglione + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. Added: vendor/lib9p/dist/GNUmakefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/GNUmakefile Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,76 @@ +CC_VERSION := $(shell $(CC) --version | \ + sed -n -e '/clang-/s/.*clang-\([0-9][0-9]*\).*/\1/p') +ifeq ($(CC_VERSION),) +# probably not clang +CC_VERSION := 0 +endif + +WFLAGS := + +# Warnings are version-dependent, unfortunately, +# so test for version before adding a -W flag. +# Note: gnu make requires $(shell test ...) for "a > b" type tests. +ifeq ($(shell test $(CC_VERSION) -gt 0; echo $$?),0) +WFLAGS += -Weverything +WFLAGS += -Wno-padded +WFLAGS += -Wno-gnu-zero-variadic-macro-arguments +WFLAGS += -Wno-format-nonliteral +WFLAGS += -Wno-unused-macros +WFLAGS += -Wno-disabled-macro-expansion +WFLAGS += -Werror +endif + +ifeq ($(shell test $(CC_VERSION) -gt 600; echo $$?),0) +WFLAGS += -Wno-reserved-id-macro +endif + +CFLAGS := $(WFLAGS) \ + -g \ + -O0 \ + -DL9P_DEBUG=L9P_DEBUG +# Note: to turn on debug, use -DL9P_DEBUG=L9P_DEBUG, +# and set env variable LIB9P_LOGGING to stderr or to +# the (preferably full path name of) the debug log file. + +LIB_SRCS := \ + pack.c \ + connection.c \ + request.c \ + genacl.c \ + log.c \ + hashtable.c \ + utils.c \ + rfuncs.c \ + threadpool.c \ + sbuf/sbuf.c \ + transport/socket.c \ + backend/fs.c + +SERVER_SRCS := \ + example/server.c + +BUILD_DIR := build +LIB_OBJS := $(addprefix build/,$(LIB_SRCS:.c=.o)) +SERVER_OBJS := $(SERVER_SRCS:.c=.o) +LIB := lib9p.dylib +SERVER := server + +all: build $(LIB) $(SERVER) + +$(LIB): $(LIB_OBJS) + cc -dynamiclib $^ -o build/$@ + +$(SERVER): $(SERVER_OBJS) $(LIB) + cc $< -o build/$(SERVER) -Lbuild/ -l9p + +clean: + rm -rf build + rm -f $(SERVER_OBJS) +build: + mkdir build + mkdir build/sbuf + mkdir build/transport + mkdir build/backend + +build/%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ Added: vendor/lib9p/dist/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/Makefile Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,27 @@ +# Note: to turn on debug, use -DL9P_DEBUG=L9P_DEBUG, +# and set env variable LIB9P_LOGGING to stderr or to +# the (preferably full path name of) the debug log file. + +LIB= 9p +SHLIB_MAJOR= 1 +SRCS= pack.c \ + connection.c \ + request.c log.c \ + hashtable.c \ + genacl.c \ + utils.c \ + rfuncs.c \ + threadpool.c \ + transport/socket.c \ + backend/fs.c + +INCS= lib9p.h +CC= clang +CFLAGS= -g -O0 -DL9P_DEBUG=L9P_DEBUG -DWITH_CASPER +LIBADD= sbuf libcasper libcap_pwd libcap_grp +SUBDIR= example + +cscope: .PHONY + cd ${.CURDIR}; cscope -buq $$(find . -name '*.[ch]' -print) + +.include Added: vendor/lib9p/dist/README.md ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/README.md Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,20 @@ +# lib9p + +lib9p is a server library implementing 9p2000, 9p2000.u and 9p2000.L revisions +of 9P protocol. It is being developed primarily as a backend for virtio-9p in +BHyVe, the FreeBSD hypervisor. + +# Features + +* 9p2000, 9p2000.u and 9p2000.L protocol support +* Built-in TCP transport + +# Supported operating systems + +* FreeBSD (>=10) +* macOS (>=10.9) + +# Authors + +* Jakub Klama [jceel](https://github.com/jceel) +* Chris Torek [chris3torek](https://github.com/chris3torek) Added: vendor/lib9p/dist/apple_endian.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/apple_endian.h Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,27 @@ +#ifndef _APPLE_ENDIAN_H +#define _APPLE_ENDIAN_H + +/* + * Shims to make Apple's endian headers and macros compatible + * with (which is awful). + */ + +# include + +# define _LITTLE_ENDIAN 0x12345678 +# define _BIG_ENDIAN 0x87654321 + +# ifdef __LITTLE_ENDIAN__ +# define _BYTE_ORDER _LITTLE_ENDIAN +# endif +# ifdef __BIG_ENDIAN__ +# define _BYTE_ORDER _BIG_ENDIAN +# endif + +# define htole32(x) OSSwapHostToLittleInt32(x) +# define le32toh(x) OSSwapLittleToHostInt32(x) + +# define htobe32(x) OSSwapHostToBigInt32(x) +# define be32toh(x) OSSwapBigToHostInt32(x) + +#endif /* _APPLE_ENDIAN_H */ Added: vendor/lib9p/dist/backend/backend.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/backend/backend.h Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Jakub Klama + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted providing 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 ``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 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. + * + */ + + +#ifndef LIB9P_BACKEND_H +#define LIB9P_BACKEND_H + +struct l9p_backend { + void *softc; + void (*freefid)(void *, struct l9p_fid *); + int (*attach)(void *, struct l9p_request *); + int (*clunk)(void *, struct l9p_fid *); + int (*create)(void *, struct l9p_request *); + int (*open)(void *, struct l9p_request *); + int (*read)(void *, struct l9p_request *); + int (*remove)(void *, struct l9p_fid *); + int (*stat)(void *, struct l9p_request *); + int (*walk)(void *, struct l9p_request *); + int (*write)(void *, struct l9p_request *); + int (*wstat)(void *, struct l9p_request *); + int (*statfs)(void *, struct l9p_request *); + int (*lopen)(void *, struct l9p_request *); + int (*lcreate)(void *, struct l9p_request *); + int (*symlink)(void *, struct l9p_request *); + int (*mknod)(void *, struct l9p_request *); + int (*rename)(void *, struct l9p_request *); + int (*readlink)(void *, struct l9p_request *); + int (*getattr)(void *, struct l9p_request *); + int (*setattr)(void *, struct l9p_request *); + int (*xattrwalk)(void *, struct l9p_request *); + int (*xattrcreate)(void *, struct l9p_request *); + int (*xattrread)(void *, struct l9p_request *); + int (*xattrwrite)(void *, struct l9p_request *); + int (*xattrclunk)(void *, struct l9p_fid *); + int (*readdir)(void *, struct l9p_request *); + int (*fsync)(void *, struct l9p_request *); + int (*lock)(void *, struct l9p_request *); + int (*getlock)(void *, struct l9p_request *); + int (*link)(void *, struct l9p_request *); + int (*mkdir)(void *, struct l9p_request *); + int (*renameat)(void *, struct l9p_request *); + int (*unlinkat)(void *, struct l9p_request *); +}; + +#endif /* LIB9P_BACKEND_H */ Added: vendor/lib9p/dist/backend/fs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lib9p/dist/backend/fs.c Wed Apr 29 16:24:32 2020 (r360470) @@ -0,0 +1,3061 @@ +/* + * Copyright 2016 Jakub Klama + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted providing 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 ``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 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. + * + */ + +/* + * Based on libixp code: ©2007-2010 Kris Maglione + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../lib9p.h" +#include "../lib9p_impl.h" +#include "../fid.h" +#include "../log.h" +#include "../rfuncs.h" +#include "../genacl.h" +#include "backend.h" +#include "fs.h" + +#if defined(WITH_CASPER) + #include + #include + #include +#endif + +#if defined(__FreeBSD__) + #include + #if __FreeBSD_version >= 1000000 + #define HAVE_BINDAT + #endif +#endif + +#if defined(__FreeBSD__) + #define HAVE_BIRTHTIME +#endif + +#if defined(__APPLE__) + #include + #include "Availability.h" + #define ACL_TYPE_NFS4 ACL_TYPE_EXTENDED +#endif + +struct fs_softc { + int fs_rootfd; + bool fs_readonly; +#if defined(WITH_CASPER) + cap_channel_t *fs_cappwd; + cap_channel_t *fs_capgrp; +#endif +}; + +struct fs_fid { + DIR *ff_dir; + int ff_dirfd; + int ff_fd; + int ff_flags; + char *ff_name; + struct fs_authinfo *ff_ai; + pthread_mutex_t ff_mtx; + struct l9p_acl *ff_acl; /* cached ACL if any */ +}; + +#define FF_NO_NFSV4_ACL 0x01 /* don't go looking for NFSv4 ACLs */ +/* FF_NO_POSIX_ACL 0x02 -- not yet */ + +/* + * Our authinfo consists of: + * + * - a reference count + * - a uid + * - a gid-set + * + * The "default" gid is the first gid in the git-set, provided the + * set size is at least 1. The set-size may be zero, though. + * + * Adjustments to the ref-count must be atomic, once it's shared. + * It would be nice to use C11 atomics here but they are not common + * enough to all systems just yet; for now, we use a mutex. + * + * Note that some ops (Linux style ones) pass an effective gid for + * the op, in which case, that gid may override. To achieve this + * effect, permissions testing functions also take an extra gid. + * If this gid is (gid_t)-1 it is not used and only the remaining + * gids take part. + * + * The uid may also be (uid_t)-1, meaning "no uid was available + * at all at attach time". In this case, new files inherit parent + * directory uids. + * + * The refcount is simply the number of "openfile"s using this + * authinfo (so that when the last ref goes away, we can free it). + * + * There are also master ACL flags (same as in ff_flags). + */ +struct fs_authinfo { + pthread_mutex_t ai_mtx; /* lock for refcnt */ + uint32_t ai_refcnt; + int ai_flags; + uid_t ai_uid; + int ai_ngids; + gid_t ai_gids[]; /* NB: flexible array member */ +}; + +/* + * We have a global-static mutex for single-threading Tattach + * requests, which use getpwnam (and indirectly, getgr* functions) + * which are not reentrant. + */ +static bool fs_attach_mutex_inited; +static pthread_mutex_t fs_attach_mutex; + +/* + * Internal functions (except inline functions). + */ +static struct passwd *fs_getpwuid(struct fs_softc *, uid_t, struct r_pgdata *); +static struct group *fs_getgrgid(struct fs_softc *, gid_t, struct r_pgdata *); +static int fs_buildname(struct l9p_fid *, char *, char *, size_t); +static int fs_pdir(struct fs_softc *, struct l9p_fid *, char *, size_t, + struct stat *st); +static int fs_dpf(char *, char *, size_t); +static int fs_oflags_dotu(int, int *); +static int fs_oflags_dotl(uint32_t, int *, enum l9p_omode *); +static int fs_nde(struct fs_softc *, struct l9p_fid *, bool, gid_t, + struct stat *, uid_t *, gid_t *); +static struct fs_fid *open_fid(int, const char *, struct fs_authinfo *, bool); +static void dostat(struct fs_softc *, struct l9p_stat *, char *, + struct stat *, bool dotu); +static void dostatfs(struct l9p_statfs *, struct statfs *, long); +static void fillacl(struct fs_fid *ff); +static struct l9p_acl *getacl(struct fs_fid *ff, int fd, const char *path); +static void dropacl(struct fs_fid *ff); +static struct l9p_acl *look_for_nfsv4_acl(struct fs_fid *ff, int fd, + const char *path); +static int check_access(int32_t, + struct l9p_acl *, struct stat *, struct l9p_acl *, struct stat *, + struct fs_authinfo *, gid_t); +static void generate_qid(struct stat *, struct l9p_qid *); + +static int fs_icreate(void *, struct l9p_fid *, char *, int, + bool, mode_t, gid_t, struct stat *); +static int fs_iopen(void *, struct l9p_fid *, int, enum l9p_omode, + gid_t, struct stat *); +static int fs_imkdir(void *, struct l9p_fid *, char *, + bool, mode_t, gid_t, struct stat *); +static int fs_imkfifo(void *, struct l9p_fid *, char *, + bool, mode_t, gid_t, struct stat *); +static int fs_imknod(void *, struct l9p_fid *, char *, + bool, mode_t, dev_t, gid_t, struct stat *); +static int fs_imksocket(void *, struct l9p_fid *, char *, + bool, mode_t, gid_t, struct stat *); +static int fs_isymlink(void *, struct l9p_fid *, char *, char *, + gid_t, struct stat *); + +/* + * Internal functions implementing backend. + */ +static int fs_attach(void *, struct l9p_request *); +static int fs_clunk(void *, struct l9p_fid *); +static int fs_create(void *, struct l9p_request *); +static int fs_open(void *, struct l9p_request *); +static int fs_read(void *, struct l9p_request *); +static int fs_remove(void *, struct l9p_fid *); +static int fs_stat(void *, struct l9p_request *); +static int fs_walk(void *, struct l9p_request *); +static int fs_write(void *, struct l9p_request *); +static int fs_wstat(void *, struct l9p_request *); +static int fs_statfs(void *, struct l9p_request *); +static int fs_lopen(void *, struct l9p_request *); +static int fs_lcreate(void *, struct l9p_request *); +static int fs_symlink(void *, struct l9p_request *); +static int fs_mknod(void *, struct l9p_request *); +static int fs_rename(void *, struct l9p_request *); +static int fs_readlink(void *, struct l9p_request *); +static int fs_getattr(void *, struct l9p_request *); +static int fs_setattr(void *, struct l9p_request *); +static int fs_xattrwalk(void *, struct l9p_request *); +static int fs_xattrcreate(void *, struct l9p_request *); +static int fs_readdir(void *, struct l9p_request *); +static int fs_fsync(void *, struct l9p_request *); +static int fs_lock(void *, struct l9p_request *); +static int fs_getlock(void *, struct l9p_request *); +static int fs_link(void *, struct l9p_request *); +static int fs_renameat(void *, struct l9p_request *); +static int fs_unlinkat(void *, struct l9p_request *); +static void fs_freefid(void *, struct l9p_fid *); + +/* + * Convert from 9p2000 open/create mode to Unix-style O_* flags. + * This includes 9p2000.u extensions, but not 9p2000.L protocol, + * which has entirely different open, create, etc., flag bits. + * + * The given here is the one-byte (uint8_t) "mode" + * argument to Tcreate or Topen, so it can have at most 8 bits. + * + * https://swtch.com/plan9port/man/man9/open.html and + * http://plan9.bell-labs.com/magic/man2html/5/open + * both say: + * + * The [low two bits of the] mode field determines the + * type of I/O ... [I]f mode has the OTRUNC (0x10) bit + * set, the file is to be truncated, which requires write + * permission ...; if the mode has the ORCLOSE (0x40) bit + * set, the file is to be removed when the fid is clunked, + * which requires permission to remove the file from its + * directory. All other bits in mode should be zero. It + * is illegal to write a directory, truncate it, or + * attempt to remove it on close. + * + * 9P2000.u may add ODIRECT (0x80); this is not completely clear. + * The fcall.h header defines OCEXEC (0x20) as well, but it makes + * no sense to send this to a server. There seem to be no bits + * 0x04 and 0x08. + * + * We always turn on O_NOCTTY since as a server, we never want + * to gain a controlling terminal. We always turn on O_NOFOLLOW + * for reasons described elsewhere. + */ +static int +fs_oflags_dotu(int mode, int *aflags) +{ + int flags; +#define CONVERT(theirs, ours) \ + do { \ + if (mode & (theirs)) { \ + mode &= ~(theirs); \ + flags |= ours; \ + } \ + } while (0) + + switch (mode & L9P_OACCMODE) { + + case L9P_OREAD: + default: + flags = O_RDONLY; + break; + + case L9P_OWRITE: + flags = O_WRONLY; + break; + + case L9P_ORDWR: + flags = O_RDWR; + break; + + case L9P_OEXEC: + if (mode & L9P_OTRUNC) + return (EINVAL); + flags = O_RDONLY; + break; + } + + flags |= O_NOCTTY | O_NOFOLLOW; + + CONVERT(L9P_OTRUNC, O_TRUNC); + + /* + * Now take away some flags locally: + * the access mode (already translated) + * ORCLOSE - caller only + * OCEXEC - makes no sense in server + * ODIRECT - not applicable here + * If there are any flag bits left after this, + * we were unable to translate them. For now, let's + * treat this as EINVAL so that we can catch problems. + */ + mode &= ~(L9P_OACCMODE | L9P_ORCLOSE | L9P_OCEXEC | L9P_ODIRECT); + if (mode != 0) { + L9P_LOG(L9P_INFO, + "fs_oflags_dotu: untranslated bits: %#x", + (unsigned)mode); + return (EINVAL); + } + + *aflags = flags; + return (0); +#undef CONVERT +} + +/* + * Convert from 9P2000.L (Linux) open mode bits to O_* flags. + * See fs_oflags_dotu above. + * + * Linux currently does not have open-for-exec, but there is a + * proposal for it using O_PATH|O_NOFOLLOW, now handled here. + * + * We may eventually also set L9P_ORCLOSE for L_O_TMPFILE. + */ +static int +fs_oflags_dotl(uint32_t l_mode, int *aflags, enum l9p_omode *ap9) +{ + int flags; + enum l9p_omode p9; +#define CLEAR(theirs) l_mode &= ~(uint32_t)(theirs) +#define CONVERT(theirs, ours) \ + do { \ + if (l_mode & (theirs)) { \ + CLEAR(theirs); \ + flags |= ours; \ + } \ + } while (0) + + /* + * Linux O_RDONLY, O_WRONLY, O_RDWR (0,1,2) match BSD/MacOS. + */ + flags = l_mode & O_ACCMODE; + if (flags == 3) + return (EINVAL); + CLEAR(O_ACCMODE); + + if ((l_mode & (L9P_L_O_PATH | L9P_L_O_NOFOLLOW)) == + (L9P_L_O_PATH | L9P_L_O_NOFOLLOW)) { + CLEAR(L9P_L_O_PATH | L9P_L_O_NOFOLLOW); + p9 = L9P_OEXEC; + } else { + /* + * Slightly dirty, but same dirt, really, as + * setting flags from l_mode & O_ACCMODE. + */ + p9 = (enum l9p_omode)flags; /* slightly dirty */ + } + + /* turn L_O_TMPFILE into L9P_ORCLOSE in *p9? */ + if (l_mode & L9P_L_O_TRUNC) + p9 |= L9P_OTRUNC; /* but don't CLEAR yet */ + + flags |= O_NOCTTY | O_NOFOLLOW; + + /* + * L_O_CREAT seems to be noise, since we get separate open + * and create. But it is actually set sometimes. We just + * throw it out here; create ops must set it themselves and + * open ops have no permissions bits and hence cannot create. + * + * L_O_EXCL does make sense on create ops, i.e., we can + * take a create op with or without L_O_EXCL. We pass that + * through. + */ + CLEAR(L9P_L_O_CREAT); + CONVERT(L9P_L_O_EXCL, O_EXCL); + CONVERT(L9P_L_O_TRUNC, O_TRUNC); + CONVERT(L9P_L_O_DIRECTORY, O_DIRECTORY); + CONVERT(L9P_L_O_APPEND, O_APPEND); + CONVERT(L9P_L_O_NONBLOCK, O_NONBLOCK); + + /* + * Discard these as useless noise at our (server) end. + * (NOATIME might be useful but we can only set it on a + * per-mount basis.) + */ + CLEAR(L9P_L_O_CLOEXEC); + CLEAR(L9P_L_O_DIRECT); + CLEAR(L9P_L_O_DSYNC); + CLEAR(L9P_L_O_FASYNC); + CLEAR(L9P_L_O_LARGEFILE); + CLEAR(L9P_L_O_NOATIME); + CLEAR(L9P_L_O_NOCTTY); + CLEAR(L9P_L_O_NOFOLLOW); + CLEAR(L9P_L_O_SYNC); + + if (l_mode != 0) { + L9P_LOG(L9P_INFO, + "fs_oflags_dotl: untranslated bits: %#x", + (unsigned)l_mode); + return (EINVAL); + } + + *aflags = flags; + *ap9 = p9; + return (0); +#undef CLEAR +#undef CONVERT +} + +static struct passwd * +fs_getpwuid(struct fs_softc *sc, uid_t uid, struct r_pgdata *pg) +{ +#if defined(WITH_CASPER) + return (r_cap_getpwuid(sc->fs_cappwd, uid, pg)); +#else + (void)sc; + return (r_getpwuid(uid, pg)); +#endif +} + +static struct group * +fs_getgrgid(struct fs_softc *sc, gid_t gid, struct r_pgdata *pg) +{ +#if defined(WITH_CASPER) + return (r_cap_getgrgid(sc->fs_capgrp, gid, pg)); +#else + (void)sc; + return (r_getgrgid(gid, pg)); +#endif +} + +/* + * Build full name of file by appending given name to directory name. + */ +static int +fs_buildname(struct l9p_fid *dir, char *name, char *buf, size_t size) +{ + struct fs_fid *dirf = dir->lo_aux; + size_t dlen, nlen1; + + assert(dirf != NULL); + dlen = strlen(dirf->ff_name); + nlen1 = strlen(name) + 1; /* +1 for '\0' */ + if (dlen + 1 + nlen1 > size) + return (ENAMETOOLONG); + memcpy(buf, dirf->ff_name, dlen); + buf[dlen] = '/'; + memcpy(buf + dlen + 1, name, nlen1); + return (0); +} + +/* + * Build parent name of file by splitting it off. Return an error + * if the given fid represents the root, so that there is no such + * parent, or if the discovered parent is not a directory. + */ +static int +fs_pdir(struct fs_softc *sc __unused, struct l9p_fid *fid, char *buf, + size_t size, struct stat *st) +{ + struct fs_fid *ff; + char *path; + + ff = fid->lo_aux; + assert(ff != NULL); + path = ff->ff_name; + path = r_dirname(path, buf, size); + if (path == NULL) + return (ENAMETOOLONG); + if (fstatat(ff->ff_dirfd, path, st, AT_SYMLINK_NOFOLLOW) != 0) + return (errno); + if (!S_ISDIR(st->st_mode)) + return (ENOTDIR); + return (0); +} + +/* + * Like fs_buildname() but for adding a file name to a buffer + * already holding a directory name. Essentially does + * strcat(dbuf, "/"); + * strcat(dbuf, fname); + * but with size checking and an ENAMETOOLONG error as needed. + * + * (Think of the function name as "directory plus-equals file".) + */ +static int +fs_dpf(char *dbuf, char *fname, size_t size) +{ + size_t dlen, nlen1; + + dlen = strlen(dbuf); + nlen1 = strlen(fname) + 1; + if (dlen + 1 + nlen1 > size) + return (ENAMETOOLONG); + dbuf[dlen] = '/'; + memcpy(dbuf + dlen + 1, fname, nlen1); + return (0); +} + +/* + * Prepare to create a new directory entry (open with O_CREAT, + * mkdir, etc -- any operation that creates a new inode), + * operating in parent data , based on authinfo and + * effective gid . + * + * The new entity should be owned by user/group <*nuid, *ngid>, + * if it's really a new entity. It will be a directory if isdir. + * + * Returns an error number if the entry should not be created + * (e.g., read-only file system or no permission to write in + * parent directory). Always sets *nuid and *ngid on success: + * in the worst case, when there is no available ID, this will + * use the parent directory's IDs. Fills in <*st> on success. + */ +static int +fs_nde(struct fs_softc *sc, struct l9p_fid *dir, bool isdir, gid_t egid, + struct stat *st, uid_t *nuid, gid_t *ngid) +{ + struct fs_fid *dirf; + struct fs_authinfo *ai; + int32_t op; + int error; + + if (sc->fs_readonly) + return (EROFS); + dirf = dir->lo_aux; + assert(dirf != NULL); + if (fstatat(dirf->ff_dirfd, dirf->ff_name, st, + AT_SYMLINK_NOFOLLOW) != 0) + return (errno); + if (!S_ISDIR(st->st_mode)) + return (ENOTDIR); + dirf = dir->lo_aux; + ai = dirf->ff_ai; + fillacl(dirf); + op = isdir ? L9P_ACE_ADD_SUBDIRECTORY : L9P_ACE_ADD_FILE; + error = check_access(op, dirf->ff_acl, st, NULL, NULL, ai, egid); + if (error) + return (EPERM); + + *nuid = ai->ai_uid != (uid_t)-1 ? ai->ai_uid : st->st_uid; + *ngid = egid != (gid_t)-1 ? egid : + ai->ai_ngids > 0 ? ai->ai_gids[0] : st->st_gid; + return (0); +} + +/* + * Allocate new open-file data structure to attach to a fid. + * + * The new file's authinfo is the same as the old one's, and + * we gain a reference. + */ +static struct fs_fid * +open_fid(int dirfd, const char *path, struct fs_authinfo *ai, bool creating) +{ + struct fs_fid *ret; + uint32_t newcount; + int error; + + ret = l9p_calloc(1, sizeof(*ret)); + error = pthread_mutex_init(&ret->ff_mtx, NULL); + if (error) { + free(ret); + return (NULL); + } + ret->ff_fd = -1; + ret->ff_dirfd = dirfd; + ret->ff_name = strdup(path); + if (ret->ff_name == NULL) { + pthread_mutex_destroy(&ret->ff_mtx); + free(ret); + return (NULL); + } + pthread_mutex_lock(&ai->ai_mtx); + newcount = ++ai->ai_refcnt; + pthread_mutex_unlock(&ai->ai_mtx); + /* + * If we just incremented the count to 1, we're the *first* + * reference. This is only allowed when creating the authinfo, + * otherwise it means something has gone wrong. This cannot + * catch every bad (re)use of a freed authinfo but it may catch + * a few. + */ + assert(newcount > 1 || creating); + L9P_LOG(L9P_DEBUG, "authinfo %p now used by %lu", + (void *)ai, (u_long)newcount); + ret->ff_ai = ai; + return (ret); +} + +static void +dostat(struct fs_softc *sc, struct l9p_stat *s, char *name, + struct stat *buf, bool dotu) +{ + struct passwd *user; + struct group *group; + + memset(s, 0, sizeof(struct l9p_stat)); + + generate_qid(buf, &s->qid); + + s->type = 0; + s->dev = 0; + s->mode = buf->st_mode & 0777; + + if (S_ISDIR(buf->st_mode)) + s->mode |= L9P_DMDIR; + + if (S_ISLNK(buf->st_mode) && dotu) + s->mode |= L9P_DMSYMLINK; + + if (S_ISCHR(buf->st_mode) || S_ISBLK(buf->st_mode)) + s->mode |= L9P_DMDEVICE; + + if (S_ISSOCK(buf->st_mode)) + s->mode |= L9P_DMSOCKET; + + if (S_ISFIFO(buf->st_mode)) + s->mode |= L9P_DMNAMEDPIPE; + + s->atime = (uint32_t)buf->st_atime; + s->mtime = (uint32_t)buf->st_mtime; + s->length = (uint64_t)buf->st_size; + + s->name = r_basename(name, NULL, 0); + + if (!dotu) { + struct r_pgdata udata, gdata; + + user = fs_getpwuid(sc, buf->st_uid, &udata); + group = fs_getgrgid(sc, buf->st_gid, &gdata); + s->uid = user != NULL ? strdup(user->pw_name) : NULL; + s->gid = group != NULL ? strdup(group->gr_name) : NULL; + s->muid = user != NULL ? strdup(user->pw_name) : NULL; + r_pgfree(&udata); + r_pgfree(&gdata); + } else { + /* + * When using 9P2000.u, we don't need to bother about + * providing user and group names in textual form. + * + * NB: if the asprintf()s fail, s->extension should + * be unset so we can ignore these. + */ + s->n_uid = buf->st_uid; + s->n_gid = buf->st_gid; + s->n_muid = buf->st_uid; + + if (S_ISLNK(buf->st_mode)) { + char target[MAXPATHLEN]; + ssize_t ret = readlink(name, target, MAXPATHLEN); + + if (ret < 0) { + s->extension = NULL; + return; + } + + s->extension = strndup(target, (size_t)ret); + } + + if (S_ISBLK(buf->st_mode)) { + asprintf(&s->extension, "b %d %d", major(buf->st_rdev), + minor(buf->st_rdev)); + } + + if (S_ISCHR(buf->st_mode)) { + asprintf(&s->extension, "c %d %d", major(buf->st_rdev), + minor(buf->st_rdev)); + } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@freebsd.org Wed Apr 29 16:28:41 2020 Return-Path: Delivered-To: svn-src-vendor@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 23B852BADC7; Wed, 29 Apr 2020 16:28:41 +0000 (UTC) (envelope-from jceel@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 49C3qF0Bsfz4V37; Wed, 29 Apr 2020 16:28:41 +0000 (UTC) (envelope-from jceel@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 DC3EE859D; Wed, 29 Apr 2020 16:28:40 +0000 (UTC) (envelope-from jceel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03TGSeeN023776; Wed, 29 Apr 2020 16:28:40 GMT (envelope-from jceel@FreeBSD.org) Received: (from jceel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03TGSewN023775; Wed, 29 Apr 2020 16:28:40 GMT (envelope-from jceel@FreeBSD.org) Message-Id: <202004291628.03TGSewN023775@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jceel set sender to jceel@FreeBSD.org using -f From: Jakub Wojciech Klama Date: Wed, 29 Apr 2020 16:28:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r360471 - vendor/lib9p/7ddb1164407da19b9b1afb83df83ae65a71a9a66 X-SVN-Group: vendor X-SVN-Commit-Author: jceel X-SVN-Commit-Paths: vendor/lib9p/7ddb1164407da19b9b1afb83df83ae65a71a9a66 X-SVN-Commit-Revision: 360471 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Apr 2020 16:28:41 -0000 Author: jceel Date: Wed Apr 29 16:28:40 2020 New Revision: 360471 URL: https://svnweb.freebsd.org/changeset/base/360471 Log: Tag import of lib9p 7ddb1164407da19b9b1afb83df83ae65a71a9a66 Added: vendor/lib9p/7ddb1164407da19b9b1afb83df83ae65a71a9a66/ - copied from r360470, vendor/lib9p/dist/ From owner-svn-src-vendor@freebsd.org Thu Apr 30 23:40:40 2020 Return-Path: Delivered-To: svn-src-vendor@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 81FD72CB6D2; Thu, 30 Apr 2020 23:40:40 +0000 (UTC) (envelope-from jkim@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 49CsMD3CVyz4CPB; Thu, 30 Apr 2020 23:40:40 +0000 (UTC) (envelope-from jkim@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 692E426D4C; Thu, 30 Apr 2020 23:40:40 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03UNeeQK081956; Thu, 30 Apr 2020 23:40:40 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03UNea8l079869; Thu, 30 Apr 2020 23:40:36 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <202004302340.03UNea8l079869@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Thu, 30 Apr 2020 23:40:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r360512 - in vendor-sys/acpica/dist: . source/common source/compiler source/components/debugger source/components/disassembler source/components/dispatcher source/components/executer so... X-SVN-Group: vendor-sys X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: in vendor-sys/acpica/dist: . source/common source/compiler source/components/debugger source/components/disassembler source/components/dispatcher source/components/executer source/include source/tools... X-SVN-Commit-Revision: 360512 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2020 23:40:40 -0000 Author: jkim Date: Thu Apr 30 23:40:36 2020 New Revision: 360512 URL: https://svnweb.freebsd.org/changeset/base/360512 Log: Import ACPICA 20200430. Modified: vendor-sys/acpica/dist/changes.txt vendor-sys/acpica/dist/source/common/acgetline.c vendor-sys/acpica/dist/source/common/dmtbdump2.c vendor-sys/acpica/dist/source/compiler/aslcompiler.l vendor-sys/acpica/dist/source/compiler/aslload.c vendor-sys/acpica/dist/source/compiler/aslmessages.c vendor-sys/acpica/dist/source/compiler/aslmessages.h vendor-sys/acpica/dist/source/compiler/aslpredef.c vendor-sys/acpica/dist/source/compiler/aslxref.c vendor-sys/acpica/dist/source/compiler/dtutils.c vendor-sys/acpica/dist/source/components/debugger/dbhistry.c vendor-sys/acpica/dist/source/components/disassembler/dmbuffer.c vendor-sys/acpica/dist/source/components/dispatcher/dsfield.c vendor-sys/acpica/dist/source/components/executer/exfield.c vendor-sys/acpica/dist/source/include/acglobal.h vendor-sys/acpica/dist/source/include/acpixf.h vendor-sys/acpica/dist/source/include/acpredef.h vendor-sys/acpica/dist/source/tools/acpiexec/aemain.c Modified: vendor-sys/acpica/dist/changes.txt ============================================================================== --- vendor-sys/acpica/dist/changes.txt Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/changes.txt Thu Apr 30 23:40:36 2020 (r360512) @@ -1,4 +1,61 @@ ---------------------------------------- + + +30 April 2020. Summary of changes for version 20200430: + + +1) ACPICA kernel-resident subsystem: + +Cleaned up the coding style of a couple of global variables +(AcpiGbl_NextCmdNum and AcpiProtocolLengths) caught by static analyzers. +AcpiProtocolLengths was made static, and the definition of +AcpiGbl_NextCmdNum was moved to acglobal.h. + + +2) iASL Compiler/Disassembler and ACPICA tools: + +iASL DataTable Compiler: Fixed a segfault on errors that aren't directly +associated with a field. + +Disassembler: has been made more resilient so that it will continue to +parse AML even if the AML generates ACPI namespace errors. This enables +iASL to disassemble some AML that may have been compiled using older +versions of iASL that no longer compile with newer versions of iASL. + +iASL: Fixed the required parameters for _NIH and _NIG. Previously, there +was a mixup where _NIG required one parameter and _NIH required zero +parameters. This change swaps these parameter requirements. Now it is +required that _NIH must be called with one parameter and _NIG requires +zero parameters. + +iASL: Allow use of undefined externals as long as they are protected by +an if (CondRefOf (...)) block when compiling multiple definition blocks. + +iASL: Fixed the type override behavior of named objects that are declared +as External. External declarations will no longer override the type of +the actual definition if it already exists. + +AcpiNames: Added setargv.obj to the MSVC 2017 link sequence to enable +command line wildcard support on Windows. Note: the AcpiNames utility is +essentially redundant with the AcpiExec utility (using the "namespace" +command) and is therefore deprecated. It will be removed in future +releases of ACPICA. + +Disassembler: ignore AE_ALREADY_EXISTS status when parsing create* +operators. The disassembler is intended to emit existing ASL code as-is. +Therefore, error messages emitted during disassembly should be ignored or +handled in a way such that the disassembler can continue to parse the +AML. This change ignores AE_ALREADY_EXISTS errors during the deferred Op +parsing for create operators in order to complete parsing ASL termlists. + +iASL DataTable Compiler: IVRS table: fix potentially uninitialized +variable warning. Some compilers catch potential uninitialized variables. +This is done by examining branches of if/else statements. This change +replaces an "else if" with an "else" to fix the uninitialized variable +warning. + + +---------------------------------------- 26 March 2020. Summary of changes for version 20200326: @@ -674,7 +731,7 @@ temporary. iASL: Emit error for creation of a zero-length operation region. Such a region is rather pointless. If encountered, a runtime error is also -implemented in the interpeter. +implemented in the interpreter. Debugger: Fix a possible fault with the "test objects" command. Modified: vendor-sys/acpica/dist/source/common/acgetline.c ============================================================================== --- vendor-sys/acpica/dist/source/common/acgetline.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/common/acgetline.c Thu Apr 30 23:40:36 2020 (r360512) @@ -189,8 +189,6 @@ AcpiAcClearLine ( #define _ASCII_LEFT_ARROW 'D' #define _ASCII_NEWLINE '\n' -extern UINT32 AcpiGbl_NextCmdNum; - /* Erase a single character on the input command line */ #define ACPI_CLEAR_CHAR() \ Modified: vendor-sys/acpica/dist/source/common/dmtbdump2.c ============================================================================== --- vendor-sys/acpica/dist/source/common/dmtbdump2.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/common/dmtbdump2.c Thu Apr 30 23:40:36 2020 (r360512) @@ -528,8 +528,10 @@ AcpiDmDumpIvrs ( DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, sizeof (ACPI_IVRS_HARDWARE1)); } - else if (Subtable->Type == ACPI_IVRS_TYPE_HARDWARE2) + else { + /* ACPI_IVRS_TYPE_HARDWARE2 subtable type */ + EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE2); DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, sizeof (ACPI_IVRS_HARDWARE2)); Modified: vendor-sys/acpica/dist/source/compiler/aslcompiler.l ============================================================================== --- vendor-sys/acpica/dist/source/compiler/aslcompiler.l Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/aslcompiler.l Thu Apr 30 23:40:36 2020 (r360512) @@ -819,7 +819,7 @@ NamePathTail [.]{NameSeg} } /* - * The eror code is contained inside the + * The error code is contained inside the * {ErrorCode} pattern. Extract it and log it * as the expected error code. */ Modified: vendor-sys/acpica/dist/source/compiler/aslload.c ============================================================================== --- vendor-sys/acpica/dist/source/compiler/aslload.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/aslload.c Thu Apr 30 23:40:36 2020 (r360512) @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dswload - Dispatcher namespace load callbacks + * Module Name: aslload - compiler namespace load callbacks * *****************************************************************************/ @@ -201,7 +201,6 @@ LdAnalyzeExternals ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op, ACPI_OBJECT_TYPE ExternalOpType, - ACPI_OBJECT_TYPE ObjectType, ACPI_WALK_STATE *WalkState); @@ -515,7 +514,6 @@ LdNamespace1Begin ( ACPI_PARSE_OBJECT *MethodOp; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; - ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; char *Path; UINT32 Flags = ACPI_NS_NO_UPSEARCH; ACPI_PARSE_OBJECT *Arg; @@ -689,8 +687,7 @@ LdNamespace1Begin ( * * first child is name, next child is ObjectType */ - ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; - ObjectType = ACPI_TYPE_ANY; + ObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; /* * We will mark every new node along the path as "External". This @@ -709,7 +706,7 @@ LdNamespace1Begin ( * Store (\_SB_.PCI0.ABCD, Local0) * } */ - Flags |= ACPI_NS_EXTERNAL; + Flags |= ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE; break; case PARSEOP_DEFAULT_ARG: @@ -913,8 +910,7 @@ LdNamespace1Begin ( else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) { - Status = LdAnalyzeExternals (Node, Op, ActualObjectType, - ObjectType, WalkState); + Status = LdAnalyzeExternals (Node, Op, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { if (Status == AE_ERROR) @@ -929,6 +925,19 @@ LdNamespace1Begin ( } return_ACPI_STATUS (Status); } + + if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + { + /* + * If we get to here, it means that an actual definition of + * the object declared external exists. Meaning that Op + * loading this this Op should have no change to the ACPI + * namespace. By going to FinishNode, we skip the + * assignment of Node->Op = Op. + */ + goto FinishNode; + } } else { @@ -980,31 +989,16 @@ LdNamespace1Begin ( } } -FinishNode: - /* - * Point the parse node to the new namespace node, and point - * the Node back to the original Parse node - */ - Op->Asl.Node = Node; + /* Point the Node back to the original Parse node */ + Node->Op = Op; - /* - * Set the actual data type if appropriate (EXTERNAL term only) - * As of 11/19/2019, ASL External() does not support parameter - * counts. When an External method is loaded, the parameter count is - * recorded in the external's arg count parameter. The parameter count may - * or may not be known in the declaration. If the value of this node turns - * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that - * we do not know the parameter count and that we must look at the usage of - * the External method call to get this information. - */ - if (ActualObjectType != ACPI_TYPE_ANY) - { - Node->Type = (UINT8) ActualObjectType; - Node->Value = (UINT32) - Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; - } +FinishNode: + /* Point the parse node to the new namespace node */ + + Op->Asl.Node = Node; + if (Op->Asl.ParseOpcode == PARSEOP_METHOD) { /* @@ -1013,6 +1007,13 @@ FinishNode: */ Node->Value = (UINT32) Op->Asl.Extra; } + else if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && + Node->Type == ACPI_TYPE_METHOD && + (Node->Flags & ANOBJ_IS_EXTERNAL)) + { + Node->Value = + (UINT32) Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; + } return_ACPI_STATUS (Status); } @@ -1020,7 +1021,7 @@ FinishNode: /******************************************************************************* * - * FUNCTION: LdAnalyzeExternals + * FUNCTION: LdMatchExternType * * PARAMETERS: Type1 * Type2 @@ -1037,7 +1038,7 @@ FinishNode: ******************************************************************************/ static BOOLEAN -LdTypesMatchExternType ( +LdMatchExternType ( ACPI_OBJECT_TYPE Type1, ACPI_OBJECT_TYPE Type2) { @@ -1093,7 +1094,6 @@ LdTypesMatchExternType ( * PARAMETERS: Node - Node that represents the named object * Op - Named object declaring this named object * ExternalOpType - Type of ExternalOp - * ObjectType - Type of Declared object * WalkState - Current WalkState * * RETURN: Status @@ -1111,7 +1111,6 @@ LdAnalyzeExternals ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op, ACPI_OBJECT_TYPE ExternalOpType, - ACPI_OBJECT_TYPE ObjectType, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; @@ -1135,12 +1134,12 @@ LdAnalyzeExternals ( else { ActualExternalOpType = Node->Type; - ActualOpType = ObjectType; + ActualOpType = ExternalOpType; } if ((ActualOpType != ACPI_TYPE_ANY) && (ActualExternalOpType != ACPI_TYPE_ANY) && - !LdTypesMatchExternType (ActualExternalOpType, ActualOpType)) + !LdMatchExternType (ActualExternalOpType, ActualOpType)) { if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) @@ -1168,6 +1167,8 @@ LdAnalyzeExternals ( } } + /* Set the object type of the external */ + if ((Node->Flags & ANOBJ_IS_EXTERNAL) && (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) { @@ -1176,13 +1177,13 @@ LdAnalyzeExternals ( * previously declared External */ Node->Flags &= ~ANOBJ_IS_EXTERNAL; - Node->Type = (UINT8) ObjectType; + Node->Type = (UINT8) ExternalOpType; /* Just retyped a node, probably will need to open a scope */ - if (AcpiNsOpensScope (ObjectType)) + if (AcpiNsOpensScope (ExternalOpType)) { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush (Node, ExternalOpType, WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -1203,7 +1204,7 @@ LdAnalyzeExternals ( } else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && - (ObjectType == ACPI_TYPE_ANY)) + (ExternalOpType == ACPI_TYPE_ANY)) { /* Allow update of externals of unknown type. */ Modified: vendor-sys/acpica/dist/source/compiler/aslmessages.c ============================================================================== --- vendor-sys/acpica/dist/source/compiler/aslmessages.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/aslmessages.c Thu Apr 30 23:40:36 2020 (r360512) @@ -380,6 +380,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:", /* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected", /* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:", +/* ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL */"CondRefOf parameter requires External() declaration", }; /* Table compiler */ Modified: vendor-sys/acpica/dist/source/compiler/aslmessages.h ============================================================================== --- vendor-sys/acpica/dist/source/compiler/aslmessages.h Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/aslmessages.h Thu Apr 30 23:40:36 2020 (r360512) @@ -382,6 +382,7 @@ typedef enum ASL_MSG_TYPE_MISMATCH_FOUND_HERE, ASL_MSG_DUPLICATE_EXTERN_MISMATCH, ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, + ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL, /* These messages are used by the Data Table compiler only */ Modified: vendor-sys/acpica/dist/source/compiler/aslpredef.c ============================================================================== --- vendor-sys/acpica/dist/source/compiler/aslpredef.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/aslpredef.c Thu Apr 30 23:40:36 2020 (r360512) @@ -674,7 +674,7 @@ ApCheckForSpecialName ( /* * Was not actually emitted by the compiler. This is a special case, * however. If the ASL code being compiled was the result of a - * dissasembly, it may possibly contain valid compiler-emitted names + * disassembly, it may possibly contain valid compiler-emitted names * of the form "_T_x". We don't want to issue an error or even a * warning and force the user to manually change the names. So, we * will issue a remark instead. Modified: vendor-sys/acpica/dist/source/compiler/aslxref.c ============================================================================== --- vendor-sys/acpica/dist/source/compiler/aslxref.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/aslxref.c Thu Apr 30 23:40:36 2020 (r360512) @@ -199,7 +199,17 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +static BOOLEAN +XfFindCondRefOfName ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); +static BOOLEAN +XfRefIsGuardedByIfCondRefOf ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + /******************************************************************************* * * FUNCTION: XfCrossReferenceNamespace @@ -582,17 +592,6 @@ XfNamespaceLocateBegin ( } /* - * One special case: CondRefOf operator - we don't care if the name exists - * or not at this point, just ignore it, the point of the operator is to - * determine if the name exists at runtime. - */ - if ((Op->Asl.Parent) && - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) - { - return_ACPI_STATUS (AE_OK); - } - - /* * We must enable the "search-to-root" for single NameSegs, but * we have to be very careful about opening up scopes */ @@ -600,7 +599,8 @@ XfNamespaceLocateBegin ( if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) || - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || + (Op->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { /* * These are name references, do not push the scope stack @@ -665,8 +665,23 @@ XfNamespaceLocateBegin ( * We didn't find the name reference by path -- we can qualify this * a little better before we print an error message */ - if (strlen (Path) == ACPI_NAMESEG_SIZE) + + if ((Op->Asl.Parent) && + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { + /* + * One special case: CondRefOf operator - if the name doesn't + * exist at this point, it means that there's no actual or + * external declaration. If the name is not found, just ignore + * it, the point of the operator is to determine if the name + * exists at runtime. We wanted to see if this named object + * exists to facilitate analysis to allow protected usage of + * undeclared externals. + */ + return_ACPI_STATUS (AE_OK); + } + else if (strlen (Path) == ACPI_NAMESEG_SIZE) + { /* A simple, one-segment ACPI name */ if (XfObjectExists (Path)) @@ -1190,6 +1205,7 @@ XfNamespaceLocateBegin ( /* * 5) Check for external resolution + * * By this point, everything should be loaded in the namespace. If a * namespace lookup results in a namespace node that is an external, it * means that this named object was not defined in the input ASL. This @@ -1197,11 +1213,38 @@ XfNamespaceLocateBegin ( * use the external keyword to suppress compiler errors about undefined * objects. Note: this only applies when compiling multiple definition * blocks. + * + * Do not check for external resolution in the following cases: + * + * case 1) External (ABCD) + * + * This declares ABCD as an external so there is no requirement for + * ABCD to be loaded in the namespace when analyzing the actual + * External() statement. + * + * case 2) CondRefOf (ABCD) + * + * This operator will query the ACPI namespace on the existence of + * ABCD. If ABCD does not exist, this operator will return a 0 + * without incurring AML runtime errors. Therefore, ABCD is allowed + * to not exist when analyzing the CondRefOf operator. + * + * case 3) External (ABCD) + * if (CondRefOf (ABCD)) + * { + * Store (0, ABCD) + * } + * + * In this case, ABCD is accessed only if it exists due to the if + * statement so there is no need to flag the ABCD nested in the + * store operator. */ if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next && - (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && - Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) && - (Node->Flags & ANOBJ_IS_EXTERNAL)) + (Node->Flags & ANOBJ_IS_EXTERNAL) && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF && + !XfRefIsGuardedByIfCondRefOf (Node, Op)) { AslError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL); } @@ -1216,6 +1259,96 @@ XfNamespaceLocateBegin ( Op->Asl.Node = Node; return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: XfRefIsGuardedByIfCondRefOf + * + * PARAMETERS: Node - Named object reference node + * Op - Named object reference parse node + * + * RETURN: BOOLEAN + * + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) + * refers to Node. + * + ******************************************************************************/ + +static BOOLEAN +XfRefIsGuardedByIfCondRefOf ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent = Op->Asl.Parent; + + + while (Parent) + { + if (Parent->Asl.ParseOpcode == PARSEOP_IF && + XfFindCondRefOfName (Node, Parent->Asl.Child)) + { + return (TRUE); + } + + Parent = Parent->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfRefIsGuardedByIfCondRefOf + * + * PARAMETERS: Node - Named object reference node + * Op - Named object reference parse node + * + * RETURN: BOOLEAN + * + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) + * refers to Node. + * + ******************************************************************************/ + +static BOOLEAN +XfFindCondRefOfName ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + BOOLEAN CondRefOfFound = FALSE; + + + if (!Op) + { + return (FALSE); + } + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_CONDREFOF: + + return (Op->Asl.Child->Common.Node == Node); + break; + + case PARSEOP_LAND: + + CondRefOfFound = XfFindCondRefOfName (Node, Op->Asl.Child); + if (CondRefOfFound) + { + return (TRUE); + } + + return (XfFindCondRefOfName (Node, Op->Asl.Child->Asl.Next)); + break; + + default: + + return (FALSE); + break; + } } Modified: vendor-sys/acpica/dist/source/compiler/dtutils.c ============================================================================== --- vendor-sys/acpica/dist/source/compiler/dtutils.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/compiler/dtutils.c Thu Apr 30 23:40:36 2020 (r360512) @@ -186,11 +186,20 @@ DtError ( DT_FIELD *FieldObject, char *ExtraMessage) { + UINT32 Line = 0; + + /* Field object could be NULL */ + + if (FieldObject) + { + Line = FieldObject->Line; + } + /* Check if user wants to ignore this exception */ if (AslIsExceptionIgnored (AslGbl_Files[ASL_FILE_INPUT].Filename, - FieldObject->Line, Level, MessageId)) + Line, Level, MessageId)) { return; } Modified: vendor-sys/acpica/dist/source/components/debugger/dbhistry.c ============================================================================== --- vendor-sys/acpica/dist/source/components/debugger/dbhistry.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/components/debugger/dbhistry.c Thu Apr 30 23:40:36 2020 (r360512) @@ -175,7 +175,6 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HIST static UINT16 AcpiGbl_LoHistory = 0; static UINT16 AcpiGbl_NumHistory = 0; static UINT16 AcpiGbl_NextHistoryIndex = 0; -UINT32 AcpiGbl_NextCmdNum = 1; /******************************************************************************* Modified: vendor-sys/acpica/dist/source/components/disassembler/dmbuffer.c ============================================================================== --- vendor-sys/acpica/dist/source/components/disassembler/dmbuffer.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/components/disassembler/dmbuffer.c Thu Apr 30 23:40:36 2020 (r360512) @@ -400,6 +400,10 @@ AcpiDmIsUuidBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -520,6 +524,10 @@ AcpiDmIsUnicodeBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -596,6 +604,10 @@ AcpiDmIsStringBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -675,13 +687,18 @@ AcpiDmIsPldBuffer ( UINT64 InitializerSize; + if (!Op) + { + return (FALSE); + } + /* * Get the BufferSize argument - Buffer(BufferSize) * If the buffer was generated by the ToPld macro, it must * be a BYTE constant. */ SizeOp = Op->Common.Value.Arg; - if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) + if (!SizeOp || SizeOp->Common.AmlOpcode != AML_BYTE_OP) { return (FALSE); } Modified: vendor-sys/acpica/dist/source/components/dispatcher/dsfield.c ============================================================================== --- vendor-sys/acpica/dist/source/components/dispatcher/dsfield.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/components/dispatcher/dsfield.c Thu Apr 30 23:40:36 2020 (r360512) @@ -341,8 +341,13 @@ AcpiDsCreateBufferField ( Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); - if (ACPI_FAILURE (Status)) + if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && + Status == AE_ALREADY_EXISTS) { + Status = AE_OK; + } + else if (ACPI_FAILURE (Status)) + { ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); @@ -682,12 +687,21 @@ AcpiDsCreateField ( Info.RegionNode = RegionNode; Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); - if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM && - !(RegionNode->Object->Field.InternalPccBuffer - = ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length))) + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS (Status); } + + if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM) + { + RegionNode->Object->Field.InternalPccBuffer = + ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length); + if (!RegionNode->Object->Field.InternalPccBuffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + return_ACPI_STATUS (Status); } Modified: vendor-sys/acpica/dist/source/components/executer/exfield.c ============================================================================== --- vendor-sys/acpica/dist/source/components/executer/exfield.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/components/executer/exfield.c Thu Apr 30 23:40:36 2020 (r360512) @@ -167,7 +167,7 @@ #define ACPI_INVALID_PROTOCOL_ID 0x80 #define ACPI_MAX_PROTOCOL_ID 0x0F -const UINT8 AcpiProtocolLengths[] = +static const UINT8 AcpiProtocolLengths[] = { ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ Modified: vendor-sys/acpica/dist/source/include/acglobal.h ============================================================================== --- vendor-sys/acpica/dist/source/include/acglobal.h Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/include/acglobal.h Thu Apr 30 23:40:36 2020 (r360512) @@ -436,6 +436,7 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_Extern #ifdef ACPI_DEBUGGER ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NextCmdNum, 1); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); Modified: vendor-sys/acpica/dist/source/include/acpixf.h ============================================================================== --- vendor-sys/acpica/dist/source/include/acpixf.h Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/include/acpixf.h Thu Apr 30 23:40:36 2020 (r360512) @@ -154,7 +154,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20200326 +#define ACPI_CA_VERSION 0x20200430 #include "acconfig.h" #include "actypes.h" Modified: vendor-sys/acpica/dist/source/include/acpredef.h ============================================================================== --- vendor-sys/acpica/dist/source/include/acpredef.h Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/include/acpredef.h Thu Apr 30 23:40:36 2020 (r360512) @@ -769,10 +769,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_Predefined {{"_NIC", METHOD_0ARGS, /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, - {{"_NIG", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ + {{"_NIG", METHOD_0ARGS, /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, - {{"_NIH", METHOD_0ARGS, /* ACPI 6.3 */ + {{"_NIH", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, {{"_NTT", METHOD_0ARGS, Modified: vendor-sys/acpica/dist/source/tools/acpiexec/aemain.c ============================================================================== --- vendor-sys/acpica/dist/source/tools/acpiexec/aemain.c Thu Apr 30 22:08:40 2020 (r360511) +++ vendor-sys/acpica/dist/source/tools/acpiexec/aemain.c Thu Apr 30 23:40:36 2020 (r360512) @@ -633,6 +633,7 @@ main ( ACPI_CHECK_OK (AcpiInitializeSubsystem, Status); if (ACPI_FAILURE (Status)) { + ExitCode = -1; goto ErrorExit; } @@ -646,6 +647,7 @@ main ( ACPI_CHECK_OK (AcpiInitializeDebugger, Status); if (ACPI_FAILURE (Status)) { + ExitCode = -1; goto ErrorExit; } @@ -707,6 +709,7 @@ main ( Status = AeBuildLocalTables (ListHead); if (ACPI_FAILURE (Status)) { + ExitCode = -1; goto ErrorExit; } @@ -743,8 +746,9 @@ main ( Status = AeLoadTables (); if (ACPI_FAILURE (Status)) { - ExitCode = -1; - goto ErrorExit; + printf ("**** Could not load ACPI tables, %s\n", + AcpiFormatException (Status)); + goto EnterDebugger; } /* @@ -754,13 +758,6 @@ main ( */ if (AcpiGbl_AeLoadOnly) { - goto EnterDebugger; - } - - if (ACPI_FAILURE (Status)) - { - printf ("**** Could not load ACPI tables, %s\n", - AcpiFormatException (Status)); goto EnterDebugger; } From owner-svn-src-vendor@freebsd.org Thu Apr 30 23:41:23 2020 Return-Path: Delivered-To: svn-src-vendor@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 999632CB8AB; Thu, 30 Apr 2020 23:41:23 +0000 (UTC) (envelope-from jkim@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 49CsN33cLGz4CZ1; Thu, 30 Apr 2020 23:41:23 +0000 (UTC) (envelope-from jkim@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 5E0BD26D92; Thu, 30 Apr 2020 23:41:23 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03UNfN6V082931; Thu, 30 Apr 2020 23:41:23 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03UNfNJL082930; Thu, 30 Apr 2020 23:41:23 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <202004302341.03UNfNJL082930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Thu, 30 Apr 2020 23:41:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r360513 - vendor-sys/acpica/20200430 X-SVN-Group: vendor-sys X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: vendor-sys/acpica/20200430 X-SVN-Commit-Revision: 360513 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2020 23:41:23 -0000 Author: jkim Date: Thu Apr 30 23:41:22 2020 New Revision: 360513 URL: https://svnweb.freebsd.org/changeset/base/360513 Log: Tag ACPICA 20200430. Added: vendor-sys/acpica/20200430/ - copied from r360512, vendor-sys/acpica/dist/