Merge ^/head r357931 through r357965.

This commit is contained in:
Dimitry Andric 2020-02-15 15:05:25 +00:00
commit dca7f66f43
61 changed files with 1109 additions and 510 deletions

View file

@ -5,7 +5,7 @@
pretty fast once you're done with this checklist.
01) Download the latest OpenSSH-portable tarball and signature from
OpenBSD (ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/).
OpenBSD (https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/).
02) Verify the signature:

View file

@ -1,6 +1,6 @@
# $FreeBSD$
Project: Portable OpenSSH
ProjectURL: http://www.openssh.com/portable.html
Version: 5.2p1
Version: 7.9p1
License: BSD
Maintainer: des

View file

@ -796,7 +796,7 @@ again:
PV_STAT(i = 0);
for (p = &pmap_invl_gen_head;; p = prev.next) {
PV_STAT(i++);
prevl = atomic_load_ptr(&p->next);
prevl = (uintptr_t)atomic_load_ptr(&p->next);
if ((prevl & PMAP_INVL_GEN_NEXT_INVALID) != 0) {
PV_STAT(atomic_add_long(&invl_start_restart, 1));
lock_delay(&lda);
@ -903,7 +903,7 @@ pmap_delayed_invl_finish_u(void)
again:
for (p = &pmap_invl_gen_head; p != NULL; p = (void *)prevl) {
prevl = atomic_load_ptr(&p->next);
prevl = (uintptr_t)atomic_load_ptr(&p->next);
if ((prevl & PMAP_INVL_GEN_NEXT_INVALID) != 0) {
PV_STAT(atomic_add_long(&invl_finish_restart, 1));
lock_delay(&lda);
@ -954,7 +954,7 @@ DB_SHOW_COMMAND(di_queue, pmap_di_queue)
for (p = &pmap_invl_gen_head, first = true; p != NULL; p = pn,
first = false) {
nextl = atomic_load_ptr(&p->next);
nextl = (uintptr_t)atomic_load_ptr(&p->next);
pn = (void *)(nextl & ~PMAP_INVL_GEN_NEXT_INVALID);
td = first ? NULL : __containerof(p, struct thread,
td_md.md_invl_gen);

View file

@ -932,7 +932,7 @@ trap_user_dtrace(struct trapframe *frame, int (**hookp)(struct trapframe *))
{
int (*hook)(struct trapframe *);
hook = (int (*)(struct trapframe *))atomic_load_ptr(hookp);
hook = atomic_load_ptr(hookp);
enable_intr();
if (hook != NULL)
return ((hook)(frame) == 0);
@ -1075,7 +1075,7 @@ amd64_syscall_ret_flush_l1d_check(int error)
if (error != EEXIST && error != EAGAIN && error != EXDEV &&
error != ENOENT && error != ENOTCONN && error != EINPROGRESS) {
p = (void *)atomic_load_ptr(&syscall_ret_l1d_flush);
p = atomic_load_ptr(&syscall_ret_l1d_flush);
if (p != NULL)
p();
}

View file

@ -547,7 +547,7 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc)
{
void *conf_table;
conf_table = (void *)atomic_load_ptr((uintptr_t *)&conf_base);
conf_table = atomic_load_ptr(&conf_base);
if (conf_table == NULL) {
conf_table = contigmalloc(LPI_CONFTAB_SIZE,
M_GICV3_ITS, M_WAITOK, 0, LPI_CONFTAB_MAX_ADDR,
@ -556,8 +556,7 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc)
if (atomic_cmpset_ptr((uintptr_t *)&conf_base,
(uintptr_t)NULL, (uintptr_t)conf_table) == 0) {
contigfree(conf_table, LPI_CONFTAB_SIZE, M_GICV3_ITS);
conf_table =
(void *)atomic_load_ptr((uintptr_t *)&conf_base);
conf_table = atomic_load_ptr(&conf_base);
}
}
sc->sc_conf_base = conf_table;

View file

@ -214,7 +214,7 @@ cloudabi_sys_file_open(struct thread *td,
fds.fs_rights_base | fds.fs_rights_inheriting, &rights);
if (error != 0)
return (error);
cap_rights_set(&rights, CAP_LOOKUP);
cap_rights_set_one(&rights, CAP_LOOKUP);
/* Convert rights to corresponding access mode. */
read = (fds.fs_rights_base & (CLOUDABI_RIGHT_FD_READ |
@ -227,7 +227,7 @@ cloudabi_sys_file_open(struct thread *td,
/* Convert open flags. */
if ((uap->oflags & CLOUDABI_O_CREAT) != 0) {
fflags |= O_CREAT;
cap_rights_set(&rights, CAP_CREATE);
cap_rights_set_one(&rights, CAP_CREATE);
}
if ((uap->oflags & CLOUDABI_O_DIRECTORY) != 0)
fflags |= O_DIRECTORY;
@ -235,7 +235,7 @@ cloudabi_sys_file_open(struct thread *td,
fflags |= O_EXCL;
if ((uap->oflags & CLOUDABI_O_TRUNC) != 0) {
fflags |= O_TRUNC;
cap_rights_set(&rights, CAP_FTRUNCATE);
cap_rights_set_one(&rights, CAP_FTRUNCATE);
}
if ((fds.fs_flags & CLOUDABI_FDFLAG_APPEND) != 0)
fflags |= O_APPEND;
@ -244,12 +244,12 @@ cloudabi_sys_file_open(struct thread *td,
if ((fds.fs_flags & (CLOUDABI_FDFLAG_SYNC | CLOUDABI_FDFLAG_DSYNC |
CLOUDABI_FDFLAG_RSYNC)) != 0) {
fflags |= O_SYNC;
cap_rights_set(&rights, CAP_FSYNC);
cap_rights_set_one(&rights, CAP_FSYNC);
}
if ((uap->dirfd.flags & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) == 0)
fflags |= O_NOFOLLOW;
if (write && (fflags & (O_APPEND | O_TRUNC)) == 0)
cap_rights_set(&rights, CAP_SEEK);
cap_rights_set_one(&rights, CAP_SEEK);
/* Allocate new file descriptor. */
error = falloc_noinstall(td, &fp);

View file

@ -1,3 +1,101 @@
----------------------------------------
14 February 2020. Summary of changes for version 20200214:
1) ACPICA kernel-resident subsystem:
Enable sleep button on ACPI legacy wake: Hibernation (S4) is triggered
in a guest when it receives a sleep trigger from the hypervisor. When the
guest resumes from this power state, it does not see the SleepEnabled
bit. In other words, the sleepHibernation (S4) is triggered in a guest
when it receives a sleep trigger from the hypervisor. When the guest
resumes from this power state, it does not see the SleepEnabled bit. In
other words, the sleep button is not enabled on waking from an S4 state.
This causes subsequent invocation of sleep state to fail since the
guest.button is not enabled on waking from an S4 state. This causes
subsequent invocation of sleep state to fail in the guest. Fix this
problem by enabling the sleep button in ACPI legacy wake. From Anchal
Agarwal <anchalag@amazon.com>.
Implemented a new external interface, AcpiAnyGpeStatusSet (). To be used
for checking the status bits of all enabled GPEs in one go. It is needed
to distinguish spurious SCIs from genuine ones when deciding whether or
not to wake up the system from suspend-to-idle.
Generic Makefiles: replace HOST name with ACPI_HOST: Some machines may be
using HOST in their environment to represent the host name for their
machines. Avoid this problem by renaming this variable from HOST to
ACPI_HOST.
MSVC 2017 project files: Enable multiprocessor generation to improve
build performance.
Added a macro to get the byte width of a Generic Address structure. New
ACPI_ACCESS_BYTE_WIDTH is in addition to the existing
ACPI_ACCESS_BIT_WIDTH. From Mika Westerberg.
2) iASL Compiler/Disassembler and ACPICA tools:
iASL: Implemented full support for the (optional, rarely used) ReturnType
and ParameterTypesList for the Method, Function, and External operators.
For Method declarations, the number of individual ParameterTypes must
match the declaration of the number of arguments (NumArgs). This also
Fixes a problem with the External operator where extra/extraneous bytes
were emitted in the AML code if the optional ReturnType/ParameterTypes
were specified for a MethodObj declaration.
New error message:
1) Method NumArgs count does not match length of ParameterTypes list
iASL: Implemented detection of type mismatches between External
declarations and named object declarations. Also, detect type mismatches
between multiple External declarations of the same Name.
New error messages:
1) Type mismatch between external declaration and actual object
declaration detected
2) Type mismatch between multiple external declarations detected
iASL: Implemented new error messages for External operators that specify
a ReturnType and/or ParameterTypesList for any object type other than
control methods (MethodObj).
New error messages:
1) Return type is only allowed for Externals declared as MethodObj
2) Parameter type is only allowed for Externals declared as MethodObj
iASL: Implemented two new remark/warning messages for ASL code that
creates named objects from within a control method. This is very
inefficient since the named object must be created and deleted each time
the method is executed.
New messages:
1) Creation of named objects within a method is highly inefficient, use
globals or method local variables instead (remark)
2) Static OperationRegion should be declared outside control method
(warning)
iASL: Improved illegal forward reference detection by adding support to
detect forward-reference method invocations.
iASL: Detect and issue an error message for NameStrings that contain too
many individual NameSegs (>255). This is an AML limitation that is
defined in the ACPI specification.
New message:
1) NameString contains too many NameSegs (>255)
acpidump: windows: use GetSystemFirmwareTable API for all tables except
SSDT. By using this API, acpidump is able to get all tables in the XSDT
iASL: Removed unused parser file and updated msvc2017 project files.
Removed the obsolete AslCompiler.y from the repository.
iASL: msvc2017: Fixed macros in the file dependency list to prevent
unnecessary rebuilds. Replace %(Directory) with %(RelativeDir).
Disassembler: Prevent spilling error messages to the output file. All
errors are directed to the console instead. These error messages
prevented re-compilation of the resulting disassembled ASL output file
(.DSL).
----------------------------------------
10 January 2020. Summary of changes for version 20200110:
@ -8845,8 +8943,8 @@ much larger code and data size.
Fix build error under Bison-2.4.
Dissasembler: Enhanced FADT support. Added decoding of the Boot
Architecture
Disassembler: Enhanced FADT support. Added decoding of the Boot
Architecture
flags. Now decode all flags, regardless of the FADT version. Flag output
includes the FADT version which first defined each flag.

View file

@ -156,6 +156,7 @@
#include <contrib/dev/acpica/include/acnamesp.h>
#include <contrib/dev/acpica/include/acparser.h>
#include <contrib/dev/acpica/include/acapps.h>
#include <contrib/dev/acpica/include/acconvert.h>
#define _COMPONENT ACPI_TOOLS
@ -379,8 +380,6 @@ AdAmlDisassemble (
Status = AE_ERROR;
goto Cleanup;
}
AcpiOsRedirectOutput (File);
}
*OutFilename = DisasmFilename;
@ -467,6 +466,11 @@ AdDisassembleOneTable (
if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
{
if (File)
{
AcpiOsRedirectOutput (File);
}
AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
/* This is a "Data Table" (non-AML table) */
@ -489,6 +493,10 @@ AdDisassembleOneTable (
return (AE_OK);
}
/* Initialize the converter output file */
ASL_CV_INIT_FILETREE(Table, File);
/*
* This is an AML table (DSDT or SSDT).
* Always parse the tables, only option is what to display
@ -501,6 +509,13 @@ AdDisassembleOneTable (
return (Status);
}
/* Redirect output for code generation and debugging output */
if (File)
{
AcpiOsRedirectOutput (File);
}
/* Debug output, namespace and parse tree */
if (AslCompilerdebug && File)

View file

@ -506,7 +506,6 @@ AdParseTable (
AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
ASL_CV_INIT_FILETREE(Table, AmlStart, AmlLength);
AcpiUtSetIntegerWidth (Table->Revision);

View file

@ -151,6 +151,7 @@
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include "aslcompiler.y.h"
#include <contrib/dev/acpica/include/acnamesp.h>
#include <string.h>
@ -421,6 +422,7 @@ AnCheckMethodReturnValue (
{
ACPI_PARSE_OBJECT *OwningOp;
ACPI_NAMESPACE_NODE *Node;
char *ExternalPath;
Node = ArgOp->Asl.Node;
@ -435,18 +437,19 @@ AnCheckMethodReturnValue (
/* Examine the parent op of this method */
OwningOp = Node->Op;
ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE);
if (OwningOp->Asl.CompileFlags & OP_METHOD_NO_RETVAL)
{
/* Method NEVER returns a value */
AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName);
AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, ExternalPath);
}
else if (OwningOp->Asl.CompileFlags & OP_METHOD_SOME_NO_RETVAL)
{
/* Method SOMETIMES returns a value, SOMETIMES not */
AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL,
Op, Op->Asl.ExternalName);
AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, ExternalPath);
}
else if (!(ThisNodeBtype & RequiredBtypes))
{
@ -470,6 +473,11 @@ AnCheckMethodReturnValue (
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, AslGbl_MsgBuffer);
}
}
if (ExternalPath)
{
ACPI_FREE (ExternalPath);
}
}

View file

@ -647,7 +647,7 @@ void
AslCompilerFileHeader (
UINT32 FileId)
{
struct tm *NewTime;
char *NewTime;
time_t Aclock;
char *Prefix = "";
@ -691,13 +691,17 @@ AslCompilerFileHeader (
/* Compilation header with timestamp */
(void) time (&Aclock);
NewTime = localtime (&Aclock);
Aclock = time (NULL);
NewTime = ctime (&Aclock);
FlPrintFile (FileId,
"%sCompilation of \"%s\" - %s%s\n",
Prefix, AslGbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
Prefix);
"%sCompilation of \"%s\" -",
Prefix, AslGbl_Files[ASL_FILE_INPUT].Filename);
if (NewTime)
{
FlPrintFile (FileId, " %s%s\n", NewTime, Prefix);
}
switch (FileId)
{

View file

@ -373,6 +373,15 @@ MtMethodAnalysisWalkEnd (
UINT32 Level,
void *Context);
UINT32
MtProcessTypeOp (
ACPI_PARSE_OBJECT *TypeOp);
UINT8
MtProcessParameterTypeList (
ACPI_PARSE_OBJECT *ParamTypeOp,
UINT32 *TypeList);
/*
* aslbtypes - bitfield data types
@ -1233,10 +1242,14 @@ UtDumpBasicOp (
ACPI_PARSE_OBJECT *Op,
UINT32 Level);
void *
UtGetParentMethod (
ACPI_NAMESPACE_NODE *
UtGetParentMethodNode (
ACPI_NAMESPACE_NODE *Node);
ACPI_PARSE_OBJECT *
UtGetParentMethodOp (
ACPI_PARSE_OBJECT *Op);
BOOLEAN
UtNodeIsDescendantOf (
ACPI_NAMESPACE_NODE *Node1,

View file

@ -192,12 +192,54 @@ ExDoExternal (
ACPI_PARSE_OBJECT *Prev;
ACPI_PARSE_OBJECT *Next;
ACPI_PARSE_OBJECT *ArgCountOp;
ACPI_PARSE_OBJECT *TypeOp;
ACPI_PARSE_OBJECT *ExternTypeOp = Op->Asl.Child->Asl.Next;
UINT32 ExternType;
UINT8 ParamCount = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS;
UINT32 ParamTypes[ACPI_METHOD_NUM_ARGS];
ExternType = AnMapObjTypeToBtype (ExternTypeOp);
/*
* The parser allows optional parameter return types regardless of the
* type. Check object type keyword emit error if optional parameter/return
* types exist.
*
* Check the parameter return type
*/
TypeOp = ExternTypeOp->Asl.Next;
if (TypeOp->Asl.Child)
{
/* Ignore the return type for now. */
(void) MtProcessTypeOp (TypeOp->Asl.Child);
if (ExternType != ACPI_BTYPE_METHOD)
{
sprintf (AslGbl_MsgBuffer, "Found type [%s]", AcpiUtGetTypeName(ExternType));
AslError (ASL_ERROR, ASL_MSG_EXTERN_INVALID_RET_TYPE, TypeOp,
AslGbl_MsgBuffer);
}
}
/* Check the parameter types */
TypeOp = TypeOp->Asl.Next;
if (TypeOp->Asl.Child)
{
ParamCount = MtProcessParameterTypeList (TypeOp->Asl.Child, ParamTypes);
if (ExternType != ACPI_BTYPE_METHOD)
{
sprintf (AslGbl_MsgBuffer, "Found type [%s]", AcpiUtGetTypeName(ExternType));
AslError (ASL_ERROR, ASL_MSG_EXTERN_INVALID_PARAM_TYPE, TypeOp,
AslGbl_MsgBuffer);
}
}
ArgCountOp = Op->Asl.Child->Asl.Next->Asl.Next;
ArgCountOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST;
ArgCountOp->Asl.Value.Integer = 0;
ArgCountOp->Asl.Value.Integer = ParamCount;
UtSetParseOpName (ArgCountOp);
/* Create new list node of arbitrary type */

View file

@ -196,6 +196,15 @@ LdCheckSpecialNames (
ACPI_NAMESPACE_NODE *Node,
ACPI_PARSE_OBJECT *Op);
static ACPI_STATUS
LdAnalyzeExternals (
ACPI_NAMESPACE_NODE *Node,
ACPI_PARSE_OBJECT *Op,
ACPI_OBJECT_TYPE ExternalOpType,
ACPI_OBJECT_TYPE ObjectType,
ACPI_WALK_STATE *WalkState);
/*******************************************************************************
*
* FUNCTION: LdLoadNamespace
@ -575,7 +584,8 @@ LdNamespace1Begin (
/* Check for a possible illegal forward reference */
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
{
/*
* Op->Asl.Namepath will be NULL for these opcodes.
@ -591,7 +601,8 @@ LdNamespace1Begin (
* We only want references to named objects:
* Store (2, WXYZ) -> Attempt to resolve the name
*/
if (OpInfo->Class == AML_CLASS_NAMED_OBJECT)
if ((Op->Asl.ParseOpcode != PARSEOP_METHODCALL) &&
(OpInfo->Class == AML_CLASS_NAMED_OBJECT))
{
return (AE_OK);
}
@ -899,56 +910,24 @@ LdNamespace1Begin (
Node->Type = (UINT8) ObjectType;
Status = AE_OK;
}
else if ((Node->Flags & ANOBJ_IS_EXTERNAL) &&
(Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
{
/*
* Allow one create on an object or segment that was
* previously declared External
*/
Node->Flags &= ~ANOBJ_IS_EXTERNAL;
Node->Type = (UINT8) ObjectType;
/* Just retyped a node, probably will need to open a scope */
if (AcpiNsOpensScope (ObjectType))
{
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
Status = AE_OK;
}
else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) &&
else if ((Node->Flags & ANOBJ_IS_EXTERNAL) ||
(Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
{
/*
* Allow externals in same scope as the definition of the
* actual object. Similar to C. Allows multiple definition
* blocks that refer to each other in the same file.
*/
Status = AE_OK;
}
else if ((Node->Flags & ANOBJ_IS_EXTERNAL) &&
(Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) &&
(ObjectType == ACPI_TYPE_ANY))
{
/* Allow update of externals of unknown type. */
if (AcpiNsOpensScope (ActualObjectType))
Status = LdAnalyzeExternals (Node, Op, ActualObjectType,
ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
Node->Type = (UINT8) ActualObjectType;
Status = AE_OK;
}
else
{
sprintf (AslGbl_MsgBuffer, "%s [%s]", Op->Asl.ExternalName,
AcpiUtGetTypeName (Node->Type));
AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer);
return_ACPI_STATUS (AE_OK);
if (Status == AE_ERROR)
{
/*
* The use of AE_ERROR here indicates that there was a
* compiler error emitted in LdAnalyzeExternals which
* means that the caller should proceed to the next Op
* for analysis of subsequent parse objects.
*/
Status = AE_OK;
}
return_ACPI_STATUS (Status);
}
}
else
@ -1013,15 +992,17 @@ FinishNode:
* 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
* unknown setting Node->Value to ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS
* indicates that the parameter count for this method is unknown.
* This information is used in ASL cross reference to help determine the
* parameter count through method calls.
* 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 = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS;
Node->Value = (UINT32)
Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer;
}
if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
@ -1037,6 +1018,145 @@ FinishNode:
}
/*******************************************************************************
*
* FUNCTION: LdAnalyzeExternals
*
* 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
*
* DESCRIPTION: Node and Op represents an identically named object declaration
* that is either declared by the ASL external keyword or declared
* by operators that declare named objects (i.e. Name, Device,
* OperationRegion, and etc.). This function ensures that the
* declarations do not contradict each other.
*
******************************************************************************/
static ACPI_STATUS
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;
ACPI_OBJECT_TYPE ActualExternalOpType;
ACPI_OBJECT_TYPE ActualOpType;
ACPI_PARSE_OBJECT *ExternalOp;
ACPI_PARSE_OBJECT *ActualOp;
/*
* The declaration represented by Node and Op must have the same type.
* The type of the external Op is represented by ExternalOpType. However,
* the type of the pre-existing declaration depends on whether if Op
* is an external declaration or an actual declaration.
*/
if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)
{
ActualExternalOpType = ExternalOpType;
ActualOpType = Node->Type;
}
else
{
ActualExternalOpType = Node->Type;
ActualOpType = ObjectType;
}
if ((ActualOpType != ACPI_TYPE_ANY) &&
(ActualExternalOpType != ACPI_TYPE_ANY) &&
(ActualExternalOpType != ActualOpType))
{
if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL &&
Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)
{
AslDualParseOpError (ASL_ERROR,
ASL_MSG_DUPLICATE_EXTERN_MISMATCH, Op, NULL,
ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, Node->Op, NULL);
}
else
{
if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL &&
Node->Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)
{
ExternalOp = Op;
ActualOp = Node->Op;
}
else
{
ExternalOp = Node->Op;
ActualOp = Op;
}
AslDualParseOpError (ASL_ERROR,
ASL_MSG_DECLARATION_TYPE_MISMATCH, ExternalOp, NULL,
ASL_MSG_TYPE_MISMATCH_FOUND_HERE, ActualOp, NULL);
}
}
if ((Node->Flags & ANOBJ_IS_EXTERNAL) &&
(Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
{
/*
* Allow one create on an object or segment that was
* previously declared External
*/
Node->Flags &= ~ANOBJ_IS_EXTERNAL;
Node->Type = (UINT8) ObjectType;
/* Just retyped a node, probably will need to open a scope */
if (AcpiNsOpensScope (ObjectType))
{
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
Status = AE_OK;
}
else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) &&
(Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
{
/*
* Allow externals in same scope as the definition of the
* actual object. Similar to C. Allows multiple definition
* blocks that refer to each other in the same file.
*/
Status = AE_OK;
}
else if ((Node->Flags & ANOBJ_IS_EXTERNAL) &&
(Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) &&
(ObjectType == ACPI_TYPE_ANY))
{
/* Allow update of externals of unknown type. */
if (AcpiNsOpensScope (ExternalOpType))
{
Node->Type = (UINT8) ExternalOpType;
Status = AE_OK;
}
else
{
sprintf (AslGbl_MsgBuffer, "%s [%s]", Op->Asl.ExternalName,
AcpiUtGetTypeName (Node->Type));
AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer);
Status = AE_ERROR;
}
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: LdCheckSpecialNames

View file

@ -320,7 +320,7 @@ const char *AslCompilerMsgs [] =
/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator",
/* ASL_MSG_SEEK */ "Could not seek file",
/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized",
/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized",
/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized due to creation of named objects within",
/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)",
/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value",
/* ASL_MSG_STRING_LENGTH */ "String literal too long",
@ -370,7 +370,16 @@ const char *AslCompilerMsgs [] =
/* ASL_MSG_INVALID_PROCESSOR_UID */ "_UID inside processor declaration must be an integer",
/* ASL_MSG_LEGACY_PROCESSOR_OP */ "Legacy Processor() keyword detected. Use Device() keyword instead.",
/* ASL_MSG_NAMESTRING_LENGTH */ "NameString contains too many NameSegs (>255)",
/* ASL_MSG_CASE_FOUND_HERE */ "Original Case value below:"
/* ASL_MSG_CASE_FOUND_HERE */ "Original Case value below:",
/* ASL_MSG_EXTERN_INVALID_RET_TYPE */ "Return type is only allowed for Externals declared as MethodObj",
/* ASL_MSG_EXTERN_INVALID_PARAM_TYPE */ "Parameter type is only allowed for Externals declared as MethodObj",
/* ASL_MSG_NAMED_OBJECT_CREATION */ "Creation of named objects within a method is highly inefficient, use globals or method local variables instead",
/* ASL_MSG_ARG_COUNT_MISMATCH */ "Method NumArgs count does not match length of ParameterTypes list",
/* ASL_MSG_STATIC_OPREGION_IN_METHOD */ "Static OperationRegion should be declared outside control method",
/* ASL_MSG_DECLARATION_TYPE_MISMATCH */ "Type mismatch between external declaration and actual object declaration detected",
/* 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:",
};
/* Table compiler */

View file

@ -373,6 +373,16 @@ typedef enum
ASL_MSG_LEGACY_PROCESSOR_OP,
ASL_MSG_NAMESTRING_LENGTH,
ASL_MSG_CASE_FOUND_HERE,
ASL_MSG_EXTERN_INVALID_RET_TYPE,
ASL_MSG_EXTERN_INVALID_PARAM_TYPE,
ASL_MSG_NAMED_OBJECT_CREATION,
ASL_MSG_ARG_COUNT_MISMATCH,
ASL_MSG_STATIC_OPREGION_IN_METHOD,
ASL_MSG_DECLARATION_TYPE_MISMATCH,
ASL_MSG_TYPE_MISMATCH_FOUND_HERE,
ASL_MSG_DUPLICATE_EXTERN_MISMATCH,
ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE,
/* These messages are used by the Data Table compiler only */

View file

@ -151,6 +151,7 @@
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include "aslcompiler.y.h"
#include <contrib/dev/acpica/include/acnamesp.h>
#include <contrib/dev/acpica/include/acparser.h>
#include <contrib/dev/acpica/include/amlcode.h>
@ -166,6 +167,10 @@ MtCheckNamedObjectInMethod (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo);
static void
MtCheckStaticOperationRegionInMethod (
ACPI_PARSE_OBJECT *Op);
/*******************************************************************************
*
@ -197,7 +202,6 @@ MtMethodAnalysisWalkBegin (
char ArgName[] = "Arg0";
ACPI_PARSE_OBJECT *ArgNode;
ACPI_PARSE_OBJECT *NextType;
ACPI_PARSE_OBJECT *NextParamType;
UINT8 ActualArgs = 0;
BOOLEAN HidExists;
BOOLEAN AdrExists;
@ -282,50 +286,35 @@ MtMethodAnalysisWalkBegin (
Next = Next->Asl.Next;
NextType = Next->Asl.Child;
while (NextType)
{
/* Get and map each of the ReturnTypes */
MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType);
NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
NextType = NextType->Asl.Next;
}
MethodInfo->ValidReturnTypes = MtProcessTypeOp (NextType);
/* Get the ParameterType node */
Next = Next->Asl.Next;
NextType = Next->Asl.Child;
while (NextType)
if (!NextType)
{
if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
NextParamType = NextType->Asl.Child;
while (NextParamType)
{
MethodInfo->ValidArgTypes[ActualArgs] |=
AnMapObjTypeToBtype (NextParamType);
NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
NextParamType = NextParamType->Asl.Next;
}
}
else
{
MethodInfo->ValidArgTypes[ActualArgs] =
AnMapObjTypeToBtype (NextType);
NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
ActualArgs++;
}
NextType = NextType->Asl.Next;
/*
* The optional parameter types list was omitted at the source
* level. Use the Argument count parameter instead.
*/
ActualArgs = MethodInfo->NumArguments;
}
else
{
ActualArgs = MtProcessParameterTypeList (NextType,
MethodInfo->ValidArgTypes);
}
if ((MethodInfo->NumArguments) &&
(MethodInfo->NumArguments != ActualArgs))
{
/* error: Param list did not match number of args */
sprintf (AslGbl_MsgBuffer,
"Length = %u", ActualArgs);
AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_MISMATCH,
Op->Asl.Child->Asl.Next, AslGbl_MsgBuffer);
}
/* Allow numarguments == 0 for Function() */
@ -576,6 +565,8 @@ MtMethodAnalysisWalkBegin (
AslError (ASL_ERROR, ASL_MSG_RESERVED_USE,
Op, Op->Asl.ExternalName);
}
MtCheckStaticOperationRegionInMethod (Op);
break;
case PARSEOP_NAME:
@ -628,6 +619,71 @@ MtMethodAnalysisWalkBegin (
}
/*******************************************************************************
*
* FUNCTION: MtProcessTypeOp
*
* PARAMETERS: Op - Op representing a btype
*
* RETURN: Btype represented by Op
*
* DESCRIPTION: Process a parse object that represents single parameter type or
* a return type in method, function, and external declarations.
*
******************************************************************************/
UINT32
MtProcessTypeOp (
ACPI_PARSE_OBJECT *TypeOp)
{
UINT32 Btype = ACPI_BTYPE_ANY;
while (TypeOp)
{
Btype |= AnMapObjTypeToBtype (TypeOp);
TypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
TypeOp = TypeOp->Asl.Next;
}
return (Btype);
}
/*******************************************************************************
*
* FUNCTION: MtProcessParameterTypeList
*
* PARAMETERS: Op - Op representing a btype
*
* RETURN: Btype represented by Op
*
* DESCRIPTION: Process a parse object that represents a parameter type list in
* method, function, and external declarations.
*
******************************************************************************/
UINT8
MtProcessParameterTypeList (
ACPI_PARSE_OBJECT *ParamTypeOp,
UINT32 *TypeList)
{
UINT8 ParameterCount = 0;
while (ParamTypeOp)
{
TypeList[ParameterCount] =
MtProcessTypeOp (ParamTypeOp->Asl.Child);
ParameterCount++;
ParamTypeOp = ParamTypeOp->Asl.Next;
}
return (ParameterCount);
}
/*******************************************************************************
*
* FUNCTION: MtCheckNamedObjectInMethod
@ -649,6 +705,7 @@ MtCheckNamedObjectInMethod (
ASL_METHOD_INFO *MethodInfo)
{
const ACPI_OPCODE_INFO *OpInfo;
char *ExternalPath;
/* We don't care about actual method declarations or scopes */
@ -672,27 +729,97 @@ MtCheckNamedObjectInMethod (
/*
* 1) Mark the method as a method that creates named objects.
*
* 2) If the method is non-serialized, emit a remark that the method
* 2) Issue a remark indicating the inefficiency of creating named
* objects within a method (Except for compiler-emitted temporary
* variables).
*
* 3) If the method is non-serialized, emit a remark that the method
* should be serialized.
*
* Reason: If a thread blocks within the method for any reason, and
* another thread enters the method, the method will fail because
* an attempt will be made to create the same object twice.
*/
ExternalPath = AcpiNsGetNormalizedPathname (MethodInfo->Op->Asl.Node, TRUE);
/* No error for compiler temp variables (name starts with "_T_") */
if ((Op->Asl.NameSeg[0] != '_') &&
(Op->Asl.NameSeg[1] != 'T') &&
(Op->Asl.NameSeg[2] != '_'))
{
AslError (ASL_REMARK, ASL_MSG_NAMED_OBJECT_CREATION, Op,
ExternalPath);
}
MethodInfo->CreatesNamedObjects = TRUE;
if (!MethodInfo->ShouldBeSerialized)
{
AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op,
"due to creation of named objects within");
ExternalPath);
/* Emit message only ONCE per method */
MethodInfo->ShouldBeSerialized = TRUE;
}
if (ExternalPath)
{
ACPI_FREE (ExternalPath);
}
}
}
/*******************************************************************************
*
* FUNCTION: MtCheckStaticOperationRegionInMethod
*
* PARAMETERS: Op - Current parser op
*
* RETURN: None
*
* DESCRIPTION: Warns if an Operation Region with static address or length
* is declared inside a control method
*
******************************************************************************/
static void
MtCheckStaticOperationRegionInMethod(
ACPI_PARSE_OBJECT* Op)
{
ACPI_PARSE_OBJECT* AddressOp;
ACPI_PARSE_OBJECT* LengthOp;
if (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION)
{
return;
}
/*
* OperationRegion should have 4 arguments defined. At this point, we
* assume that the parse tree is well-formed.
*/
AddressOp = Op->Asl.Child->Asl.Next->Asl.Next;
LengthOp = Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next;
if (UtGetParentMethodOp (Op) &&
AddressOp->Asl.ParseOpcode == PARSEOP_INTEGER &&
LengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)
{
/*
* At this point, a static operation region declared inside of a
* control method has been found. Throw a warning because this is
* highly inefficient.
*/
AslError(ASL_WARNING, ASL_MSG_STATIC_OPREGION_IN_METHOD, Op, NULL);
}
return;
}
/*******************************************************************************
*
* FUNCTION: MtMethodAnalysisWalkEnd
@ -714,6 +841,7 @@ MtMethodAnalysisWalkEnd (
{
ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;
ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack;
char *ExternalPath;
switch (Op->Asl.ParseOpcode)
@ -766,8 +894,15 @@ MtMethodAnalysisWalkEnd (
if (MethodInfo->NumReturnNoValue &&
MethodInfo->NumReturnWithValue)
{
ExternalPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE);
AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op,
Op->Asl.ExternalName);
ExternalPath);
if (ExternalPath)
{
ACPI_FREE (ExternalPath);
}
}
/*

View file

@ -743,13 +743,18 @@ TrCreateConstantLeafOp (
/* Get a copy of the current time */
Op->Asl.Value.String = "";
CurrentTime = time (NULL);
StaticTimeString = ctime (&CurrentTime);
TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1);
strcpy (TimeString, StaticTimeString);
TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */
Op->Asl.Value.String = TimeString;
StaticTimeString = ctime (&CurrentTime);
if (StaticTimeString)
{
TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1);
strcpy (TimeString, StaticTimeString);
TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */
Op->Asl.Value.String = TimeString;
}
break;
default: /* This would be an internal error */

View file

@ -663,7 +663,7 @@ FunctionTerm
PARSEOP_CLOSE_PAREN '{' {COMMENT_CAPTURE_ON; }
TermList '}' {$$ = TrLinkOpChildren ($<n>3,7,
TrSetOpFlags ($4, OP_IS_NAME_DECLARATION),
TrCreateValuedLeafOp (PARSEOP_BYTECONST, 0),
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),
TrCreateLeafOp (PARSEOP_SERIALIZERULE_NOTSERIAL),
TrCreateValuedLeafOp (PARSEOP_BYTECONST, 0),$5,$6,$10);}
| PARSEOP_FUNCTION

View file

@ -421,14 +421,16 @@ ParameterTypePackage
ParameterTypePackageList
: {$$ = NULL;}
| ObjectTypeKeyword {$$ = $1;}
| '{' ParameterTypePackage '}' {$$ = $2;}
| ObjectTypeKeyword {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);}
| '{' ParameterTypePackage '}' {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
;
OptionalParameterTypePackage
: {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);}
| ',' ParameterTypePackageList {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
: {$$ = NULL;}
| ',' ParameterTypePackageList {$$ = $2;}
;
/* Rules for specifying the types for method arguments */
@ -441,14 +443,15 @@ ParameterTypesPackage
ParameterTypesPackageList
: {$$ = NULL;}
| ObjectTypeKeyword {$$ = $1;}
| '{' ParameterTypesPackage '}' {$$ = $2;}
| ObjectTypeKeyword {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);}
| '{' ParameterTypesPackage '}' {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
;
OptionalParameterTypesPackage
: {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);}
| ',' ParameterTypesPackageList {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
: {$$ = NULL;}
| ',' ParameterTypesPackageList {$$ = $2;}
;
/*

View file

@ -205,6 +205,10 @@ TrCheckForBufferMatch (
ACPI_PARSE_OBJECT *Next1,
ACPI_PARSE_OBJECT *Next2);
static void
TrDoMethod (
ACPI_PARSE_OBJECT *Op);
/*******************************************************************************
*
@ -463,11 +467,8 @@ TrTransformSubtree (
break;
case PARSEOP_METHOD:
/*
* TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global,
* however
*/
AslGbl_TempCount = 0;
TrDoMethod (Op);
break;
case PARSEOP_EXTERNAL:
@ -1240,3 +1241,76 @@ TrCheckForBufferMatch (
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: TrDoMethod
*
* PARAMETERS: Op - Parse node for SWITCH
*
* RETURN: None
*
* DESCRIPTION: Determine that parameter count of an ASL method node by
* translating the parameter count parse node from
* PARSEOP_DEFAULT_ARG to PARSEOP_BYTECONST.
*
******************************************************************************/
static void
TrDoMethod (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *ArgCountOp;
UINT8 ArgCount;
ACPI_PARSE_OBJECT *ParameterOp;
/*
* TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global,
* however
*/
AslGbl_TempCount = 0;
ArgCountOp = Op->Asl.Child->Asl.Next;
if (ArgCountOp->Asl.ParseOpcode == PARSEOP_BYTECONST)
{
/*
* Parameter count for this method has already been recorded in the
* method declaration.
*/
return;
}
/*
* Parameter count has been omitted in the method declaration.
* Count the amount of arguments here.
*/
ParameterOp = ArgCountOp->Asl.Next->Asl.Next->Asl.Next->Asl.Next;
if (ParameterOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
ArgCount = 0;
ParameterOp = ParameterOp->Asl.Child;
while (ParameterOp)
{
ParameterOp = ParameterOp->Asl.Next;
ArgCount++;
}
ArgCountOp->Asl.Value.Integer = ArgCount;
ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST;
}
else
{
/*
* Method parameters can be counted by analyzing the Parameter type
* list. If the Parameter list contains more than 1 parameter, it
* is nested under PARSEOP_DEFAULT_ARG. When there is only 1
* parameter, the parse tree contains a single node representing
* that type.
*/
ArgCountOp->Asl.Value.Integer = 1;
ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST;
}
}

View file

@ -298,7 +298,7 @@ UtNodeIsDescendantOf (
/*******************************************************************************
*
* FUNCTION: UtGetParentMethod
* FUNCTION: UtGetParentMethodNode
*
* PARAMETERS: Node - Namespace node for any object
*
@ -309,8 +309,8 @@ UtNodeIsDescendantOf (
*
******************************************************************************/
void *
UtGetParentMethod (
ACPI_NAMESPACE_NODE *
UtGetParentMethodNode (
ACPI_NAMESPACE_NODE *Node)
{
ACPI_NAMESPACE_NODE *ParentNode;
@ -338,6 +338,41 @@ UtGetParentMethod (
}
/*******************************************************************************
*
* FUNCTION: UtGetParentMethodOp
*
* PARAMETERS: Op - Parse Op to be checked
*
* RETURN: Control method Op if found. NULL otherwise
*
* DESCRIPTION: Find the control method parent of a parse op. Returns NULL if
* the input Op is not within a control method.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
UtGetParentMethodOp (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *NextOp;
NextOp = Op->Asl.Parent;
while (NextOp)
{
if (NextOp->Asl.AmlOpcode == AML_METHOD_OP)
{
return (NextOp);
}
NextOp = NextOp->Asl.Parent;
}
return (NULL); /* No parent method found */
}
/*******************************************************************************
*
* FUNCTION: UtDisplaySupportedTables

View file

@ -180,10 +180,6 @@ XfValidateCrossReference (
const ACPI_OPCODE_INFO *OpInfo,
ACPI_NAMESPACE_NODE *Node);
static ACPI_PARSE_OBJECT *
XfGetParentMethod (
ACPI_PARSE_OBJECT *Op);
static BOOLEAN
XfObjectExists (
char *Name);
@ -380,41 +376,6 @@ XfCheckFieldRange (
}
/*******************************************************************************
*
* FUNCTION: XfGetParentMethod
*
* PARAMETERS: Op - Parse Op to be checked
*
* RETURN: Control method Op if found. NULL otherwise
*
* DESCRIPTION: Find the control method parent of a parse op. Returns NULL if
* the input Op is not within a control method.
*
******************************************************************************/
static ACPI_PARSE_OBJECT *
XfGetParentMethod (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *NextOp;
NextOp = Op->Asl.Parent;
while (NextOp)
{
if (NextOp->Asl.AmlOpcode == AML_METHOD_OP)
{
return (NextOp);
}
NextOp = NextOp->Asl.Parent;
}
return (NULL); /* No parent method found */
}
/*******************************************************************************
*
* FUNCTION: XfNamespaceLocateBegin
@ -539,7 +500,7 @@ XfNamespaceLocateBegin (
{
/* Find parent method Op */
NextOp = XfGetParentMethod (Op);
NextOp = UtGetParentMethodOp (Op);
if (!NextOp)
{
return_ACPI_STATUS (AE_OK);
@ -576,7 +537,7 @@ XfNamespaceLocateBegin (
{
/* Find parent method Op */
NextOp = XfGetParentMethod (Op);
NextOp = UtGetParentMethodOp (Op);
if (!NextOp)
{
return_ACPI_STATUS (AE_OK);
@ -814,10 +775,10 @@ XfNamespaceLocateBegin (
* same method or outside of any method, this is a forward reference
* and should be reported as a compiler error.
*/
DeclarationParentMethod = UtGetParentMethod (Node);
ReferenceParentMethod = XfGetParentMethod (Op);
DeclarationParentMethod = UtGetParentMethodNode (Node);
ReferenceParentMethod = UtGetParentMethodOp (Op);
/* case 1: declaration and refrence are both outside of method */
/* case 1: declaration and reference are both outside of method */
if (!ReferenceParentMethod && !DeclarationParentMethod)
{
@ -1337,8 +1298,8 @@ XfNamespaceLocateEnd (
* execution of A)
*
* NOTES:
* A null pointer returned by either XfGetParentMethod or
* UtGetParentMethod indicates that the parameter object is not
* A null pointer returned by either UtGetParentMethodOp or
* UtGetParentMethodNode indicates that the parameter object is not
* within a control method.
*
* Five cases are handled: Case(Op, Node)
@ -1371,8 +1332,8 @@ XfValidateCrossReference (
* 1) Search upwards in parse tree for owner of the referencing object
* 2) Search upwards in namespace to find the owner of the referenced object
*/
ReferencingMethodOp = XfGetParentMethod (Op);
ReferencedMethodNode = UtGetParentMethod (Node);
ReferencingMethodOp = UtGetParentMethodOp (Op);
ReferencedMethodNode = UtGetParentMethodNode (Node);
if (!ReferencingMethodOp && !ReferencedMethodNode)
{

View file

@ -230,8 +230,7 @@ CvIsFilename (
* FUNCTION: CvInitFileTree
*
* PARAMETERS: Table - input table
* AmlStart - Address of the starting point of the AML.
* AmlLength - Length of the AML file.
* RootFile - Output file that defines the DefinitionBlock
*
* RETURN: None
*
@ -243,8 +242,7 @@ CvIsFilename (
void
CvInitFileTree (
ACPI_TABLE_HEADER *Table,
UINT8 *AmlStart,
UINT32 AmlLength)
FILE *RootFile)
{
UINT8 *TreeAml;
UINT8 *FileEnd;
@ -252,6 +250,8 @@ CvInitFileTree (
char *PreviousFilename = NULL;
char *ParentFilename = NULL;
char *ChildFilename = NULL;
UINT8 *AmlStart;
UINT32 AmlLength;
if (!AcpiGbl_CaptureComments)
@ -259,9 +259,13 @@ CvInitFileTree (
return;
}
AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
CvDbgPrint ("AmlLength: %x\n", AmlLength);
CvDbgPrint ("AmlStart: %p\n", AmlStart);
CvDbgPrint ("AmlEnd?: %p\n", AmlStart+AmlLength);
CvDbgPrint ("AmlEnd: %p\n", AmlStart+AmlLength);
AcpiGbl_FileTreeRoot = AcpiOsAcquireObject (AcpiGbl_FileCache);
@ -273,7 +277,7 @@ CvInitFileTree (
/* Set the root file to the current open file */
AcpiGbl_FileTreeRoot->File = AcpiGbl_OutputFile;
AcpiGbl_FileTreeRoot->File = RootFile;
/*
* Set this to true because we don't need to output

View file

@ -299,7 +299,7 @@ AcpiEvFixedEventInitialize (
/*
* Initialize the structure that keeps track of fixed event handlers and
* enable the fixed events.
* disable all of the fixed events.
*/
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
{

View file

@ -1065,6 +1065,44 @@ AcpiEnableAllWakeupGpes (
ACPI_EXPORT_SYMBOL (AcpiEnableAllWakeupGpes)
/******************************************************************************
*
* FUNCTION: AcpiAnyGpeStatusSet
*
* PARAMETERS: None
*
* RETURN: Whether or not the status bit is set for any GPE
*
* DESCRIPTION: Check the status bits of all enabled GPEs and return TRUE if any
* of them is set or FALSE otherwise.
*
******************************************************************************/
UINT32
AcpiAnyGpeStatusSet (
void)
{
ACPI_STATUS Status;
UINT8 Ret;
ACPI_FUNCTION_TRACE (AcpiAnyGpeStatusSet);
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (Status))
{
return (FALSE);
}
Ret = AcpiHwCheckAllGpes ();
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
return (Ret);
}
ACPI_EXPORT_SYMBOL(AcpiAnyGpeStatusSet)
/*******************************************************************************
*
* FUNCTION: AcpiInstallGpeBlock

View file

@ -635,6 +635,58 @@ AcpiHwEnableWakeupGpeBlock (
}
/******************************************************************************
*
* FUNCTION: AcpiHwGetGpeBlockStatus
*
* PARAMETERS: GpeXruptInfo - GPE Interrupt info
* GpeBlock - Gpe Block info
*
* RETURN: Success
*
* DESCRIPTION: Produce a combined GPE status bits mask for the given block.
*
******************************************************************************/
static ACPI_STATUS
AcpiHwGetGpeBlockStatus(
ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
ACPI_GPE_BLOCK_INFO *GpeBlock,
void *RetPtr)
{
ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
UINT64 InEnable;
UINT64 InStatus;
ACPI_STATUS Status;
UINT8 *Ret = RetPtr;
UINT32 i;
/* Examine each GPE Register within the block */
for (i = 0; i < GpeBlock->RegisterCount; i++)
{
GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
Status = AcpiHwRead (&InEnable, &GpeRegisterInfo->EnableAddress);
if (ACPI_FAILURE (Status))
{
continue;
}
Status = AcpiHwRead (&InStatus, &GpeRegisterInfo->StatusAddress);
if (ACPI_FAILURE (Status))
{
continue;
}
*Ret |= InEnable & InStatus;
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: AcpiHwDisableAllGpes
@ -715,4 +767,31 @@ AcpiHwEnableAllWakeupGpes (
return_ACPI_STATUS (Status);
}
/******************************************************************************
*
* FUNCTION: AcpiHwCheckAllGpes
*
* PARAMETERS: None
*
* RETURN: Combined status of all GPEs
*
* DESCRIPTION: Check all enabled GPEs in all GPE blocks and return TRUE if the
* status bit is set for at least one of them of FALSE otherwise.
*
******************************************************************************/
UINT8
AcpiHwCheckAllGpes (
void)
{
UINT8 Ret = 0;
ACPI_FUNCTION_TRACE (AcpiHwCheckAllGpes);
(void) AcpiEvWalkGpeList (AcpiHwGetGpeBlockStatus, &Ret);
return (Ret != 0);
}
#endif /* !ACPI_REDUCED_HARDWARE */

View file

@ -464,6 +464,16 @@ AcpiHwLegacyWake (
AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId,
ACPI_CLEAR_STATUS);
/* Enable sleep button */
(void) AcpiWriteBitRegister (
AcpiGbl_FixedEventInfo[ACPI_EVENT_SLEEP_BUTTON].EnableRegisterId,
ACPI_ENABLE_EVENT);
(void) AcpiWriteBitRegister (
AcpiGbl_FixedEventInfo[ACPI_EVENT_SLEEP_BUTTON].StatusRegisterId,
ACPI_CLEAR_STATUS);
AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, ACPI_SST_WORKING);
return_ACPI_STATUS (Status);
}

View file

@ -336,7 +336,7 @@ AcpiNsHandleToPathname (
/* Build the path in the caller buffer */
(void) AcpiNsBuildNormalizedPath (Node, Buffer->Pointer,
RequiredSize, NoTrailing);
(UINT32) RequiredSize, NoTrailing);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n",
(char *) Buffer->Pointer, (UINT32) RequiredSize));
@ -509,7 +509,7 @@ AcpiNsGetNormalizedPathname (
/* Build the path in the allocated buffer */
(void) AcpiNsBuildNormalizedPath (Node, NameBuffer, Size, NoTrailing);
(void) AcpiNsBuildNormalizedPath (Node, NameBuffer, (UINT32) Size, NoTrailing);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%s: Path \"%s\"\n",
ACPI_GET_FUNCTION_NAME, NameBuffer));
@ -542,7 +542,7 @@ AcpiNsBuildPrefixedPathname (
char *FullPath = NULL;
char *ExternalPath = NULL;
char *PrefixPath = NULL;
UINT32 PrefixPathLength = 0;
ACPI_SIZE PrefixPathLength = 0;
/* If there is a prefix, get the pathname to it */

View file

@ -714,7 +714,7 @@ AcpiInstallMethod (
MethodFlags = *ParserState.Aml++;
AmlStart = ParserState.Aml;
AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart);
AmlLength = (UINT32) ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart);
/*
* Allocate resources up-front. We don't want to have to delete a new

View file

@ -368,14 +368,14 @@ ACPI_EXPORT_SYMBOL_INIT (AcpiReallocateRootTable)
*
* PARAMETERS: Signature - ACPI signature of needed table
* Instance - Which instance (for SSDTs)
* OutTableHeader - The pointer to the table header to fill
* OutTableHeader - The pointer to the where the table header
* is returned
*
* RETURN: Status and pointer to mapped table header
* RETURN: Status and a copy of the table header
*
* DESCRIPTION: Finds an ACPI table header.
*
* NOTE: Caller is responsible in unmapping the header with
* AcpiOsUnmapMemory
* DESCRIPTION: Finds and returns an ACPI table header. Caller provides the
* memory where a copy of the header is to be returned
* (fixed length).
*
******************************************************************************/

View file

@ -192,7 +192,7 @@ AcpiUtGetElementLength (
*
* NOTE: We always allocate the worst-case object descriptor because
* these objects are cached, and we want them to be
* one-size-satisifies-any-request. This in itself may not be
* one-size-satisfies-any-request. This in itself may not be
* the most memory efficient, but the efficiency of the object
* cache should more than make up for this!
*

View file

@ -237,8 +237,7 @@ CgWriteAmlComment (
void
CvInitFileTree (
ACPI_TABLE_HEADER *Table,
UINT8 *AmlStart,
UINT32 AmlLength);
FILE *RootFile);
void
CvClearOpComments (

View file

@ -315,6 +315,10 @@ ACPI_STATUS
AcpiHwEnableAllWakeupGpes (
void);
UINT8
AcpiHwCheckAllGpes (
void);
ACPI_STATUS
AcpiHwEnableRuntimeGpeBlock (
ACPI_GPE_XRUPT_INFO *GpeXruptInfo,

View file

@ -625,7 +625,7 @@
#define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d) CvPrintOneCommentType (a,b,c,d);
#define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b) CvPrintOneCommentList (a,b);
#define ASL_CV_FILE_HAS_SWITCHED(a) CvFileHasSwitched(a)
#define ASL_CV_INIT_FILETREE(a,b,c) CvInitFileTree(a,b,c);
#define ASL_CV_INIT_FILETREE(a,b) CvInitFileTree(a,b);
#else
@ -640,7 +640,7 @@
#define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d)
#define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b)
#define ASL_CV_FILE_HAS_SWITCHED(a) 0
#define ASL_CV_INIT_FILETREE(a,b,c)
#define ASL_CV_INIT_FILETREE(a,b)
#endif

View file

@ -154,7 +154,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */
#define ACPI_CA_VERSION 0x20200110
#define ACPI_CA_VERSION 0x20200214
#include <contrib/dev/acpica/include/acconfig.h>
#include <contrib/dev/acpica/include/actypes.h>
@ -1109,6 +1109,10 @@ ACPI_STATUS
AcpiEnableAllWakeupGpes (
void))
ACPI_HW_DEPENDENT_RETURN_UINT32 (
UINT32 AcpiAnyGpeStatusSet (
void))
ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiGetGpeDevice (

View file

@ -1149,7 +1149,7 @@ enum AcpiErstInstructions
enum AcpiErstCommandStatus
{
ACPI_ERST_SUCESS = 0,
ACPI_ERST_SUCCESS = 0,
ACPI_ERST_NO_SPACE = 1,
ACPI_ERST_NOT_AVAILABLE = 2,
ACPI_ERST_FAILURE = 3,

View file

@ -683,11 +683,12 @@ typedef UINT64 ACPI_INTEGER;
strnlen (a, ACPI_NAMESEG_SIZE) == ACPI_NAMESEG_SIZE)
/*
* Algorithm to obtain access bit width.
* Can be used with AccessWidth of ACPI_GENERIC_ADDRESS and AccessSize of
* Algorithm to obtain access bit or byte width.
* Can be used with AccessSize field of ACPI_GENERIC_ADDRESS and
* ACPI_RESOURCE_GENERIC_REGISTER.
*/
#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + 2))
#define ACPI_ACCESS_BIT_WIDTH(AccessSize) (1 << ((AccessSize) + 2))
#define ACPI_ACCESS_BYTE_WIDTH(AccessSize) (1 << ((AccessSize) - 1))
/*******************************************************************************

View file

@ -88,7 +88,6 @@ static int tmpfs_root(struct mount *, int flags, struct vnode **);
static int tmpfs_fhtovp(struct mount *, struct fid *, int,
struct vnode **);
static int tmpfs_statfs(struct mount *, struct statfs *);
static void tmpfs_susp_clean(struct mount *);
static const char *tmpfs_opts[] = {
"from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export",
@ -646,14 +645,6 @@ tmpfs_sync(struct mount *mp, int waitfor)
return (0);
}
/*
* The presence of a susp_clean method tells the VFS to track writes.
*/
static void
tmpfs_susp_clean(struct mount *mp __unused)
{
}
static int
tmpfs_init(struct vfsconf *conf)
{
@ -679,7 +670,6 @@ struct vfsops tmpfs_vfsops = {
.vfs_statfs = tmpfs_statfs,
.vfs_fhtovp = tmpfs_fhtovp,
.vfs_sync = tmpfs_sync,
.vfs_susp_clean = tmpfs_susp_clean,
.vfs_init = tmpfs_init,
.vfs_uninit = tmpfs_uninit,
};

View file

@ -976,7 +976,7 @@ trap_user_dtrace(struct trapframe *frame, int (**hookp)(struct trapframe *))
{
int (*hook)(struct trapframe *);
hook = (int (*)(struct trapframe *))atomic_load_ptr(hookp);
hook = atomic_load_ptr(hookp);
enable_intr();
if (hook != NULL)
return ((hook)(frame) == 0);

View file

@ -847,7 +847,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
* and any vfs op on this vnode going forward will return an
* error (meaning return value in this case is meaningless).
*/
mp = (struct mount *)atomic_load_ptr(&vp->v_mount);
mp = atomic_load_ptr(&vp->v_mount);
if (__predict_false(mp == NULL)) {
fdrop(fp, td);
error = EBADF;
@ -2741,7 +2741,7 @@ fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
* table before this fd was closed, so it is possible
* that there is a stale fp pointer in cached version.
*/
fdt = (struct fdescenttbl *)atomic_load_ptr(&fdp->fd_files);
fdt = atomic_load_ptr(&fdp->fd_files);
continue;
}
/*
@ -3601,7 +3601,7 @@ export_file_to_kinfo(struct file *fp, int fd, cap_rights_t *rightsp,
if (rightsp != NULL)
kif->kf_cap_rights = *rightsp;
else
cap_rights_init(&kif->kf_cap_rights);
cap_rights_init_zero(&kif->kf_cap_rights);
kif->kf_fd = fd;
kif->kf_ref_count = fp->f_count;
kif->kf_offset = foffset_get(fp);
@ -3632,7 +3632,7 @@ export_vnode_to_kinfo(struct vnode *vp, int fd, int fflags,
if (error == 0)
kif->kf_status |= KF_ATTR_VALID;
kif->kf_flags = xlate_fflags(fflags);
cap_rights_init(&kif->kf_cap_rights);
cap_rights_init_zero(&kif->kf_cap_rights);
kif->kf_fd = fd;
kif->kf_ref_count = -1;
kif->kf_offset = -1;

View file

@ -1195,11 +1195,11 @@ kern_kevent(struct thread *td, int fd, int nchanges, int nevents,
struct file *fp;
int error;
cap_rights_init(&rights);
cap_rights_init_zero(&rights);
if (nchanges > 0)
cap_rights_set(&rights, CAP_KQUEUE_CHANGE);
cap_rights_set_one(&rights, CAP_KQUEUE_CHANGE);
if (nevents > 0)
cap_rights_set(&rights, CAP_KQUEUE_EVENT);
cap_rights_set_one(&rights, CAP_KQUEUE_EVENT);
error = fget(td, fd, &rights, &fp);
if (error != 0)
return (error);

View file

@ -72,6 +72,7 @@ struct timehands {
struct timecounter *th_counter;
int64_t th_adjustment;
uint64_t th_scale;
u_int th_large_delta;
u_int th_offset_count;
struct bintime th_offset;
struct bintime th_bintime;
@ -87,6 +88,7 @@ static struct timehands ths[16] = {
[0] = {
.th_counter = &dummy_timecounter,
.th_scale = (uint64_t)-1 / 1000000,
.th_large_delta = 1000000,
.th_offset = { .sec = 1 },
.th_generation = 1,
},
@ -202,20 +204,72 @@ tc_delta(struct timehands *th)
* the comment in <sys/time.h> for a description of these 12 functions.
*/
#ifdef FFCLOCK
void
fbclock_binuptime(struct bintime *bt)
static __inline void
bintime_off(struct bintime *bt, u_int off)
{
struct timehands *th;
unsigned int gen;
struct bintime *btp;
uint64_t scale, x;
u_int delta, gen, large_delta;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_offset;
bintime_addx(bt, th->th_scale * tc_delta(th));
btp = (struct bintime *)((vm_offset_t)th + off);
*bt = *btp;
scale = th->th_scale;
delta = tc_delta(th);
large_delta = th->th_large_delta;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
if (__predict_false(delta >= large_delta)) {
/* Avoid overflow for scale * delta. */
x = (scale >> 32) * delta;
bt->sec += x >> 32;
bintime_addx(bt, x << 32);
bintime_addx(bt, (scale & 0xffffffff) * delta);
} else {
bintime_addx(bt, scale * delta);
}
}
#define GETTHBINTIME(dst, member) \
do { \
_Static_assert(_Generic(((struct timehands *)NULL)->member, \
struct bintime: 1, default: 0) == 1, \
"struct timehands member is not of struct bintime type"); \
bintime_off(dst, __offsetof(struct timehands, member)); \
} while (0)
static __inline void
getthmember(void *out, size_t out_size, u_int off)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
memcpy(out, (char *)th + off, out_size);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
}
#define GETTHMEMBER(dst, member) \
do { \
_Static_assert(_Generic(*dst, \
__typeof(((struct timehands *)NULL)->member): 1, \
default: 0) == 1, \
"*dst and struct timehands member have different types"); \
getthmember(dst, sizeof(*dst), __offsetof(struct timehands, \
member)); \
} while (0)
#ifdef FFCLOCK
void
fbclock_binuptime(struct bintime *bt)
{
GETTHBINTIME(bt, th_offset);
}
void
@ -239,16 +293,8 @@ fbclock_microuptime(struct timeval *tvp)
void
fbclock_bintime(struct bintime *bt)
{
struct timehands *th;
unsigned int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_bintime;
bintime_addx(bt, th->th_scale * tc_delta(th));
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHBINTIME(bt, th_bintime);
}
void
@ -272,100 +318,55 @@ fbclock_microtime(struct timeval *tvp)
void
fbclock_getbinuptime(struct bintime *bt)
{
struct timehands *th;
unsigned int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_offset;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(bt, th_offset);
}
void
fbclock_getnanouptime(struct timespec *tsp)
{
struct timehands *th;
unsigned int gen;
struct bintime bt;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
bintime2timespec(&th->th_offset, tsp);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(&bt, th_offset);
bintime2timespec(&bt, tsp);
}
void
fbclock_getmicrouptime(struct timeval *tvp)
{
struct timehands *th;
unsigned int gen;
struct bintime bt;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
bintime2timeval(&th->th_offset, tvp);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(&bt, th_offset);
bintime2timeval(&bt, tvp);
}
void
fbclock_getbintime(struct bintime *bt)
{
struct timehands *th;
unsigned int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_bintime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(bt, th_bintime);
}
void
fbclock_getnanotime(struct timespec *tsp)
{
struct timehands *th;
unsigned int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*tsp = th->th_nanotime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(tsp, th_nanotime);
}
void
fbclock_getmicrotime(struct timeval *tvp)
{
struct timehands *th;
unsigned int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*tvp = th->th_microtime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(tvp, th_microtime);
}
#else /* !FFCLOCK */
void
binuptime(struct bintime *bt)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_offset;
bintime_addx(bt, th->th_scale * tc_delta(th));
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHBINTIME(bt, th_offset);
}
void
@ -389,16 +390,8 @@ microuptime(struct timeval *tvp)
void
bintime(struct bintime *bt)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_bintime;
bintime_addx(bt, th->th_scale * tc_delta(th));
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHBINTIME(bt, th_bintime);
}
void
@ -422,85 +415,47 @@ microtime(struct timeval *tvp)
void
getbinuptime(struct bintime *bt)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_offset;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(bt, th_offset);
}
void
getnanouptime(struct timespec *tsp)
{
struct timehands *th;
u_int gen;
struct bintime bt;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
bintime2timespec(&th->th_offset, tsp);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(&bt, th_offset);
bintime2timespec(&bt, tsp);
}
void
getmicrouptime(struct timeval *tvp)
{
struct timehands *th;
u_int gen;
struct bintime bt;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
bintime2timeval(&th->th_offset, tvp);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(&bt, th_offset);
bintime2timeval(&bt, tvp);
}
void
getbintime(struct bintime *bt)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*bt = th->th_bintime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(bt, th_bintime);
}
void
getnanotime(struct timespec *tsp)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*tsp = th->th_nanotime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(tsp, th_nanotime);
}
void
getmicrotime(struct timeval *tvp)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*tvp = th->th_microtime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(tvp, th_microtime);
}
#endif /* FFCLOCK */
@ -516,15 +471,8 @@ getboottime(struct timeval *boottime)
void
getboottimebin(struct bintime *boottimebin)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*boottimebin = th->th_boottime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(boottimebin, th_boottime);
}
#ifdef FFCLOCK
@ -1040,15 +988,8 @@ getmicrotime(struct timeval *tvp)
void
dtrace_getnanotime(struct timespec *tsp)
{
struct timehands *th;
u_int gen;
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
*tsp = th->th_nanotime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
GETTHMEMBER(tsp, th_nanotime);
}
/*
@ -1466,6 +1407,7 @@ tc_windup(struct bintime *new_boottimebin)
scale += (th->th_adjustment / 1024) * 2199;
scale /= th->th_counter->tc_frequency;
th->th_scale = scale * 2;
th->th_large_delta = MIN(((uint64_t)1 << 63) / scale, UINT_MAX);
/*
* Now that the struct timehands is again consistent, set the new

View file

@ -103,50 +103,50 @@ __read_mostly cap_rights_t cap_no_rights;
static void
__cap_rights_sysinit1(void *arg)
{
cap_rights_init(&cap_accept_rights, CAP_ACCEPT);
cap_rights_init(&cap_bind_rights, CAP_BIND);
cap_rights_init(&cap_connect_rights, CAP_CONNECT);
cap_rights_init(&cap_event_rights, CAP_EVENT);
cap_rights_init(&cap_fchdir_rights, CAP_FCHDIR);
cap_rights_init(&cap_fchflags_rights, CAP_FCHFLAGS);
cap_rights_init(&cap_fchmod_rights, CAP_FCHMOD);
cap_rights_init(&cap_fchown_rights, CAP_FCHOWN);
cap_rights_init(&cap_fcntl_rights, CAP_FCNTL);
cap_rights_init(&cap_fexecve_rights, CAP_FEXECVE);
cap_rights_init(&cap_flock_rights, CAP_FLOCK);
cap_rights_init(&cap_fpathconf_rights, CAP_FPATHCONF);
cap_rights_init(&cap_fstat_rights, CAP_FSTAT);
cap_rights_init(&cap_fstatfs_rights, CAP_FSTATFS);
cap_rights_init(&cap_fsync_rights, CAP_FSYNC);
cap_rights_init(&cap_ftruncate_rights, CAP_FTRUNCATE);
cap_rights_init(&cap_futimes_rights, CAP_FUTIMES);
cap_rights_init(&cap_getpeername_rights, CAP_GETPEERNAME);
cap_rights_init(&cap_getsockname_rights, CAP_GETSOCKNAME);
cap_rights_init(&cap_getsockopt_rights, CAP_GETSOCKOPT);
cap_rights_init(&cap_ioctl_rights, CAP_IOCTL);
cap_rights_init(&cap_linkat_source_rights, CAP_LINKAT_SOURCE);
cap_rights_init(&cap_linkat_target_rights, CAP_LINKAT_TARGET);
cap_rights_init(&cap_listen_rights, CAP_LISTEN);
cap_rights_init(&cap_mkdirat_rights, CAP_MKDIRAT);
cap_rights_init(&cap_mkfifoat_rights, CAP_MKFIFOAT);
cap_rights_init(&cap_mknodat_rights, CAP_MKNODAT);
cap_rights_init(&cap_mmap_rights, CAP_MMAP);
cap_rights_init(&cap_pdgetpid_rights, CAP_PDGETPID);
cap_rights_init(&cap_pdkill_rights, CAP_PDKILL);
cap_rights_init(&cap_pread_rights, CAP_PREAD);
cap_rights_init(&cap_pwrite_rights, CAP_PWRITE);
cap_rights_init(&cap_read_rights, CAP_READ);
cap_rights_init(&cap_recv_rights, CAP_RECV);
cap_rights_init(&cap_renameat_source_rights, CAP_RENAMEAT_SOURCE);
cap_rights_init(&cap_renameat_target_rights, CAP_RENAMEAT_TARGET);
cap_rights_init(&cap_seek_rights, CAP_SEEK);
cap_rights_init(&cap_send_rights, CAP_SEND);
cap_rights_init_one(&cap_accept_rights, CAP_ACCEPT);
cap_rights_init_one(&cap_bind_rights, CAP_BIND);
cap_rights_init_one(&cap_connect_rights, CAP_CONNECT);
cap_rights_init_one(&cap_event_rights, CAP_EVENT);
cap_rights_init_one(&cap_fchdir_rights, CAP_FCHDIR);
cap_rights_init_one(&cap_fchflags_rights, CAP_FCHFLAGS);
cap_rights_init_one(&cap_fchmod_rights, CAP_FCHMOD);
cap_rights_init_one(&cap_fchown_rights, CAP_FCHOWN);
cap_rights_init_one(&cap_fcntl_rights, CAP_FCNTL);
cap_rights_init_one(&cap_fexecve_rights, CAP_FEXECVE);
cap_rights_init_one(&cap_flock_rights, CAP_FLOCK);
cap_rights_init_one(&cap_fpathconf_rights, CAP_FPATHCONF);
cap_rights_init_one(&cap_fstat_rights, CAP_FSTAT);
cap_rights_init_one(&cap_fstatfs_rights, CAP_FSTATFS);
cap_rights_init_one(&cap_fsync_rights, CAP_FSYNC);
cap_rights_init_one(&cap_ftruncate_rights, CAP_FTRUNCATE);
cap_rights_init_one(&cap_futimes_rights, CAP_FUTIMES);
cap_rights_init_one(&cap_getpeername_rights, CAP_GETPEERNAME);
cap_rights_init_one(&cap_getsockname_rights, CAP_GETSOCKNAME);
cap_rights_init_one(&cap_getsockopt_rights, CAP_GETSOCKOPT);
cap_rights_init_one(&cap_ioctl_rights, CAP_IOCTL);
cap_rights_init_one(&cap_linkat_source_rights, CAP_LINKAT_SOURCE);
cap_rights_init_one(&cap_linkat_target_rights, CAP_LINKAT_TARGET);
cap_rights_init_one(&cap_listen_rights, CAP_LISTEN);
cap_rights_init_one(&cap_mkdirat_rights, CAP_MKDIRAT);
cap_rights_init_one(&cap_mkfifoat_rights, CAP_MKFIFOAT);
cap_rights_init_one(&cap_mknodat_rights, CAP_MKNODAT);
cap_rights_init_one(&cap_mmap_rights, CAP_MMAP);
cap_rights_init_one(&cap_pdgetpid_rights, CAP_PDGETPID);
cap_rights_init_one(&cap_pdkill_rights, CAP_PDKILL);
cap_rights_init_one(&cap_pread_rights, CAP_PREAD);
cap_rights_init_one(&cap_pwrite_rights, CAP_PWRITE);
cap_rights_init_one(&cap_read_rights, CAP_READ);
cap_rights_init_one(&cap_recv_rights, CAP_RECV);
cap_rights_init_one(&cap_renameat_source_rights, CAP_RENAMEAT_SOURCE);
cap_rights_init_one(&cap_renameat_target_rights, CAP_RENAMEAT_TARGET);
cap_rights_init_one(&cap_seek_rights, CAP_SEEK);
cap_rights_init_one(&cap_send_rights, CAP_SEND);
cap_rights_init(&cap_send_connect_rights, CAP_SEND, CAP_CONNECT);
cap_rights_init(&cap_setsockopt_rights, CAP_SETSOCKOPT);
cap_rights_init(&cap_shutdown_rights, CAP_SHUTDOWN);
cap_rights_init(&cap_symlinkat_rights, CAP_SYMLINKAT);
cap_rights_init(&cap_unlinkat_rights, CAP_UNLINKAT);
cap_rights_init(&cap_write_rights, CAP_WRITE);
cap_rights_init_one(&cap_setsockopt_rights, CAP_SETSOCKOPT);
cap_rights_init_one(&cap_shutdown_rights, CAP_SHUTDOWN);
cap_rights_init_one(&cap_symlinkat_rights, CAP_SYMLINKAT);
cap_rights_init_one(&cap_unlinkat_rights, CAP_UNLINKAT);
cap_rights_init_one(&cap_write_rights, CAP_WRITE);
cap_rights_init(&cap_no_rights);
}
SYSINIT(cap_rights1_sysinit, SI_SUB_COPYRIGHT, SI_ORDER_ANY, \

View file

@ -95,7 +95,7 @@ __sanitizer_cov_trace_pc(void)
{
cov_trace_pc_t trace_pc;
trace_pc = (cov_trace_pc_t)atomic_load_ptr(&cov_trace_pc);
trace_pc = atomic_load_ptr(&cov_trace_pc);
if (trace_pc != NULL)
trace_pc((uint64_t)__builtin_return_address(0));
}
@ -110,7 +110,7 @@ __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(0), arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -121,7 +121,7 @@ __sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(1), arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -132,7 +132,7 @@ __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(2), arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -143,7 +143,7 @@ __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(3), arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -154,7 +154,7 @@ __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(0) | COV_CMP_CONST, arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -165,7 +165,7 @@ __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(1) | COV_CMP_CONST, arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -176,7 +176,7 @@ __sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(2) | COV_CMP_CONST, arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -187,7 +187,7 @@ __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2)
{
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp != NULL)
trace_cmp(COV_CMP_SIZE(3) | COV_CMP_CONST, arg1, arg2,
(uint64_t)__builtin_return_address(0));
@ -205,7 +205,7 @@ __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases)
uint64_t i, count, ret, type;
cov_trace_cmp_t trace_cmp;
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp);
trace_cmp = atomic_load_ptr(&cov_trace_cmp);
if (trace_cmp == NULL)
return;

View file

@ -267,7 +267,7 @@ sys_cap_rights_limit(struct thread *td, struct cap_rights_limit_args *uap)
cap_rights_t rights;
int error, version;
cap_rights_init(&rights);
cap_rights_init_zero(&rights);
error = copyin(uap->rightsp, &rights, sizeof(rights.cr_rights[0]));
if (error != 0)

View file

@ -436,7 +436,7 @@ sys___acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
AUDIT_ARG_FD(uap->filedes);
error = getvnode(td, uap->filedes,
cap_rights_init(&rights, CAP_ACL_GET), &fp);
cap_rights_init_one(&rights, CAP_ACL_GET), &fp);
if (error == 0) {
error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
@ -456,7 +456,7 @@ sys___acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
AUDIT_ARG_FD(uap->filedes);
error = getvnode(td, uap->filedes,
cap_rights_init(&rights, CAP_ACL_SET), &fp);
cap_rights_init_one(&rights, CAP_ACL_SET), &fp);
if (error == 0) {
error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
@ -512,7 +512,7 @@ sys___acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
AUDIT_ARG_FD(uap->filedes);
error = getvnode(td, uap->filedes,
cap_rights_init(&rights, CAP_ACL_DELETE), &fp);
cap_rights_init_one(&rights, CAP_ACL_DELETE), &fp);
if (error == 0) {
error = vacl_delete(td, fp->f_vnode, uap->type);
fdrop(fp, td);
@ -569,7 +569,7 @@ sys___acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
AUDIT_ARG_FD(uap->filedes);
error = getvnode(td, uap->filedes,
cap_rights_init(&rights, CAP_ACL_CHECK), &fp);
cap_rights_init_one(&rights, CAP_ACL_CHECK), &fp);
if (error == 0) {
error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);

View file

@ -243,7 +243,7 @@ sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap)
AUDIT_ARG_TEXT(attrname);
error = getvnode(td, uap->fd,
cap_rights_init(&rights, CAP_EXTATTR_SET), &fp);
cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp);
if (error)
return (error);
@ -410,7 +410,7 @@ sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap)
AUDIT_ARG_TEXT(attrname);
error = getvnode(td, uap->fd,
cap_rights_init(&rights, CAP_EXTATTR_GET), &fp);
cap_rights_init_one(&rights, CAP_EXTATTR_GET), &fp);
if (error)
return (error);
@ -545,7 +545,7 @@ sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap)
AUDIT_ARG_TEXT(attrname);
error = getvnode(td, uap->fd,
cap_rights_init(&rights, CAP_EXTATTR_DELETE), &fp);
cap_rights_init_one(&rights, CAP_EXTATTR_DELETE), &fp);
if (error)
return (error);
@ -691,7 +691,7 @@ sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap)
AUDIT_ARG_FD(uap->fd);
AUDIT_ARG_VALUE(uap->attrnamespace);
error = getvnode(td, uap->fd,
cap_rights_init(&rights, CAP_EXTATTR_LIST), &fp);
cap_rights_init_one(&rights, CAP_EXTATTR_LIST), &fp);
if (error)
return (error);

View file

@ -440,7 +440,7 @@ namei(struct nameidata *ndp)
} else {
vrefact(ndp->ni_rootdir);
rights = ndp->ni_rightsneeded;
cap_rights_set(&rights, CAP_LOOKUP);
cap_rights_set_one(&rights, CAP_LOOKUP);
if (cnp->cn_flags & AUDITVNODE1)
AUDIT_ARG_ATFD1(ndp->ni_dirfd);
@ -493,7 +493,7 @@ namei(struct nameidata *ndp)
vrefact(ndp->ni_beneath_latch);
} else {
rights = ndp->ni_rightsneeded;
cap_rights_set(&rights, CAP_LOOKUP);
cap_rights_set_one(&rights, CAP_LOOKUP);
error = fgetvp_rights(td, ndp->ni_dirfd, &rights,
&dirfd_caps, &ndp->ni_beneath_latch);
if (error == 0 && dp->v_type != VDIR) {
@ -1344,7 +1344,7 @@ NDINIT_ALL(struct nameidata *ndp, u_long op, u_long flags, enum uio_seg segflg,
if (rightsp != NULL)
ndp->ni_rightsneeded = *rightsp;
else
cap_rights_init(&ndp->ni_rightsneeded);
cap_rights_init_zero(&ndp->ni_rightsneeded);
}
/*

View file

@ -6139,7 +6139,7 @@ vfs_cache_root(struct mount *mp, int flags, struct vnode **vpp)
if (!vfs_op_thread_enter(mp))
return (vfs_cache_root_fallback(mp, flags, vpp));
vp = (struct vnode *)atomic_load_ptr(&mp->mnt_rootvnode);
vp = atomic_load_ptr(&mp->mnt_rootvnode);
if (vp == NULL || VN_IS_DOOMED(vp)) {
vfs_op_thread_exit(mp);
return (vfs_cache_root_fallback(mp, flags, vpp));

View file

@ -966,34 +966,34 @@ flags_to_rights(int flags, cap_rights_t *rightsp)
{
if (flags & O_EXEC) {
cap_rights_set(rightsp, CAP_FEXECVE);
cap_rights_set_one(rightsp, CAP_FEXECVE);
} else {
switch ((flags & O_ACCMODE)) {
case O_RDONLY:
cap_rights_set(rightsp, CAP_READ);
cap_rights_set_one(rightsp, CAP_READ);
break;
case O_RDWR:
cap_rights_set(rightsp, CAP_READ);
cap_rights_set_one(rightsp, CAP_READ);
/* FALLTHROUGH */
case O_WRONLY:
cap_rights_set(rightsp, CAP_WRITE);
cap_rights_set_one(rightsp, CAP_WRITE);
if (!(flags & (O_APPEND | O_TRUNC)))
cap_rights_set(rightsp, CAP_SEEK);
cap_rights_set_one(rightsp, CAP_SEEK);
break;
}
}
if (flags & O_CREAT)
cap_rights_set(rightsp, CAP_CREATE);
cap_rights_set_one(rightsp, CAP_CREATE);
if (flags & O_TRUNC)
cap_rights_set(rightsp, CAP_FTRUNCATE);
cap_rights_set_one(rightsp, CAP_FTRUNCATE);
if (flags & (O_SYNC | O_FSYNC))
cap_rights_set(rightsp, CAP_FSYNC);
cap_rights_set_one(rightsp, CAP_FSYNC);
if (flags & (O_EXLOCK | O_SHLOCK))
cap_rights_set(rightsp, CAP_FLOCK);
cap_rights_set_one(rightsp, CAP_FLOCK);
}
/*
@ -1048,7 +1048,7 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
AUDIT_ARG_FFLAGS(flags);
AUDIT_ARG_MODE(mode);
cap_rights_init(&rights, CAP_LOOKUP);
cap_rights_init_one(&rights, CAP_LOOKUP);
flags_to_rights(flags, &rights);
/*
* Only one of the O_EXEC, O_RDONLY, O_WRONLY and O_RDWR flags
@ -3752,7 +3752,7 @@ kern_frmdirat(struct thread *td, int dfd, const char *path, int fd,
fp = NULL;
if (fd != FD_NONE) {
error = getvnode(td, fd, cap_rights_init(&rights, CAP_LOOKUP),
error = getvnode(td, fd, cap_rights_init_one(&rights, CAP_LOOKUP),
&fp);
if (error != 0)
return (error);

View file

@ -1643,13 +1643,6 @@ vn_closefile(struct file *fp, struct thread *td)
return (error);
}
static bool
vn_suspendable(struct mount *mp)
{
return (mp->mnt_op->vfs_susp_clean != NULL);
}
/*
* Preparing to start a filesystem write operation. If the operation is
* permitted, then we bump the count of operations in progress and
@ -1729,12 +1722,6 @@ vn_start_write(struct vnode *vp, struct mount **mpp, int flags)
if ((mp = *mpp) == NULL)
return (0);
if (!vn_suspendable(mp)) {
if (vp != NULL || (flags & V_MNTREF) != 0)
vfs_rel(mp);
return (0);
}
/*
* VOP_GETWRITEMOUNT() returns with the mp refcount held through
* a vfs_ref().
@ -1780,12 +1767,6 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
if ((mp = *mpp) == NULL)
return (0);
if (!vn_suspendable(mp)) {
if (vp != NULL || (flags & V_MNTREF) != 0)
vfs_rel(mp);
return (0);
}
/*
* VOP_GETWRITEMOUNT() returns with the mp refcount held through
* a vfs_ref().
@ -1829,7 +1810,7 @@ vn_finished_write(struct mount *mp)
{
int c;
if (mp == NULL || !vn_suspendable(mp))
if (mp == NULL)
return;
if (vfs_op_thread_enter(mp)) {
@ -1863,7 +1844,7 @@ vn_finished_write(struct mount *mp)
void
vn_finished_secondary_write(struct mount *mp)
{
if (mp == NULL || !vn_suspendable(mp))
if (mp == NULL)
return;
MNT_ILOCK(mp);
MNT_REL(mp);
@ -1884,8 +1865,6 @@ vfs_write_suspend(struct mount *mp, int flags)
{
int error;
MPASS(vn_suspendable(mp));
vfs_op_enter(mp);
MNT_ILOCK(mp);
@ -1934,8 +1913,6 @@ void
vfs_write_resume(struct mount *mp, int flags)
{
MPASS(vn_suspendable(mp));
MNT_ILOCK(mp);
if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) {
KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner"));
@ -1970,7 +1947,6 @@ vfs_write_suspend_umnt(struct mount *mp)
{
int error;
MPASS(vn_suspendable(mp));
KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0,
("vfs_write_suspend_umnt: recursed"));

View file

@ -57,7 +57,7 @@
vm_offset_t pc_cmap2_addr; /* KVA page for copy window 2 */ \
vm_offset_t pc_qmap_addr; /* KVA page for temporary mappings */ \
pt_entry_t *pc_qmap_ptep; /* PTE for temporary mapping KVA */ \
char __pad[101]
char __pad[97]
#endif
#ifdef __mips_n64

View file

@ -219,14 +219,14 @@ sys_sctp_generic_sendmsg (td, uap)
u_sinfo = &sinfo;
}
cap_rights_init(&rights, CAP_SEND);
cap_rights_init_one(&rights, CAP_SEND);
if (uap->tolen != 0) {
error = getsockaddr(&to, uap->to, uap->tolen);
if (error != 0) {
to = NULL;
goto sctp_bad2;
}
cap_rights_set(&rights, CAP_CONNECT);
cap_rights_set_one(&rights, CAP_CONNECT);
}
AUDIT_ARG_FD(uap->sd);
@ -332,14 +332,14 @@ sys_sctp_generic_sendmsg_iov(td, uap)
return (error);
u_sinfo = &sinfo;
}
cap_rights_init(&rights, CAP_SEND);
cap_rights_init_one(&rights, CAP_SEND);
if (uap->tolen != 0) {
error = getsockaddr(&to, uap->to, uap->tolen);
if (error != 0) {
to = NULL;
goto sctp_bad2;
}
cap_rights_set(&rights, CAP_CONNECT);
cap_rights_set_one(&rights, CAP_CONNECT);
}
AUDIT_ARG_FD(uap->sd);

View file

@ -170,7 +170,11 @@ void kcsan_atomic_thread_fence_seq_cst(void);
#define atomic_fcmpset_acq_ptr kcsan_atomic_fcmpset_acq_ptr
#define atomic_fcmpset_rel_ptr kcsan_atomic_fcmpset_rel_ptr
#define atomic_fetchadd_ptr kcsan_atomic_fetchadd_ptr
#define atomic_load_ptr(x) kcsan_atomic_load_ptr((volatile uintptr_t *)(x))
#define atomic_load_ptr(x) ({ \
__typeof(*x) __retptr; \
__retptr = (void *)kcsan_atomic_load_ptr((volatile uintptr_t *)(x)); \
__retptr; \
})
#define atomic_load_acq_ptr kcsan_atomic_load_acq_ptr
#define atomic_readandclear_ptr kcsan_atomic_readandclear_ptr
#define atomic_set_ptr kcsan_atomic_set_ptr

View file

@ -41,7 +41,7 @@
#define atomic_load_short(p) (*(volatile u_short *)(p))
#define atomic_load_int(p) (*(volatile u_int *)(p))
#define atomic_load_long(p) (*(volatile u_long *)(p))
#define atomic_load_ptr(p) (*(volatile uintptr_t*)(p))
#define atomic_load_ptr(p) (*(volatile __typeof(p))(p))
#define atomic_load_8(p) (*(volatile uint8_t *)(p))
#define atomic_load_16(p) (*(volatile uint16_t *)(p))
#define atomic_load_32(p) (*(volatile uint32_t *)(p))

View file

@ -351,6 +351,27 @@ void __cap_rights_sysinit(void *arg);
_Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00,
"unsupported version of capsicum rights");
#define cap_rights_init_zero(r) ({ \
cap_rights_t *_r = (r); \
CAP_NONE(_r); \
_r; \
})
#define cap_rights_init_one(r, right) ({ \
CTASSERT(CAPRVER(right) == CAP_RIGHTS_VERSION); \
cap_rights_t *_r = (r); \
CAP_NONE(_r); \
_r->cr_rights[CAPIDXBIT(right) - 1] |= right; \
_r; \
})
#define cap_rights_set_one(r, right) ({ \
CTASSERT(CAPRVER(right) == CAP_RIGHTS_VERSION); \
cap_rights_t *_r = (r); \
_r->cr_rights[CAPIDXBIT(right) - 1] |= right; \
_r; \
})
/*
* Allow checking caps which are possibly getting modified at the same time.
* The caller is expected to determine whether the result is legitimate via

View file

@ -389,15 +389,15 @@ kern_mmap_fpcheck(struct thread *td, uintptr_t addr0, size_t len, int prot,
* rights, but also return the maximum rights to be combined
* with maxprot later.
*/
cap_rights_init(&rights, CAP_MMAP);
cap_rights_init_one(&rights, CAP_MMAP);
if (prot & PROT_READ)
cap_rights_set(&rights, CAP_MMAP_R);
cap_rights_set_one(&rights, CAP_MMAP_R);
if ((flags & MAP_SHARED) != 0) {
if (prot & PROT_WRITE)
cap_rights_set(&rights, CAP_MMAP_W);
cap_rights_set_one(&rights, CAP_MMAP_W);
}
if (prot & PROT_EXEC)
cap_rights_set(&rights, CAP_MMAP_X);
cap_rights_set_one(&rights, CAP_MMAP_X);
error = fget_mmap(td, fd, &rights, &cap_maxprot, &fp);
if (error != 0)
goto done;
@ -895,8 +895,7 @@ retry:
while (object == NULL || m->object != object) {
if (object != NULL)
VM_OBJECT_WUNLOCK(object);
object = (vm_object_t)atomic_load_ptr(
&m->object);
object = atomic_load_ptr(&m->object);
if (object == NULL)
goto retry;
VM_OBJECT_WLOCK(object);

View file

@ -2500,8 +2500,7 @@ retry:
pa);
}
#endif
else if ((object =
(vm_object_t)atomic_load_ptr(&m->object)) != NULL) {
else if ((object = atomic_load_ptr(&m->object)) != NULL) {
/*
* The page is considered eligible for relocation if
* and only if it could be laundered or reclaimed by
@ -2643,8 +2642,7 @@ vm_page_reclaim_run(int req_class, int domain, u_long npages, vm_page_t m_run,
*/
if (vm_page_wired(m))
error = EBUSY;
else if ((object =
(vm_object_t)atomic_load_ptr(&m->object)) != NULL) {
else if ((object = atomic_load_ptr(&m->object)) != NULL) {
/*
* The page is relocated if and only if it could be
* laundered or reclaimed by the page daemon.
@ -4065,7 +4063,7 @@ vm_page_release(vm_page_t m, int flags)
if ((flags & VPR_TRYFREE) != 0) {
for (;;) {
object = (vm_object_t)atomic_load_ptr(&m->object);
object = atomic_load_ptr(&m->object);
if (object == NULL)
break;
/* Depends on type-stability. */

View file

@ -767,7 +767,7 @@ scan:
if (object == NULL || object != m->object) {
if (object != NULL)
VM_OBJECT_WUNLOCK(object);
object = (vm_object_t)atomic_load_ptr(&m->object);
object = atomic_load_ptr(&m->object);
if (__predict_false(object == NULL))
/* The page is being freed by another thread. */
continue;
@ -1238,7 +1238,7 @@ act_scan:
* A page's object pointer may be set to NULL before
* the object lock is acquired.
*/
object = (vm_object_t)atomic_load_ptr(&m->object);
object = atomic_load_ptr(&m->object);
if (__predict_false(object == NULL))
/*
* The page has been removed from its object.
@ -1481,7 +1481,7 @@ vm_pageout_scan_inactive(struct vm_domain *vmd, int shortage,
if (object == NULL || object != m->object) {
if (object != NULL)
VM_OBJECT_WUNLOCK(object);
object = (vm_object_t)atomic_load_ptr(&m->object);
object = atomic_load_ptr(&m->object);
if (__predict_false(object == NULL))
/* The page is being freed by another thread. */
continue;

View file

@ -1106,7 +1106,7 @@ smp_after_idle_runnable(void *arg __unused)
for (cpu = 1; cpu < mp_ncpus; cpu++) {
pc = pcpu_find(cpu);
while (atomic_load_ptr(&pc->pc_curpcb) == (uintptr_t)NULL)
while (atomic_load_ptr(&pc->pc_curpcb) == NULL)
cpu_spinwait();
kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages *
PAGE_SIZE);