xref: /xnu-10063.121.3/iokit/Kernel/i386/IOKeyStoreHelper.cpp (revision 2c2f96dc2b9a4408a43d3150ae9c105355ca3daa)
1*2c2f96dcSApple OSS Distributions /*
2*2c2f96dcSApple OSS Distributions  * Copyright (c) 2010 Apple Inc. All rights reserved.
3*2c2f96dcSApple OSS Distributions  *
4*2c2f96dcSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*2c2f96dcSApple OSS Distributions  *
6*2c2f96dcSApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*2c2f96dcSApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*2c2f96dcSApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*2c2f96dcSApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*2c2f96dcSApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*2c2f96dcSApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*2c2f96dcSApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*2c2f96dcSApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*2c2f96dcSApple OSS Distributions  *
15*2c2f96dcSApple OSS Distributions  * Please obtain a copy of the License at
16*2c2f96dcSApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*2c2f96dcSApple OSS Distributions  *
18*2c2f96dcSApple OSS Distributions  * The Original Code and all software distributed under the License are
19*2c2f96dcSApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*2c2f96dcSApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*2c2f96dcSApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*2c2f96dcSApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*2c2f96dcSApple OSS Distributions  * Please see the License for the specific language governing rights and
24*2c2f96dcSApple OSS Distributions  * limitations under the License.
25*2c2f96dcSApple OSS Distributions  *
26*2c2f96dcSApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*2c2f96dcSApple OSS Distributions  */
28*2c2f96dcSApple OSS Distributions 
29*2c2f96dcSApple OSS Distributions #include <sys/cdefs.h>
30*2c2f96dcSApple OSS Distributions #include <stdbool.h>
31*2c2f96dcSApple OSS Distributions 
32*2c2f96dcSApple OSS Distributions #include <IOKit/assert.h>
33*2c2f96dcSApple OSS Distributions #include <IOKit/system.h>
34*2c2f96dcSApple OSS Distributions #include <IOKit/IOLib.h>
35*2c2f96dcSApple OSS Distributions #include <IOKit/IOMemoryDescriptor.h>
36*2c2f96dcSApple OSS Distributions #include <IOKit/IOKitDebug.h>
37*2c2f96dcSApple OSS Distributions 
38*2c2f96dcSApple OSS Distributions __BEGIN_DECLS
39*2c2f96dcSApple OSS Distributions 
40*2c2f96dcSApple OSS Distributions #include <pexpert/pexpert.h>
41*2c2f96dcSApple OSS Distributions 
42*2c2f96dcSApple OSS Distributions static volatile UInt32 alreadyFetched = 0;
43*2c2f96dcSApple OSS Distributions static IOMemoryDescriptor * newData;
44*2c2f96dcSApple OSS Distributions 
45*2c2f96dcSApple OSS Distributions IOMemoryDescriptor *
46*2c2f96dcSApple OSS Distributions IOGetBootKeyStoreData(void);
47*2c2f96dcSApple OSS Distributions void
48*2c2f96dcSApple OSS Distributions IOSetKeyStoreData(IOMemoryDescriptor * data);
49*2c2f96dcSApple OSS Distributions 
50*2c2f96dcSApple OSS Distributions // APFS
51*2c2f96dcSApple OSS Distributions static volatile UInt32 apfsKeyFetched = 0;
52*2c2f96dcSApple OSS Distributions static IOMemoryDescriptor* apfsKeyData = NULL;
53*2c2f96dcSApple OSS Distributions 
54*2c2f96dcSApple OSS Distributions IOMemoryDescriptor* IOGetAPFSKeyStoreData();
55*2c2f96dcSApple OSS Distributions void IOSetAPFSKeyStoreData(IOMemoryDescriptor* data);
56*2c2f96dcSApple OSS Distributions 
57*2c2f96dcSApple OSS Distributions static volatile UInt32 ARVRootHashFetched = 0;
58*2c2f96dcSApple OSS Distributions static volatile UInt32 bsARVRootHashFetched = 0;
59*2c2f96dcSApple OSS Distributions 
60*2c2f96dcSApple OSS Distributions IOMemoryDescriptor* IOGetARVRootHashData(void);
61*2c2f96dcSApple OSS Distributions IOMemoryDescriptor* IOGetBaseSystemARVRootHashData(void);
62*2c2f96dcSApple OSS Distributions 
63*2c2f96dcSApple OSS Distributions bool IOBaseSystemARVRootHashAvailable(void);
64*2c2f96dcSApple OSS Distributions 
65*2c2f96dcSApple OSS Distributions static volatile UInt32 ARVManifestFetched = 0;
66*2c2f96dcSApple OSS Distributions static volatile UInt32 bsARVManifestFetched = 0;
67*2c2f96dcSApple OSS Distributions 
68*2c2f96dcSApple OSS Distributions IOMemoryDescriptor* IOGetARVManifestData(void);
69*2c2f96dcSApple OSS Distributions IOMemoryDescriptor* IOGetBaseSystemARVManifestData(void);
70*2c2f96dcSApple OSS Distributions 
71*2c2f96dcSApple OSS Distributions __END_DECLS
72*2c2f96dcSApple OSS Distributions 
73*2c2f96dcSApple OSS Distributions #if 1
74*2c2f96dcSApple OSS Distributions #define DEBG(fmt, args...)      { kprintf(fmt, ## args); }
75*2c2f96dcSApple OSS Distributions #else
76*2c2f96dcSApple OSS Distributions #define DEBG(fmt, args...)      {}
77*2c2f96dcSApple OSS Distributions #endif
78*2c2f96dcSApple OSS Distributions 
79*2c2f96dcSApple OSS Distributions void
IOSetKeyStoreData(IOMemoryDescriptor * data)80*2c2f96dcSApple OSS Distributions IOSetKeyStoreData(IOMemoryDescriptor * data)
81*2c2f96dcSApple OSS Distributions {
82*2c2f96dcSApple OSS Distributions 	newData = data;
83*2c2f96dcSApple OSS Distributions 	alreadyFetched = 0;
84*2c2f96dcSApple OSS Distributions }
85*2c2f96dcSApple OSS Distributions 
86*2c2f96dcSApple OSS Distributions IOMemoryDescriptor *
IOGetBootKeyStoreData(void)87*2c2f96dcSApple OSS Distributions IOGetBootKeyStoreData(void)
88*2c2f96dcSApple OSS Distributions {
89*2c2f96dcSApple OSS Distributions 	IOMemoryDescriptor *memoryDescriptor;
90*2c2f96dcSApple OSS Distributions 	boot_args *args = (boot_args *)PE_state.bootArgs;
91*2c2f96dcSApple OSS Distributions 	IOOptionBits options;
92*2c2f96dcSApple OSS Distributions 	IOAddressRange ranges;
93*2c2f96dcSApple OSS Distributions 
94*2c2f96dcSApple OSS Distributions 	if (!OSCompareAndSwap(0, 1, &alreadyFetched)) {
95*2c2f96dcSApple OSS Distributions 		return NULL;
96*2c2f96dcSApple OSS Distributions 	}
97*2c2f96dcSApple OSS Distributions 
98*2c2f96dcSApple OSS Distributions 	if (newData) {
99*2c2f96dcSApple OSS Distributions 		IOMemoryDescriptor * data = newData;
100*2c2f96dcSApple OSS Distributions 		newData = NULL;
101*2c2f96dcSApple OSS Distributions 		return data;
102*2c2f96dcSApple OSS Distributions 	}
103*2c2f96dcSApple OSS Distributions 
104*2c2f96dcSApple OSS Distributions 	DEBG("%s: data at address %u size %u\n", __func__,
105*2c2f96dcSApple OSS Distributions 	    args->keyStoreDataStart,
106*2c2f96dcSApple OSS Distributions 	    args->keyStoreDataSize);
107*2c2f96dcSApple OSS Distributions 
108*2c2f96dcSApple OSS Distributions 	if (args->keyStoreDataStart == 0) {
109*2c2f96dcSApple OSS Distributions 		return NULL;
110*2c2f96dcSApple OSS Distributions 	}
111*2c2f96dcSApple OSS Distributions 
112*2c2f96dcSApple OSS Distributions 	ranges.address = args->keyStoreDataStart;
113*2c2f96dcSApple OSS Distributions 	ranges.length = args->keyStoreDataSize;
114*2c2f96dcSApple OSS Distributions 
115*2c2f96dcSApple OSS Distributions 	options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
116*2c2f96dcSApple OSS Distributions 
117*2c2f96dcSApple OSS Distributions 	memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges,
118*2c2f96dcSApple OSS Distributions 	    1,
119*2c2f96dcSApple OSS Distributions 	    0,
120*2c2f96dcSApple OSS Distributions 	    NULL,
121*2c2f96dcSApple OSS Distributions 	    options);
122*2c2f96dcSApple OSS Distributions 
123*2c2f96dcSApple OSS Distributions 	DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
124*2c2f96dcSApple OSS Distributions 
125*2c2f96dcSApple OSS Distributions 	return memoryDescriptor;
126*2c2f96dcSApple OSS Distributions }
127*2c2f96dcSApple OSS Distributions 
128*2c2f96dcSApple OSS Distributions // APFS volume key fetcher
129*2c2f96dcSApple OSS Distributions 
130*2c2f96dcSApple OSS Distributions // Store in-memory key (could be used by IOHibernateDone)
131*2c2f96dcSApple OSS Distributions void
IOSetAPFSKeyStoreData(IOMemoryDescriptor * data)132*2c2f96dcSApple OSS Distributions IOSetAPFSKeyStoreData(IOMemoryDescriptor* data)
133*2c2f96dcSApple OSS Distributions {
134*2c2f96dcSApple OSS Distributions 	// Do not allow re-fetching of the boot_args key by passing NULL here.
135*2c2f96dcSApple OSS Distributions 	if (data != NULL) {
136*2c2f96dcSApple OSS Distributions 		apfsKeyData = data;
137*2c2f96dcSApple OSS Distributions 		apfsKeyFetched = 0;
138*2c2f96dcSApple OSS Distributions 	}
139*2c2f96dcSApple OSS Distributions }
140*2c2f96dcSApple OSS Distributions 
141*2c2f96dcSApple OSS Distributions // Retrieve any key we may have (stored in boot_args or by Hibernate)
142*2c2f96dcSApple OSS Distributions IOMemoryDescriptor*
IOGetAPFSKeyStoreData()143*2c2f96dcSApple OSS Distributions IOGetAPFSKeyStoreData()
144*2c2f96dcSApple OSS Distributions {
145*2c2f96dcSApple OSS Distributions 	// Check if someone got the key before us
146*2c2f96dcSApple OSS Distributions 	if (!OSCompareAndSwap(0, 1, &apfsKeyFetched)) {
147*2c2f96dcSApple OSS Distributions 		return NULL;
148*2c2f96dcSApple OSS Distributions 	}
149*2c2f96dcSApple OSS Distributions 
150*2c2f96dcSApple OSS Distributions 	// Do we have in-memory key?
151*2c2f96dcSApple OSS Distributions 	if (apfsKeyData) {
152*2c2f96dcSApple OSS Distributions 		IOMemoryDescriptor* data = apfsKeyData;
153*2c2f96dcSApple OSS Distributions 		apfsKeyData = NULL;
154*2c2f96dcSApple OSS Distributions 		return data;
155*2c2f96dcSApple OSS Distributions 	}
156*2c2f96dcSApple OSS Distributions 
157*2c2f96dcSApple OSS Distributions 	// Looks like there was no in-memory key and it's the first call - try boot_args
158*2c2f96dcSApple OSS Distributions 	boot_args* args = (boot_args*)PE_state.bootArgs;
159*2c2f96dcSApple OSS Distributions 
160*2c2f96dcSApple OSS Distributions 	DEBG("%s: data at address %u size %u\n", __func__, args->apfsDataStart, args->apfsDataSize);
161*2c2f96dcSApple OSS Distributions 	if (args->apfsDataStart == 0) {
162*2c2f96dcSApple OSS Distributions 		return NULL;
163*2c2f96dcSApple OSS Distributions 	}
164*2c2f96dcSApple OSS Distributions 
165*2c2f96dcSApple OSS Distributions 	// We have the key in the boot_args, create IOMemoryDescriptor for the blob
166*2c2f96dcSApple OSS Distributions 	IOAddressRange ranges;
167*2c2f96dcSApple OSS Distributions 	ranges.address = args->apfsDataStart;
168*2c2f96dcSApple OSS Distributions 	ranges.length = args->apfsDataSize;
169*2c2f96dcSApple OSS Distributions 
170*2c2f96dcSApple OSS Distributions 	const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
171*2c2f96dcSApple OSS Distributions 
172*2c2f96dcSApple OSS Distributions 	IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
173*2c2f96dcSApple OSS Distributions 	DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
174*2c2f96dcSApple OSS Distributions 	return memoryDescriptor;
175*2c2f96dcSApple OSS Distributions }
176*2c2f96dcSApple OSS Distributions 
177*2c2f96dcSApple OSS Distributions // ARV Root Hash fetcher
178*2c2f96dcSApple OSS Distributions 
179*2c2f96dcSApple OSS Distributions // Retrieve any root hash we may have (stored in boot_args)
180*2c2f96dcSApple OSS Distributions IOMemoryDescriptor*
IOGetARVRootHashData(void)181*2c2f96dcSApple OSS Distributions IOGetARVRootHashData(void)
182*2c2f96dcSApple OSS Distributions {
183*2c2f96dcSApple OSS Distributions 	// Check if someone got the root hash before us
184*2c2f96dcSApple OSS Distributions 	if (!OSCompareAndSwap(0, 1, &ARVRootHashFetched)) {
185*2c2f96dcSApple OSS Distributions 		return NULL;
186*2c2f96dcSApple OSS Distributions 	}
187*2c2f96dcSApple OSS Distributions 
188*2c2f96dcSApple OSS Distributions 	boot_args* args = (boot_args*)PE_state.bootArgs;
189*2c2f96dcSApple OSS Distributions 
190*2c2f96dcSApple OSS Distributions 	DEBG("%s: data at address %llu size %llu\n", __func__, args->arvRootHashStart, args->arvRootHashSize);
191*2c2f96dcSApple OSS Distributions 	if (args->arvRootHashStart == 0) {
192*2c2f96dcSApple OSS Distributions 		return NULL;
193*2c2f96dcSApple OSS Distributions 	}
194*2c2f96dcSApple OSS Distributions 
195*2c2f96dcSApple OSS Distributions 	// We have the root hash in the boot_args, create IOMemoryDescriptor for the blob
196*2c2f96dcSApple OSS Distributions 	IOAddressRange ranges;
197*2c2f96dcSApple OSS Distributions 	ranges.address = args->arvRootHashStart;
198*2c2f96dcSApple OSS Distributions 	ranges.length = args->arvRootHashSize;
199*2c2f96dcSApple OSS Distributions 
200*2c2f96dcSApple OSS Distributions 	const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
201*2c2f96dcSApple OSS Distributions 
202*2c2f96dcSApple OSS Distributions 	IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
203*2c2f96dcSApple OSS Distributions 	DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
204*2c2f96dcSApple OSS Distributions 	return memoryDescriptor;
205*2c2f96dcSApple OSS Distributions }
206*2c2f96dcSApple OSS Distributions 
207*2c2f96dcSApple OSS Distributions // Base System Analogue
208*2c2f96dcSApple OSS Distributions 
209*2c2f96dcSApple OSS Distributions IOMemoryDescriptor*
IOGetBaseSystemARVRootHashData(void)210*2c2f96dcSApple OSS Distributions IOGetBaseSystemARVRootHashData(void)
211*2c2f96dcSApple OSS Distributions {
212*2c2f96dcSApple OSS Distributions 	// Check if someone got the base system root hash before us
213*2c2f96dcSApple OSS Distributions 	if (!OSCompareAndSwap(0, 1, &bsARVRootHashFetched)) {
214*2c2f96dcSApple OSS Distributions 		return NULL;
215*2c2f96dcSApple OSS Distributions 	}
216*2c2f96dcSApple OSS Distributions 
217*2c2f96dcSApple OSS Distributions 	boot_args* args = (boot_args*)PE_state.bootArgs;
218*2c2f96dcSApple OSS Distributions 
219*2c2f96dcSApple OSS Distributions 	DEBG("%s: data at address %llu size %llu\n", __func__, args->bsARVRootHashStart, args->bsARVRootHashSize);
220*2c2f96dcSApple OSS Distributions 	if (args->bsARVRootHashStart == 0) {
221*2c2f96dcSApple OSS Distributions 		return NULL;
222*2c2f96dcSApple OSS Distributions 	}
223*2c2f96dcSApple OSS Distributions 
224*2c2f96dcSApple OSS Distributions 	// We have the base system root hash in the boot_args, create IOMemoryDescriptor for the blob
225*2c2f96dcSApple OSS Distributions 	IOAddressRange ranges;
226*2c2f96dcSApple OSS Distributions 	ranges.address = args->bsARVRootHashStart;
227*2c2f96dcSApple OSS Distributions 	ranges.length = args->bsARVRootHashSize;
228*2c2f96dcSApple OSS Distributions 
229*2c2f96dcSApple OSS Distributions 	const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
230*2c2f96dcSApple OSS Distributions 
231*2c2f96dcSApple OSS Distributions 	IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
232*2c2f96dcSApple OSS Distributions 	DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
233*2c2f96dcSApple OSS Distributions 	return memoryDescriptor;
234*2c2f96dcSApple OSS Distributions }
235*2c2f96dcSApple OSS Distributions 
236*2c2f96dcSApple OSS Distributions bool
IOBaseSystemARVRootHashAvailable(void)237*2c2f96dcSApple OSS Distributions IOBaseSystemARVRootHashAvailable(void)
238*2c2f96dcSApple OSS Distributions {
239*2c2f96dcSApple OSS Distributions 	boot_args* args = (boot_args*)PE_state.bootArgs;
240*2c2f96dcSApple OSS Distributions 
241*2c2f96dcSApple OSS Distributions 	if (args->bsARVRootHashStart == 0 || args->bsARVRootHashSize == 0) {
242*2c2f96dcSApple OSS Distributions 		return false;
243*2c2f96dcSApple OSS Distributions 	}
244*2c2f96dcSApple OSS Distributions 
245*2c2f96dcSApple OSS Distributions 	if (args->bsARVManifestStart == 0 || args->bsARVManifestSize == 0) {
246*2c2f96dcSApple OSS Distributions 		return false;
247*2c2f96dcSApple OSS Distributions 	}
248*2c2f96dcSApple OSS Distributions 
249*2c2f96dcSApple OSS Distributions 	return true;
250*2c2f96dcSApple OSS Distributions }
251*2c2f96dcSApple OSS Distributions 
252*2c2f96dcSApple OSS Distributions // ARV Manifest fetcher
253*2c2f96dcSApple OSS Distributions 
254*2c2f96dcSApple OSS Distributions // Retrieve any manifest we may have (stored in boot_args)
255*2c2f96dcSApple OSS Distributions IOMemoryDescriptor*
IOGetARVManifestData(void)256*2c2f96dcSApple OSS Distributions IOGetARVManifestData(void)
257*2c2f96dcSApple OSS Distributions {
258*2c2f96dcSApple OSS Distributions 	// Check if someone got the manifest before us
259*2c2f96dcSApple OSS Distributions 	if (!OSCompareAndSwap(0, 1, &ARVManifestFetched)) {
260*2c2f96dcSApple OSS Distributions 		return NULL;
261*2c2f96dcSApple OSS Distributions 	}
262*2c2f96dcSApple OSS Distributions 
263*2c2f96dcSApple OSS Distributions 	boot_args* args = (boot_args*)PE_state.bootArgs;
264*2c2f96dcSApple OSS Distributions 
265*2c2f96dcSApple OSS Distributions 	DEBG("%s: data at address %llu size %llu\n", __func__, args->arvManifestStart, args->arvManifestSize);
266*2c2f96dcSApple OSS Distributions 	if (args->arvManifestStart == 0) {
267*2c2f96dcSApple OSS Distributions 		return NULL;
268*2c2f96dcSApple OSS Distributions 	}
269*2c2f96dcSApple OSS Distributions 
270*2c2f96dcSApple OSS Distributions 	// We have the manifest in the boot_args, create IOMemoryDescriptor for the blob
271*2c2f96dcSApple OSS Distributions 	IOAddressRange ranges;
272*2c2f96dcSApple OSS Distributions 	ranges.address = args->arvManifestStart;
273*2c2f96dcSApple OSS Distributions 	ranges.length = args->arvManifestSize;
274*2c2f96dcSApple OSS Distributions 
275*2c2f96dcSApple OSS Distributions 	const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
276*2c2f96dcSApple OSS Distributions 
277*2c2f96dcSApple OSS Distributions 	IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
278*2c2f96dcSApple OSS Distributions 	DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
279*2c2f96dcSApple OSS Distributions 	return memoryDescriptor;
280*2c2f96dcSApple OSS Distributions }
281*2c2f96dcSApple OSS Distributions 
282*2c2f96dcSApple OSS Distributions // Base System Analogue
283*2c2f96dcSApple OSS Distributions 
284*2c2f96dcSApple OSS Distributions IOMemoryDescriptor*
IOGetBaseSystemARVManifestData(void)285*2c2f96dcSApple OSS Distributions IOGetBaseSystemARVManifestData(void)
286*2c2f96dcSApple OSS Distributions {
287*2c2f96dcSApple OSS Distributions 	// Check if someone got the base system manifest before us
288*2c2f96dcSApple OSS Distributions 	if (!OSCompareAndSwap(0, 1, &bsARVManifestFetched)) {
289*2c2f96dcSApple OSS Distributions 		return NULL;
290*2c2f96dcSApple OSS Distributions 	}
291*2c2f96dcSApple OSS Distributions 
292*2c2f96dcSApple OSS Distributions 	boot_args* args = (boot_args*)PE_state.bootArgs;
293*2c2f96dcSApple OSS Distributions 
294*2c2f96dcSApple OSS Distributions 	DEBG("%s: data at address %llu size %llu\n", __func__, args->bsARVManifestStart, args->bsARVManifestSize);
295*2c2f96dcSApple OSS Distributions 	if (args->bsARVManifestStart == 0) {
296*2c2f96dcSApple OSS Distributions 		return NULL;
297*2c2f96dcSApple OSS Distributions 	}
298*2c2f96dcSApple OSS Distributions 
299*2c2f96dcSApple OSS Distributions 	// We have the manifest in the boot_args, create IOMemoryDescriptor for the blob
300*2c2f96dcSApple OSS Distributions 	IOAddressRange ranges;
301*2c2f96dcSApple OSS Distributions 	ranges.address = args->bsARVManifestStart;
302*2c2f96dcSApple OSS Distributions 	ranges.length = args->bsARVManifestSize;
303*2c2f96dcSApple OSS Distributions 
304*2c2f96dcSApple OSS Distributions 	const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
305*2c2f96dcSApple OSS Distributions 
306*2c2f96dcSApple OSS Distributions 	IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
307*2c2f96dcSApple OSS Distributions 	DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
308*2c2f96dcSApple OSS Distributions 	return memoryDescriptor;
309*2c2f96dcSApple OSS Distributions }
310