[PATCH] KASLR: change code
From: Baoquan He
Date: Wed Dec 06 2017 - 04:24:55 EST
Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
---
arch/x86/boot/compressed/kaslr.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 13d26b859c69..73b1562a7439 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -638,13 +638,23 @@ static bool process_immovable_mem(struct mem_vector region,
unsigned long long minimum,
unsigned long long image_size)
{
- int i;
+ /* If no immovable_mem stored, use region directly */
+ if (num_immovable_region == 0) {
+ process_mem_region(&entry, minimum, image_size);
+
+ if (slot_area_index == MAX_SLOT_AREA) {
+ debug_putstr("Aborted memmap scan (slot_areas full)!\n");
+ return 1;
+ }
+
+ return 0;
+ }
/*
* Walk all immovable regions, and filter the intersection
* to process_mem_region.
*/
- for (i = 0; i < num_immovable_region; i++) {
+ for (int i = 0; i < num_immovable_region; i++) {
struct mem_vector entry;
unsigned long long start, end, entry_end;
@@ -738,14 +748,7 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
region.start = md->phys_addr;
region.size = md->num_pages << EFI_PAGE_SHIFT;
- /* If no immovable_mem stored, use region directly */
- if (num_immovable_region == 0) {
- process_mem_region(®ion, minimum, image_size);
- if (slot_area_index == MAX_SLOT_AREA) {
- debug_putstr("Aborted memmap scan (slot_areas full)!\n");
- break;
- }
- } else if (process_immovable_mem(region, minimum, image_size))
+ if (process_immovable_mem(region, minimum, image_size))
break;
}
return true;
@@ -774,14 +777,7 @@ static void process_e820_entries(unsigned long minimum,
region.start = entry->addr;
region.size = entry->size;
- /* If no immovable_mem stored, use region directly */
- if (num_immovable_region == 0) {
- process_mem_region(®ion, minimum, image_size);
- if (slot_area_index == MAX_SLOT_AREA) {
- debug_putstr("Aborted memmap scan (slot_areas full)!\n");
- break;
- }
- } else if (process_immovable_mem(region, minimum, image_size))
+ if (process_immovable_mem(region, minimum, image_size))
break;
}
}
--
2.5.5