arch/x86/platform/efi/efi_64.c
Source file repositories/reference/linux-study-clean/arch/x86/platform/efi/efi_64.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/platform/efi/efi_64.c- Extension
.c- Size
- 23194 bytes
- Lines
- 876
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/mm.hlinux/types.hlinux/spinlock.hlinux/memblock.hlinux/ioport.hlinux/mc146818rtc.hlinux/efi.hlinux/export.hlinux/uaccess.hlinux/io.hlinux/reboot.hlinux/slab.hlinux/ucs2_string.hlinux/cc_platform.hlinux/sched/task.hasm/setup.hasm/page.hasm/e820/api.hasm/tlbflush.hasm/proto.hasm/efi.hasm/cacheflush.hasm/fixmap.hasm/realmode.hasm/time.hasm/pgalloc.hasm/sev.h
Detected Declarations
function mappingsfunction efi_sync_low_kernel_mappingsfunction slow_virt_to_physfunction efi_setup_page_tablesfunction trim_bios_rangefunction __map_regionfunction efi_map_regionfunction efi_map_region_fixedfunction parse_efi_setupfunction efi_update_mappingsfunction efi_update_mem_attrfunction efi_runtime_update_mappingsfunction efi_dump_pagetablefunction efi_enter_mmfunction efi_leave_mmfunction efi_disable_lassfunction efi_enable_lassfunction arch_efi_call_virt_setupfunction arch_efi_call_virt_teardownfunction efi_thunk_set_virtual_address_mapfunction efi_thunk_get_timefunction efi_thunk_set_timefunction efi_thunk_get_wakeup_timefunction efi_thunk_set_wakeup_timefunction efi_name_sizefunction efi_thunk_get_variablefunction efi_thunk_set_variablefunction efi_thunk_set_variable_nonblockingfunction efi_thunk_get_next_variablefunction efi_thunk_get_next_high_mono_countfunction efi_thunk_reset_systemfunction efi_thunk_update_capsulefunction efi_thunk_query_variable_infofunction efi_thunk_query_variable_info_nonblockingfunction efi_thunk_query_capsule_capsfunction efi_thunk_runtime_setupfunction efi_set_virtual_address_map
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* x86_64 specific EFI support functions
* Based on Extensible Firmware Interface Specification version 1.0
*
* Copyright (C) 2005-2008 Intel Co.
* Fenghua Yu <fenghua.yu@intel.com>
* Bibo Mao <bibo.mao@intel.com>
* Chandramouli Narayanan <mouli@linux.intel.com>
* Huang Ying <ying.huang@intel.com>
*
* Code to convert EFI to E820 map has been implemented in elilo bootloader
* based on a EFI patch by Edgar Hucek. Based on the E820 map, the page table
* is setup appropriately for EFI runtime code.
* - mouli 06/14/2007.
*
*/
#define pr_fmt(fmt) "efi: " fmt
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/memblock.h>
#include <linux/ioport.h>
#include <linux/mc146818rtc.h>
#include <linux/efi.h>
#include <linux/export.h>
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/reboot.h>
#include <linux/slab.h>
#include <linux/ucs2_string.h>
#include <linux/cc_platform.h>
#include <linux/sched/task.h>
#include <asm/setup.h>
#include <asm/page.h>
#include <asm/e820/api.h>
#include <asm/tlbflush.h>
#include <asm/proto.h>
#include <asm/efi.h>
#include <asm/cacheflush.h>
#include <asm/fixmap.h>
#include <asm/realmode.h>
#include <asm/time.h>
#include <asm/pgalloc.h>
#include <asm/sev.h>
/*
* We allocate runtime services regions top-down, starting from -4G, i.e.
* 0xffff_ffff_0000_0000 and limit EFI VA mapping space to 64G.
*/
static u64 efi_va = EFI_VA_START;
static struct mm_struct *efi_prev_mm;
static unsigned long efi_cr4_lass;
/*
* We need our own copy of the higher levels of the page tables
* because we want to avoid inserting EFI region mappings (EFI_VA_END
* to EFI_VA_START) into the standard kernel page tables. Everything
* else can be shared, see efi_sync_low_kernel_mappings().
*
* We don't want the pgd on the pgd_list and cannot use pgd_alloc() for the
* allocation.
*/
int __init efi_alloc_page_tables(void)
{
pgd_t *pgd, *efi_pgd;
p4d_t *p4d;
pud_t *pud;
gfp_t gfp_mask;
gfp_mask = GFP_KERNEL | __GFP_ZERO;
efi_pgd = (pgd_t *)__get_free_pages(gfp_mask, pgd_allocation_order());
if (!efi_pgd)
goto fail;
pgd = efi_pgd + pgd_index(EFI_VA_END);
p4d = p4d_alloc(&init_mm, pgd, EFI_VA_END);
if (!p4d)
goto free_pgd;
pud = pud_alloc(&init_mm, p4d, EFI_VA_END);
if (!pud)
goto free_p4d;
efi_mm.pgd = efi_pgd;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/mm.h`, `linux/types.h`, `linux/spinlock.h`, `linux/memblock.h`, `linux/ioport.h`, `linux/mc146818rtc.h`.
- Detected declarations: `function mappings`, `function efi_sync_low_kernel_mappings`, `function slow_virt_to_phys`, `function efi_setup_page_tables`, `function trim_bios_range`, `function __map_region`, `function efi_map_region`, `function efi_map_region_fixed`, `function parse_efi_setup`, `function efi_update_mappings`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.