ANDROID: arm64: Add a helper to retrieve the PTE of a fixmap

In order to transfer the early mapping state into KVM's MMIO
guard infrastructure, provide a small helper that will retrieve
the associated PTE.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Bug: 233587962
Change-Id: Iefc1c57d5e9476b718a8a68f60e562a57b09fb6a
Signed-off-by: Will Deacon <willdeacon@google.com>
This commit is contained in:
Marc Zyngier
2021-07-01 09:30:45 +01:00
committed by Will Deacon
parent 82e2a5389c
commit 94fb783d60
2 changed files with 17 additions and 0 deletions

View File

@@ -107,6 +107,8 @@ void __init early_fixmap_init(void);
extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
extern pte_t *__get_fixmap_pte(enum fixed_addresses idx);
#include <asm-generic/fixmap.h>
#endif /* !__ASSEMBLY__ */

View File

@@ -1332,6 +1332,21 @@ void __set_fixmap(enum fixed_addresses idx,
}
}
pte_t *__get_fixmap_pte(enum fixed_addresses idx)
{
unsigned long addr = __fix_to_virt(idx);
pte_t *ptep;
BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses);
ptep = fixmap_pte(addr);
if (!pte_valid(*ptep))
return NULL;
return ptep;
}
void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
{
const u64 dt_virt_base = __fix_to_virt(FIX_FDT);