From patchwork Thu Jun 26 00:45:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 32513 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E9829201EF for ; Thu, 26 Jun 2014 00:53:36 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id f51sf3924067qge.10 for ; Wed, 25 Jun 2014 17:53:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:subject:message-id :in-reply-to:references:organization:mime-version:cc:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=dsAyFqjzSjz6oqZo1UbyVJcoHz3uL2YSfekmnKmBISw=; b=IrUSJsqt5Y0S0WDcEMIPIcYCzI0RjIXRiXHKW5KohfElu8bYJqmBbTxNBm6Yxd0qU2 uNmU9zN8O0pM311+W85MTDn2OoE3IGp5MocIPRxT4qht8T6MHu2Y2I73hZ0Idr6Lvbjk RCMPC1w+eH0398ySR97yyleXIWa4UZ4X4i6crNbNN/joQHRQpMQNHpsd5zVJam4BS213 tVk8GsLyAB26iq49BJOmH2fnzif7UXcZV2AOVWZCL+Nw2Raf4r/RlV2npmeMTXnw0ACy rKmKC3bYlHh70/tbNNVKI/qYdvxz4vqr+bAV+9GxCiCHkCVfCw8hXNbhP+GkE2HXiJ1h BW/w== X-Gm-Message-State: ALoCoQmWQ1OX+luNxZAPMWPsqEZ89z4kWmYXMB+PVU6f1jLXjIKzK+IaRWNojZvrYP7h7404v5+r X-Received: by 10.58.151.238 with SMTP id ut14mr6157385veb.11.1403744016469; Wed, 25 Jun 2014 17:53:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.118 with SMTP id x109ls37993qge.74.gmail; Wed, 25 Jun 2014 17:53:36 -0700 (PDT) X-Received: by 10.52.92.100 with SMTP id cl4mr4241370vdb.48.1403744016322; Wed, 25 Jun 2014 17:53:36 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id sd9si3419997vdc.26.2014.06.25.17.53.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Jun 2014 17:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hy10so2779547vcb.29 for ; Wed, 25 Jun 2014 17:53:36 -0700 (PDT) X-Received: by 10.52.118.99 with SMTP id kl3mr8530232vdb.18.1403744016228; Wed, 25 Jun 2014 17:53:36 -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.221.37.5 with SMTP id tc5csp329173vcb; Wed, 25 Jun 2014 17:53:35 -0700 (PDT) X-Received: by 10.68.189.137 with SMTP id gi9mr16480959pbc.79.1403744015249; Wed, 25 Jun 2014 17:53:35 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id uz10si7515556pbc.54.2014.06.25.17.53.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jun 2014 17:53:35 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WzxuO-0006F7-Tk; Thu, 26 Jun 2014 00:51:24 +0000 Received: from mail-bn1blp0186.outbound.protection.outlook.com ([207.46.163.186] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WzxuL-0006EH-9h for linux-arm-kernel@lists.infradead.org; Thu, 26 Jun 2014 00:51:22 +0000 Received: from BY2PR03CA036.namprd03.prod.outlook.com (10.242.234.157) by BY2PR03MB091.namprd03.prod.outlook.com (10.255.241.159) with Microsoft SMTP Server (TLS) id 15.0.959.15; Thu, 26 Jun 2014 00:50:57 +0000 Received: from BN1AFFO11FD028.protection.gbl (2a01:111:f400:7c10::128) by BY2PR03CA036.outlook.office365.com (2a01:111:e400:2c2c::29) with Microsoft SMTP Server (TLS) id 15.0.969.15 via Frontend Transport; Thu, 26 Jun 2014 00:50:57 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD028.mail.protection.outlook.com (10.58.52.88) with Microsoft SMTP Server (TLS) id 15.0.969.12 via Frontend Transport; Thu, 26 Jun 2014 00:50:56 +0000 Received: from x9.am.freescale.net (x9.am.freescale.net [10.81.32.211]) by az84smr01.freescale.net (8.14.3/8.14.0) with SMTP id s5Q0or2s027078; Wed, 25 Jun 2014 17:50:53 -0700 Date: Wed, 25 Jun 2014 19:45:51 -0500 From: Kim Phillips To: Marc Zyngier Subject: [PATCH 2/2 v2] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Message-ID: <20140625194551.a6443252bf913023159d25fd@freescale.com> In-Reply-To: <53A9556D.3000003@arm.com> References: <1395785294-2545-1-git-send-email-kim.phillips@linaro.org> <1395785294-2545-2-git-send-email-kim.phillips@linaro.org> <20140506180448.GH3066@lvm> <87bnvaotei.fsf@approximate.cambridge.arm.com> <20140507145557.GJ3066@lvm> <20140624102327.GA9121@arm.com> <53A9556D.3000003@arm.com> Organization: Freescale Semiconductor, Inc. X-Mailer: Sylpheed 3.2.0 (GTK+ 2.24.13; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(189002)(199002)(46102001)(69596002)(99396002)(87286001)(19580405001)(83322001)(87936001)(6806004)(88136002)(100306002)(20776003)(81542001)(81342001)(89996001)(68736004)(44976005)(50466002)(19580395003)(47776003)(104166001)(92566001)(21056001)(102836001)(92726001)(4396001)(85852003)(76482001)(26826002)(80022001)(50986999)(79102001)(93916002)(46406003)(76176999)(50226001)(86362001)(36756003)(93886003)(77982001)(74502001)(74662001)(31966008)(83072002)(95666004)(81156004)(104016002)(97736001)(105606002)(85306003)(23726002)(77156001)(33646001)(64706001)(84676001)(62966002)(106466001)(107046002); DIR:OUT; SFP:; SCL:1; SRVR:BY2PR03MB091; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: BL:0; ACTION:Default; RISK:Low; SCL:0; SPMLVL:NotSpam; PCL:0; RULEID: X-Forefront-PRVS: 02543CD7CD Received-SPF: Fail (: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=; client-ip=192.88.158.2; helo=az84smr01.freescale.net; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140625_175121_542173_0DF162DE X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [207.46.163.186 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.46.163.186 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record Cc: "kvm@vger.kernel.org" , Eric Auger , Kim Phillips , Will Deacon , "linux-kernel@vger.kernel.org" , Alex Williamson , "linux-arm-kernel@lists.infradead.org" , Antonios Motakis , "kvmarm@lists.cs.columbia.edu" , Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kim.phillips@freescale.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 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 From: Kim Phillips 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 --- Hi, here's a v2, upon request: - rebased onto today's mainline ToT - mmu.o-build tested only (ToT build doesn't complete) - made commit text less terse - added Christoffer's ack Cheers, Kim 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 16f8049..69af021 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -748,6 +748,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) { @@ -798,6 +799,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; @@ -805,7 +809,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); @@ -814,13 +818,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); }