Skip to content

Commit 403d133

Browse files
linmag7torvalds
authored andcommitted
mm: pgtable: fix pte_swp_exclusive
Make pte_swp_exclusive return bool instead of int. This will better reflect how pte_swp_exclusive is actually used in the code. This fixes swap/swapoff problems on Alpha due pte_swp_exclusive not returning correct values when _PAGE_SWP_EXCLUSIVE bit resides in upper 32-bits of PTE (like on alpha). Suggested-by: Al Viro <[email protected]> Signed-off-by: Magnus Lindholm <[email protected]> Cc: Sam James <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/lkml/20250602041118.GA2675383@ZenIV/ [ Applied as the 'sed' script Al suggested - Linus ] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 488ef35 commit 403d133

File tree

26 files changed

+27
-27
lines changed

26 files changed

+27
-27
lines changed

arch/alpha/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
327327
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
328328
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
329329

330-
static inline int pte_swp_exclusive(pte_t pte)
330+
static inline bool pte_swp_exclusive(pte_t pte)
331331
{
332332
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
333333
}

arch/arc/include/asm/pgtable-bits-arcv2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
130130
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
131131
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
132132

133-
static inline int pte_swp_exclusive(pte_t pte)
133+
static inline bool pte_swp_exclusive(pte_t pte)
134134
{
135135
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
136136
}

arch/arm/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
301301
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
302302
#define __swp_entry_to_pte(swp) __pte((swp).val)
303303

304-
static inline int pte_swp_exclusive(pte_t pte)
304+
static inline bool pte_swp_exclusive(pte_t pte)
305305
{
306306
return pte_isset(pte, L_PTE_SWP_EXCLUSIVE);
307307
}

arch/arm64/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ static inline pte_t pte_swp_mkexclusive(pte_t pte)
563563
return set_pte_bit(pte, __pgprot(PTE_SWP_EXCLUSIVE));
564564
}
565565

566-
static inline int pte_swp_exclusive(pte_t pte)
566+
static inline bool pte_swp_exclusive(pte_t pte)
567567
{
568568
return pte_val(pte) & PTE_SWP_EXCLUSIVE;
569569
}

arch/csky/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static inline pte_t pte_mkyoung(pte_t pte)
200200
return pte;
201201
}
202202

203-
static inline int pte_swp_exclusive(pte_t pte)
203+
static inline bool pte_swp_exclusive(pte_t pte)
204204
{
205205
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
206206
}

arch/hexagon/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
387387
(((type & 0x1f) << 1) | \
388388
((offset & 0x3ffff8) << 10) | ((offset & 0x7) << 7)) })
389389

390-
static inline int pte_swp_exclusive(pte_t pte)
390+
static inline bool pte_swp_exclusive(pte_t pte)
391391
{
392392
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
393393
}

arch/loongarch/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
301301
#define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val(pmd) })
302302
#define __swp_entry_to_pmd(x) ((pmd_t) { (x).val | _PAGE_HUGE })
303303

304-
static inline int pte_swp_exclusive(pte_t pte)
304+
static inline bool pte_swp_exclusive(pte_t pte)
305305
{
306306
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
307307
}

arch/m68k/include/asm/mcf_pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
268268
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
269269
#define __swp_entry_to_pte(x) (__pte((x).val))
270270

271-
static inline int pte_swp_exclusive(pte_t pte)
271+
static inline bool pte_swp_exclusive(pte_t pte)
272272
{
273273
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
274274
}

arch/m68k/include/asm/motorola_pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ extern pgd_t kernel_pg_dir[128];
185185
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
186186
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
187187

188-
static inline int pte_swp_exclusive(pte_t pte)
188+
static inline bool pte_swp_exclusive(pte_t pte)
189189
{
190190
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
191191
}

arch/m68k/include/asm/sun3_pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
169169
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
170170
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
171171

172-
static inline int pte_swp_exclusive(pte_t pte)
172+
static inline bool pte_swp_exclusive(pte_t pte)
173173
{
174174
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
175175
}

arch/microblaze/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
398398
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> 2 })
399399
#define __swp_entry_to_pte(x) ((pte_t) { (x).val << 2 })
400400

401-
static inline int pte_swp_exclusive(pte_t pte)
401+
static inline bool pte_swp_exclusive(pte_t pte)
402402
{
403403
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
404404
}

arch/mips/include/asm/pgtable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
534534
#endif
535535

536536
#if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
537-
static inline int pte_swp_exclusive(pte_t pte)
537+
static inline bool pte_swp_exclusive(pte_t pte)
538538
{
539539
return pte.pte_low & _PAGE_SWP_EXCLUSIVE;
540540
}
@@ -551,7 +551,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
551551
return pte;
552552
}
553553
#else
554-
static inline int pte_swp_exclusive(pte_t pte)
554+
static inline bool pte_swp_exclusive(pte_t pte)
555555
{
556556
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
557557
}

arch/nios2/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
259259
#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val })
260260
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
261261

262-
static inline int pte_swp_exclusive(pte_t pte)
262+
static inline bool pte_swp_exclusive(pte_t pte)
263263
{
264264
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
265265
}

arch/openrisc/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf,
411411
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
412412
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
413413

414-
static inline int pte_swp_exclusive(pte_t pte)
414+
static inline bool pte_swp_exclusive(pte_t pte)
415415
{
416416
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
417417
}

arch/parisc/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
425425
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
426426
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
427427

428-
static inline int pte_swp_exclusive(pte_t pte)
428+
static inline bool pte_swp_exclusive(pte_t pte)
429429
{
430430
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
431431
}

arch/powerpc/include/asm/book3s/32/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,
365365
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> 3 })
366366
#define __swp_entry_to_pte(x) ((pte_t) { (x).val << 3 })
367367

368-
static inline int pte_swp_exclusive(pte_t pte)
368+
static inline bool pte_swp_exclusive(pte_t pte)
369369
{
370370
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
371371
}

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static inline pte_t pte_swp_mkexclusive(pte_t pte)
693693
return __pte_raw(pte_raw(pte) | cpu_to_be64(_PAGE_SWP_EXCLUSIVE));
694694
}
695695

696-
static inline int pte_swp_exclusive(pte_t pte)
696+
static inline bool pte_swp_exclusive(pte_t pte)
697697
{
698698
return !!(pte_raw(pte) & cpu_to_be64(_PAGE_SWP_EXCLUSIVE));
699699
}

arch/powerpc/include/asm/nohash/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
286286
return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
287287
}
288288

289-
static inline int pte_swp_exclusive(pte_t pte)
289+
static inline bool pte_swp_exclusive(pte_t pte)
290290
{
291291
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
292292
}

arch/riscv/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ static inline pud_t pud_modify(pud_t pud, pgprot_t newprot)
10281028
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
10291029
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
10301030

1031-
static inline int pte_swp_exclusive(pte_t pte)
1031+
static inline bool pte_swp_exclusive(pte_t pte)
10321032
{
10331033
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
10341034
}

arch/s390/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static inline int pmd_protnone(pmd_t pmd)
915915
}
916916
#endif
917917

918-
static inline int pte_swp_exclusive(pte_t pte)
918+
static inline bool pte_swp_exclusive(pte_t pte)
919919
{
920920
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
921921
}

arch/sh/include/asm/pgtable_32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
470470
/* In both cases, we borrow bit 6 to store the exclusive marker in swap PTEs. */
471471
#define _PAGE_SWP_EXCLUSIVE _PAGE_USER
472472

473-
static inline int pte_swp_exclusive(pte_t pte)
473+
static inline bool pte_swp_exclusive(pte_t pte)
474474
{
475475
return pte.pte_low & _PAGE_SWP_EXCLUSIVE;
476476
}

arch/sparc/include/asm/pgtable_32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static inline swp_entry_t __swp_entry(unsigned long type, unsigned long offset)
348348
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
349349
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
350350

351-
static inline int pte_swp_exclusive(pte_t pte)
351+
static inline bool pte_swp_exclusive(pte_t pte)
352352
{
353353
return pte_val(pte) & SRMMU_SWP_EXCLUSIVE;
354354
}

arch/sparc/include/asm/pgtable_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
10231023
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
10241024
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
10251025

1026-
static inline int pte_swp_exclusive(pte_t pte)
1026+
static inline bool pte_swp_exclusive(pte_t pte)
10271027
{
10281028
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
10291029
}

arch/um/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
314314
((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
315315
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
316316

317-
static inline int pte_swp_exclusive(pte_t pte)
317+
static inline bool pte_swp_exclusive(pte_t pte)
318318
{
319319
return pte_get_bits(pte, _PAGE_SWP_EXCLUSIVE);
320320
}

arch/x86/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ static inline pte_t pte_swp_mkexclusive(pte_t pte)
15611561
return pte_set_flags(pte, _PAGE_SWP_EXCLUSIVE);
15621562
}
15631563

1564-
static inline int pte_swp_exclusive(pte_t pte)
1564+
static inline bool pte_swp_exclusive(pte_t pte)
15651565
{
15661566
return pte_flags(pte) & _PAGE_SWP_EXCLUSIVE;
15671567
}

arch/xtensa/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
349349
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
350350
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
351351

352-
static inline int pte_swp_exclusive(pte_t pte)
352+
static inline bool pte_swp_exclusive(pte_t pte)
353353
{
354354
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
355355
}

0 commit comments

Comments
 (0)