diff options
Diffstat (limited to 'drivers/char/hw_random/via-rng.c')
| -rw-r--r-- | drivers/char/hw_random/via-rng.c | 17 | 
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c index 794aacb715c..de5a6dcfb3e 100644 --- a/drivers/char/hw_random/via-rng.c +++ b/drivers/char/hw_random/via-rng.c @@ -24,17 +24,18 @@   * warranty of any kind, whether express or implied.   */ +#include <crypto/padlock.h>  #include <linux/module.h>  #include <linux/kernel.h>  #include <linux/hw_random.h>  #include <linux/delay.h> +#include <asm/cpu_device_id.h>  #include <asm/io.h>  #include <asm/msr.h>  #include <asm/cpufeature.h>  #include <asm/i387.h> -#define PFX	KBUILD_MODNAME ": "  enum { @@ -81,8 +82,7 @@ static inline u32 xstore(u32 *addr, u32 edx_in)  	ts_state = irq_ts_save();  	asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" -		:"=m"(*addr), "=a"(eax_out) -		:"D"(addr), "d"(edx_in)); +		: "=m" (*addr), "=a" (eax_out), "+d" (edx_in), "+D" (addr));  	irq_ts_restore(ts_state);  	return eax_out; @@ -90,8 +90,10 @@ static inline u32 xstore(u32 *addr, u32 edx_in)  static int via_rng_data_present(struct hwrng *rng, int wait)  { +	char buf[16 + PADLOCK_ALIGNMENT - STACK_ALIGN] __attribute__ +		((aligned(STACK_ALIGN))); +	u32 *via_rng_datum = (u32 *)PTR_ALIGN(&buf[0], PADLOCK_ALIGNMENT);  	u32 bytes_out; -	u32 *via_rng_datum = (u32 *)(&rng->priv);  	int i;  	/* We choose the recommended 1-byte-per-instruction RNG rate, @@ -115,6 +117,7 @@ static int via_rng_data_present(struct hwrng *rng, int wait)  			break;  		udelay(10);  	} +	rng->priv = *via_rng_datum;  	return bytes_out ? 1 : 0;  } @@ -218,5 +221,11 @@ static void __exit mod_exit(void)  module_init(mod_init);  module_exit(mod_exit); +static struct x86_cpu_id __maybe_unused via_rng_cpu_id[] = { +	X86_FEATURE_MATCH(X86_FEATURE_XSTORE), +	{} +}; +  MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock");  MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(x86cpu, via_rng_cpu_id);  | 
