Re: [PATCH v3] x86/hyper-v: Mark TLFS structures packed

From: Vitaly Kuznetsov
Date: Wed Dec 12 2018 - 12:43:28 EST


Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> writes:

> /* Define virtual processor assist page structure. */
> struct hv_vp_assist_page {
> @@ -519,7 +519,7 @@ struct hv_vp_assist_page {
> __u64 nested_enlightenments_control[2];
> __u32 enlighten_vmentry;
> __u64 current_nested_vmcs;
> -};
> +} __packed;
>

This particular structure wasn't properly padded: u32 padding is missing
between 'enlighten_vmentry' and 'current_nested_vmcs'.

> struct hv_enlightened_vmcs {
> u32 revision_id;
> @@ -693,7 +693,7 @@ struct hv_enlightened_vmcs {
> u32 nested_flush_hypercall:1;
> u32 msr_bitmap:1;
> u32 reserved:30;
> - } hv_enlightenments_control;
> + } __packed hv_enlightenments_control;
> u32 hv_vp_id;
>
> u64 hv_vm_id;
> @@ -703,7 +703,7 @@ struct hv_enlightened_vmcs {
> u64 padding64_5[7];
> u64 xss_exit_bitmap;
> u64 padding64_6[7];
> -};
> +} __packed;

struct hv_enlightened_vmcs also has a hole: we need an u16 padding after
'u16 host_tr_selector'.

Both these problems led to Enlightened VMCS for Hyper-V on KVM being
completely broken.

As this is not yet merged, v4 is coming to rescue!

--
Vitaly