mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 22:35:37 +07:00
8b1e0f81fb
Drop the pgtable_t variable from all implementation for pte_fn_t as none of them use it. apply_to_pte_range() should stop computing it as well. Should help us save some cycles. Link: http://lkml.kernel.org/r/1556803126-26596-1-git-send-email-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Acked-by: Matthew Wilcox <willy@infradead.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Logan Gunthorpe <logang@deltatee.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: <jglisse@redhat.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
76 lines
2.0 KiB
C
76 lines
2.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
|
|
*/
|
|
|
|
#include <linux/efi.h>
|
|
#include <asm/efi.h>
|
|
#include <asm/mach/map.h>
|
|
#include <asm/mmu_context.h>
|
|
|
|
static int __init set_permissions(pte_t *ptep, unsigned long addr, void *data)
|
|
{
|
|
efi_memory_desc_t *md = data;
|
|
pte_t pte = *ptep;
|
|
|
|
if (md->attribute & EFI_MEMORY_RO)
|
|
pte = set_pte_bit(pte, __pgprot(L_PTE_RDONLY));
|
|
if (md->attribute & EFI_MEMORY_XP)
|
|
pte = set_pte_bit(pte, __pgprot(L_PTE_XN));
|
|
set_pte_ext(ptep, pte, PTE_EXT_NG);
|
|
return 0;
|
|
}
|
|
|
|
int __init efi_set_mapping_permissions(struct mm_struct *mm,
|
|
efi_memory_desc_t *md)
|
|
{
|
|
unsigned long base, size;
|
|
|
|
base = md->virt_addr;
|
|
size = md->num_pages << EFI_PAGE_SHIFT;
|
|
|
|
/*
|
|
* We can only use apply_to_page_range() if we can guarantee that the
|
|
* entire region was mapped using pages. This should be the case if the
|
|
* region does not cover any naturally aligned SECTION_SIZE sized
|
|
* blocks.
|
|
*/
|
|
if (round_down(base + size, SECTION_SIZE) <
|
|
round_up(base, SECTION_SIZE) + SECTION_SIZE)
|
|
return apply_to_page_range(mm, base, size, set_permissions, md);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
|
|
{
|
|
struct map_desc desc = {
|
|
.virtual = md->virt_addr,
|
|
.pfn = __phys_to_pfn(md->phys_addr),
|
|
.length = md->num_pages * EFI_PAGE_SIZE,
|
|
};
|
|
|
|
/*
|
|
* Order is important here: memory regions may have all of the
|
|
* bits below set (and usually do), so we check them in order of
|
|
* preference.
|
|
*/
|
|
if (md->attribute & EFI_MEMORY_WB)
|
|
desc.type = MT_MEMORY_RWX;
|
|
else if (md->attribute & EFI_MEMORY_WT)
|
|
desc.type = MT_MEMORY_RWX_NONCACHED;
|
|
else if (md->attribute & EFI_MEMORY_WC)
|
|
desc.type = MT_DEVICE_WC;
|
|
else
|
|
desc.type = MT_DEVICE;
|
|
|
|
create_mapping_late(mm, &desc, true);
|
|
|
|
/*
|
|
* If stricter permissions were specified, apply them now.
|
|
*/
|
|
if (md->attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP))
|
|
return efi_set_mapping_permissions(mm, md);
|
|
return 0;
|
|
}
|