diff options
author | Jocelyn Falempe <jfalempe@redhat.com> | 2025-04-07 15:42:25 +0200 |
---|---|---|
committer | Jocelyn Falempe <jfalempe@redhat.com> | 2025-04-10 10:50:57 +0200 |
commit | 8702048bb8313a21ec9179e9ce7ad3c5cb2ef072 (patch) | |
tree | dba96dd52c9b7fa0032f32fe5957a6abc072684a /include/linux/highmem-internal.h | |
parent | d74cc229cfbbc5a96139825c297f34accd670bce (diff) |
mm/kmap: Add kmap_local_page_try_from_panic()
kmap_local_page() can be unsafe to call from a panic handler, if
CONFIG_HIGHMEM is set, and the page is in the highmem zone.
So add kmap_local_page_try_from_panic() to handle this case.
Suggested-by: Simona Vetter <simona.vetter@ffwll.ch>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250407140138.162383-2-jfalempe@redhat.com
Diffstat (limited to 'include/linux/highmem-internal.h')
-rw-r--r-- | include/linux/highmem-internal.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h index dd100e849f5e..9a7683d79a4b 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -73,6 +73,14 @@ static inline void *kmap_local_page(struct page *page) return __kmap_local_page_prot(page, kmap_prot); } +static inline void *kmap_local_page_try_from_panic(struct page *page) +{ + if (!PageHighMem(page)) + return page_address(page); + /* If the page is in HighMem, it's not safe to kmap it.*/ + return NULL; +} + static inline void *kmap_local_folio(struct folio *folio, size_t offset) { struct page *page = folio_page(folio, offset / PAGE_SIZE); @@ -180,6 +188,11 @@ static inline void *kmap_local_page(struct page *page) return page_address(page); } +static inline void *kmap_local_page_try_from_panic(struct page *page) +{ + return page_address(page); +} + static inline void *kmap_local_folio(struct folio *folio, size_t offset) { return page_address(&folio->page) + offset; |