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: 3653161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC0E3BF13A for ; Fri, 14 Feb 2014 16:57:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D73AB201DE for ; Fri, 14 Feb 2014 16:57:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D621F201C7 for ; Fri, 14 Feb 2014 16:57:41 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WEM3o-0003x2-NO; Fri, 14 Feb 2014 16:56:21 +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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bsnq3DLkNWwqK+gKi/35l/gBl5M7O6Rw75sA/j8FCAw=; b=Ded25L3m4L4oiazc6u7I+unZ35flyPVWjU89n/oYhhRb8r5EvbbegUQEV/UoUmuLmi IABsCEbBK8LuQec9C5aHjPBGcqsoTNB4B1rIib4ugRmr2siXA4E0snd1oX0JTQwKzRa9 BCRYjb3z42/1WNOt91YcsTQjBHB0D5QckaFfz4oaJQN9G9rYKQcsrhPD1pG9EcMlloHS aDESYpnlfKKudgxWimhIkk2NwTb0nkF3SNNEdc1rX08V/ZZfn9SXWXA+/LjsBDoJdHpZ qtCG0na8gAqNRflZREvBVA2IifjiF43DGLBFJzSM3bhNP+Om5PjRbjmLR4Yn4TfF4QjV mjLQ== X-Gm-Message-State: ALoCoQkUu97GFxWuXQPvxGkDLHpFl7Y1KrSkdV+tKBwN4A9Qcf1fZHaXKPiL5A/RritCa/80i5VF 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 (--) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)