add Via Nehemiah ("xstore") rng support
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · H. Peter Anvin
In article <[email protected]> of
linux.dev.kernel, you write:Quoted 6 lines
diff -Nru a/drivers/char/Kconfig b/drivers/char/Kconfig
drivers/char/Kconfig +0
-0@@ -710,7 +710,7 @@ If you're not sure, say N.
Quoted 10 lines
Quoted 6 lines
config
HW_RANDOMdrivers/char/Kconfig +1
-1- tristate "Intel/AMD H/W Random Number Generator support" + tristate "Intel/AMD/Via H/W Random Number Generator support"depends on (X86 || IA64) && PCI ---help--- This driver provides kernel-side support for the Random NumberHow about changing this to "HW Random Number Generator"?
easily done.
Quoted 17 lines
drivers/char/Kconfig
Quoted 10 lines
drivers/char/Kconfig +10
-0+static inline u32 xstore(u32 *addr, u32 edx_in) +{ + u32 eax_out; + + asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" + :"=m"(*addr), "=a"(eax_out) + :"D"(addr), "d"(edx_in)); + + return eax_out; +}Note that your "=m" (*addr) is never actually used here -- it doesn't affect the instruction encoding, and it only shows up in a comment. Since gcc will generate an instruction mode here, it will be highly confused.
Quoted 3 lines
I am assuming
0xC0is a modr/m byte, in which case the most sane interpretation of this instruction would be "xstore %eax"; %edi is presumably implicit since you claim it can take a REP prefix...
and yet strangely the asm code seems to be correct :)
.p2align 4,,15
.type via_data_present,@function
via_data_present:
pushl %edi
xorl %edi, %edi # zero edi
movl $3, %edx # edx_in
movl %edi, via_rng_datum # zero via_rng_datum
movl $via_rng_datum, %edi # addr
#APP
.byte 0x0F,0xA7,0xC0 /* xstore %edi (addr=via_rng_datum) */
#NO_APP
popl %edi
andl $15, %eax # eax_out
setne %al
movzbl %al, %eaxret
Quoted 6 lines · Jeff Garzik
Quoted 6 lines
Note that your "=m" (*addr) is never actually used here -- it doesn't affect the instruction encoding, and it only shows up in a comment. Since gcc will generate an instruction mode here, it will be highly confused.
Quoted 7 lines
Quoted 3 lines
I am assuming
0xC0is a modr/m byte, in which case the most sane interpretation of this instruction would be "xstore %eax"; %edi is presumably implicit since you claim it can take a REP prefix...and yet strangely the asm code seems to be correct :)
Right... I got confused by the comment (the one inside the asm) and the fact that "addr" appeared twice. I think it's a bad comment; it draws attention to the wrong thing.
-hpa