diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cgroup/cpuset.c | 15 | ||||
| -rw-r--r-- | kernel/dma/coherent.c | 7 | ||||
| -rw-r--r-- | kernel/dma/direct.c | 6 | ||||
| -rw-r--r-- | kernel/dma/mapping.c | 8 | ||||
| -rw-r--r-- | kernel/dma/ops_helpers.c | 4 | ||||
| -rw-r--r-- | kernel/events/core.c | 20 | ||||
| -rw-r--r-- | kernel/events/uprobes.c | 13 | ||||
| -rw-r--r-- | kernel/kcov.c | 2 | ||||
| -rw-r--r-- | kernel/liveupdate/kexec_handover.c | 3 | ||||
| -rw-r--r-- | kernel/trace/ring_buffer.c | 3 |
10 files changed, 45 insertions, 36 deletions
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 6d054054c202..d100634fa12b 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -4335,7 +4335,7 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk) * * Are any of the nodes in the nodemask allowed in current->mems_allowed? */ -int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask) +int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask) { return nodes_intersects(*nodemask, current->mems_allowed); } @@ -4371,7 +4371,7 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs) * nearest enclosing hardwalled ancestor cpuset. * * Scanning up parent cpusets requires callback_lock. The - * __alloc_pages() routine only calls here with __GFP_HARDWALL bit + * page allocator only calls here with __GFP_HARDWALL bit * _not_ set if it's a GFP_KERNEL allocation, and all nodes in the * current tasks mems_allowed came up empty on the first pass over * the zonelist. So only GFP_KERNEL allocations, if all nodes in the @@ -4384,11 +4384,8 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs) * come before the __GFP_HARDWALL check, otherwise a dying task * would be blocked on the fast path. * - * The second pass through get_page_from_freelist() doesn't even call - * here for GFP_ATOMIC calls. For those calls, the __alloc_pages() - * variable 'wait' is not set, and the bit ALLOC_CPUSET is not set - * in alloc_flags. That logic and the checks below have the combined - * affect that: + * The second pass through get_page_from_freelist() doesn't even call here for + * GFP_ATOMIC calls. That, and the checks below have the combined affect that: * in_interrupt - any node ok (current task context irrelevant) * GFP_ATOMIC - any node ok * tsk_is_oom_victim - any node ok @@ -4501,8 +4498,8 @@ void cpuset_nodes_allowed(struct cgroup *cgroup, nodemask_t *mask) * should not be possible for the following code to return an * offline node. But if it did, that would be ok, as this routine * is not returning the node where the allocation must be, only - * the node where the search should start. The zonelist passed to - * __alloc_pages() will include all nodes. If the slab allocator + * the node where the search should start. The zonelist used by + * the allocator will include all nodes. If the slab allocator * is passed an offline node, it will fall back to the local node. * See kmem_cache_alloc_node(). */ diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c index bcdc0f76d2e8..2d3195eb7e83 100644 --- a/kernel/dma/coherent.c +++ b/kernel/dma/coherent.c @@ -236,14 +236,15 @@ static int __dma_mmap_from_coherent(struct dma_coherent_mem *mem, { if (mem && vaddr >= mem->virt_base && vaddr + size <= (mem->virt_base + ((dma_addr_t)mem->size << PAGE_SHIFT))) { - unsigned long off = vma->vm_pgoff; + const pgoff_t pgoff_start = vma_start_pgoff(vma); + const pgoff_t pgoff_end = vma_end_pgoff(vma); int start = (vaddr - mem->virt_base) >> PAGE_SHIFT; unsigned long user_count = vma_pages(vma); int count = PAGE_ALIGN(size) >> PAGE_SHIFT; *ret = -ENXIO; - if (off < count && user_count <= count - off) { - unsigned long pfn = mem->pfn_base + start + off; + if (pgoff_start < count && pgoff_end <= count) { + unsigned long pfn = mem->pfn_base + start + pgoff_start; *ret = remap_pfn_range(vma, vma->vm_start, pfn, user_count << PAGE_SHIFT, vma->vm_page_prot); diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 4391b797d4db..436310d6e4a2 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -534,6 +534,8 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma, unsigned long user_count = vma_pages(vma); unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; unsigned long pfn = PHYS_PFN(dma_to_phys(dev, dma_addr)); + const pgoff_t pgoff_start = vma_start_pgoff(vma); + const pgoff_t pgoff_end = vma_end_pgoff(vma); int ret = -ENXIO; vma->vm_page_prot = dma_pgprot(dev, vma->vm_page_prot, attrs); @@ -545,9 +547,9 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma, if (dma_mmap_from_global_coherent(vma, cpu_addr, size, &ret)) return ret; - if (vma->vm_pgoff >= count || user_count > count - vma->vm_pgoff) + if (pgoff_start >= count || pgoff_end > count) return -ENXIO; - return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff, + return remap_pfn_range(vma, vma->vm_start, pfn + pgoff_start, user_count << PAGE_SHIFT, vma->vm_page_prot); } diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index 4fe04669e5e6..c986639044e9 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -761,12 +761,14 @@ EXPORT_SYMBOL_GPL(dma_free_pages); int dma_mmap_pages(struct device *dev, struct vm_area_struct *vma, size_t size, struct page *page) { - unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; + const pgoff_t pgoff_start = vma_start_pgoff(vma); + const pgoff_t pgoff_end = vma_end_pgoff(vma); + const unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; - if (vma->vm_pgoff >= count || vma_pages(vma) > count - vma->vm_pgoff) + if (pgoff_start >= count || pgoff_end > count) return -ENXIO; return remap_pfn_range(vma, vma->vm_start, - page_to_pfn(page) + vma->vm_pgoff, + page_to_pfn(page) + pgoff_start, vma_pages(vma) << PAGE_SHIFT, vma->vm_page_prot); } EXPORT_SYMBOL_GPL(dma_mmap_pages); diff --git a/kernel/dma/ops_helpers.c b/kernel/dma/ops_helpers.c index 20caf9cabf69..6b5f9208d31c 100644 --- a/kernel/dma/ops_helpers.c +++ b/kernel/dma/ops_helpers.c @@ -39,7 +39,7 @@ int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, #ifdef CONFIG_MMU unsigned long user_count = vma_pages(vma); unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; - unsigned long off = vma->vm_pgoff; + unsigned long off = vma_start_pgoff(vma); struct page *page = dma_common_vaddr_to_page(cpu_addr); int ret = -ENXIO; @@ -52,7 +52,7 @@ int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, return -ENXIO; return remap_pfn_range(vma, vma->vm_start, - page_to_pfn(page) + vma->vm_pgoff, + page_to_pfn(page) + vma_start_pgoff(vma), user_count << PAGE_SHIFT, vma->vm_page_prot); #else return -ENXIO; diff --git a/kernel/events/core.c b/kernel/events/core.c index 421b897de71e..66d874e2b173 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7005,7 +7005,7 @@ static void perf_mmap_open(struct vm_area_struct *vma) refcount_inc(&event->mmap_count); refcount_inc(&event->rb->mmap_count); - if (vma->vm_pgoff) + if (vma_start_pgoff(vma)) refcount_inc(&event->rb->aux_mmap_count); if (mapped) @@ -7039,7 +7039,7 @@ static void perf_mmap_close(struct vm_area_struct *vma) * The AUX buffer is strictly a sub-buffer, serialize using aux_mutex * to avoid complications. */ - if (rb_has_aux(rb) && vma->vm_pgoff == rb->aux_pgoff && + if (rb_has_aux(rb) && vma_start_pgoff(vma) == rb->aux_pgoff && refcount_dec_and_mutex_lock(&rb->aux_mmap_count, &rb->aux_mutex)) { /* * Stop all AUX events that are writing to this buffer, @@ -7199,7 +7199,8 @@ static int map_range(struct perf_buffer *rb, struct vm_area_struct *vma) */ for (pagenum = 0; pagenum < nr_pages; pagenum++) { unsigned long va = vma->vm_start + PAGE_SIZE * pagenum; - struct page *page = perf_mmap_to_page(rb, vma->vm_pgoff + pagenum); + struct page *page = perf_mmap_to_page(rb, + vma_start_pgoff(vma) + pagenum); if (page == NULL) { err = -EINVAL; @@ -7353,6 +7354,7 @@ static int perf_mmap_rb(struct vm_area_struct *vma, struct perf_event *event, static int perf_mmap_aux(struct vm_area_struct *vma, struct perf_event *event, unsigned long nr_pages) { + const pgoff_t pgoff_start = vma_start_pgoff(vma); long extra = 0, user_extra = nr_pages; u64 aux_offset, aux_size; struct perf_buffer *rb; @@ -7375,11 +7377,11 @@ static int perf_mmap_aux(struct vm_area_struct *vma, struct perf_event *event, if (aux_offset < perf_data_size(rb) + PAGE_SIZE) return -EINVAL; - if (aux_offset != vma->vm_pgoff << PAGE_SHIFT) + if (aux_offset != pgoff_start << PAGE_SHIFT) return -EINVAL; /* already mapped with a different offset */ - if (rb_has_aux(rb) && rb->aux_pgoff != vma->vm_pgoff) + if (rb_has_aux(rb) && rb->aux_pgoff != pgoff_start) return -EINVAL; if (aux_size != nr_pages * PAGE_SIZE) @@ -7409,7 +7411,7 @@ static int perf_mmap_aux(struct vm_area_struct *vma, struct perf_event *event, if (vma->vm_flags & VM_WRITE) rb_flags |= RING_BUFFER_WRITABLE; - ret = rb_alloc_aux(rb, event, vma->vm_pgoff, nr_pages, + ret = rb_alloc_aux(rb, event, pgoff_start, nr_pages, event->attr.aux_watermark, rb_flags); if (ret) { refcount_dec(&rb->mmap_count); @@ -7466,7 +7468,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) if (event->state <= PERF_EVENT_STATE_REVOKED) return -ENODEV; - if (vma->vm_pgoff == 0) + if (!vma_start_pgoff(vma)) ret = perf_mmap_rb(vma, event, nr_pages); else ret = perf_mmap_aux(vma, event, nr_pages); @@ -9916,7 +9918,7 @@ static bool perf_addr_filter_vma_adjust(struct perf_addr_filter *filter, struct perf_addr_filter_range *fr) { unsigned long vma_size = vma->vm_end - vma->vm_start; - unsigned long off = vma->vm_pgoff << PAGE_SHIFT; + unsigned long off = vma_start_pgoff(vma) << PAGE_SHIFT; struct file *file = vma->vm_file; if (!perf_addr_filter_match(filter, file, off, vma_size)) @@ -10006,7 +10008,7 @@ void perf_event_mmap(struct vm_area_struct *vma) /* .tid */ .start = vma->vm_start, .len = vma->vm_end - vma->vm_start, - .pgoff = (u64)vma->vm_pgoff << PAGE_SHIFT, + .pgoff = (u64)vma_start_pgoff(vma) << PAGE_SHIFT, }, /* .maj (attr_mmap2 only) */ /* .min (attr_mmap2 only) */ diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index a18529ab2b87..b25531331902 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -144,12 +144,14 @@ static bool valid_vma(struct vm_area_struct *vma, bool is_register) static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) { - return vma->vm_start + offset - ((loff_t)vma->vm_pgoff << PAGE_SHIFT); + return vma->vm_start + offset - + ((loff_t)vma_start_pgoff(vma) << PAGE_SHIFT); } static loff_t vaddr_to_offset(struct vm_area_struct *vma, unsigned long vaddr) { - return ((loff_t)vma->vm_pgoff << PAGE_SHIFT) + (vaddr - vma->vm_start); + return ((loff_t)vma_start_pgoff(vma) << PAGE_SHIFT) + + (vaddr - vma->vm_start); } /** @@ -1211,7 +1213,7 @@ build_map_info(struct address_space *mapping, loff_t offset, bool is_register) again: i_mmap_lock_read(mapping); - vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { + mapping_rmap_tree_foreach(vma, mapping, pgoff, pgoff) { if (!valid_vma(vma, is_register)) continue; @@ -1483,7 +1485,7 @@ static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm) file_inode(vma->vm_file) != uprobe->inode) continue; - offset = (loff_t)vma->vm_pgoff << PAGE_SHIFT; + offset = (loff_t)vma_start_pgoff(vma) << PAGE_SHIFT; if (uprobe->offset < offset || uprobe->offset >= offset + vma->vm_end - vma->vm_start) continue; @@ -2448,7 +2450,8 @@ static struct uprobe *find_active_uprobe_speculative(unsigned long bp_vaddr) if (!vm_file) return NULL; - offset = (loff_t)(vma->vm_pgoff << PAGE_SHIFT) + (bp_vaddr - vma->vm_start); + offset = (loff_t)(vma_start_pgoff(vma) << PAGE_SHIFT) + + (bp_vaddr - vma->vm_start); uprobe = find_uprobe_rcu(vm_file->f_inode, offset); if (!uprobe) return NULL; diff --git a/kernel/kcov.c b/kernel/kcov.c index 1df373fb562b..b19b473c366a 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -512,7 +512,7 @@ static int kcov_mmap(struct file *filep, struct vm_area_struct *vma) spin_lock_irqsave(&kcov->lock, flags); size = kcov->size * sizeof(unsigned long); - if (kcov->area == NULL || vma->vm_pgoff != 0 || + if (kcov->area == NULL || vma_start_pgoff(vma) || vma->vm_end - vma->vm_start != size) { res = -EINVAL; goto exit; diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index 6fad9152387a..9260e601c61d 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -34,7 +34,8 @@ * KHO is tightly coupled with mm init and needs access to some of mm * internal APIs. */ -#include "../../mm/internal.h" +#include "../../mm/mm_init.h" +#include "../../mm/vmalloc.h" #include "../kexec_internal.h" #include "kexec_handover_internal.h" diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 5fc009edc1ec..3c3ed639923d 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -7667,7 +7667,8 @@ static int __rb_inc_dec_mapped(struct ring_buffer_per_cpu *cpu_buffer, static int __rb_map_vma(struct ring_buffer_per_cpu *cpu_buffer, struct vm_area_struct *vma) { - unsigned long nr_subbufs, nr_pages, nr_vma_pages, pgoff = vma->vm_pgoff; + unsigned long nr_subbufs, nr_pages, nr_vma_pages; + pgoff_t pgoff = vma_start_pgoff(vma); unsigned int subbuf_pages, subbuf_order; struct page **pages __free(kfree) = NULL; int p = 0, s = 0; |
