@@ -414,6 +414,34 @@ static ssize_t read_vmcore(struct kiocb *iocb, struct iov_iter *iter)
414
414
return __read_vmcore (iter , & iocb -> ki_pos );
415
415
}
416
416
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
+
417
445
/*
418
446
* The vmcore fault handler uses the page cache and fills data using the
419
447
* standard __read_vmcore() function.
@@ -457,34 +485,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
457
485
#endif
458
486
}
459
487
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
-
488
488
static const struct vm_operations_struct vmcore_mmap_ops = {
489
489
.fault = mmap_vmcore_fault ,
490
490
};
0 commit comments