aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/boot/compressed/aslr.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
index 8746487fa916..38a07cc4fbac 100644
--- a/arch/x86/boot/compressed/aslr.c
+++ b/arch/x86/boot/compressed/aslr.c
@@ -64,6 +64,11 @@ static unsigned long get_random_boot(void)
64 64
65static unsigned long get_random_long(void) 65static unsigned long get_random_long(void)
66{ 66{
67#ifdef CONFIG_X86_64
68 const unsigned long mix_const = 0x5d6008cbf3848dd3UL;
69#else
70 const unsigned long mix_const = 0x3f39e593UL;
71#endif
67 unsigned long raw, random = get_random_boot(); 72 unsigned long raw, random = get_random_boot();
68 bool use_i8254 = true; 73 bool use_i8254 = true;
69 74
@@ -90,6 +95,12 @@ static unsigned long get_random_long(void)
90 random ^= i8254(); 95 random ^= i8254();
91 } 96 }
92 97
98 /* Circular multiply for better bit diffusion */
99 asm("mul %3"
100 : "=a" (random), "=d" (raw)
101 : "a" (random), "rm" (mix_const));
102 random += raw;
103
93 debug_putstr("...\n"); 104 debug_putstr("...\n");
94 105
95 return random; 106 return random;