From patchwork Tue Mar 25 22:08:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kim-phillips X-Patchwork-Id: 27089 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7C15820539 for ; Tue, 25 Mar 2014 22:08:59 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id jt11sf2567730pbb.3 for ; Tue, 25 Mar 2014 15:08:58 -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=CjPC+cKKDe+LDoDK1lYWmcYRwIrgJ3NezO3xOzkAUkI=; b=AUdWtLw2E/TBb8CzTzJ9Zz+mwoFVVVRVRwOTip8XDUbzIIEMDVNCGdPrxlSX73GQMW ld6uMzkFb0p85iZkyGuRsFDNFO7Bm/9tPjOILotSlUA0/CSdwWN+e82gUfhF4tRE+iu8 HpUTkc8Am7z167MtO4ara9JZEybaNUO8DlNEXTfNJdZm34sbnC16Xg92SkfwqWU/bC77 qH5HjBgqbMWFdmF5cI/Mlnub/zkP/Cd/glvBBPT4xaUtCputJfp5HaGFxnDyM8X857OT J38hVbQ8wIJZ6i2gs8bV97mllBm5x0N5Ki0YKjcTgu4AF1sQv5aYIgoKZE8PpVBRrG+r SVkg== X-Gm-Message-State: ALoCoQm0P3qCFTiDlV0Qn8twzF75HbTfCxUNM0oCSLoQ0YHov6RdYm3Dn/mgU64gCVl1kBOShSRH X-Received: by 10.66.148.10 with SMTP id to10mr96922pab.12.1395785337914; Tue, 25 Mar 2014 15:08:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.110 with SMTP id 101ls405840qgq.88.gmail; Tue, 25 Mar 2014 15:08:57 -0700 (PDT) X-Received: by 10.52.135.132 with SMTP id ps4mr16307329vdb.2.1395785337703; Tue, 25 Mar 2014 15:08:57 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id sh5si4150749vdc.140.2014.03.25.15.08.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 15:08:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so1318876veb.22 for ; Tue, 25 Mar 2014 15:08:57 -0700 (PDT) X-Received: by 10.220.10.2 with SMTP id n2mr3164611vcn.26.1395785337611; Tue, 25 Mar 2014 15:08:57 -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.220.78.9 with SMTP id i9csp341032vck; Tue, 25 Mar 2014 15:08:56 -0700 (PDT) X-Received: by 10.68.235.6 with SMTP id ui6mr80146537pbc.45.1395785336139; Tue, 25 Mar 2014 15:08:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh4si12208560pbc.434.2014.03.25.15.08.55; Tue, 25 Mar 2014 15:08:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S1754745AbaCYWIr (ORCPT + 26 others); Tue, 25 Mar 2014 18:08:47 -0400 Received: from mail-oa0-f50.google.com ([209.85.219.50]:52489 "EHLO mail-oa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751911AbaCYWI3 (ORCPT ); Tue, 25 Mar 2014 18:08:29 -0400 Received: by mail-oa0-f50.google.com with SMTP id i7so1401318oag.37 for ; Tue, 25 Mar 2014 15:08:28 -0700 (PDT) X-Received: by 10.182.128.138 with SMTP id no10mr34288599obb.32.1395785308592; Tue, 25 Mar 2014 15:08:28 -0700 (PDT) Received: from ntel.Asprouli (cpe-70-112-130-68.austin.res.rr.com. [70.112.130.68]) by mx.google.com with ESMTPSA id x3sm524956oek.3.2014.03.25.15.08.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 15:08:27 -0700 (PDT) From: Kim Phillips To: Christoffer Dall , Gleb Natapov , Paolo Bonzini , Russell King , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Eric Auger , Alex Williamson , Antonios Motakis , Kim Phillips , Kim Phillips Subject: [PATCH 2/2] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Date: Tue, 25 Mar 2014 17:08:14 -0500 Message-Id: <1395785294-2545-2-git-send-email-kim.phillips@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1395785294-2545-1-git-send-email-kim.phillips@linaro.org> References: <1395785294-2545-1-git-send-email-kim.phillips@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kim.phillips@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Use the correct memory type for device MMIO mappings: PAGE_S2_DEVICE. Signed-off-by: Kim Phillips Acked-by: Christoffer Dall --- arch/arm/kvm/mmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 7789857..a354610 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -652,6 +652,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, struct kvm_mmu_memory_cache *memcache = &vcpu->arch.mmu_page_cache; struct vm_area_struct *vma; pfn_t pfn; + pgprot_t mem_type = PAGE_S2; write_fault = kvm_is_write_fault(kvm_vcpu_get_hsr(vcpu)); if (fault_status == FSC_PERM && !write_fault) { @@ -702,6 +703,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (is_error_pfn(pfn)) return -EFAULT; + if (kvm_is_mmio_pfn(pfn)) + mem_type = PAGE_S2_DEVICE; + spin_lock(&kvm->mmu_lock); if (mmu_notifier_retry(kvm, mmu_seq)) goto out_unlock; @@ -709,7 +713,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, hugetlb = transparent_hugepage_adjust(&pfn, &fault_ipa); if (hugetlb) { - pmd_t new_pmd = pfn_pmd(pfn, PAGE_S2); + pmd_t new_pmd = pfn_pmd(pfn, mem_type); new_pmd = pmd_mkhuge(new_pmd); if (writable) { kvm_set_s2pmd_writable(&new_pmd); @@ -718,13 +722,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, coherent_icache_guest_page(kvm, hva & PMD_MASK, PMD_SIZE); ret = stage2_set_pmd_huge(kvm, memcache, fault_ipa, &new_pmd); } else { - pte_t new_pte = pfn_pte(pfn, PAGE_S2); + pte_t new_pte = pfn_pte(pfn, mem_type); if (writable) { kvm_set_s2pte_writable(&new_pte); kvm_set_pfn_dirty(pfn); } coherent_icache_guest_page(kvm, hva, PAGE_SIZE); - ret = stage2_set_pte(kvm, memcache, fault_ipa, &new_pte, false); + ret = stage2_set_pte(kvm, memcache, fault_ipa, &new_pte, + mem_type == PAGE_S2_DEVICE); }