From patchwork Mon Feb 10 17:28:28 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: 11373829 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 98193139A for ; Mon, 10 Feb 2020 17:30:34 +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 752AA20733 for ; Mon, 10 Feb 2020 17:30:34 +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="cOl/ZB1z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 752AA20733 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 1j1CsA-0006hi-7C; Mon, 10 Feb 2020 17:29:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1Cs9-0006h6-AA for xen-devel@lists.xenproject.org; Mon, 10 Feb 2020 17:29:25 +0000 X-Inumbo-ID: e151bc44-4c2a-11ea-852a-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e151bc44-4c2a-11ea-852a-bc764e2007e4; Mon, 10 Feb 2020 17:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1581355764; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WCEo9Ows5qPa/HxrFk2RxBO14wcSrhNPhC7c9qZxXX4=; b=cOl/ZB1zs2Ww6nXszwlu7DA13CAKMuOBUDsRKGuUq+KmmaQPfdKzDjYb Tkgm7JUqanJJGSpo0L1TAcCFgS5OZeO3vz5E2x77PCsNG4qbdC7OFECPS nYWEAHwvOL2St7MrvcwWl0rfWnrGiBG48QxyhB8jGwXif4nMIaoci3Xi7 4=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: xzv3IqIuzsoPgS9+mgcfMmdVQGTi9CJSHDwt6VUns90BRkkcB/faWRQJsz5GOG3LEDLgfUEh2V rT1kuE0qmWsb9SBh2EFL18H+PL/er0+i89xpW3mq6NTOhXgim0JtkM5YQUM3VcSVP0EWhNM7tf 9ziFvLm8OCeRIzOkqM/qstRU9weycXrHdRkmINROSr65nCKQEtYbXxxsoxtLfcX3HbeKSZ1pIm X1ucDFT4qU4am2XIvGf2SMhjHeBLZRKY+3gogObYY7Wjt9oaIjAxoiLKSFXdoDFS8N+j7H7xkU uNk= X-SBRS: 2.7 X-MesageID: 12589345 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,425,1574139600"; d="scan'208";a="12589345" From: Roger Pau Monne To: Date: Mon, 10 Feb 2020 18:28:28 +0100 Message-ID: <20200210172829.43604-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210172829.43604-1-roger.pau@citrix.com> References: <20200210172829.43604-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 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 --- 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,