Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753185AbcCIKGO (ORCPT ); Wed, 9 Mar 2016 05:06:14 -0500 Received: from foss.arm.com ([217.140.101.70]:39075 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750853AbcCIKGJ (ORCPT ); Wed, 9 Mar 2016 05:06:09 -0500 Date: Wed, 9 Mar 2016 10:06:05 +0000 From: Catalin Marinas To: Ganapatrao Kulkarni Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Will.Deacon@arm.com, dann.frazier@canonical.com, gpkulkarni@gmail.com Subject: Re: [PATCH] arm64: Fix the ptep_set_wrprotect() to set PTE_DIRTY if (PTE_DBM && !PTE_RDONLY) Message-ID: <20160309100605.GJ6192@e104818-lin.cambridge.arm.com> References: <1457499768-31176-1-git-send-email-gkulkarni@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1457499768-31176-1-git-send-email-gkulkarni@caviumnetworks.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1459 Lines: 34 On Wed, Mar 09, 2016 at 10:32:48AM +0530, Ganapatrao Kulkarni wrote: > 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. > > ptep_set_wrprotect is setting PTR_DIRTY if !PTE_RDONLY, > however by design it suppose to set PTE_DIRTY > only if (PTE_DBM && !PTE_RDONLY). This patch addes code to > test and set accordingly. The reasoning behind the original code is that if !PTE_RDONLY, you have no way to tell whether the page was written or not since it is already writable, independent of the DBM. So by clearing the DBM bit (making the page read-only), we need to ensure that a potential dirty state is transferred to the software PTE_DIRTY bit. By checking PTE_DBM && !PTE_RDONLY, you kind of imply that you can have a page with !PTE_DBM && !PTE_RDONLY. Given that PTE_DBM is actually PTE_WRITE, PTE_RDONLY must always be set when !PTE_DBM. The bug may be elsewhere not setting these bits correctly. > This patch fixes BUG, > kernel BUG at /build/linux-StrpB2/linux-4.4.0/fs/ext4/inode.c:2394! > Internal error: Oops - BUG: 0 [#1] SMP Which bug is this? It's a PageWriteback() check in the for-next/core branch. What kernel version are you using? BTW, in 4.5-rc2 we pushed commit ac15bd63bbb2 ("arm64: Honour !PTE_WRITE in set_pte_at() for kernel mappings"), though not sure that's what you are hitting. -- Catalin