aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/um/kernel/physmem.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index 549ecf3f5857..9034fc8056b4 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -57,22 +57,51 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
57 57
58extern int __syscall_stub_start; 58extern int __syscall_stub_start;
59 59
60/**
61 * setup_physmem() - Setup physical memory for UML
62 * @start: Start address of the physical kernel memory,
63 * i.e start address of the executable image.
64 * @reserve_end: end address of the physical kernel memory.
65 * @len: Length of total physical memory that should be mapped/made
66 * available, in bytes.
67 * @highmem: Number of highmem bytes that should be mapped/made available.
68 *
69 * Creates an unlinked temporary file of size (len + highmem) and memory maps
70 * it on the last executable image address (uml_reserved).
71 *
72 * The offset is needed as the length of the total physical memory
73 * (len + highmem) includes the size of the memory used be the executable image,
74 * but the mapped-to address is the last address of the executable image
75 * (uml_reserved == end address of executable image).
76 *
77 * The memory mapped memory of the temporary file is used as backing memory
78 * of all user space processes/kernel tasks.
79 */
60void __init setup_physmem(unsigned long start, unsigned long reserve_end, 80void __init setup_physmem(unsigned long start, unsigned long reserve_end,
61 unsigned long len, unsigned long long highmem) 81 unsigned long len, unsigned long long highmem)
62{ 82{
63 unsigned long reserve = reserve_end - start; 83 unsigned long reserve = reserve_end - start;
64 int pfn = PFN_UP(__pa(reserve_end)); 84 unsigned long pfn = PFN_UP(__pa(reserve_end));
65 int delta = (len - reserve) >> PAGE_SHIFT; 85 unsigned long delta = (len - reserve) >> PAGE_SHIFT;
66 int err, offset, bootmap_size; 86 unsigned long offset, bootmap_size;
87 long map_size;
88 int err;
89
90 offset = uml_reserved - uml_physmem;
91 map_size = len - offset;
92 if(map_size <= 0) {
93 printf("Too few physical memory! Needed=%d, given=%d\n",
94 offset, len);
95 exit(1);
96 }
67 97
68 physmem_fd = create_mem_file(len + highmem); 98 physmem_fd = create_mem_file(len + highmem);
69 99
70 offset = uml_reserved - uml_physmem;
71 err = os_map_memory((void *) uml_reserved, physmem_fd, offset, 100 err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
72 len - offset, 1, 1, 1); 101 map_size, 1, 1, 1);
73 if (err < 0) { 102 if (err < 0) {
74 printf("setup_physmem - mapping %ld bytes of memory at 0x%p " 103 printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
75 "failed - errno = %d\n", len - offset, 104 "failed - errno = %d\n", map_size,
76 (void *) uml_reserved, err); 105 (void *) uml_reserved, err);
77 exit(1); 106 exit(1);
78 } 107 }