All of lore.kernel.org
 help / color / mirror / Atom feed
* Field names inside ms_hyperv_info
@ 2020-10-28 15:03 Wei Liu
  2020-10-30 15:24 ` Vitaly Kuznetsov
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2020-10-28 15:03 UTC (permalink / raw)
  To: Linux on Hyper-V List; +Cc: Wei Liu, Michael Kelley

Hi all

During my work to make Linux boot as root partition on MSHV, I found out
that a privilege mask was not collected in ms_hyperv_info.

Looking at the code, the field names of ms_hyperv_info are not
consistent with the names defined in TLFS. That makes it difficult to
choose a name for the field that stores the privilege mask.

I've got a local patch to make the existing fields closer to TLFS. The
suffix "_a" means the value comes from EAX.

Given that this structure is also used on ARM, so having x86 suffix is
probably not the best idea. Do people care?

diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index c57799684170..913af5e93cce 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -26,9 +26,9 @@
 #include <asm/hyperv-tlfs.h>

 struct ms_hyperv_info {
-       u32 features;
-       u32 misc_features;
-       u32 hints;
+       u32 features_a;
+       u32 features_d;
+       u32 recommendations;
        u32 nested_features;
        u32 max_vp_index;
        u32 max_lp_index;

Any comment on this? I'm normally bad at naming things so any suggestion
is welcomed.

Thanks,
Wei.

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

* Re: Field names inside ms_hyperv_info
  2020-10-28 15:03 Field names inside ms_hyperv_info Wei Liu
@ 2020-10-30 15:24 ` Vitaly Kuznetsov
  2020-10-30 16:29   ` Michael Kelley
  0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2020-10-30 15:24 UTC (permalink / raw)
  To: Wei Liu; +Cc: Michael Kelley, Linux on Hyper-V List

Wei Liu <wei.liu@kernel.org> writes:

> Hi all
>
> During my work to make Linux boot as root partition on MSHV, I found out
> that a privilege mask was not collected in ms_hyperv_info.
>
> Looking at the code, the field names of ms_hyperv_info are not
> consistent with the names defined in TLFS. That makes it difficult to
> choose a name for the field that stores the privilege mask.
>
> I've got a local patch to make the existing fields closer to TLFS. The
> suffix "_a" means the value comes from EAX.
>
> Given that this structure is also used on ARM, so having x86 suffix is
> probably not the best idea. Do people care?
>
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index c57799684170..913af5e93cce 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -26,9 +26,9 @@
>  #include <asm/hyperv-tlfs.h>
>
>  struct ms_hyperv_info {
> -       u32 features;
> -       u32 misc_features;
> -       u32 hints;
> +       u32 features_a;
> +       u32 features_d;
> +       u32 recommendations;
>         u32 nested_features;
>         u32 max_vp_index;
>         u32 max_lp_index;
>
> Any comment on this? I'm normally bad at naming things so any suggestion
> is welcomed.

My take: let's avoid ambiguous '_a', '_d' and use full register names,
it's only three letters after all. Let's also avoid suffix-less names as
eventually we'll need to add non-eax parts. That is:

       u32 features_eax;
       u32 features_edx;
       u32 recommendations_eax;
       u32 nested_features_eax;
...

I would also feel comfortable with these names sortened,

       u32 feat_eax;
       u32 feat_edx;
       u32 recomm_eax;
       u32 nested_feat_eax;
...

-- 
Vitaly


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

* RE: Field names inside ms_hyperv_info
  2020-10-30 15:24 ` Vitaly Kuznetsov
@ 2020-10-30 16:29   ` Michael Kelley
  2020-10-30 17:09     ` ** POTENTIAL FRAUD ALERT - RED HAT ** " Vitaly Kuznetsov
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Kelley @ 2020-10-30 16:29 UTC (permalink / raw)
  To: vkuznets, Wei Liu; +Cc: Linux on Hyper-V List

From: Vitaly Kuznetsov <vkuznets@redhat.com>
> 
> Wei Liu <wei.liu@kernel.org> writes:
> 
> > Hi all
> >
> > During my work to make Linux boot as root partition on MSHV, I found out
> > that a privilege mask was not collected in ms_hyperv_info.
> >
> > Looking at the code, the field names of ms_hyperv_info are not
> > consistent with the names defined in TLFS. That makes it difficult to
> > choose a name for the field that stores the privilege mask.
> >
> > I've got a local patch to make the existing fields closer to TLFS. The
> > suffix "_a" means the value comes from EAX.
> >
> > Given that this structure is also used on ARM, so having x86 suffix is
> > probably not the best idea. Do people care?
> >
> > diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> > index c57799684170..913af5e93cce 100644
> > --- a/include/asm-generic/mshyperv.h
> > +++ b/include/asm-generic/mshyperv.h
> > @@ -26,9 +26,9 @@
> >  #include <asm/hyperv-tlfs.h>
> >
> >  struct ms_hyperv_info {
> > -       u32 features;
> > -       u32 misc_features;
> > -       u32 hints;
> > +       u32 features_a;
> > +       u32 features_d;
> > +       u32 recommendations;
> >         u32 nested_features;
> >         u32 max_vp_index;
> >         u32 max_lp_index;
> >
> > Any comment on this? I'm normally bad at naming things so any suggestion
> > is welcomed.
> 
> My take: let's avoid ambiguous '_a', '_d' and use full register names,
> it's only three letters after all. Let's also avoid suffix-less names as
> eventually we'll need to add non-eax parts. That is:
> 
>        u32 features_eax;
>        u32 features_edx;
>        u32 recommendations_eax;
>        u32 nested_features_eax;
> ...
> 
> I would also feel comfortable with these names sortened,
> 
>        u32 feat_eax;
>        u32 feat_edx;
>        u32 recomm_eax;
>        u32 nested_feat_eax;
> ...
> 

This is in the asm-generic portion of mshyperv.h, so it is shared
across the x86 and ARM64 architectures.  So I don't think we
want x86 register names.  On ARM64, the eax/ebx/ecx/edx
portions are retrieved all together in a single 128-bit register
read.  I abstracted this into four 32-bit parts labeled
"a", "b", "c", and "d" with the obvious mapping to
eax/ebx/ecx/edx on the x86 side, but without using those names.

We don't have a TLFS for ARM64 (should be coming soon).  Might
be worth seeing what naming, if any, will be used there.

Michael

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

* Re: ** POTENTIAL FRAUD ALERT - RED HAT ** RE: Field names inside ms_hyperv_info
  2020-10-30 16:29   ` Michael Kelley
@ 2020-10-30 17:09     ` Vitaly Kuznetsov
  2020-11-01 18:19       ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2020-10-30 17:09 UTC (permalink / raw)
  To: Michael Kelley, Wei Liu; +Cc: Linux on Hyper-V List

Michael Kelley <mikelley@microsoft.com> writes:

> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>> 
>> Wei Liu <wei.liu@kernel.org> writes:
>> 
>> > Hi all
>> >
>> > During my work to make Linux boot as root partition on MSHV, I found out
>> > that a privilege mask was not collected in ms_hyperv_info.
>> >
>> > Looking at the code, the field names of ms_hyperv_info are not
>> > consistent with the names defined in TLFS. That makes it difficult to
>> > choose a name for the field that stores the privilege mask.
>> >
>> > I've got a local patch to make the existing fields closer to TLFS. The
>> > suffix "_a" means the value comes from EAX.
>> >
>> > Given that this structure is also used on ARM, so having x86 suffix is
>> > probably not the best idea. Do people care?
>> >
>> > diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
>> > index c57799684170..913af5e93cce 100644
>> > --- a/include/asm-generic/mshyperv.h
>> > +++ b/include/asm-generic/mshyperv.h
>> > @@ -26,9 +26,9 @@
>> >  #include <asm/hyperv-tlfs.h>
>> >
>> >  struct ms_hyperv_info {
>> > -       u32 features;
>> > -       u32 misc_features;
>> > -       u32 hints;
>> > +       u32 features_a;
>> > +       u32 features_d;
>> > +       u32 recommendations;
>> >         u32 nested_features;
>> >         u32 max_vp_index;
>> >         u32 max_lp_index;
>> >
>> > Any comment on this? I'm normally bad at naming things so any suggestion
>> > is welcomed.
>> 
>> My take: let's avoid ambiguous '_a', '_d' and use full register names,
>> it's only three letters after all. Let's also avoid suffix-less names as
>> eventually we'll need to add non-eax parts. That is:
>> 
>>        u32 features_eax;
>>        u32 features_edx;
>>        u32 recommendations_eax;
>>        u32 nested_features_eax;
>> ...
>> 
>> I would also feel comfortable with these names sortened,
>> 
>>        u32 feat_eax;
>>        u32 feat_edx;
>>        u32 recomm_eax;
>>        u32 nested_feat_eax;
>> ...
>> 
>
> This is in the asm-generic portion of mshyperv.h, so it is shared
> across the x86 and ARM64 architectures.  So I don't think we
> want x86 register names.  On ARM64, the eax/ebx/ecx/edx
> portions are retrieved all together in a single 128-bit register
> read.  I abstracted this into four 32-bit parts labeled
> "a", "b", "c", and "d" with the obvious mapping to
> eax/ebx/ecx/edx on the x86 side, but without using those names.
>

Oh, yea, I completely forgot about ARM! Using '_a'..'_d' suffixes is
justified then. 

> We don't have a TLFS for ARM64 (should be coming soon).  Might
> be worth seeing what naming, if any, will be used there.

In that case we should probably wait untill the naming there is clear as
I'm afraid we'll be renaming again.

-- 
Vitaly


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

* Re: ** POTENTIAL FRAUD ALERT - RED HAT ** RE: Field names inside ms_hyperv_info
  2020-10-30 17:09     ` ** POTENTIAL FRAUD ALERT - RED HAT ** " Vitaly Kuznetsov
@ 2020-11-01 18:19       ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2020-11-01 18:19 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: Michael Kelley, Wei Liu, Linux on Hyper-V List

On Fri, Oct 30, 2020 at 06:09:57PM +0100, Vitaly Kuznetsov wrote:
[...]
> > We don't have a TLFS for ARM64 (should be coming soon).  Might
> > be worth seeing what naming, if any, will be used there.
> 
> In that case we should probably wait untill the naming there is clear as
> I'm afraid we'll be renaming again.
> 

Sure. I'm fine with this too.

Wei.

> -- 
> Vitaly
> 

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

end of thread, other threads:[~2020-11-01 18:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 15:03 Field names inside ms_hyperv_info Wei Liu
2020-10-30 15:24 ` Vitaly Kuznetsov
2020-10-30 16:29   ` Michael Kelley
2020-10-30 17:09     ` ** POTENTIAL FRAUD ALERT - RED HAT ** " Vitaly Kuznetsov
2020-11-01 18:19       ` Wei Liu

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.