From patchwork Wed Feb 19 17:43:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11392151 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 4603F109A for ; Wed, 19 Feb 2020 17:45:52 +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 22539206DB for ; Wed, 19 Feb 2020 17:45:52 +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="Yp48fX4y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22539206DB 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 1j4TOz-0001vh-G1; Wed, 19 Feb 2020 17:44:49 +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 1j4TOy-0001ui-HA for xen-devel@lists.xenproject.org; Wed, 19 Feb 2020 17:44:48 +0000 X-Inumbo-ID: 823ee3ea-533f-11ea-83f8-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 823ee3ea-533f-11ea-83f8-12813bfff9fa; Wed, 19 Feb 2020 17:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582134284; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/s5u8sMdunnqNRIWop29wFYp8BPH9IKS621+zWod4l0=; b=Yp48fX4yGxgQOAzDW1IwyyNUhKTikwV0AABJ8yvMkBfLs2iu9v7nYIQQ YgRFzEV4BOY+p3emm3a1YwwdwdP3AOsaKAAx6vYMHiJhaq9awpdof0d/C umecLsd0TUg5fU6UFnuQftfQvBwBl1CldVJ8djxClPCpUqryC41fP++x2 Y=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: pB94+noT6O70wgniVX0Xb/7jddOpgpw8XvSFM/7Xo3utDH0SucIa+RK0IymhD2HAFZaDM48C1x 2n45x/2MaIoJ29MEyQd8hIeg88SBpSQ1oPH658DR9ycZJgxKJcunqkY9vcpfVVJZ8L8IyjTDUX h1i34YYxFgN01dmU/T349DMJ0KCZTpjr7LIZYnJiciiTG1od0Xe7QXYpAmgLFPlFSkCML2bEc7 hljMkynzxZO50cmCzQfwL7LPH7MqlndrLKqcf62JlNdWs4IoC9QtcAw1TPdUx5RdlrDnslX1Pd 3Is= X-SBRS: 2.7 X-MesageID: 12882318 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,461,1574139600"; d="scan'208";a="12882318" From: Roger Pau Monne To: Date: Wed, 19 Feb 2020 18:43:53 +0100 Message-ID: <20200219174354.84726-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200219174354.84726-1-roger.pau@citrix.com> References: <20200219174354.84726-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v5 6/7] xen/guest: prepare hypervisor ops to use alternative calls 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: Andrew Cooper , Paul Durrant , Jan Beulich , Wei Liu , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Adapt the hypervisor ops framework so it can be used with the alternative calls framework. So far no hooks are modified to make use of the alternatives patching, as they are not in any hot path. No functional change intended. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu Reviewed-by: Paul Durrant Reviewed-by: Jan Beulich --- Changes since v3: - New in this version. --- xen/arch/x86/guest/hyperv/hyperv.c | 2 +- xen/arch/x86/guest/hypervisor.c | 41 +++++++++++++++--------------- xen/arch/x86/guest/xen/xen.c | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index fabc62b0d6..70f4cd5ae0 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -199,7 +199,7 @@ static void __init e820_fixup(struct e820map *e820) panic("Unable to reserve Hyper-V hypercall range\n"); } -static const struct hypervisor_ops ops = { +static const struct hypervisor_ops __initdata ops = { .name = "Hyper-V", .setup = setup, .ap_setup = ap_setup, diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 5fd433c8d4..647cdb1367 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -24,52 +24,53 @@ #include #include -static const struct hypervisor_ops *__read_mostly ops; +static struct hypervisor_ops __read_mostly ops; const char *__init hypervisor_probe(void) { + const struct hypervisor_ops *fns; + if ( !cpu_has_hypervisor ) return NULL; - ops = xg_probe(); - if ( ops ) - return ops->name; + fns = xg_probe(); + if ( !fns ) + /* + * Detection of Hyper-V must come after Xen to avoid false positive due + * to viridian support + */ + fns = hyperv_probe(); - /* - * Detection of Hyper-V must come after Xen to avoid false positive due - * to viridian support - */ - ops = hyperv_probe(); - if ( ops ) - return ops->name; + if ( fns ) + ops = *fns; - return NULL; + return ops.name; } void __init hypervisor_setup(void) { - if ( ops && ops->setup ) - ops->setup(); + if ( ops.setup ) + ops.setup(); } int hypervisor_ap_setup(void) { - if ( ops && ops->ap_setup ) - return ops->ap_setup(); + if ( ops.ap_setup ) + return ops.ap_setup(); return 0; } void hypervisor_resume(void) { - if ( ops && ops->resume ) - ops->resume(); + if ( ops.resume ) + ops.resume(); } void __init hypervisor_e820_fixup(struct e820map *e820) { - if ( ops && ops->e820_fixup ) - ops->e820_fixup(e820); + if ( ops.e820_fixup ) + ops.e820_fixup(e820); } /* diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 3cf8f667a1..f151b07548 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -324,7 +324,7 @@ static void __init e820_fixup(struct e820map *e820) pv_shim_fixup_e820(e820); } -static const struct hypervisor_ops ops = { +static const struct hypervisor_ops __initdata ops = { .name = "Xen", .setup = setup, .ap_setup = ap_setup,