From patchwork Tue Jun 2 14:47:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49377 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C0C1D20BD1 for ; Tue, 2 Jun 2015 14:49:03 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf42635237lbb.0 for ; Tue, 02 Jun 2015 07:49:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=i7dnowyBb6R7l3DEHmjuA9n4t9sgp57CKf76pnvnFEY=; b=Q4IKwt//i70rHfsp5+0FzZAfea2LxFMNjzA2SdT0gYJqIpyynKfULGCxkMOsFf0P2P /LyeiVtW8uLKz5G0wKHUbTZCLx3H+KotKKqWvc2wKYuN/X397h3G0IKFLmOgYVMW3eTk d6Xt/0BLrQd9M0NbIebi488Bx6yvzwN/m/gGfvlqjabNJ4uIpPffay4WXEpII6vO7DzV D2979JYcsbpHCdn4tHEiqDdQo/Z+ueLc4NPIBzxKKxMgx7YF7CnGdoFmqu5Uy5um4Kjh 0OMPbfGlakeXsowleNnI8qzq5Xp4aNMgtNfty2iSsxkZ3xpkPGbj3XrH+pA5c5pGRu4E mQbg== X-Gm-Message-State: ALoCoQlGZnyLvqQZdAFMLp44HiIdZkJP40pKdDiFQmj+JEgBXhBJjMs2mm2nhSc2/BB0sQX8yRsU X-Received: by 10.112.171.41 with SMTP id ar9mr26199069lbc.24.1433256542610; Tue, 02 Jun 2015 07:49:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.164 with SMTP id cz4ls815594lac.3.gmail; Tue, 02 Jun 2015 07:49:02 -0700 (PDT) X-Received: by 10.112.148.166 with SMTP id tt6mr15883709lbb.11.1433256542454; Tue, 02 Jun 2015 07:49:02 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id qs3si12749670lbb.164.2015.06.02.07.49.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:49:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by labpy14 with SMTP id py14so115655846lab.0 for ; Tue, 02 Jun 2015 07:49:02 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr26116825lag.112.1433256542311; Tue, 02 Jun 2015 07:49:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3128043lbb; Tue, 2 Jun 2015 07:49:01 -0700 (PDT) X-Received: by 10.70.44.199 with SMTP id g7mr50516598pdm.27.1433256540395; Tue, 02 Jun 2015 07:49:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yw2si26390509pbc.95.2015.06.02.07.48.59; Tue, 02 Jun 2015 07:49:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932667AbbFBOs7 (ORCPT + 2 others); Tue, 2 Jun 2015 10:48:59 -0400 Received: from mail-ob0-f171.google.com ([209.85.214.171]:36583 "EHLO mail-ob0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759032AbbFBOs6 (ORCPT ); Tue, 2 Jun 2015 10:48:58 -0400 Received: by obbea2 with SMTP id ea2so129454273obb.3 for ; Tue, 02 Jun 2015 07:48:57 -0700 (PDT) X-Received: by 10.202.242.212 with SMTP id q203mr13840218oih.52.1433256537562; Tue, 02 Jun 2015 07:48:57 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id jh7sm9556380obb.15.2015.06.02.07.48.55 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:48:56 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Eric Auger Subject: [PATCH for 3.14.y stable 02/32] ARM: KVM: Unmap IPA on memslot delete/move Date: Tue, 2 Jun 2015 22:47:57 +0800 Message-Id: <1433256507-7856-3-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> References: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Eric Auger commit df6ce24f2ee485c4f9a5cb610063a5eb60da8267 upstream. Currently when a KVM region is deleted or moved after KVM_SET_USER_MEMORY_REGION ioctl, the corresponding intermediate physical memory is not unmapped. This patch corrects this and unmaps the region's IPA range in kvm_arch_commit_memory_region using unmap_stage2_range. Signed-off-by: Eric Auger Signed-off-by: Christoffer Dall Signed-off-by: Shannon Zhao --- arch/arm/kvm/arm.c | 37 ------------------------------------- arch/arm/kvm/mmu.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index bd18bb8..f92a7fb 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -155,16 +155,6 @@ int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf) return VM_FAULT_SIGBUS; } -void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free, - struct kvm_memory_slot *dont) -{ -} - -int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, - unsigned long npages) -{ - return 0; -} /** * kvm_arch_destroy_vm - destroy the VM data structure @@ -224,33 +214,6 @@ long kvm_arch_dev_ioctl(struct file *filp, return -EINVAL; } -void kvm_arch_memslots_updated(struct kvm *kvm) -{ -} - -int kvm_arch_prepare_memory_region(struct kvm *kvm, - struct kvm_memory_slot *memslot, - struct kvm_userspace_memory_region *mem, - enum kvm_mr_change change) -{ - return 0; -} - -void kvm_arch_commit_memory_region(struct kvm *kvm, - struct kvm_userspace_memory_region *mem, - const struct kvm_memory_slot *old, - enum kvm_mr_change change) -{ -} - -void kvm_arch_flush_shadow_all(struct kvm *kvm) -{ -} - -void kvm_arch_flush_shadow_memslot(struct kvm *kvm, - struct kvm_memory_slot *slot) -{ -} struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) { diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 1cfede7..3d96ece 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -1111,3 +1111,49 @@ out: free_hyp_pgds(); return err; } + +void kvm_arch_commit_memory_region(struct kvm *kvm, + struct kvm_userspace_memory_region *mem, + const struct kvm_memory_slot *old, + enum kvm_mr_change change) +{ + gpa_t gpa = old->base_gfn << PAGE_SHIFT; + phys_addr_t size = old->npages << PAGE_SHIFT; + if (change == KVM_MR_DELETE || change == KVM_MR_MOVE) { + spin_lock(&kvm->mmu_lock); + unmap_stage2_range(kvm, gpa, size); + spin_unlock(&kvm->mmu_lock); + } +} + +int kvm_arch_prepare_memory_region(struct kvm *kvm, + struct kvm_memory_slot *memslot, + struct kvm_userspace_memory_region *mem, + enum kvm_mr_change change) +{ + return 0; +} + +void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free, + struct kvm_memory_slot *dont) +{ +} + +int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, + unsigned long npages) +{ + return 0; +} + +void kvm_arch_memslots_updated(struct kvm *kvm) +{ +} + +void kvm_arch_flush_shadow_all(struct kvm *kvm) +{ +} + +void kvm_arch_flush_shadow_memslot(struct kvm *kvm, + struct kvm_memory_slot *slot) +{ +}