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: 22991 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8FA18202E2 for ; Wed, 8 Jan 2014 22:51:54 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wo20sf8312306obc.1 for ; Wed, 08 Jan 2014 14:51:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=2f19Toh0t1wx1H6SS7ODiLi8wNkqn4BqPjU09nD2S0E=; b=SNYoSq8tDgESFVOWzm9BhIK5LKidonqLDjnDAv/vhTSYKIO0Y3zMhEmCwJYTYoakj4 d8pOCccS+gx+PRihLuuufRdBMnTuRdc0mfK9iWgvC8KDybUed/MBvmO0QiJAG46PW0b/ Q8rvUFTjE+g+WWsmqAZZ0bHPep00HubQB3gazfhCBLL7O42JAseqmgRqx++aJIzd34O5 e8SG1aNXGGTCu3kNzUVsMR1eTBtZg5j5/BFXwLIWld3M4eRuicTsjr1u4vaN63KIcV3Y vsQhm55K+sYvYOL/pcKDIF/o45blV3AMQ5azadSWVJix9nXfG4s2UyqWQWF8/owJeMgz 8JnA== X-Gm-Message-State: ALoCoQnojx2o0Lpe7IWdaEPWHS3L/SQz9gK3RWFO+1+S8YZmEyJZuYHDzkFOXqxp7xUOMLB7w3GL X-Received: by 10.42.81.84 with SMTP id y20mr47667961ick.10.1389221513725; Wed, 08 Jan 2014 14:51:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.75.129 with SMTP id c1ls604037qew.88.gmail; Wed, 08 Jan 2014 14:51:53 -0800 (PST) X-Received: by 10.52.117.135 with SMTP id ke7mr5332055vdb.43.1389221513602; Wed, 08 Jan 2014 14:51:53 -0800 (PST) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by mx.google.com with ESMTPS id ef6si1463269ved.9.2014.01.08.14.51.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 14:51:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.48 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.48; Received: by mail-vb0-f48.google.com with SMTP id q12so1634152vbe.21 for ; Wed, 08 Jan 2014 14:51:53 -0800 (PST) X-Received: by 10.58.69.41 with SMTP id b9mr48126615veu.5.1389221513465; Wed, 08 Jan 2014 14:51:53 -0800 (PST) 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.59.13.131 with SMTP id ey3csp257095ved; Wed, 8 Jan 2014 14:51:52 -0800 (PST) X-Received: by 10.194.175.66 with SMTP id by2mr12987811wjc.59.1389221512520; Wed, 08 Jan 2014 14:51:52 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id vh7si83919wjc.28.2014.01.08.14.51.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jan 2014 14:51:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W11vv-0000Xv-UM; Wed, 08 Jan 2014 22:49:09 +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-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 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.51 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.48 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: 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);