• [PATCH v5 3/4] x86/xen/time: setup vcpu 0 time info page

    From Boris Ostrovsky@21:1/5 to All on Mon Oct 2 22:50:11 2017
    +
    +static void xen_setup_vsyscall_time_info(void)
    +{
    + struct vcpu_register_time_memory_area t;
    + struct pvclock_vsyscall_time_info *ti;
    + int ret;


    In the previous version you'd return immediately if
    PVCLOCK_TSC_STABLE_BIT was not set. Don't you still need to check this? Especially give...


    +
    + ti = (struct pvclock_vsyscall_time_info *)get_zeroed_page(GFP_KERNEL); + if (!ti)
    + return;
    +
    + t.addr.v = &ti->pvti;
    +
    + ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, 0, &t); + if (ret) {
    + pr_notice("xen: VCLOCK_PVCLOCK not supported (err %d)\n", ret); + free_page((unsigned long)ti);
    + return;
    + }
    +
    + /*
    + * If primary time info had this bit set, secondary should too since

    ... this comment?

    -boris

    + * it's the same data on both just different memory regions. But we
    + * still check it in case hypervisor is buggy.
    + */
    + if (!(ti->pvti.flags & PVCLOCK_TSC_STABLE_BIT)) {
    + t.addr.v = NULL;
    + ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, + 0, &t);
    + if (!ret)
    + free_page((unsigned long)ti);
    +
    + pr_notice("xen: VCLOCK_PVCLOCK not supported (tsc unstable)\n");
    + return;
    + }
    +
    + xen_clock = ti;
    + pvclock_set_pvti_cpu0_va(xen_clock);
    +
    + xen_clocksource.archdata.vclock_mode = VCLOCK_PVCLOCK;
    +}
    +


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joao Martins@21:1/5 to All on Mon Oct 2 22:50:16 2017
    In order to support pvclock vdso on xen we need to setup the time
    info page for vcpu 0 and register the page with Xen using the VCPUOP_register_vcpu_time_memory_area hypercall. This hypercall
    will also forcefully update the pvti which will set some of the
    necessary flags for vdso. Afterwards we check if it supports the PVCLOCK_TSC_STABLE_BIT flag which is mandatory for having
    vdso/vsyscall support. And if so, it will set the cpu 0 pvti that
    will be later on used when mapping the vdso image.

    The xen headers are also updated to include the new hypercall for
    registering the secondary vcpu_time_info struct.

    Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    ---
    Changes since v4:
    * Remove pvclock_set_flags since predecessor patch will set in
    xen_time_init. Consequently pvti local variable is not so useful
    and doesn't make things more clear - therefore remove it.
    * Adjust comment on xen_setup_vsyscall_time_info()
    * Add Juergen's Reviewed-by (Retained as there wasn't functional
    changes)

    Changes since v3:
    (Comments from Juergen)
    * Remove _t added suffix from *GUEST_HANDLE* when sync vcpu.h
    with the latest

    Changes since v2:
    (Comments from Juergen)
    * Omit the blank after the cast on all 3 occurrences.
    * Change last VCLOCK_PVCLOCK message to be more descriptive
    * Sync the complete vcpu.h header instead of just adding the
    needed one. (IOW adding VCPUOP_get_physid)

    Changes since v1:
    * Check flags ahead to see if the primary clock can use
    PVCLOCK_TSC_STABLE_BIT even if secondary registration fails.
    (Comments from Boris)
    * Remove addr, addr variables;
    * Change first pr_debug to pr_warn;
    * Change last pr_debug to pr_notice;