xref: /xnu-11417.101.15/bsd/sys/munge.h (revision e3723e1f17661b24996789d8afc084c0c3303b26)
1*e3723e1fSApple OSS Distributions /*
2*e3723e1fSApple OSS Distributions  * Coyright (c) 2005-2024 Apple Inc. All rights reserved.
3*e3723e1fSApple OSS Distributions  *
4*e3723e1fSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*e3723e1fSApple OSS Distributions  *
6*e3723e1fSApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*e3723e1fSApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*e3723e1fSApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*e3723e1fSApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*e3723e1fSApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*e3723e1fSApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*e3723e1fSApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*e3723e1fSApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*e3723e1fSApple OSS Distributions  *
15*e3723e1fSApple OSS Distributions  * Please obtain a copy of the License at
16*e3723e1fSApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*e3723e1fSApple OSS Distributions  *
18*e3723e1fSApple OSS Distributions  * The Original Code and all software distributed under the License are
19*e3723e1fSApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*e3723e1fSApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*e3723e1fSApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*e3723e1fSApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*e3723e1fSApple OSS Distributions  * Please see the License for the specific language governing rights and
24*e3723e1fSApple OSS Distributions  * limitations under the License.
25*e3723e1fSApple OSS Distributions  *
26*e3723e1fSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*e3723e1fSApple OSS Distributions  */
28*e3723e1fSApple OSS Distributions 
29*e3723e1fSApple OSS Distributions #ifndef __MUNGE_H__
30*e3723e1fSApple OSS Distributions #define __MUNGE_H__
31*e3723e1fSApple OSS Distributions 
32*e3723e1fSApple OSS Distributions /*
33*e3723e1fSApple OSS Distributions  * Syscall argument mungers.
34*e3723e1fSApple OSS Distributions  *
35*e3723e1fSApple OSS Distributions  * The data to be munged has been explicitly copied in to the argument
36*e3723e1fSApple OSS Distributions  * area, and will be munged in place in the uu_arg[] array. These
37*e3723e1fSApple OSS Distributions  * mungers are for 32-bit app's syscalls, since 64-bit args are copied
38*e3723e1fSApple OSS Distributions  * from the save area to the uu_args in the order the
39*e3723e1fSApple OSS Distributions  * syscall ABI calls for.
40*e3723e1fSApple OSS Distributions  *
41*e3723e1fSApple OSS Distributions  * The issue is that the incoming args are 32-bit, but we must expand
42*e3723e1fSApple OSS Distributions  * them in place into 64-bit args, as if they were from a 64-bit process.
43*e3723e1fSApple OSS Distributions  *
44*e3723e1fSApple OSS Distributions  * There are several functions in this file with the following prototype
45*e3723e1fSApple OSS Distributions  *
46*e3723e1fSApple OSS Distributions  *	void	munge_XXXX(void *uu_args);
47*e3723e1fSApple OSS Distributions  *
48*e3723e1fSApple OSS Distributions  * The name of the function encodes the number and type of the parameters,
49*e3723e1fSApple OSS Distributions  * as follows:
50*e3723e1fSApple OSS Distributions  *
51*e3723e1fSApple OSS Distributions  *	w = a 32-bit value such as an int or a 32-bit ptr, that does not
52*e3723e1fSApple OSS Distributions  *	    require sign extension.  These are handled by zeroing a word
53*e3723e1fSApple OSS Distributions  *          of output, and copying a word from input to output.
54*e3723e1fSApple OSS Distributions  *
55*e3723e1fSApple OSS Distributions  *	s = a 32-bit value such as a long, which must be sign-extended to
56*e3723e1fSApple OSS Distributions  *	    a 64-bit long-long in the uu_args.  These are handled by
57*e3723e1fSApple OSS Distributions  *	    loading a word of input and sign extending it to a double,
58*e3723e1fSApple OSS Distributions  *          and storing two words of output.
59*e3723e1fSApple OSS Distributions  *
60*e3723e1fSApple OSS Distributions  *	l = a 64-bit long-long.  These are handled by copying two words
61*e3723e1fSApple OSS Distributions  *          of input to the output.
62*e3723e1fSApple OSS Distributions  *
63*e3723e1fSApple OSS Distributions  * For example, "munge_wls" takes a word, a long-long, and a word.  This
64*e3723e1fSApple OSS Distributions  * takes four words in the uu_arg[] area: the first word is in one, the
65*e3723e1fSApple OSS Distributions  * long-long takes two, and the final word is in the fourth.  We store six
66*e3723e1fSApple OSS Distributions  * words: the low word is left in place, followed by a 0, followed by the
67*e3723e1fSApple OSS Distributions  * two words of the long-long, followed by the low word and the sign extended
68*e3723e1fSApple OSS Distributions  * high word of the preceeding low word.
69*e3723e1fSApple OSS Distributions  *
70*e3723e1fSApple OSS Distributions  * Because this is an in-place modification, we actually start at the end
71*e3723e1fSApple OSS Distributions  * of uu_arg[] and work our way back to the beginning of the array.
72*e3723e1fSApple OSS Distributions  */
73*e3723e1fSApple OSS Distributions 
74*e3723e1fSApple OSS Distributions #if __arm__ && (__BIGGEST_ALIGNMENT__ > 4)
75*e3723e1fSApple OSS Distributions int munge_w(const void *regs, void *args);
76*e3723e1fSApple OSS Distributions int munge_ww(const void *regs, void *args);
77*e3723e1fSApple OSS Distributions int munge_www(const void *regs, void *args);
78*e3723e1fSApple OSS Distributions int munge_wwww(const void *regs, void *args);
79*e3723e1fSApple OSS Distributions int munge_wwwww(const void *regs, void *args);
80*e3723e1fSApple OSS Distributions int munge_wwwwww(const void *regs, void *args);
81*e3723e1fSApple OSS Distributions int munge_wwwwwww(const void *regs, void *args);
82*e3723e1fSApple OSS Distributions int munge_wwwwwwww(const void *regs, void *args);
83*e3723e1fSApple OSS Distributions int munge_wl(const void *regs, void *args);
84*e3723e1fSApple OSS Distributions int munge_wwl(const void *regs, void *args);
85*e3723e1fSApple OSS Distributions int munge_wwlw(const void *regs, void *args);
86*e3723e1fSApple OSS Distributions int munge_wwlll(const void *regs, void *args);
87*e3723e1fSApple OSS Distributions int munge_wwlllll(const void *regs, void *args);
88*e3723e1fSApple OSS Distributions int munge_wwllllll(const void *regs, void *args);
89*e3723e1fSApple OSS Distributions int munge_wwllww(const void *regs, void *args);
90*e3723e1fSApple OSS Distributions int munge_wlw(const void *regs, void *args);
91*e3723e1fSApple OSS Distributions int munge_wlww(const void *regs, void *args);
92*e3723e1fSApple OSS Distributions int munge_wlwwwl(const void *regs, void *args);
93*e3723e1fSApple OSS Distributions int munge_wlwwwll(const void *regs, void *args);
94*e3723e1fSApple OSS Distributions int munge_wlwwwllw(const void *regs, void *args);
95*e3723e1fSApple OSS Distributions int munge_wlwwlwlw(const void *regs, void *args);
96*e3723e1fSApple OSS Distributions int munge_wll(const void *regs, void *args);
97*e3723e1fSApple OSS Distributions int munge_wllww(const void *regs, void *args);
98*e3723e1fSApple OSS Distributions int munge_wlll(const void *regs, void *args);
99*e3723e1fSApple OSS Distributions int munge_wlllww(const void *regs, void *args);
100*e3723e1fSApple OSS Distributions int munge_wllll(const void *regs, void *args);
101*e3723e1fSApple OSS Distributions int munge_wllwwll(const void *regs, void *args);
102*e3723e1fSApple OSS Distributions int munge_wwwlw(const void *regs, void *args);
103*e3723e1fSApple OSS Distributions int munge_wwwlww(const void *regs, void *args);
104*e3723e1fSApple OSS Distributions int munge_wwwlwww(const void *regs, void *args);
105*e3723e1fSApple OSS Distributions int munge_wwwl(const void *regs, void *args);
106*e3723e1fSApple OSS Distributions int munge_wwwwlw(const void *regs, void *args);
107*e3723e1fSApple OSS Distributions int munge_wwwwllww(const void *regs, void *args);
108*e3723e1fSApple OSS Distributions int munge_wwwwl(const void *regs, void *args);
109*e3723e1fSApple OSS Distributions int munge_wwwwwl(const void *regs, void *args);
110*e3723e1fSApple OSS Distributions int munge_wwwwwlww(const void *regs, void *args);
111*e3723e1fSApple OSS Distributions int munge_wwwwwllw(const void *regs, void *args);
112*e3723e1fSApple OSS Distributions int munge_wwwwwlll(const void *regs, void *args);
113*e3723e1fSApple OSS Distributions int munge_wwwwwwl(const void *regs, void *args);
114*e3723e1fSApple OSS Distributions int munge_wwwwwwlw(const void *regs, void *args);
115*e3723e1fSApple OSS Distributions int munge_wwwwwwll(const void *regs, void *args);
116*e3723e1fSApple OSS Distributions int munge_wsw(const void *regs, void *args);
117*e3723e1fSApple OSS Distributions int munge_wws(const void *regs, void *args);
118*e3723e1fSApple OSS Distributions int munge_wwws(const void *regs, void *args);
119*e3723e1fSApple OSS Distributions int munge_wwwsw(const void *regs, void *args);
120*e3723e1fSApple OSS Distributions int munge_llllllll(const void *regs, void *args);
121*e3723e1fSApple OSS Distributions int munge_llllll(const void *regs, void *args);
122*e3723e1fSApple OSS Distributions int munge_l(const void *regs, void *args);
123*e3723e1fSApple OSS Distributions int munge_ll(const void *regs, void *args);
124*e3723e1fSApple OSS Distributions int munge_lll(const void *regs, void *args);
125*e3723e1fSApple OSS Distributions int munge_lw(const void *regs, void *args);
126*e3723e1fSApple OSS Distributions int munge_lww(const void *regs, void *args);
127*e3723e1fSApple OSS Distributions int munge_lwww(const void *regs, void *args);
128*e3723e1fSApple OSS Distributions int munge_lwwwwwww(const void *regs, void *args);
129*e3723e1fSApple OSS Distributions int munge_wwlww(const void *regs, void *args);
130*e3723e1fSApple OSS Distributions int munge_wwlwww(const void *regs, void *args);
131*e3723e1fSApple OSS Distributions int munge_wwlwwwl(const void *regs, void *args);
132*e3723e1fSApple OSS Distributions int munge_wlwwlww(const void *regs, void *args);
133*e3723e1fSApple OSS Distributions #else
134*e3723e1fSApple OSS Distributions void munge_w(void *args);
135*e3723e1fSApple OSS Distributions void munge_ww(void *args);
136*e3723e1fSApple OSS Distributions void munge_www(void *args);
137*e3723e1fSApple OSS Distributions void munge_wwww(void *args);
138*e3723e1fSApple OSS Distributions void munge_wwwww(void *args);
139*e3723e1fSApple OSS Distributions void munge_wwwwww(void *args);
140*e3723e1fSApple OSS Distributions void munge_wwwwwww(void *args);
141*e3723e1fSApple OSS Distributions void munge_wwwwwwww(void *args);
142*e3723e1fSApple OSS Distributions void munge_wl(void *args);
143*e3723e1fSApple OSS Distributions void munge_wwl(void *args);
144*e3723e1fSApple OSS Distributions void munge_wwlw(void *args);
145*e3723e1fSApple OSS Distributions void munge_wwlll(void *args);
146*e3723e1fSApple OSS Distributions void munge_wwlllll(void *args);
147*e3723e1fSApple OSS Distributions void munge_wwllllll(void *args);
148*e3723e1fSApple OSS Distributions void munge_wwllww(void *args);
149*e3723e1fSApple OSS Distributions void munge_wlw(void *args);
150*e3723e1fSApple OSS Distributions void munge_wlww(void *args);
151*e3723e1fSApple OSS Distributions void munge_wlwwwl(void *args);
152*e3723e1fSApple OSS Distributions void munge_wlwwwll(void *args);
153*e3723e1fSApple OSS Distributions void munge_wlwwwllw(void *args);
154*e3723e1fSApple OSS Distributions void munge_wlwwlwlw(void *args);
155*e3723e1fSApple OSS Distributions void munge_wll(void *args);
156*e3723e1fSApple OSS Distributions void munge_wllww(void *args);
157*e3723e1fSApple OSS Distributions void munge_wlll(void *args);
158*e3723e1fSApple OSS Distributions void munge_wlllww(void *args);
159*e3723e1fSApple OSS Distributions void munge_wllll(void *args);
160*e3723e1fSApple OSS Distributions void munge_wllwwll(void *args);
161*e3723e1fSApple OSS Distributions void munge_wwwlw(void *args);
162*e3723e1fSApple OSS Distributions void munge_wwwlww(void *args);
163*e3723e1fSApple OSS Distributions void munge_wwwlwww(void *args);
164*e3723e1fSApple OSS Distributions void munge_wwwl(void *args);
165*e3723e1fSApple OSS Distributions void munge_wwwwlw(void *args);
166*e3723e1fSApple OSS Distributions void munge_wwwwllww(void *args);
167*e3723e1fSApple OSS Distributions void munge_wwwwl(void *args);
168*e3723e1fSApple OSS Distributions void munge_wwwwwl(void *args);
169*e3723e1fSApple OSS Distributions void munge_wwwwwlww(void *args);
170*e3723e1fSApple OSS Distributions void munge_wwwwwllw(void *args);
171*e3723e1fSApple OSS Distributions void munge_wwwwwlll(void *args);
172*e3723e1fSApple OSS Distributions void munge_wwwwwwl(void *args);
173*e3723e1fSApple OSS Distributions void munge_wwwwwwlw(void *args);
174*e3723e1fSApple OSS Distributions void munge_wwwwwwll(void *args);
175*e3723e1fSApple OSS Distributions void munge_wsw(void *args);
176*e3723e1fSApple OSS Distributions void munge_wws(void *args);
177*e3723e1fSApple OSS Distributions void munge_wwws(void *args);
178*e3723e1fSApple OSS Distributions void munge_wwwsw(void *args);
179*e3723e1fSApple OSS Distributions void munge_llllllll(void *args);
180*e3723e1fSApple OSS Distributions void munge_llllll(void *args);
181*e3723e1fSApple OSS Distributions void munge_llll(void *args);
182*e3723e1fSApple OSS Distributions void munge_l(void *args);
183*e3723e1fSApple OSS Distributions void munge_ll(void *args);
184*e3723e1fSApple OSS Distributions void munge_lll(void *args);
185*e3723e1fSApple OSS Distributions void munge_lw(void *args);
186*e3723e1fSApple OSS Distributions void munge_lww(void *args);
187*e3723e1fSApple OSS Distributions void munge_lwww(void *args);
188*e3723e1fSApple OSS Distributions void munge_lwwwwwww(void *args);
189*e3723e1fSApple OSS Distributions void munge_wwlww(void *args);
190*e3723e1fSApple OSS Distributions void munge_wwlwww(void *args);
191*e3723e1fSApple OSS Distributions void munge_wwlwwwl(void *args);
192*e3723e1fSApple OSS Distributions void munge_wlwwlww(void *args);
193*e3723e1fSApple OSS Distributions #endif /* __arm__ && (__BIGGEST_ALIGNMENT__ > 4) */
194*e3723e1fSApple OSS Distributions #endif /* __MUNGE_H__ */
195