From: Simon Glass <simon.glass@canonical.com> U-Boot does not have virtual memory management. The ext4l filesystem uses several VM-related types which are currently defined inline in ext4_uboot.h. Create a new linux/mm_types.h header file with stub implementations to better match the Linux kernel structure. Types moved: - struct page - vm_fault_t - VM_SHARED, VM_WRITE, VM_HUGEPAGE flags - FAULT_FLAG_WRITE - VM_FAULT_SIGBUS, VM_FAULT_NOPAGE, VM_FAULT_LOCKED - MAX_PAGECACHE_ORDER - struct vm_area_struct - struct vm_fault - struct vm_operations_struct - struct vm_area_desc Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 60 ++------------------ include/linux/mm_types.h | 116 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 55 deletions(-) create mode 100644 include/linux/mm_types.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index d04a843175b..6a06805329f 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -456,29 +456,15 @@ struct name_snapshot { struct qstr name; }; -/* vm_fault_t - stub */ -typedef unsigned int vm_fault_t; - -/* VM flags */ -#define VM_SHARED 0x00000008 -#define VM_WRITE 0x00000002 -#define VM_HUGEPAGE 0x01000000 -#define FAULT_FLAG_WRITE 0x01 +/* VM types - use linux/mm_types.h */ +#include <linux/mm_types.h> /* pipe_inode_info - forward declaration */ struct pipe_inode_info; -/* vm_area_desc - for mmap_prepare */ -struct vm_area_desc { - struct file *file; - unsigned long vm_flags; - const struct vm_operations_struct *vm_ops; -}; - -/* Forward declarations for function prototypes */ +/* Forward declarations for function prototypes (vm_fault is in linux/mm_types.h) */ struct kstat; struct path; -struct vm_fault; struct file_kattr; struct dir_context; struct readahead_control; @@ -592,10 +578,7 @@ static inline int bdev_read_only(struct block_device *bdev) #define STATX_ATTR_ENCRYPTED 0x00000800 #define STATX_ATTR_VERITY 0x00100000 -/* VM fault return values */ -#define VM_FAULT_SIGBUS 0x0002 -#define VM_FAULT_NOPAGE 0x0010 -#define VM_FAULT_LOCKED 0x0200 +/* VM fault return values are in linux/mm_types.h */ /* struct path is defined in linux/fs.h */ @@ -625,44 +608,11 @@ struct kstat { u32 atomic_write_segments_max; }; -/* struct vm_area_struct - virtual memory area */ -struct vm_area_struct { - unsigned long vm_start; - unsigned long vm_end; - struct file *vm_file; - unsigned long vm_flags; -}; - -/* struct page - minimal stub */ -struct page { - unsigned long flags; -}; - -/* struct vm_fault - virtual memory fault info */ -struct vm_fault { - struct vm_area_struct *vma; - unsigned long address; - unsigned int flags; - pgoff_t pgoff; - struct folio *folio; - struct page *page; -}; - -/* vm_operations_struct - virtual memory area operations */ -struct vm_operations_struct { - vm_fault_t (*fault)(struct vm_fault *vmf); - vm_fault_t (*huge_fault)(struct vm_fault *vmf, unsigned int order); - vm_fault_t (*page_mkwrite)(struct vm_fault *vmf); - vm_fault_t (*pfn_mkwrite)(struct vm_fault *vmf); - vm_fault_t (*map_pages)(struct vm_fault *vmf, pgoff_t start, pgoff_t end); -}; +/* VM structs (vm_area_struct, page, vm_fault, vm_operations_struct) are in linux/mm_types.h */ /* Forward declaration for swap */ struct swap_info_struct; -/* MAX_PAGECACHE_ORDER - maximum order for page cache allocations */ -#define MAX_PAGECACHE_ORDER 12 - /* Process flags */ #define PF_MEMALLOC 0x00000800 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h new file mode 100644 index 00000000000..57a52769b05 --- /dev/null +++ b/include/linux/mm_types.h @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Memory management types stub for U-Boot + * + * U-Boot doesn't have virtual memory management, so these are stubs. + */ +#ifndef _LINUX_MM_TYPES_H +#define _LINUX_MM_TYPES_H + +#include <linux/types.h> + +/* Forward declarations */ +struct file; +struct folio; +struct address_space; + +/** + * struct page - minimal stub for page structure + * @flags: page flags + * + * U-Boot stub - only the flags field is provided. + */ +struct page { + unsigned long flags; +}; + +/** + * typedef vm_fault_t - return type for page fault handlers + * + * Encodes the result of a page fault. + */ +typedef unsigned int vm_fault_t; + +/* VM flags for vm_area_struct */ +#define VM_SHARED 0x00000008 +#define VM_WRITE 0x00000002 +#define VM_HUGEPAGE 0x01000000 + +/* Fault flags */ +#define FAULT_FLAG_WRITE 0x01 + +/* VM fault return values */ +#define VM_FAULT_SIGBUS 0x0002 +#define VM_FAULT_NOPAGE 0x0010 +#define VM_FAULT_LOCKED 0x0200 + +/* Maximum order for page cache allocations */ +#define MAX_PAGECACHE_ORDER 12 + +struct vm_operations_struct; + +/** + * struct vm_area_struct - virtual memory area + * @vm_start: start address + * @vm_end: end address + * @vm_file: file this vma is associated with + * @vm_flags: VM flags + * + * U-Boot stub. + */ +struct vm_area_struct { + unsigned long vm_start; + unsigned long vm_end; + struct file *vm_file; + unsigned long vm_flags; +}; + +/** + * struct vm_fault - virtual memory fault info + * @vma: virtual memory area + * @address: faulting address + * @flags: fault flags + * @pgoff: page offset + * @folio: folio being faulted + * @page: page being faulted + * + * U-Boot stub. + */ +struct vm_fault { + struct vm_area_struct *vma; + unsigned long address; + unsigned int flags; + pgoff_t pgoff; + struct folio *folio; + struct page *page; +}; + +/** + * struct vm_operations_struct - virtual memory area operations + * + * Callbacks for VM operations. U-Boot stub. + */ +struct vm_operations_struct { + vm_fault_t (*fault)(struct vm_fault *vmf); + vm_fault_t (*huge_fault)(struct vm_fault *vmf, unsigned int order); + vm_fault_t (*page_mkwrite)(struct vm_fault *vmf); + vm_fault_t (*pfn_mkwrite)(struct vm_fault *vmf); + vm_fault_t (*map_pages)(struct vm_fault *vmf, pgoff_t start, + pgoff_t end); +}; + +/** + * struct vm_area_desc - for mmap_prepare + * @file: associated file + * @vm_flags: VM flags + * @vm_ops: VM operations + * + * U-Boot stub. + */ +struct vm_area_desc { + struct file *file; + unsigned long vm_flags; + const struct vm_operations_struct *vm_ops; +}; + +#endif /* _LINUX_MM_TYPES_H */ -- 2.43.0