Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1963940imm; Fri, 6 Jul 2018 09:26:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdos6HyAdsNKd1fazFWn2DJN58j4nNoR/gO/G68EbcN+xDZWygoAkmAGq1dG/zxDLtHCr6n X-Received: by 2002:a62:d842:: with SMTP id e63-v6mr11363774pfg.88.1530894385046; Fri, 06 Jul 2018 09:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530894385; cv=none; d=google.com; s=arc-20160816; b=k7wA6lKhubj6pw7c2O3e7Ahc+SVdUWEm2MEIgS0KiPBO0olsVFoN+4oOvpBwBEQLNM FxzD+ARMAkm2fXfHF3BgaRLD+ElV2DzYfNeBcouvGCtyH6b4dEH3zHePf6ghdy7rkBM6 SNOuuNQwkvYq5Wdoe67v4C5WPIf01angG/wuJv4a+dJLmuetECRHNaYlW2s7AglD/MqI rJEJwMNkdoGB9YBpFRd3KFLylFj9TQKCm/BuIds1L9JVqxoBTAiqQZYZUSjkoXoGvN+R ae10Olu9WRQOxW1LuhBKXJDPrOYV/xPcKk7akZA3on8kEcPsbP9CGDwgFrvwlFc2+0il WOmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :references:subject:cc:to:from:date:user-agent:message-id :arc-authentication-results; bh=XmmSRjoy/zRvIE12JZdSBwhmEDWSfFRbKuL1XkMvGI0=; b=Mrf5X4olHccIsBgwSqz0eQvBbJgLhVRr+OtbbmDMu4d43HNA0f1U66yG5jaRDB1bkX CLsP1jjEjsca7nrYqSiFftwrE7WOHB0riSIQ9Hdm43cz8zXwbtvxtr7oQtQDobPgCL/k U/toAP6B2qnMo2sveHoJ6L26sZV7btJAgK5Q7SVx6CdhJI9SQCE16bM25U6JTHVLpjXM O6Q5I96j/SLLB40vzeih1Jx650zWJCxkljnmGcSpUhWZXorBvbRgDwhdOD6uT71WAWEY yYui0+3XHW2Jns5qvGlNeEsTkbGxjqif5Vo0j/TBk+nvNUa+dKHkKHokZTzbPqpIq2iw TMoQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24-v6si7725033pgv.527.2018.07.06.09.26.10; Fri, 06 Jul 2018 09:26:25 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933863AbeGFQXl (ORCPT + 99 others); Fri, 6 Jul 2018 12:23:41 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55152 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933442AbeGFQXe (ORCPT ); Fri, 6 Jul 2018 12:23:34 -0400 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fbTVu-00006u-26; Fri, 06 Jul 2018 18:23:18 +0200 Message-ID: <20180706162049.765314976@linutronix.de> User-Agent: quilt/0.65 Date: Fri, 06 Jul 2018 18:13:13 +0200 From: Thomas Gleixner To: LKML Cc: Paolo Bonzini , Radim Krcmar , Peter Zijlstra , Juergen Gross , Pavel Tatashin , steven.sistare@oracle.com, daniel.m.jordan@oracle.com, x86@kernel.org, kvm@vger.kernel.org Subject: [patch 6/7] x86/kvmclock: Move kvmclock vsyscall param and init to kvmclock References: <20180706161307.733337643@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no point to have this in the kvm code itself and call it from there. This can be called from an initcall and the parameter is cleared when the hypervisor is not KVM. Signed-off-by: Thomas Gleixner Cc: Paolo Bonzini Cc: Radim Krcmar Cc: Peter Zijlstra Cc: Juergen Gross Cc: Pavel Tatashin Cc: steven.sistare@oracle.com Cc: daniel.m.jordan@oracle.com Cc: x86@kernel.org Cc: kvm@vger.kernel.org --- arch/x86/include/asm/kvm_guest.h | 7 ----- arch/x86/kernel/kvm.c | 13 ---------- arch/x86/kernel/kvmclock.c | 49 ++++++++++++++++++++++++--------------- 3 files changed, 31 insertions(+), 38 deletions(-) --- a/arch/x86/include/asm/kvm_guest.h +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_KVM_GUEST_H -#define _ASM_X86_KVM_GUEST_H - -int kvm_setup_vsyscall_timeinfo(void); - -#endif /* _ASM_X86_KVM_GUEST_H */ --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -45,7 +45,6 @@ #include #include #include -#include static int kvmapf = 1; @@ -66,15 +65,6 @@ static int __init parse_no_stealacc(char early_param("no-steal-acc", parse_no_stealacc); -static int kvmclock_vsyscall = 1; -static int __init parse_no_kvmclock_vsyscall(char *arg) -{ - kvmclock_vsyscall = 0; - return 0; -} - -early_param("no-kvmclock-vsyscall", parse_no_kvmclock_vsyscall); - static DEFINE_PER_CPU_DECRYPTED(struct kvm_vcpu_pv_apf_data, apf_reason) __aligned(64); static DEFINE_PER_CPU_DECRYPTED(struct kvm_steal_time, steal_time) __aligned(64); static int has_steal_clock = 0; @@ -560,9 +550,6 @@ static void __init kvm_guest_init(void) if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) apic_set_eoi_write(kvm_guest_apic_eoi_write); - if (kvmclock_vsyscall) - kvm_setup_vsyscall_timeinfo(); - #ifdef CONFIG_SMP smp_ops.smp_prepare_cpus = kvm_smp_prepare_cpus; smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu; --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -27,12 +27,14 @@ #include #include +#include #include #include #include #include static int __initdata kvmclock = 1; +static int __initdata kvmclock_vsyscall = 1; static int msr_kvm_system_time __ro_after_init = MSR_KVM_SYSTEM_TIME; static int msr_kvm_wall_clock __ro_after_init = MSR_KVM_WALL_CLOCK; static u64 kvm_sched_clock_offset __ro_after_init; @@ -44,6 +46,13 @@ static int __init parse_no_kvmclock(char } early_param("no-kvmclock", parse_no_kvmclock); +static int __init parse_no_kvmclock_vsyscall(char *arg) +{ + kvmclock_vsyscall = 0; + return 0; +} +early_param("no-kvmclock-vsyscall", parse_no_kvmclock_vsyscall); + /* Aligned to page sizes to match whats mapped via vsyscalls to userspace */ #define HV_CLOCK_SIZE (sizeof(struct pvclock_vsyscall_time_info) * NR_CPUS) @@ -227,6 +236,25 @@ static void kvm_shutdown(void) native_machine_shutdown(); } +static int __init kvm_setup_vsyscall_timeinfo(void) +{ +#ifdef CONFIG_X86_64 + u8 flags; + + if (!hv_clock || !kvmclock_vsyscall) + return 0; + + flags = pvclock_read_flags(&hv_clock[0].pvti); + if (!(flags & PVCLOCK_TSC_STABLE_BIT)) + return 1; + + pvclock_set_pvti_cpu0_va(hv_clock); + kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK; +#endif + return 0; +} +early_initcall(kvm_setup_vsyscall_timeinfo); + void __init kvmclock_init(void) { u8 flags; @@ -241,6 +269,9 @@ void __init kvmclock_init(void) return; } + if (!hypervisor_is_type(X86_HYPER_KVM)) + kvmclock_vsyscall = 0; + pr_info("kvm-clock: Using msrs %x and %x", msr_kvm_system_time, msr_kvm_wall_clock); @@ -270,21 +301,3 @@ void __init kvmclock_init(void) clocksource_register_hz(&kvm_clock, NSEC_PER_SEC); pv_info.name = "KVM"; } - -int __init kvm_setup_vsyscall_timeinfo(void) -{ -#ifdef CONFIG_X86_64 - u8 flags; - - if (!hv_clock) - return 0; - - flags = pvclock_read_flags(&hv_clock[0].pvti); - if (!(flags & PVCLOCK_TSC_STABLE_BIT)) - return 1; - - pvclock_set_pvti_cpu0_va(hv_clock); - kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK; -#endif - return 0; -}