Received: by 10.223.164.221 with SMTP id h29csp322715wrb; Fri, 3 Nov 2017 15:18:44 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SXSYKbJ205NZpufigK6IONx0cVAIzrWRT+yUQvppk0WSshXGcifv/7GmPt4HzG94l+21MH X-Received: by 10.101.88.129 with SMTP id d1mr8704733pgu.315.1509747524398; Fri, 03 Nov 2017 15:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509747524; cv=none; d=google.com; s=arc-20160816; b=LX4gBlEnyJDX/jAk1ohzyOWu8fXp8KfqkBQMJvDQaFN1Gu/d2zpG206Yf6zdvsVHpn aWuNkYnNioXeMUBDHm9+PDyHQw5k0RBdkQAawzOE2i39kywrOu+lHjiKFDfpOg8jUIdU bgQBTS2S9TQlwz5h76orWAW+Sh2n7H2YmsnxSlEC8A9NH33mITUqUTh3S8ATJxCZqETM FHPCZwDakhFWIxfFZaMnp2v3xvTP+TqSZQfSwn7LMuyh1rYZpGuEKnuzgC1kICES35Wv CEsktRQEQNmewGFuWQt5mRNe+8718i8SujyyYpw/NvEoOVGuwB60k8NwOGqD261k03b+ kpTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:message-id:date:subject:cc:to :from:arc-authentication-results; bh=7ZKKY3BNh/HrumOeXpwWtTZAJWPc01HG3KeK4lwdsZs=; b=RW7cnFzAPMS39yMunn7Funh7Fuc2z8Ou1+i56ndEUV0lLoY/efqWHpYMYtsB7KTODC yO0KlMx0Vzcimn8JbMgukbrxZXO92AFzATYRvy5rZrRvP1US8Fql7Tjyp32ZTCrILmhF KnrLOb1v/COcmrrFwZgLgWsyeLZQ7A6yiDgYxeBDF3K1a+Imsk1wLrqhBfacLw8+2/rI 9gzBmex2Arua38W/rpPHgIwW+tP/mRmOHCxU7VEboZRe4MWhoYT98I0su8boCiICQEj+ c1n0ZX4eL0aJQqEOlzD2uvW0dvumqptnUI7NBWdS2jM5KG/vBYk/mPKQYdFOu0E7uD9v 3Wrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z28si6984529pgc.512.2017.11.03.15.18.21; Fri, 03 Nov 2017 15:18:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752668AbdKCWR1 (ORCPT + 92 others); Fri, 3 Nov 2017 18:17:27 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:47690 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752114AbdKCWRZ (ORCPT ); Fri, 3 Nov 2017 18:17:25 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id AkGGeYAnmV6DQAkGGeXiVo; Fri, 03 Nov 2017 15:16:24 -0700 x-originating-ip: 107.180.71.197 Received: from mikelley by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eAkGG-0006N8-1K; Fri, 03 Nov 2017 15:16:24 -0700 From: mikelley@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com, kys@microsoft.com Cc: Michael Kelley Subject: [PATCH char-misc v3 1/1] Drivers: hv: vmbus: Remove x86-isms from arch independent drivers Date: Fri, 3 Nov 2017 15:16:04 -0700 Message-Id: <20171103221604.24401-1-mikelley@exchange.microsoft.com> X-Mailer: git-send-email 2.14.1 Reply-To: mikelley@microsoft.com X-CMAE-Envelope: MS4wfGWmZNPA6/pL7ASI7Vtz+I25E6QDt+GdMe2iGNq88uRmNXjggkP0O9kIclF56TUwvtT8VNg0bF5vVgSR7vdrl5/fN0rzETNGUxmCulHGpaZ5Bsnt23HU jTbl8IRJdd7fZ0SxWeB5dnPg/FMzpce2r+b2WnfhGc+bUNkhA5VlYIFSg2BowQWxOM5zEhzbKXWYKBOhp/05rQURukGpf1ej5lJVXRw++r0Ei022fMrorrld sR9i/LQr7JGiye3qOFltvHOEOrt/wd5bDUhbKQVtqKOs54sqHKr80uB5PJHg4wwRE4WMubSMvjeKrHSfmNQsDcmFGCzsrCwHiRiW7+X2GzNiePyTQJQ0cKHZ FEXQerbu5kuAwDz871E4TiPHk/iDMHCWFLG4RjrBE3Hd1LvP5/Jlb4fbtsD6sTv9vo8lCIGabNDh9OhbV43jwu3gAaJZOuojDHxqK5++FEJEdoUe7ZmkvToj zONC3bwYrB2GuKEy6Crlg4SsvW+qgCcAI9fVdIUocb1M6aT+2dA04hqj89U3Sq3EoFBQlkplrzstGRoSgZeAUoUDf0Fd9ZgQSNWZEw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kelley hv_is_hypercall_page_setup() is used to check if Hyper-V is initialized, but a 'hypercall page' is an x86 implementation detail that isn't necessarily present on other architectures. Rename to the architecture independent hv_is_hyperv_initialized() and add check that x86_hyper is pointing to Hyper-V. Use this function instead of direct references to x86-specific data structures in vmbus_drv.c, and remove now redundant call in hv_init(). Also remove 'x86' from the string name passed to cpuhp_setup_state(). Signed-off-by: Michael Kelley --- Changed since v1: * Incorporated x86_hyper check into hv_is_hyperv_initialized() per KY Srinivasan's comment that it is still needed * Removed now redundant call to hv_is_hyperv_initialized() in hv_init() Changed since v2: * Fixed block comment style in hv_is_hyperv_initialized() * Fixed my Reply-To email address --- arch/x86/hyperv/hv_init.c | 21 ++++++++++++++------- arch/x86/include/asm/mshyperv.h | 4 ++-- drivers/hv/hv.c | 3 --- drivers/hv/vmbus_drv.c | 5 ++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index aeb8edf..e5372c9 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -239,17 +239,24 @@ void hyperv_report_panic(struct pt_regs *regs, long err) } EXPORT_SYMBOL_GPL(hyperv_report_panic); -bool hv_is_hypercall_page_setup(void) +bool hv_is_hyperv_initialized(void) { union hv_x64_msr_hypercall_contents hypercall_msr; - /* Check if the hypercall page is setup */ + /* + * Ensure that we're really on Hyper-V, and not a KVM or Xen + * emulation of Hyper-V + */ + if (x86_hyper != &x86_hyper_ms_hyperv) + return false; + + /* + * Verify that earlier initialization succeeded by checking + * that the hypercall page is setup + */ hypercall_msr.as_uint64 = 0; rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); - if (!hypercall_msr.enable) - return false; - - return true; + return hypercall_msr.enable; } -EXPORT_SYMBOL_GPL(hv_is_hypercall_page_setup); +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index bd89104..740dc97 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -311,11 +311,11 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number) void hyperv_setup_mmu_ops(void); void hyper_alloc_mmu(void); void hyperv_report_panic(struct pt_regs *regs, long err); -bool hv_is_hypercall_page_setup(void); +bool hv_is_hyperv_initialized(void); void hyperv_cleanup(void); #else /* CONFIG_HYPERV */ static inline void hyperv_init(void) {} -static inline bool hv_is_hypercall_page_setup(void) { return false; } +static inline bool hv_is_hyperv_initialized(void) { return false; } static inline void hyperv_cleanup(void) {} static inline void hyperv_setup_mmu_ops(void) {} #endif /* CONFIG_HYPERV */ diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 8267439..fe96aab 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -49,9 +49,6 @@ struct hv_context hv_context = { */ int hv_init(void) { - if (!hv_is_hypercall_page_setup()) - return -ENOTSUPP; - hv_context.cpu_context = alloc_percpu(struct hv_per_cpu_context); if (!hv_context.cpu_context) return -ENOMEM; diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 8fe13cd..574668c 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -1049,7 +1048,7 @@ static int vmbus_bus_init(void) * Initialize the per-cpu interrupt state and * connect to the host. */ - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv:online", + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online", hv_synic_init, hv_synic_cleanup); if (ret < 0) goto err_alloc; @@ -1711,7 +1710,7 @@ static int __init hv_acpi_init(void) { int ret, t; - if (x86_hyper != &x86_hyper_ms_hyperv) + if (!hv_is_hyperv_initialized()) return -ENODEV; init_completion(&probe_event); -- 1.8.3.1 From 1583080350662624888@xxx Fri Nov 03 21:04:31 +0000 2017 X-GM-THRID: 1583036649122869903 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread