2021-07-06 12:12:13

by Cornelia Huck

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation

On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:

> When this feature is enabled the hardware is free to interpret
> specification exceptions generated by the guest, instead of causing
> program interruption interceptions.
>
> This benefits (test) programs that generate a lot of specification
> exceptions (roughly 4x increase in exceptions/sec).
>
> Interceptions will occur as before if ICTL_PINT is set,
> i.e. if guest debug is enabled.
>
> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
> ---
> I'll additionally send kvm-unit-tests for testing this feature.
>
> arch/s390/include/asm/kvm_host.h | 1 +
> arch/s390/kvm/kvm-s390.c | 2 ++
> arch/s390/kvm/vsie.c | 2 ++
> 3 files changed, 5 insertions(+)

(...)

> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index b655a7d82bf0..aadd589a3755 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
> vcpu->arch.sie_block->ecb |= ECB_SRSI;
> if (test_kvm_facility(vcpu->kvm, 73))
> vcpu->arch.sie_block->ecb |= ECB_TE;
> + if (!kvm_is_ucontrol(vcpu->kvm))
> + vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu
feature?)

>
> if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
> vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;


2021-07-06 12:14:16

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation



On 06.07.21 13:52, Cornelia Huck wrote:
> On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:
>
>> When this feature is enabled the hardware is free to interpret
>> specification exceptions generated by the guest, instead of causing
>> program interruption interceptions.
>>
>> This benefits (test) programs that generate a lot of specification
>> exceptions (roughly 4x increase in exceptions/sec).
>>
>> Interceptions will occur as before if ICTL_PINT is set,
>> i.e. if guest debug is enabled.
>>
>> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
>> ---
>> I'll additionally send kvm-unit-tests for testing this feature.
>>
>> arch/s390/include/asm/kvm_host.h | 1 +
>> arch/s390/kvm/kvm-s390.c | 2 ++
>> arch/s390/kvm/vsie.c | 2 ++
>> 3 files changed, 5 insertions(+)
>
> (...)
>
>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>> index b655a7d82bf0..aadd589a3755 100644
>> --- a/arch/s390/kvm/kvm-s390.c
>> +++ b/arch/s390/kvm/kvm-s390.c
>> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
>> vcpu->arch.sie_block->ecb |= ECB_SRSI;
>> if (test_kvm_facility(vcpu->kvm, 73))
>> vcpu->arch.sie_block->ecb |= ECB_TE;
>> + if (!kvm_is_ucontrol(vcpu->kvm))
>> + vcpu->arch.sie_block->ecb |= ECB_SPECI;
>
> Does this exist for any hardware version (i.e. not guarded by a cpu
> feature?)

Not for all hardware versions, but also no indication. The architecture
says that the HW is free to do this or not. (which makes the vsie code
simpler).
>
>>
>> if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
>> vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
>

2021-07-06 12:21:43

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation

On 06.07.21 13:56, Christian Borntraeger wrote:
>
>
> On 06.07.21 13:52, Cornelia Huck wrote:
>> On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:
>>
>>> When this feature is enabled the hardware is free to interpret
>>> specification exceptions generated by the guest, instead of causing
>>> program interruption interceptions.
>>>
>>> This benefits (test) programs that generate a lot of specification
>>> exceptions (roughly 4x increase in exceptions/sec).
>>>
>>> Interceptions will occur as before if ICTL_PINT is set,
>>> i.e. if guest debug is enabled.
>>>
>>> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
>>> ---
>>> I'll additionally send kvm-unit-tests for testing this feature.
>>>
>>> arch/s390/include/asm/kvm_host.h | 1 +
>>> arch/s390/kvm/kvm-s390.c | 2 ++
>>> arch/s390/kvm/vsie.c | 2 ++
>>> 3 files changed, 5 insertions(+)
>>
>> (...)
>>
>>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>>> index b655a7d82bf0..aadd589a3755 100644
>>> --- a/arch/s390/kvm/kvm-s390.c
>>> +++ b/arch/s390/kvm/kvm-s390.c
>>> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
>>> vcpu->arch.sie_block->ecb |= ECB_SRSI;
>>> if (test_kvm_facility(vcpu->kvm, 73))
>>> vcpu->arch.sie_block->ecb |= ECB_TE;
>>> + if (!kvm_is_ucontrol(vcpu->kvm))
>>> + vcpu->arch.sie_block->ecb |= ECB_SPECI;
>>
>> Does this exist for any hardware version (i.e. not guarded by a cpu
>> feature?)
>
> Not for all hardware versions, but also no indication. The architecture
> says that the HW is free to do this or not. (which makes the vsie code
> simpler).

I remember the architecture said at some point to never set undefined
bits - and this bit is undefined on older HW generations. I might be
wrong, though.

(I though HW learned the lesson to always use proper feature indications
along with new features)


--
Thanks,

David / dhildenb

2021-07-06 12:22:13

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation



On 06.07.21 13:59, David Hildenbrand wrote:
> On 06.07.21 13:56, Christian Borntraeger wrote:
>>
>>
>> On 06.07.21 13:52, Cornelia Huck wrote:
>>> On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:
>>>
>>>> When this feature is enabled the hardware is free to interpret
>>>> specification exceptions generated by the guest, instead of causing
>>>> program interruption interceptions.
>>>>
>>>> This benefits (test) programs that generate a lot of specification
>>>> exceptions (roughly 4x increase in exceptions/sec).
>>>>
>>>> Interceptions will occur as before if ICTL_PINT is set,
>>>> i.e. if guest debug is enabled.
>>>>
>>>> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
>>>> ---
>>>> I'll additionally send kvm-unit-tests for testing this feature.
>>>>
>>>>    arch/s390/include/asm/kvm_host.h | 1 +
>>>>    arch/s390/kvm/kvm-s390.c         | 2 ++
>>>>    arch/s390/kvm/vsie.c             | 2 ++
>>>>    3 files changed, 5 insertions(+)
>>>
>>> (...)
>>>
>>>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>>>> index b655a7d82bf0..aadd589a3755 100644
>>>> --- a/arch/s390/kvm/kvm-s390.c
>>>> +++ b/arch/s390/kvm/kvm-s390.c
>>>> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
>>>>            vcpu->arch.sie_block->ecb |= ECB_SRSI;
>>>>        if (test_kvm_facility(vcpu->kvm, 73))
>>>>            vcpu->arch.sie_block->ecb |= ECB_TE;
>>>> +    if (!kvm_is_ucontrol(vcpu->kvm))
>>>> +        vcpu->arch.sie_block->ecb |= ECB_SPECI;
>>>
>>> Does this exist for any hardware version (i.e. not guarded by a cpu
>>> feature?)
>>
>> Not for all hardware versions, but also no indication. The architecture
>> says that the HW is free to do this or not. (which makes the vsie code
>> simpler).
>
> I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.

I can confirm that this bit will be ignored on older machines. The notion of
never setting undefined bits comes from "you never know what this bit will
change in future machines". Now we know :-)

2021-07-06 15:17:30

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation

On 06.07.21 14:02, Christian Borntraeger wrote:
>
>
> On 06.07.21 13:59, David Hildenbrand wrote:
>> On 06.07.21 13:56, Christian Borntraeger wrote:
>>>
>>>
>>> On 06.07.21 13:52, Cornelia Huck wrote:
>>>> On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:
>>>>
>>>>> When this feature is enabled the hardware is free to interpret
>>>>> specification exceptions generated by the guest, instead of causing
>>>>> program interruption interceptions.
>>>>>
>>>>> This benefits (test) programs that generate a lot of specification
>>>>> exceptions (roughly 4x increase in exceptions/sec).
>>>>>
>>>>> Interceptions will occur as before if ICTL_PINT is set,
>>>>> i.e. if guest debug is enabled.
>>>>>
>>>>> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
>>>>> ---
>>>>> I'll additionally send kvm-unit-tests for testing this feature.
>>>>>
>>>>>    arch/s390/include/asm/kvm_host.h | 1 +
>>>>>    arch/s390/kvm/kvm-s390.c         | 2 ++
>>>>>    arch/s390/kvm/vsie.c             | 2 ++
>>>>>    3 files changed, 5 insertions(+)
>>>>
>>>> (...)
>>>>
>>>>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>>>>> index b655a7d82bf0..aadd589a3755 100644
>>>>> --- a/arch/s390/kvm/kvm-s390.c
>>>>> +++ b/arch/s390/kvm/kvm-s390.c
>>>>> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
>>>>>            vcpu->arch.sie_block->ecb |= ECB_SRSI;
>>>>>        if (test_kvm_facility(vcpu->kvm, 73))
>>>>>            vcpu->arch.sie_block->ecb |= ECB_TE;
>>>>> +    if (!kvm_is_ucontrol(vcpu->kvm))
>>>>> +        vcpu->arch.sie_block->ecb |= ECB_SPECI;
>>>>
>>>> Does this exist for any hardware version (i.e. not guarded by a cpu
>>>> feature?)
>>>
>>> Not for all hardware versions, but also no indication. The architecture
>>> says that the HW is free to do this or not. (which makes the vsie code
>>> simpler).
>>
>> I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.
>
> I can confirm that this bit will be ignored on older machines. The notion of
> never setting undefined bits comes from "you never know what this bit will
> change in future machines". Now we know :-)

Well, okay then :)

So the plan for vSIE is to always keep it disabled? IIUC, one could
similarly always forward the bit of set.


--
Thanks,

David / dhildenb

2021-07-06 15:29:33

by Janis Schoetterl-Glausch

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation

On 7/6/21 5:16 PM, David Hildenbrand wrote:
> On 06.07.21 14:02, Christian Borntraeger wrote:
>>
>>
>> On 06.07.21 13:59, David Hildenbrand wrote:
>>> On 06.07.21 13:56, Christian Borntraeger wrote:
>>>>
>>>>
>>>> On 06.07.21 13:52, Cornelia Huck wrote:
>>>>> On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:
>>>>>
>>>>>> When this feature is enabled the hardware is free to interpret
>>>>>> specification exceptions generated by the guest, instead of causing
>>>>>> program interruption interceptions.
>>>>>>
>>>>>> This benefits (test) programs that generate a lot of specification
>>>>>> exceptions (roughly 4x increase in exceptions/sec).
>>>>>>
>>>>>> Interceptions will occur as before if ICTL_PINT is set,
>>>>>> i.e. if guest debug is enabled.
>>>>>>
>>>>>> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
>>>>>> ---
>>>>>> I'll additionally send kvm-unit-tests for testing this feature.
>>>>>>
>>>>>>     arch/s390/include/asm/kvm_host.h | 1 +
>>>>>>     arch/s390/kvm/kvm-s390.c         | 2 ++
>>>>>>     arch/s390/kvm/vsie.c             | 2 ++
>>>>>>     3 files changed, 5 insertions(+)
>>>>>
>>>>> (...)
>>>>>
>>>>>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>>>>>> index b655a7d82bf0..aadd589a3755 100644
>>>>>> --- a/arch/s390/kvm/kvm-s390.c
>>>>>> +++ b/arch/s390/kvm/kvm-s390.c
>>>>>> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
>>>>>>             vcpu->arch.sie_block->ecb |= ECB_SRSI;
>>>>>>         if (test_kvm_facility(vcpu->kvm, 73))
>>>>>>             vcpu->arch.sie_block->ecb |= ECB_TE;
>>>>>> +    if (!kvm_is_ucontrol(vcpu->kvm))
>>>>>> +        vcpu->arch.sie_block->ecb |= ECB_SPECI;
>>>>>
>>>>> Does this exist for any hardware version (i.e. not guarded by a cpu
>>>>> feature?)
>>>>
>>>> Not for all hardware versions, but also no indication. The architecture
>>>> says that the HW is free to do this or not. (which makes the vsie code
>>>> simpler).
>>>
>>> I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.
>>
>> I can confirm that this bit will be ignored on older machines. The notion of
>> never setting undefined bits comes from "you never know what this bit will
>> change in future machines". Now we know :-)
>
> Well, okay then :)
>
> So the plan for vSIE is to always keep it disabled? IIUC, one could similarly always forward the bit of set.

The bit does get copied for vSIE.

2021-07-07 07:28:39

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] KVM: s390: Enable specification exception interpretation

On 06.07.21 17:27, Janis Schoetterl-Glausch wrote:
> On 7/6/21 5:16 PM, David Hildenbrand wrote:
>> On 06.07.21 14:02, Christian Borntraeger wrote:
>>>
>>>
>>> On 06.07.21 13:59, David Hildenbrand wrote:
>>>> On 06.07.21 13:56, Christian Borntraeger wrote:
>>>>>
>>>>>
>>>>> On 06.07.21 13:52, Cornelia Huck wrote:
>>>>>> On Tue, Jul 06 2021, Janis Schoetterl-Glausch <[email protected]> wrote:
>>>>>>
>>>>>>> When this feature is enabled the hardware is free to interpret
>>>>>>> specification exceptions generated by the guest, instead of causing
>>>>>>> program interruption interceptions.
>>>>>>>
>>>>>>> This benefits (test) programs that generate a lot of specification
>>>>>>> exceptions (roughly 4x increase in exceptions/sec).
>>>>>>>
>>>>>>> Interceptions will occur as before if ICTL_PINT is set,
>>>>>>> i.e. if guest debug is enabled.
>>>>>>>
>>>>>>> Signed-off-by: Janis Schoetterl-Glausch <[email protected]>
>>>>>>> ---
>>>>>>> I'll additionally send kvm-unit-tests for testing this feature.
>>>>>>>
>>>>>>>     arch/s390/include/asm/kvm_host.h | 1 +
>>>>>>>     arch/s390/kvm/kvm-s390.c         | 2 ++
>>>>>>>     arch/s390/kvm/vsie.c             | 2 ++
>>>>>>>     3 files changed, 5 insertions(+)
>>>>>>
>>>>>> (...)
>>>>>>
>>>>>>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>>>>>>> index b655a7d82bf0..aadd589a3755 100644
>>>>>>> --- a/arch/s390/kvm/kvm-s390.c
>>>>>>> +++ b/arch/s390/kvm/kvm-s390.c
>>>>>>> @@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
>>>>>>>             vcpu->arch.sie_block->ecb |= ECB_SRSI;
>>>>>>>         if (test_kvm_facility(vcpu->kvm, 73))
>>>>>>>             vcpu->arch.sie_block->ecb |= ECB_TE;
>>>>>>> +    if (!kvm_is_ucontrol(vcpu->kvm))
>>>>>>> +        vcpu->arch.sie_block->ecb |= ECB_SPECI;
>>>>>>
>>>>>> Does this exist for any hardware version (i.e. not guarded by a cpu
>>>>>> feature?)
>>>>>
>>>>> Not for all hardware versions, but also no indication. The architecture
>>>>> says that the HW is free to do this or not. (which makes the vsie code
>>>>> simpler).
>>>>
>>>> I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.
>>>
>>> I can confirm that this bit will be ignored on older machines. The notion of
>>> never setting undefined bits comes from "you never know what this bit will
>>> change in future machines". Now we know :-)
>>
>> Well, okay then :)
>>
>> So the plan for vSIE is to always keep it disabled? IIUC, one could similarly always forward the bit of set.
>
> The bit does get copied for vSIE.

... and I missed that hunk :)

LGTM then

Reviewed-by: David Hildenbrand <[email protected]>


--
Thanks,

David / dhildenb