From patchwork Tue Jan 16 17:02:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 124751 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1080511lje; Tue, 16 Jan 2018 09:02:54 -0800 (PST) X-Google-Smtp-Source: ACJfBotj6hCJ3r4vJwHndn+kMGu3FtlDTyuupwE+1U4IUyViozCFlYekjGih1yUL9kS3ENjmuNdN X-Received: by 10.84.253.148 with SMTP id a20mr38540444plm.216.1516122174691; Tue, 16 Jan 2018 09:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516122174; cv=none; d=google.com; s=arc-20160816; b=r5MrNRZ289fFoGrAtxcBHgt6Vnx9EXRWjf1oHoIOz/crObp7rzChJt4II5E49YB5hy SmlmiTTem/O4s6UjDHprRT0gtl1iPOhgA33qnk5VE9bby3Z28j+Af8nAXpB1TOd2Slxz yE+FDFJt6llBgHMxI1UZlhnM2Giwj3efXF16nF8KXE3wBGzWdb8vgQ1xsZYg705EUWWC kang0TjOOb2zGrgXWz45F0JmxoQ2V8boAS5o+zvx1eFf/oqsNRJKVZCGqwJKeX+fuTLj nrKjhFS3fnF+gZzKKSalUi87BRSLuml3tU1yiuR6TSrSHXz1TfgqrEG+h1xH+hUfLirU EjxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=N/5CM2WExP+3Sg/y66D4RldSXLI/4HOx6RZ1zsknEA8=; b=urNFgUqLXyjjbRV+VDh4zy6MYlr9+BflFC5Q+EowIumB602ainxbLOeIIIcLOO5T1M XcdkpSHAv7x5xe67GxgjImWpoKk6S4V+hnXoCVr2cVEAwKjG54SOMOvLu3+pyqnJMPNB FCrekdCPSXfekg41sQji7x8Hm9WqceEnu0DY+f4C5bUtx1y4JPzj7uIyKGt3FbFJv3fF SWMADSV5d/ePBXCnVMfcZWC2CG4GCJHNVQ64RvqOc71VHNw8LbEJloWnntL9mzQf2Yqr WZHe8rOWvJAUXzRxByRaLjQudsM2G1fcRhdbZWx8npxsloyxMQHats86A1SbUJ+62oJw TKlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FkOXRyXy; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u196si1956542pgc.116.2018.01.16.09.02.54; Tue, 16 Jan 2018 09:02:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FkOXRyXy; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751375AbeAPRCn (ORCPT + 10 others); Tue, 16 Jan 2018 12:02:43 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37159 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbeAPRCk (ORCPT ); Tue, 16 Jan 2018 12:02:40 -0500 Received: by mail-wm0-f67.google.com with SMTP id v71so10106470wmv.2 for ; Tue, 16 Jan 2018 09:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N/5CM2WExP+3Sg/y66D4RldSXLI/4HOx6RZ1zsknEA8=; b=FkOXRyXyNJZp2QA2jY6HWoa9JGlO+WKmk2CgcyIFwJhUbdSgs9+SGrMyvcGIlGmvBJ IpDzsmqhCKCCqpEFdx75+8wIJq7iW/4Q1V55M/OSQFBFYhBWgi7joPNwabF4jNdki3q7 to760LZ2DVoxlkuNb6GVG5HP2SneWw8F4MN9Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N/5CM2WExP+3Sg/y66D4RldSXLI/4HOx6RZ1zsknEA8=; b=gEF/BruGlBGL7ZLptfv3amTcvGUTJQWW7dkkoLvj/tsVpJyxowDUZJ07PrIo0iT2EY ksyqhHMVTFDIB3EkTfJKw1Jg8Jg7GKZkfMDQfbVtH5umLBsbkbeZgiZStM/DniYHQHaN aGogE3OnbTsqUu2aaDo2yM6D0uyhjQ/D70IaxkXMDeohtyRSDLSLHoHurfBIRgjHsF5b 2eFsqkDJPZqf+VpYnmDaVtoSUZ0SEasqGuCsY4d7IHwNx8bz8wux1S7yQGAK75/sVRel IaJtfHoKNkRsBCMZfiePhNRnUuXT5EcG5B0kO2SxkHx2eqPl5f5mTc+y0XK1a9eZaQXy Oeaw== X-Gm-Message-State: AKGB3mKYcN7wRGrPRr3o9qC/BVhL9ltZNANBHMPtOVF4x34XPKXw+BVd jh6RxTKVUwGsOnq9VAbGXJ4Z6A== X-Received: by 10.80.202.7 with SMTP id d7mr54755679edi.32.1516122158908; Tue, 16 Jan 2018 09:02:38 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id r29sm2107162edl.82.2018.01.16.09.02.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 09:02:38 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Punit Agrawal , stable@vger.kernel.org, Christoffer Dall Subject: [PULL v2 1/3] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Date: Tue, 16 Jan 2018 18:02:31 +0100 Message-Id: <20180116170233.7085-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180116170233.7085-1-christoffer.dall@linaro.org> References: <20180116170233.7085-1-christoffer.dall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Punit Agrawal KVM only supports PMD hugepages at stage 2 but doesn't actually check that the provided hugepage memory pagesize is PMD_SIZE before populating stage 2 entries. In cases where the backing hugepage size is smaller than PMD_SIZE (such as when using contiguous hugepages), KVM can end up creating stage 2 mappings that extend beyond the supplied memory. Fix this by checking for the pagesize of userspace vma before creating PMD hugepage at stage 2. Fixes: 66b3923a1a0f77a ("arm64: hugetlb: add support for PTE contiguous bit") Signed-off-by: Punit Agrawal Cc: Marc Zyngier Cc: # v4.5+ Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall --- virt/kvm/arm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.14.2 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index b4b69c2d1012..9dea96380339 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1310,7 +1310,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, return -EFAULT; } - if (is_vm_hugetlb_page(vma) && !logging_active) { + if (vma_kernel_pagesize(vma) == PMD_SIZE && !logging_active) { hugetlb = true; gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT; } else {