efi/libstub: Add random.c to ARM build
Make random.c build for ARM by moving the fallback definition of EFI_ALLOC_ALIGN to efistub.h, and replacing a division by a value we know to be a power of 2 with a right shift (this is required since ARM does not have any integer division helper routines in its decompressor) Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk> Reviewed-by: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20161112213237.8804-5-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:

committed by
Ingo Molnar

parent
636259880a
commit
a6a144698d
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/efi.h>
|
||||
#include <linux/log2.h>
|
||||
#include <asm/efi.h>
|
||||
|
||||
#include "efistub.h"
|
||||
@@ -41,8 +42,9 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg,
|
||||
*/
|
||||
static unsigned long get_entry_num_slots(efi_memory_desc_t *md,
|
||||
unsigned long size,
|
||||
unsigned long align)
|
||||
unsigned long align_shift)
|
||||
{
|
||||
unsigned long align = 1UL << align_shift;
|
||||
u64 start, end;
|
||||
|
||||
if (md->type != EFI_CONVENTIONAL_MEMORY)
|
||||
@@ -55,7 +57,7 @@ static unsigned long get_entry_num_slots(efi_memory_desc_t *md,
|
||||
if (start > end)
|
||||
return 0;
|
||||
|
||||
return (end - start + 1) / align;
|
||||
return (end - start + 1) >> align_shift;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -98,7 +100,7 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
|
||||
efi_memory_desc_t *md = (void *)memory_map + map_offset;
|
||||
unsigned long slots;
|
||||
|
||||
slots = get_entry_num_slots(md, size, align);
|
||||
slots = get_entry_num_slots(md, size, ilog2(align));
|
||||
MD_NUM_SLOTS(md) = slots;
|
||||
total_slots += slots;
|
||||
}
|
||||
|
Reference in New Issue
Block a user