Re: [PATCH 6/8] modules: switch to execmem API for remapping as RW and restoring ROX

2025-01-03 Thread Luis Chamberlain
On Fri, Jan 03, 2025 at 07:58:13AM +0100, Jürgen Groß wrote: > On 03.01.25 03:06, Andrew Cooper wrote: > > > Hi Mike, > > > > > > This commit is making my intel box not boot in mm-unstable :>) I bisected > > > it to > > > this commit. > > > > For what it's worth, we've found the same under Xen t

[PATCH v2 4/6] ARM: mm: Rename PGD helpers

2025-01-03 Thread Kevin Brodsky
Generic implementations of __pgd_alloc and __pgd_free are about to be introduced. Rename the macros in arch/arm/mm/pgd.c to avoid clashes. While we're at it, also pass down the mm as argument to those helpers, as it will be needed to call the generic __pgd_{alloc,free}. Acked-by: Dave Hansen Sign

[PATCH v2 6/6] mm: Introduce ctor/dtor at PGD level

2025-01-03 Thread Kevin Brodsky
Following on from the introduction of P4D-level ctor/dtor, let's finish the job and introduce ctor/dtor at PGD level. The incurred improvement in page accounting is minimal - the main motivation is to create a single, generic place where construction/destruction hooks can be added for all page tabl

[PATCH v2 5/6] asm-generic: pgalloc: Provide generic __pgd_{alloc,free}

2025-01-03 Thread Kevin Brodsky
We already have a generic implementation of alloc/free up to P4D level, as well as pgd_free(). Let's finish the work and add a generic PGD-level alloc helper as well. Unlike at lower levels, almost all architectures need some specific magic at PGD level (typically initialising PGD entries), so int

[PATCH v2 3/6] m68k: mm: Add calls to pagetable_pmd_[cd]tor

2025-01-03 Thread Kevin Brodsky
get_pointer_table() and free_pointer_table() already special-case TABLE_PTE to call pagetable_pte_[cd]tor. Let's do the same at PMD level to improve accounting further. TABLE_PGD and TABLE_PMD are currently defined to the same value, so we first need to separate them. That also implies separating p

[PATCH v2 2/6] parisc: mm: Ensure pagetable_pmd_[cd]tor are called

2025-01-03 Thread Kevin Brodsky
The implementation of pmd_{alloc_one,free} on parisc requires a non-zero allocation order, but is completely standard aside from that. Let's reuse the generic implementation of pmd_alloc_one(). Explicit zeroing is not needed as GFP_PGTABLE_KERNEL includes __GFP_ZERO. The generic pmd_free() can hand

[PATCH v2 1/6] mm: Move common part of pagetable_*_ctor to helper

2025-01-03 Thread Kevin Brodsky
pagetable_*_ctor all have the same basic implementation. Move the common part to a helper to reduce duplication. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- include/linux/mm.h | 28 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/include/l

[PATCH v2 0/6] Account page tables at all levels

2025-01-03 Thread Kevin Brodsky
v1: https://lore.kernel.org/linux-mm/20241219164425.2277022-1-kevin.brod...@arm.com/ This series should be considered in conjunction with Qi's series [1]. Together, they ensure that page table ctor/dtor are called at all levels (PTE to PGD) and all architectures, where page tables are regular pag

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-03 Thread Kevin Brodsky
On 03/01/2025 10:35, Qi Zheng wrote: > On 2025/1/3 17:13, Qi Zheng wrote: >> On 2025/1/3 16:02, Kevin Brodsky wrote: >>> On 03/01/2025 04:48, Qi Zheng wrote: [...] In __tlb_batch_free_encoded_pages(), we can indeed detect PageTable() and call pagetable_dtor() to dtor the page ta

Re: [PATCH 1/8] x86/mm/pat: cpa-test: fix length for CPA_ARRAY test

2025-01-03 Thread Peter Zijlstra
On Fri, Dec 27, 2024 at 09:28:18AM +0200, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > The CPA_ARRAY test always uses len[1] as numpages argument to > change_page_attr_set() although the addresses array is different each > iteration of the test loop. > > Replace len[1] with len[i

Re: [PATCH v3 15/17] mm: pgtable: remove tlb_remove_page_ptdesc()

2025-01-03 Thread Peter Zijlstra
On Sat, Dec 28, 2024 at 11:26:22AM +0200, Mike Rapoport wrote: > On Mon, Dec 23, 2024 at 05:41:01PM +0800, Qi Zheng wrote: > > Here we are explicitly dealing with struct page, and the following logic > > semms strange: > > > > tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); > > > > tlb_remove_

Re: [PATCH 6/8] modules: switch to execmem API for remapping as RW and restoring ROX

2025-01-03 Thread Marek Marczykowski-Górecki
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On Thu, Jan 02, 2025 at 09:57:14PM -0800, Andrew Morton wrote: > On Fri, 3 Jan 2025 02:06:10 + Andrew Cooper > wrote: > > > > Hi Mike, > > > > > > This commit is making my intel box not boot in mm-unstable :>) I bisected > > > it to > > > thi

Re: [PATCH 05/10] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one

2025-01-03 Thread Kevin Brodsky
+Qi On 03/01/2025 11:31, Alexandre Ghiti wrote: > Hi Kevin, > > On 19/12/2024 17:44, Kevin Brodsky wrote: >> {pmd,pud,p4d}_alloc_one() is never called if the corresponding page >> table level is folded, as {pmd,pud,p4d}_alloc() already does the >> required check. We can therefore remove the runtim

Re: [PATCH 05/10] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one

2025-01-03 Thread Alexandre Ghiti
Hi Kevin, On 19/12/2024 17:44, Kevin Brodsky wrote: {pmd,pud,p4d}_alloc_one() is never called if the corresponding page table level is folded, as {pmd,pud,p4d}_alloc() already does the required check. We can therefore remove the runtime page table level checks in {pud,p4d}_alloc_one. The PUD hel

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-03 Thread Qi Zheng
On 2025/1/3 17:13, Qi Zheng wrote: On 2025/1/3 16:02, Kevin Brodsky wrote: On 03/01/2025 04:48, Qi Zheng wrote: Hi Kevin, On 2025/1/3 00:53, Kevin Brodsky wrote: On 30/12/2024 10:07, Qi Zheng wrote:    static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb, void *pt)    { -  

Re: [PATCH 00/10] Account page tables at all levels

2025-01-03 Thread Kevin Brodsky
On 20/12/2024 20:31, Dave Hansen wrote: > On 12/20/24 02:58, Kevin Brodsky wrote: >>> One super tiny nit is that the PAE pgd _can_ be allocated using >>> __get_free_pages(). It was originally there for Xen, but I think it's >>> being used for PTI only at this point and the comments are wrong-ish. >

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-03 Thread Qi Zheng
On 2025/1/3 16:02, Kevin Brodsky wrote: On 03/01/2025 04:48, Qi Zheng wrote: Hi Kevin, On 2025/1/3 00:53, Kevin Brodsky wrote: On 30/12/2024 10:07, Qi Zheng wrote:   static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb, void *pt)   { -    if (riscv_use_sbi_for_rfence()) +   

Re: [PATCH v4 10/15] riscv: pgtable: move pagetable_dtor() to __tlb_remove_table()

2025-01-03 Thread Kevin Brodsky
On 03/01/2025 04:48, Qi Zheng wrote: > Hi Kevin, > > On 2025/1/3 00:53, Kevin Brodsky wrote: >> On 30/12/2024 10:07, Qi Zheng wrote: >>>   static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb, >>> void *pt) >>>   { >>> -    if (riscv_use_sbi_for_rfence()) >>> +    if (riscv_use_sbi_for