rtc: rv8803: Clear V1F when setting the time
[platform/kernel/linux-exynos.git] / arch / x86 / platform / efi / efi_64.c
1 /*
2  * x86_64 specific EFI support functions
3  * Based on Extensible Firmware Interface Specification version 1.0
4  *
5  * Copyright (C) 2005-2008 Intel Co.
6  *      Fenghua Yu <fenghua.yu@intel.com>
7  *      Bibo Mao <bibo.mao@intel.com>
8  *      Chandramouli Narayanan <mouli@linux.intel.com>
9  *      Huang Ying <ying.huang@intel.com>
10  *
11  * Code to convert EFI to E820 map has been implemented in elilo bootloader
12  * based on a EFI patch by Edgar Hucek. Based on the E820 map, the page table
13  * is setup appropriately for EFI runtime code.
14  * - mouli 06/14/2007.
15  *
16  */
17
18 #define pr_fmt(fmt) "efi: " fmt
19
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/mm.h>
23 #include <linux/types.h>
24 #include <linux/spinlock.h>
25 #include <linux/bootmem.h>
26 #include <linux/ioport.h>
27 #include <linux/module.h>
28 #include <linux/mc146818rtc.h>
29 #include <linux/efi.h>
30 #include <linux/uaccess.h>
31 #include <linux/io.h>
32 #include <linux/reboot.h>
33 #include <linux/slab.h>
34
35 #include <asm/setup.h>
36 #include <asm/page.h>
37 #include <asm/e820.h>
38 #include <asm/pgtable.h>
39 #include <asm/tlbflush.h>
40 #include <asm/proto.h>
41 #include <asm/efi.h>
42 #include <asm/cacheflush.h>
43 #include <asm/fixmap.h>
44 #include <asm/realmode.h>
45 #include <asm/time.h>
46 #include <asm/pgalloc.h>
47
48 /*
49  * We allocate runtime services regions bottom-up, starting from -4G, i.e.
50  * 0xffff_ffff_0000_0000 and limit EFI VA mapping space to 64G.
51  */
52 static u64 efi_va = EFI_VA_START;
53
54 struct efi_scratch efi_scratch;
55
56 static void __init early_code_mapping_set_exec(int executable)
57 {
58         efi_memory_desc_t *md;
59
60         if (!(__supported_pte_mask & _PAGE_NX))
61                 return;
62
63         /* Make EFI service code area executable */
64         for_each_efi_memory_desc(md) {
65                 if (md->type == EFI_RUNTIME_SERVICES_CODE ||
66                     md->type == EFI_BOOT_SERVICES_CODE)
67                         efi_set_executable(md, executable);
68         }
69 }
70
71 pgd_t * __init efi_call_phys_prolog(void)
72 {
73         unsigned long vaddress;
74         pgd_t *save_pgd;
75
76         int pgd;
77         int n_pgds;
78
79         if (!efi_enabled(EFI_OLD_MEMMAP)) {
80                 save_pgd = (pgd_t *)read_cr3();
81                 write_cr3((unsigned long)efi_scratch.efi_pgt);
82                 goto out;
83         }
84
85         early_code_mapping_set_exec(1);
86
87         n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
88         save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL);
89
90         for (pgd = 0; pgd < n_pgds; pgd++) {
91                 save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
92                 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
93                 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
94         }
95 out:
96         __flush_tlb_all();
97
98         return save_pgd;
99 }
100
101 void __init efi_call_phys_epilog(pgd_t *save_pgd)
102 {
103         /*
104          * After the lock is released, the original page table is restored.
105          */
106         int pgd_idx;
107         int nr_pgds;
108
109         if (!efi_enabled(EFI_OLD_MEMMAP)) {
110                 write_cr3((unsigned long)save_pgd);
111                 __flush_tlb_all();
112                 return;
113         }
114
115         nr_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
116
117         for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++)
118                 set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);
119
120         kfree(save_pgd);
121
122         __flush_tlb_all();
123         early_code_mapping_set_exec(0);
124 }
125
126 static pgd_t *efi_pgd;
127
128 /*
129  * We need our own copy of the higher levels of the page tables
130  * because we want to avoid inserting EFI region mappings (EFI_VA_END
131  * to EFI_VA_START) into the standard kernel page tables. Everything
132  * else can be shared, see efi_sync_low_kernel_mappings().
133  */
134 int __init efi_alloc_page_tables(void)
135 {
136         pgd_t *pgd;
137         pud_t *pud;
138         gfp_t gfp_mask;
139
140         if (efi_enabled(EFI_OLD_MEMMAP))
141                 return 0;
142
143         gfp_mask = GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO;
144         efi_pgd = (pgd_t *)__get_free_page(gfp_mask);
145         if (!efi_pgd)
146                 return -ENOMEM;
147
148         pgd = efi_pgd + pgd_index(EFI_VA_END);
149
150         pud = pud_alloc_one(NULL, 0);
151         if (!pud) {
152                 free_page((unsigned long)efi_pgd);
153                 return -ENOMEM;
154         }
155
156         pgd_populate(NULL, pgd, pud);
157
158         return 0;
159 }
160
161 /*
162  * Add low kernel mappings for passing arguments to EFI functions.
163  */
164 void efi_sync_low_kernel_mappings(void)
165 {
166         unsigned num_entries;
167         pgd_t *pgd_k, *pgd_efi;
168         pud_t *pud_k, *pud_efi;
169
170         if (efi_enabled(EFI_OLD_MEMMAP))
171                 return;
172
173         /*
174          * We can share all PGD entries apart from the one entry that
175          * covers the EFI runtime mapping space.
176          *
177          * Make sure the EFI runtime region mappings are guaranteed to
178          * only span a single PGD entry and that the entry also maps
179          * other important kernel regions.
180          */
181         BUILD_BUG_ON(pgd_index(EFI_VA_END) != pgd_index(MODULES_END));
182         BUILD_BUG_ON((EFI_VA_START & PGDIR_MASK) !=
183                         (EFI_VA_END & PGDIR_MASK));
184
185         pgd_efi = efi_pgd + pgd_index(PAGE_OFFSET);
186         pgd_k = pgd_offset_k(PAGE_OFFSET);
187
188         num_entries = pgd_index(EFI_VA_END) - pgd_index(PAGE_OFFSET);
189         memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries);
190
191         /*
192          * We share all the PUD entries apart from those that map the
193          * EFI regions. Copy around them.
194          */
195         BUILD_BUG_ON((EFI_VA_START & ~PUD_MASK) != 0);
196         BUILD_BUG_ON((EFI_VA_END & ~PUD_MASK) != 0);
197
198         pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
199         pud_efi = pud_offset(pgd_efi, 0);
200
201         pgd_k = pgd_offset_k(EFI_VA_END);
202         pud_k = pud_offset(pgd_k, 0);
203
204         num_entries = pud_index(EFI_VA_END);
205         memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
206
207         pud_efi = pud_offset(pgd_efi, EFI_VA_START);
208         pud_k = pud_offset(pgd_k, EFI_VA_START);
209
210         num_entries = PTRS_PER_PUD - pud_index(EFI_VA_START);
211         memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
212 }
213
214 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
215 {
216         unsigned long pfn, text;
217         efi_memory_desc_t *md;
218         struct page *page;
219         unsigned npages;
220         pgd_t *pgd;
221
222         if (efi_enabled(EFI_OLD_MEMMAP))
223                 return 0;
224
225         efi_scratch.efi_pgt = (pgd_t *)__pa(efi_pgd);
226         pgd = efi_pgd;
227
228         /*
229          * It can happen that the physical address of new_memmap lands in memory
230          * which is not mapped in the EFI page table. Therefore we need to go
231          * and ident-map those pages containing the map before calling
232          * phys_efi_set_virtual_address_map().
233          */
234         pfn = pa_memmap >> PAGE_SHIFT;
235         if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, _PAGE_NX | _PAGE_RW)) {
236                 pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap);
237                 return 1;
238         }
239
240         efi_scratch.use_pgd = true;
241
242         /*
243          * When making calls to the firmware everything needs to be 1:1
244          * mapped and addressable with 32-bit pointers. Map the kernel
245          * text and allocate a new stack because we can't rely on the
246          * stack pointer being < 4GB.
247          */
248         if (!IS_ENABLED(CONFIG_EFI_MIXED))
249                 return 0;
250
251         /*
252          * Map all of RAM so that we can access arguments in the 1:1
253          * mapping when making EFI runtime calls.
254          */
255         for_each_efi_memory_desc(md) {
256                 if (md->type != EFI_CONVENTIONAL_MEMORY &&
257                     md->type != EFI_LOADER_DATA &&
258                     md->type != EFI_LOADER_CODE)
259                         continue;
260
261                 pfn = md->phys_addr >> PAGE_SHIFT;
262                 npages = md->num_pages;
263
264                 if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, _PAGE_RW)) {
265                         pr_err("Failed to map 1:1 memory\n");
266                         return 1;
267                 }
268         }
269
270         page = alloc_page(GFP_KERNEL|__GFP_DMA32);
271         if (!page)
272                 panic("Unable to allocate EFI runtime stack < 4GB\n");
273
274         efi_scratch.phys_stack = virt_to_phys(page_address(page));
275         efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */
276
277         npages = (_etext - _text) >> PAGE_SHIFT;
278         text = __pa(_text);
279         pfn = text >> PAGE_SHIFT;
280
281         if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, _PAGE_RW)) {
282                 pr_err("Failed to map kernel text 1:1\n");
283                 return 1;
284         }
285
286         return 0;
287 }
288
289 void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
290 {
291         kernel_unmap_pages_in_pgd(efi_pgd, pa_memmap, num_pages);
292 }
293
294 static void __init __map_region(efi_memory_desc_t *md, u64 va)
295 {
296         unsigned long flags = _PAGE_RW;
297         unsigned long pfn;
298         pgd_t *pgd = efi_pgd;
299
300         if (!(md->attribute & EFI_MEMORY_WB))
301                 flags |= _PAGE_PCD;
302
303         pfn = md->phys_addr >> PAGE_SHIFT;
304         if (kernel_map_pages_in_pgd(pgd, pfn, va, md->num_pages, flags))
305                 pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n",
306                            md->phys_addr, va);
307 }
308
309 void __init efi_map_region(efi_memory_desc_t *md)
310 {
311         unsigned long size = md->num_pages << PAGE_SHIFT;
312         u64 pa = md->phys_addr;
313
314         if (efi_enabled(EFI_OLD_MEMMAP))
315                 return old_map_region(md);
316
317         /*
318          * Make sure the 1:1 mappings are present as a catch-all for b0rked
319          * firmware which doesn't update all internal pointers after switching
320          * to virtual mode and would otherwise crap on us.
321          */
322         __map_region(md, md->phys_addr);
323
324         /*
325          * Enforce the 1:1 mapping as the default virtual address when
326          * booting in EFI mixed mode, because even though we may be
327          * running a 64-bit kernel, the firmware may only be 32-bit.
328          */
329         if (!efi_is_native () && IS_ENABLED(CONFIG_EFI_MIXED)) {
330                 md->virt_addr = md->phys_addr;
331                 return;
332         }
333
334         efi_va -= size;
335
336         /* Is PA 2M-aligned? */
337         if (!(pa & (PMD_SIZE - 1))) {
338                 efi_va &= PMD_MASK;
339         } else {
340                 u64 pa_offset = pa & (PMD_SIZE - 1);
341                 u64 prev_va = efi_va;
342
343                 /* get us the same offset within this 2M page */
344                 efi_va = (efi_va & PMD_MASK) + pa_offset;
345
346                 if (efi_va > prev_va)
347                         efi_va -= PMD_SIZE;
348         }
349
350         if (efi_va < EFI_VA_END) {
351                 pr_warn(FW_WARN "VA address range overflow!\n");
352                 return;
353         }
354
355         /* Do the VA map */
356         __map_region(md, efi_va);
357         md->virt_addr = efi_va;
358 }
359
360 /*
361  * kexec kernel will use efi_map_region_fixed to map efi runtime memory ranges.
362  * md->virt_addr is the original virtual address which had been mapped in kexec
363  * 1st kernel.
364  */
365 void __init efi_map_region_fixed(efi_memory_desc_t *md)
366 {
367         __map_region(md, md->virt_addr);
368 }
369
370 void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size,
371                                  u32 type, u64 attribute)
372 {
373         unsigned long last_map_pfn;
374
375         if (type == EFI_MEMORY_MAPPED_IO)
376                 return ioremap(phys_addr, size);
377
378         last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size);
379         if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size) {
380                 unsigned long top = last_map_pfn << PAGE_SHIFT;
381                 efi_ioremap(top, size - (top - phys_addr), type, attribute);
382         }
383
384         if (!(attribute & EFI_MEMORY_WB))
385                 efi_memory_uc((u64)(unsigned long)__va(phys_addr), size);
386
387         return (void __iomem *)__va(phys_addr);
388 }
389
390 void __init parse_efi_setup(u64 phys_addr, u32 data_len)
391 {
392         efi_setup = phys_addr + sizeof(struct setup_data);
393 }
394
395 void __init efi_runtime_update_mappings(void)
396 {
397         unsigned long pfn;
398         pgd_t *pgd = efi_pgd;
399         efi_memory_desc_t *md;
400
401         if (efi_enabled(EFI_OLD_MEMMAP)) {
402                 if (__supported_pte_mask & _PAGE_NX)
403                         runtime_code_page_mkexec();
404                 return;
405         }
406
407         if (!efi_enabled(EFI_NX_PE_DATA))
408                 return;
409
410         for_each_efi_memory_desc(md) {
411                 unsigned long pf = 0;
412
413                 if (!(md->attribute & EFI_MEMORY_RUNTIME))
414                         continue;
415
416                 if (!(md->attribute & EFI_MEMORY_WB))
417                         pf |= _PAGE_PCD;
418
419                 if ((md->attribute & EFI_MEMORY_XP) ||
420                         (md->type == EFI_RUNTIME_SERVICES_DATA))
421                         pf |= _PAGE_NX;
422
423                 if (!(md->attribute & EFI_MEMORY_RO) &&
424                         (md->type != EFI_RUNTIME_SERVICES_CODE))
425                         pf |= _PAGE_RW;
426
427                 /* Update the 1:1 mapping */
428                 pfn = md->phys_addr >> PAGE_SHIFT;
429                 if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, md->num_pages, pf))
430                         pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n",
431                                    md->phys_addr, md->virt_addr);
432
433                 if (kernel_map_pages_in_pgd(pgd, pfn, md->virt_addr, md->num_pages, pf))
434                         pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n",
435                                    md->phys_addr, md->virt_addr);
436         }
437 }
438
439 void __init efi_dump_pagetable(void)
440 {
441 #ifdef CONFIG_EFI_PGT_DUMP
442         ptdump_walk_pgd_level(NULL, efi_pgd);
443 #endif
444 }
445
446 #ifdef CONFIG_EFI_MIXED
447 extern efi_status_t efi64_thunk(u32, ...);
448
449 #define runtime_service32(func)                                          \
450 ({                                                                       \
451         u32 table = (u32)(unsigned long)efi.systab;                      \
452         u32 *rt, *___f;                                                  \
453                                                                          \
454         rt = (u32 *)(table + offsetof(efi_system_table_32_t, runtime));  \
455         ___f = (u32 *)(*rt + offsetof(efi_runtime_services_32_t, func)); \
456         *___f;                                                           \
457 })
458
459 /*
460  * Switch to the EFI page tables early so that we can access the 1:1
461  * runtime services mappings which are not mapped in any other page
462  * tables. This function must be called before runtime_service32().
463  *
464  * Also, disable interrupts because the IDT points to 64-bit handlers,
465  * which aren't going to function correctly when we switch to 32-bit.
466  */
467 #define efi_thunk(f, ...)                                               \
468 ({                                                                      \
469         efi_status_t __s;                                               \
470         unsigned long flags;                                            \
471         u32 func;                                                       \
472                                                                         \
473         efi_sync_low_kernel_mappings();                                 \
474         local_irq_save(flags);                                          \
475                                                                         \
476         efi_scratch.prev_cr3 = read_cr3();                              \
477         write_cr3((unsigned long)efi_scratch.efi_pgt);                  \
478         __flush_tlb_all();                                              \
479                                                                         \
480         func = runtime_service32(f);                                    \
481         __s = efi64_thunk(func, __VA_ARGS__);                   \
482                                                                         \
483         write_cr3(efi_scratch.prev_cr3);                                \
484         __flush_tlb_all();                                              \
485         local_irq_restore(flags);                                       \
486                                                                         \
487         __s;                                                            \
488 })
489
490 efi_status_t efi_thunk_set_virtual_address_map(
491         void *phys_set_virtual_address_map,
492         unsigned long memory_map_size,
493         unsigned long descriptor_size,
494         u32 descriptor_version,
495         efi_memory_desc_t *virtual_map)
496 {
497         efi_status_t status;
498         unsigned long flags;
499         u32 func;
500
501         efi_sync_low_kernel_mappings();
502         local_irq_save(flags);
503
504         efi_scratch.prev_cr3 = read_cr3();
505         write_cr3((unsigned long)efi_scratch.efi_pgt);
506         __flush_tlb_all();
507
508         func = (u32)(unsigned long)phys_set_virtual_address_map;
509         status = efi64_thunk(func, memory_map_size, descriptor_size,
510                              descriptor_version, virtual_map);
511
512         write_cr3(efi_scratch.prev_cr3);
513         __flush_tlb_all();
514         local_irq_restore(flags);
515
516         return status;
517 }
518
519 static efi_status_t efi_thunk_get_time(efi_time_t *tm, efi_time_cap_t *tc)
520 {
521         efi_status_t status;
522         u32 phys_tm, phys_tc;
523
524         spin_lock(&rtc_lock);
525
526         phys_tm = virt_to_phys(tm);
527         phys_tc = virt_to_phys(tc);
528
529         status = efi_thunk(get_time, phys_tm, phys_tc);
530
531         spin_unlock(&rtc_lock);
532
533         return status;
534 }
535
536 static efi_status_t efi_thunk_set_time(efi_time_t *tm)
537 {
538         efi_status_t status;
539         u32 phys_tm;
540
541         spin_lock(&rtc_lock);
542
543         phys_tm = virt_to_phys(tm);
544
545         status = efi_thunk(set_time, phys_tm);
546
547         spin_unlock(&rtc_lock);
548
549         return status;
550 }
551
552 static efi_status_t
553 efi_thunk_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
554                           efi_time_t *tm)
555 {
556         efi_status_t status;
557         u32 phys_enabled, phys_pending, phys_tm;
558
559         spin_lock(&rtc_lock);
560
561         phys_enabled = virt_to_phys(enabled);
562         phys_pending = virt_to_phys(pending);
563         phys_tm = virt_to_phys(tm);
564
565         status = efi_thunk(get_wakeup_time, phys_enabled,
566                              phys_pending, phys_tm);
567
568         spin_unlock(&rtc_lock);
569
570         return status;
571 }
572
573 static efi_status_t
574 efi_thunk_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
575 {
576         efi_status_t status;
577         u32 phys_tm;
578
579         spin_lock(&rtc_lock);
580
581         phys_tm = virt_to_phys(tm);
582
583         status = efi_thunk(set_wakeup_time, enabled, phys_tm);
584
585         spin_unlock(&rtc_lock);
586
587         return status;
588 }
589
590
591 static efi_status_t
592 efi_thunk_get_variable(efi_char16_t *name, efi_guid_t *vendor,
593                        u32 *attr, unsigned long *data_size, void *data)
594 {
595         efi_status_t status;
596         u32 phys_name, phys_vendor, phys_attr;
597         u32 phys_data_size, phys_data;
598
599         phys_data_size = virt_to_phys(data_size);
600         phys_vendor = virt_to_phys(vendor);
601         phys_name = virt_to_phys(name);
602         phys_attr = virt_to_phys(attr);
603         phys_data = virt_to_phys(data);
604
605         status = efi_thunk(get_variable, phys_name, phys_vendor,
606                            phys_attr, phys_data_size, phys_data);
607
608         return status;
609 }
610
611 static efi_status_t
612 efi_thunk_set_variable(efi_char16_t *name, efi_guid_t *vendor,
613                        u32 attr, unsigned long data_size, void *data)
614 {
615         u32 phys_name, phys_vendor, phys_data;
616         efi_status_t status;
617
618         phys_name = virt_to_phys(name);
619         phys_vendor = virt_to_phys(vendor);
620         phys_data = virt_to_phys(data);
621
622         /* If data_size is > sizeof(u32) we've got problems */
623         status = efi_thunk(set_variable, phys_name, phys_vendor,
624                            attr, data_size, phys_data);
625
626         return status;
627 }
628
629 static efi_status_t
630 efi_thunk_get_next_variable(unsigned long *name_size,
631                             efi_char16_t *name,
632                             efi_guid_t *vendor)
633 {
634         efi_status_t status;
635         u32 phys_name_size, phys_name, phys_vendor;
636
637         phys_name_size = virt_to_phys(name_size);
638         phys_vendor = virt_to_phys(vendor);
639         phys_name = virt_to_phys(name);
640
641         status = efi_thunk(get_next_variable, phys_name_size,
642                            phys_name, phys_vendor);
643
644         return status;
645 }
646
647 static efi_status_t
648 efi_thunk_get_next_high_mono_count(u32 *count)
649 {
650         efi_status_t status;
651         u32 phys_count;
652
653         phys_count = virt_to_phys(count);
654         status = efi_thunk(get_next_high_mono_count, phys_count);
655
656         return status;
657 }
658
659 static void
660 efi_thunk_reset_system(int reset_type, efi_status_t status,
661                        unsigned long data_size, efi_char16_t *data)
662 {
663         u32 phys_data;
664
665         phys_data = virt_to_phys(data);
666
667         efi_thunk(reset_system, reset_type, status, data_size, phys_data);
668 }
669
670 static efi_status_t
671 efi_thunk_update_capsule(efi_capsule_header_t **capsules,
672                          unsigned long count, unsigned long sg_list)
673 {
674         /*
675          * To properly support this function we would need to repackage
676          * 'capsules' because the firmware doesn't understand 64-bit
677          * pointers.
678          */
679         return EFI_UNSUPPORTED;
680 }
681
682 static efi_status_t
683 efi_thunk_query_variable_info(u32 attr, u64 *storage_space,
684                               u64 *remaining_space,
685                               u64 *max_variable_size)
686 {
687         efi_status_t status;
688         u32 phys_storage, phys_remaining, phys_max;
689
690         if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
691                 return EFI_UNSUPPORTED;
692
693         phys_storage = virt_to_phys(storage_space);
694         phys_remaining = virt_to_phys(remaining_space);
695         phys_max = virt_to_phys(max_variable_size);
696
697         status = efi_thunk(query_variable_info, attr, phys_storage,
698                            phys_remaining, phys_max);
699
700         return status;
701 }
702
703 static efi_status_t
704 efi_thunk_query_capsule_caps(efi_capsule_header_t **capsules,
705                              unsigned long count, u64 *max_size,
706                              int *reset_type)
707 {
708         /*
709          * To properly support this function we would need to repackage
710          * 'capsules' because the firmware doesn't understand 64-bit
711          * pointers.
712          */
713         return EFI_UNSUPPORTED;
714 }
715
716 void efi_thunk_runtime_setup(void)
717 {
718         efi.get_time = efi_thunk_get_time;
719         efi.set_time = efi_thunk_set_time;
720         efi.get_wakeup_time = efi_thunk_get_wakeup_time;
721         efi.set_wakeup_time = efi_thunk_set_wakeup_time;
722         efi.get_variable = efi_thunk_get_variable;
723         efi.get_next_variable = efi_thunk_get_next_variable;
724         efi.set_variable = efi_thunk_set_variable;
725         efi.get_next_high_mono_count = efi_thunk_get_next_high_mono_count;
726         efi.reset_system = efi_thunk_reset_system;
727         efi.query_variable_info = efi_thunk_query_variable_info;
728         efi.update_capsule = efi_thunk_update_capsule;
729         efi.query_capsule_caps = efi_thunk_query_capsule_caps;
730 }
731 #endif /* CONFIG_EFI_MIXED */