From patchwork Tue Nov 11 11:31:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Pengyang X-Patchwork-Id: 40567 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E5638241C9 for ; Tue, 11 Nov 2014 11:33:14 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf6715239eek.2 for ; Tue, 11 Nov 2014 03:33:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=J4m9xq5+zlB10bQQby4lbuX4z7ViM8cAVhW2Mj2gJQM=; b=X2sFWuzl5rZRNdh6+YTnWQytrlVISIxM/znxZP5MfDGfvBEzpsylGx3mTZddRnErP4 KcWimwZdWw2cZo1HZDG2LX5wsVzEwgmEM6vT/72DNh5AFcxeCjgwwmlPtH0gJ6QKTBCM Hnw5I5q5zJQ5PfDGh6aPdv+ZWdt9ey5Iyu4Ik/+fyAt913KyDIaWKZr87vFRsd29+o0s uuvxunjIdn6k6Tnyff7pvrI/4qpR1WXhfsrfRD0+4BkWG9dvzxPUJrUW2gvAws+A9ZTj NSn6aqZp/9nSnygchbHkVIC4RRZkmYBW9/msXAX9lP2+QhC9Odiny92pngd8HCQWGJc8 RUcQ== X-Gm-Message-State: ALoCoQnMKPLZ9tHXcM5lxWkVbNH9gU1cvaOMwM0eVmc5MjzJ8wNgRCh8Z9RoeTNNGT7gnLYaSWOr X-Received: by 10.112.247.74 with SMTP id yc10mr6380750lbc.8.1415705594227; Tue, 11 Nov 2014 03:33:14 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.227 with SMTP id ap3ls555114lac.60.gmail; Tue, 11 Nov 2014 03:33:13 -0800 (PST) X-Received: by 10.112.137.39 with SMTP id qf7mr35271277lbb.47.1415705593923; Tue, 11 Nov 2014 03:33:13 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id oc10si31030143lbb.99.2014.11.11.03.33.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 03:33:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id z12so694832lbi.36 for ; Tue, 11 Nov 2014 03:33:13 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr35297465lbc.23.1415705593813; Tue, 11 Nov 2014 03:33:13 -0800 (PST) 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.184.201 with SMTP id ew9csp239555lbc; Tue, 11 Nov 2014 03:33:12 -0800 (PST) X-Received: by 10.68.92.97 with SMTP id cl1mr38504361pbb.99.1415705589880; Tue, 11 Nov 2014 03:33:09 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ms8si6258344pdb.144.2014.11.11.03.33.09 for ; Tue, 11 Nov 2014 03:33:09 -0800 (PST) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753192AbaKKLc4 (ORCPT + 1 other); Tue, 11 Nov 2014 06:32:56 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:23019 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbaKKLcy (ORCPT ); Tue, 11 Nov 2014 06:32:54 -0500 Received: from 172.24.2.119 (EHLO szxeml406-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AWY31727; Tue, 11 Nov 2014 19:32:51 +0800 (CST) Received: from linux-2wy1.site (10.107.197.185) by szxeml406-hub.china.huawei.com (10.82.67.93) with Microsoft SMTP Server id 14.3.158.1; Tue, 11 Nov 2014 19:32:43 +0800 From: Hou Pengyang To: , CC: Subject: [PATCH 01/12] ARM: mm: correct pte_same behaviour for LPAE. Date: Tue, 11 Nov 2014 11:31:28 +0000 Message-ID: <1415705499-197612-2-git-send-email-houpengyang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1415705499-197612-1-git-send-email-houpengyang@huawei.com> References: <1415705499-197612-1-git-send-email-houpengyang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.185] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020208.5461F3E4.0086, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5bef2b8fd3fe08efe4253db5970673f9 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: patch@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.217.177 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: Steve Capper commit dde1b65110353517816bcbc58539463396202244 upstream. For 3 levels of paging the PTE_EXT_NG bit will be set for user address ptes that are written to a page table but not for ptes created with mk_pte. This can cause some comparison tests made by pte_same to fail spuriously and lead to other problems. To correct this behaviour, we mask off PTE_EXT_NG for any pte that is present before running the comparison. Signed-off-by: Steve Capper Reviewed-by: Will Deacon --- arch/arm/include/asm/pgtable-3level.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 86b8fe3..70f041c 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -166,6 +166,23 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) clean_pmd_entry(pmdp); \ } while (0) +/* + * For 3 levels of paging the PTE_EXT_NG bit will be set for user address ptes + * that are written to a page table but not for ptes created with mk_pte. + * + * In hugetlb_no_page, a new huge pte (new_pte) is generated and passed to + * hugetlb_cow, where it is compared with an entry in a page table. + * This comparison test fails erroneously leading ultimately to a memory leak. + * + * To correct this behaviour, we mask off PTE_EXT_NG for any pte that is + * present before running the comparison. + */ +#define __HAVE_ARCH_PTE_SAME +#define pte_same(pte_a,pte_b) ((pte_present(pte_a) ? pte_val(pte_a) & ~PTE_EXT_NG \ + : pte_val(pte_a)) \ + == (pte_present(pte_b) ? pte_val(pte_b) & ~PTE_EXT_NG \ + : pte_val(pte_b))) + #define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,__pte(pte_val(pte)|(ext))) #endif /* __ASSEMBLY__ */