lkml.org 
[lkml]   [2018]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V3 3/5] x86/efi: Permanently save the EFI_MEMORY_MAP passed by the firmware
On Tue, Sep 04, 2018 at 03:12:27PM -0700, Sai Praneeth Prakhya wrote:
> +void __init efi_save_original_memmap(void)
> +{
> + efi_memory_desc_t *md;
> + void *remapped_phys, *new_md;
> + phys_addr_t new_phys, new_size;
> +
> + new_size = efi.memmap.desc_size * efi.memmap.nr_map;
> + new_phys = efi_memmap_alloc(efi.memmap.nr_map);
> + if (!new_phys) {
> + pr_err("Failed to allocate new EFI memmap\n");
> + return;
> + }
> +
> + remapped_phys = memremap(new_phys, new_size, MEMREMAP_WB);
> + if (!remapped_phys) {
> + pr_err("Failed to remap new EFI memmap\n");
> + __free_pages(pfn_to_page(PHYS_PFN(new_phys)), get_order(new_size));
> + return;
> + }
> +
> + new_md = remapped_phys;
> + for_each_efi_memory_desc(md) {
> + memcpy(new_md, md, efi.memmap.desc_size);
> + new_md += efi.memmap.desc_size;
> + }

Should we ioremap_prot(remapped_phys, new_size, PROT_NONE), here? Such
that nobody can accidentally use this thing?

> + original_memory_map.late = 1;
> + original_memory_map.phys_map = new_phys;
> + original_memory_map.map = remapped_phys;
> + original_memory_map.nr_map = efi.memmap.nr_map;
> + original_memory_map.desc_size = efi.memmap.desc_size;
> + original_memory_map.map_end = remapped_phys + new_size;
> + original_memory_map.desc_version = efi.memmap.desc_version;
> +
> + original_memory_map_present = true;
> +}
> +#endif /* CONFIG_EFI_WARN_ON_ILLEGAL_ACCESS */
> --
> 2.7.4
>

\
 
 \ /
  Last update: 2018-09-05 13:49    [W:0.080 / U:3.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site