vma.c (cacded5e42b9609b07b22d80c10f0076d439f7d1) vma.c (cc8cb3697a8d8eabe1fb9acb8768b11c1ab607d8)
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#include <stdbool.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7#include "maple-shared.h"
8#include "vma_internal.h"

--- 98 unchanged lines hidden (view full) ---

107}
108
109/*
110 * Helper function which provides a wrapper around a merge existing VMA
111 * operation.
112 */
113static struct vm_area_struct *merge_existing(struct vma_merge_struct *vmg)
114{
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#include <stdbool.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7#include "maple-shared.h"
8#include "vma_internal.h"

--- 98 unchanged lines hidden (view full) ---

107}
108
109/*
110 * Helper function which provides a wrapper around a merge existing VMA
111 * operation.
112 */
113static struct vm_area_struct *merge_existing(struct vma_merge_struct *vmg)
114{
115 return vma_merge(vmg);
115 return vma_merge_existing_range(vmg);
116}
117
118/*
119 * Helper function which provides a wrapper around the expansion of an existing
120 * VMA.
121 */
122static int expand_existing(struct vma_merge_struct *vmg)
123{

--- 623 unchanged lines hidden (view full) ---

747 vma_next->__vm_flags &= ~VM_MAYWRITE;
748 /* Allocate prev. */
749 vmg.prev = alloc_and_link_vma(&mm, 0, 0x1000, 0, flags);
750 /* Assign a vm_ops->close() function to VMA explicitly. */
751 vma->vm_ops = &vm_ops;
752 vmg.vma = vma;
753 /* Make sure merge does not occur. */
754 ASSERT_EQ(merge_existing(&vmg), NULL);
116}
117
118/*
119 * Helper function which provides a wrapper around the expansion of an existing
120 * VMA.
121 */
122static int expand_existing(struct vma_merge_struct *vmg)
123{

--- 623 unchanged lines hidden (view full) ---

747 vma_next->__vm_flags &= ~VM_MAYWRITE;
748 /* Allocate prev. */
749 vmg.prev = alloc_and_link_vma(&mm, 0, 0x1000, 0, flags);
750 /* Assign a vm_ops->close() function to VMA explicitly. */
751 vma->vm_ops = &vm_ops;
752 vmg.vma = vma;
753 /* Make sure merge does not occur. */
754 ASSERT_EQ(merge_existing(&vmg), NULL);
755 ASSERT_EQ(vmg.state, VMA_MERGE_NOMERGE);
755 /*
756 * Initially this is misapprehended as an out of memory report, as the
757 * close() check is handled in the same way as anon_vma duplication
758 * failures, however a subsequent patch resolves this.
759 */
760 ASSERT_EQ(vmg.state, VMA_MERGE_ERROR_NOMEM);
756
757 cleanup_mm(&mm, &vmi);
758 return true;
759}
760
761static bool test_vma_merge_new_with_close(void)
762{
763 unsigned long flags = VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE;

--- 705 unchanged lines hidden ---
761
762 cleanup_mm(&mm, &vmi);
763 return true;
764}
765
766static bool test_vma_merge_new_with_close(void)
767{
768 unsigned long flags = VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE;

--- 705 unchanged lines hidden ---