Skip to content

Commit def1379

Browse files
committed
fs/proc/vmcore.c: fix warning when CONFIG_MMU=n
>> fs/proc/vmcore.c:424:19: warning: 'mmap_vmcore_fault' defined but not used [-Wunused-function] 424 | static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf) Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Cc: Qi Xi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 40384c8 commit def1379

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

fs/proc/vmcore.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,34 @@ static ssize_t read_vmcore(struct kiocb *iocb, struct iov_iter *iter)
414414
return __read_vmcore(iter, &iocb->ki_pos);
415415
}
416416

417+
/**
418+
* vmcore_alloc_buf - allocate buffer in vmalloc memory
419+
* @size: size of buffer
420+
*
421+
* If CONFIG_MMU is defined, use vmalloc_user() to allow users to mmap
422+
* the buffer to user-space by means of remap_vmalloc_range().
423+
*
424+
* If CONFIG_MMU is not defined, use vzalloc() since mmap_vmcore() is
425+
* disabled and there's no need to allow users to mmap the buffer.
426+
*/
427+
static inline char *vmcore_alloc_buf(size_t size)
428+
{
429+
#ifdef CONFIG_MMU
430+
return vmalloc_user(size);
431+
#else
432+
return vzalloc(size);
433+
#endif
434+
}
435+
436+
/*
437+
* Disable mmap_vmcore() if CONFIG_MMU is not defined. MMU is
438+
* essential for mmap_vmcore() in order to map physically
439+
* non-contiguous objects (ELF header, ELF note segment and memory
440+
* regions in the 1st kernel pointed to by PT_LOAD entries) into
441+
* virtually contiguous user-space in ELF layout.
442+
*/
443+
#ifdef CONFIG_MMU
444+
417445
/*
418446
* The vmcore fault handler uses the page cache and fills data using the
419447
* standard __read_vmcore() function.
@@ -457,34 +485,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
457485
#endif
458486
}
459487

460-
/**
461-
* vmcore_alloc_buf - allocate buffer in vmalloc memory
462-
* @size: size of buffer
463-
*
464-
* If CONFIG_MMU is defined, use vmalloc_user() to allow users to mmap
465-
* the buffer to user-space by means of remap_vmalloc_range().
466-
*
467-
* If CONFIG_MMU is not defined, use vzalloc() since mmap_vmcore() is
468-
* disabled and there's no need to allow users to mmap the buffer.
469-
*/
470-
static inline char *vmcore_alloc_buf(size_t size)
471-
{
472-
#ifdef CONFIG_MMU
473-
return vmalloc_user(size);
474-
#else
475-
return vzalloc(size);
476-
#endif
477-
}
478-
479-
/*
480-
* Disable mmap_vmcore() if CONFIG_MMU is not defined. MMU is
481-
* essential for mmap_vmcore() in order to map physically
482-
* non-contiguous objects (ELF header, ELF note segment and memory
483-
* regions in the 1st kernel pointed to by PT_LOAD entries) into
484-
* virtually contiguous user-space in ELF layout.
485-
*/
486-
#ifdef CONFIG_MMU
487-
488488
static const struct vm_operations_struct vmcore_mmap_ops = {
489489
.fault = mmap_vmcore_fault,
490490
};

0 commit comments

Comments
 (0)