Re: [PATCH v3 2/3] x86/xen/time: setup vcpu 0 time info page

From: Joao Martins
Date: Wed Sep 27 2017 - 10:00:10 EST


On 09/27/2017 01:14 PM, Juergen Gross wrote:
> On 27/09/17 14:00, Joao Martins wrote:

[...]

>> diff --git a/include/xen/interface/vcpu.h b/include/xen/interface/vcpu.h
>> index 98188c87f5c1..b4a1eabcf1c4 100644
>> --- a/include/xen/interface/vcpu.h
>> +++ b/include/xen/interface/vcpu.h
>> @@ -178,4 +178,46 @@ DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_vcpu_info);
>>
>> /* Send an NMI to the specified VCPU. @extra_arg == NULL. */
>> #define VCPUOP_send_nmi 11
>> +
>> +/*
>> + * Get the physical ID information for a pinned vcpu's underlying physical
>> + * processor. The physical ID informmation is architecture-specific.
>> + * On x86: id[31:0]=apic_id, id[63:32]=acpi_id.
>> + * This command returns -EINVAL if it is not a valid operation for this VCPU.
>> + */
>> +#define VCPUOP_get_physid 12 /* arg == vcpu_get_physid_t */
>> +struct vcpu_get_physid {
>> + uint64_t phys_id;
>> +};
>> +DEFINE_GUEST_HANDLE_STRUCT(vcpu_get_physid_t);
>
> DEFINE_GUEST_HANDLE_STRUCT(vcpu_get_physid);
>
>> +#define xen_vcpu_physid_to_x86_apicid(physid) ((uint32_t)(physid))
>> +#define xen_vcpu_physid_to_x86_acpiid(physid) ((uint32_t)((physid) >> 32))
>> +
>> +/*
>> + * Register a memory location to get a secondary copy of the vcpu time
>> + * parameters. The master copy still exists as part of the vcpu shared
>> + * memory area, and this secondary copy is updated whenever the master copy
>> + * is updated (and using the same versioning scheme for synchronisation).
>> + *
>> + * The intent is that this copy may be mapped (RO) into userspace so
>> + * that usermode can compute system time using the time info and the
>> + * tsc. Usermode will see an array of vcpu_time_info structures, one
>> + * for each vcpu, and choose the right one by an existing mechanism
>> + * which allows it to get the current vcpu number (such as via a
>> + * segment limit). It can then apply the normal algorithm to compute
>> + * system time from the tsc.
>> + *
>> + * @extra_arg == pointer to vcpu_register_time_info_memory_area structure.
>> + */
>> +#define VCPUOP_register_vcpu_time_memory_area 13
>> +DEFINE_GUEST_HANDLE_STRUCT(vcpu_time_info_t);
>
> DEFINE_GUEST_HANDLE_STRUCT(vcpu_time_info);
>
>> +struct vcpu_register_time_memory_area {
>> + union {
>> + GUEST_HANDLE(vcpu_time_info_t) h;
>
> GUEST_HANDLE(vcpu_time_info) h;
>
>> + struct pvclock_vcpu_time_info *v;
>> + uint64_t p;
>> + } addr;
>> +};
>> +DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_time_memory_area_t);
>
> DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_time_memory_area);

Oh sorry - I forgot to remove the suffix. In the meantime I sent over v4
addressing the above.

Joao