]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - arch/i386/kernel/efi.c
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[mirror_ubuntu-jammy-kernel.git] / arch / i386 / kernel / efi.c
1 /*
2 * Extensible Firmware Interface
3 *
4 * Based on Extensible Firmware Interface Specification version 1.0
5 *
6 * Copyright (C) 1999 VA Linux Systems
7 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
8 * Copyright (C) 1999-2002 Hewlett-Packard Co.
9 * David Mosberger-Tang <davidm@hpl.hp.com>
10 * Stephane Eranian <eranian@hpl.hp.com>
11 *
12 * All EFI Runtime Services are not implemented yet as EFI only
13 * supports physical mode addressing on SoftSDV. This is to be fixed
14 * in a future version. --drummond 1999-07-20
15 *
16 * Implemented EFI runtime services and virtual mode calls. --davidm
17 *
18 * Goutham Rao: <goutham.rao@intel.com>
19 * Skip non-WB memory and ignore empty memory ranges.
20 */
21
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/mm.h>
25 #include <linux/types.h>
26 #include <linux/time.h>
27 #include <linux/spinlock.h>
28 #include <linux/bootmem.h>
29 #include <linux/ioport.h>
30 #include <linux/module.h>
31 #include <linux/efi.h>
32 #include <linux/kexec.h>
33
34 #include <asm/setup.h>
35 #include <asm/io.h>
36 #include <asm/page.h>
37 #include <asm/pgtable.h>
38 #include <asm/processor.h>
39 #include <asm/desc.h>
40 #include <asm/tlbflush.h>
41
42 #define EFI_DEBUG 0
43 #define PFX "EFI: "
44
45 extern efi_status_t asmlinkage efi_call_phys(void *, ...);
46
47 struct efi efi;
48 EXPORT_SYMBOL(efi);
49 static struct efi efi_phys;
50 struct efi_memory_map memmap;
51
52 /*
53 * We require an early boot_ioremap mapping mechanism initially
54 */
55 extern void * boot_ioremap(unsigned long, unsigned long);
56
57 /*
58 * To make EFI call EFI runtime service in physical addressing mode we need
59 * prelog/epilog before/after the invocation to disable interrupt, to
60 * claim EFI runtime service handler exclusively and to duplicate a memory in
61 * low memory space say 0 - 3G.
62 */
63
64 static unsigned long efi_rt_eflags;
65 static DEFINE_SPINLOCK(efi_rt_lock);
66 static pgd_t efi_bak_pg_dir_pointer[2];
67
68 static void efi_call_phys_prelog(void)
69 {
70 unsigned long cr4;
71 unsigned long temp;
72 struct Xgt_desc_struct *cpu_gdt_descr;
73
74 spin_lock(&efi_rt_lock);
75 local_irq_save(efi_rt_eflags);
76
77 cpu_gdt_descr = &per_cpu(cpu_gdt_descr, 0);
78
79 /*
80 * If I don't have PSE, I should just duplicate two entries in page
81 * directory. If I have PSE, I just need to duplicate one entry in
82 * page directory.
83 */
84 cr4 = read_cr4();
85
86 if (cr4 & X86_CR4_PSE) {
87 efi_bak_pg_dir_pointer[0].pgd =
88 swapper_pg_dir[pgd_index(0)].pgd;
89 swapper_pg_dir[0].pgd =
90 swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
91 } else {
92 efi_bak_pg_dir_pointer[0].pgd =
93 swapper_pg_dir[pgd_index(0)].pgd;
94 efi_bak_pg_dir_pointer[1].pgd =
95 swapper_pg_dir[pgd_index(0x400000)].pgd;
96 swapper_pg_dir[pgd_index(0)].pgd =
97 swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
98 temp = PAGE_OFFSET + 0x400000;
99 swapper_pg_dir[pgd_index(0x400000)].pgd =
100 swapper_pg_dir[pgd_index(temp)].pgd;
101 }
102
103 /*
104 * After the lock is released, the original page table is restored.
105 */
106 local_flush_tlb();
107
108 cpu_gdt_descr->address = __pa(cpu_gdt_descr->address);
109 load_gdt(cpu_gdt_descr);
110 }
111
112 static void efi_call_phys_epilog(void)
113 {
114 unsigned long cr4;
115 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, 0);
116
117 cpu_gdt_descr->address = (unsigned long)__va(cpu_gdt_descr->address);
118 load_gdt(cpu_gdt_descr);
119
120 cr4 = read_cr4();
121
122 if (cr4 & X86_CR4_PSE) {
123 swapper_pg_dir[pgd_index(0)].pgd =
124 efi_bak_pg_dir_pointer[0].pgd;
125 } else {
126 swapper_pg_dir[pgd_index(0)].pgd =
127 efi_bak_pg_dir_pointer[0].pgd;
128 swapper_pg_dir[pgd_index(0x400000)].pgd =
129 efi_bak_pg_dir_pointer[1].pgd;
130 }
131
132 /*
133 * After the lock is released, the original page table is restored.
134 */
135 local_flush_tlb();
136
137 local_irq_restore(efi_rt_eflags);
138 spin_unlock(&efi_rt_lock);
139 }
140
141 static efi_status_t
142 phys_efi_set_virtual_address_map(unsigned long memory_map_size,
143 unsigned long descriptor_size,
144 u32 descriptor_version,
145 efi_memory_desc_t *virtual_map)
146 {
147 efi_status_t status;
148
149 efi_call_phys_prelog();
150 status = efi_call_phys(efi_phys.set_virtual_address_map,
151 memory_map_size, descriptor_size,
152 descriptor_version, virtual_map);
153 efi_call_phys_epilog();
154 return status;
155 }
156
157 static efi_status_t
158 phys_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
159 {
160 efi_status_t status;
161
162 efi_call_phys_prelog();
163 status = efi_call_phys(efi_phys.get_time, tm, tc);
164 efi_call_phys_epilog();
165 return status;
166 }
167
168 inline int efi_set_rtc_mmss(unsigned long nowtime)
169 {
170 int real_seconds, real_minutes;
171 efi_status_t status;
172 efi_time_t eft;
173 efi_time_cap_t cap;
174
175 spin_lock(&efi_rt_lock);
176 status = efi.get_time(&eft, &cap);
177 spin_unlock(&efi_rt_lock);
178 if (status != EFI_SUCCESS)
179 panic("Ooops, efitime: can't read time!\n");
180 real_seconds = nowtime % 60;
181 real_minutes = nowtime / 60;
182
183 if (((abs(real_minutes - eft.minute) + 15)/30) & 1)
184 real_minutes += 30;
185 real_minutes %= 60;
186
187 eft.minute = real_minutes;
188 eft.second = real_seconds;
189
190 if (status != EFI_SUCCESS) {
191 printk("Ooops: efitime: can't read time!\n");
192 return -1;
193 }
194 return 0;
195 }
196 /*
197 * This should only be used during kernel init and before runtime
198 * services have been remapped, therefore, we'll need to call in physical
199 * mode. Note, this call isn't used later, so mark it __init.
200 */
201 inline unsigned long __init efi_get_time(void)
202 {
203 efi_status_t status;
204 efi_time_t eft;
205 efi_time_cap_t cap;
206
207 status = phys_efi_get_time(&eft, &cap);
208 if (status != EFI_SUCCESS)
209 printk("Oops: efitime: can't read time status: 0x%lx\n",status);
210
211 return mktime(eft.year, eft.month, eft.day, eft.hour,
212 eft.minute, eft.second);
213 }
214
215 int is_available_memory(efi_memory_desc_t * md)
216 {
217 if (!(md->attribute & EFI_MEMORY_WB))
218 return 0;
219
220 switch (md->type) {
221 case EFI_LOADER_CODE:
222 case EFI_LOADER_DATA:
223 case EFI_BOOT_SERVICES_CODE:
224 case EFI_BOOT_SERVICES_DATA:
225 case EFI_CONVENTIONAL_MEMORY:
226 return 1;
227 }
228 return 0;
229 }
230
231 /*
232 * We need to map the EFI memory map again after paging_init().
233 */
234 void __init efi_map_memmap(void)
235 {
236 memmap.map = NULL;
237
238 memmap.map = bt_ioremap((unsigned long) memmap.phys_map,
239 (memmap.nr_map * memmap.desc_size));
240 if (memmap.map == NULL)
241 printk(KERN_ERR PFX "Could not remap the EFI memmap!\n");
242
243 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
244 }
245
246 #if EFI_DEBUG
247 static void __init print_efi_memmap(void)
248 {
249 efi_memory_desc_t *md;
250 void *p;
251 int i;
252
253 for (p = memmap.map, i = 0; p < memmap.map_end; p += memmap.desc_size, i++) {
254 md = p;
255 printk(KERN_INFO "mem%02u: type=%u, attr=0x%llx, "
256 "range=[0x%016llx-0x%016llx) (%lluMB)\n",
257 i, md->type, md->attribute, md->phys_addr,
258 md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
259 (md->num_pages >> (20 - EFI_PAGE_SHIFT)));
260 }
261 }
262 #endif /* EFI_DEBUG */
263
264 /*
265 * Walks the EFI memory map and calls CALLBACK once for each EFI
266 * memory descriptor that has memory that is available for kernel use.
267 */
268 void efi_memmap_walk(efi_freemem_callback_t callback, void *arg)
269 {
270 int prev_valid = 0;
271 struct range {
272 unsigned long start;
273 unsigned long end;
274 } prev, curr;
275 efi_memory_desc_t *md;
276 unsigned long start, end;
277 void *p;
278
279 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
280 md = p;
281
282 if ((md->num_pages == 0) || (!is_available_memory(md)))
283 continue;
284
285 curr.start = md->phys_addr;
286 curr.end = curr.start + (md->num_pages << EFI_PAGE_SHIFT);
287
288 if (!prev_valid) {
289 prev = curr;
290 prev_valid = 1;
291 } else {
292 if (curr.start < prev.start)
293 printk(KERN_INFO PFX "Unordered memory map\n");
294 if (prev.end == curr.start)
295 prev.end = curr.end;
296 else {
297 start =
298 (unsigned long) (PAGE_ALIGN(prev.start));
299 end = (unsigned long) (prev.end & PAGE_MASK);
300 if ((end > start)
301 && (*callback) (start, end, arg) < 0)
302 return;
303 prev = curr;
304 }
305 }
306 }
307 if (prev_valid) {
308 start = (unsigned long) PAGE_ALIGN(prev.start);
309 end = (unsigned long) (prev.end & PAGE_MASK);
310 if (end > start)
311 (*callback) (start, end, arg);
312 }
313 }
314
315 void __init efi_init(void)
316 {
317 efi_config_table_t *config_tables;
318 efi_runtime_services_t *runtime;
319 efi_char16_t *c16;
320 char vendor[100] = "unknown";
321 unsigned long num_config_tables;
322 int i = 0;
323
324 memset(&efi, 0, sizeof(efi) );
325 memset(&efi_phys, 0, sizeof(efi_phys));
326
327 efi_phys.systab = EFI_SYSTAB;
328 memmap.phys_map = EFI_MEMMAP;
329 memmap.nr_map = EFI_MEMMAP_SIZE/EFI_MEMDESC_SIZE;
330 memmap.desc_version = EFI_MEMDESC_VERSION;
331 memmap.desc_size = EFI_MEMDESC_SIZE;
332
333 efi.systab = (efi_system_table_t *)
334 boot_ioremap((unsigned long) efi_phys.systab,
335 sizeof(efi_system_table_t));
336 /*
337 * Verify the EFI Table
338 */
339 if (efi.systab == NULL)
340 printk(KERN_ERR PFX "Woah! Couldn't map the EFI system table.\n");
341 if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
342 printk(KERN_ERR PFX "Woah! EFI system table signature incorrect\n");
343 if ((efi.systab->hdr.revision ^ EFI_SYSTEM_TABLE_REVISION) >> 16 != 0)
344 printk(KERN_ERR PFX
345 "Warning: EFI system table major version mismatch: "
346 "got %d.%02d, expected %d.%02d\n",
347 efi.systab->hdr.revision >> 16,
348 efi.systab->hdr.revision & 0xffff,
349 EFI_SYSTEM_TABLE_REVISION >> 16,
350 EFI_SYSTEM_TABLE_REVISION & 0xffff);
351 /*
352 * Grab some details from the system table
353 */
354 num_config_tables = efi.systab->nr_tables;
355 config_tables = (efi_config_table_t *)efi.systab->tables;
356 runtime = efi.systab->runtime;
357
358 /*
359 * Show what we know for posterity
360 */
361 c16 = (efi_char16_t *) boot_ioremap(efi.systab->fw_vendor, 2);
362 if (c16) {
363 for (i = 0; i < (sizeof(vendor) - 1) && *c16; ++i)
364 vendor[i] = *c16++;
365 vendor[i] = '\0';
366 } else
367 printk(KERN_ERR PFX "Could not map the firmware vendor!\n");
368
369 printk(KERN_INFO PFX "EFI v%u.%.02u by %s \n",
370 efi.systab->hdr.revision >> 16,
371 efi.systab->hdr.revision & 0xffff, vendor);
372
373 /*
374 * Let's see what config tables the firmware passed to us.
375 */
376 config_tables = (efi_config_table_t *)
377 boot_ioremap((unsigned long) config_tables,
378 num_config_tables * sizeof(efi_config_table_t));
379
380 if (config_tables == NULL)
381 printk(KERN_ERR PFX "Could not map EFI Configuration Table!\n");
382
383 efi.mps = EFI_INVALID_TABLE_ADDR;
384 efi.acpi = EFI_INVALID_TABLE_ADDR;
385 efi.acpi20 = EFI_INVALID_TABLE_ADDR;
386 efi.smbios = EFI_INVALID_TABLE_ADDR;
387 efi.sal_systab = EFI_INVALID_TABLE_ADDR;
388 efi.boot_info = EFI_INVALID_TABLE_ADDR;
389 efi.hcdp = EFI_INVALID_TABLE_ADDR;
390 efi.uga = EFI_INVALID_TABLE_ADDR;
391
392 for (i = 0; i < num_config_tables; i++) {
393 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
394 efi.mps = config_tables[i].table;
395 printk(KERN_INFO " MPS=0x%lx ", config_tables[i].table);
396 } else
397 if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
398 efi.acpi20 = config_tables[i].table;
399 printk(KERN_INFO " ACPI 2.0=0x%lx ", config_tables[i].table);
400 } else
401 if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
402 efi.acpi = config_tables[i].table;
403 printk(KERN_INFO " ACPI=0x%lx ", config_tables[i].table);
404 } else
405 if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
406 efi.smbios = config_tables[i].table;
407 printk(KERN_INFO " SMBIOS=0x%lx ", config_tables[i].table);
408 } else
409 if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
410 efi.hcdp = config_tables[i].table;
411 printk(KERN_INFO " HCDP=0x%lx ", config_tables[i].table);
412 } else
413 if (efi_guidcmp(config_tables[i].guid, UGA_IO_PROTOCOL_GUID) == 0) {
414 efi.uga = config_tables[i].table;
415 printk(KERN_INFO " UGA=0x%lx ", config_tables[i].table);
416 }
417 }
418 printk("\n");
419
420 /*
421 * Check out the runtime services table. We need to map
422 * the runtime services table so that we can grab the physical
423 * address of several of the EFI runtime functions, needed to
424 * set the firmware into virtual mode.
425 */
426
427 runtime = (efi_runtime_services_t *) boot_ioremap((unsigned long)
428 runtime,
429 sizeof(efi_runtime_services_t));
430 if (runtime != NULL) {
431 /*
432 * We will only need *early* access to the following
433 * two EFI runtime services before set_virtual_address_map
434 * is invoked.
435 */
436 efi_phys.get_time = (efi_get_time_t *) runtime->get_time;
437 efi_phys.set_virtual_address_map =
438 (efi_set_virtual_address_map_t *)
439 runtime->set_virtual_address_map;
440 } else
441 printk(KERN_ERR PFX "Could not map the runtime service table!\n");
442
443 /* Map the EFI memory map for use until paging_init() */
444 memmap.map = boot_ioremap((unsigned long) EFI_MEMMAP, EFI_MEMMAP_SIZE);
445 if (memmap.map == NULL)
446 printk(KERN_ERR PFX "Could not map the EFI memory map!\n");
447
448 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
449
450 #if EFI_DEBUG
451 print_efi_memmap();
452 #endif
453 }
454
455 static inline void __init check_range_for_systab(efi_memory_desc_t *md)
456 {
457 if (((unsigned long)md->phys_addr <= (unsigned long)efi_phys.systab) &&
458 ((unsigned long)efi_phys.systab < md->phys_addr +
459 ((unsigned long)md->num_pages << EFI_PAGE_SHIFT))) {
460 unsigned long addr;
461
462 addr = md->virt_addr - md->phys_addr +
463 (unsigned long)efi_phys.systab;
464 efi.systab = (efi_system_table_t *)addr;
465 }
466 }
467
468 /*
469 * This function will switch the EFI runtime services to virtual mode.
470 * Essentially, look through the EFI memmap and map every region that
471 * has the runtime attribute bit set in its memory descriptor and update
472 * that memory descriptor with the virtual address obtained from ioremap().
473 * This enables the runtime services to be called without having to
474 * thunk back into physical mode for every invocation.
475 */
476
477 void __init efi_enter_virtual_mode(void)
478 {
479 efi_memory_desc_t *md;
480 efi_status_t status;
481 void *p;
482
483 efi.systab = NULL;
484
485 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
486 md = p;
487
488 if (!(md->attribute & EFI_MEMORY_RUNTIME))
489 continue;
490
491 md->virt_addr = (unsigned long)ioremap(md->phys_addr,
492 md->num_pages << EFI_PAGE_SHIFT);
493 if (!(unsigned long)md->virt_addr) {
494 printk(KERN_ERR PFX "ioremap of 0x%lX failed\n",
495 (unsigned long)md->phys_addr);
496 }
497 /* update the virtual address of the EFI system table */
498 check_range_for_systab(md);
499 }
500
501 if (!efi.systab)
502 BUG();
503
504 status = phys_efi_set_virtual_address_map(
505 memmap.desc_size * memmap.nr_map,
506 memmap.desc_size,
507 memmap.desc_version,
508 memmap.phys_map);
509
510 if (status != EFI_SUCCESS) {
511 printk (KERN_ALERT "You are screwed! "
512 "Unable to switch EFI into virtual mode "
513 "(status=%lx)\n", status);
514 panic("EFI call to SetVirtualAddressMap() failed!");
515 }
516
517 /*
518 * Now that EFI is in virtual mode, update the function
519 * pointers in the runtime service table to the new virtual addresses.
520 */
521
522 efi.get_time = (efi_get_time_t *) efi.systab->runtime->get_time;
523 efi.set_time = (efi_set_time_t *) efi.systab->runtime->set_time;
524 efi.get_wakeup_time = (efi_get_wakeup_time_t *)
525 efi.systab->runtime->get_wakeup_time;
526 efi.set_wakeup_time = (efi_set_wakeup_time_t *)
527 efi.systab->runtime->set_wakeup_time;
528 efi.get_variable = (efi_get_variable_t *)
529 efi.systab->runtime->get_variable;
530 efi.get_next_variable = (efi_get_next_variable_t *)
531 efi.systab->runtime->get_next_variable;
532 efi.set_variable = (efi_set_variable_t *)
533 efi.systab->runtime->set_variable;
534 efi.get_next_high_mono_count = (efi_get_next_high_mono_count_t *)
535 efi.systab->runtime->get_next_high_mono_count;
536 efi.reset_system = (efi_reset_system_t *)
537 efi.systab->runtime->reset_system;
538 }
539
540 void __init
541 efi_initialize_iomem_resources(struct resource *code_resource,
542 struct resource *data_resource)
543 {
544 struct resource *res;
545 efi_memory_desc_t *md;
546 void *p;
547
548 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
549 md = p;
550
551 if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >
552 0x100000000ULL)
553 continue;
554 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
555 switch (md->type) {
556 case EFI_RESERVED_TYPE:
557 res->name = "Reserved Memory";
558 break;
559 case EFI_LOADER_CODE:
560 res->name = "Loader Code";
561 break;
562 case EFI_LOADER_DATA:
563 res->name = "Loader Data";
564 break;
565 case EFI_BOOT_SERVICES_DATA:
566 res->name = "BootServices Data";
567 break;
568 case EFI_BOOT_SERVICES_CODE:
569 res->name = "BootServices Code";
570 break;
571 case EFI_RUNTIME_SERVICES_CODE:
572 res->name = "Runtime Service Code";
573 break;
574 case EFI_RUNTIME_SERVICES_DATA:
575 res->name = "Runtime Service Data";
576 break;
577 case EFI_CONVENTIONAL_MEMORY:
578 res->name = "Conventional Memory";
579 break;
580 case EFI_UNUSABLE_MEMORY:
581 res->name = "Unusable Memory";
582 break;
583 case EFI_ACPI_RECLAIM_MEMORY:
584 res->name = "ACPI Reclaim";
585 break;
586 case EFI_ACPI_MEMORY_NVS:
587 res->name = "ACPI NVS";
588 break;
589 case EFI_MEMORY_MAPPED_IO:
590 res->name = "Memory Mapped IO";
591 break;
592 case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
593 res->name = "Memory Mapped IO Port Space";
594 break;
595 default:
596 res->name = "Reserved";
597 break;
598 }
599 res->start = md->phys_addr;
600 res->end = res->start + ((md->num_pages << EFI_PAGE_SHIFT) - 1);
601 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
602 if (request_resource(&iomem_resource, res) < 0)
603 printk(KERN_ERR PFX "Failed to allocate res %s : "
604 "0x%llx-0x%llx\n", res->name,
605 (unsigned long long)res->start,
606 (unsigned long long)res->end);
607 /*
608 * We don't know which region contains kernel data so we try
609 * it repeatedly and let the resource manager test it.
610 */
611 if (md->type == EFI_CONVENTIONAL_MEMORY) {
612 request_resource(res, code_resource);
613 request_resource(res, data_resource);
614 #ifdef CONFIG_KEXEC
615 request_resource(res, &crashk_res);
616 #endif
617 }
618 }
619 }
620
621 /*
622 * Convenience functions to obtain memory types and attributes
623 */
624
625 u32 efi_mem_type(unsigned long phys_addr)
626 {
627 efi_memory_desc_t *md;
628 void *p;
629
630 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
631 md = p;
632 if ((md->phys_addr <= phys_addr) && (phys_addr <
633 (md->phys_addr + (md-> num_pages << EFI_PAGE_SHIFT)) ))
634 return md->type;
635 }
636 return 0;
637 }
638
639 u64 efi_mem_attributes(unsigned long phys_addr)
640 {
641 efi_memory_desc_t *md;
642 void *p;
643
644 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
645 md = p;
646 if ((md->phys_addr <= phys_addr) && (phys_addr <
647 (md->phys_addr + (md-> num_pages << EFI_PAGE_SHIFT)) ))
648 return md->attribute;
649 }
650 return 0;
651 }