diff mbox

[v7,1/5] ptp_kvm: probe for kvm guest availability

Message ID 20171019133918.18367-2-joao.m.martins@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joao Martins Oct. 19, 2017, 1:39 p.m. UTC
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 <joao.m.martins@oracle.com>
---
New in v7;
---
 drivers/ptp/ptp_kvm.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Radim Krčmář Oct. 20, 2017, 2:33 p.m. UTC | #1
2017-10-19 14:39+0100, Joao Martins:
> 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 <joao.m.martins@oracle.com>
> ---
> New in v7;
> ---

Acked-by: Radim Krčmář <rkrcmar@redhat.com>
diff mbox

Patch

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();