mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
ANDROID: KVM: arm64: Unmap PVM firmware from host stage-2 during de-privilege
Unmap the PVM firmware memory from the pKVM host by transferring ownership of the pages to the hypervisor when the host deprivileges itself during boot. Signed-off-by: Will Deacon <will@kernel.org> Bug: 209580772 Change-Id: I311642f543c0c73d0e0cf2ec051e8e2d9759c5d1 Signed-off-by: Will Deacon <willdeacon@google.com>
This commit is contained in:
@@ -231,6 +231,9 @@ static inline int pkvm_get_max_wrps(void)
|
||||
extern struct memblock_region kvm_nvhe_sym(hyp_memory)[];
|
||||
extern unsigned int kvm_nvhe_sym(hyp_memblock_nr);
|
||||
|
||||
extern phys_addr_t kvm_nvhe_sym(pvmfw_base);
|
||||
extern phys_addr_t kvm_nvhe_sym(pvmfw_size);
|
||||
|
||||
static inline unsigned long
|
||||
hyp_vmemmap_memblock_size(struct memblock_region *reg, size_t vmemmap_entry_size)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
unsigned long hyp_nr_cpus;
|
||||
|
||||
phys_addr_t pvmfw_base;
|
||||
phys_addr_t pvmfw_size;
|
||||
|
||||
#define hyp_percpu_size ((unsigned long)__per_cpu_end - \
|
||||
(unsigned long)__per_cpu_start)
|
||||
|
||||
@@ -135,6 +138,13 @@ static int recreate_hyp_mappings(phys_addr_t phys, unsigned long size,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
start = hyp_phys_to_virt(pvmfw_base);
|
||||
end = start + pvmfw_size;
|
||||
prot = pkvm_mkstate(PAGE_HYP, PKVM_PAGE_OWNED);
|
||||
ret = pkvm_create_mappings(start, end, prot);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "hyp_constants.h"
|
||||
|
||||
static struct reserved_mem *pkvm_firmware_mem;
|
||||
static phys_addr_t *pvmfw_base = &kvm_nvhe_sym(pvmfw_base);
|
||||
static phys_addr_t *pvmfw_size = &kvm_nvhe_sym(pvmfw_size);
|
||||
|
||||
static struct memblock_region *hyp_memory = kvm_nvhe_sym(hyp_memory);
|
||||
static unsigned int *hyp_memblock_nr_ptr = &kvm_nvhe_sym(hyp_memblock_nr);
|
||||
@@ -217,6 +219,8 @@ static int __init pkvm_firmware_rmem_init(struct reserved_mem *rmem)
|
||||
if (!PAGE_ALIGNED(rmem->size))
|
||||
return pkvm_firmware_rmem_err(rmem, "size is not page-aligned");
|
||||
|
||||
*pvmfw_size = rmem->size;
|
||||
*pvmfw_base = rmem->base;
|
||||
pkvm_firmware_mem = rmem;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user