Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp810405rwd; Thu, 18 May 2023 04:25:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Tw+7SuorQpWOs/ECxpgnyScWoRJMV5vPTbvQzzivkIA7EZiE0DKodMpXciEBuFYH7D7QE X-Received: by 2002:a05:6a00:2e1a:b0:647:4dee:62a4 with SMTP id fc26-20020a056a002e1a00b006474dee62a4mr4358687pfb.34.1684409100286; Thu, 18 May 2023 04:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684409100; cv=none; d=google.com; s=arc-20160816; b=ZIHkKWABNWpX7Jp2r2Y1NEdt0LH8wo4DYQBVXoxYnFo8++KLEaiHhC7LbISbsuhaYL YgX/U0Itji6ibWjDJlzirPRBAmxekOUCiZQOEdaww3t9bhDPgOKasWGxGQncnlB9QjM1 I6smc1guSIApCWQE5GhV09Ck59wN6d8E80b/70y9pCj79H1Jbp9HD0tpPyJRbHtlMyZP CAkpnDJhVh24s8y28tWuqu/QscFYCl/ibwOzfwZ8rWI+YlpcDUpBpXxc3C+Wko2h/W1f vEMEN75qqMVo5X7N0229v/hHdPbbXb6wtrt4RLFWqfAp+x188v0Se8B28wfxAVmXw8Qz W/xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nM1RfkieUUw/+R1a5EL0kfVtnQnHLyPCkHqfiwjArQI=; b=bizqrTOFnePlKk6ERxKhvk5EmTvEADiKJPq1Qb7iggDhSANqyHKon6mlzT2etczFTP jT2+2WveAA1vN0M9cJqdypzC8EUvwczP+Pj+qJgoeIou4jc0LSlfRbizGDggAo9bNV9K s8tHGYPvDiG3DqOEM5AboeCu3E7X85HXuXzxMfZigS3St+Ug9ZsSBuR0f2VlYDCBW3Bm Pbxz2K4aEs4hKDjdR0g8x2mDI0Sg1sRJdp/xupi+oZ9pNN/4UpQ5A5Uh5Wii9Gplovg3 DlK8kpm1GUUaTFsDuNvd9iUXnEHiOwgVTgBGN5a2RL9L24JMaFkhaXIlY8Ut4tB0Af1K 3PhQ== 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 w188-20020a6230c5000000b00643b4daa91asi1321701pfw.369.2023.05.18.04.24.47; Thu, 18 May 2023 04:25:00 -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 S230367AbjERLHk (ORCPT + 99 others); Thu, 18 May 2023 07:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjERLHj (ORCPT ); Thu, 18 May 2023 07:07:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6CF5AB8 for ; Thu, 18 May 2023 04:07:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBDF81FB; Thu, 18 May 2023 04:08:22 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 91E4D3F793; Thu, 18 May 2023 04:07:36 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , SeongJae Park , Christoph Hellwig Cc: Ryan Roberts , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Lorenzo Stoakes , Uladzislau Rezki , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [PATCH v2 0/5] Encapsulate PTE contents from non-arch code Date: Thu, 18 May 2023 12:07:22 +0100 Message-Id: <20230518110727.2106156-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 Hi All, This is v2 of a series to improve the encapsulation of pte entries by disallowing non-arch code from directly dereferencing pte_t pointers. Instead code must use a new helper, `pte_t ptep_deref(pte_t *ptep)`. See the v1 cover letter at [1] for rationale and explanation of approach. As with v1, the series is split up as follows: patchs 1-2: Fix bugs where code was _setting_ ptes directly, rather than using set_pte_at() and friends. patch 3: Fix highmem unmapping issue I spotted while doing the work. patch 4: Introduce the new ptep_deref() helper with default implementation. patch 5: Convert all direct dereferences to use ptep_deref(). Patches are based on v6.4-rc2 and a branch is available at [2]. Changes since v1: - patch 5: Fixed sh build bug reported by 0-day CI - patch 1: Refactored pfn to use local variable - patch 1-2: Minor rewording of commit message: 'verify' -> 'check' - patch 1-3: applied Ack/Reviewed-by tags; thanks for those! [1] https://lore.kernel.org/linux-mm/20230511132113.80196-1-ryan.roberts@arm.com/ [2] https://gitlab.arm.com/linux-arm/linux-rr/-/tree/features/granule_perf/ptep_deref-lkml_v2 Thanks, Ryan Ryan Roberts (5): mm: vmalloc must set pte via arch code mm: damon must atomically clear young on ptes and pmds mm: Fix failure to unmap pte on highmem systems mm: Add new ptep_deref() helper to fully encapsulate pte_t mm: ptep_deref() conversion .../drm/i915/gem/selftests/i915_gem_mman.c | 8 +- drivers/misc/sgi-gru/grufault.c | 2 +- drivers/vfio/vfio_iommu_type1.c | 7 +- drivers/xen/privcmd.c | 2 +- fs/proc/task_mmu.c | 33 +++--- fs/userfaultfd.c | 6 +- include/linux/hugetlb.h | 4 + include/linux/mm_inline.h | 2 +- include/linux/pgtable.h | 13 ++- kernel/events/uprobes.c | 2 +- mm/damon/ops-common.c | 18 ++- mm/damon/ops-common.h | 4 +- mm/damon/paddr.c | 6 +- mm/damon/vaddr.c | 14 ++- mm/filemap.c | 2 +- mm/gup.c | 21 ++-- mm/highmem.c | 12 +- mm/hmm.c | 2 +- mm/huge_memory.c | 4 +- mm/hugetlb.c | 2 +- mm/hugetlb_vmemmap.c | 6 +- mm/kasan/init.c | 9 +- mm/kasan/shadow.c | 10 +- mm/khugepaged.c | 24 ++-- mm/ksm.c | 22 ++-- mm/madvise.c | 6 +- mm/mapping_dirty_helpers.c | 4 +- mm/memcontrol.c | 4 +- mm/memory-failure.c | 6 +- mm/memory.c | 105 +++++++++--------- mm/mempolicy.c | 6 +- mm/migrate.c | 14 ++- mm/migrate_device.c | 14 ++- mm/mincore.c | 2 +- mm/mlock.c | 6 +- mm/mprotect.c | 8 +- mm/mremap.c | 2 +- mm/page_table_check.c | 4 +- mm/page_vma_mapped.c | 26 +++-- mm/pgtable-generic.c | 2 +- mm/rmap.c | 32 +++--- mm/sparse-vmemmap.c | 8 +- mm/swap_state.c | 4 +- mm/swapfile.c | 16 +-- mm/userfaultfd.c | 4 +- mm/vmalloc.c | 16 ++- mm/vmscan.c | 14 ++- virt/kvm/kvm_main.c | 9 +- 48 files changed, 310 insertions(+), 237 deletions(-) -- 2.25.1