madvise.c (fbc90c042cd1dc7258ebfebe6d226017e5b5ac8c) madvise.c (9651fcedf7b92d3f7f1ab179e8ab55b85ee10fc1)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/mm/madvise.c
4 *
5 * Copyright (C) 1999 Linus Torvalds
6 * Copyright (C) 2002 Christoph Hellwig
7 */
8

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

1063 break;
1064 case MADV_WIPEONFORK:
1065 /* MADV_WIPEONFORK is only supported on anonymous memory. */
1066 if (vma->vm_file || vma->vm_flags & VM_SHARED)
1067 return -EINVAL;
1068 new_flags |= VM_WIPEONFORK;
1069 break;
1070 case MADV_KEEPONFORK:
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/mm/madvise.c
4 *
5 * Copyright (C) 1999 Linus Torvalds
6 * Copyright (C) 2002 Christoph Hellwig
7 */
8

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

1063 break;
1064 case MADV_WIPEONFORK:
1065 /* MADV_WIPEONFORK is only supported on anonymous memory. */
1066 if (vma->vm_file || vma->vm_flags & VM_SHARED)
1067 return -EINVAL;
1068 new_flags |= VM_WIPEONFORK;
1069 break;
1070 case MADV_KEEPONFORK:
1071 if (vma->vm_flags & VM_DROPPABLE)
1072 return -EINVAL;
1071 new_flags &= ~VM_WIPEONFORK;
1072 break;
1073 case MADV_DONTDUMP:
1074 new_flags |= VM_DONTDUMP;
1075 break;
1076 case MADV_DODUMP:
1073 new_flags &= ~VM_WIPEONFORK;
1074 break;
1075 case MADV_DONTDUMP:
1076 new_flags |= VM_DONTDUMP;
1077 break;
1078 case MADV_DODUMP:
1077 if (!is_vm_hugetlb_page(vma) && new_flags & VM_SPECIAL)
1079 if ((!is_vm_hugetlb_page(vma) && new_flags & VM_SPECIAL) ||
1080 (vma->vm_flags & VM_DROPPABLE))
1078 return -EINVAL;
1079 new_flags &= ~VM_DONTDUMP;
1080 break;
1081 case MADV_MERGEABLE:
1082 case MADV_UNMERGEABLE:
1083 error = ksm_madvise(vma, start, end, behavior, &new_flags);
1084 if (error)
1085 goto out;

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

1142
1143 if (behavior == MADV_SOFT_OFFLINE) {
1144 pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
1145 pfn, start);
1146 ret = soft_offline_page(pfn, MF_COUNT_INCREASED);
1147 } else {
1148 pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
1149 pfn, start);
1081 return -EINVAL;
1082 new_flags &= ~VM_DONTDUMP;
1083 break;
1084 case MADV_MERGEABLE:
1085 case MADV_UNMERGEABLE:
1086 error = ksm_madvise(vma, start, end, behavior, &new_flags);
1087 if (error)
1088 goto out;

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

1145
1146 if (behavior == MADV_SOFT_OFFLINE) {
1147 pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
1148 pfn, start);
1149 ret = soft_offline_page(pfn, MF_COUNT_INCREASED);
1150 } else {
1151 pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
1152 pfn, start);
1150 ret = memory_failure(pfn, MF_ACTION_REQUIRED | MF_COUNT_INCREASED | MF_SW_SIMULATED);
1153 ret = memory_failure(pfn, MF_COUNT_INCREASED | MF_SW_SIMULATED);
1151 if (ret == -EOPNOTSUPP)
1152 ret = 0;
1153 }
1154
1155 if (ret)
1156 return ret;
1157 }
1158

--- 394 unchanged lines hidden ---
1154 if (ret == -EOPNOTSUPP)
1155 ret = 0;
1156 }
1157
1158 if (ret)
1159 return ret;
1160 }
1161

--- 394 unchanged lines hidden ---