From patchwork Fri Dec 16 10:45:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 9477705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9EE2D6047D for ; Fri, 16 Dec 2016 10:48:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B71028787 for ; Fri, 16 Dec 2016 10:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8055F28795; Fri, 16 Dec 2016 10:48:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F3CF128787 for ; Fri, 16 Dec 2016 10:48:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHq1l-0005as-Dg; Fri, 16 Dec 2016 10:46:13 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHq1k-0005af-64 for xen-devel@lists.xenproject.org; Fri, 16 Dec 2016 10:46:12 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id C7/73-25337-3F5C3585; Fri, 16 Dec 2016 10:46:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOIsWRWlGSWpSXmKPExsVyuP0Ov+6no8E RBp/2q1t83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmXjvxmLDjLX/Fw3kzWBsZvPF2MnBwSAkYS byf+YwKxhQQWMkpcnyAHYadLnPq8nhXEZhFQlej938IOYrMJKEn8/rQOzBYRUJb42NoLZHNxM AvMYJTYs3gJWxcjB4ewgJXE5tdpIDW8AqYSJ2bvZgWpERK4xSyxb/ZBVoiEoMTJmU9YQGxmAX WJP/MuMYP0MgtISyz/xwERlpdo3jobLMwpYCOx9V8NSFhUQEVi1uU5LBMYBWYhGTQLyaBZCIN mIRm0gJFlFaNGcWpRWWqRrpGJXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGYMAy AMEOxpXrAg8xSnIwKYnyLt8RHCHEl5SfUpmRWJwRX1Sak1p8iFGDg0Ng89rVFxilWPLy81KVJ HhNgJEhJFiUmp5akZaZA4wpmFIJDh4lEd6FR4DSvMUFibnFmekQqVOMuhzTni1+yiQENkNKnN cSZIYASFFGaR7cCFh8X2KUlRLmZQQ6UIinILUoN7MEVf4VozgHo5Iw7wGQVTyZeSVwm14BHcE EdITFPLAjShIRUlINjOazrfhuisja235e/VRepCPs6rZIec0pDTe+PRZmlv5/56nzvcwpyVWP jtUW6uTUBT3etyHpbfdzUdlnuwSL/1z8ULqrYPNCwzWHXqSUCBxdITrRR2KmYfSOy38bKpSa/ y58HL3yzZt37Ida+9bKdc5TCBAtu7BRvMe8ptq+5lLk1EhGJT5jHyWW4oxEQy3mouJEANMGBU zqAgAA X-Env-Sender: bp@suse.de X-Msg-Ref: server-13.tower-27.messagelabs.com!1481885170!68260994!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5116 invoked from network); 16 Dec 2016 10:46:10 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-13.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Dec 2016 10:46:10 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DA577AAC7; Fri, 16 Dec 2016 10:45:09 +0000 (UTC) Received: by pd.tnic (Postfix, from userid 1000) id 3EF2E160EE6; Fri, 16 Dec 2016 11:45:05 +0100 (CET) Date: Fri, 16 Dec 2016 11:45:05 +0100 From: Borislav Petkov To: Juergen Gross Message-ID: <20161216104505.lk3s7fc7brrnmbq3@pd.tnic> References: <20161215164635.thm7ruio2ddnxszw@pd.tnic> <20161215171755.xpfuax7a6q3jofet@pd.tnic> <20161215173609.ornfok6lk5oro2pj@pd.tnic> <20161216090228.ri4alokiaagqtibt@pd.tnic> <29d252b8-67ff-bd61-f274-0ed75708cd55@suse.com> <20161216094326.bnkr5a2k3njmdeyi@pd.tnic> <7ca8a9b9-e374-8052-6be3-d3eda78c891a@suse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7ca8a9b9-e374-8052-6be3-d3eda78c891a@suse.com> User-Agent: NeoMutt/20161014 (1.7.1) Cc: xen-devel , Boris Ostrovsky , Linux Kernel Mailing List Subject: Re: [Xen-devel] Can't boot as Xen dom0 due to commit fe055896 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Dec 16, 2016 at 11:00:29AM +0100, Juergen Gross wrote: > Should work. I'm happy to test any patch. :-) I'm happy that you're happy to! :-) Let's try this below. Thanks! Tested-by: Juergen Gross Acked-by: Juergen Gross diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 6996413c78c3..c4bb2f7169f6 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -44,7 +44,7 @@ #define DRIVER_VERSION "2.2" static struct microcode_ops *microcode_ops; -static bool dis_ucode_ldr; +static bool dis_ucode_ldr = true; LIST_HEAD(microcode_cache); @@ -76,6 +76,7 @@ struct cpu_info_ctx { static bool __init check_loader_disabled_bsp(void) { static const char *__dis_opt_str = "dis_ucode_ldr"; + u32 a, b, c, d; #ifdef CONFIG_X86_32 const char *cmdline = (const char *)__pa_nodebug(boot_command_line); @@ -88,8 +89,23 @@ static bool __init check_loader_disabled_bsp(void) bool *res = &dis_ucode_ldr; #endif - if (cmdline_find_option_bool(cmdline, option)) - *res = true; + if (!have_cpuid_p()) + return *res; + + a = 1; + c = 0; + native_cpuid(&a, &b, &c, &d); + + /* + * CPUID(1).ECX[31]: reserved for hypervisor use. This is still not + * completely accurate as xen pv guests don't see that CPUID bit set but + * that's good enough as they don't land on the BSP path anyway. + */ + if (c & BIT(31)) + return *res; + + if (cmdline_find_option_bool(cmdline, option) <= 0) + *res = false; return *res; } @@ -121,9 +137,6 @@ void __init load_ucode_bsp(void) if (check_loader_disabled_bsp()) return; - if (!have_cpuid_p()) - return; - vendor = x86_cpuid_vendor(); family = x86_cpuid_family(); @@ -157,9 +170,6 @@ void load_ucode_ap(void) if (check_loader_disabled_ap()) return; - if (!have_cpuid_p()) - return; - vendor = x86_cpuid_vendor(); family = x86_cpuid_family();