Commit 9f08890a authored by Joao Martins's avatar Joao Martins Committed by Boris Ostrovsky

x86/pvclock: add setter for pvclock_pvti_cpu0_va

Right now there is only a pvclock_pvti_cpu0_va() which is defined
on kvmclock since:

commit dac16fba
("x86/vdso: Get pvclock data from the vvar VMA instead of the fixmap")

The only user of this interface so far is kvm. This commit adds a
setter function for the pvti page and moves pvclock_pvti_cpu0_va
to pvclock, which is a more generic place to have it; and would
allow other PV clocksources to use it, such as Xen.

While moving pvclock_pvti_cpu0_va into pvclock, rename also this
function to pvclock_get_pvti_cpu0_va (including its call sites)
to be symmetric with the setter (pvclock_set_pvti_cpu0_va).
Signed-off-by: default avatarJoao Martins <>
Acked-by: default avatarAndy Lutomirski <>
Acked-by: default avatarPaolo Bonzini <>
Acked-by: default avatarThomas Gleixner <>
Signed-off-by: default avatarBoris Ostrovsky <>
parent 001f60e1
......@@ -112,7 +112,7 @@ static int vvar_fault(const struct vm_special_mapping *sm,
__pa_symbol(&__vvar_page) >> PAGE_SHIFT);
} else if (sym_offset == image->sym_pvclock_page) {
struct pvclock_vsyscall_time_info *pvti =
if (pvti && vclock_was_used(VCLOCK_PVCLOCK)) {
ret = vm_insert_pfn(
......@@ -4,15 +4,6 @@
#include <linux/clocksource.h>
#include <asm/pvclock-abi.h>
extern struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void);
static inline struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void)
return NULL;
/* some helper functions for xen and kvm pv clock sources */
u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src);
......@@ -101,4 +92,14 @@ struct pvclock_vsyscall_time_info {
#define PVTI_SIZE sizeof(struct pvclock_vsyscall_time_info)
void pvclock_set_pvti_cpu0_va(struct pvclock_vsyscall_time_info *pvti);
struct pvclock_vsyscall_time_info *pvclock_get_pvti_cpu0_va(void);
static inline struct pvclock_vsyscall_time_info *pvclock_get_pvti_cpu0_va(void)
return NULL;
#endif /* _ASM_X86_PVCLOCK_H */
......@@ -47,12 +47,6 @@ early_param("no-kvmclock", parse_no_kvmclock);
static struct pvclock_vsyscall_time_info *hv_clock;
static struct pvclock_wall_clock wall_clock;
struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void)
return hv_clock;
* The wallclock is the time of day when we booted. Since then, some time may
* have elapsed since the hypervisor wrote the data. So we try to account for
......@@ -334,6 +328,7 @@ int __init kvm_setup_vsyscall_timeinfo(void)
return 1;
kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK;
......@@ -25,8 +25,10 @@
#include <asm/fixmap.h>
#include <asm/pvclock.h>
#include <asm/vgtod.h>
static u8 valid_flags __read_mostly = 0;
static struct pvclock_vsyscall_time_info *pvti_cpu0_va __read_mostly;
void pvclock_set_flags(u8 flags)
......@@ -144,3 +146,15 @@ void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
void pvclock_set_pvti_cpu0_va(struct pvclock_vsyscall_time_info *pvti)
pvti_cpu0_va = pvti;
struct pvclock_vsyscall_time_info *pvclock_get_pvti_cpu0_va(void)
return pvti_cpu0_va;
......@@ -182,7 +182,7 @@ static int __init ptp_kvm_init(void)
return -ENODEV;
clock_pair_gpa = slow_virt_to_phys(&clock_pair);
hv_clock = pvclock_pvti_cpu0_va();
hv_clock = pvclock_get_pvti_cpu0_va();
if (!hv_clock)
return -ENODEV;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment