Path: blob/main/sys/cddl/dev/dtrace/dtrace_cddl.h
106109 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License (the "License").5* You may not use this file except in compliance with the License.6*7* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE8* or http://www.opensolaris.org/os/licensing.9* See the License for the specific language governing permissions10* and limitations under the License.11*12* When distributing Covered Code, include this CDDL HEADER in each13* file and include the License file at usr/src/OPENSOLARIS.LICENSE.14* If applicable, add the following below this CDDL HEADER, with the15* fields enclosed by brackets "[]" replaced with your own identifying16* information: Portions Copyright [yyyy] [name of copyright owner]17*18* CDDL HEADER END19*20*/2122#ifndef _DTRACE_CDDL_H_23#define _DTRACE_CDDL_H_2425#include <sys/proc.h>2627/*28* Kernel DTrace extension to 'struct proc' for FreeBSD.29*/30typedef struct kdtrace_proc {31int p_dtrace_probes; /* Are there probes for this proc? */32uint64_t p_dtrace_count; /* Number of DTrace tracepoints */33void *p_dtrace_helpers; /* DTrace helpers, if any */34int p_dtrace_model;35uint64_t p_fasttrap_tp_gen; /* Tracepoint hash table gen */36} kdtrace_proc_t;3738/*39* Kernel DTrace extension to 'struct thread' for FreeBSD.40*/41typedef struct kdtrace_thread {42uint8_t td_dtrace_stop; /* Indicates a DTrace-desired stop */43uint8_t td_dtrace_sig; /* Signal sent via DTrace's raise() */44uint8_t td_dtrace_inprobe; /* Are we in a probe? */45u_int td_predcache; /* DTrace predicate cache */46uint64_t td_dtrace_vtime; /* DTrace virtual time */47uint64_t td_dtrace_start; /* DTrace slice start time */4849union __tdu {50struct __tds {51uint8_t _td_dtrace_on;52/* Hit a fasttrap tracepoint. */53uint8_t _td_dtrace_step;54/* About to return to kernel. */55uint8_t _td_dtrace_ret;56/* Handling a return probe. */57uint8_t _td_dtrace_ast;58/* Saved ast flag. */59#ifdef __amd64__60uint8_t _td_dtrace_reg;61#endif62} _tds;63u_long _td_dtrace_ft; /* Bitwise or of these flags. */64} _tdu;65#define td_dtrace_ft _tdu._td_dtrace_ft66#define td_dtrace_on _tdu._tds._td_dtrace_on67#define td_dtrace_step _tdu._tds._td_dtrace_step68#define td_dtrace_ret _tdu._tds._td_dtrace_ret69#define td_dtrace_ast _tdu._tds._td_dtrace_ast70#define td_dtrace_reg _tdu._tds._td_dtrace_reg7172uintptr_t td_dtrace_pc; /* DTrace saved pc from fasttrap. */73uintptr_t td_dtrace_npc; /* DTrace next pc from fasttrap. */74uintptr_t td_dtrace_scrpc;75/* DTrace per-thread scratch location. */76uintptr_t td_dtrace_astpc;77/* DTrace return sequence location. */78#ifdef __amd64__79uintptr_t td_dtrace_regv;80#endif81uintptr_t td_dtrace_sdt_arg[1]; /* Space for extra SDT args */82void *td_dtrace_sscr; /* Saved scratch space location. */83void *td_systrace_args; /* syscall probe arguments. */84uint64_t td_fasttrap_tp_gen; /* Tracepoint hash table gen. */85struct trapframe *td_dtrace_trapframe; /* Trap frame from invop. */86void *td_kinst_tramp;87} kdtrace_thread_t;8889/*90* Definitions to reference fields in the FreeBSD DTrace structures defined91* above using the names of fields in similar structures in Solaris. Note92* that the separation on FreeBSD is a licensing constraint designed to93* keep the GENERIC kernel BSD licensed.94*/95#define t_dtrace_vtime td_dtrace->td_dtrace_vtime96#define t_dtrace_start td_dtrace->td_dtrace_start97#define t_dtrace_stop td_dtrace->td_dtrace_stop98#define t_dtrace_sig td_dtrace->td_dtrace_sig99#define t_dtrace_inprobe td_dtrace->td_dtrace_inprobe100#define t_predcache td_dtrace->td_predcache101#define t_dtrace_ft td_dtrace->td_dtrace_ft102#define t_dtrace_on td_dtrace->td_dtrace_on103#define t_dtrace_step td_dtrace->td_dtrace_step104#define t_dtrace_ret td_dtrace->td_dtrace_ret105#define t_dtrace_ast td_dtrace->td_dtrace_ast106#define t_dtrace_reg td_dtrace->td_dtrace_reg107#define t_dtrace_pc td_dtrace->td_dtrace_pc108#define t_dtrace_npc td_dtrace->td_dtrace_npc109#define t_dtrace_scrpc td_dtrace->td_dtrace_scrpc110#define t_dtrace_astpc td_dtrace->td_dtrace_astpc111#define t_dtrace_regv td_dtrace->td_dtrace_regv112#define t_dtrace_sdt_arg td_dtrace->td_dtrace_sdt_arg113#define t_dtrace_sscr td_dtrace->td_dtrace_sscr114#define t_dtrace_systrace_args td_dtrace->td_systrace_args115#define t_fasttrap_tp_gen td_dtrace->td_fasttrap_tp_gen116#define t_dtrace_trapframe td_dtrace->td_dtrace_trapframe117#define t_kinst_tramp td_dtrace->td_kinst_tramp118#define p_dtrace_helpers p_dtrace->p_dtrace_helpers119#define p_dtrace_count p_dtrace->p_dtrace_count120#define p_dtrace_probes p_dtrace->p_dtrace_probes121#define p_model p_dtrace->p_dtrace_model122#define p_fasttrap_tp_gen p_dtrace->p_fasttrap_tp_gen123124#define DATAMODEL_NATIVE 0125#ifdef __amd64__126#define DATAMODEL_LP64 0127#define DATAMODEL_ILP32 1128#else129#define DATAMODEL_LP64 1130#define DATAMODEL_ILP32 0131#endif132133/*134* Definitions for fields in struct proc which are named differently in FreeBSD.135*/136#define p_cred p_ucred137#define p_parent p_pptr138139/*140* Definitions for fields in struct thread which are named differently in FreeBSD.141*/142#define t_procp td_proc143#define t_tid td_tid144#define t_did td_tid145#define t_cred td_ucred146147148int priv_policy(const cred_t *, int, boolean_t, int, const char *);149boolean_t priv_policy_only(const cred_t *, int, boolean_t);150boolean_t priv_policy_choice(const cred_t *, int, boolean_t);151152/*153* Test privilege. Audit success or failure, allow privilege debugging.154* Returns 0 for success, err for failure.155*/156#define PRIV_POLICY(cred, priv, all, err, reason) \157priv_policy((cred), (priv), (all), (err), (reason))158159/*160* Test privilege. Audit success only, no privilege debugging.161* Returns 1 for success, and 0 for failure.162*/163#define PRIV_POLICY_CHOICE(cred, priv, all) \164priv_policy_choice((cred), (priv), (all))165166/*167* Test privilege. No priv_debugging, no auditing.168* Returns 1 for success, and 0 for failure.169*/170171#define PRIV_POLICY_ONLY(cred, priv, all) \172priv_policy_only((cred), (priv), (all))173174#endif /* !_DTRACE_CDDL_H_ */175176177