KVM: arm64: Add host/guest KVM-PTP support
Subsystems (13)
Marc Zyngier
maintainerv19 cover KVM: arm64: Add host/guest KVM-PTP support
Given that this series[0] has languished in my Inbox for the best of the past two years, and in an effort to eventually get it merged, I've taken the liberty to pick it up and do the changes I wanted to see instead of waiting to go through yet another round.
All the patches have a link to their original counterpart (though I have squashed a couple of them where it made sense). Tested both 64 and 32bit guests for a good measure. Of course, I claim full responsibility for any bug introduced here.
Unless someone screams now, this is going in 5.13, because I'm frankly fed up with it! ;-)
* From v18 [2]
- Fix kvm_hypercall2() return type
- Rebased on top of 5.12-rc3
- Added RBs
* From v17 [1]:
- Fixed compilation issue on 32bit systems not selecting CONFIG_HAVE_ARM_SMCCC_DISCOVERY
- Fixed KVM service discovery not properly parsing the reply from the hypervisor
* From v16 [0]:
- Moved the KVM service discovery to its own file, plugged it into PSCI instead of the arch code, dropped the inlining, made use of asm/hypervisor.h.
- Tidied-up the namespacing
- Cleanup the hypercall handler
- De-duplicate the guest code
- Tidied-up arm64-specific documentation
- Dropped the generic PTP documentation as it needs a new location, and some cleanup
- Squashed hypercall documentation and capability into the main KVM patch
- Rebased on top of 5.11-rc4
[0] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
Jianyong Wu (4):
ptp: Reorganize ptp_kvm.c to make it arch-independent
clocksource: Add clocksource id for arm arch counter
KVM: arm64: Add support for the KVM PTP service
ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Thomas Gleixner (1):
time: Add mechanism to recognize clocksource in time_get_snapshot
Will Deacon (2):
arm/arm64: Probe for the presence of KVM hypervisor
KVM: arm64: Advertise KVM UID to guests via SMCCC
Documentation/virt/kvm/api.rst | 10 +++
Documentation/virt/kvm/arm/index.rst | 1 +
Documentation/virt/kvm/arm/ptp_kvm.rst | 25 ++++++
arch/arm/include/asm/hypervisor.h | 3 +
arch/arm64/include/asm/hypervisor.h | 3 +
arch/arm64/kvm/arm.c | 1 +
arch/arm64/kvm/hypercalls.c | 80 +++++++++++++++--
drivers/clocksource/arm_arch_timer.c | 36 ++++++++
drivers/firmware/psci/psci.c | 2 +
drivers/firmware/smccc/Makefile | 2 +-
drivers/firmware/smccc/kvm_guest.c | 50 +++++++++++
drivers/firmware/smccc/smccc.c | 1 +
drivers/ptp/Kconfig | 2 +-
drivers/ptp/Makefile | 2 +
drivers/ptp/ptp_kvm_arm.c | 28 ++++++
drivers/ptp/{ptp_kvm.c => ptp_kvm_common.c} | 84 +++++-------------
drivers/ptp/ptp_kvm_x86.c | 97 +++++++++++++++++++++
include/linux/arm-smccc.h | 41 +++++++++
include/linux/clocksource.h | 6 ++
include/linux/clocksource_ids.h | 12 +++
include/linux/ptp_kvm.h | 19 ++++
include/linux/timekeeping.h | 12 +--
include/uapi/linux/kvm.h | 1 +
kernel/time/clocksource.c | 2 +
kernel/time/timekeeping.c | 1 +
25 files changed, 443 insertions(+), 78 deletions(-)
create mode 100644 Documentation/virt/kvm/arm/ptp_kvm.rst
create mode 100644 drivers/firmware/smccc/kvm_guest.c
create mode 100644 drivers/ptp/ptp_kvm_arm.c
rename drivers/ptp/{ptp_kvm.c => ptp_kvm_common.c} (60%)
create mode 100644 drivers/ptp/ptp_kvm_x86.c
create mode 100644 include/linux/clocksource_ids.h
create mode 100644 include/linux/ptp_kvm.hSignature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH v19 1/7 arm/arm64: Probe for the presence of KVM hypervisor
From: Will Deacon <[email protected]>
Although the SMCCC specification provides some limited functionality for describing the presence of hypervisor and firmware services, this is generally applicable only to functions designated as "Arm Architecture Service Functions" and no portable discovery mechanism is provided for standard hypervisor services, despite having a designated range of function identifiers reserved by the specification.
In an attempt to avoid the need for additional firmware changes every time a new function is added, introduce a UID to identify the service provider as being compatible with KVM. Once this has been established, additional services can be discovered via a feature bitmap.
--- arch/arm/include/asm/hypervisor.h | 3 ++ arch/arm64/include/asm/hypervisor.h | 3 ++ drivers/firmware/psci/psci.c | 2 ++ drivers/firmware/smccc/Makefile | 2 +- drivers/firmware/smccc/kvm_guest.c | 50 +++++++++++++++++++++++++++++ drivers/firmware/smccc/smccc.c | 1 + include/linux/arm-smccc.h | 25 +++++++++++++++ 7 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/smccc/kvm_guest.c
arch/arm/include/asm/hypervisor.h +3 -0
@@ -4,4 +4,7 @@#include <asm/xen/hypervisor.h> +void kvm_init_hyp_services (void ); +bool kvm_arm_hyp_service_available (u32 func_id); +#endif
arch/arm64/include/asm/hypervisor.h +3 -0
@@ -4,4 +4,7 @@#include <asm/xen/hypervisor.h> +void kvm_init_hyp_services (void ); +bool kvm_arm_hyp_service_available (u32 func_id); +#endif
drivers/firmware/psci/psci.c +2 -0
@@ -23,6 +23,7 @@#include <asm/cpuidle.h> #include <asm/cputype.h> +#include <asm/hypervisor.h> #include <asm/system_misc.h> #include <asm/smp_plat.h> #include <asm/suspend.h>
@@ -498,6 +499,7 @@ static int __init psci_probe(void)psci_init_cpu_suspend ();psci_init_system_suspend ();psci_init_system_reset2 (); +kvm_init_hyp_services (); }return 0 ;
drivers/firmware/smccc/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 # -obj-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smccc.o +obj-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smccc.o kvm_guest.o obj-$(CONFIG_ARM_SMCCC_SOC_ID) += soc_id.o
drivers/firmware/smccc/kvm_guest.c new file +50 -0
50 lines not on this page · raw message
drivers/firmware/smccc/smccc.c +1 -0
@@ -8,6 +8,7 @@#include <linux/cache.h> #include <linux/init.h> #include <linux/arm-smccc.h> +#include <linux/kernel.h> #include <asm/archrandom.h> static u32 smccc_version =ARM_SMCCC_VERSION_1_0 ;
include/linux/arm-smccc.h +25 -0
@@ -55,6 +55,8 @@#define ARM_SMCCC_OWNER_TRUSTED_OS 50#define ARM_SMCCC_OWNER_TRUSTED_OS_END 63 +#define ARM_SMCCC_FUNC_QUERY_CALL_UID 0xff01 +#define ARM_SMCCC_QUIRK_NONE 0#define ARM_SMCCC_QUIRK_QCOM_A6 1/* Save/restore register a6 */
@@ -87,6 +89,29 @@ ARM_SMCCC_SMC_32, \ 0, 0x7fff) +#define ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_FUNC_QUERY_CALL_UID) + +/* KVM UID value: 28b46fb6-2ec5-11e9-a9ca-4b564d003a74 */ +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 0xb66fb428U +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 0xe911c52eU +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2 0x564bcaa9U +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3 0x743a004dU + +/* KVM "vendor specific" services */ +#define ARM_SMCCC_KVM_FUNC_FEATURES 0 +#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127 +#define ARM_SMCCC_KVM_NUM_FUNCS 128 + +#define ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_FEATURES) +#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1/* Paravirtualised time calls (defined by ARM DEN0057A) */
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Zenghui Yu
reviewerRe: [PATCH v19 1/7] arm/arm64: Probe for the presence of KVM hypervisor
Quoted 1 line · Marc Zyngier
#define
SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED1
I think it'd be better to keep this definition together with other wa Function IDs. It's only a cosmetic comment anyway.
Zenghui
Marc Zyngier
maintainerPATCH v19 2/7 KVM: arm64: Advertise KVM UID to guests via SMCCC
In reply to Marc ZyngierFrom: Will Deacon <[email protected]>
We can advertise ourselves to guests as KVM and provide a basic features bitmap for discoverability of future hypervisor services.
--- arch/arm64/kvm/hypercalls.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
arch/arm64/kvm/hypercalls.c +18 -9
@@ -12,13 +12,13 @@int kvm_hvc_call_handler (struct kvm_vcpu *vcpu) {u32 func_id =smccc_get_function (vcpu); -long val =SMCCC_RET_NOT_SUPPORTED ; +u64 val[4 ] = {SMCCC_RET_NOT_SUPPORTED };u32 feature;gpa_t gpa;switch (func_id) {case ARM_SMCCC_VERSION_FUNC_ID : - val =ARM_SMCCC_VERSION_1_1 ; + val[0 ] =ARM_SMCCC_VERSION_1_1 ;break ;case ARM_SMCCC_ARCH_FEATURES_FUNC_ID : feature =smccc_get_arg1 (vcpu);
@@ -28,10 +28,10 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)case SPECTRE_VULNERABLE :break ;case SPECTRE_MITIGATED : - val =SMCCC_RET_SUCCESS ; + val[0 ] =SMCCC_RET_SUCCESS ;break ;case SPECTRE_UNAFFECTED : - val =SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED ; + val[0 ] =SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED ;break ; }break ;
@@ -54,22 +54,31 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)break ; fallthrough;case SPECTRE_UNAFFECTED : - val =SMCCC_RET_NOT_REQUIRED ; + val[0 ] =SMCCC_RET_NOT_REQUIRED ;break ; }break ;case ARM_SMCCC_HV_PV_TIME_FEATURES : - val =SMCCC_RET_SUCCESS ; + val[0 ] =SMCCC_RET_SUCCESS ;break ; }break ;case ARM_SMCCC_HV_PV_TIME_FEATURES : - val =kvm_hypercall_pv_features (vcpu); + val[0 ] =kvm_hypercall_pv_features (vcpu);break ;case ARM_SMCCC_HV_PV_TIME_ST : gpa =kvm_init_stolen_time (vcpu);if (gpa !=GPA_INVALID ) - val = gpa; + val[0 ] = gpa; +break ; +case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID : + val[0 ] =ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 ; + val[1 ] =ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 ; + val[2 ] =ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2 ; + val[3 ] =ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3 ; +break ; +case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID : + val[0 ] =BIT (ARM_SMCCC_KVM_FUNC_FEATURES );break ;case ARM_SMCCC_TRNG_VERSION :case ARM_SMCCC_TRNG_FEATURES :
@@ -81,6 +90,6 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)return kvm_psci_call (vcpu); } -smccc_set_retval (vcpu, val,0 ,0 ,0 ); +smccc_set_retval (vcpu, val[0 ], val[1 ], val[2 ], val[3 ]);return 1 ; }
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH v19 3/7 ptp: Reorganize ptp_kvm.c to make it arch-independent
In reply to Marc ZyngierFrom: Jianyong Wu <[email protected]>
Currently, the ptp_kvm module contains a lot of x86-specific code. Let's move this code into a new arch-specific file in the same directory, and rename the arch-independent file to ptp_kvm_common.c.
---
drivers/ptp/Makefile | 1 +
drivers/ptp/{ptp_kvm.c => ptp_kvm_common.c} | 84 +++++-------------
drivers/ptp/ptp_kvm_x86.c | 97 +++++++++++++++++++++
include/linux/ptp_kvm.h | 19 ++++
4 files changed, 139 insertions(+), 62 deletions(-)
rename drivers/ptp/{ptp_kvm.c => ptp_kvm_common.c} (60%)
create mode 100644 drivers/ptp/ptp_kvm_x86.c
create mode 100644 include/linux/ptp_kvm.hdrivers/ptp/Makefile +1 -0
@@ -4,6 +4,7 @@ # ptp-y := ptp_clock.o ptp_chardev.o ptp_sysfs.o +ptp_kvm-$(CONFIG_X86) := ptp_kvm_x86.o ptp_kvm_common.o obj-$(CONFIG_PTP_1588_CLOCK) += ptp.o obj-$(CONFIG_PTP_1588_CLOCK_DTE) += ptp_dte.o obj-$(CONFIG_PTP_1588_CLOCK_INES) += ptp_ines.o
drivers/ptp/ptp_kvm_common.c renamed from drivers/ptp/ptp_kvm.c +22 -62
130 lines not on this page · raw message
drivers/ptp/ptp_kvm_x86.c new file +97 -0
97 lines not on this page · raw message
include/linux/ptp_kvm.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Virtual PTP 1588 clock for use with KVM guests +* +* Copyright (C) 2017 Red Hat Inc. +*/ + +#ifndef _PTP_KVM_H_ +#define _PTP_KVM_H_ + +struct timespec64 ; +struct clocksource ; + +int kvm_arch_ptp_init (void ); +int kvm_arch_ptp_get_clock (struct timespec64 *ts); +int kvm_arch_ptp_get_crosststamp (u64 *cycle, +struct timespec64 *tspec,struct clocksource **cs); + +#endif /* _PTP_KVM_H_ */
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH v19 3/7] ptp: Reorganize ptp_kvm.c to make it arch-independent
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
Currently, the
ptp_kvmmodule contains a lot of x86-specific code. Let's move this code into a new arch-specific file in the same directory, and rename the arch-independent file toptp_kvm_common.c.Reviewed-by Andre Przywara <[email protected]>Signed-off-by Jianyong Wu <[email protected]>Signed-off-by Marc Zyngier <[email protected]>
Richard, Paolo,
Can I get an Ack on this and patch #7? We're getting pretty close to the next merge window, and this series has been going on for a couple of years now...
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Re: [PATCH v19 3/7] ptp: Reorganize ptp_kvm.c to make it arch-independent
Quoted 14 lines · Marc Zyngier
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
Currently, the
ptp_kvmmodule contains a lot of x86-specific code. Let's move this code into a new arch-specific file in the same directory, and rename the arch-independent file toptp_kvm_common.c.Reviewed-by Andre Przywara <[email protected]>Signed-off-by Jianyong Wu <[email protected]>Signed-off-by Marc Zyngier <[email protected]>
Quoted 5 lines
Richard, Paolo,
Can I get an Ack on this and patch #7? We're getting pretty close to the next merge window, and this series has been going on for a couple of years now...
For both patches:
Marc Zyngier
maintainerRe: [PATCH v19 3/7] ptp: Reorganize ptp_kvm.c to make it arch-independent
Quoted 18 lines · Richard Cochran
Quoted 16 lines · Marc Zyngier
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
Currently, the
ptp_kvmmodule contains a lot of x86-specific code. Let's move this code into a new arch-specific file in the same directory, and rename the arch-independent file toptp_kvm_common.c.Reviewed-by Andre Przywara <[email protected]>Signed-off-by Jianyong Wu <[email protected]>Signed-off-by Marc Zyngier <[email protected]>Richard, Paolo,
Quoted 7 lines
Quoted 3 lines
Can I get an Ack on this and patch #7? We're getting pretty close to the next merge window, and this series has been going on for a couple of years now...
For both patches:
Acked-by Richard Cochran <[email protected]>
Cheers Richard, much appreciated.
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH v19 4/7 time: Add mechanism to recognize clocksource in time_get_snapshot
In reply to Marc ZyngierFrom: Thomas Gleixner <[email protected]>
System time snapshots are not conveying information about the current clocksource which was used, but callers like the PTP KVM guest implementation have the requirement to evaluate the clocksource type to select the appropriate mechanism.
Introduce a clocksource id field in struct clocksource which is by default set to CSID_GENERIC (0). Clocksource implementations can set that field to a value which allows to identify the clocksource.
Store the clocksource id of the current clocksource in the system_time_snapshot so callers can evaluate which clocksource was used to take the snapshot and act accordingly.
--- include/linux/clocksource.h | 6 ++++++ include/linux/clocksource_ids.h | 11 +++++++++++ include/linux/timekeeping.h | 12 +++++++----- kernel/time/clocksource.c | 2 ++ kernel/time/timekeeping.c | 1 + 5 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 include/linux/clocksource_ids.h
include/linux/clocksource.h +6 -0
@@ -17,6 +17,7 @@#include <linux/timer.h> #include <linux/init.h> #include <linux/of.h> +#include <linux/clocksource_ids.h> #include <asm/div64.h> #include <asm/io.h>
@@ -62,6 +63,10 @@ struct module;* 400-499: Perfect * The ideal clocksource. A must-use where * available. +* @id: Defaults to CSID_GENERIC. The id value is captured +* in certain snapshot functions to allow callers to +* validate the clocksource from which the snapshot was +* taken. * @flags: Flags describing special properties * @enable: Optional function to enable the clocksource * @disable: Optional function to disable the clocksource
@@ -100,6 +105,7 @@ struct clocksource {const char *name;struct list_head list;int rating; +enum clocksource_ids id;enum vdso_clock_mode vdso_clock_mode;unsigned long flags;
include/linux/clocksource_ids.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CLOCKSOURCE_IDS_H +#define _LINUX_CLOCKSOURCE_IDS_H + +/* Enum to give clocksources a unique identifier */ +enum clocksource_ids { +CSID_GENERIC =0 , +CSID_MAX , +}; + +#endif
include/linux/timekeeping.h +7 -5
@@ -3,6 +3,7 @@#define _LINUX_TIMEKEEPING_H#include <linux/errno.h> +#include <linux/clocksource_ids.h> /* Included from linux/ktime.h */
@@ -243,11 +244,12 @@ struct ktime_timestamps {* @cs_was_changed_seq: The sequence number of clocksource change events */ struct system_time_snapshot { -u64 cycles; -ktime_t real; -ktime_t raw; -unsigned int clock_was_set_seq; -u8 cs_was_changed_seq; +u64 cycles; +ktime_t real; +ktime_t raw; +enum clocksource_ids cs_id; +unsigned int clock_was_set_seq; +u8 cs_was_changed_seq; };/**
kernel/time/clocksource.c +2 -0
@@ -920,6 +920,8 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)clocksource_arch_init (cs); +if (WARN_ON_ONCE ((unsigned int )cs->id >=CSID_MAX )) + cs->id =CSID_GENERIC ;if (cs->vdso_clock_mode <0 || cs->vdso_clock_mode >=VDSO_CLOCKMODE_MAX ) { pr_warn("clocksource %s registered with invalid VDSO mode %d. Disabling VDSO support.\n",
kernel/time/timekeeping.c +1 -0
@@ -1048,6 +1048,7 @@ void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot) do { seq = read_seqcount_begin(&tk_core.seq); now = tk_clock_read(&tk->tkr_mono); + systime_snapshot->cs_id = tk->tkr_mono.clock->id; systime_snapshot->cs_was_changed_seq = tk->cs_was_changed_seq; systime_snapshot->clock_was_set_seq = tk->clock_was_set_seq; base_real = ktime_add(tk->tkr_mono.base,
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Zenghui Yu
reviewerRe: [PATCH v19 4/7] time: Add mechanism to recognize clocksource in time_get_snapshot
include/linux/timekeeping.h struct ktime_timestamps { · line 250
Quoted 9 lines · Marc Zyngier
include/linux/timekeeping.h +4
-5-u64 cycles; -ktime_t real; -ktime_t raw; -unsigned int clock_was_set_seq; -u8 cs_was_changed_seq; +u64 cycles; +ktime_t real; +ktime_t raw; +enum clocksource_ids cs_id;
nit: worth adding a description for it (on top of the structure)?
Quoted 2 lines
include/linux/timekeeping.h +2
-0+unsigned int clock_was_set_seq; +u8 cs_was_changed_seq;
Marc Zyngier
maintainerPATCH v19 5/7 clocksource: Add clocksource id for arm arch counter
In reply to Marc ZyngierFrom: Jianyong Wu <[email protected]>
Add clocksource id to the ARM generic counter so that it can be easily identified from callers such as ptp_kvm.
--- drivers/clocksource/arm_arch_timer.c | 2 ++ include/linux/clocksource_ids.h | 1 + 2 files changed, 3 insertions(+)
drivers/clocksource/arm_arch_timer.c +2 -0
@@ -16,6 +16,7 @@#include <linux/cpu_pm.h> #include <linux/clockchips.h> #include <linux/clocksource.h> +#include <linux/clocksource_ids.h> #include <linux/interrupt.h> #include <linux/of_irq.h> #include <linux/of_address.h>
@@ -191,6 +192,7 @@ static u64 arch_counter_read_cc(const struct cyclecounter *cc)static struct clocksource clocksource_counter = { .name ="arch_sys_counter" , + .id =CSID_ARM_ARCH_COUNTER , .rating =400 , .read = arch_counter_read, .mask =CLOCKSOURCE_MASK (56 ),
include/linux/clocksource_ids.h +1 -0
@@ -5,6 +5,7 @@/* Enum to give clocksources a unique identifier */ enum clocksource_ids {CSID_GENERIC =0 , +CSID_ARM_ARCH_COUNTER ,CSID_MAX , };
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH v19 6/7 KVM: arm64: Add support for the KVM PTP service
In reply to Marc ZyngierFrom: Jianyong Wu <[email protected]>
Implement the hypervisor side of the KVM PTP interface.
The service offers wall time and cycle count from host to guest. The caller must specify whether they want the host's view of either the virtual or physical counter.
--- Documentation/virt/kvm/api.rst | 10 +++++ Documentation/virt/kvm/arm/index.rst | 1 + Documentation/virt/kvm/arm/ptp_kvm.rst | 25 ++++++++++++ arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hypercalls.c | 53 ++++++++++++++++++++++++++ include/linux/arm-smccc.h | 16 ++++++++ include/uapi/linux/kvm.h | 1 + 7 files changed, 107 insertions(+) create mode 100644 Documentation/virt/kvm/arm/ptp_kvm.rst
Documentation/virt/kvm/api.rst +10 -0
@@ -6724,3 +6724,13 @@ vcpu_info is set. The KVM_XEN_HVM_CONFIG_RUNSTATE flag indicates that the runstate-related features KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR/_CURRENT/_DATA/_ADJUST are supported by the KVM_XEN_VCPU_SET_ATTR/KVM_XEN_VCPU_GET_ATTR ioctls. + +8.31 KVM_CAP_PTP_KVM +-------------------- + +:Architectures: arm64 + +This capability indicates that the KVM virtual PTP service is +supported in the host. A VMM can check whether the service is +available to the guest on migration. +
Documentation/virt/kvm/arm/index.rst +1 -0
@@ -10,3 +10,4 @@ ARM hyp-abi psci pvtime + ptp_kvm
Documentation/virt/kvm/arm/ptp_kvm.rst new file +25 -0
@@ -0,0 +1,25 @@ +.. SPDX-License-Identifier: GPL-2.0 + +PTP_KVM support for arm/arm64 +============================= + +PTP_KVM is used for high precision time sync between host and guests. +It relies on transferring the wall clock and counter value from the +host to the guest using a KVM-specific hypercall. + +* ARM_SMCCC_HYP_KVM_PTP_FUNC_ID: 0x86000001 + +This hypercall uses the SMC32/HVC32 calling convention: + +ARM_SMCCC_HYP_KVM_PTP_FUNC_ID + ============= ========== ========== + Function ID: (uint32) 0x86000001 + Arguments: (uint32) KVM_PTP_VIRT_COUNTER(0) + KVM_PTP_PHYS_COUNTER(1) + Return Values: (int32) NOT_SUPPORTED(-1) on error, or + (uint32) Upper 32 bits of wall clock time (r0) + (uint32) Lower 32 bits of wall clock time (r1) + (uint32) Upper 32 bits of counter (r2) + (uint32) Lower 32 bits of counter (r3) + Endianness: No Restrictions. + ============= ========== ==========
arch/arm64/kvm/arm.c +1 -0
@@ -206,6 +206,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_ARM_INJECT_EXT_DABT :case KVM_CAP_SET_GUEST_DEBUG :case KVM_CAP_VCPU_ATTRIBUTES : +case KVM_CAP_PTP_KVM : r =1 ;break ;case KVM_CAP_ARM_SET_DEVICE_ADDR :
arch/arm64/kvm/hypercalls.c +53 -0
65 lines not on this page · raw message
include/linux/arm-smccc.h +16 -0
@@ -103,6 +103,7 @@/* KVM "vendor specific" services */ #define ARM_SMCCC_KVM_FUNC_FEATURES 0 +#define ARM_SMCCC_KVM_FUNC_PTP 1#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127#define ARM_SMCCC_KVM_NUM_FUNCS 128
@@ -114,6 +115,21 @@#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1 +/* +* ptp_kvm is a feature used for time sync between vm and host. +* ptp_kvm module in guest kernel will get service from host using +* this hypercall ID. +*/ +#define ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_PTP) + +/* ptp_kvm counter type ID */ +#define KVM_PTP_VIRT_COUNTER 0 +#define KVM_PTP_PHYS_COUNTER 1 +/* Paravirtualised time calls (defined by ARM DEN0057A) */ #define ARM_SMCCC_HV_PV_TIME_FEATURES \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
include/uapi/linux/kvm.h +1 -0
@@ -1078,6 +1078,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_DIRTY_LOG_RING 192#define KVM_CAP_X86_BUS_LOCK_EXIT 193#define KVM_CAP_PPC_DAWR1 194 +#define KVM_CAP_PTP_KVM 195#ifdef KVM_CAP_IRQ_ROUTING
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Zenghui Yu
reviewerRe: [PATCH v19 6/7] KVM: arm64: Add support for the KVM PTP service
Documentation/virt/kvm/arm/ptp_kvm.rst line 10
Quoted 8 lines · Marc Zyngier
Documentation/virt/kvm/arm/ptp_kvm.rst new file +8
-0+PTP_KVM support for arm/arm64 +============================= + +PTP_KVM is used for high precision time sync between host and guests. +It relies on transferring the wall clock and counter value from the +host to the guest using a KVM-specific hypercall. + +* ARM_SMCCC_HYP_KVM_PTP_FUNC_ID: 0x86000001
Per include/linux/arm-smccc.h, this should beARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID.
Documentation/virt/kvm/arm/ptp_kvm.rst line 14
Quoted 4 lines
Documentation/virt/kvm/arm/ptp_kvm.rst new file +4
-0+ +This hypercall uses the SMC32/HVC32 calling convention: + +ARM_SMCCC_HYP_KVM_PTP_FUNC_ID
ditto
Quoted 4 lines
Documentation/virt/kvm/arm/ptp_kvm.rst new file +4
-0+ ============= ========== ========== + Function ID: (uint32) 0x86000001 + Arguments: (uint32) KVM_PTP_VIRT_COUNTER(0) + KVM_PTP_PHYS_COUNTER(1)
Marc Zyngier
maintainerRe: [PATCH v19 6/7] KVM: arm64: Add support for the KVM PTP service
Quoted 13 lines · Zenghui Yu
Documentation/virt/kvm/arm/ptp_kvm.rst line 10
Quoted 8 lines · Marc Zyngier
Documentation/virt/kvm/arm/ptp_kvm.rst new file +8
-0+PTP_KVM support for arm/arm64 +============================= + +PTP_KVM is used for high precision time sync between host and guests. +It relies on transferring the wall clock and counter value from the +host to the guest using a KVM-specific hypercall. + +* ARM_SMCCC_HYP_KVM_PTP_FUNC_ID: 0x86000001Per
include/linux/arm-smccc.h, this should beARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID.
Well spotted. Care to send a patch on top of my kvm-arm64/ptp branch?
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Zenghui Yu
reviewerRe: [PATCH v19 6/7] KVM: arm64: Add support for the KVM PTP service
Quoted 16 lines · Marc Zyngier
Quoted 13 lines · Zenghui Yu
Documentation/virt/kvm/arm/ptp_kvm.rst line 10
Quoted 8 lines · Marc Zyngier
Documentation/virt/kvm/arm/ptp_kvm.rst new file +8
-0+PTP_KVM support for arm/arm64 +============================= + +PTP_KVM is used for high precision time sync between host and guests. +It relies on transferring the wall clock and counter value from the +host to the guest using a KVM-specific hypercall. + +* ARM_SMCCC_HYP_KVM_PTP_FUNC_ID: 0x86000001Per
include/linux/arm-smccc.h, this should beARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID.
Quoted 1 line
Well spotted. Care to send a patch on top of my kvm-arm64/ptp branch?
Okay. I'll have a patch for that.
Zenghui
Marc Zyngier
maintainerPATCH v19 7/7 ptp: arm/arm64: Enable ptp_kvm for arm/arm64
In reply to Marc ZyngierFrom: Jianyong Wu <[email protected]>
Currently, there is no mechanism to keep time sync between guest and host in arm/arm64 virtualization environment. Time in guest will drift compared with host after boot up as they may both use third party time sources to correct their time respectively. The time deviation will be in order of milliseconds. But in some scenarios,like in cloud environment, we ask for higher time precision.
kvm ptp clock, which chooses the host clock source as a reference clock to sync time between guest and host, has been adopted by x86 which takes the time sync order from milliseconds to nanoseconds.
This patch enables kvm ptp clock for arm/arm64 and improves clock sync precision significantly.
Test result comparisons between with kvm ptp clock and without it in arm/arm64 are as follows. This test derived from the result of command 'chronyc sources'. we should take more care of the last sample column which shows the offset between the local clock and the source at the last measurement.
no kvm ptp in guest:
MS Name/IP address Stratum Poll Reach LastRx Last sample
========================================================================
^* dns1.synet.edu.cn 2 6 377 13 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 21 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 29 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 37 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 45 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 53 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 61 +1040us[+1581us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 4 -130us[ +796us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 12 -130us[ +796us] +/- 21ms ^* dns1.synet.edu.cn 2 6 377 20 -130us[ +796us] +/- 21ms
in host:
MS Name/IP address Stratum Poll Reach LastRx Last sample
========================================================================
^* 120.25.115.20 2 7 377 72 -470us[ -603us] +/- 18ms ^* 120.25.115.20 2 7 377 92 -470us[ -603us] +/- 18ms ^* 120.25.115.20 2 7 377 112 -470us[ -603us] +/- 18ms ^* 120.25.115.20 2 7 377 2 +872ns[-6808ns] +/- 17ms ^* 120.25.115.20 2 7 377 22 +872ns[-6808ns] +/- 17ms ^* 120.25.115.20 2 7 377 43 +872ns[-6808ns] +/- 17ms ^* 120.25.115.20 2 7 377 63 +872ns[-6808ns] +/- 17ms ^* 120.25.115.20 2 7 377 83 +872ns[-6808ns] +/- 17ms ^* 120.25.115.20 2 7 377 103 +872ns[-6808ns] +/- 17ms ^* 120.25.115.20 2 7 377 123 +872ns[-6808ns] +/- 17ms
The dns1.synet.edu.cn is the network reference clock for guest and 120.25.115.20 is the network reference clock for host. we can't get the clock error between guest and host directly, but a roughly estimated value will be in order of hundreds of us to ms.
with kvm ptp in guest:
chrony has been disabled in host to remove the disturb by network clock.
MS Name/IP address Stratum Poll Reach LastRx Last sample
========================================================================
* PHC0 0 3 377 8 -7ns[ +1ns] +/- 3ns * PHC0 0 3 377 8 +1ns[ +16ns] +/- 3ns * PHC0 0 3 377 6 -4ns[ -0ns] +/- 6ns * PHC0 0 3 377 6 -8ns[ -12ns] +/- 5ns * PHC0 0 3 377 5 +2ns[ +4ns] +/- 4ns * PHC0 0 3 377 13 +2ns[ +4ns] +/- 4ns * PHC0 0 3 377 12 -4ns[ -6ns] +/- 4ns * PHC0 0 3 377 11 -8ns[ -11ns] +/- 6ns * PHC0 0 3 377 10 -14ns[ -20ns] +/- 4ns * PHC0 0 3 377 8 +4ns[ +5ns] +/- 4ns
The PHC0 is the ptp clock which choose the host clock as its source clock. So we can see that the clock difference between host and guest is in order of ns.
--- drivers/clocksource/arm_arch_timer.c | 34 ++++++++++++++++++++++++++++ drivers/ptp/Kconfig | 2 +- drivers/ptp/Makefile | 1 + drivers/ptp/ptp_kvm_arm.c | 28 +++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 drivers/ptp/ptp_kvm_arm.c
drivers/clocksource/arm_arch_timer.c +34 -0
@@ -25,6 +25,8 @@#include <linux/sched/clock.h> #include <linux/sched_clock.h> #include <linux/acpi.h> +#include <linux/arm-smccc.h> +#include <linux/ptp_kvm.h> #include <asm/arch_timer.h> #include <asm/virt.h>
@@ -1659,3 +1661,35 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table) }TIMER_ACPI_DECLARE (arch_timer,ACPI_SIG_GTDT , arch_timer_acpi_init);#endif + +int kvm_arch_ptp_get_crosststamp (u64 *cycle,struct timespec64 *ts, +struct clocksource **cs) +{ +struct arm_smccc_res hvc_res; +u32 ptp_counter; +ktime_t ktime; + +if (!IS_ENABLED (CONFIG_HAVE_ARM_SMCCC_DISCOVERY )) +return -EOPNOTSUPP ; + +if (arch_timer_uses_ppi ==ARCH_TIMER_VIRT_PPI ) + ptp_counter =KVM_PTP_VIRT_COUNTER ; +else + ptp_counter =KVM_PTP_PHYS_COUNTER ; + +arm_smccc_1_1_invoke (ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID , + ptp_counter, &hvc_res); + +if ((int )(hvc_res.a0) <0 ) +return -EOPNOTSUPP ; + + ktime = (u64 )hvc_res.a0 <<32 | hvc_res.a1; + *ts =ktime_to_timespec64 (ktime); +if (cycle) + *cycle = (u64 )hvc_res.a2 <<32 | hvc_res.a3; +if (cs) + *cs = &clocksource_counter; + +return 0 ; +} +EXPORT_SYMBOL_GPL (kvm_arch_ptp_get_crosststamp);
drivers/ptp/Kconfig +1 -1
@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER) default y help This driver adds support for using kvm infrastructure as a PTP
drivers/ptp/Makefile +1 -0
@@ -5,6 +5,7 @@ ptp-y := ptp_clock.o ptp_chardev.o ptp_sysfs.o ptp_kvm-$(CONFIG_X86) := ptp_kvm_x86.o ptp_kvm_common.o +ptp_kvm-$(CONFIG_HAVE_ARM_SMCCC) := ptp_kvm_arm.o ptp_kvm_common.o obj-$(CONFIG_PTP_1588_CLOCK) += ptp.o obj-$(CONFIG_PTP_1588_CLOCK_DTE) += ptp_dte.o obj-$(CONFIG_PTP_1588_CLOCK_INES) += ptp_ines.o
drivers/ptp/ptp_kvm_arm.c new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Virtual PTP 1588 clock for use with KVM guests +* Copyright (C) 2019 ARM Ltd. +* All Rights Reserved +*/ + +#include <linux/arm-smccc.h> +#include <linux/ptp_kvm.h> + +#include <asm/arch_timer.h> +#include <asm/hypervisor.h> + +int kvm_arch_ptp_init (void ) +{ +int ret; + + ret =kvm_arm_hyp_service_available (ARM_SMCCC_KVM_FUNC_PTP ); +if (ret <=0 ) +return -EOPNOTSUPP ; + +return 0 ; +} + +int kvm_arch_ptp_get_clock (struct timespec64 *ts) +{ +return kvm_arch_ptp_get_crosststamp (NULL , ts,NULL ); +}
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Zenghui Yu
reviewerRe: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
drivers/ptp/ptp_kvm_arm.c line 19
Quoted 6 lines · Marc Zyngier
drivers/ptp/ptp_kvm_arm.c new file +6
-0+int kvm_arch_ptp_init (void ) +{ +int ret; + + ret =kvm_arm_hyp_service_available (ARM_SMCCC_KVM_FUNC_PTP ); +if (ret <=0 )
kvm_arm_hyp_service_available() returns boolean. Maybe write as ?
bool ret; ret = kvm_arm_hyp_service_available(); if (!ret) return -ENODEV;
Quoted 4 lines
drivers/clocksource/arm_arch_timer.c +4
-0+return -EOPNOTSUPP ; + +return 0 ; +}
Marc Zyngier
maintainerRe: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Quoted 11 lines · Zenghui Yu
drivers/ptp/ptp_kvm_arm.c line 19
Quoted 6 lines · Marc Zyngier
drivers/ptp/ptp_kvm_arm.c new file +6
-0+int kvm_arch_ptp_init (void ) +{ +int ret; + + ret =kvm_arm_hyp_service_available (ARM_SMCCC_KVM_FUNC_PTP ); +if (ret <=0 )
kvm_arm_hyp_service_available()returns boolean. Maybe write as ?
Quoted 5 lines
bool ret; ret = kvm_arm_hyp_service_available(); if (!ret) return -ENODEV;
Fixed in 300bb1fe7671, as previously reported by Dan Carpenter in [1].
Thanks,
M.
https://lore.kernel.org/r/20210331043704.GG2065@kadam
Signature · 1 line
Without deviation from the norm, progress is not possible.
Re: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
In reply to Marc ZyngierHi Marc, Jianyong,
Quoted 19 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
Currently, there is no mechanism to keep time sync between guest and host in arm/arm64 virtualization environment. Time in guest will drift compared with host after boot up as they may both use third party time sources to correct their time respectively. The time deviation will be in order of milliseconds. But in some scenarios,like in cloud environment, we ask for higher time precision.
kvm ptp clock, which chooses the host clock source as a reference clock to sync time between guest and host, has been adopted by x86 which takes the time sync order from milliseconds to nanoseconds.
This patch enables kvm ptp clock for arm/arm64 and improves clock sync precision significantly.
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 111
Quoted 5 lines
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)
Why does this not depend on KVM_GUEST on ARM?
I.e. shouldn't the dependency be:
KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))
?
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 114
Quoted 3 lines
drivers/ptp/Kconfig +0
-0default y help This driver adds support for using kvm infrastructure as a PTP
Gr{oetje,eeting}s,
Geert
Signature · 9 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Hi Geert,
Quoted 32 lines · Geert Uytterhoeven
Hi Marc, Jianyong,
Quoted 19 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
Currently, there is no mechanism to keep time sync between guest and host in arm/arm64 virtualization environment. Time in guest will drift compared with host after boot up as they may both use third party time sources to correct their time respectively. The time deviation will be in order of milliseconds. But in some scenarios,like in cloud environment, we ask for higher time precision.
kvm ptp clock, which chooses the host clock source as a reference clock to sync time between guest and host, has been adopted by x86 which takes the time sync order from milliseconds to nanoseconds.
This patch enables kvm ptp clock for arm/arm64 and improves clock sync precision significantly.
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 112
Quoted 6 lines
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)Why does this not depend on
KVM_GUESTon ARM?
I.e. shouldn't the dependency be:
Quoted 3 lines
KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))?
arm/arm64 do not select KVM_GUEST. Any kernel can be used for a guest, and KVM/arm64 doesn't know about this configuration symbol.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Hi Marc,
Quoted 36 lines · Marc Zyngier
Quoted 35 lines · Geert Uytterhoeven
Quoted 24 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
Currently, there is no mechanism to keep time sync between guest and host
in arm/arm64 virtualization environment. Time in guest will drift compared
with host after boot up as they may both use third party time sources to correct their time respectively. The time deviation will be in order
of milliseconds. But in some scenarios,like in cloud environment, we ask
for higher time precision.kvm ptp clock, which chooses the host clock source as a reference clock to sync time between guest and host, has been adopted by x86 which takes the time sync order from milliseconds to nanoseconds.
This patch enables kvm ptp clock for arm/arm64 and improves clock sync precision
significantly.drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 112
Quoted 6 lines
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)Why does this not depend on
KVM_GUESTon ARM?
I.e. shouldn't the dependency be:
Quoted 6 lines
Quoted 3 lines
KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))?
arm/arm64 do not select
KVM_GUEST. Any kernel can be used for a guest, and KVM/arm64 doesn't know about this configuration symbol.
OK.
Does PTP_1588_CLOCK_KVM need to default to yes?
Perhaps only on X86, to maintain the status quo?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Marc Zyngier
maintainerRe: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Hi Geert,
Quoted 25 lines · Geert Uytterhoeven
Hi Marc,
Quoted 21 lines · Marc Zyngier
Quoted 19 lines · Geert Uytterhoeven
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 112
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)Why does this not depend on
KVM_GUESTon ARM?
I.e. shouldn't the dependency be:KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))?
Quoted 7 lines
Quoted 2 lines
arm/arm64 do not select
KVM_GUEST. Any kernel can be used for a guest, and KVM/arm64 doesn't know about this configuration symbol.OK.
Does
PTP_1588_CLOCK_KVMneed to default to yes?
Perhaps only on X86, to maintain the status quo?
I think I don't really understand the problem you are trying to solve. Is it that 'make oldconfig' now asks you about this new driver? Why is that an issue?
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Hi Marc,
Quoted 27 lines · Marc Zyngier
Quoted 25 lines · Geert Uytterhoeven
Quoted 23 lines · Marc Zyngier
Quoted 16 lines · Geert Uytterhoeven
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 112
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)Why does this not depend on
KVM_GUESTon ARM?
I.e. shouldn't the dependency be:Quoted 3 lines
KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))?
arm/arm64 do not select
KVM_GUEST. Any kernel can be used for a guest, and KVM/arm64 doesn't know about this configuration symbol.
Quoted 8 lines
Quoted 4 lines
OK.
Does
PTP_1588_CLOCK_KVMneed to default to yes?
Perhaps only on X86, to maintain the status quo?I think I don't really understand the problem you are trying to solve. Is it that 'make oldconfig' now asks you about this new driver? Why is that an issue?
My first "problem" was that it asked about this new driver on arm/arm64, while I assumed there were some missing dependencies (configuring a kernel should not ask useless questions). That turned out to be a wrong assumption, so there is no such problem here.
The second problem is "default y": code that is not critical should not be enabled by default. Hence my last question.
Thanks!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Marc Zyngier
maintainerRe: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Quoted 40 lines · Geert Uytterhoeven
Hi Marc,
Quoted 27 lines · Marc Zyngier
Quoted 25 lines · Geert Uytterhoeven
Quoted 23 lines · Marc Zyngier
Quoted 16 lines · Geert Uytterhoeven
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 112
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)Why does this not depend on
KVM_GUESTon ARM?
I.e. shouldn't the dependency be:Quoted 3 lines
KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))?
arm/arm64 do not select
KVM_GUEST. Any kernel can be used for a guest, and KVM/arm64 doesn't know about this configuration symbol.Quoted 8 lines
Quoted 4 lines
OK.
Does
PTP_1588_CLOCK_KVMneed to default to yes?
Perhaps only on X86, to maintain the status quo?I think I don't really understand the problem you are trying to solve. Is it that 'make oldconfig' now asks you about this new driver? Why is that an issue?
Quoted 7 lines
My first "problem" was that it asked about this new driver on arm/arm64, while I assumed there were some missing dependencies (configuring a kernel should not ask useless questions). That turned out to be a wrong assumption, so there is no such problem here.
The second problem is "default y": code that is not critical should not be enabled by default. Hence my last question.
I think consistency between architectures is important. Certainly, distributions depend on that, and we otherwise end-up with distro kernels missing functionalities.
The notion of "critical" is also pretty relative. defconfig contains a gazillion of things that are not critical to most people, for example, and yet misses a bunch of things that are needed to boot on some of my systems.
That's just to say that I find it difficult to make that choice from the PoV of a kernel hacker. I'm personally more inclined to leave things enabled and let people *disable* things if they want to reduce the footprint of their kernel.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Re: [PATCH v19 7/7] ptp: arm/arm64: Enable ptp_kvm for arm/arm64
Hi Marc,
Quoted 44 lines · Marc Zyngier
Quoted 42 lines · Geert Uytterhoeven
Quoted 27 lines · Marc Zyngier
Quoted 25 lines · Geert Uytterhoeven
Quoted 23 lines · Marc Zyngier
Quoted 16 lines · Geert Uytterhoeven
drivers/ptp/Kconfig config PTP_1588_CLOCK_PCH · line 112
Quoted 11 lines · Marc Zyngier
From: Jianyong Wu <[email protected]>
drivers/ptp/Kconfig +1
-1@@ -108,7 +108,7 @@ config PTP_1588_CLOCK_PCH config PTP_1588_CLOCK_KVM tristate "KVM virtual PTP clock" depends on PTP_1588_CLOCK - depends on KVM_GUEST && X86 + depends on (KVM_GUEST && X86) || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER)Why does this not depend on
KVM_GUESTon ARM?
I.e. shouldn't the dependency be:Quoted 3 lines
KVM_GUEST && (X86 || (HAVE_ARM_SMCCC_DISCOVERY && ARM_ARCH_TIMER))?
arm/arm64 do not select
KVM_GUEST. Any kernel can be used for a guest, and KVM/arm64 doesn't know about this configuration symbol.Quoted 8 lines
Quoted 4 lines
OK.
Does
PTP_1588_CLOCK_KVMneed to default to yes?
Perhaps only on X86, to maintain the status quo?I think I don't really understand the problem you are trying to solve. Is it that 'make oldconfig' now asks you about this new driver? Why is that an issue?
My first "problem" was that it asked about this new driver on arm/arm64, while I assumed there were some missing dependencies (configuring a kernel should not ask useless questions). That turned out to be a wrong assumption, so there is no such problem here.
Quoted 8 lines
Quoted 2 lines
The second problem is "default y": code that is not critical should not be enabled by default. Hence my last question.
I think consistency between architectures is important. Certainly, distributions depend on that, and we otherwise end-up with distro kernels missing functionalities.
The notion of "critical" is also pretty relative. defconfig contains a
I'm not talking about defconfig, but about "default y" in defconfig.
Quoted 3 lines
gazillion of things that are not critical to most people, for example, and yet misses a bunch of things that are needed to boot on some of my systems.
Perhaps those should be added, so those systems can be tested using defconfig? At least for arm64, I think that's aligned with the arm64 defconfig policy.
Quoted 4 lines
That's just to say that I find it difficult to make that choice from the PoV of a kernel hacker. I'm personally more inclined to leave things enabled and let people *disable* things if they want to reduce the footprint of their kernel.
The standard question to respond to w.r.t. "default y" is: "Why is your feature so special that it needs to be enabled by default?", which implies "default y" is the exception, not the rule.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds