mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
Lots of functions in mm/highmem.c do not write to the given pointers and do not call functions that take non-const pointers and can therefore be constified. This includes functions like kunmap() which might be implemented in a way that writes to the pointer (e.g. to update reference counters or mapping fields), but currently are not. kmap() on the other hand cannot be made const because it calls set_page_address() which is non-const in some architectures/configurations. [akpm@linux-foundation.org: "fix" folio_page() build failure] Link: https://lkml.kernel.org/r/20250901205021.3573313-13-max.kellermann@ionos.com Signed-off-by: Max Kellermann <max.kellermann@ionos.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andreas Larsson <andreas@gaisler.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Borislav Betkov <bp@alien8.de> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Christian Zankel <chris@zankel.net> Cc: David Rientjes <rientjes@google.com> Cc: David S. Miller <davem@davemloft.net> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Hugh Dickins <hughd@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Bottomley <james.bottomley@HansenPartnership.com> Cc: Jan Kara <jack@suse.cz> Cc: Jocelyn Falempe <jfalempe@redhat.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Mark Brown <broonie@kernel.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@suse.com> Cc: "Nysal Jan K.A" <nysal@linux.ibm.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Russel King <linux@armlinux.org.uk> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleinxer <tglx@linutronix.de> Cc: Thomas Huth <thuth@redhat.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> Cc: Wei Xu <weixugc@google.com> Cc: Yuanchu Xie <yuanchu@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
85 lines
2.1 KiB
C
85 lines
2.1 KiB
C
/*
|
|
* include/asm-xtensa/highmem.h
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General
|
|
* Public License. See the file "COPYING" in the main directory of
|
|
* this archive for more details.
|
|
*
|
|
* Copyright (C) 2003 - 2005 Tensilica Inc.
|
|
* Copyright (C) 2014 Cadence Design Systems Inc.
|
|
*/
|
|
|
|
#ifndef _XTENSA_HIGHMEM_H
|
|
#define _XTENSA_HIGHMEM_H
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
#include <linux/wait.h>
|
|
#include <linux/pgtable.h>
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/fixmap.h>
|
|
|
|
#define PKMAP_BASE ((FIXADDR_START - \
|
|
(LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
|
|
#define LAST_PKMAP (PTRS_PER_PTE * DCACHE_N_COLORS)
|
|
#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
|
|
#define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
|
|
#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
|
|
|
|
#define kmap_prot PAGE_KERNEL_EXEC
|
|
|
|
#if DCACHE_WAY_SIZE > PAGE_SIZE
|
|
#define get_pkmap_color get_pkmap_color
|
|
static inline int get_pkmap_color(const struct page *page)
|
|
{
|
|
return DCACHE_ALIAS(page_to_phys(page));
|
|
}
|
|
|
|
extern unsigned int last_pkmap_nr_arr[];
|
|
|
|
static inline unsigned int get_next_pkmap_nr(unsigned int color)
|
|
{
|
|
last_pkmap_nr_arr[color] =
|
|
(last_pkmap_nr_arr[color] + DCACHE_N_COLORS) & LAST_PKMAP_MASK;
|
|
return last_pkmap_nr_arr[color] + color;
|
|
}
|
|
|
|
static inline int no_more_pkmaps(unsigned int pkmap_nr, unsigned int color)
|
|
{
|
|
return pkmap_nr < DCACHE_N_COLORS;
|
|
}
|
|
|
|
static inline int get_pkmap_entries_count(unsigned int color)
|
|
{
|
|
return LAST_PKMAP / DCACHE_N_COLORS;
|
|
}
|
|
|
|
extern wait_queue_head_t pkmap_map_wait_arr[];
|
|
|
|
static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color)
|
|
{
|
|
return pkmap_map_wait_arr + color;
|
|
}
|
|
|
|
enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn);
|
|
#define arch_kmap_local_map_idx kmap_local_map_idx
|
|
|
|
enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr);
|
|
#define arch_kmap_local_unmap_idx kmap_local_unmap_idx
|
|
|
|
#endif
|
|
|
|
extern pte_t *pkmap_page_table;
|
|
|
|
static inline void flush_cache_kmaps(void)
|
|
{
|
|
flush_cache_all();
|
|
}
|
|
|
|
#define arch_kmap_local_post_unmap(vaddr) \
|
|
local_flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE)
|
|
|
|
void kmap_init(void);
|
|
|
|
#endif /* CONFIG_HIGHMEM */
|
|
#endif
|