From patchwork Tue Jun 2 14:47:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49378 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10E4820BD1 for ; Tue, 2 Jun 2015 14:49:17 +0000 (UTC) Received: by wgla2 with SMTP id a2sf41325944wgl.1 for ; Tue, 02 Jun 2015 07:49:16 -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=rJFlhGF7mliMU6h+ay3LUUqpST92yLILpueeEShFQAw=; b=J9LoRcWB4f9nLpllN/9leDU7n2LdBzsqlCkNG1ocJJwsTM13CUynugeoNOmR6l34st BV/3lLlBSHbcz+ezmNMA6XdaOjF/FG7kt8NNd3S+rzYwJYJpOmQp+JC/khIwI0Cwhq83 y9PGGvAxlNc7j5AFv4YFmHv/r8uKNXBs2UFIkhJxNWVejzuJChh7VW/PSg8PZ6Vczwi9 iUj/fOJCH9opGZA6//6Y8hi2xtm0YWh1kKvzZxMlVNoT/1o/DozeQcuj/BCo9Gz42Gf0 YzmSR6mNtiigzWihmmqYMowPU+cU6w5hpwPc9jYJiOzoyVaNWbIvyO17SNmzkWwmlxJU Elmg== X-Gm-Message-State: ALoCoQnfVhIptpHWIKNAX1uCMffPLFIVb5lSQtVIIDvjIx1EqEte3TiGc0qtmwpYibMIQGC1XMIJ X-Received: by 10.112.118.162 with SMTP id kn2mr26399486lbb.22.1433256556416; Tue, 02 Jun 2015 07:49:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.7 with SMTP id v7ls224834laa.75.gmail; Tue, 02 Jun 2015 07:49:16 -0700 (PDT) X-Received: by 10.112.199.35 with SMTP id jh3mr26355856lbc.23.1433256556260; Tue, 02 Jun 2015 07:49:16 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id pl9si15270049lbb.111.2015.06.02.07.49.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:49:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbqq2 with SMTP id qq2so105975277lbb.3 for ; Tue, 02 Jun 2015 07:49:15 -0700 (PDT) X-Received: by 10.152.7.7 with SMTP id f7mr26987552laa.106.1433256555832; Tue, 02 Jun 2015 07:49:15 -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 hn6csp3128223lbb; Tue, 2 Jun 2015 07:49:14 -0700 (PDT) X-Received: by 10.66.141.48 with SMTP id rl16mr49535251pab.147.1433256553859; Tue, 02 Jun 2015 07:49:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si26719700pdd.107.2015.06.02.07.49.13; Tue, 02 Jun 2015 07:49:13 -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 S1759322AbbFBOtG (ORCPT + 2 others); Tue, 2 Jun 2015 10:49:06 -0400 Received: from mail-oi0-f47.google.com ([209.85.218.47]:36232 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759207AbbFBOtE (ORCPT ); Tue, 2 Jun 2015 10:49:04 -0400 Received: by oihb142 with SMTP id b142so127241009oih.3 for ; Tue, 02 Jun 2015 07:49:03 -0700 (PDT) X-Received: by 10.60.128.200 with SMTP id nq8mr15072101oeb.54.1433256543775; Tue, 02 Jun 2015 07:49:03 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id sn2sm9561170obc.11.2015.06.02.07.49.01 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:49:02 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Kim Phillips , Marc Zyngier Subject: [PATCH for 3.14.y stable 03/32] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Date: Tue, 2 Jun 2015 22:47:58 +0800 Message-Id: <1433256507-7856-4-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.217.174 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: Kim Phillips commit b88657674d39fc2127d62d0de9ca142e166443c8 upstream. A userspace process can map device MMIO memory via VFIO or /dev/mem, e.g., for platform device passthrough support in QEMU. During early development, we found the PAGE_S2 memory type being used for MMIO mappings. This patch corrects that by using the more strongly ordered memory type for device MMIO mappings: PAGE_S2_DEVICE. Signed-off-by: Kim Phillips Acked-by: Christoffer Dall Acked-by: Will Deacon Signed-off-by: Marc Zyngier Signed-off-by: Shannon Zhao --- 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 3d96ece..70ed2c1 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -759,6 +759,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) { @@ -809,6 +810,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; @@ -816,7 +820,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); @@ -825,13 +829,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, coherent_cache_guest_page(vcpu, 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_cache_guest_page(vcpu, 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); }