static const char __init *ep93xx_get_soc_id(void) { unsigned int id, id2, id3, id4, id5; if (__raw_readl(EP93XX_SECURITY_UNIQVAL) != 1) return "bad Hamming code"; id = __raw_readl(EP93XX_SECURITY_UNIQID); id2 = __raw_readl(EP93XX_SECURITY_UNIQID2); id3 = __raw_readl(EP93XX_SECURITY_UNIQID3); id4 = __raw_readl(EP93XX_SECURITY_UNIQID4); id5 = __raw_readl(EP93XX_SECURITY_UNIQID5); if (id != id2) return "invalid"; /* Toss the unique ID into the entropy pool */ add_device_randomness(&id2, 4); add_device_randomness(&id3, 4); add_device_randomness(&id4, 4); add_device_randomness(&id5, 4); snprintf(ep93xx_soc_id, sizeof(ep93xx_soc_id), "%08x%08x%08x%08x", id2, id3, id4, id5); return ep93xx_soc_id; }
static void __init db8500_add_gpios(struct device *parent) { struct nmk_gpio_platform_data pdata = { .supports_sleepmode = true, }; dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base), IRQ_DB8500_GPIO0, &pdata); dbx500_add_pinctrl(parent, "pinctrl-db8500", U8500_PRCMU_BASE); } static int usb_db8500_dma_cfg[] = { DB8500_DMA_DEV38_USB_OTG_IEP_AND_OEP_1_9, DB8500_DMA_DEV37_USB_OTG_IEP_AND_OEP_2_10, DB8500_DMA_DEV36_USB_OTG_IEP_AND_OEP_3_11, DB8500_DMA_DEV19_USB_OTG_IEP_AND_OEP_4_12, DB8500_DMA_DEV18_USB_OTG_IEP_AND_OEP_5_13, DB8500_DMA_DEV17_USB_OTG_IEP_AND_OEP_6_14, DB8500_DMA_DEV16_USB_OTG_IEP_AND_OEP_7_15, DB8500_DMA_DEV39_USB_OTG_IEP_AND_OEP_8 }; static const char *db8500_read_soc_id(void) { void __iomem *uid = __io_address(U8500_BB_UID_BASE); /* Throw these device-specific numbers into the entropy pool */ add_device_randomness(uid, 0x14); return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", readl((u32 *)uid+0), readl((u32 *)uid+1), readl((u32 *)uid+2), readl((u32 *)uid+3), readl((u32 *)uid+4)); }
/* * These are both called with the siglock held, when the current thread * is being reaped. When the final (leader) thread in the group is reaped, * posix_cpu_timers_exit_group will be called after posix_cpu_timers_exit. */ void posix_cpu_timers_exit(struct task_struct *tsk) { add_device_randomness((const void*) &tsk->se.sum_exec_runtime, sizeof(unsigned long long)); cleanup_timers(tsk->cpu_timers); }
static int mpu3050_hw_init(struct mpu3050 *mpu3050) { int ret; u8 otp[8]; /* Reset */ ret = regmap_update_bits(mpu3050->map, MPU3050_PWR_MGM, MPU3050_PWR_MGM_RESET, MPU3050_PWR_MGM_RESET); if (ret) return ret; /* Turn on the PLL */ ret = regmap_update_bits(mpu3050->map, MPU3050_PWR_MGM, MPU3050_PWR_MGM_CLKSEL_MASK, MPU3050_PWR_MGM_PLL_Z); if (ret) return ret; /* Disable IRQs */ ret = regmap_write(mpu3050->map, MPU3050_INT_CFG, 0); if (ret) return ret; /* Read out the 8 bytes of OTP (one-time-programmable) memory */ ret = mpu3050_read_mem(mpu3050, (MPU3050_MEM_PRFTCH | MPU3050_MEM_USER_BANK | MPU3050_MEM_OTP_BANK_0), 0, sizeof(otp), otp); if (ret) return ret; /* This is device-unique data so it goes into the entropy pool */ add_device_randomness(otp, sizeof(otp)); dev_info(mpu3050->dev, "die ID: %04X, wafer ID: %02X, A lot ID: %04X, " "W lot ID: %03X, WP ID: %01X, rev ID: %02X\n", /* Die ID, bits 0-12 */ (otp[1] << 8 | otp[0]) & 0x1fff, /* Wafer ID, bits 13-17 */ ((otp[2] << 8 | otp[1]) & 0x03e0) >> 5, /* A lot ID, bits 18-33 */ ((otp[4] << 16 | otp[3] << 8 | otp[2]) & 0x3fffc) >> 2, /* W lot ID, bits 34-45 */ ((otp[5] << 8 | otp[4]) & 0x3ffc) >> 2, /* WP ID, bits 47-49 */ ((otp[6] << 8 | otp[5]) & 0x0380) >> 7, /* rev ID, bits 50-55 */ otp[6] >> 2); return 0; }
/* * These are both called with the siglock held, when the current thread * is being reaped. When the final (leader) thread in the group is reaped, * posix_cpu_timers_exit_group will be called after posix_cpu_timers_exit. */ void posix_cpu_timers_exit(struct task_struct *tsk) { cputime_t utime, stime; add_device_randomness((const void*) &tsk->se.sum_exec_runtime, sizeof(unsigned long long)); task_cputime(tsk, &utime, &stime); cleanup_timers(tsk->cpu_timers, utime, stime, tsk->se.sum_exec_runtime); }
static const char *db8500_read_soc_id(void) { void __iomem *uid = __io_address(U8500_BB_UID_BASE); /* Throw these device-specific numbers into the entropy pool */ add_device_randomness(uid, 0x14); return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", readl((u32 *)uid+0), readl((u32 *)uid+1), readl((u32 *)uid+2), readl((u32 *)uid+3), readl((u32 *)uid+4)); }
static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, void *)) { u8 *buf; buf = dmi_ioremap(dmi_base, dmi_len); if (buf == NULL) return -1; dmi_table(buf, dmi_len, dmi_num, decode, NULL); add_device_randomness(buf, dmi_len); dmi_iounmap(buf, dmi_len); return 0; }
static void __init tegra20_fuse_add_randomness(void) { u32 randomness[7]; randomness[0] = tegra_sku_info.sku_id; randomness[1] = tegra_read_straps(); randomness[2] = tegra_read_chipid(); randomness[3] = tegra_sku_info.cpu_process_id << 16; randomness[3] |= tegra_sku_info.core_process_id; randomness[4] = tegra_sku_info.cpu_speedo_id << 16; randomness[4] |= tegra_sku_info.soc_speedo_id; randomness[5] = tegra20_fuse_early(FUSE_UID_LOW); randomness[6] = tegra20_fuse_early(FUSE_UID_HIGH); add_device_randomness(randomness, sizeof(randomness)); }
static void wm831x_rtc_add_randomness(struct wm831x *wm831x) { int ret; u16 reg; /* * The write counter contains a pseudo-random number which is * regenerated every time we set the RTC so it should be a * useful per-system source of entropy. */ ret = wm831x_reg_read(wm831x, WM831X_RTC_WRITE_COUNTER); if (ret >= 0) { reg = ret; add_device_randomness(®, sizeof(reg)); } else { dev_warn(wm831x->dev, "Failed to read RTC write counter: %d\n", ret); } }
static void __init tegra30_fuse_add_randomness(void) { u32 randomness[12]; randomness[0] = tegra_sku_info.sku_id; randomness[1] = tegra_read_straps(); randomness[2] = tegra_read_chipid(); randomness[3] = tegra_sku_info.cpu_process_id << 16; randomness[3] |= tegra_sku_info.core_process_id; randomness[4] = tegra_sku_info.cpu_speedo_id << 16; randomness[4] |= tegra_sku_info.soc_speedo_id; randomness[5] = tegra30_fuse_readl(FUSE_VENDOR_CODE); randomness[6] = tegra30_fuse_readl(FUSE_FAB_CODE); randomness[7] = tegra30_fuse_readl(FUSE_LOT_CODE_0); randomness[8] = tegra30_fuse_readl(FUSE_LOT_CODE_1); randomness[9] = tegra30_fuse_readl(FUSE_WAFER_ID); randomness[10] = tegra30_fuse_readl(FUSE_X_COORDINATE); randomness[11] = tegra30_fuse_readl(FUSE_Y_COORDINATE); add_device_randomness(randomness, sizeof(randomness)); }