From patchwork Wed Nov 13 09:58:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 13873400 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 9AD7FD41C27 for ; Wed, 13 Nov 2024 10:06:30 +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=lZzx54cF7pnuo6ZEw1lvjMOyaGSasDPCjHCvYH/bwlU=; b=wDhvOGs7evKPDJ X2vqyuTxUI7ttVO+Qwafdbvry1lnlNoi4e+j0jJWlWeAn3nmlUzBwbHv4AwNpRzuLt1RhBpvG+IK2 YanvFHGYoDackjMbkV+69a2Y7XEpS8hWNKQCm15FuM9MZmlpB4VWCznSU3mBbQYyFrS7aImt39ZG8 cw+IqhrXMdzFW309wrqVwW1XzSM8neHl1DkRo75NXnIOAcm46rtPcXoPMs+G/M+p4Ybk8RrVcS27R 6ySb9Qzo3hlBSJxX8sViiIoFp+bqPOB5LXXx3SWfhXKyzhZ2isQHVO+5Ll6zkLKuQKiOhdA1QozgC wxtqW8wREaVlCtbi4eoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tBAGW-00000006N1I-3x7P; Wed, 13 Nov 2024 10:06:24 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tBAGL-00000006N0o-0pPe for linux-riscv@bombadil.infradead.org; Wed, 13 Nov 2024 10:06:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=Lx5jZHrhJ1Uatk9SK4awYXME5YT5I50K19xPpwKBjDc=; b=i04tZXJSeJLnXLDWPuO6GQzmbw rDM0diiRqhMUi6c6yb7ViogKBuz6UKZ7QXDVlOCDbdhtPVu51YePYgpnEbXG9zOuP4QTbj6JgxRM8 0QEIeYN05BggHVQ9TXp3I2nGEvn2VjEJ4gRM7bmy451LESE/symez5ETzJ2+/H5Rv/IwN7Znno0sa 7n2cPl+XpdBleLwLz0i0wLNKI5ZNvPkNsVnVL7w8rWt+UYXjuiE7egQwPp9rhrld9Zq+gR8Qy6Gyu X2gP8wZU6co0JkKCHmV3ttHnZth2l4ADMrSzP5+LZQNFZKp49posVlauPKYKA5xOvhA3elKaL0vkH 4piKH7rg==; Received: from smtp84.cstnet.cn ([159.226.251.84] helo=cstnet.cn) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tBAGG-0000000DErD-1was for linux-riscv@lists.infradead.org; Wed, 13 Nov 2024 10:06:11 +0000 Received: from ubt.. (unknown [210.73.53.31]) by APP-05 (Coremail) with SMTP id zQCowADHr7p4eDRnlmI4Ag--.57753S2; Wed, 13 Nov 2024 17:59:20 +0800 (CST) From: Chunyan Zhang To: Palmer Dabbelt , Albert Ou , Paul Walmsley , Alexandre Ghiti , Andrew Morton Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [PATCH V5 0/3] riscv: mm: Add soft-dirty and uffd-wp support Date: Wed, 13 Nov 2024 17:58:30 +0800 Message-Id: <20241113095833.1805746-1-zhangchunyan@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: zQCowADHr7p4eDRnlmI4Ag--.57753S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw17trWrtr4xKryUZF4UXFb_yoW8Aw4xpa 93Kwn8trW5Ar1xtrs3CrnF9r15W3Z3J3s8GrWft34ktws8JF4jvr9YkF1fJry8X3WY9r90 9F45Cry5u3yvyaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvFb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l c2xSY4AK67AK6r4fMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWU tVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAF wI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvj xUyZmRDUUUU X-Originating-IP: [210.73.53.31] X-CM-SenderInfo: x2kd0wxfkx051dq6x2xfdvhtffof0/1tbiDAYAB2c0cpIT4wAAsO X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241113_100609_074432_C372E2FD X-CRM114-Status: GOOD ( 10.11 ) 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.12-rc7. V5: - Fixed typos and corrected some words in Kconfig and commit message; - Removed pte_wrprotect() from pte_swp_mkuffd_wp(), this is a copy-paste error; - Added Alex's Reviewed-by tag in patch 2. 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(-)