Messages in this thread | | | From | David Laight <> | Subject | RE: [PATCH] x86/entry/64: randomize kernel stack offset upon syscall | Date | Fri, 3 May 2019 16:40:53 +0000 |
| |
From: Reshetova, Elena > Sent: 03 May 2019 17:17 ... > rdrand (calling every 8 syscalls): Simple syscall: 0.0795 microseconds
You could try something like: u64 rand_val = cpu_var->syscall_rand
while (unlikely(rand_val == 0)) rand_val = rdrand64();
stack_offset = rand_val & 0xff; rand_val >>= 6; if (likely(rand_val >= 4)) cpu_var->syscall_rand = rand_val; else cpu_var->syscall_rand = rdrand64();
return stack_offset;
That gives you 10 system calls per rdrand instruction and mostly takes the latency out of line.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
| |