1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_PAGE_SIZE_MIGRATION_H
3 #define _LINUX_PAGE_SIZE_MIGRATION_H
4
5 /*
6 * Page Size Migration
7 *
8 * Copyright (c) 2024, Google LLC.
9 * Author: Kalesh Singh <kaleshsingh@goole.com>
10 *
11 * This file contains the APIs for mitigations to ensure
12 * app compatibility during the transition from 4kB to 16kB
13 * page size in Android.
14 */
15
16 #include <linux/pgsize_migration_inline.h>
17 #include <linux/seq_file.h>
18 #include <linux/mm.h>
19
20 #if PAGE_SIZE == SZ_4K && defined(CONFIG_64BIT)
21 extern void vma_set_pad_pages(struct vm_area_struct *vma,
22 unsigned long nr_pages);
23
24 extern unsigned long vma_pad_pages(struct vm_area_struct *vma);
25
26 extern void madvise_vma_pad_pages(struct vm_area_struct *vma,
27 unsigned long start, unsigned long end);
28
29 extern void show_map_pad_vma(struct vm_area_struct *vma,
30 struct seq_file *m, void *func, bool smaps);
31
32 extern void split_pad_vma(struct vm_area_struct *vma, struct vm_area_struct *new,
33 unsigned long addr, int new_below);
34
35 extern bool is_mergable_pad_vma(struct vm_area_struct *vma,
36 unsigned long vm_flags);
37
38 extern unsigned long vma_data_pages(struct vm_area_struct *vma);
39 #else /* PAGE_SIZE != SZ_4K || !defined(CONFIG_64BIT) */
vma_set_pad_pages(struct vm_area_struct * vma,unsigned long nr_pages)40 static inline void vma_set_pad_pages(struct vm_area_struct *vma,
41 unsigned long nr_pages)
42 {
43 }
44
vma_pad_pages(struct vm_area_struct * vma)45 static inline unsigned long vma_pad_pages(struct vm_area_struct *vma)
46 {
47 return 0;
48 }
49
madvise_vma_pad_pages(struct vm_area_struct * vma,unsigned long start,unsigned long end)50 static inline void madvise_vma_pad_pages(struct vm_area_struct *vma,
51 unsigned long start, unsigned long end)
52 {
53 }
54
show_map_pad_vma(struct vm_area_struct * vma,struct seq_file * m,void * func,bool smaps)55 static inline void show_map_pad_vma(struct vm_area_struct *vma,
56 struct seq_file *m, void *func, bool smaps)
57 {
58 }
59
split_pad_vma(struct vm_area_struct * vma,struct vm_area_struct * new,unsigned long addr,int new_below)60 static inline void split_pad_vma(struct vm_area_struct *vma, struct vm_area_struct *new,
61 unsigned long addr, int new_below)
62 {
63 }
64
is_mergable_pad_vma(struct vm_area_struct * vma,unsigned long vm_flags)65 static inline bool is_mergable_pad_vma(struct vm_area_struct *vma,
66 unsigned long vm_flags)
67 {
68 return true;
69 }
70
vma_data_pages(struct vm_area_struct * vma)71 static inline unsigned long vma_data_pages(struct vm_area_struct *vma)
72 {
73 return vma_pages(vma);
74 }
75 #endif /* PAGE_SIZE == SZ_4K && defined(CONFIG_64BIT) */
76 #endif /* _LINUX_PAGE_SIZE_MIGRATION_H */
77