Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e492fe35 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "arm64: Honor limits set by bootloader"

parents 40bfdc30 5768f08b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -189,6 +189,9 @@ extern u64 kimage_vaddr;
/* the offset between the kernel virtual and physical mappings */
extern u64			kimage_voffset;

/* physical memory limit imposed by the booloader */
extern phys_addr_t bootloader_memory_limit;

static inline unsigned long kaslr_offset(void)
{
	return kimage_vaddr - KIMAGE_VADDR;
+27 −0
Original line number Diff line number Diff line
@@ -313,6 +313,7 @@ static void __init arm64_memory_present(void)
#endif

static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX;
phys_addr_t bootloader_memory_limit;

/*
 * Limit the memory size that was specified via FDT.
@@ -395,6 +396,12 @@ void __init arm64_memblock_init(void)
		memblock_remove(0, memstart_addr);
	}

	/*
	 * Save bootloader imposed memory limit before we overwirte
	 * memblock.
	 */
	bootloader_memory_limit = memblock_end_of_DRAM();

	/*
	 * Apply the memory limit if it was set. Since the kernel may be loaded
	 * high up in memory, add back the kernel region that must be accessible
@@ -835,4 +842,24 @@ int arch_remove_memory(u64 start, u64 size)
}

#endif /* CONFIG_MEMORY_HOTREMOVE */
static int arm64_online_page(struct page *page)
{
	unsigned long phy_addr = page_to_phys(page);

	if (phy_addr + PAGE_SIZE >= bootloader_memory_limit)
		return -EINVAL;

	__online_page_set_limits(page);
	__online_page_increment_counters(page);
	__online_page_free(page);

	return 0;
}

static int __init arm64_memory_hotplug_init(void)
{
	set_online_page_callback(&arm64_online_page);
	return 0;
}
core_initcall(arm64_memory_hotplug_init);
#endif /* CONFIG_MEMORY_HOTPLUG */
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ extern int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn,
	unsigned long *valid_start, unsigned long *valid_end);
extern void __offline_isolated_pages(unsigned long, unsigned long);

typedef void (*online_page_callback_t)(struct page *page);
typedef int (*online_page_callback_t)(struct page *page);

extern int set_online_page_callback(online_page_callback_t callback);
extern int restore_online_page_callback(online_page_callback_t callback);
+7 −5
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@
 * and restore_online_page_callback() for generic callback restore.
 */

static void generic_online_page(struct page *page);
static int generic_online_page(struct page *page);

static online_page_callback_t online_page_callback = generic_online_page;
static DEFINE_MUTEX(online_page_callback_lock);
@@ -679,11 +679,12 @@ void __online_page_free(struct page *page)
}
EXPORT_SYMBOL_GPL(__online_page_free);

static void generic_online_page(struct page *page)
static int generic_online_page(struct page *page)
{
	__online_page_set_limits(page);
	__online_page_increment_counters(page);
	__online_page_free(page);
	return 0;
}

static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
@@ -692,11 +693,12 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
	unsigned long i;
	unsigned long onlined_pages = *(unsigned long *)arg;
	struct page *page;

	int ret;
	if (PageReserved(pfn_to_page(start_pfn)))
		for (i = 0; i < nr_pages; i++) {
			page = pfn_to_page(start_pfn + i);
			(*online_page_callback)(page);
			ret = (*online_page_callback)(page);
			if (!ret)
				onlined_pages++;
		}