From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF727C5DF60 for ; Tue, 5 Nov 2019 16:54:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC90521928 for ; Tue, 5 Nov 2019 16:54:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YzDKrEF2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC90521928 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hUTn/B9bXnY+inxG5qTf1podH+jK4NHqnamPbaTbUmk=; b=YzDKrEF2HuBvSq bpb6/ECDB+98Y9gV8VB6Mq+IDV6gpi52BacB3z0ncUxA5gklZlLVcLh76l5rl79MZvMeQYnZN/vEU ajEk5s2anOdF/LdGlen3yhzOmJzj/Wda4sEMkFOivLqqjQ+q2KcKdMwFcEQuxYSyveKS7nDs0Kg5p hFjRaRELvy5GbmroUMfVNz+NSgre4Qv9YZAXFdgX/dQjEwXH19O/4pvb1eG/jXDpDHOnlAQM+/Gzu vBgwo/qrpv8Fo/jSyalvp6GZa//JsG38oqij/EBDUKc0Lo48lbpYoPS7gD+djQTPkPVZofyucPjGi QqP2x8dOo9pUshY/gn9g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iS26O-0003CK-4r; Tue, 05 Nov 2019 16:54:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iS26L-0002xg-0d for linux-arm-kernel@lists.infradead.org; Tue, 05 Nov 2019 16:54:42 +0000 Received: from arrakis.emea.arm.com (unknown [46.69.195.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B280921928; Tue, 5 Nov 2019 16:54:36 +0000 (UTC) Date: Tue, 5 Nov 2019 16:54:33 +0000 From: Catalin Marinas To: Will Deacon Subject: Re: [PATCH] arm64: Ensure VM_WRITE|VM_SHARED ptes are clean by default Message-ID: <20191105165433.GD22987@arrakis.emea.arm.com> References: <20191029153051.24367-1-catalin.marinas@arm.com> <20191105102902.GB29852@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191105102902.GB29852@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191105_085441_081510_B90BB192 X-CRM114-Status: GOOD ( 18.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Delva , Sandeep Patil , Steve Capper , stable , John Stultz , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 05, 2019 at 10:29:03AM +0000, Will Deacon wrote: > On Mon, Nov 04, 2019 at 05:16:42PM -0800, John Stultz wrote: > > On Tue, Oct 29, 2019 at 8:31 AM Catalin Marinas wrote: > > > > > > Shared and writable mappings (__S.1.) should be clean (!dirty) initially > > > and made dirty on a subsequent write either through the hardware DBM > > > (dirty bit management) mechanism or through a write page fault. A clean > > > pte for the arm64 kernel is one that has PTE_RDONLY set and PTE_DIRTY > > > clear. > > > > > > The PAGE_SHARED{,_EXEC} attributes have PTE_WRITE set (PTE_DBM) and > > > PTE_DIRTY clear. Prior to commit 73e86cb03cf2 ("arm64: Move PTE_RDONLY > > > bit handling out of set_pte_at()"), it was the responsibility of > > > set_pte_at() to set the PTE_RDONLY bit and mark the pte clean if the > > > software PTE_DIRTY bit was not set. However, the above commit removed > > > the pte_sw_dirty() check and the subsequent setting of PTE_RDONLY in > > > set_pte_at() while leaving the PAGE_SHARED{,_EXEC} definitions > > > unchanged. The result is that shared+writable mappings are now dirty by > > > default > > > > > > Fix the above by explicitly setting PTE_RDONLY in PAGE_SHARED{,_EXEC}. > > > In addition, remove the superfluous PTE_DIRTY bit from the kernel PROT_* > > > attributes. > > > > > > Fixes: 73e86cb03cf2 ("arm64: Move PTE_RDONLY bit handling out of set_pte_at()") > > > Cc: # 4.14.x- > > > Cc: Will Deacon > > > Signed-off-by: Catalin Marinas [...] > As an experiment, can you try reverting just the part of the patch that > removes PTE_DIRTY from the PROT_* definitions? (see below) Another thing worth trying is reverting commit 747a70e60b72 ("arm64: Fix copy-on-write referencing in HugeTLB") when this patch is applied. That commit is not just about hugetlb but changes pte_same() to ignore PTE_RDONLY on the assumption that this is set by set_pte_at(). We subsequently changed set_pte_at() to drop PTE_RDONLY. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel