From patchwork Fri Apr 24 05:27:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47521 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 989D320553 for ; Fri, 24 Apr 2015 05:32:58 +0000 (UTC) Received: by wgin8 with SMTP id n8sf9111184wgi.0 for ; Thu, 23 Apr 2015 22:32:57 -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=EHqEo9M3HQlU+6+vWkAkCfYHjlbBlx04ZjC9hWE3Euw=; b=jTA5eaFHAG4Z+ojGqPBkT0YbvmdZ6CogdEZsAQ4gPBFxLzurrkD1YLByt6eQWXCuMc GG+XeGbJLNbpf3W6jy3VuW251cOmbx8rassg15sDw7uil+elb2wwHmskc4bG6Rkk4YsV mOa8G6gltlBzRcnXwrJVNprzK8RxStyuZ4mrw9DGUdPnzed5L7CnxhfMTD8FiIZyGeP6 0A1TNEI3X0ac5Z7oUq730T9iEmCWRhbk/inv6T1CHNfGF+ysE07ZEU5XAms+CTCSg/Dw 8/da9kPfbFl/FvbHOpyz+Q6q3C3BlIp1pp5GEBKsqsP1j1Z5Rk5soYPWP1EveaKeEODm XFJw== X-Gm-Message-State: ALoCoQlJkp5zJeBH9ITFbwiAuXskbEUF/nlkMR1Pez9FcW6hl1RDL4fNcUwT29dsRArhjfcmO3Tl X-Received: by 10.112.142.170 with SMTP id rx10mr3165557lbb.12.1429853577762; Thu, 23 Apr 2015 22:32:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.129 with SMTP id w1ls195524lal.32.gmail; Thu, 23 Apr 2015 22:32:57 -0700 (PDT) X-Received: by 10.112.137.164 with SMTP id qj4mr5375930lbb.105.1429853577486; Thu, 23 Apr 2015 22:32:57 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id p11si2422175lal.92.2015.04.23.22.32.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagv1 with SMTP id v1so27542383lag.3 for ; Thu, 23 Apr 2015 22:32:57 -0700 (PDT) X-Received: by 10.112.204.6 with SMTP id ku6mr5353150lbc.73.1429853577388; Thu, 23 Apr 2015 22:32: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.112.67.65 with SMTP id l1csp978236lbt; Thu, 23 Apr 2015 22:32:56 -0700 (PDT) X-Received: by 10.70.44.199 with SMTP id g7mr2915350pdm.27.1429853575570; Thu, 23 Apr 2015 22:32:55 -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.54; Thu, 23 Apr 2015 22:32:55 -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 S1754547AbbDXFcy (ORCPT + 2 others); Fri, 24 Apr 2015 01:32:54 -0400 Received: from mail-oi0-f44.google.com ([209.85.218.44]:33884 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754544AbbDXFcx (ORCPT ); Fri, 24 Apr 2015 01:32:53 -0400 Received: by oiko83 with SMTP id o83so32491034oik.1 for ; Thu, 23 Apr 2015 22:32:53 -0700 (PDT) X-Received: by 10.202.173.144 with SMTP id w138mr5473811oie.100.1429853573417; Thu, 23 Apr 2015 22:32:53 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id su4sm6072517obc.20.2015.04.23.22.32.51 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:32:52 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Kim Phillips , Marc Zyngier Subject: [PATCH for 3.12.y stable 36/63] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Date: Fri, 24 Apr 2015 13:27:34 +0800 Message-Id: <1429853281-6136-37-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.43 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 9f83bc7..484084b 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -647,6 +647,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, unsigned long mmu_seq; unsigned long hva = gfn_to_hva(vcpu->kvm, gfn); struct kvm_mmu_memory_cache *memcache = &vcpu->arch.mmu_page_cache; + pgprot_t mem_type = PAGE_S2; write_fault = kvm_is_write_fault(kvm_vcpu_get_hsr(vcpu)); if (fault_status == FSC_PERM && !write_fault) { @@ -675,7 +676,10 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (is_error_pfn(pfn)) return -EFAULT; - new_pte = pfn_pte(pfn, PAGE_S2); + if (kvm_is_mmio_pfn(pfn)) + mem_type = PAGE_S2_DEVICE; + + new_pte = pfn_pte(pfn, mem_type); coherent_cache_guest_page(vcpu, hva, PAGE_SIZE); spin_lock(&vcpu->kvm->mmu_lock); @@ -685,7 +689,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, kvm_set_s2pte_writable(&new_pte); kvm_set_pfn_dirty(pfn); } - stage2_set_pte(vcpu->kvm, memcache, fault_ipa, &new_pte, false); + stage2_set_pte(vcpu->kvm, memcache, fault_ipa, &new_pte, + mem_type == PAGE_S2_DEVICE); out_unlock: spin_unlock(&vcpu->kvm->mmu_lock);