From patchwork Fri Jan 12 12:33:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10160673 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 B8BD9602A7 for ; Fri, 12 Jan 2018 12:34:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4AC028870 for ; Fri, 12 Jan 2018 12:34:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 990F8289D6; Fri, 12 Jan 2018 12:34:28 +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 0DFC728870 for ; Fri, 12 Jan 2018 12:34:27 +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=LOpqdvk0KxcNp9TbCYStE0O+GU UG6hku0hkEKg4/lNCG8L1m0otZAFINmbMDMSL7Jdj/cbzljBN6q9WNoVzvpq8gAiZd1MS5pyfbrVP +3QYtcl+Zk6NCKCniVJI+9Z0tAOmO04j1Kw5ZWWTg3wIFJhIkK8w9FbWOUtsB4BNn8KWjZJhIUlCU ivlUucTRFPfHcG++ci7oR8hFtnGNaI2uYEF3ITXAVwzqGybibINXYUXSBgRRBlOFVtUaKVTqZPlPT 1sCb0RUkqNAi8kSxMTQK5cuCdgW8eG7QlTrJnNXpYkLebXvklk5vW+vqOwdNNenJT0MPT+l51rsDW pXeL/OSQ==; 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 1eZyXP-0002Ai-0D; Fri, 12 Jan 2018 12:34:23 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZyWu-0001Vo-3Z for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2018 12:33:53 +0000 Received: by mail-wm0-x243.google.com with SMTP id r78so11626825wme.0 for ; Fri, 12 Jan 2018 04:33:41 -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=fnKZOzJ26JhyDyi+Zgk4uxhsktRRc8wwAEYdjGvlGRChz+mOlhKz6Sh+H86GXDlaAH QMBbmy4B/9WdSrR3abFu1TC8/KaUIqRUpKtPsUdoElK9Iqwr8UqEe29zxYM6sPAfru7g WpJ/9uCM9rUvwduWYMcOZO78BMkvKMlUuvww8= 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=lC7e0o/KSqXCMKx/WulA1GzcHVXQ3Cwd4AmauT9notJyRxNgSS5mb9ekiHEWuyuawD ELfUjOzqTCXgQhKPcRsiqx/2uwntmMkRsJn7CoznhNxLLrEnvJZgck578w19ayYlA8mo pHKVsRLRKOrbnMGZCjmZdni30zoJLTXueyfrRq8FSAVCfYfdJ73S3sUEfpUqY0iGQ3B7 qBnZdfuLpL1KWOQnhk+SWSrAr6YsZ5I22pR6pigYiTXrQOj90Iw0+P80weSV3FHN/WW4 jCuoMXl1eR1g6g4iAf2KA6gsB1Vz09eBR9rbVEIcZ81WWa7u8UKOaJbk5l1vPIxtpbul oPyA== X-Gm-Message-State: AKwxytcuJ3f1TdLOTTNK6bBZOn9HOt+5xztMxeO7yLAL3efmfh6BFc5z pcy2PzN+agtV5BTxAAq9WuDekw== X-Google-Smtp-Source: ACJfBosBNy2eRSxSoIzCui1WTLZQinHPqhyQFJcjp4GJk6r4tm2nVSx0K13yw/tsTpMK1LaagS+yEQ== X-Received: by 10.80.195.75 with SMTP id q11mr1793748edb.254.1515760420568; Fri, 12 Jan 2018 04:33:40 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id g61sm12591145edd.48.2018.01.12.04.33.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 04:33:39 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 1/2] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Date: Fri, 12 Jan 2018 13:33:33 +0100 Message-Id: <20180112123334.28687-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180112123334.28687-1-christoffer.dall@linaro.org> References: <20180112123334.28687-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_043352_145598_2E25FA5E X-CRM114-Status: GOOD ( 11.05 ) 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 {