From patchwork Wed Oct 30 14:54:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 11219703 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1A051668 for ; Wed, 30 Oct 2019 14:56:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C5FC20856 for ; Wed, 30 Oct 2019 14:56:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="gA1j08W5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C5FC20856 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iPpNF-00038A-UG; Wed, 30 Oct 2019 14:55:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iPpNE-00037y-UG for xen-devel@lists.xen.org; Wed, 30 Oct 2019 14:55:00 +0000 X-Inumbo-ID: 3c55c4b7-fb25-11e9-9527-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3c55c4b7-fb25-11e9-9527-12813bfff9fa; Wed, 30 Oct 2019 14:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1572447295; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=P7baffnUHo1jCBAVaJZGgOtzgVyT4RMajAmx/fFBT/4=; b=gA1j08W5OWzZ5iTzZDdVRWaGycqVLrdR3dAngevZ4AQ3qqgz/1v3Brgh 9icLZ5RjoBsygWNynTudLEX1PLB4BpV8XDOX4ElGVzNNJLSxQz/leSXnD 6TXW3NH2bY6vHLhzldxlrBSmKnSJUVJsRkuby3dPgl6b5sjOP4EJP7mHG Q=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=sergey.dyasli@citrix.com; spf=Pass smtp.mailfrom=sergey.dyasli@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of sergey.dyasli@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of sergey.dyasli@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: /ZyavpBRSWzpAmyGMh+klFKt2+bLXBU68aPJy5dRnyaFoojVB7wU/R1MV1JeVtuKpcprWPmH3I rz+qlVGpJ2xtdgC68ksw1CiLXu6fZ7E4/vBZWUcEwfryg9u+n5AHhlqmpzqxoXmLFIp6dDBnXH zC/ulQk1atIlMnIu2lhWJFh5beLOPJEp2BgcJKxDzlZ+Dpm+RYYthcXbH1+1Vnwd/CPsLv2cQY qzhgv8JMtF3/UYu4MiG1ZQcJ8jIRXWPKMHaWdiVvjaEGHOM9UqDKkZzkhhU8fdXwfrgliuYGg+ RZo= X-SBRS: 2.7 X-MesageID: 8094669 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,247,1569297600"; d="scan'208";a="8094669" From: Sergey Dyasli To: Date: Wed, 30 Oct 2019 14:54:46 +0000 Message-ID: <20191030145447.11122-1-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 for 4.13 1/2] x86/boot: allow early usage of cpu_has_hypervisor X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Sergey Dyasli , Wei Liu , Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Move early_cpu_init() to be near the top of __start_xen(). Since there is no serial / vga output at that stage, introduce a new function to print CPU information at the usual place during boot. Finally, convert users of cpuid_ecx(1) & X86_FEATURE_HYPERVISOR. Signed-off-by: Sergey Dyasli --- CC: Jan Beulich CC: Andrew Cooper CC: Wei Liu CC: "Roger Pau Monné" CC: Juergen Gross --- xen/arch/x86/cpu/common.c | 25 +++++++++++++++++-------- xen/arch/x86/guest/xen.c | 3 +-- xen/arch/x86/mm.c | 2 +- xen/arch/x86/setup.c | 4 +++- xen/include/asm-x86/setup.h | 1 + 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 6c6bd63301..4f336f64d3 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -109,6 +109,7 @@ static const struct cpu_dev default_cpu = { .c_init = default_init, }; static const struct cpu_dev *this_cpu = &default_cpu; +static bool __initdata unrecognised_cpu; static DEFINE_PER_CPU(uint64_t, msr_misc_features); void (* __read_mostly ctxt_switch_masking)(const struct vcpu *next); @@ -301,9 +302,7 @@ void __init early_cpu_init(void) case X86_VENDOR_SHANGHAI: this_cpu = &shanghai_cpu_dev; break; case X86_VENDOR_HYGON: this_cpu = &hygon_cpu_dev; break; default: - printk(XENLOG_ERR - "Unrecognised or unsupported CPU vendor '%.12s'\n", - c->x86_vendor_id); + unrecognised_cpu = true; } cpuid(0x00000001, &eax, &ebx, &ecx, &edx); @@ -317,11 +316,6 @@ void __init early_cpu_init(void) c->x86_capability[cpufeat_word(X86_FEATURE_FPU)] = edx; c->x86_capability[cpufeat_word(X86_FEATURE_SSE3)] = ecx; - printk(XENLOG_INFO - "CPU Vendor: %s, Family %u (%#x), Model %u (%#x), Stepping %u (raw %08x)\n", - x86_cpuid_vendor_to_str(c->x86_vendor), c->x86, c->x86, - c->x86_model, c->x86_model, c->x86_mask, eax); - eax = cpuid_eax(0x80000000); if ((eax >> 16) == 0x8000 && eax >= 0x80000008) { eax = cpuid_eax(0x80000008); @@ -342,6 +336,21 @@ void __init early_cpu_init(void) initialize_cpu_data(0); } +void __init early_cpu_print_info(void) +{ + struct cpuinfo_x86 *c = &boot_cpu_data; + + if (unrecognised_cpu) + printk(XENLOG_ERR + "Unrecognised or unsupported CPU vendor '%.12s'\n", + c->x86_vendor_id); + + printk(XENLOG_INFO "CPU Vendor: %s, Family %u (%#x), Model %u (%#x), " + "Stepping %u (raw %08x)\n", + x86_cpuid_vendor_to_str(c->x86_vendor), c->x86, c->x86, + c->x86_model, c->x86_model, c->x86_mask, cpuid_eax(0x00000001)); +} + static void generic_identify(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx, tmp; diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c index 7b7a5badab..9b776afed9 100644 --- a/xen/arch/x86/guest/xen.c +++ b/xen/arch/x86/guest/xen.c @@ -72,8 +72,7 @@ void __init probe_hypervisor(void) if ( xen_guest ) return; - /* Too early to use cpu_has_hypervisor */ - if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) ) + if ( !cpu_has_hypervisor ) return; find_xen_leaves(); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 99816fc67c..4cdccab8c8 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5943,7 +5943,7 @@ const struct platform_bad_page *__init get_platform_badpages(unsigned int *array case 0x000806e0: /* erratum KBL??? */ case 0x000906e0: /* errata KBL??? / KBW114 / CFW103 */ *array_size = (cpuid_eax(0) >= 7 && - !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) && + !cpu_has_hypervisor && (cpuid_count_ebx(7, 0) & cpufeat_mask(X86_FEATURE_HLE))); return &hle_bad_page; } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index dec60d0301..07adfed566 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -723,6 +723,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Enable NMIs. Our loader (e.g. Tboot) may have left them disabled. */ enable_nmis(); + early_cpu_init(); + if ( pvh_boot ) { /* @@ -1519,7 +1521,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) softirq_init(); tasklet_subsys_init(); - early_cpu_init(); + early_cpu_print_info(); paging_init(); diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h index 861d46d6ac..251151508d 100644 --- a/xen/include/asm-x86/setup.h +++ b/xen/include/asm-x86/setup.h @@ -15,6 +15,7 @@ extern char __2M_rwdata_start[], __2M_rwdata_end[]; extern unsigned long xenheap_initial_phys_start; void early_cpu_init(void); +void early_cpu_print_info(void); void early_time_init(void); void set_nr_cpu_ids(unsigned int max_cpus);