Re: [PATCH v3 04/14] KVM: s390: device attribute to set AP interpretive execution

From: Halil Pasic
Date: Tue Mar 20 2018 - 18:48:47 EST




On 03/20/2018 06:58 PM, Tony Krowiak wrote:
> I spoke with Christian this morning and he made a suggestion which I thinkÂwouldÂprovideÂtheÂbestÂsolutionÂhere.
> ThisÂisÂmyÂproposal:
> 1. Get rid of the KVM_S390_VM_CRYPTO_INTERPRET_AP device attribute and returnÂtoÂsettingÂECA.28ÂfromÂthe
> ÂÂÂmdevÂdeviceÂopenÂcallback.
> 2. Since there may be vcpus online at the time the mdev device open is called,ÂweÂmustÂfirstÂtakeÂallÂrunningÂvcpusÂoutÂof
> ÂÂ SIE and block them. Christian suggested the kvm_s390_vcpu_block_all(structÂkvmÂ*kvm)ÂfunctionÂwillÂdoÂtheÂtrick.ÂSoÂI
> ÂÂ propose introducing a function like the following to be called duringÂmdevÂopen:

There is one thing you missed, otherwise I'm *very* satisfied with this
proposal.

What you have missed IMHO is vcpu hottplug. So IMHO you should keep
kvm->arch.crypto.apie, and update it accordingly ...


>
> ÂÂÂÂintÂkvm_ap_set_interpretive_exec(structÂkvmÂ*kvm,ÂboolÂenable)
> ÂÂÂÂ{
> ÂÂÂÂÂÂÂÂintÂi;
> ÂÂÂÂÂÂÂÂstructÂkvm_vcpuÂ*vcpu;
>
> ÂÂÂÂÂÂÂÂifÂ(!test_kvm_cpu_feat(kvm,ÂKVM_S390_VM_CPU_FEAT_AP))
> ÂÂÂÂÂÂÂÂÂÂÂÂreturnÂ-EOPNOTSUPP;
>
> ÂÂÂÂÂÂÂÂmutex_lock(&kvm->lock);
>
> ÂÂÂÂÂÂÂÂkvm_s390_vcpu_block_all(kvm);

... let's say here.

>
> ÂÂÂÂÂÂÂÂkvm_for_each_vcpu(i,Âvcpu,Âkvm)Â{

And here you can call kvm_s390_vcpu_crypto_setup(vcpu) (the changes to
this function will be required for hotplug) if you like

> ÂÂÂÂÂÂÂÂÂÂÂÂifÂ(enable)
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvcpu->arch.sie_block->ecaÂ|=ÂECA_APIE;
> ÂÂÂÂÂÂÂÂÂÂÂÂelse
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvcpu->arch.sie_block->ecaÂ&=Â~ECA_APIE;

or keep this stuff, it does not really matter to me.

> ÂÂÂÂÂÂÂÂ}
>
> ÂÂÂÂÂÂÂÂkvm_s390_vcpu_unblock_all(kvm);
>
> ÂÂÂÂÂÂÂÂmutex_unlock(&kvm->lock);
>
> ÂÂÂÂÂÂÂÂreturnÂ0;
> ÂÂÂÂ}
>
> ÂÂÂThisÂinterfaceÂallowsÂusÂtoÂsetÂECA.28ÂevenÂifÂvcpusÂareÂrunning

I tend to agree. I will give it a proper review when this gets more
formal (e.g. v4 (preferably) or patches to be fixed up to this series).

Please don't forget to revisit the discussion on kvm_s390_vm_set_crypto:
if the mechanism there isn't right for ECA.28 I think you should tell
us why it's OK for the other attributes if it's OK. If it is not then
I guess you will want to do a stand alone patch for that.