From patchwork Thu Apr 30 12:12:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 47831 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 29C8F2121F for ; Thu, 30 Apr 2015 12:23:34 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf14075921lbb.0 for ; Thu, 30 Apr 2015 05:23:33 -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: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=XDjFaZC+Be/87giWSvPKPCO1VPraLz/4SNGA05nTggs=; b=IktTTpPkAEiznLxfvgfhKRuIHQweddXxg/rmIYDFjefjJQU07udB9V3DQyGIz3UCiK lfcKQ7wZOXQMkYhABc4Wu77dTu+u0UZ662RxmSFZu+ImJVqTz21fpgey8J846gbLIsYi /EbFRlG0W3ERxy9Cbc/fWgu9cYT4NSIkPuxKmzOi+oqNq8xUx80RjOGmYhDs8Rs0wfKh GEYYpSsEzNxCcM91w9UPCA+r5Aeau4C7MFusGGA98T3hN/cCO06fn4WMUPd4g0/pVtJr ECmnH8er5QzDu6VrnRFzw152v2ZhYkVQwNwZqCV02QZMeLJFTc6NakAhZMrM1a8eFUgF GoeA== X-Gm-Message-State: ALoCoQmjFi9vHjKmw1zHe5aG2ljpj59UnjRnVZXOeDcOORPIdMKcbPZN2KpoC5Zki9oC4LEG8LZh X-Received: by 10.112.138.2 with SMTP id qm2mr2373900lbb.19.1430396613165; Thu, 30 Apr 2015 05:23:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.111 with SMTP id v15ls391896lal.5.gmail; Thu, 30 Apr 2015 05:23:32 -0700 (PDT) X-Received: by 10.112.125.33 with SMTP id mn1mr3589207lbb.82.1430396612913; Thu, 30 Apr 2015 05:23:32 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id l8si1653982lah.54.2015.04.30.05.23.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 05:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labbd9 with SMTP id bd9so42791657lab.2 for ; Thu, 30 Apr 2015 05:23:32 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr3611163laj.88.1430396612489; Thu, 30 Apr 2015 05:23:32 -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 l1csp3080178lbt; Thu, 30 Apr 2015 05:23:31 -0700 (PDT) X-Received: by 10.70.92.193 with SMTP id co1mr7739154pdb.7.1430396581895; Thu, 30 Apr 2015 05:23:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nz1si3264923pab.174.2015.04.30.05.23.00; Thu, 30 Apr 2015 05:23:01 -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 S1752434AbbD3MUx (ORCPT + 2 others); Thu, 30 Apr 2015 08:20:53 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:53645 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751393AbbD3MMe (ORCPT ); Thu, 30 Apr 2015 08:12:34 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.85) (envelope-from ) id 1YnnKT-0008C0-5B; Thu, 30 Apr 2015 14:12:33 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kim Phillips , Marc Zyngier , Shannon Zhao , Jiri Slaby Subject: [PATCH 3.12 36/63] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Date: Thu, 30 Apr 2015 14:12:05 +0200 Message-Id: <714b16417725d1adc0b8d2010c5cbb4c8df5e371.1430387326.git.jslaby@suse.cz> X-Mailer: git-send-email 2.3.5 In-Reply-To: <45aaf85687dd6ac119c55c5ec0dbe0bef0e62235.1430387326.git.jslaby@suse.cz> References: <45aaf85687dd6ac119c55c5ec0dbe0bef0e62235.1430387326.git.jslaby@suse.cz> In-Reply-To: References: 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: patch@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.42 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 3.12-stable review patch. If anyone has any objections, please let me know. =============== 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 Signed-off-by: Jiri Slaby --- 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 9f83bc755018..484084b6a585 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);