From patchwork Fri Dec 16 09:01:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 9477583 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 8DF3F607EE for ; Fri, 16 Dec 2016 09:03:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F432287FC for ; Fri, 16 Dec 2016 09:03:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 729B72880D; Fri, 16 Dec 2016 09:03:47 +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 0D1652880E for ; Fri, 16 Dec 2016 09:03:47 +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 1cHoO4-0003B5-Kv; Fri, 16 Dec 2016 09:01:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHoO2-0003Az-T9 for xen-devel@lists.xenproject.org; Fri, 16 Dec 2016 09:01:06 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 99/77-09053-25DA3585; Fri, 16 Dec 2016 09:01:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDIsWRWlGSWpSXmKPExsVyuP0Ov27g2uA Ig/WztS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oz7a0+wFZzgrdi88jlrA+Mi7i5GTg4JASOJ txP/MYHYQgILGSUuT+GAsNMl3vy7yAJiswioSmy4fJ8NxGYTUJL4/WkdO4gtImAg8f76JKA4F wezQDejROuBy6xdjBwcwgJWEptfp4HU8AqYSpzdPIcZpEZI4AGzRHdPBxNEQlDi5MwnYAuYBd Ql/sy7xAzSyywgLbH8HwdEWF6ieetsZhCbU8BO4t3st2CtogIqErMuz2GZwCgwC8mkWUgmzUK YNAvJpAWMLKsYNYpTi8pSi3SNDfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQJD lgEIdjA2LQo8xCjJwaQkyuuVGxwhxJeUn1KZkVicEV9UmpNafIhRg4NDYPPa1RcYpVjy8vNSl SR4hdYA1QkWpaanVqRl5gCjCqZUgoNHSYTXdxVQmre4IDG3ODMdInWKUVFKnDcIpE8AJJFRmg fXBovkS4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLmZQWZwpOZVwI3/RXQYiagxRbzwBaXJCK kpBoYja/nvvNqueZR8DPGK9Rcv6Yk+GLggf/3JljrFRS8u67zZYLWm7pFvKbxKwTyIpV991f8 YZQyez8x5GtezKfyPRWGph5FJ46ltT9ffWaZuNWFVrcvOuZ5hxofqSZ175zCbf7/sOJOl71RV TU7eoSe79+vUcn+wZPzyP8YO72tDRHl5YwZNV+UWIozEg21mIuKEwEnGkNg3wIAAA== X-Env-Sender: bp@suse.de X-Msg-Ref: server-10.tower-21.messagelabs.com!1481878865!41937962!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 40253 invoked from network); 16 Dec 2016 09:01:05 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-10.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Dec 2016 09:01:05 -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 EC439AB49; Fri, 16 Dec 2016 09:01:04 +0000 (UTC) Received: by pd.tnic (Postfix, from userid 1000) id B1E34160EE6; Fri, 16 Dec 2016 10:01:00 +0100 (CET) Date: Fri, 16 Dec 2016 10:01:00 +0100 From: Borislav Petkov To: Boris Ostrovsky Message-ID: <20161216090100.cekw347kly3qd7c6@pd.tnic> References: <20161215171755.xpfuax7a6q3jofet@pd.tnic> <20161215173609.ornfok6lk5oro2pj@pd.tnic> <385ac3cd-7a3f-4c4d-69bb-8feee235fb7e@oracle.com> <20161215192305.dlgyrmteirgzop4y@pd.tnic> <399c758a-a94b-8aa1-efbb-79a0161b8020@oracle.com> <20161215200324.6ju7o5e3aiirrycf@pd.tnic> <51f0a58d-a5bc-aae4-22b2-f45bf7164088@oracle.com> <20161215230433.m52cs2gef662c2s7@pd.tnic> <539c1b43-009d-9a59-0c80-7b1e552ab0ed@oracle.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <539c1b43-009d-9a59-0c80-7b1e552ab0ed@oracle.com> User-Agent: NeoMutt/20161014 (1.7.1) Cc: Juergen Gross , xen-devel , 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 Thu, Dec 15, 2016 at 10:56:25PM -0500, Boris Ostrovsky wrote: > You can use xen_cpuid_base(), for example. It will prevent microcode loading Actually I want to do this at the end. CPUID(1).ECX[31] is reserved by both vendors for hypervisor use. > True. But I don't think it's clear that the problem we are seeing is > Xen-specific. If you can trigger it on baremetal, I'm all ears. diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 6996413c78c3..54219f619205 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -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); @@ -91,6 +92,17 @@ static bool __init check_loader_disabled_bsp(void) if (cmdline_find_option_bool(cmdline, option)) *res = true; + if (!have_cpuid_p()) + *res = true; + + a = 1; + c = 0; + native_cpuid(&a, &b, &c, &d); + + /* CPUID(1).ECX[31]: reserved for hypervisor use */ + if (c & BIT(31)) + *res = true; + return *res; } @@ -121,9 +133,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 +166,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();