Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp4675595rwp; Sun, 16 Jul 2023 08:16:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlGsbPumM2IsdIylLLSlQyhPRiczNYvTVL9aa6pS8NDCESpuqPz1Jmlj94owNWp+9iXM4luT X-Received: by 2002:a17:906:7c44:b0:969:93f2:259a with SMTP id g4-20020a1709067c4400b0096993f2259amr8759927ejp.73.1689520618522; Sun, 16 Jul 2023 08:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689520618; cv=none; d=google.com; s=arc-20160816; b=LnsdLpsRty5adds8IXLcsnC8X0irVZghaieiBIldXoDL0argTT0gT6BUVp9JUqANUh utcIkbeQLhB3iEzo96wBkc5MsCvO5mCVHL1C/CgABVbpSwmeJbsyF+JQcWxaCjWL4C6P Z2hFYP6yB75NtsVZY8kPK7Lb5O+RSB7/6L2tgHiMhENWsfbrbobAA/JV3pXZlhlRoXiY BHymyo1Ll8T1B02wKjRgTD+fKwCy1i3MSR5G5KzAojM0wXEXdmZqPHblxY/+JTeZ73kb F1Nm9NTs8VJQab2St30fBg/JEM1YHl+1+4JoibXCY9I5GAy4ZKQvzjaBMkQ78qG2y8GJ uqvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=skA/loKK2gRCeJ5B7+5KJirPHJhBw6iBvdE6OTPfZWY=; fh=JYAMAze/0O1scVLykOcHNef6iXmJ5nPL8z2a5D7yTEQ=; b=mVcofR74XgRW+bqs/N2iXiC/xRV4QIvxJurS1TXuo8l0HCU639xyUTDthqG2NQ1d4s bmTxn9I8RDRUUQGOxpMhrfgqza5E2g4qcJbInRI3C0RsrafM1jb46fIisxQEOuXJFm0g gYHyJ3PeuETecWWT5PkoKDTp+C7rNyEJ8H7Mda1AxDvTw+XWdKQp0idbdyYyEmFzlNTM K4s+lBfcaqCIJ5M7g3gjJUYCmWojp3JQWumdmg4JJ+eCKSuBuGI3NzUM+fZktofmcwl3 s5OAG7qsyD4Ox8Xbf+Ro5139uu30o/jKrHoZldXZoyg/1VeB3DnWBcIOpe6c2HhrUcpV 0RwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck8-20020a170906c44800b0098f99048058si4179139ejb.1015.2023.07.16.08.16.30; Sun, 16 Jul 2023 08:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjGPPKi (ORCPT + 99 others); Sun, 16 Jul 2023 11:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjGPPKh (ORCPT ); Sun, 16 Jul 2023 11:10:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E35171B7 for ; Sun, 16 Jul 2023 08:10:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8251860D2B for ; Sun, 16 Jul 2023 15:10:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76752C433C7; Sun, 16 Jul 2023 15:10:35 +0000 (UTC) Date: Sun, 16 Jul 2023 08:10:33 -0700 From: Catalin Marinas To: Nico Pache Cc: Anshuman Khandual , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, aquini@redhat.com, Andrew Morton , David Hildenbrand , Gerald Schaefer , Liu Shixin , Will Deacon , Yu Zhao Subject: Re: [RFC] arm64: properly define SOFT_DIRTY for arm64 Message-ID: References: <20230703135526.930004-1-npache@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (I noticed Mark already replied in another thread along the same lines) On Tue, Jul 04, 2023 at 06:08:59AM -0400, Nico Pache wrote: > Is it possible to add the same DBM check I'm using > (!arch_has_hw_pte_young) in these pte helper functions to only clear > it when DBM is not present? It's not possible since we don't have a way to encode a read-only + dirty PTE (e.g. after ptep_set_wrprotect()). The PTE_WRITE/PTE_DBM bit in the architecture only tells that the hardware is allowed to clear the PTE_RDONLY bit on a write access and that's what we consider hw-dirty. When a dirty/writeable PTE is made read-only, we clear PTE_WRITE, set PTE_RDONLY _and_ the software PTE_DIRTY bit. With the permission indirection extensions (PIE, see patches from Joey), PTE_RDONLY can be treated as a true !PTE_DIRTY bit but there's no hardware around yet. So if you need software dirty, it can only be done with another software PTE bit. The problem is that we are short of such bits (only one left if we move PTE_PROT_NONE to a different location). The userfaultfd people also want such bit. Personally I'd reuse the four PBHA bits but I keep hearing that they may be used with some out of tree patches. -- Catalin