| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
|---|
| 3 | | - * Licensed under the GPL |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | #include <linux/module.h> |
|---|
| 7 | | -#include <linux/bootmem.h> |
|---|
| 7 | +#include <linux/memblock.h> |
|---|
| 8 | 8 | #include <linux/mm.h> |
|---|
| 9 | 9 | #include <linux/pfn.h> |
|---|
| 10 | 10 | #include <asm/page.h> |
|---|
| .. | .. |
|---|
| 80 | 80 | unsigned long len, unsigned long long highmem) |
|---|
| 81 | 81 | { |
|---|
| 82 | 82 | unsigned long reserve = reserve_end - start; |
|---|
| 83 | | - unsigned long pfn = PFN_UP(__pa(reserve_end)); |
|---|
| 84 | | - unsigned long delta = (len - reserve) >> PAGE_SHIFT; |
|---|
| 85 | | - unsigned long offset, bootmap_size; |
|---|
| 86 | | - long map_size; |
|---|
| 83 | + long map_size = len - reserve; |
|---|
| 87 | 84 | int err; |
|---|
| 88 | 85 | |
|---|
| 89 | | - offset = uml_reserved - uml_physmem; |
|---|
| 90 | | - map_size = len - offset; |
|---|
| 91 | 86 | if(map_size <= 0) { |
|---|
| 92 | 87 | os_warn("Too few physical memory! Needed=%lu, given=%lu\n", |
|---|
| 93 | | - offset, len); |
|---|
| 88 | + reserve, len); |
|---|
| 94 | 89 | exit(1); |
|---|
| 95 | 90 | } |
|---|
| 96 | 91 | |
|---|
| 97 | 92 | physmem_fd = create_mem_file(len + highmem); |
|---|
| 98 | 93 | |
|---|
| 99 | | - err = os_map_memory((void *) uml_reserved, physmem_fd, offset, |
|---|
| 94 | + err = os_map_memory((void *) reserve_end, physmem_fd, reserve, |
|---|
| 100 | 95 | map_size, 1, 1, 1); |
|---|
| 101 | 96 | if (err < 0) { |
|---|
| 102 | 97 | os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p " |
|---|
| 103 | 98 | "failed - errno = %d\n", map_size, |
|---|
| 104 | | - (void *) uml_reserved, err); |
|---|
| 99 | + (void *) reserve_end, err); |
|---|
| 105 | 100 | exit(1); |
|---|
| 106 | 101 | } |
|---|
| 107 | 102 | |
|---|
| .. | .. |
|---|
| 113 | 108 | os_write_file(physmem_fd, __syscall_stub_start, PAGE_SIZE); |
|---|
| 114 | 109 | os_fsync_file(physmem_fd); |
|---|
| 115 | 110 | |
|---|
| 116 | | - bootmap_size = init_bootmem(pfn, pfn + delta); |
|---|
| 117 | | - free_bootmem(__pa(reserve_end) + bootmap_size, |
|---|
| 118 | | - len - bootmap_size - reserve); |
|---|
| 111 | + memblock_add(__pa(start), len + highmem); |
|---|
| 112 | + memblock_reserve(__pa(start), reserve); |
|---|
| 113 | + |
|---|
| 114 | + min_low_pfn = PFN_UP(__pa(reserve_end)); |
|---|
| 115 | + max_low_pfn = min_low_pfn + (map_size >> PAGE_SHIFT); |
|---|
| 119 | 116 | } |
|---|
| 120 | 117 | |
|---|
| 121 | 118 | int phys_mapping(unsigned long phys, unsigned long long *offset_out) |
|---|
| .. | .. |
|---|
| 146 | 143 | |
|---|
| 147 | 144 | return fd; |
|---|
| 148 | 145 | } |
|---|
| 146 | +EXPORT_SYMBOL(phys_mapping); |
|---|
| 149 | 147 | |
|---|
| 150 | 148 | static int __init uml_mem_setup(char *line, int *add) |
|---|
| 151 | 149 | { |
|---|