mbox series

[RFC,0/3] Use DIAG318 to set Control Program Name & Version Codes

Message ID 1535734279-10204-1-git-send-email-walling@linux.ibm.com (mailing list archive)
Headers show
Series Use DIAG318 to set Control Program Name & Version Codes | expand

Message

Collin Walling Aug. 31, 2018, 4:51 p.m. UTC
A new diagnose instruction, 318, allows the kernel to set an 8-byte "Control 
Program Code" (CPC) that is composed of:

    1-byte Control Program Name Code (CPNC)
    7-byte Control Program Version Code (CPVC) composed of:
        3-bytes for Linux Kernel version (determined at build-time)
        3-bytes for Distribution Identifier (referred to as distro_id; set by Kconfig option)
        1-byte trailing NULL

Note about distro_id:
[
The initial idea for the 3-byte distro_id is for each distribution to set 
three characters that correspond to their distribution name (for a theoretical 
distributor "ACME," they could set "ACM" as the distro_id). A registry file 
could be included in the s390 kernel documentation to avoid name collisions.
]

This instruction call is executed once-and-only-once during Kernel setup.
The availability of this instruction depends on Read SCP Info byte 134, bit 0.
Diagnose318's functionality is also emulated by KVM, which means we can 
enable this feature for a guest even if the host cannot support it.

Also introduced with this patchset is a Host Program Identifier (HPID), which
denotes the underlying host environment.

The CPC and HPID are used for problem diagnosis and allows IBM to identify 
control program information by answering the following questions:

    "What environment is this guest running in?" (CPNC)
    "What distribution is this guest running?" (CPVC)
    "What underlying host environment is this guest running on?" (HPID)

Please note: I will be returning to the office on Thursday (9/6).

Collin Walling (3):
  s390/setup: set control program code via diag 318
  s390/kvm: handle diagnose 318 instruction call
  s390/kvm: set host program identifier

 arch/s390/Kconfig                      |  8 +++
 arch/s390/include/asm/diag.h           | 12 +++++
 arch/s390/include/asm/kvm_host.h       | 12 ++++-
 arch/s390/include/asm/sclp.h           |  1 +
 arch/s390/include/uapi/asm/kvm.h       |  5 ++
 arch/s390/kernel/diag.c                |  1 +
 arch/s390/kernel/setup.c               | 23 +++++++++
 arch/s390/kvm/diag.c                   | 16 ++++++
 arch/s390/kvm/kvm-s390.c               | 92 ++++++++++++++++++++++++++++++++++
 arch/s390/kvm/kvm-s390.h               |  1 +
 arch/s390/kvm/vsie.c                   |  2 +
 drivers/s390/char/sclp_early.c         |  6 ++-
 tools/arch/s390/include/uapi/asm/kvm.h |  1 +
 13 files changed, 177 insertions(+), 3 deletions(-)

Comments

Collin Walling Aug. 31, 2018, 7:31 p.m. UTC | #1
On 08/31/2018 12:51 PM, Collin Walling wrote:
> A new diagnose instruction, 318, allows the kernel to set an 8-byte "Control 
> Program Code" (CPC) that is composed of:
> 
>     1-byte Control Program Name Code (CPNC)
>     7-byte Control Program Version Code (CPVC) composed of:
>         3-bytes for Linux Kernel version (determined at build-time)
>         3-bytes for Distribution Identifier (referred to as distro_id; set by Kconfig option)
>         1-byte trailing NULL
> 
> Note about distro_id:
> [
> The initial idea for the 3-byte distro_id is for each distribution to set 
> three characters that correspond to their distribution name (for a theoretical 
> distributor "ACME," they could set "ACM" as the distro_id). A registry file 
> could be included in the s390 kernel documentation to avoid name collisions.
> ]

Another (likely better) idea is to use 1-byte for the distribution, followed
by 2-bytes for major.minor release.
Hendrik Brueckner Sept. 3, 2018, 7:06 a.m. UTC | #2
On Fri, Aug 31, 2018 at 03:31:09PM -0400, Collin Walling wrote:
> On 08/31/2018 12:51 PM, Collin Walling wrote:
> > A new diagnose instruction, 318, allows the kernel to set an 8-byte "Control 
> > Program Code" (CPC) that is composed of:
> > 
> >     1-byte Control Program Name Code (CPNC)
> >     7-byte Control Program Version Code (CPVC) composed of:
> >         3-bytes for Linux Kernel version (determined at build-time)
> >         3-bytes for Distribution Identifier (referred to as distro_id; set by Kconfig option)
> >         1-byte trailing NULL
> > 
> > Note about distro_id:
> > [
> > The initial idea for the 3-byte distro_id is for each distribution to set 
> > three characters that correspond to their distribution name (for a theoretical 
> > distributor "ACME," they could set "ACM" as the distro_id). A registry file 
> > could be included in the s390 kernel documentation to avoid name collisions.
> > ]
> 
> Another (likely better) idea is to use 1-byte for the distribution, followed
> by 2-bytes for major.minor release.

That's sounds indeed better.

Thanks and regards,
  Hendrik
Cornelia Huck Sept. 19, 2018, 9:30 a.m. UTC | #3
On Fri, 31 Aug 2018 12:51:16 -0400
Collin Walling <walling@linux.ibm.com> wrote:

> A new diagnose instruction, 318, allows the kernel to set an 8-byte "Control 
> Program Code" (CPC) that is composed of:
> 
>     1-byte Control Program Name Code (CPNC)
>     7-byte Control Program Version Code (CPVC) composed of:
>         3-bytes for Linux Kernel version (determined at build-time)
>         3-bytes for Distribution Identifier (referred to as distro_id; set by Kconfig option)
>         1-byte trailing NULL

Is this a new diagnose code, or is just the implementation in Linux new?

> 
> Note about distro_id:
> [
> The initial idea for the 3-byte distro_id is for each distribution to set 
> three characters that correspond to their distribution name (for a theoretical 
> distributor "ACME," they could set "ACM" as the distro_id). A registry file 
> could be included in the s390 kernel documentation to avoid name collisions.
> ]

Yes, I think we do want some kind of registry for this.

> 
> This instruction call is executed once-and-only-once during Kernel setup.
> The availability of this instruction depends on Read SCP Info byte 134, bit 0.
> Diagnose318's functionality is also emulated by KVM, which means we can 
> enable this feature for a guest even if the host cannot support it.
> 
> Also introduced with this patchset is a Host Program Identifier (HPID), which
> denotes the underlying host environment.
> 
> The CPC and HPID are used for problem diagnosis and allows IBM to identify 
> control program information by answering the following questions:
> 
>     "What environment is this guest running in?" (CPNC)
>     "What distribution is this guest running?" (CPVC)
>     "What underlying host environment is this guest running on?" (HPID)

Is there also a way for people-who-are-not-IBM to find out what these
values have been set to? :) (IOW, is that write-only from a Linux
perspective?)

I see that for the emulated instruction the values are logged into the
debug feature, which seems useful.
Collin Walling Sept. 19, 2018, 5:09 p.m. UTC | #4
On 09/19/2018 05:30 AM, Cornelia Huck wrote:
> On Fri, 31 Aug 2018 12:51:16 -0400
> Collin Walling <walling@linux.ibm.com> wrote:
> 
>> A new diagnose instruction, 318, allows the kernel to set an 8-byte "Control 
>> Program Code" (CPC) that is composed of:
>>
>>     1-byte Control Program Name Code (CPNC)
>>     7-byte Control Program Version Code (CPVC) composed of:
>>         3-bytes for Linux Kernel version (determined at build-time)
>>         3-bytes for Distribution Identifier (referred to as distro_id; set by Kconfig option)
>>         1-byte trailing NULL
> 
> Is this a new diagnose code, or is just the implementation in Linux new?
> 

It is a new diagnose code.

>>
>> Note about distro_id:
>> [
>> The initial idea for the 3-byte distro_id is for each distribution to set 
>> three characters that correspond to their distribution name (for a theoretical 
>> distributor "ACME," they could set "ACM" as the distro_id). A registry file 
>> could be included in the s390 kernel documentation to avoid name collisions.
>> ]
> 
> Yes, I think we do want some kind of registry for this.

I'll include it in the next round of patches so we can work on a decent format.

> 
>>
>> This instruction call is executed once-and-only-once during Kernel setup.
>> The availability of this instruction depends on Read SCP Info byte 134, bit 0.
>> Diagnose318's functionality is also emulated by KVM, which means we can 
>> enable this feature for a guest even if the host cannot support it.
>>
>> Also introduced with this patchset is a Host Program Identifier (HPID), which
>> denotes the underlying host environment.
>>
>> The CPC and HPID are used for problem diagnosis and allows IBM to identify 
>> control program information by answering the following questions:
>>
>>     "What environment is this guest running in?" (CPNC)
>>     "What distribution is this guest running?" (CPVC)
>>     "What underlying host environment is this guest running on?" (HPID)
> 
> Is there also a way for people-who-are-not-IBM to find out what these
> values have been set to? :) (IOW, is that write-only from a Linux
> perspective?)
> 
> I see that for the emulated instruction the values are logged into the
> debug feature, which seems useful.
> 

Maybe it would help to include a toString-esque macro for these values. Then
when the HPID and CPNC get logged we will have something us humans can read? :)

The distro_id will have to be deciphered via the registry file. Thoughts?
Christian Borntraeger Sept. 19, 2018, 5:46 p.m. UTC | #5
On 09/19/2018 11:30 AM, Cornelia Huck wrote:

>> The CPC and HPID are used for problem diagnosis and allows IBM to identify 
>> control program information by answering the following questions:
>>
>>     "What environment is this guest running in?" (CPNC)
>>     "What distribution is this guest running?" (CPVC)
>>     "What underlying host environment is this guest running on?" (HPID)
> 
> Is there also a way for people-who-are-not-IBM to find out what these
> values have been set to? :) (IOW, is that write-only from a Linux
> perspective?)

The name code is pre-defined (4==LINUX). The 7 byte version code is actually free
to be defined by the operating system, and Collin has made a proposal. No idea
if there are better ways to use the 7 byte.
Cornelia Huck Sept. 20, 2018, 9:18 a.m. UTC | #6
On Wed, 19 Sep 2018 13:09:34 -0400
Collin Walling <walling@linux.ibm.com> wrote:

> On 09/19/2018 05:30 AM, Cornelia Huck wrote:
> > On Fri, 31 Aug 2018 12:51:16 -0400
> > Collin Walling <walling@linux.ibm.com> wrote:

> >> The CPC and HPID are used for problem diagnosis and allows IBM to identify 
> >> control program information by answering the following questions:
> >>
> >>     "What environment is this guest running in?" (CPNC)
> >>     "What distribution is this guest running?" (CPVC)
> >>     "What underlying host environment is this guest running on?" (HPID)  
> > 
> > Is there also a way for people-who-are-not-IBM to find out what these
> > values have been set to? :) (IOW, is that write-only from a Linux
> > perspective?)
> > 
> > I see that for the emulated instruction the values are logged into the
> > debug feature, which seems useful.
> >   
> 
> Maybe it would help to include a toString-esque macro for these values. Then
> when the HPID and CPNC get logged we will have something us humans can read? :)
> 
> The distro_id will have to be deciphered via the registry file. Thoughts?

It's probably fine if this has to be decoded outside of the kernel.

One thing that came to my mind: Would it be useful to be able to
introspect a live guest from the hypervisor? For example, being able to
get the CPNC/CPVC from a QEMU monitor command? (The debug feature may
wrap around so that the info can get lost, I guess?)