Patch "KVM: arm/arm64: Fix HYP unmapping going off limits" has been added to the 4.14-stable tree
This is a note to let you know that I've just added the patch titled
KVM: arm/arm64: Fix HYP unmapping going off limits
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
kvm-arm-arm64-fix-hyp-unmapping-going-off-limits.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
7839c672e58bf62da8f2f0197fefb442c02ba1ddMon Sep 17 00:00:00 2001
From: Marc Zyngier <[email protected]>
Date: Thu, 7 Dec 2017 11:45:45 +0000
Subject: KVM: arm/arm64: Fix HYP unmapping going off limits
From: Marc Zyngier <[email protected]>
commit 7839c672e58bf62da8f2f0197fefb442c02ba1dd upstream.
When we unmap the HYP memory, we try to be clever and unmap one PGD at a time. If we start with a non-PGD aligned address and try to unmap a whole PGD, things go horribly wrong in unmap_hyp_range (addr and end can never match, and it all goes really badly as we keep incrementing pgd and parse random memory as page tables...).
The obvious fix is to let unmap_hyp_range do what it does best, which is to iterate over a range.
The size of the linear mapping, which begins at PAGE_OFFSET, can be easily calculated by subtracting PAGE_OFFSET form high_memory, because high_memory is defined as the linear map address of the last byte of DRAM, plus one.
The size of the vmalloc region is given trivially by VMALLOC_END - VMALLOC_START.
--- virt/kvm/arm/mmu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
virt/kvm/arm/mmu.c +4 -6
@@ -509,8 +509,6 @@ static void unmap_hyp_range(pgd_t *pgdp,*/ void free_hyp_pgds (void ) { -unsigned long addr; -mutex_lock (&kvm_hyp_pgd_mutex);if (boot_hyp_pgd) {
@@ -521,10 +519,10 @@ void free_hyp_pgds(void)if (hyp_pgd) {unmap_hyp_range (hyp_pgd, hyp_idmap_start,PAGE_SIZE ); -for (addr =PAGE_OFFSET ;virt_addr_valid (addr); addr +=PGDIR_SIZE ) -unmap_hyp_range (hyp_pgd,kern_hyp_va (addr),PGDIR_SIZE ); -for (addr =VMALLOC_START ;is_vmalloc_addr ((void *)addr); addr +=PGDIR_SIZE ) -unmap_hyp_range (hyp_pgd,kern_hyp_va (addr),PGDIR_SIZE ); +unmap_hyp_range (hyp_pgd,kern_hyp_va (PAGE_OFFSET ), + (uintptr_t )high_memory -PAGE_OFFSET ); +unmap_hyp_range (hyp_pgd,kern_hyp_va (VMALLOC_START ), +VMALLOC_END -VMALLOC_START );free_pages ((unsigned long )hyp_pgd, hyp_pgd_order); hyp_pgd =NULL ;
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/arm64-kvm-prevent-restoring-stale-pmscr_el1-for-vcpu.patch queue-4.14/kvm-arm-arm64-fix-hyp-unmapping-going-off-limits.patch