From patchwork Fri Feb 14 16:55:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 24661 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 476CF2055D for ; Fri, 14 Feb 2014 16:58:20 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf27688581yha.7 for ; Fri, 14 Feb 2014 08:58:19 -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:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=pP+hY2U1W8MkWen4WCEzu30+/RyYWq+RTOj+rewC/GM=; b=VSZbYIylg9jiItfyEdZL7RCC5ofqj1Iibz67Yt5dfSEAP495i6DtYlVAECtOoW0AVQ 7C12Y59STAUCBx93MZ7aKVwmAK2UGw3xJDlQhaOCjnNQnA9/U57WkHhtH75NDnYUZT/a J9/s3ciReb/JLre5OlqXOk65XFI/IxxGclEjn0j6LDuLqE4NB9d6ZxcKe0nQ2IEbvYWT QQxy32jyH75szLoDZCGwNFe0VEa7QN+V4i8P2NABeVeh5MPTCS/9gZKUIbK1jj0DE+mL gAbWaPP1rhwpLc4Z7NLM6jyNkUiUG5omFvMsc+0U29qeawXSiSafinV79BxlnpXSfjN4 rjwA== X-Gm-Message-State: ALoCoQl8sTS0s4EO9X4MTj1fQcefxNO2YivWpXyNyju/9irs+R2f15ywH8j85o3mrRn1o+ViMSQ3 X-Received: by 10.236.138.114 with SMTP id z78mr2900775yhi.25.1392397099189; Fri, 14 Feb 2014 08:58:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.113 with SMTP id p104ls115113qga.41.gmail; Fri, 14 Feb 2014 08:58:19 -0800 (PST) X-Received: by 10.221.55.133 with SMTP id vy5mr6054100vcb.17.1392397099092; Fri, 14 Feb 2014 08:58:19 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id ls10si2119217vec.19.2014.02.14.08.58.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 08:58:19 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id c14so9764605vea.20 for ; Fri, 14 Feb 2014 08:58:19 -0800 (PST) X-Received: by 10.52.107.35 with SMTP id gz3mr5071784vdb.8.1392397098988; Fri, 14 Feb 2014 08:58:18 -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.220.174.196 with SMTP id u4csp124163vcz; Fri, 14 Feb 2014 08:58:18 -0800 (PST) X-Received: by 10.180.78.164 with SMTP id c4mr3069337wix.57.1392397097728; Fri, 14 Feb 2014 08:58:17 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id v4si1827559wiy.47.2014.02.14.08.58.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Feb 2014 08:58:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEM3m-0003x3-Mv; Fri, 14 Feb 2014 16:56:18 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEM3d-00075h-1M; Fri, 14 Feb 2014 16:56:09 +0000 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEM3N-000721-Ns for linux-arm-kernel@lists.infradead.org; Fri, 14 Feb 2014 16:55:54 +0000 Received: by mail-wi0-f176.google.com with SMTP id hi5so665216wib.15 for ; Fri, 14 Feb 2014 08:55:29 -0800 (PST) X-Received: by 10.180.98.35 with SMTP id ef3mr3103879wib.39.1392396929548; Fri, 14 Feb 2014 08:55:29 -0800 (PST) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id h13sm14005110wjr.22.2014.02.14.08.55.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Feb 2014 08:55:29 -0800 (PST) From: Steve Capper To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Subject: [RFC PATCH 2/2] arm: mm: Double logical invert for LPAE pte_write(), pte_dirty() Date: Fri, 14 Feb 2014 16:55:13 +0000 Message-Id: <1392396913-13570-3-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1392396913-13570-1-git-send-email-steve.capper@linaro.org> References: <1392396913-13570-1-git-send-email-steve.capper@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140214_115554_025325_6BD620BF X-CRM114-Status: GOOD ( 10.06 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.176 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: lauraa@codeaurora.org, catalin.marinas@arm.com, will.deacon@arm.com, keescook@chromium.org, Steve Capper X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On LPAE, L_PTE_WRITE and L_PTE_DIRTY are in the upper 32-bits. Unfortunately, results from pte_write() and pte_dirty() are downcast to 32-bits by core code: o gather_stats o huge_pte_dirty o huge_pte_write o make_migration_entry This patch adds a double logical invert to pte_write() and pte_dirty() for LPAE to ensure that the lower 32-bits are set if true. Signed-off-by: Steve Capper --- arch/arm/include/asm/pgtable-2level.h | 2 ++ arch/arm/include/asm/pgtable-3level.h | 14 ++++++++++++++ arch/arm/include/asm/pgtable.h | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index ca43b84..7e8ebe7 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -162,6 +162,8 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_large(pmd) (pmd_val(pmd) & 2) #define pmd_bad(pmd) (pmd_val(pmd) & 2) +#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE) +#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY) #define copy_pmd(pmdpd,pmdps) \ do { \ diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 8a392ef..62efcc5 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -135,6 +135,20 @@ #ifndef __ASSEMBLY__ +/* + * On LPAE, L_PTE_WRITE and L_PTE_DIRTY are in the upper 32-bits. + * Unfortunately, results from pte_write() and pte_dirty() are downcast + * to 32-bits by core code: + * o gather_stats + * o huge_pte_dirty + * o huge_pte_write + * o make_migration_entry + * + * Double logical invert to make sure lower 32-bits are set if true. + */ +#define pte_write(pte) (!!(pte_val(pte) & L_PTE_WRITE)) +#define pte_dirty(pte) (!!(pte_val(pte) & L_PTE_DIRTY)) + #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!(pud_val(pud) & 2)) #define pud_present(pud) (pud_val(pud)) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index 7a17611..e94a616 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -216,8 +216,6 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd) #define pte_none(pte) (!pte_val(pte)) #define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT) -#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE) -#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY) #define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG) #define pte_exec(pte) (!(pte_val(pte) & L_PTE_XN)) #define pte_special(pte) (0)