|
|
Log in / Subscribe / Register

riscv: Use READ_ONCE()/WRITE_ONCE() for pte accesses

From:  Alexandre Ghiti <alexghiti-AT-rivosinc.com>
To:  Ryan Roberts <ryan.roberts-AT-arm.com>, Alexander Potapenko <glider-AT-google.com>, Marco Elver <elver-AT-google.com>, Dmitry Vyukov <dvyukov-AT-google.com>, Paul Walmsley <paul.walmsley-AT-sifive.com>, Palmer Dabbelt <palmer-AT-dabbelt.com>, Albert Ou <aou-AT-eecs.berkeley.edu>, Anup Patel <anup-AT-brainfault.org>, Atish Patra <atishp-AT-atishpatra.org>, Ard Biesheuvel <ardb-AT-kernel.org>, Andrey Ryabinin <ryabinin.a.a-AT-gmail.com>, Andrey Konovalov <andreyknvl-AT-gmail.com>, Vincenzo Frascino <vincenzo.frascino-AT-arm.com>, kasan-dev-AT-googlegroups.com, linux-riscv-AT-lists.infradead.org, linux-kernel-AT-vger.kernel.org, kvm-AT-vger.kernel.org, kvm-riscv-AT-lists.infradead.org, linux-efi-AT-vger.kernel.org, linux-mm-AT-kvack.org
Subject:  [PATCH 0/5] riscv: Use READ_ONCE()/WRITE_ONCE() for pte accesses
Date:  Mon, 02 Oct 2023 17:10:26 +0200
Message-ID:  <20231002151031.110551-1-alexghiti@rivosinc.com>
Cc:  Alexandre Ghiti <alexghiti-AT-rivosinc.com>
Archive-link:  Article

This series is a follow-up for riscv of a recent series from Ryan [1] which
converts all direct dereferences of pte_t into a ptet_get() access.

The goal here for riscv is to use READ_ONCE()/WRITE_ONCE() for all page
table entries accesses to avoid any compiler transformation when the
hardware can concurrently modify the page tables entries (A/D bits for
example).

I went a bit further and added pud/p4d/pgd_get() helpers as such concurrent
modifications can happen too at those levels.

[1] https://lore.kernel.org/all/20230612151545.3317766-1-ryan...

Alexandre Ghiti (5):
  riscv: Use WRITE_ONCE() when setting page table entries
  mm: Introduce pudp/p4dp/pgdp_get() functions
  riscv: mm: Only compile pgtable.c if MMU
  riscv: Suffix all page table entry pointers with 'p'
  riscv: Use accessors to page table entries instead of direct
    dereference

 arch/riscv/include/asm/kfence.h     |   6 +-
 arch/riscv/include/asm/kvm_host.h   |   2 +-
 arch/riscv/include/asm/pgalloc.h    |  86 ++++++++++----------
 arch/riscv/include/asm/pgtable-64.h |  26 +++---
 arch/riscv/include/asm/pgtable.h    |  33 ++------
 arch/riscv/kernel/efi.c             |   2 +-
 arch/riscv/kvm/mmu.c                |  44 +++++-----
 arch/riscv/mm/Makefile              |   3 +-
 arch/riscv/mm/fault.c               |  38 ++++-----
 arch/riscv/mm/hugetlbpage.c         |  80 +++++++++----------
 arch/riscv/mm/init.c                |  30 +++----
 arch/riscv/mm/kasan_init.c          | 119 ++++++++++++++--------------
 arch/riscv/mm/pageattr.c            |  74 +++++++++--------
 arch/riscv/mm/pgtable.c             |  71 +++++++++++------
 include/linux/pgtable.h             |  21 +++++
 15 files changed, 334 insertions(+), 301 deletions(-)

-- 
2.39.2



Copyright © 2023, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds