From patchwork Mon May 4 01:52:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47955 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EA8CB2121F for ; Mon, 4 May 2015 01:54:50 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf42599625lab.1 for ; Sun, 03 May 2015 18:54:49 -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=XAEI251vYo1RFHqJpWhhkJ0JG8pi4W+cODmq9VYZml/UyB2AIHvBdAF+d9s3Co3KNY I3S7/MX51pXL2eJGBnlYkgl/1sOAy/UPH/LDFHzBLrKZcf/3+98rlLCBZenW0lKtoEx8 o3bL5OLZmzJsCGGq/xC/mdi8NZutjGX+h00lNsucrw2zR0XJItWkzfE9VsMtpn164r3u crPV2W+8OUsnvvW11Z/8K4Wbg0mSDavL3kEkKeDJF+Ux44qN7cvQG/JyPSsubwqqbcJZ OkU3XddqcAkjblyfHJEs+wp4yatc2ELmZQguSO/QdJtekg68QDmPTN9GAcn3GamX3/E4 YIzQ== X-Gm-Message-State: ALoCoQlhD/9US25gQ1z193Vcy9Q9Gjd1h01cp5v7jh9PWREAJaCdTNNrpO1KqYf41FR46M7BBAa2 X-Received: by 10.180.211.168 with SMTP id nd8mr6910215wic.4.1430704489935; Sun, 03 May 2015 18:54:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.8 with SMTP id eq8ls775956lac.91.gmail; Sun, 03 May 2015 18:54:49 -0700 (PDT) X-Received: by 10.112.202.103 with SMTP id kh7mr9989190lbc.118.1430704489756; Sun, 03 May 2015 18:54:49 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id ys9si9089090lab.63.2015.05.03.18.54.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:54:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbqq2 with SMTP id qq2so95592606lbb.3 for ; Sun, 03 May 2015 18:54:49 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr17281182lbc.41.1430704489623; Sun, 03 May 2015 18:54:49 -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.67.65 with SMTP id l1csp1412751lbt; Sun, 3 May 2015 18:54:48 -0700 (PDT) X-Received: by 10.70.125.129 with SMTP id mq1mr38598388pdb.19.1430704487836; Sun, 03 May 2015 18:54:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.54.46; Sun, 03 May 2015 18:54:47 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893AbbEDByq (ORCPT + 2 others); Sun, 3 May 2015 21:54:46 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36348 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751904AbbEDByq (ORCPT ); Sun, 3 May 2015 21:54:46 -0400 Received: by pabsx10 with SMTP id sx10so147762202pab.3 for ; Sun, 03 May 2015 18:54:45 -0700 (PDT) X-Received: by 10.68.129.39 with SMTP id nt7mr37965591pbb.72.1430704485713; Sun, 03 May 2015 18:54:45 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id nz7sm5798947pbb.40.2015.05.03.18.54.44 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:54:44 -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 17/47] ARM: KVM: Unmap IPA on memslot delete/move Date: Mon, 4 May 2015 09:52:12 +0800 Message-Id: <1430704362-6292-18-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-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.217.182 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) +{ +}