[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1536201382-13133-2-git-send-email-kernelfans@gmail.com>
Date: Thu, 6 Sep 2018 10:36:20 +0800
From: Pingfan Liu <kernelfans@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Pingfan Liu <kernelfans@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Baoquan He <bhe@...hat.com>,
Chao Fan <fanc.fnst@...fujitsu.com>, x86@...nel.org
Subject: [PATCH 1/3] x86/boot/KASLR: change the prototypes of process_efi_entries/process_e820_entries
Changing the prototypes of process_efi_entries/process_e820_entries in
order to reuse the mem entries' iteration (used in patch 3/3).
Signed-off-by: Pingfan Liu <kernelfans@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Baoquan He <bhe@...hat.com>
Cc: Chao Fan <fanc.fnst@...fujitsu.com> (authored:1/16=6%)
Cc: x86@...nel.org
---
arch/x86/boot/compressed/kaslr.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index d1e19f3..5185267 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -573,6 +573,10 @@ static unsigned long slots_fetch_random(void)
return 0;
}
+typedef void (*handles_mem_region)(struct mem_vector *entry,
+ unsigned long minimum,
+ unsigned long image_size);
+
static void process_mem_region(struct mem_vector *entry,
unsigned long minimum,
unsigned long image_size)
@@ -658,7 +662,8 @@ static void process_mem_region(struct mem_vector *entry,
* for slots adding)
*/
static bool
-process_efi_entries(unsigned long minimum, unsigned long image_size)
+process_efi_entries(unsigned long minimum, unsigned long image_size,
+ handles_mem_region handle)
{
struct efi_info *e = &boot_params->efi_info;
bool efi_mirror_found = false;
@@ -717,7 +722,7 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
region.start = md->phys_addr;
region.size = md->num_pages << EFI_PAGE_SHIFT;
- process_mem_region(®ion, minimum, image_size);
+ (*handle)(®ion, minimum, image_size);
if (slot_area_index == MAX_SLOT_AREA) {
debug_putstr("Aborted EFI scan (slot_areas full)!\n");
break;
@@ -727,14 +732,15 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
}
#else
static inline bool
-process_efi_entries(unsigned long minimum, unsigned long image_size)
+process_efi_entries(unsigned long minimum, unsigned long image_size,
+ handles_mem_region handle)
{
return false;
}
#endif
static void process_e820_entries(unsigned long minimum,
- unsigned long image_size)
+ unsigned long image_size, handles_mem_region handle)
{
int i;
struct mem_vector region;
@@ -748,7 +754,7 @@ static void process_e820_entries(unsigned long minimum,
continue;
region.start = entry->addr;
region.size = entry->size;
- process_mem_region(®ion, minimum, image_size);
+ (*handle)(®ion, minimum, image_size);
if (slot_area_index == MAX_SLOT_AREA) {
debug_putstr("Aborted e820 scan (slot_areas full)!\n");
break;
@@ -768,10 +774,10 @@ static unsigned long find_random_phys_addr(unsigned long minimum,
/* Make sure minimum is aligned. */
minimum = ALIGN(minimum, CONFIG_PHYSICAL_ALIGN);
- if (process_efi_entries(minimum, image_size))
+ if (process_efi_entries(minimum, image_size, process_mem_region))
return slots_fetch_random();
- process_e820_entries(minimum, image_size);
+ process_e820_entries(minimum, image_size, process_mem_region);
return slots_fetch_random();
}
--
2.7.4
Powered by blists - more mailing lists