From patchwork Thu Apr 30 09:24:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 47797 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DE5D62121F for ; Thu, 30 Apr 2015 09:32:57 +0000 (UTC) Received: by lamp14 with SMTP id p14sf13848869lam.3 for ; Thu, 30 Apr 2015 02:32:56 -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=9n13ZKADdbxQFmvz4gXXtnIuEQg6zlsOh45N5/NKnG0=; b=PDT2hIljEKlG91ktH5FIzCmVDSVLDzFca5SbgB8YyCMtEaQOduQrHSHedFVuVdpAdl mKuGaZA1TeCFZkdhMFEn67oe+eNvvdRCLEQpHy8k66mnEn3G5fN1ummj49wasKGsZ7LF RQyu1OW5HYWwNWN1aRNJkTpsrDewxJIBdUCcng9uTj4Px1hrCUCyE0OznR7wZy+nzpuB tI2BqowGL708ZwWA1VQ6v874qNgZQwZnFN1ARAZndNa1fGCHw+7ajO436DdB45gvIu2C XvV5cu/lIpubxA9ASCFHrsWG5d9THYkJIJjUE+eD6XpSwtziRDiHApydl5qdBww92ifO HI1g== X-Gm-Message-State: ALoCoQmsCuHRUn5exeL+Kx01UueHdZZfRMytRTvrCwxRE9k4Th0+zxWBDcTd0QqWB0AiIrqZ4Xz8 X-Received: by 10.180.73.137 with SMTP id l9mr1216062wiv.5.1430386376942; Thu, 30 Apr 2015 02:32:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.3 with SMTP id bc3ls348238lab.22.gmail; Thu, 30 Apr 2015 02:32:56 -0700 (PDT) X-Received: by 10.112.126.136 with SMTP id my8mr3032658lbb.18.1430386376816; Thu, 30 Apr 2015 02:32:56 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id r10si1366089lal.5.2015.04.30.02.32.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 02:32:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcga7 with SMTP id ga7so39991734lbc.1 for ; Thu, 30 Apr 2015 02:32:56 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr3035757lbb.36.1430386376518; Thu, 30 Apr 2015 02:32:56 -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 l1csp2998389lbt; Thu, 30 Apr 2015 02:32:55 -0700 (PDT) X-Received: by 10.66.66.166 with SMTP id g6mr6638559pat.88.1430385975422; Thu, 30 Apr 2015 02:26:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nf2si2640288pbc.149.2015.04.30.02.26.14; Thu, 30 Apr 2015 02:26:15 -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 S1751505AbbD3JZz (ORCPT + 2 others); Thu, 30 Apr 2015 05:25:55 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:53081 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751531AbbD3JZT (ORCPT ); Thu, 30 Apr 2015 05:25:19 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.85) (envelope-from ) id 1YnkiW-0005OD-7t; Thu, 30 Apr 2015 11:25:12 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: Kim Phillips , Marc Zyngier , Shannon Zhao , Jiri Slaby Subject: [patch added to the 3.12 stable tree] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Date: Thu, 30 Apr 2015 11:24:44 +0200 Message-Id: <1430385911-20480-36-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430385911-20480-1-git-send-email-jslaby@suse.cz> References: <1430385911-20480-1-git-send-email-jslaby@suse.cz> 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.217.169 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 This patch has been added to the 3.12 stable tree. If you have any objections, please let us 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);