From 8a597e7a2d06d699fb7b6c7787291e3916a502e2 Mon Sep 17 00:00:00 2001 From: Sebastian Ene Date: Tue, 31 Oct 2023 12:15:46 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Don't prepopulate MMIO regions for host stage-2 As we reserve only 1GB of memory for the MMIO region don't prepopulate the entire remaining address space with MMIO as this is prone to failure. Instead, let the MMIO regions to be created lazily on the fault path and keep only the RAM regions prepopulated. Bug: 307805059 Test: Boot pKVM with CONFIG_ARM64_16K_PAGES Change-Id: I6327f42eb17c6588335a1e04736393c9032114ab Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 2c1032a59826..b3920a37f334 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -149,22 +149,16 @@ static void prepare_host_vtcr(void) static int prepopulate_host_stage2(void) { struct memblock_region *reg; - u64 addr = 0; - int i, ret; + int i, ret = 0; for (i = 0; i < hyp_memblock_nr; i++) { reg = &hyp_memory[i]; - ret = host_stage2_idmap_locked(addr, reg->base - addr, PKVM_HOST_MMIO_PROT, false); - if (ret) - return ret; ret = host_stage2_idmap_locked(reg->base, reg->size, PKVM_HOST_MEM_PROT, false); if (ret) return ret; - addr = reg->base + reg->size; } - return host_stage2_idmap_locked(addr, BIT(host_mmu.pgt.ia_bits) - addr, PKVM_HOST_MMIO_PROT, - false); + return ret; } int kvm_host_prepare_stage2(void *pgt_pool_base)