Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4191985ybi; Tue, 18 Jun 2019 13:32:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHUtb87tikqhhw3PvEqg35hRZxGDoQdMo7WM9PdeidIslFdy0h1ln54ZVJXxwOgDnMGVah X-Received: by 2002:a17:90a:216f:: with SMTP id a102mr7291402pje.29.1560889931083; Tue, 18 Jun 2019 13:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560889931; cv=none; d=google.com; s=arc-20160816; b=JZvZijW/uXOof+2QqTbNZ0Ys+1NThB+ipaAw12ogUyM4rjZZFkbpN8uUeY4BIFBrmr RQCVFdFrKijdFh9qTY+C81Prsd0HWfoSdPo/CgEc6x9mHpO05KqfgyHf9Jc9zGImjkfe wVLIfkR8q632vYnTwuVAZG+j5MGl7bbmlPCVMRJCddurrt12Jp3eh+QPcdlrl0sPJSNn S0L9Fh5gZOQ+QlKFDfid0iQJAM+wjEiNASOPKFji5uinP+OxCt/8DZzjvD1k3iZObeQC 7LOQZcrYou/GR60qyd1o71nyPReejIPCqESJuutZiaxh59XHkG3V4I0TsQ5q2TUuGBDt 3Qug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date; bh=6Cud0zpdRiMch5W2M69On3SnN8mIuqF8niryQfMe8sc=; b=UvR0l3QTziVFaMelio+G8C8ecuw2aEfPdgN2LkyXGMwrOtw/rCiqpbciKCLHdH2Bzw VCaGk29juzGcuNJxzE80cDgsPQtZRmEmOBdnoCpcCkqxvETtBiNdsckAr4lvP/ETnV3V YaqSTi0OEr9tSAsbi9Spzn+bdeV2jX8b7TaffalpGeIldcs0e0otnXxMTa2GpksErqWe DHgARU9jQ9VaKifZ7yvzcG14uJrHk2eDr2Z26GhjPT5XbRnRGJVh+KWwfYNPTh82/9Ew QQZN/808U/ERu0SwpmuRXdlosRoH7pFpizu/q1eBZ1Tf9xi/6BIm7W9jyZBD47pKmGd4 Rttg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i94si3586836plb.78.2019.06.18.13.31.54; Tue, 18 Jun 2019 13:32:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730555AbfFRUbs (ORCPT + 99 others); Tue, 18 Jun 2019 16:31:48 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:48706 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729961AbfFRUbs (ORCPT ); Tue, 18 Jun 2019 16:31:48 -0400 Received: from p5b06daab.dip0.t-ipconnect.de ([91.6.218.171] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hdKld-0002Cf-QM; Tue, 18 Jun 2019 22:31:45 +0200 Date: Tue, 18 Jun 2019 22:31:40 +0200 (CEST) From: Thomas Gleixner To: LKML cc: x86@kernel.org, Borislav Petkov Subject: [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent change moved the microcode loader hotplug callback into the early startup phase, which is running with interrupts disabled. It missed that the callbacks invoke sysfs functions which might sleep causing nice 'might sleep' splats with proper debugging enabled. Split the callbacks and only load the microcode in the early startup phase and move the sysfs handling back into the later threaded and preemptible bringup phase where it was before. Fixes: 78f4e932f776 ("x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback") Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org --- arch/x86/kernel/cpu/microcode/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -789,13 +789,16 @@ static struct syscore_ops mc_syscore_ops .resume = mc_bp_resume, }; -static int mc_cpu_online(unsigned int cpu) +static int mc_cpu_starting(unsigned int cpu) { - struct device *dev; - - dev = get_cpu_device(cpu); microcode_update_cpu(cpu); pr_debug("CPU%d added\n", cpu); + return 0; +} + +static int mc_cpu_online(unsigned int cpu) +{ + struct device *dev = get_cpu_device(cpu); if (sysfs_create_group(&dev->kobj, &mc_attr_group)) pr_err("Failed to create group for CPU%d\n", cpu); @@ -872,7 +875,9 @@ int __init microcode_init(void) goto out_ucode_group; register_syscore_ops(&mc_syscore_ops); - cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:online", + cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting", + mc_cpu_starting, NULL); + cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online", mc_cpu_online, mc_cpu_down_prep); pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);