From patchwork Tue Aug 4 14:41:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 51911 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 14359229FD for ; Tue, 4 Aug 2015 14:44:18 +0000 (UTC) Received: by wixh2 with SMTP id h2sf7270602wix.0 for ; Tue, 04 Aug 2015 07:44:17 -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:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=TYloDn1GjvphlfLaezmAznLvAF+YlA2LlOh/Y4v75zs=; b=VQLTT/yBFNtI4IFXcs3FWdW/TXLDnJaeUrtXKJHKEIn237W/aVtoHhqLNxS1nDQo/v 31POavCubqpa3aM2KMnyOh55iQD3FpKdskSmQx40zj1L9Egt5fjgPRPGPRz33KpamonR NxepCKKVq4YMhGSln6KG5qUCdtlK10ak5Y38wPjO5Rm3VTSlgglh/tcBGJiyOXTdK5Qy di5CWsQRFu9vUVt89bZwaNjNBaOIgPila/qGL+mz1/+LVT2jL/JV1UQp9ep4erDgsjLv bnme1gnLP1Mm6Gzl89vUU+vV12BUmA5/uPrqFuo08s/GhItOqGumzjqpvxNYGlmnN75F TCZQ== X-Gm-Message-State: ALoCoQnZnEpn56l43j5CPGmbNy0HYBO+M4MHqScQkl/ZwF647ZhKhEo6HgR2V611iRk3zmfUdl5s X-Received: by 10.112.173.230 with SMTP id bn6mr1229326lbc.15.1438699457342; Tue, 04 Aug 2015 07:44:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.70 with SMTP id x6ls63718laa.5.gmail; Tue, 04 Aug 2015 07:44:17 -0700 (PDT) X-Received: by 10.112.150.4 with SMTP id ue4mr3944512lbb.26.1438699457198; Tue, 04 Aug 2015 07:44:17 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id a4si832132lak.156.2015.08.04.07.44.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 07:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by labsr2 with SMTP id sr2so8863024lab.2 for ; Tue, 04 Aug 2015 07:44:17 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr3886752lay.72.1438699456933; Tue, 04 Aug 2015 07:44:16 -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.7.198 with SMTP id l6csp2464834lba; Tue, 4 Aug 2015 07:44:15 -0700 (PDT) X-Received: by 10.67.15.67 with SMTP id fm3mr8418887pad.114.1438699454914; Tue, 04 Aug 2015 07:44:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ve14si2368735pab.20.2015.08.04.07.44.13; Tue, 04 Aug 2015 07:44:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S1756881AbbHDOoL (ORCPT + 28 others); Tue, 4 Aug 2015 10:44:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:59425 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965211AbbHDOmy (ORCPT ); Tue, 4 Aug 2015 10:42:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F069BAAF6; Tue, 4 Aug 2015 14:42:52 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Christoffer Dall , Catalin Marinas , Jiri Slaby Subject: [PATCH 3.12 119/123] arm64: Don't report clear pmds and puds as huge Date: Tue, 4 Aug 2015 16:41:03 +0200 Message-Id: <60354de68f547faaf71569eefdeed00b4df968a0.1438699154.git.jslaby@suse.cz> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.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.46 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: , From: Christoffer Dall 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit fd28f5d439fca77348c129d5b73043a56f8a0296 upstream. 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. Signed-off-by: Christoffer Dall Reviewed-by: Steve Capper Acked-by: Marc Zyngier Fixes: 084bd29810a5 ("ARM64: mm: HugeTLB support.") Signed-off-by: Catalin Marinas Signed-off-by: Jiri Slaby --- 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 2de9d2e59d96..0eeb4f0930a0 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