Received: by 10.223.164.202 with SMTP id h10csp41493wrb; Tue, 14 Nov 2017 10:46:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMaJUx/TEuBidfcyPD9aYi6Yz3gmAYEnu/o5qolz/2BtmWhF0BVB6KwyPPkTwVaw45ipuRiY X-Received: by 10.98.102.74 with SMTP id a71mr13085737pfc.23.1510685177026; Tue, 14 Nov 2017 10:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510685176; cv=none; d=google.com; s=arc-20160816; b=OlWmjJxTQIWF7ju+GyN+l8QBqQ7xuZMsQEdHE7N6QrlVWXDQRBdK/7xL1crqegPlsT v4gxKkB937vcvXOUa1wIsy8MiVKJQRQEMiMlkz9NjXhFV+ROKdyV53uGNmEV5zIpVkVF PpCQUkWXks3e4qbpK9W3WMs4JyGGFkNcMs47D5u5ANHvFE25eaJ0KHOkbKbEJP6Yl110 5ozirYEbrQV5A50//jSdIQXsklyQrTh2FJ4wOXSlvkpD/zrcAxtO8fV108z993+saqqx 7ottWdYBaoRfhM19VQ64GQELX+H7C9U0fuzWH78EpKi154PkSTag+idwERuk0mKcuaF2 wGZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=K+yFDFehEinwSoq+P7yPi9JgS5tg4+zfIiyjhEYwyMY=; b=CoppYkOTjjJHQGAjlkjeSVZ/IDEoDZHKj5C64X2QAweqoKZ7FOaZVBDesQlREYm5f5 3Stl0dp0Fxw9PH99qMmKxdGsx1BvvYI8YEOSDfFHQFoSmGrd0917GojdY77elYBF5Ijg oIw0h+j2Wb4Zpv2GYaBkqwj+whtQy5GzqLZMefIcSOk4k5IIu+w5w5piOrkqg4jzt920 hiMdWnBSdwXb5NNz4wdL5cdTT7LX0t2gwRt6UpmAn55f6g1FzeklOFVnl7NLNgS8zg68 dwy5cbomMX4uI1eDxvDirg0Flh81ThneA8Ar10oFYsbsgT5uNH7J/njCXc0Ps3RoIyLL JsoQ== 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 b3si9130246pgr.683.2017.11.14.10.46.04; Tue, 14 Nov 2017 10:46:16 -0800 (PST) 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 S1756188AbdKNRx0 (ORCPT + 88 others); Tue, 14 Nov 2017 12:53:26 -0500 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:33390 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753855AbdKNRxL (ORCPT ); Tue, 14 Nov 2017 12:53:11 -0500 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id EfNZeZsb6GgZeEfNZeFsz6; Tue, 14 Nov 2017 10:52:09 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eEfNZ-0003dW-Fy; Tue, 14 Nov 2017 10:52:09 -0700 From: kys@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 Cc: Michael Kelley , "K. Y. Srinivasan" Subject: [PATCH 1/2] Drivers: hv: vmbus: Remove x86-isms from arch independent drivers Date: Tue, 14 Nov 2017 10:52:07 -0700 Message-Id: <1510681928-13951-1-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1510681887-13846-1-git-send-email-kys@exchange.microsoft.com> References: <1510681887-13846-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfE8mmLkSM6lhAGek+CpAxzLxSyUk+R3/Mwxkj0GemJKaocarpxCqtT046TOPDyq5FB2FlnbSIMnQ//vuaEMYrGPhiUy1wUqPASk6RQ8GqdGrsz3HDlDC uXEsRph93uZPRPw46qy2LZpWvdkpiqBbbCbQmzHXJn02VXmnwcNPzVCqLkNSfSwAB1f8Ae3u4THAcGZXi0hca08qtQLNIfuOLPthSuVaXTdxjqwzjDHEtA9T 15j2Lhv6SZACGY+LztD0t/VSGXlLVzD4xRgwlemNO820KWiev8xeRZRbgwpoAlq6jMLsbZDlSaq6IsNSrmSj/Q0XDr/yqC1CNI/R+sSAEdlPy1s4A/h8JW9k PLFuPEsni3baucCTkkOhanCc0fWW9S7fiXwtcw2Zo3/agv3ugscKlR/X4ZmqCjPlaT5U2n8XXuhW5eDI0aJvgLOlGXgp7jA/IFJYTkL7Gz75hutLqhBnD2rf cS/y//Vrk6Qg56Io44w3pAJmwiY02RH6Ez3IjNdQbhKFC1So6Dl9lSjMpoHOsnfuGPGg5C/m/KwLws5KS5d8qr1Zu82uW8oBBZm9Dw== 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 Signed-off-by: K. Y. Srinivasan --- 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 4f3faf5..398643b 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -1053,7 +1052,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; @@ -1717,7 +1716,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.7.1 From 1585323068383816015@xxx Tue Nov 28 15:11:33 +0000 2017 X-GM-THRID: 1585323068383816015 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread