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: 124310 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2005989qgn; Fri, 12 Jan 2018 04:33:46 -0800 (PST) X-Google-Smtp-Source: ACJfBosGQs2ukZrqATjHGNUDNU/7yIKzc6FkdsxjQiT1uDNpjzErQ/Sf9AXm6mExZlL5CGeuC+xs X-Received: by 10.99.63.14 with SMTP id m14mr20355991pga.358.1515760426606; Fri, 12 Jan 2018 04:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515760426; cv=none; d=google.com; s=arc-20160816; b=lg50d92uqT4chUi2UKsh7vu+9PKxeOdJDvTb7TlnpDdjhrxvflRibtRFbe0nhSQzMU iDK5wd8lANnAUtnQWJv4v165bZ6DLLJ6ZJ4J5FIAxb6mOPy8Cc/3Jzuv9rJEaXSEcpmT Lxa7+l3ZJyb+34PEj6njACbBq1ZJ/TA7Jxlq4eee/mGRFLUPthMbRZAL47Lg86laybpd hTC+wQs8bH/M/oCBtj0g/NqIqP9km+X6ck0iCjGWSsaBwFbMhxTDNSajd674OnbRvzPd qaguMzmG7Vv+4/ag7pcAXsaqV4cnbU1YCnm1dcAcueocchSMxPSOFJ+o7sS/awR1Df1K XWyw== 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=qihEByNj+mfbJrG6MwytlNIGeu3BuXm1c6q82haOy5KBW+XyIyoFiH5HpR55tOAzy7 CLl3mIwEPQGB9gbCgh53YBKq27Y9IUj8tqsX/lRLf13+Vh3cUqcP5PCT6CAV1vaPa/Wz 61PGBGERJXZYgJoDa3Nwwc23/1OM4e30MZstUZw5WpW2vG3Uxpe3vOb7+lNYrah7peu9 PnfiCiA4fdIsZ04JaNrNa94Ddwwy6wooyOzB9lVVTKJlM1zAdGdtvQUEo6XJcN1NeAUz ozET64CIDkRVYhbqeziPcgsHQ/QEiqmUh/q4LdqAitqlDFfKfg8L7XDTZaoaglsIY76U p8fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fnKZOzJ2; 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 ay5si15514189plb.438.2018.01.12.04.33.46; Fri, 12 Jan 2018 04:33:46 -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=fnKZOzJ2; 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 S933410AbeALMdn (ORCPT + 10 others); Fri, 12 Jan 2018 07:33:43 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39672 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933355AbeALMdl (ORCPT ); Fri, 12 Jan 2018 07:33:41 -0500 Received: by mail-wm0-f65.google.com with SMTP id i11so11473191wmf.4 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=gyaZCPcNpLktfESYTq+xf+Grypw5900i4xxzaqKCV/Zs0RFStC4i7g8Evgn21rNTfO wbgkIyaDRUgg4YPF23QWoBs438ZxFMeNsOsNM/7k3xCnM76atz4OLTKVFHk4ujvw1tjA mB45zBTij55s8xs16SBf3vgEI1od30n79NxNBI4bmKx1usZCDvhvAirDOh8mot5GI7Xp hy5tlfNed3c6Q/dSxqrqJa7P34szNDnJTfTpOzs0Ua+rR9ST5xFpsZ0CGLkGPXZYE0Fs IZsFie1itvDLPSrDrjY2wT/yJgXlmYX++Efet0LLroJZo8tZk9nlZB4lyFRqa7wGRgBl QVQw== X-Gm-Message-State: AKwxytct099ALmqMh2FKS0YIbmPiEpT1xbEIykgO7NJf8000z5WITq+l kW5f4ZLPJSQG3g6Bzz8WA+Toew== 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?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 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> 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 {