Skip to content

Commit d6d0f36

Browse files
nivedita76ingomolnar
authored andcommitted
x86/kaslr: Make the type of number of slots/slot areas consistent
The number of slots can be 'unsigned int', since on 64-bit, the maximum amount of memory is 2^52, the minimum alignment is 2^21, so the slot number cannot be greater than 2^31. But in case future processors have more than 52 physical address bits, make it 'unsigned long'. The slot areas are limited by MAX_SLOT_AREA, currently 100. It is indexed by an int, but the number of areas is stored as 'unsigned long'. Change both to 'unsigned int' for consistency. Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20200728225722.67457-15-nivedita@alum.mit.edu
1 parent 3870d97 commit d6d0f36

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

arch/x86/boot/compressed/kaslr.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,15 @@ static bool mem_avoid_overlap(struct mem_vector *img,
508508

509509
struct slot_area {
510510
unsigned long addr;
511-
int num;
511+
unsigned long num;
512512
};
513513

514514
#define MAX_SLOT_AREA 100
515515

516516
static struct slot_area slot_areas[MAX_SLOT_AREA];
517-
517+
static unsigned int slot_area_index;
518518
static unsigned long slot_max;
519519

520-
static unsigned long slot_area_index;
521-
522520
static void store_slot_info(struct mem_vector *region, unsigned long image_size)
523521
{
524522
struct slot_area slot_area;
@@ -588,7 +586,7 @@ process_gb_huge_pages(struct mem_vector *region, unsigned long image_size)
588586
static unsigned long slots_fetch_random(void)
589587
{
590588
unsigned long slot;
591-
int i;
589+
unsigned int i;
592590

593591
/* Handle case of no slots stored. */
594592
if (slot_max == 0)

0 commit comments

Comments
 (0)