All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/Hyper-V: Expand definition of struct hv_vp_assist_page
@ 2022-11-04  4:56 Saurabh Sengar
  2022-11-04  7:16 ` Anirudh Rayabharam
  0 siblings, 1 reply; 4+ messages in thread
From: Saurabh Sengar @ 2022-11-04  4:56 UTC (permalink / raw)
  To: ssengar, kys, haiyangz, wei.liu, decui, ssengar, linux-hyperv,
	linux-kernel, mikelley, tglx, bp, dave.hansen, x86, hpa

The struct hv_vp_assist_page has 24 bytes which is defined as u64[3],
expand that to expose vtl_entry_reason, vtl_ret_x64rax and vtl_ret_x64rcx
field. vtl_entry_reason is updated by hypervisor for the entry reason as
to why the VTL was entered on the virtual processor.
Guest updates the vtl_ret_* fields to provide the register values to
restore on VTL return. The specific register values that are restored
which will be updated on vtl_ret_x64rax and vtl_ret_x64rcx.
Also added the missing fields for synthetic_time_unhalted_timer_expired,
virtualization_fault_information and intercept_message.

Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
---
 arch/x86/include/asm/hyperv-tlfs.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
index f769b9db4630..b3d0f42853d2 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -377,11 +377,20 @@ struct hv_nested_enlightenments_control {
 struct hv_vp_assist_page {
 	__u32 apic_assist;
 	__u32 reserved1;
-	__u64 vtl_control[3];
+	__u8  vtl_entry_reason;
+	__u8  vtl_reserved[7];
+	__u64 vtl_ret_x64rax;
+	__u64 vtl_ret_x64rcx;
 	struct hv_nested_enlightenments_control nested_control;
 	__u8 enlighten_vmentry;
 	__u8 reserved2[7];
 	__u64 current_nested_vmcs;
+	__u8 synthetic_time_unhalted_timer_expired;
+	__u8 reserved3[7];
+	__u8 virtualization_fault_information[40];
+	__u8 reserved4[8];
+	__u8 intercept_message[256];
+	__u8 vtl_ret_actions[256];
 } __packed;
 
 struct hv_enlightened_vmcs {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/Hyper-V: Expand definition of struct hv_vp_assist_page
  2022-11-04  4:56 [PATCH] x86/Hyper-V: Expand definition of struct hv_vp_assist_page Saurabh Sengar
@ 2022-11-04  7:16 ` Anirudh Rayabharam
  2022-11-04  7:51   ` Saurabh Singh Sengar
  2022-11-04 15:52   ` Michael Kelley (LINUX)
  0 siblings, 2 replies; 4+ messages in thread
From: Anirudh Rayabharam @ 2022-11-04  7:16 UTC (permalink / raw)
  To: Saurabh Sengar
  Cc: ssengar, kys, haiyangz, wei.liu, decui, linux-hyperv,
	linux-kernel, mikelley, tglx, bp, dave.hansen, x86, hpa

On Thu, Nov 03, 2022 at 09:56:54PM -0700, Saurabh Sengar wrote:
> The struct hv_vp_assist_page has 24 bytes which is defined as u64[3],
> expand that to expose vtl_entry_reason, vtl_ret_x64rax and vtl_ret_x64rcx
> field. vtl_entry_reason is updated by hypervisor for the entry reason as
> to why the VTL was entered on the virtual processor.
> Guest updates the vtl_ret_* fields to provide the register values to
> restore on VTL return. The specific register values that are restored
> which will be updated on vtl_ret_x64rax and vtl_ret_x64rcx.
> Also added the missing fields for synthetic_time_unhalted_timer_expired,
> virtualization_fault_information and intercept_message.
> 
> Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> ---
>  arch/x86/include/asm/hyperv-tlfs.h | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
> index f769b9db4630..b3d0f42853d2 100644
> --- a/arch/x86/include/asm/hyperv-tlfs.h
> +++ b/arch/x86/include/asm/hyperv-tlfs.h
> @@ -377,11 +377,20 @@ struct hv_nested_enlightenments_control {
>  struct hv_vp_assist_page {
>  	__u32 apic_assist;
>  	__u32 reserved1;
> -	__u64 vtl_control[3];
> +	__u8  vtl_entry_reason;

This is defined as an enum in the TLFS [1]. We should do the same.
And since the TLFS defines it as an enum it is a 32 bit value and
not a u8.

> +	__u8  vtl_reserved[7];
> +	__u64 vtl_ret_x64rax;
> +	__u64 vtl_ret_x64rcx;

The TLFS groups the above VTL related fields into a struct
HV_VP_VTL_CONTROL. Any reason to not do the same?

[1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/datatypes/hv_vp_vtl_control

Thanks,
Anirudh.

>  	struct hv_nested_enlightenments_control nested_control;
>  	__u8 enlighten_vmentry;
>  	__u8 reserved2[7];
>  	__u64 current_nested_vmcs;
> +	__u8 synthetic_time_unhalted_timer_expired;
> +	__u8 reserved3[7];
> +	__u8 virtualization_fault_information[40];
> +	__u8 reserved4[8];
> +	__u8 intercept_message[256];
> +	__u8 vtl_ret_actions[256];
>  } __packed;
>  
>  struct hv_enlightened_vmcs {
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/Hyper-V: Expand definition of struct hv_vp_assist_page
  2022-11-04  7:16 ` Anirudh Rayabharam
@ 2022-11-04  7:51   ` Saurabh Singh Sengar
  2022-11-04 15:52   ` Michael Kelley (LINUX)
  1 sibling, 0 replies; 4+ messages in thread
From: Saurabh Singh Sengar @ 2022-11-04  7:51 UTC (permalink / raw)
  To: Anirudh Rayabharam
  Cc: ssengar, kys, haiyangz, wei.liu, decui, linux-hyperv,
	linux-kernel, mikelley, tglx, bp, dave.hansen, x86, hpa

On Fri, Nov 04, 2022 at 12:46:57PM +0530, Anirudh Rayabharam wrote:
> On Thu, Nov 03, 2022 at 09:56:54PM -0700, Saurabh Sengar wrote:
> > The struct hv_vp_assist_page has 24 bytes which is defined as u64[3],
> > expand that to expose vtl_entry_reason, vtl_ret_x64rax and vtl_ret_x64rcx
> > field. vtl_entry_reason is updated by hypervisor for the entry reason as
> > to why the VTL was entered on the virtual processor.
> > Guest updates the vtl_ret_* fields to provide the register values to
> > restore on VTL return. The specific register values that are restored
> > which will be updated on vtl_ret_x64rax and vtl_ret_x64rcx.
> > Also added the missing fields for synthetic_time_unhalted_timer_expired,
> > virtualization_fault_information and intercept_message.
> > 
> > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> > ---
> >  arch/x86/include/asm/hyperv-tlfs.h | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
> > index f769b9db4630..b3d0f42853d2 100644
> > --- a/arch/x86/include/asm/hyperv-tlfs.h
> > +++ b/arch/x86/include/asm/hyperv-tlfs.h
> > @@ -377,11 +377,20 @@ struct hv_nested_enlightenments_control {
> >  struct hv_vp_assist_page {
> >  	__u32 apic_assist;
> >  	__u32 reserved1;
> > -	__u64 vtl_control[3];
> > +	__u8  vtl_entry_reason;
> 
> This is defined as an enum in the TLFS [1]. We should do the same.
> And since the TLFS defines it as an enum it is a 32 bit value and
> not a u8.

I think we can do that. Let me check this and update on v2.

> 
> > +	__u8  vtl_reserved[7];
> > +	__u64 vtl_ret_x64rax;
> > +	__u64 vtl_ret_x64rcx;
> 
> The TLFS groups the above VTL related fields into a struct
> HV_VP_VTL_CONTROL. Any reason to not do the same?

No particular reason, but this change is simple and sufficient.
We can expand in future as the need arises.

> 
> [1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/datatypes/hv_vp_vtl_control
> 
> Thanks,
> Anirudh.
> 
> >  	struct hv_nested_enlightenments_control nested_control;
> >  	__u8 enlighten_vmentry;
> >  	__u8 reserved2[7];
> >  	__u64 current_nested_vmcs;
> > +	__u8 synthetic_time_unhalted_timer_expired;
> > +	__u8 reserved3[7];
> > +	__u8 virtualization_fault_information[40];
> > +	__u8 reserved4[8];
> > +	__u8 intercept_message[256];
> > +	__u8 vtl_ret_actions[256];
> >  } __packed;
> >  
> >  struct hv_enlightened_vmcs {
> > -- 
> > 2.34.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] x86/Hyper-V: Expand definition of struct hv_vp_assist_page
  2022-11-04  7:16 ` Anirudh Rayabharam
  2022-11-04  7:51   ` Saurabh Singh Sengar
@ 2022-11-04 15:52   ` Michael Kelley (LINUX)
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Kelley (LINUX) @ 2022-11-04 15:52 UTC (permalink / raw)
  To: Anirudh Rayabharam, Saurabh Sengar
  Cc: Saurabh Singh Sengar, KY Srinivasan, Haiyang Zhang, wei.liu,
	Dexuan Cui, linux-hyperv, linux-kernel, tglx, bp, dave.hansen,
	x86, hpa

From: Anirudh Rayabharam <anrayabh@linux.microsoft.com> Sent: Friday, November 4, 2022 12:17 AM
> 
> On Thu, Nov 03, 2022 at 09:56:54PM -0700, Saurabh Sengar wrote:
> > The struct hv_vp_assist_page has 24 bytes which is defined as u64[3],
> > expand that to expose vtl_entry_reason, vtl_ret_x64rax and vtl_ret_x64rcx
> > field. vtl_entry_reason is updated by hypervisor for the entry reason as
> > to why the VTL was entered on the virtual processor.
> > Guest updates the vtl_ret_* fields to provide the register values to
> > restore on VTL return. The specific register values that are restored
> > which will be updated on vtl_ret_x64rax and vtl_ret_x64rcx.
> > Also added the missing fields for synthetic_time_unhalted_timer_expired,
> > virtualization_fault_information and intercept_message.
> >
> > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> > ---
> >  arch/x86/include/asm/hyperv-tlfs.h | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-
> tlfs.h
> > index f769b9db4630..b3d0f42853d2 100644
> > --- a/arch/x86/include/asm/hyperv-tlfs.h
> > +++ b/arch/x86/include/asm/hyperv-tlfs.h
> > @@ -377,11 +377,20 @@ struct hv_nested_enlightenments_control {
> >  struct hv_vp_assist_page {
> >  	__u32 apic_assist;
> >  	__u32 reserved1;
> > -	__u64 vtl_control[3];
> > +	__u8  vtl_entry_reason;
> 
> This is defined as an enum in the TLFS [1]. We should do the same.
> And since the TLFS defines it as an enum it is a 32 bit value and
> not a u8.

In the *tlfs.h files we have avoided defining fields with type "enum"
because of the potential for variability in number of bytes it occupies. 
The TLFS documentation assumes an enum is 4 bytes, so in these
structure definitions we use a __u32 type to be explicit about the size.

We do have enum types defined in the *tlfs.h files, but these are just
lists of related constant values, and that's OK.

Michael

> 
> > +	__u8  vtl_reserved[7];
> > +	__u64 vtl_ret_x64rax;
> > +	__u64 vtl_ret_x64rcx;
> 
> The TLFS groups the above VTL related fields into a struct
> HV_VP_VTL_CONTROL. Any reason to not do the same?
> 
> [1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/datatypes/hv_vp_vtl_control
> 
> Thanks,
> Anirudh.
> 
> >  	struct hv_nested_enlightenments_control nested_control;
> >  	__u8 enlighten_vmentry;
> >  	__u8 reserved2[7];
> >  	__u64 current_nested_vmcs;
> > +	__u8 synthetic_time_unhalted_timer_expired;
> > +	__u8 reserved3[7];
> > +	__u8 virtualization_fault_information[40];
> > +	__u8 reserved4[8];
> > +	__u8 intercept_message[256];
> > +	__u8 vtl_ret_actions[256];
> >  } __packed;
> >
> >  struct hv_enlightened_vmcs {
> > --
> > 2.34.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-04 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04  4:56 [PATCH] x86/Hyper-V: Expand definition of struct hv_vp_assist_page Saurabh Sengar
2022-11-04  7:16 ` Anirudh Rayabharam
2022-11-04  7:51   ` Saurabh Singh Sengar
2022-11-04 15:52   ` Michael Kelley (LINUX)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.