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: 10167699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA32D600CA for ; Tue, 16 Jan 2018 17:03:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8B8F22701 for ; Tue, 16 Jan 2018 17:03:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD26822BF1; Tue, 16 Jan 2018 17:03:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4486722701 for ; Tue, 16 Jan 2018 17:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6297HRaiSWqRrHVOmj4vcHxnvzduU81t4msryqo30hs=; b=N055ZPOT/MBwZG1evbZEqZ05su ZqgvgGRAA6nZbmKjYt3H6gbOGuy7zrGtOSxXJgZCqT+dKpbD66YuSJLofXPfTDoROWuwvZPcd1kPn d/x/FGqcWhCCVOckiNPaGj7rm/cL1SD26yA9G1IpkDby5nfL3gqaXc2bjjYDZIDK3lWPH6vPLNGv/ aFbk4N+1PTp0lCnYroW+HDbI7UjkIn4BTJCrDU02Vxf2sndJlLxfLm+gMf0yn5iqyOf/YkQe4uhg1 uND0L6sdbAfY2LbBxIKMSddDu/2x6g4muWC9yRtFYx83aS6EPVAOLYspJ+wdTlQlNDfonzNQbuxV0 SwZeuhQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebUdg-0006xb-SM; Tue, 16 Jan 2018 17:03:08 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebUdO-0006fr-MS for linux-arm-kernel@lists.infradead.org; Tue, 16 Jan 2018 17:02:56 +0000 Received: by mail-wm0-x241.google.com with SMTP id i11so9995359wmf.4 for ; Tue, 16 Jan 2018 09:02:40 -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=sj8/C1KGTrj/9X0trLxlZJY63jGgDKEVndq7DTRBN0HogumpiZFx7iW08S/4p+2rVv c089NYLtzfzrrIYVRW7eqi00Hqe2KgRJDriqsJyDFJ+HQb2JMfdEwcW1kklUdncK+U36 c6z/2OrCp/raDOMaeX3enlt0nV3kmB11+fvoLomQvx17sYuFLYeR4O7l9itbhMoPqK1f 6cBlLTmc/60JYkq8QTX4XFQ+yOhmfrSax/UqCLSuDxO+3A5kNSQ6OQn3M8rrh3fXB74o DTl2gV6PAEWxJLu00+UlohquSrEMd6zWbcAx0IxN1ZucRd7fSz9LsDm/2daBazZKa9ma V7TA== X-Gm-Message-State: AKGB3mICo1ixzeBegIjlS6G019Cpd1AFCGXCqSUyy+0snTBAPPcR4pEA F8vOfLOBeHarmvyq/syLDUyI0A== X-Google-Smtp-Source: ACJfBou/W/IUav+s3YnplOmmBPlkUJifIkpl5UTf1nxFEWIJYAIkuqo9Ta2U4xyGDB2RMG9WlFz2gw== 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?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180116_090250_740492_FEDB492D X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Marc Zyngier , Punit Agrawal , stable@vger.kernel.org, Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 {