@@ -919,8 +919,8 @@ static void __init ramoops_register_dummy(void)
struct ramoops_platform_data pdata;
if (mem_name) {
- unsigned long start;
- unsigned long size;
+ phys_addr_t start;
+ phys_addr_t size;
if (reserve_mem_find_by_name(mem_name, &start, &size)) {
mem_address = start;
@@ -4263,6 +4263,6 @@ static inline bool pfn_is_unaccepted_memory(unsigned long pfn)
void vma_pgtable_walk_begin(struct vm_area_struct *vma);
void vma_pgtable_walk_end(struct vm_area_struct *vma);
-int reserve_mem_find_by_name(const char *name, unsigned long *start, unsigned long *size);
+int reserve_mem_find_by_name(const char *name, phys_addr_t *start, phys_addr_t *size);
#endif /* _LINUX_MM_H */
@@ -2249,14 +2249,14 @@ void __init memblock_free_all(void)
#define RESERVE_MEM_NAME_SIZE 16
struct reserve_mem_table {
char name[RESERVE_MEM_NAME_SIZE];
- unsigned long start;
- unsigned long size;
+ phys_addr_t start;
+ phys_addr_t size;
};
static struct reserve_mem_table reserved_mem_table[RESERVE_MEM_MAX_ENTRIES];
static int reserved_mem_count;
/* Add wildcard region with a lookup name */
-static int __init reserved_mem_add(unsigned long start, unsigned long size,
+static int __init reserved_mem_add(phys_addr_t start, phys_addr_t size,
const char *name)
{
struct reserve_mem_table *map;
@@ -2282,7 +2282,7 @@ static int __init reserved_mem_add(unsigned long start, unsigned long size,
*
* Returns: 1 if found or 0 if not found.
*/
-int reserve_mem_find_by_name(const char *name, unsigned long *start, unsigned long *size)
+int reserve_mem_find_by_name(const char *name, phys_addr_t *start, phys_addr_t *size)
{
struct reserve_mem_table *map;
int i;
@@ -2302,11 +2302,12 @@ int reserve_mem_find_by_name(const char *name, unsigned long *start, unsigned lo
EXPORT_SYMBOL_GPL(reserve_mem_find_by_name);
/*
- * Parse early_reserve_mem=nn:align:name
+ * Parse reserve_mem=nn:align:name
*/
static int __init reserve_mem(char *p)
{
phys_addr_t start, size, align;
+ char *name;
char *oldp;
int err;
@@ -2315,7 +2316,7 @@ static int __init reserve_mem(char *p)
oldp = p;
size = memparse(p, &p);
- if (p == oldp)
+ if (!size || p == oldp)
return -EINVAL;
if (*p != ':')
@@ -2325,20 +2326,36 @@ static int __init reserve_mem(char *p)
if (*p != ':')
return -EINVAL;
+ /*
+ * memblock_phys_alloc() doesn't like a zero size align,
+ * but it is OK for this command to have it.
+ */
+ if (align <= SMP_CACHE_BYTES)
+ align = SMP_CACHE_BYTES;
+
+ name = p + 1;
+ if (!strlen(name))
+ return -EINVAL;
+
+ /* Make sure that name has text */
+ for (p = name; *p; p++) {
+ if (!isspace(*p))
+ break;
+ }
+ if (!*p)
+ return -EINVAL;
+
start = memblock_phys_alloc(size, align);
if (!start)
return -ENOMEM;
- p++;
- err = reserved_mem_add(start, size, p);
+ err = reserved_mem_add(start, size, name);
if (err) {
memblock_phys_free(start, size);
return err;
}
- p += strlen(p);
-
- return *p == '\0' ? 0: -EINVAL;
+ return 0;
}
__setup("reserve_mem=", reserve_mem);