Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpu updates from Ingo Molnar: "The main changes in this cycle were: - Improved CPU ID handling code and related enhancements (Borislav Petkov) - RDRAND fix (Len Brown)" * 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86: Replace RDRAND forced-reseed with simple sanity check x86/MSR: Chop off lower 32-bit value x86/cpu: Fix MSR value truncation issue x86/cpu/amd, kvm: Satisfy guest kernel reads of IC_CFG MSR kvm: Add accessors for guest CPU's family, model, stepping x86/cpu: Unify CPU family, model, stepping calculation
This commit is contained in:
@@ -678,9 +678,9 @@ static void init_amd_bd(struct cpuinfo_x86 *c)
|
||||
* Disable it on the affected CPUs.
|
||||
*/
|
||||
if ((c->x86_model >= 0x02) && (c->x86_model < 0x20)) {
|
||||
if (!rdmsrl_safe(0xc0011021, &value) && !(value & 0x1E)) {
|
||||
if (!rdmsrl_safe(MSR_F15H_IC_CFG, &value) && !(value & 0x1E)) {
|
||||
value |= 0x1E;
|
||||
wrmsrl_safe(0xc0011021, value);
|
||||
wrmsrl_safe(MSR_F15H_IC_CFG, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -581,14 +581,9 @@ void cpu_detect(struct cpuinfo_x86 *c)
|
||||
u32 junk, tfms, cap0, misc;
|
||||
|
||||
cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
|
||||
c->x86 = (tfms >> 8) & 0xf;
|
||||
c->x86_model = (tfms >> 4) & 0xf;
|
||||
c->x86_mask = tfms & 0xf;
|
||||
|
||||
if (c->x86 == 0xf)
|
||||
c->x86 += (tfms >> 20) & 0xff;
|
||||
if (c->x86 >= 0x6)
|
||||
c->x86_model += ((tfms >> 16) & 0xf) << 4;
|
||||
c->x86 = x86_family(tfms);
|
||||
c->x86_model = x86_model(tfms);
|
||||
c->x86_mask = x86_stepping(tfms);
|
||||
|
||||
if (cap0 & (1<<19)) {
|
||||
c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
|
||||
@@ -1187,7 +1182,7 @@ void syscall_init(void)
|
||||
* They both write to the same internal register. STAR allows to
|
||||
* set CS/DS but only a 32bit target. LSTAR sets the 64bit rip.
|
||||
*/
|
||||
wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
|
||||
wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS);
|
||||
wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64);
|
||||
|
||||
#ifdef CONFIG_IA32_EMULATION
|
||||
|
@@ -129,8 +129,8 @@ void __init load_ucode_bsp(void)
|
||||
if (!have_cpuid_p())
|
||||
return;
|
||||
|
||||
vendor = x86_vendor();
|
||||
family = x86_family();
|
||||
vendor = x86_cpuid_vendor();
|
||||
family = x86_cpuid_family();
|
||||
|
||||
switch (vendor) {
|
||||
case X86_VENDOR_INTEL:
|
||||
@@ -165,8 +165,8 @@ void load_ucode_ap(void)
|
||||
if (!have_cpuid_p())
|
||||
return;
|
||||
|
||||
vendor = x86_vendor();
|
||||
family = x86_family();
|
||||
vendor = x86_cpuid_vendor();
|
||||
family = x86_cpuid_family();
|
||||
|
||||
switch (vendor) {
|
||||
case X86_VENDOR_INTEL:
|
||||
@@ -206,8 +206,8 @@ void reload_early_microcode(void)
|
||||
{
|
||||
int vendor, family;
|
||||
|
||||
vendor = x86_vendor();
|
||||
family = x86_family();
|
||||
vendor = x86_cpuid_vendor();
|
||||
family = x86_cpuid_family();
|
||||
|
||||
switch (vendor) {
|
||||
case X86_VENDOR_INTEL:
|
||||
|
@@ -145,10 +145,10 @@ matching_model_microcode(struct microcode_header_intel *mc_header,
|
||||
int ext_sigcount, i;
|
||||
struct extended_signature *ext_sig;
|
||||
|
||||
fam = __x86_family(sig);
|
||||
fam = x86_family(sig);
|
||||
model = x86_model(sig);
|
||||
|
||||
fam_ucode = __x86_family(mc_header->sig);
|
||||
fam_ucode = x86_family(mc_header->sig);
|
||||
model_ucode = x86_model(mc_header->sig);
|
||||
|
||||
if (fam == fam_ucode && model == model_ucode)
|
||||
@@ -163,7 +163,7 @@ matching_model_microcode(struct microcode_header_intel *mc_header,
|
||||
ext_sigcount = ext_header->count;
|
||||
|
||||
for (i = 0; i < ext_sigcount; i++) {
|
||||
fam_ucode = __x86_family(ext_sig->sig);
|
||||
fam_ucode = x86_family(ext_sig->sig);
|
||||
model_ucode = x86_model(ext_sig->sig);
|
||||
|
||||
if (fam == fam_ucode && model == model_ucode)
|
||||
@@ -365,7 +365,7 @@ static int collect_cpu_info_early(struct ucode_cpu_info *uci)
|
||||
native_cpuid(&eax, &ebx, &ecx, &edx);
|
||||
csig.sig = eax;
|
||||
|
||||
family = __x86_family(csig.sig);
|
||||
family = x86_family(csig.sig);
|
||||
model = x86_model(csig.sig);
|
||||
|
||||
if ((model >= 5) || (family > 6)) {
|
||||
@@ -521,16 +521,12 @@ static bool __init load_builtin_intel_microcode(struct cpio_data *cp)
|
||||
{
|
||||
#ifdef CONFIG_X86_64
|
||||
unsigned int eax = 0x00000001, ebx, ecx = 0, edx;
|
||||
unsigned int family, model, stepping;
|
||||
char name[30];
|
||||
|
||||
native_cpuid(&eax, &ebx, &ecx, &edx);
|
||||
|
||||
family = __x86_family(eax);
|
||||
model = x86_model(eax);
|
||||
stepping = eax & 0xf;
|
||||
|
||||
sprintf(name, "intel-ucode/%02x-%02x-%02x", family, model, stepping);
|
||||
sprintf(name, "intel-ucode/%02x-%02x-%02x",
|
||||
x86_family(eax), x86_model(eax), x86_stepping(eax));
|
||||
|
||||
return get_builtin_firmware(cp, name);
|
||||
#else
|
||||
|
@@ -33,28 +33,27 @@ static int __init x86_rdrand_setup(char *s)
|
||||
__setup("nordrand", x86_rdrand_setup);
|
||||
|
||||
/*
|
||||
* Force a reseed cycle; we are architecturally guaranteed a reseed
|
||||
* after no more than 512 128-bit chunks of random data. This also
|
||||
* acts as a test of the CPU capability.
|
||||
* RDRAND has Built-In-Self-Test (BIST) that runs on every invocation.
|
||||
* Run the instruction a few times as a sanity check.
|
||||
* If it fails, it is simple to disable RDRAND here.
|
||||
*/
|
||||
#define RESEED_LOOP ((512*128)/sizeof(unsigned long))
|
||||
#define SANITY_CHECK_LOOPS 8
|
||||
|
||||
void x86_init_rdrand(struct cpuinfo_x86 *c)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_RANDOM
|
||||
unsigned long tmp;
|
||||
int i, count, ok;
|
||||
int i;
|
||||
|
||||
if (!cpu_has(c, X86_FEATURE_RDRAND))
|
||||
return; /* Nothing to do */
|
||||
return;
|
||||
|
||||
for (count = i = 0; i < RESEED_LOOP; i++) {
|
||||
ok = rdrand_long(&tmp);
|
||||
if (ok)
|
||||
count++;
|
||||
for (i = 0; i < SANITY_CHECK_LOOPS; i++) {
|
||||
if (!rdrand_long(&tmp)) {
|
||||
clear_cpu_cap(c, X86_FEATURE_RDRAND);
|
||||
printk_once(KERN_WARNING "rdrand: disabled\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != RESEED_LOOP)
|
||||
clear_cpu_cap(c, X86_FEATURE_RDRAND);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user