From patchwork Wed Jul 1 12:08:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 50519 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 03B78214B3 for ; Wed, 1 Jul 2015 12:08:39 +0000 (UTC) Received: by lbcpe5 with SMTP id pe5sf5117174lbc.3 for ; Wed, 01 Jul 2015 05:08:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=WSUhm3/TSJkJFkcUigO2UlI9DxRg8uKWPhx8ez+w8ec=; b=j+izIu4EF1vDeiqIevG14UR+9+jzagWlEYnFbIkU6+0Jd6gNWizs/Rf5ns00P5+qHh 7LM69qJC6pc/Bw0cZI0lV3DJ+iv85O4Uk4557y71Ct7xfi/GIb4qV5cqHpGXVPUDNZRF CzBZn4L87GVkyNffNUnS5Yhx5DeMn3pwb8DfebOzNll4pzwTNhfqeMCMlKLqSdk84VKp 3NAio0UulU35ZCMRo/uBqG3Rdq3lBic06nFGAhiESe56tlmd4Y9tXNWyeHp3IKeyhPUX LSrNPcsxTgCBDvyQjZUrsjpX5MGCa0t2Z6yBH1KxcV3ke3svbI2M/XCb4NhKLx1Mj1s8 61jg== X-Gm-Message-State: ALoCoQkcaiJ+THZGjACj38lby9o7o28oSJvmYM9zI7a2goKwfvpf16xMZ8rW9fJMQ4iIgPYa3+mz X-Received: by 10.194.81.136 with SMTP id a8mr17065911wjy.2.1435752517917; Wed, 01 Jul 2015 05:08:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.8 with SMTP id u8ls181846laj.39.gmail; Wed, 01 Jul 2015 05:08:37 -0700 (PDT) X-Received: by 10.152.29.69 with SMTP id i5mr24829603lah.6.1435752517687; Wed, 01 Jul 2015 05:08:37 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id l9si1554124lam.36.2015.07.01.05.08.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2015 05:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lagc2 with SMTP id c2so39225324lag.3 for ; Wed, 01 Jul 2015 05:08:37 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr25366835lbb.56.1435752517562; Wed, 01 Jul 2015 05:08:37 -0700 (PDT) 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.112.108.230 with SMTP id hn6csp562906lbb; Wed, 1 Jul 2015 05:08:36 -0700 (PDT) X-Received: by 10.68.179.228 with SMTP id dj4mr53543229pbc.141.1435752515854; Wed, 01 Jul 2015 05:08:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id by2si3105531pbb.217.2015.07.01.05.08.35; Wed, 01 Jul 2015 05:08:35 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbbGAMIe (ORCPT + 2 others); Wed, 1 Jul 2015 08:08:34 -0400 Received: from mail-la0-f42.google.com ([209.85.215.42]:33153 "EHLO mail-la0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751548AbbGAMId (ORCPT ); Wed, 1 Jul 2015 08:08:33 -0400 Received: by laar3 with SMTP id r3so39331567laa.0 for ; Wed, 01 Jul 2015 05:08:32 -0700 (PDT) X-Received: by 10.152.206.10 with SMTP id lk10mr24919291lac.90.1435752511815; Wed, 01 Jul 2015 05:08:31 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id mx10sm459877lbb.20.2015.07.01.05.08.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jul 2015 05:08:30 -0700 (PDT) From: Christoffer Dall To: linux-arm-kernel@lists.infradead.org Cc: Steve Capper , Alexander Graf , Marc Zyngier , Catalin Marinas , kvmarm@lists.cs.columbia.edu, dirk@dmllr.de, Christoffer Dall , stable@vger.kernel.org Subject: [PATCH] arm64: Don't report clear pmds and puds as huge Date: Wed, 1 Jul 2015 14:08:31 +0200 Message-Id: <1435752511-7079-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The current pmd_huge() and pud_huge() functions simply check if the table bit is not set and reports the entries as huge in that case. This is counter-intuitive as a clear pmd/pud cannot also be a huge pmd/pud, and it is inconsistent with at least arm and x86. To prevent others from making the same mistake as me in looking at code that calls these functions and to fix an issue with KVM on arm64 that causes memory corruption due to incorrect page reference counting resulting from this mistake, let's change the behavior. Cc: stable@vger.kernel.org Signed-off-by: Christoffer Dall Reviewed-by: Steve Capper --- arch/arm64/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 2de9d2e..0eeb4f09 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -40,13 +40,13 @@ int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep) int pmd_huge(pmd_t pmd) { - return !(pmd_val(pmd) & PMD_TABLE_BIT); + return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT); } int pud_huge(pud_t pud) { #ifndef __PAGETABLE_PMD_FOLDED - return !(pud_val(pud) & PUD_TABLE_BIT); + return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT); #else return 0; #endif