Commit 5adfeaec authored by Kiryl Shutsemau's avatar Kiryl Shutsemau Committed by Andrew Morton
Browse files

mm: rework accept memory helpers

Make accept_memory() and range_contains_unaccepted_memory() take 'start'
and 'size' arguments instead of 'start' and 'end'.

Remove accept_page(), replacing it with direct calls to accept_memory(). 
The accept_page() name is going to be used for a different function.

Link: https://lkml.kernel.org/r/20240809114854.3745464-6-kirill.shutemov@linux.intel.com


Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Suggested-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 310183de
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -511,7 +511,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)

	if (init_unaccepted_memory()) {
		debug_putstr("Accepting memory... ");
		accept_memory(__pa(output), __pa(output) + needed_size);
		accept_memory(__pa(output), needed_size);
	}

	entry_offset = decompress_kernel(output, virt_addr, error);
+1 −1
Original line number Diff line number Diff line
@@ -256,6 +256,6 @@ static inline bool init_unaccepted_memory(void) { return false; }

/* Defined in EFI stub */
extern struct efi_unaccepted_memory *unaccepted_table;
void accept_memory(phys_addr_t start, phys_addr_t end);
void accept_memory(phys_addr_t start, unsigned long size);

#endif /* BOOT_COMPRESSED_MISC_H */
+1 −1
Original line number Diff line number Diff line
@@ -1229,7 +1229,7 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab);
efi_status_t allocate_unaccepted_bitmap(__u32 nr_desc,
					struct efi_boot_memmap *map);
void process_unaccepted_memory(u64 start, u64 end);
void accept_memory(phys_addr_t start, phys_addr_t end);
void accept_memory(phys_addr_t start, unsigned long size);
void arch_accept_memory(phys_addr_t start, phys_addr_t end);

#endif
+2 −1
Original line number Diff line number Diff line
@@ -177,9 +177,10 @@ void process_unaccepted_memory(u64 start, u64 end)
		   start / unit_size, (end - start) / unit_size);
}

void accept_memory(phys_addr_t start, phys_addr_t end)
void accept_memory(phys_addr_t start, unsigned long size)
{
	unsigned long range_start, range_end;
	phys_addr_t end = start + size;
	unsigned long bitmap_size;
	u64 unit_size;

+10 −8
Original line number Diff line number Diff line
@@ -30,11 +30,12 @@ static LIST_HEAD(accepting_list);
 *  - memory that is below phys_base;
 *  - memory that is above the memory that addressable by the bitmap;
 */
void accept_memory(phys_addr_t start, phys_addr_t end)
void accept_memory(phys_addr_t start, unsigned long size)
{
	struct efi_unaccepted_memory *unaccepted;
	unsigned long range_start, range_end;
	struct accept_range range, *entry;
	phys_addr_t end = start + size;
	unsigned long flags;
	u64 unit_size;

@@ -74,13 +75,13 @@ void accept_memory(phys_addr_t start, phys_addr_t end)
	 * "guard" page is accepted in addition to the memory that needs to be
	 * used:
	 *
	 * 1. Implicitly extend the range_contains_unaccepted_memory(start, end)
	 *    checks up to end+unit_size if 'end' is aligned on a unit_size
	 *    boundary.
	 * 1. Implicitly extend the range_contains_unaccepted_memory(start, size)
	 *    checks up to the next unit_size if 'start+size' is aligned on a
	 *    unit_size boundary.
	 *
	 * 2. Implicitly extend accept_memory(start, end) to end+unit_size if
	 *    'end' is aligned on a unit_size boundary. (immediately following
	 *    this comment)
	 * 2. Implicitly extend accept_memory(start, size) to the next unit_size
	 *    if 'size+end' is aligned on a unit_size boundary. (immediately
	 *    following this comment)
	 */
	if (!(end % unit_size))
		end += unit_size;
@@ -156,9 +157,10 @@ void accept_memory(phys_addr_t start, phys_addr_t end)
	spin_unlock_irqrestore(&unaccepted_memory_lock, flags);
}

bool range_contains_unaccepted_memory(phys_addr_t start, phys_addr_t end)
bool range_contains_unaccepted_memory(phys_addr_t start, unsigned long size)
{
	struct efi_unaccepted_memory *unaccepted;
	phys_addr_t end = start + size;
	unsigned long flags;
	bool ret = false;
	u64 unit_size;
Loading