From patchwork Fri Apr 24 05:27:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47520 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DC04820553 for ; Fri, 24 Apr 2015 05:32:52 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf8858268lbb.3 for ; Thu, 23 Apr 2015 22:32:51 -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=e9wWRR20pCjTG6iVaS/wn9cS74CgIcIK16pDHE4wsfw=; b=Rs6p8dp1BaDuHGjOewBGVZGFL7uGirm/ktBQK4yFn23m+leLbfbSSf7Kn8/9QOU03f yhIbjj9XfJbiYz8yrsafCLRahWBMhsJb0qu08x08Y7+AWimD5J1mh+xVryQmMKTKPOVD WrBkw8egvk3/CDKQZRcp3A6264w+DEEb5/MVVlb6caNgp2KfDlcV4eRYseDhy5FGuOiV pEcHDHWjeWVLvg8U1cx9cpHcqpyy2vRVB/SxCycn9QBa8OJtsjtqQimGRw4ubXaNoF8+ YvLFQbbjFEO3wokcrK/XjS6hoDAKlMekUhoR2oMV9+X7cO43gmycT4FCxH+Ya17EQlrn ymbg== X-Gm-Message-State: ALoCoQlMDzYtusSJm90xtBKNd3iDqPkryKHozMJszpPC/fRrSy1mOobK6kGCIu5yCtkzSuuPqXWn X-Received: by 10.180.98.130 with SMTP id ei2mr177757wib.0.1429853571849; Thu, 23 Apr 2015 22:32:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.130 with SMTP id v2ls361992lae.98.gmail; Thu, 23 Apr 2015 22:32:51 -0700 (PDT) X-Received: by 10.152.197.2 with SMTP id iq2mr5437090lac.103.1429853571683; Thu, 23 Apr 2015 22:32:51 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id rm3si7488631lbb.5.2015.04.23.22.32.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by labbd9 with SMTP id bd9so27567859lab.2 for ; Thu, 23 Apr 2015 22:32:51 -0700 (PDT) X-Received: by 10.152.29.161 with SMTP id l1mr5313188lah.76.1429853571402; Thu, 23 Apr 2015 22:32:51 -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 l1csp978195lbt; Thu, 23 Apr 2015 22:32:50 -0700 (PDT) X-Received: by 10.70.43.225 with SMTP id z1mr2918308pdl.45.1429853569617; Thu, 23 Apr 2015 22:32:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.32.48; Thu, 23 Apr 2015 22:32:49 -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 S1754546AbbDXFcs (ORCPT + 2 others); Fri, 24 Apr 2015 01:32:48 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:33832 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754544AbbDXFcr (ORCPT ); Fri, 24 Apr 2015 01:32:47 -0400 Received: by oiko83 with SMTP id o83so32489746oik.1 for ; Thu, 23 Apr 2015 22:32:47 -0700 (PDT) X-Received: by 10.202.104.88 with SMTP id d85mr5419826oic.37.1429853567344; Thu, 23 Apr 2015 22:32:47 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id mk6sm6006864oeb.15.2015.04.23.22.32.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:32:46 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Eric Auger Subject: [PATCH for 3.12.y stable 35/63] ARM: KVM: Unmap IPA on memslot delete/move Date: Fri, 24 Apr 2015 13:27:33 +0800 Message-Id: <1429853281-6136-36-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-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.47 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 | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 8da56e4..bf801be 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_memory_slot *free, - struct kvm_memory_slot *dont) -{ -} - -int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages) -{ - return 0; -} - /** * kvm_arch_destroy_vm - destroy the VM data structure * @kvm: pointer to the KVM struct @@ -222,33 +212,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 8e364f7..9f83bc7 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -963,3 +963,48 @@ 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_memory_slot *free, + struct kvm_memory_slot *dont) +{ +} + +int kvm_arch_create_memslot(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) +{ +}