From patchwork Fri Sep 11 17:22:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 53494 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id C11C1215BF for ; Fri, 11 Sep 2015 17:23:51 +0000 (UTC) Received: by lagj9 with SMTP id j9sf30223427lag.0 for ; Fri, 11 Sep 2015 10:23:50 -0700 (PDT) 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:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=DcdgcKVuu32acPT732itlzthksJT9ZHFlYIuVII9j4A=; b=XYoPiJH8np30P9j9o9ZLfud7e2Hkt9W7rdP5vRYkHCs+fNQoNsKmTb5KChsReFrM7P lnMmhnIicbhjcSDnabrj4vcbhv1Br8v7B0WFRgD4zUOe/ovNdEYk/+GPu70yRC8T4yGS k92sFt/ohe4hjPqGb9vXyo/NcBzK6KJ++rT0CRGkvvJghX6xBMqxveWy0oZv1IOrMLf+ 67R27e4w05chCss45VGiiPMWN2oUnqvFj3PNitn8aGEcAJAggNhxSkkTi6HaOxdmNGi1 WBBZpW8lJe7h9HRhRIso1950yW4+LLHunWv5Yztxz3xKZnJzpCw5z7+y4bf0y5CPR6jx 7cHQ== X-Gm-Message-State: ALoCoQlsHLy0m3jroQPNJDa+N35Ab5QkwzB3E50IY8EWUetJEG2nB9qWYIa3dy0mZ+d+68XMpqAX X-Received: by 10.112.26.212 with SMTP id n20mr404669lbg.2.1441992230825; Fri, 11 Sep 2015 10:23:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.130 with SMTP id e2ls398555lam.40.gmail; Fri, 11 Sep 2015 10:23:50 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr43137596lac.73.1441992230678; Fri, 11 Sep 2015 10:23:50 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id jb6si843849lbc.40.2015.09.11.10.23.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 10:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbmp1 with SMTP id mp1so43253889lbb.1 for ; Fri, 11 Sep 2015 10:23:50 -0700 (PDT) X-Received: by 10.112.168.100 with SMTP id zv4mr42724933lbb.117.1441992230519; Fri, 11 Sep 2015 10:23:50 -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.59.35 with SMTP id w3csp1741548lbq; Fri, 11 Sep 2015 10:23:49 -0700 (PDT) X-Received: by 10.107.9.212 with SMTP id 81mr5535584ioj.191.1441992229378; Fri, 11 Sep 2015 10:23:49 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e18si1227143ioe.97.2015.09.11.10.23.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 10:23:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZaS24-0004dn-BD; Fri, 11 Sep 2015 17:22:40 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZaS1u-0004HX-Sg for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2015 17:22:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33EBD317; Fri, 11 Sep 2015 10:22:22 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4425C3F21A; Fri, 11 Sep 2015 10:22:09 -0700 (PDT) From: Catalin Marinas To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] arm64: Fix the pte_hw_dirty() check when AF/DBM is enabled Date: Fri, 11 Sep 2015 18:22:00 +0100 Message-Id: <1441992122-19888-2-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441992122-19888-1-git-send-email-catalin.marinas@arm.com> References: <1441992122-19888-1-git-send-email-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150911_102230_931883_3DB07680 X-CRM114-Status: GOOD ( 10.33 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Julien Grall , Will Deacon 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: catalin.marinas@arm.com 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.174 as permitted sender) smtp.mailfrom=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 Commit 2f4b829c625e (arm64: Add support for hardware updates of the access and dirty pte bits) introduced support for handling hardware updates of the access flag and dirty status. The PTE is automatically dirtied in hardware (if supported) by clearing the PTE_RDONLY bit when the PTE_DBM/PTE_WRITE bit is set. The pte_hw_dirty() macro was added to detect a hardware dirtied pte. The pte_dirty() macro checks for both software PTE_DIRTY and pte_hw_dirty(). Functions like pte_modify() clear the PTE_RDONLY bit since it is meant to be set in set_pte_at() when written to memory. In such cases, pte_hw_dirty() would return true even though such pte is clean. This patch changes pte_hw_dirty() to test the PTE_DBM/PTE_WRITE bit together with PTE_RDONLY. Signed-off-by: Catalin Marinas Reported-by: Julien Grall Cc: Will Deacon Fixes: 2f4b829c625e ("arm64: Add support for hardware updates of the access and dirty pte bits") --- arch/arm64/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 6900b2d95371..69207f016891 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -146,7 +146,7 @@ extern struct page *empty_zero_page; #define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) #ifdef CONFIG_ARM64_HW_AFDBM -#define pte_hw_dirty(pte) (!(pte_val(pte) & PTE_RDONLY)) +#define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY)) #else #define pte_hw_dirty(pte) (0) #endif @@ -238,7 +238,7 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr); * When hardware DBM is not present, the sofware PTE_DIRTY bit is updated via * the page fault mechanism. Checking the dirty status of a pte becomes: * - * PTE_DIRTY || !PTE_RDONLY + * PTE_DIRTY || (PTE_WRITE && !PTE_RDONLY) */ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)