From patchwork Mon Feb 8 16:35:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 8252011 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1F0A8BEEE5 for ; Mon, 8 Feb 2016 16:38:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34F8F203A4 for ; Mon, 8 Feb 2016 16:38:10 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5077A201C8 for ; Mon, 8 Feb 2016 16:38:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSomq-0003AO-SQ; Mon, 08 Feb 2016 16:35:40 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSomp-0003AD-JW for xen-devel@lists.xensource.com; Mon, 08 Feb 2016 16:35:39 +0000 Received: from [193.109.254.147] by server-9.bemta-14.messagelabs.com id E0/97-13475-BD3C8B65; Mon, 08 Feb 2016 16:35:39 +0000 X-Env-Sender: bp@alien8.de X-Msg-Ref: server-2.tower-27.messagelabs.com!1454949338!20338462!1 X-Originating-IP: [78.46.96.112] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13741 invoked from network); 8 Feb 2016 16:35:38 -0000 Received: from mail.skyhub.de (HELO mail.skyhub.de) (78.46.96.112) by server-2.tower-27.messagelabs.com with SMTP; 8 Feb 2016 16:35:38 -0000 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Plx-QnUgMu+E; Mon, 8 Feb 2016 17:35:37 +0100 (CET) Received: from pd.tnic (p5DDC60AB.dip0.t-ipconnect.de [93.220.96.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id CAE2B1D955C; Mon, 8 Feb 2016 17:35:36 +0100 (CET) Received: by pd.tnic (Postfix, from userid 1000) id A277B160FEE; Mon, 8 Feb 2016 17:35:26 +0100 (CET) Date: Mon, 8 Feb 2016 17:35:26 +0100 From: Borislav Petkov To: Boris Ostrovsky Message-ID: <20160208163526.GI28980@pd.tnic> References: <20160206085930.GF25240@wotan.suse.de> <20160206220437.GA4435@pd.tnic> <56B8B6BF.6030007@oracle.com> <20160208155507.GF28980@pd.tnic> <56B8BCDB.9040701@citrix.com> <56B8BE58.6070003@oracle.com> <56B8C1BC.9040603@citrix.com> <56B8C2C8.8050406@oracle.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56B8C2C8.8050406@oracle.com> User-Agent: Mutt/1.5.24 (2015-08-30) Cc: X86 ML , david.e.box@intel.com, Andrey Ryabinin , Lv Zheng , Jan Beulich , "H. Peter Anvin" , qiuxishi@huawei.com, cocci@systeme.lip6.fr, Xen Devel , Joerg Roedel , "Rafael J. Wysocki" , Robert Moore , Ingo Molnar , Andrey Ryabinin , Mauro Carvalho Chehab , "Luis R. Rodriguez" , Rusty Russell , Thomas Gleixner , mcb30@ipxe.org, Juergen Gross , Andrew Cooper , "linux-kernel@vger.kernel.org" , Andy Lutomirski , "Luis R. Rodriguez" , long.wanglong@huawei.com, Fengguang Wu Subject: Re: [Xen-devel] [PATCH v2 3/3] paravirt: rename paravirt_enabled to paravirt_legacy X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Feb 08, 2016 at 11:31:04AM -0500, Boris Ostrovsky wrote: > I think we are OK for PV because this code will be executed after pvops are > set and so we will be calling xen_cpuid(). Not for the early loader - it is too early for pvops then. So you're saying something like that won't work? diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h index 055ea9941dd5..f3e563e8b5c3 100644 --- a/arch/x86/include/asm/hypervisor.h +++ b/arch/x86/include/asm/hypervisor.h @@ -56,9 +56,11 @@ extern const struct hypervisor_x86 x86_hyper_kvm; extern void init_hypervisor(struct cpuinfo_x86 *c); extern void init_hypervisor_platform(void); extern bool hypervisor_x2apic_available(void); +bool is_xen_hypervisor(void); #else static inline void init_hypervisor(struct cpuinfo_x86 *c) { } static inline void init_hypervisor_platform(void) { } static inline bool hypervisor_x2apic_available(void) { return false; } +static inline bool is_xen_hypervisor(void) { return false; } #endif /* CONFIG_HYPERVISOR_GUEST */ #endif /* _ASM_X86_HYPERVISOR_H */ diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c index d820d8eae96b..bda29017f946 100644 --- a/arch/x86/kernel/cpu/hypervisor.c +++ b/arch/x86/kernel/cpu/hypervisor.c @@ -85,3 +85,24 @@ bool __init hypervisor_x2apic_available(void) x86_hyper->x2apic_available && x86_hyper->x2apic_available(); } + +bool is_xen_hypervisor(void) +{ + u32 eax, ebx, ecx, edx; + + eax = 0x4000000; + ecx = 0; + native_cpuid(&eax, &ebx, &ecx, &edx); + + if (ebx == 0x566e6558 && ecx == 0x65584d4d && edx == 0x4d4d566e) + return true; + + eax = 0x40000100; + ecx = 0; + native_cpuid(&eax, &ebx, &ecx, &edx); + + if (ebx == 0x566e6558 && ecx == 0x65584d4d && edx == 0x4d4d566e) + return true; + + return false; +} diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index cea8552e2b3a..0a941ff8095c 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +87,7 @@ static bool __init check_loader_disabled_bsp(void) bool *res = &dis_ucode_ldr; #endif - if (cmdline_find_option_bool(cmdline, option)) + if (cmdline_find_option_bool(cmdline, option) || is_xen_hypervisor()) *res = true; return *res;