X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3e170ce000f1506b7b5d2c5c7faec85ceabb573d..d26ffc64f583ab2d29df48f13518685602bc8832:/osfmk/mach/message.h?ds=sidebyside diff --git a/osfmk/mach/message.h b/osfmk/mach/message.h index b3769d484..13481e1bd 100644 --- a/osfmk/mach/message.h +++ b/osfmk/mach/message.h @@ -222,20 +222,23 @@ typedef unsigned int mach_msg_bits_t; typedef natural_t mach_msg_size_t; typedef integer_t mach_msg_id_t; - #define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0 +typedef unsigned int mach_msg_priority_t; + +#define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0 + typedef unsigned int mach_msg_type_name_t; -#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */ -#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */ -#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */ -#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */ -#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ -#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */ -#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */ -#define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */ -#define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */ +#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */ +#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */ +#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */ +#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */ +#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ +#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */ +#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */ +#define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */ +#define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */ #define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */ typedef unsigned int mach_msg_copy_options_t; @@ -493,6 +496,27 @@ typedef struct mach_port_context_t msgh_context; } mach_msg_context_trailer_t; +#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__) +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_port_context32_t msgh_context; +} mach_msg_context_trailer32_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_port_context64_t msgh_context; +} mach_msg_context_trailer64_t; +#endif typedef struct @@ -517,6 +541,32 @@ typedef struct msg_labels_t msgh_labels; } mach_msg_mac_trailer_t; +#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__) +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_port_context32_t msgh_context; + int msgh_ad; + msg_labels_t msgh_labels; +} mach_msg_mac_trailer32_t; + +typedef struct +{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_port_context64_t msgh_context; + int msgh_ad; + msg_labels_t msgh_labels; +} mach_msg_mac_trailer64_t; + +#endif #define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t) @@ -529,6 +579,10 @@ typedef struct * another module may exceed the local modules notion of * MAX_TRAILER_SIZE. */ +#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__) +typedef mach_msg_mac_trailer64_t mach_msg_max_trailer64_t; +typedef mach_msg_mac_trailer32_t mach_msg_max_trailer32_t; +#endif typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t; #define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t)) @@ -658,6 +712,7 @@ typedef integer_t mach_msg_option_t; #define MACH_RCV_LARGE_IDENTITY 0x00000008 /* identify source of large messages */ #define MACH_SEND_TIMEOUT 0x00000010 /* timeout value applies to send */ +#define MACH_SEND_OVERRIDE 0x00000020 /* priority override for send */ #define MACH_SEND_INTERRUPT 0x00000040 /* don't restart interrupted sends */ #define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */ #define MACH_SEND_ALWAYS 0x00010000 /* ignore qlimits - kernel only */ @@ -665,6 +720,7 @@ typedef integer_t mach_msg_option_t; #define MACH_SEND_NOIMPORTANCE 0x00040000 /* msg won't carry importance */ #define MACH_SEND_NODENAP MACH_SEND_NOIMPORTANCE #define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */ +#define MACH_SEND_SYNC_OVERRIDE 0x00100000 /* msg should do sync ipc override */ #define MACH_RCV_TIMEOUT 0x00000100 /* timeout value applies to receive */ @@ -672,6 +728,21 @@ typedef integer_t mach_msg_option_t; #define MACH_RCV_INTERRUPT 0x00000400 /* don't restart interrupted receive */ #define MACH_RCV_VOUCHER 0x00000800 /* willing to receive voucher port */ #define MACH_RCV_OVERWRITE 0x00001000 /* scatter receive (deprecated) */ +#define MACH_RCV_SYNC_WAIT 0x00004000 /* sync waiter waiting for rcv */ + +#ifdef XNU_KERNEL_PRIVATE + +#define MACH_RCV_STACK 0x00002000 /* receive into highest addr of buffer */ + +/* + * NOTE: + * This internal-only flag is intended for use by a single thread per-port/set! + * If more than one thread attempts to MACH_PEEK_MSG on a port or set, one of + * the threads may miss messages (in fact, it may never wake up). + */ +#define MACH_PEEK_MSG 0x00100000 /* receive, but leave msgs queued */ + +#endif /* * NOTE: a 0x00------ RCV mask implies to ask for @@ -698,31 +769,31 @@ typedef integer_t mach_msg_option_t; #ifdef MACH_KERNEL_PRIVATE /* The options that the kernel honors when passed from user space */ -#define MACH_SEND_USER (MACH_SEND_MSG | \ - MACH_SEND_TIMEOUT | MACH_SEND_NOTIFY | \ - MACH_SEND_TRAILER | MACH_SEND_NOIMPORTANCE ) +#define MACH_SEND_USER (MACH_SEND_MSG | MACH_SEND_TIMEOUT | \ + MACH_SEND_NOTIFY | MACH_SEND_OVERRIDE | \ + MACH_SEND_TRAILER | MACH_SEND_NOIMPORTANCE | \ + MACH_SEND_SYNC_OVERRIDE) -#define MACH_RCV_USER (MACH_RCV_MSG | MACH_RCV_TIMEOUT | \ - MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \ - MACH_RCV_VOUCHER | MACH_RCV_TRAILER_MASK) +#define MACH_RCV_USER (MACH_RCV_MSG | MACH_RCV_TIMEOUT | \ + MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \ + MACH_RCV_VOUCHER | MACH_RCV_TRAILER_MASK | \ + MACH_RCV_SYNC_WAIT) #define MACH_MSG_OPTION_USER (MACH_SEND_USER | MACH_RCV_USER) /* The options implemented by the library interface to mach_msg et. al. */ #define MACH_MSG_OPTION_LIB (MACH_SEND_INTERRUPT | MACH_RCV_INTERRUPT) -/* Default options to use when sending from the kernel */ -#if 11938665 - /* - * Until we are sure of its effects, we are disabling - * importance donation from the kernel-side of user - * threads in importance-donating tasks. - */ +/* + * Default options to use when sending from the kernel. + * + * Until we are sure of its effects, we are disabling + * importance donation from the kernel-side of user + * threads in importance-donating tasks. + * (11938665 & 23925818) + */ #define MACH_SEND_KERNEL_DEFAULT (MACH_SEND_MSG | \ MACH_SEND_ALWAYS | MACH_SEND_NOIMPORTANCE) -#else -#define MACH_SEND_KERNEL_DEFAULT (MACH_SEND_MSG | MACH_SEND_ALWAYS) -#endif #endif /* MACH_KERNEL_PRIVATE */ @@ -754,7 +825,25 @@ typedef integer_t mach_msg_option_t; #ifdef XNU_KERNEL_PRIVATE +#if defined(__arm64__) +#define REQUESTED_TRAILER_SIZE(is64, y) \ + ((mach_msg_trailer_size_t) \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \ + sizeof(mach_msg_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \ + sizeof(mach_msg_seqno_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \ + sizeof(mach_msg_security_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \ + sizeof(mach_msg_audit_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \ + ((is64) ? sizeof(mach_msg_context_trailer64_t) : sizeof(mach_msg_context_trailer32_t)) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \ + ((is64) ? sizeof(mach_msg_mac_trailer64_t) : sizeof(mach_msg_mac_trailer32_t)) : \ + sizeof(mach_msg_max_trailer_t)))))))) +#else #define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y) +#endif #else /* XNU_KERNEL_PRIVATE */ #define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y) @@ -855,6 +944,13 @@ typedef kern_return_t mach_msg_return_t; #define MACH_RCV_IN_PROGRESS_TIMED 0x10004011 /* Waiting for receive with timeout. (Internal use only.) */ +#ifdef XNU_KERNEL_PRIVATE +#define MACH_PEEK_IN_PROGRESS 0x10008001 + /* Waiting for a peek. (Internal use only.) */ +#define MACH_PEEK_READY 0x10008002 + /* Waiting for a peek. (Internal use only.) */ +#endif + __BEGIN_DECLS @@ -918,8 +1014,10 @@ extern kern_return_t mach_voucher_deallocate( #elif defined(MACH_KERNEL_PRIVATE) -extern mach_msg_return_t mach_msg_receive_results(void); +extern mach_msg_return_t mach_msg_receive_results(mach_msg_size_t *size); +extern mach_msg_priority_t mach_msg_priority_combine(mach_msg_priority_t msg_qos, + mach_msg_priority_t recv_qos); #endif /* KERNEL */ __END_DECLS