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: 10016895 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 46946603FF for ; Thu, 19 Oct 2017 13:41:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B65A28CFA for ; Thu, 19 Oct 2017 13:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 300F928B4D; Thu, 19 Oct 2017 13:41:50 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E36ED28CFA for ; Thu, 19 Oct 2017 13:41:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5B2w-0002UP-VU; Thu, 19 Oct 2017 13:39:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5B2w-0002UJ-3U for xen-devel@lists.xenproject.org; Thu, 19 Oct 2017 13:39:38 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 34/85-21876-91BA8E95; Thu, 19 Oct 2017 13:39:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42LpnVTnqiux+kW kwcxfZhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8azG/uYCm6xVfzdfoy1gfE6axcjF4eQwEQm iRWbTzFDOH8ZJWafvs0C4WxglJh0/TWU080ocXL+E6AeTg42AT2J1vOfmUFsEQFTiYMT7oHFm QVmMkt8PBQDYgsLOEp0vH0MVsMioCqxeMdRNhCbV8BOYt6B3UwgtoSAvMSutotgvZwC9hKL1i 8Fs4WAaq5v7WSFqDGUOP1wG+MERr4FjAyrGDWKU4vKUot0jcz0kooy0zNKchMzc3QNDUz1clO LixPTU3MSk4r1kvNzNzECg6WegYFxB+PtyX6HGCU5mJREeT9WvYgU4kvKT6nMSCzOiC8qzUkt PsQow8GhJMH7cyVQTrAoNT21Ii0zBxi2MGkJDh4lEd4pIGne4oLE3OLMdIjUKUZjjhsPr/9h4 ui4efcPkxBLXn5eqpQ47y2QUgGQ0ozSPLhBsHi6xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUU mY9y7IFJ7MvBK4fa+ATmECOoXdHuyUkkSElFQDI2vuEVVNs1OXD7Pbd/+2mc5p/k3wZ+nktMl N3Xx97Z/0FzRGc6UKr39SpHRIR23ilu5Hz9QtdLP1b6yvvSTMeGx56qNjLBNX5yz41hJcGryI M6byp4XD741+MqJVh9J8rkT7HJmzYWpyhvX7pWdV1H/uZO7SuvD/I/eG7qzFVm0TS02WbryZr sRSnJFoqMVcVJwIANTYlaCiAgAA X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1508420375!91849690!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19793 invoked from network); 19 Oct 2017 13:39:36 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 19 Oct 2017 13:39:36 -0000 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 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] Cc: Juergen Gross , Radim Krcmar , Richard Cochran , Marcelo Tosatti , Andy Lutomirski , xen-devel , Paolo Bonzini , Joao Martins , Boris Ostrovsky Subject: [Xen-devel] [PATCH v7 1/5] ptp_kvm: probe for kvm guest availability X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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();