From patchwork Thu May 23 15:31:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 17152 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A4B32395B for ; Thu, 23 May 2013 15:32:31 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id cz11sf4665935veb.2 for ; Thu, 23 May 2013 08:31:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=a510q/N+DLkITvZTnSZOxBABUSP00u8+uKKaQB3Mq18=; b=L3bj3pdtk/2v0SGA1ksfemiUadoK6CA6yFKZYZMqUpoaWCn9i7aZY/paZSoPvFuHzP Xzho7IG8C3SKpzH1HNJ8Thpp3Pq/vxUu+wqfB5wGruu2+sSkQzfbaKhWP3fez6lKqpBP paFyFfRRTIiNEK/bOp7tLQLrlwG2/kxRlImU8HaaOaAB4LxTDrelrYmaiJlTI8XPQXMl B8QmkmqkhFmbGiq1DwSQMcstyYa4vnvnVb6RPHguqyyQYg2iP4SLc+TrEvUo24o20QuU d0Qk5K18qf7KtSYur2RzqjxJC2qsuFTFQ+F+tMToeBL/DGZ5+Pe4MfBiDYa86rFVbNhH fogg== X-Received: by 10.224.59.205 with SMTP id m13mr6577696qah.7.1369323095844; Thu, 23 May 2013 08:31:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.96.35 with SMTP id dp3ls1548592qeb.87.gmail; Thu, 23 May 2013 08:31:35 -0700 (PDT) X-Received: by 10.58.171.167 with SMTP id av7mr5582738vec.15.1369323095553; Thu, 23 May 2013 08:31:35 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id sa4si6660728vdc.36.2013.05.23.08.31.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:31:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id kw10so2284571vcb.14 for ; Thu, 23 May 2013 08:31:35 -0700 (PDT) X-Received: by 10.52.163.207 with SMTP id yk15mr4755096vdb.42.1369323095419; Thu, 23 May 2013 08:31:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp57322vcs; Thu, 23 May 2013 08:31:31 -0700 (PDT) X-Received: by 10.180.90.164 with SMTP id bx4mr44190299wib.13.1369323090871; Thu, 23 May 2013 08:31:30 -0700 (PDT) Received: from mail-wg0-x236.google.com (mail-wg0-x236.google.com [2a00:1450:400c:c00::236]) by mx.google.com with ESMTPS id hk7si9230447wib.107.2013.05.23.08.31.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:31:30 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c00::236 is neither permitted nor denied by best guess record for domain of steve.capper@linaro.org) client-ip=2a00:1450:400c:c00::236; Received: by mail-wg0-f54.google.com with SMTP id j13so755491wgh.33 for ; Thu, 23 May 2013 08:31:30 -0700 (PDT) X-Received: by 10.180.14.199 with SMTP id r7mr25846173wic.6.1369323090349; Thu, 23 May 2013 08:31:30 -0700 (PDT) Received: from localhost.localdomain (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id b11sm36416484wiv.10.2013.05.23.08.31.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 May 2013 08:31:29 -0700 (PDT) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Cc: will.deacon@arm.com, patches@linaro.org, Steve Capper Subject: [PATCH v2 1/4] ARM: mm: correct pte_same behaviour for LPAE. Date: Thu, 23 May 2013 16:31:17 +0100 Message-Id: <1369323080-9673-2-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1369323080-9673-1-git-send-email-steve.capper@linaro.org> References: <1369323080-9673-1-git-send-email-steve.capper@linaro.org> X-Gm-Message-State: ALoCoQn/dKbztg1qgnuFl9lKWKEK0EkufMFhxnyADgGqjh2KMHCkpfess99qPBOiQ7gpERXC96GX X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Reviewed-by: Catalin Marinas --- 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__ */