On Wed, Sep 15, 2021 at 2:44 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote: > > On 14/09/21 20:49, Sean Christopherson wrote: > > On Tue, Sep 14, 2021, Peter Gonda wrote: > >> I do not think so. You cannot call KVM_SEV_LAUNCH_UPDATE_VMSA on the mirror > >> because svm_mem_enc_op() blocks calls from the mirror. So either you have to > >> update vmsa from the mirror or have the original VM read through its mirror's > >> vCPUs when calling KVM_SEV_LAUNCH_UPDATE_VMSA. Not sure which way is better > >> but I don't see a way to do this without updating KVM. > > > > Ah, right, I forgot all of the SEV ioctls are blocked on the mirror. Put something > > to that effect into the changelog to squash any argument about whether or not this > > is the correct KVM behavior. > > Indeed, at least KVM_SEV_LAUNCH_UPDATE_VMSA would have to be allowed in > the mirror VM. Do you think anything else would be necessary? Thanks Paolo. Yes I think that only the KVM_SEV_LAUNCH_UPDATE_VMSA ioctl needs to be allowed on the mirror VM. But I don't think that's the only changes needed. Additionally the mirror VM will need the sev 'handle' and the sev device 'fd' copied in vm_vm_copy_asid_from(). The handle is needed for KVM_SEV_LAUNCH_UPDATE_VMSA, the fd is required for sev_issue_cmd(). Also you you'd need to mirror es_active bool. (I think its quite confusing that svm_vm_copy_asid_from() only copies some of the metadata in sev_info but I can see why as the locked pages and cg group metadata shouldn't be copied.) I *think* that would be all that's needed but I haven't tried or tested this in any way. svm_vm_copy_asid_from() { asid = to_kvm_svm(source_kvm)->sev_info.asid; + handle = to_kvm_svm(source_kvm)->sev_info.handle; + fd = to_kvm_svm(source_kvm)->sev_info.fd; + es_active = to_kvm_svm(source_kvm)->sev_info.es_active; ... /* Set enc_context_owner and copy its encryption context over */ mirror_sev = &to_kvm_svm(kvm)->sev_info; mirror_sev->enc_context_owner = source_kvm; mirror_sev->asid = asid; mirror_sev->active = true; + mirror_sev->handle = handle; + mirror_sev->fd = fd; + mirror_sev->es_active = es_active; Paolo would you prefer a patch to enable ES mirroring or continue with this patch to disable it for now? > > Paolo >