Commit 5924bbec authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar:
 "Three fixes:

   - AMD microcode loading fix with randomization

   - an lguest tooling fix

   - and an APIC enumeration boundary condition fix"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/apic: Fix num_processors value in case of failure
  tools/lguest: Don't bork the terminal in case of wrong args
  x86/microcode/AMD: Fix load of builtin microcode with randomized memory
parents fda67514 c291b015
...@@ -2093,7 +2093,6 @@ int generic_processor_info(int apicid, int version) ...@@ -2093,7 +2093,6 @@ int generic_processor_info(int apicid, int version)
return -EINVAL; return -EINVAL;
} }
num_processors++;
if (apicid == boot_cpu_physical_apicid) { if (apicid == boot_cpu_physical_apicid) {
/* /*
* x86_bios_cpu_apicid is required to have processors listed * x86_bios_cpu_apicid is required to have processors listed
...@@ -2116,10 +2115,13 @@ int generic_processor_info(int apicid, int version) ...@@ -2116,10 +2115,13 @@ int generic_processor_info(int apicid, int version)
pr_warning("APIC: Package limit reached. Processor %d/0x%x ignored.\n", pr_warning("APIC: Package limit reached. Processor %d/0x%x ignored.\n",
thiscpu, apicid); thiscpu, apicid);
disabled_cpus++; disabled_cpus++;
return -ENOSPC; return -ENOSPC;
} }
num_processors++;
/* /*
* Validate version * Validate version
*/ */
......
...@@ -54,6 +54,7 @@ static LIST_HEAD(pcache); ...@@ -54,6 +54,7 @@ static LIST_HEAD(pcache);
*/ */
static u8 *container; static u8 *container;
static size_t container_size; static size_t container_size;
static bool ucode_builtin;
static u32 ucode_new_rev; static u32 ucode_new_rev;
static u8 amd_ucode_patch[PATCH_MAX_SIZE]; static u8 amd_ucode_patch[PATCH_MAX_SIZE];
...@@ -281,18 +282,22 @@ static bool __init load_builtin_amd_microcode(struct cpio_data *cp, ...@@ -281,18 +282,22 @@ static bool __init load_builtin_amd_microcode(struct cpio_data *cp,
void __init load_ucode_amd_bsp(unsigned int family) void __init load_ucode_amd_bsp(unsigned int family)
{ {
struct cpio_data cp; struct cpio_data cp;
bool *builtin;
void **data; void **data;
size_t *size; size_t *size;
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
data = (void **)__pa_nodebug(&ucode_cpio.data); data = (void **)__pa_nodebug(&ucode_cpio.data);
size = (size_t *)__pa_nodebug(&ucode_cpio.size); size = (size_t *)__pa_nodebug(&ucode_cpio.size);
builtin = (bool *)__pa_nodebug(&ucode_builtin);
#else #else
data = &ucode_cpio.data; data = &ucode_cpio.data;
size = &ucode_cpio.size; size = &ucode_cpio.size;
builtin = &ucode_builtin;
#endif #endif
if (!load_builtin_amd_microcode(&cp, family)) *builtin = load_builtin_amd_microcode(&cp, family);
if (!*builtin)
cp = find_ucode_in_initrd(); cp = find_ucode_in_initrd();
if (!(cp.data && cp.size)) if (!(cp.data && cp.size))
...@@ -373,7 +378,8 @@ void load_ucode_amd_ap(void) ...@@ -373,7 +378,8 @@ void load_ucode_amd_ap(void)
return; return;
/* Add CONFIG_RANDOMIZE_MEMORY offset. */ /* Add CONFIG_RANDOMIZE_MEMORY offset. */
cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; if (!ucode_builtin)
cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
eax = cpuid_eax(0x00000001); eax = cpuid_eax(0x00000001);
eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ);
...@@ -439,7 +445,8 @@ int __init save_microcode_in_initrd_amd(void) ...@@ -439,7 +445,8 @@ int __init save_microcode_in_initrd_amd(void)
container = cont_va; container = cont_va;
/* Add CONFIG_RANDOMIZE_MEMORY offset. */ /* Add CONFIG_RANDOMIZE_MEMORY offset. */
container += PAGE_OFFSET - __PAGE_OFFSET_BASE; if (!ucode_builtin)
container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
eax = cpuid_eax(0x00000001); eax = cpuid_eax(0x00000001);
eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
......
...@@ -3266,6 +3266,9 @@ int main(int argc, char *argv[]) ...@@ -3266,6 +3266,9 @@ int main(int argc, char *argv[])
} }
} }
/* If we exit via err(), this kills all the threads, restores tty. */
atexit(cleanup_devices);
/* We always have a console device, and it's always device 1. */ /* We always have a console device, and it's always device 1. */
setup_console(); setup_console();
...@@ -3369,9 +3372,6 @@ int main(int argc, char *argv[]) ...@@ -3369,9 +3372,6 @@ int main(int argc, char *argv[])
/* Ensure that we terminate if a device-servicing child dies. */ /* Ensure that we terminate if a device-servicing child dies. */
signal(SIGCHLD, kill_launcher); signal(SIGCHLD, kill_launcher);
/* If we exit via err(), this kills all the threads, restores tty. */
atexit(cleanup_devices);
/* If requested, chroot to a directory */ /* If requested, chroot to a directory */
if (chroot_path) { if (chroot_path) {
if (chroot(chroot_path) != 0) if (chroot(chroot_path) != 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment