From patchwork Sat Oct 20 14:25:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1621511 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 4DDC53FCFC for ; Sat, 20 Oct 2012 14:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753577Ab2JTO0U (ORCPT ); Sat, 20 Oct 2012 10:26:20 -0400 Received: from mail-vc0-f174.google.com ([209.85.220.174]:41094 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529Ab2JTO0T (ORCPT ); Sat, 20 Oct 2012 10:26:19 -0400 Received: by mail-vc0-f174.google.com with SMTP id fk26so1487253vcb.19 for ; Sat, 20 Oct 2012 07:26:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=pSFKpMXiGTAqfKvgF2SQPgvH/ZCJFeS5c7ItwRI7LTs=; b=Nf1bYK0+zaSaLuYw8cgxcpo66ECdIM5+r+k/MRp4/6VwucGwn0qkeMnYfkkrvJbXKy YQInNlnoovMUT5LduDSO3zX+KtKxpcvln1EYHJK84VBZui0RmU0KOdGJx0j6hRkhUxnA L89iH3uZZZAFuIxrD6Nzc5rOYNPEF4MsLH3V48L6Zjr8aZmXJYXgR27W0nIoB41Fioc/ W0Xh89uoA0gYDZyVWux8yNMM6keGaW0o3/r0NS2qOkku6C/z2lrOgtqbS5GAU0r4TZiw xHX/oyO4GC1+zVTLUxTxfpRmWdQmdHoRKKZFGwdHuJq+mMCZW/mC9U3lOmgll7nZEGNk Ajug== Received: by 10.52.76.103 with SMTP id j7mr4713768vdw.22.1350743178528; Sat, 20 Oct 2012 07:26:18 -0700 (PDT) Received: from localhost.localdomain (pool-72-80-83-148.nycmny.fios.verizon.net. [72.80.83.148]) by mx.google.com with ESMTPS id v9sm4161046ves.8.2012.10.20.07.26.17 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 20 Oct 2012 07:26:18 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Christoffer Dall Subject: [PATCH] fixup! KVM: ARM: Check for overlaps of mapped io addresses Date: Sat, 20 Oct 2012 10:25:58 -0400 Message-Id: <1350743158-35017-1-git-send-email-c.dall@virtualopensystems.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQnxp45vudlUGJ2swDSWNxIEXrQbOg/D+5U4HuWLuhCPyyBrim1C+Xr3wtoGsf8qE0iz1Gg1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Missed a commit of my working tree, so accidentally sent out the wrong patch. This fixes it. Signed-off-by: Christoffer Dall --- arch/arm/kvm/mmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index e5ace0e..cb03d45 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -421,8 +421,8 @@ static void stage2_clear_pte(struct kvm *kvm, phys_addr_t addr) kvm_tlb_flush_vmid(kvm); } -static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, - phys_addr_t addr, const pte_t *new_pte, bool iomap) +static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, + phys_addr_t addr, const pte_t *new_pte, bool iomap) { pgd_t *pgd; pud_t *pud; @@ -434,7 +434,7 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, pud = pud_offset(pgd, addr); if (pud_none(*pud)) { if (!cache) - return; /* ignore calls from kvm_set_spte_hva */ + return 0; /* ignore calls from kvm_set_spte_hva */ pmd = mmu_memory_cache_alloc(cache); pud_populate(NULL, pud, pmd); pmd += pmd_index(addr); @@ -445,7 +445,7 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, /* Create 2nd stage page table mapping - Level 2 */ if (pmd_none(*pmd)) { if (!cache) - return; /* ignore calls from kvm_set_spte_hva */ + return 0; /* ignore calls from kvm_set_spte_hva */ pte = mmu_memory_cache_alloc(cache); clean_pte_table(pte); pmd_populate_kernel(NULL, pmd, pte); @@ -454,7 +454,7 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, } else pte = pte_offset_kernel(pmd, addr); - if (iomap && pte_present(old_pte)) + if (iomap && pte_present(*pte)) return -EFAULT; /* Create 2nd stage page table mapping - Level 3 */ @@ -464,6 +464,8 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, kvm_tlb_flush_vmid(kvm); else get_page(virt_to_page(pte)); + + return 0; } /** @@ -492,8 +494,10 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, if (ret) goto out; spin_lock(&kvm->mmu_lock); - stage2_set_pte(kvm, &cache, addr, &pte, true); + ret = stage2_set_pte(kvm, &cache, addr, &pte, true); spin_unlock(&kvm->mmu_lock); + if (ret) + goto out; pfn++; }