From patchwork Wed Jan 8 22:47:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 3456461 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CAC4FC02DC for ; Wed, 8 Jan 2014 22:50:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06D36201BC for ; Wed, 8 Jan 2014 22:50:59 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 20A742010F for ; Wed, 8 Jan 2014 22:50:58 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W11vt-0000Xw-Vg; Wed, 08 Jan 2014 22:49:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W11vT-0004jK-5s; Wed, 08 Jan 2014 22:48:39 +0000 Received: from mail-pa0-f51.google.com ([209.85.220.51]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W11uz-0004fI-Da for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2014 22:48:10 +0000 Received: by mail-pa0-f51.google.com with SMTP id fa1so2477320pad.10 for ; Wed, 08 Jan 2014 14:47:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ttr9WmYndIycYr/wu8kAPJZmDD/qITWFHfXPA+GerSA=; b=aX5D07ejTVSZ39F4K2EOXkOlPRtVSOGEhis53M8TK9E3hxXMUTELbLqebMwmz7ooyQ 1TyXmX9YkZLHCFB+gruFMeGRQubA0SccS1Mg0Jv5GaXuDDxmAH0HrX3o5Bc3EDxIYcOb TtFj0zTQg18vVmYAHgiXOIdcnpHoM1Y0mDyYfxG4KiL40qT/Rk+Z4OUkLOV6rdn6GnSr Zt/3LB8ghfhrappvLSFvyxJptvJp33evz1WYz0lTdb4iJlpO62qa9/CdpS+thyUWFRqq 50LRTQLgt0NfZ3F66fKXVmiET3LsQZpei1eXxazQvgRoQud2i8kEZGwAdOplS69xbr+3 rUKA== X-Gm-Message-State: ALoCoQknDy2WATm8O58PQ31PqG8PSBNmmiTD/hix1FwE16xEyhHzUxfqbMXdV+6hA+a9MKRFhtb7 X-Received: by 10.66.190.198 with SMTP id gs6mr16073131pac.49.1389221267949; Wed, 08 Jan 2014 14:47:47 -0800 (PST) Received: from localhost.localdomain (c-67-169-181-221.hsd1.ca.comcast.net. [67.169.181.221]) by mx.google.com with ESMTPSA id xv2sm4920755pbb.39.2014.01.08.14.47.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 14:47:47 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 4/5] arm/arm64: KVM: relax the requirements of VMA alignment for THP Date: Wed, 8 Jan 2014 14:47:29 -0800 Message-Id: <1389221250-30034-5-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389221250-30034-1-git-send-email-christoffer.dall@linaro.org> References: <1389221250-30034-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140108_174809_591706_B95D60DF X-CRM114-Status: GOOD ( 14.40 ) X-Spam-Score: -2.6 (--) Cc: Gleb Natapov , Marc Zyngier , Marcelo Tosatti , Christoffer Dall , Paolo Bonzini , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier The THP code in KVM/ARM is a bit restrictive in not allowing a THP to be used if the VMA is not 2MB aligned. Actually, it is not so much the VMA that matters, but the associated memslot: A process can perfectly mmap a region with no particular alignment restriction, and then pass a 2MB aligned address to KVM. In this case, KVM will only use this 2MB aligned region, and will ignore the range between vma->vm_start and memslot->userspace_addr. It can also choose to place this memslot at whatever alignment it wants in the IPA space. In the end, what matters is the relative alignment of the user space and IPA mappings with respect to a 2M page. They absolutely must be the same if you want to use THP. Cc: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/kvm/mmu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 659db0e..7789857 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -667,14 +667,16 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT; } else { /* - * Pages belonging to VMAs not aligned to the PMD mapping - * granularity cannot be mapped using block descriptors even - * if the pages belong to a THP for the process, because the - * stage-2 block descriptor will cover more than a single THP - * and we loose atomicity for unmapping, updates, and splits - * of the THP or other pages in the stage-2 block range. + * Pages belonging to memslots that don't have the same + * alignment for userspace and IPA cannot be mapped using + * block descriptors even if the pages belong to a THP for + * the process, because the stage-2 block descriptor will + * cover more than a single THP and we loose atomicity for + * unmapping, updates, and splits of the THP or other pages + * in the stage-2 block range. */ - if (vma->vm_start & ~PMD_MASK) + if ((memslot->userspace_addr & ~PMD_MASK) != + ((memslot->base_gfn << PAGE_SHIFT) & ~PMD_MASK)) force_pte = true; } up_read(¤t->mm->mmap_sem);