From patchwork Thu Oct 19 13:39:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 10016873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA6A460224 for ; Thu, 19 Oct 2017 13:39:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBFF828CFA for ; Thu, 19 Oct 2017 13:39:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF41528D25; Thu, 19 Oct 2017 13:39:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EDE028CFA for ; Thu, 19 Oct 2017 13:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753333AbdJSNjn (ORCPT ); Thu, 19 Oct 2017 09:39:43 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:46803 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753252AbdJSNjl (ORCPT ); Thu, 19 Oct 2017 09:39:41 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9JDdVGl007487 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Oct 2017 13:39:32 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9JDdV3Q014171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Oct 2017 13:39:31 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9JDdUTn002504; Thu, 19 Oct 2017 13:39:30 GMT Received: from paddy.uk.oracle.com (/10.175.233.11) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 19 Oct 2017 06:39:29 -0700 From: Joao Martins To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Joao Martins , Paolo Bonzini , Radim Krcmar , Richard Cochran , Marcelo Tosatti , xen-devel , Boris Ostrovsky , Juergen Gross , Andy Lutomirski Subject: [PATCH v7 1/5] ptp_kvm: probe for kvm guest availability Date: Thu, 19 Oct 2017 14:39:14 +0100 Message-Id: <20171019133918.18367-2-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171019133918.18367-1-joao.m.martins@oracle.com> References: <20171019133918.18367-1-joao.m.martins@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the event of moving pvclock_pvti_cpu0_va() definition to common pvclock code, this function could return a value on non KVM guests. If user tried to load the module (or have it builtin) it would fail with a GPF on ptp_kvm_init when running on a Xen guest. Therefore, ptp_kvm_init() should check whether it is running in a KVM guest. Signed-off-by: Joao Martins Acked-by: Radim Krčmář --- New in v7; --- drivers/ptp/ptp_kvm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ptp/ptp_kvm.c b/drivers/ptp/ptp_kvm.c index 2b1b212c219e..e04d7b2ecb3a 100644 --- a/drivers/ptp/ptp_kvm.c +++ b/drivers/ptp/ptp_kvm.c @@ -178,6 +178,9 @@ static int __init ptp_kvm_init(void) { long ret; + if (!kvm_para_available()) + return -ENODEV; + clock_pair_gpa = slow_virt_to_phys(&clock_pair); hv_clock = pvclock_pvti_cpu0_va();