mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
tools/testing/vma: convert bulk of test code to vma_flags_t
Convert the test code to utilise vma_flags_t as opposed to the deprecate vm_flags_t as much as possible. As part of this change, add VMA_STICKY_FLAGS and VMA_SPECIAL_FLAGS as early versions of what these defines will look like in the kernel logic once this logic is implemented. Link: https://lkml.kernel.org/r/df90efe29300bd899989f695be4ae3adc901a828.1774034900.git.ljs@kernel.org Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: "Borislav Petkov (AMD)" <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chengming Zhou <chengming.zhou@linux.dev> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christian Brauner <brauner@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: Dinh Nguyen <dinguyen@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Kees Cook <kees@kernel.org> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Ondrej Mosnacek <omosnace@redhat.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Moore <paul@paul-moore.com> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Richard Weinberger <richard@nod.at> Cc: Russell King <linux@armlinux.org.uk> Cc: Stephen Smalley <stephen.smalley.work@gmail.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vineet Gupta <vgupta@kernel.org> Cc: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Will Deacon <will@kernel.org> Cc: xu xin <xu.xin16@zte.com.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
8228e42b5f
commit
bd44d91d0c
@@ -132,3 +132,10 @@ static __always_inline bool vma_flags_same_mask(vma_flags_t *flags,
|
||||
}
|
||||
#define vma_flags_same(flags, ...) \
|
||||
vma_flags_same_mask(flags, mk_vma_flags(__VA_ARGS__))
|
||||
#define VMA_SPECIAL_FLAGS mk_vma_flags(VMA_IO_BIT, VMA_DONTEXPAND_BIT, \
|
||||
VMA_PFNMAP_BIT, VMA_MIXEDMAP_BIT)
|
||||
#ifdef CONFIG_MEM_SOFT_DIRTY
|
||||
#define VMA_STICKY_FLAGS mk_vma_flags(VMA_SOFTDIRTY_BIT, VMA_MAYBE_GUARD_BIT)
|
||||
#else
|
||||
#define VMA_STICKY_FLAGS mk_vma_flags(VMA_MAYBE_GUARD_BIT)
|
||||
#endif
|
||||
|
||||
@@ -507,10 +507,7 @@ struct vm_area_desc {
|
||||
/* Mutable fields. Populated with initial state. */
|
||||
pgoff_t pgoff;
|
||||
struct file *vm_file;
|
||||
union {
|
||||
vm_flags_t vm_flags;
|
||||
vma_flags_t vma_flags;
|
||||
};
|
||||
vma_flags_t vma_flags;
|
||||
pgprot_t page_prot;
|
||||
|
||||
/* Write-only fields. */
|
||||
@@ -1146,7 +1143,7 @@ static inline int __compat_vma_mmap(const struct file_operations *f_op,
|
||||
|
||||
.pgoff = vma->vm_pgoff,
|
||||
.vm_file = vma->vm_file,
|
||||
.vm_flags = vma->vm_flags,
|
||||
.vma_flags = vma->flags,
|
||||
.page_prot = vma->vm_page_prot,
|
||||
|
||||
.action.type = MMAP_NOTHING, /* Default */
|
||||
|
||||
@@ -14,7 +14,7 @@ struct task_struct __current;
|
||||
|
||||
struct vm_area_struct *alloc_vma(struct mm_struct *mm,
|
||||
unsigned long start, unsigned long end,
|
||||
pgoff_t pgoff, vm_flags_t vm_flags)
|
||||
pgoff_t pgoff, vma_flags_t vma_flags)
|
||||
{
|
||||
struct vm_area_struct *vma = vm_area_alloc(mm);
|
||||
|
||||
@@ -24,7 +24,7 @@ struct vm_area_struct *alloc_vma(struct mm_struct *mm,
|
||||
vma->vm_start = start;
|
||||
vma->vm_end = end;
|
||||
vma->vm_pgoff = pgoff;
|
||||
vm_flags_reset(vma, vm_flags);
|
||||
vma->flags = vma_flags;
|
||||
vma_assert_detached(vma);
|
||||
|
||||
return vma;
|
||||
@@ -38,9 +38,9 @@ void detach_free_vma(struct vm_area_struct *vma)
|
||||
|
||||
struct vm_area_struct *alloc_and_link_vma(struct mm_struct *mm,
|
||||
unsigned long start, unsigned long end,
|
||||
pgoff_t pgoff, vm_flags_t vm_flags)
|
||||
pgoff_t pgoff, vma_flags_t vma_flags)
|
||||
{
|
||||
struct vm_area_struct *vma = alloc_vma(mm, start, end, pgoff, vm_flags);
|
||||
struct vm_area_struct *vma = alloc_vma(mm, start, end, pgoff, vma_flags);
|
||||
|
||||
if (vma == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -94,7 +94,7 @@ static inline void dummy_close(struct vm_area_struct *)
|
||||
/* Helper function to simply allocate a VMA. */
|
||||
struct vm_area_struct *alloc_vma(struct mm_struct *mm,
|
||||
unsigned long start, unsigned long end,
|
||||
pgoff_t pgoff, vm_flags_t vm_flags);
|
||||
pgoff_t pgoff, vma_flags_t vma_flags);
|
||||
|
||||
/* Helper function to detach and free a VMA. */
|
||||
void detach_free_vma(struct vm_area_struct *vma);
|
||||
@@ -102,7 +102,7 @@ void detach_free_vma(struct vm_area_struct *vma);
|
||||
/* Helper function to allocate a VMA and link it to the tree. */
|
||||
struct vm_area_struct *alloc_and_link_vma(struct mm_struct *mm,
|
||||
unsigned long start, unsigned long end,
|
||||
pgoff_t pgoff, vm_flags_t vm_flags);
|
||||
pgoff_t pgoff, vma_flags_t vma_flags);
|
||||
|
||||
/*
|
||||
* Helper function to reset the dummy anon_vma to indicate it has not been
|
||||
|
||||
+166
-147
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,8 @@ static bool compare_legacy_flags(vm_flags_t legacy_flags, vma_flags_t flags)
|
||||
|
||||
static bool test_copy_vma(void)
|
||||
{
|
||||
vm_flags_t vm_flags = VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE;
|
||||
vma_flags_t vma_flags = mk_vma_flags(VMA_READ_BIT, VMA_WRITE_BIT,
|
||||
VMA_MAYREAD_BIT, VMA_MAYWRITE_BIT);
|
||||
struct mm_struct mm = {};
|
||||
bool need_locks = false;
|
||||
VMA_ITERATOR(vmi, &mm, 0);
|
||||
@@ -30,7 +31,7 @@ static bool test_copy_vma(void)
|
||||
|
||||
/* Move backwards and do not merge. */
|
||||
|
||||
vma = alloc_and_link_vma(&mm, 0x3000, 0x5000, 3, vm_flags);
|
||||
vma = alloc_and_link_vma(&mm, 0x3000, 0x5000, 3, vma_flags);
|
||||
vma_new = copy_vma(&vma, 0, 0x2000, 0, &need_locks);
|
||||
ASSERT_NE(vma_new, vma);
|
||||
ASSERT_EQ(vma_new->vm_start, 0);
|
||||
@@ -42,8 +43,8 @@ static bool test_copy_vma(void)
|
||||
|
||||
/* Move a VMA into position next to another and merge the two. */
|
||||
|
||||
vma = alloc_and_link_vma(&mm, 0, 0x2000, 0, vm_flags);
|
||||
vma_next = alloc_and_link_vma(&mm, 0x6000, 0x8000, 6, vm_flags);
|
||||
vma = alloc_and_link_vma(&mm, 0, 0x2000, 0, vma_flags);
|
||||
vma_next = alloc_and_link_vma(&mm, 0x6000, 0x8000, 6, vma_flags);
|
||||
vma_new = copy_vma(&vma, 0x4000, 0x2000, 4, &need_locks);
|
||||
vma_assert_attached(vma_new);
|
||||
|
||||
@@ -61,7 +62,6 @@ static bool test_vma_flags_unchanged(void)
|
||||
struct vm_area_struct vma;
|
||||
struct vm_area_desc desc;
|
||||
|
||||
|
||||
vma.flags = EMPTY_VMA_FLAGS;
|
||||
desc.vma_flags = EMPTY_VMA_FLAGS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user