From patchwork Fri Aug 30 01:10:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 13784092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C483DCA0ECE for ; Fri, 30 Aug 2024 01:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=T6kZ47WdlcHlsvbfGYlfKfcLjBbti8KJWZR+aQKbtLE=; b=OjLR7uzMEQv8y5 9dh9FCu0n3aHV26Rjajtt+SrC1CmE2yTVl6CNcHOHB0LE4Ayy6CC9HW47dWyhXOw837WrjAgYeV7/ FgiYXWgbQC92soSTgP4SLHNd+wAsHvbiASl8/v2REkcsOUQALlWH05E7az2VRaBvV6YOx0L9KbyRR 5241nhCyMKcN4lVfhTkRcqCEl5z0BhRZip8pChtNHTYMcU5q+cauVdmASqBknEQYOqGuz8VjGYZ3U 39qHei/hj8p+amGvv+s6K7nwI5Z+ewd1T5kQGh5V//eWJ0njqVC0GYmQHNN8etx71XC8dSi7mzt9R +Oj6K57CdjFvdhNTYG2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjqGw-00000004GWM-0eu6; Fri, 30 Aug 2024 01:17:54 +0000 Received: from smtp21.cstnet.cn ([159.226.251.21] helo=cstnet.cn) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjqGr-00000004GUE-1IxW for linux-riscv@lists.infradead.org; Fri, 30 Aug 2024 01:17:51 +0000 Received: from ubt.. (unknown [210.73.53.31]) by APP-01 (Coremail) with SMTP id qwCowAC3vUmsHdFmIwaXCw--.62105S2; Fri, 30 Aug 2024 09:17:33 +0800 (CST) From: Chunyan Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , Alexandre Ghiti Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [RESEND PATCH V4 0/3] riscv: mm: Add soft-dirty and uffd-wp support Date: Fri, 30 Aug 2024 09:10:58 +0800 Message-Id: <20240830011101.3189522-1-zhangchunyan@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: qwCowAC3vUmsHdFmIwaXCw--.62105S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw17trWrtr4xKryUZF4UXFb_yoW8Wrykpa 93Gwn8tryYkr1xtrs3Cr1DKr15Wa1ft3s8Cryft34vyw45JF4jvrnYkF1fJw18Xa429r90 kF15CrW3u3ykZaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvYb7Iv0xC_tr1lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4 A2jsIEc7CjxVAFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l c2xSY4AK67AK6w4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxV Aqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q 6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6x kF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AK xVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07 jetCwUUUUU= X-Originating-IP: [210.73.53.31] X-CM-SenderInfo: x2kd0wxfkx051dq6x2xfdvhtffof0/1tbiBwoCB2bNLFyRwAACsA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_181749_741795_0D0755A2 X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This patchset adds soft dirty and userfaultfd write protect tracking support for RISC-V. As described in the patches, we are trying to utilize only one free PTE bit(9) to support three kernel features (devmap, soft-dirty, uffd-wp). Users cannot have them supported at the same time (have to select one when building the kernel). This patchset has been tested with: 1) The kselftest mm suite in which soft-dirty, madv_populate, test_unmerge_uffd_wp, and uffd-unit-tests run and pass, and no regressions are observed in any of the other tests. 2) CRIU: - 'criu check --feature mem_dirty_track' returns supported; - incremental_dumps[1] and simple_loop [2] dump and restores work fine; - zdtm test suite can run under host mode. This patchset applies on top of v6.11-rc1. V4: - Added bit(4) descriptions into "Format of swap PTE". V3: - Fixed the issue reported by kernel test irobot . V1 -> V2: - Add uffd-wp supported; - Make soft-dirty uffd-wp and devmap mutually exclusive which all use the same PTE bit; - Add test results of CRIU in the cover-letter. [1] https://www.criu.org/Incremental_dumps [2] https://asciinema.org/a/232445 Chunyan Zhang (3): riscv: mm: Prepare for reusing PTE RSW bit(9) riscv: mm: Add soft-dirty page tracking support riscv: mm: Add uffd write-protect support arch/riscv/Kconfig | 34 ++++++- arch/riscv/include/asm/pgtable-64.h | 2 +- arch/riscv/include/asm/pgtable-bits.h | 31 ++++++ arch/riscv/include/asm/pgtable.h | 133 +++++++++++++++++++++++++- 4 files changed, 197 insertions(+), 3 deletions(-)