From patchwork Fri Dec 16 07:28:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 9477339 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 5363D607EE for ; Fri, 16 Dec 2016 07:31:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B31728764 for ; Fri, 16 Dec 2016 07:31:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FD92287D4; Fri, 16 Dec 2016 07:31:09 +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=unavailable 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 940AE287AE for ; Fri, 16 Dec 2016 07:31:05 +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 1cHmwl-0001fH-RS; Fri, 16 Dec 2016 07:28:51 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHmwk-0001f9-MY for xen-devel@lists.xenproject.org; Fri, 16 Dec 2016 07:28:50 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 70/78-22514-1B793585; Fri, 16 Dec 2016 07:28:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRWlGSWpSXmKPExsVyuP0Ov+7G6cE RBq9mslh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlzJ65iK/goUrGo8TZrA+M3wS5GTg4JASOJ txP/MXUxcnEICSxklLh9p5Oti5GDQ1jASmLz6zSQGhEBP4kP534wQtQsYpJ4fKaRBaSGWSBT4 sjrPJAaNgFViQ3XT7GC2LwC1hIHN3ezgpSwAMUfbxADMUUFwiWuHjaHqBCUODnzCQuIzSlgJn F27QN2EJtZwF9iW2MH4wRG3llIymYhSUHY6hJ/5l1ihrDlJba/nQNlJ0u8+nOWFVUc5M46iX+ dmgsY2VcxahSnFpWlFukameslFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgSGaz0D A+MOxqtb/A4xSnIwKYnyeuUGRwjxJeWnVGYkFmfEF5XmpBYfYtTg4BDYvHb1BUYplrz8vFQlC d6l04DqBItS01Mr0jJzgBEFUyrBwaMkwps8FSjNW1yQmFucmQ6ROsWoKCXOWwbSJwCSyCjNg2 uDRfElRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK86SBTeDLzSuCmvwJazAS0WHSJP8jikkS ElFQDY8HXhkOTk9Y9a4uU/q3LpXrCJZyP5ZRVwOYfTN8nmj69pXRAIk7o43rJ8OYjWS5RfPt6 zz9ZLZx2Y5nOiR3Fi49K88qUiXTY1x/ba3X08AfWKSbPijVnyz+48fWTcWnjNEU/zg/115TSF 1T93pv38qn75lnP7Psa9RRbM9QTnoZkSemz/spWV2Ipzkg01GIuKk4EAOstDKfdAgAA X-Env-Sender: jgross@suse.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1481873325!39435476!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 58296 invoked from network); 16 Dec 2016 07:28:45 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-12.tower-206.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Dec 2016 07:28:45 -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 F4204AAC8; Fri, 16 Dec 2016 07:28:47 +0000 (UTC) To: Borislav Petkov , Boris Ostrovsky References: <73a4d64b-b139-6579-a560-92311641d6c7@suse.com> <20161215164635.thm7ruio2ddnxszw@pd.tnic> <20161215171755.xpfuax7a6q3jofet@pd.tnic> <20161215173609.ornfok6lk5oro2pj@pd.tnic> From: Juergen Gross Message-ID: Date: Fri, 16 Dec 2016 08:28:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161215173609.ornfok6lk5oro2pj@pd.tnic> Cc: 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 15/12/16 18:36, Borislav Petkov wrote: > On Thu, Dec 15, 2016 at 12:27:49PM -0500, Boris Ostrovsky wrote: >> It will probably fix it but I don't think we want this: it's a >> build-time solution. Most kernels have XEN on even though they are >> booted bare-metal. > > Lemme tell you want I want: a way to detect I'm running on xen. Does > CPUID(4) work really early, at load_ucode_bsp() time? > > IOW, can I use some of the functionality hypervisor_cpuid_base() uses to > detect xen and stop loading any further? What you really need is to avoid being called on a Xen pv guest. And this is easy by using xen_domain(). Not trying to load ucode in _any_ guest is an optimization only. The attached patch works for me in dom0, bare metal and Xen HVM guest. Juergen From 0b56d1f86679c5dc435ab6d96eb2f68b666271bb Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 16 Dec 2016 07:18:34 +0100 Subject: [PATCH] x86/microcode: don't try to load microcode when running as a xen pv guest As a Xen pv guest some mechanisms to do microcode loading or verification might not work. As the hypervisor is responsible for loading the microcode just skip microcode loading in case of running under Xen. Signed-off-by: Juergen Gross --- arch/x86/kernel/cpu/microcode/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 6996413..8dfc8bd 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -91,6 +93,9 @@ static bool __init check_loader_disabled_bsp(void) if (cmdline_find_option_bool(cmdline, option)) *res = true; + if (xen_domain()) + *res = true; + return *res; } @@ -143,6 +148,9 @@ void __init load_ucode_bsp(void) static bool check_loader_disabled_ap(void) { + if (xen_domain()) + return true; + #ifdef CONFIG_X86_32 return *((bool *)__pa_nodebug(&dis_ucode_ldr)); #else -- 2.10.2