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

From: Boris Ostrovsky
Date: Mon Oct 02 2017 - 14:45:56 EST



> +
> +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;
> +}
> +
>