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