All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [patch added to 3.12-stable] kvm-arm: Unmap shadow pagetables properly
Date: Thu, 29 Sep 2016 11:06:17 +0200	[thread overview]
Message-ID: <20160929090654.27405-6-jslaby@suse.cz> (raw)
In-Reply-To: <20160929090654.27405-1-jslaby@suse.cz>

From: Suzuki K Poulose <suzuki.poulose@arm.com>

This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.

===============

commit 293f293637b55db4f9f522a5a72514e98a541076 upstream.

On arm/arm64, we depend on the kvm_unmap_hva* callbacks (via
mmu_notifiers::invalidate_*) to unmap the stage2 pagetables when
the userspace buffer gets unmapped. However, when the Hypervisor
process exits without explicit unmap of the guest buffers, the only
notifier we get is kvm_arch_flush_shadow_all() (via mmu_notifier::release
) which does nothing on arm. Later this causes us to access pages that
were already released [via exit_mmap() -> unmap_vmas()] when we actually
get to unmap the stage2 pagetable [via kvm_arch_destroy_vm() ->
kvm_free_stage2_pgd()]. This triggers crashes with CONFIG_DEBUG_PAGEALLOC,
which unmaps any free'd pages from the linear map.

 [  757.644120] Unable to handle kernel paging request at virtual address
  ffff800661e00000
 [  757.652046] pgd = ffff20000b1a2000
 [  757.655471] [ffff800661e00000] *pgd=00000047fffe3003, *pud=00000047fcd8c003,
  *pmd=00000047fcc7c003, *pte=00e8004661e00712
 [  757.666492] Internal error: Oops: 96000147 [#3] PREEMPT SMP
 [  757.672041] Modules linked in:
 [  757.675100] CPU: 7 PID: 3630 Comm: qemu-system-aar Tainted: G      D
 4.8.0-rc1 #3
 [  757.683240] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene Mustang Board,
  BIOS 3.06.15 Aug 19 2016
 [  757.692938] task: ffff80069cdd3580 task.stack: ffff8006adb7c000
 [  757.698840] PC is at __flush_dcache_area+0x1c/0x40
 [  757.703613] LR is at kvm_flush_dcache_pmd+0x60/0x70
 [  757.708469] pc : [<ffff20000809dbdc>] lr : [<ffff2000080b4a70>] pstate: 20000145
 ...
 [  758.357249] [<ffff20000809dbdc>] __flush_dcache_area+0x1c/0x40
 [  758.363059] [<ffff2000080b6748>] unmap_stage2_range+0x458/0x5f0
 [  758.368954] [<ffff2000080b708c>] kvm_free_stage2_pgd+0x34/0x60
 [  758.374761] [<ffff2000080b2280>] kvm_arch_destroy_vm+0x20/0x68
 [  758.380570] [<ffff2000080aa330>] kvm_put_kvm+0x210/0x358
 [  758.385860] [<ffff2000080aa524>] kvm_vm_release+0x2c/0x40
 [  758.391239] [<ffff2000082ad234>] __fput+0x114/0x2e8
 [  758.396096] [<ffff2000082ad46c>] ____fput+0xc/0x18
 [  758.400869] [<ffff200008104658>] task_work_run+0x108/0x138
 [  758.406332] [<ffff2000080dc8ec>] do_exit+0x48c/0x10e8
 [  758.411363] [<ffff2000080dd5fc>] do_group_exit+0x6c/0x130
 [  758.416739] [<ffff2000080ed924>] get_signal+0x284/0xa18
 [  758.421943] [<ffff20000808a098>] do_signal+0x158/0x860
 [  758.427060] [<ffff20000808aad4>] do_notify_resume+0x6c/0x88
 [  758.432608] [<ffff200008083624>] work_pending+0x10/0x14
 [  758.437812] Code: 9ac32042 8b010001 d1000443 8a230000 (d50b7e20)

This patch fixes the issue by moving the kvm_free_stage2_pgd() to
kvm_arch_flush_shadow_all().

Tested-by: Itaru Kitayama <itaru.kitayama@riken.jp>
Reported-by: Itaru Kitayama <itaru.kitayama@riken.jp>
Reported-by: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/arm/kvm/arm.c | 2 --
 arch/arm/kvm/mmu.c | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 28b60461936e..25e58d390640 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -163,8 +163,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 {
 	int i;
 
-	kvm_free_stage2_pgd(kvm);
-
 	for (i = 0; i < KVM_MAX_VCPUS; ++i) {
 		if (kvm->vcpus[i]) {
 			kvm_arch_vcpu_free(kvm->vcpus[i]);
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 87a2769898ac..683cac91a7f6 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1096,6 +1096,7 @@ void kvm_arch_memslots_updated(struct kvm *kvm)
 
 void kvm_arch_flush_shadow_all(struct kvm *kvm)
 {
+	kvm_free_stage2_pgd(kvm);
 }
 
 void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
-- 
2.10.0


  parent reply	other threads:[~2016-09-29  9:07 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29  9:06 [patch added to 3.12-stable] clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] powerpc/mm: Don't alias user region to other regions below PAGE_OFFSET Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] NFSv4.x: Fix a refcount leak in nfs_callback_up_net Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] dm flakey: fix reads to be issued if drop_writes configured Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] x86/paravirt: Do not trace _paravirt_ident_*() functions Jiri Slaby
2016-09-29  9:06 ` Jiri Slaby [this message]
2016-09-29  9:06 ` [patch added to 3.12-stable] iio: accel: kxsd9: Fix raw read return Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] iio: accel: kxsd9: Fix scaling bug Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] USB: serial: simple: add support for another Infineon flashloader Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] usb: renesas_usbhs: fix clearing the {BRDY,BEMP}STS condition Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] USB: change bInterval default to 10 ms Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] ARM: OMAP3: hwmod data: Add sysc information for DSI Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] arm64: spinlocks: implement smp_mb__before_spinlock() as smp_mb() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] crypto: cryptd - initialize child shash_desc on import Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] microblaze: fix __get_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] avr32: fix copy_from_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] microblaze: " Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] fix minor infoleak in get_user_ex() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] mn10300: failing __get_user() and get_user() should zero Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] m32r: fix __get_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] sh64: failing __get_user() should zero Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] score: fix __get_user/get_user Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] s390: get_user() should zero on failure Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] ARC: uaccess: get_user to zero out dest in cause of fault Jiri Slaby
2016-09-29  9:06   ` Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] asm-generic: make get_user() clear the destination on errors Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] frv: fix clear_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] cris: buggered copy_from_user/copy_to_user/clear_user Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] blackfin: fix copy_from_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] score: fix copy_from_user() and friends Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] sh: fix copy_from_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] hexagon: fix strncpy_from_user() error return Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] mips: copy_from_user() must zero the destination on access_ok() failure Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] asm-generic: make copy_from_user() zero the destination properly Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] alpha: fix copy_from_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] metag: copy_from_user() should zero the destination on access_ok() failure Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] parisc: fix copy_from_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] openrisc: " Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] mn10300: copy_from_user() should zero on access_ok() failure Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] sparc32: fix copy_from_user() Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] ppc32: " Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] ia64: copy_from_user() should zero the destination on access_ok() failure Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] avr32: fix 'undefined reference to `___copy_from_user' Jiri Slaby
2016-09-29  9:06 ` [patch added to 3.12-stable] openrisc: fix the fix of copy_from_user() Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160929090654.27405-6-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=marc.zyngier@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.