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