"Kirill A. Shutemov" <kir...@shutemov.name> writes: > On Wed, Oct 21, 2020 at 04:46:48PM +0200, Vitaly Kuznetsov wrote: >> "Kirill A. Shutemov" <kir...@shutemov.name> writes: >> >> > Maybe it would be cleaner to handle reboot in userspace? If we got the VM >> > rebooted, just reconstruct it from scratch as if it would be new boot. >> >> We are definitely not trying to protect against malicious KVM so maybe >> we can do the cleanup there (when protection was enabled) so we can >> unprotect everything without risk of a leak? > > Do you have any particular codepath in mind? I didn't find anything > suitable so far.
I didn't put much thought in it but e.g. on x86, what if we put this to kvm_vcpu_reset() under 'if (kvm_vcpu_is_bsp())' condition? The main problem I see is that we can't clean up *all* memory, e.g. firmware related stuff should stay intact and this contraducts your KVM_HC_ENABLE_MEM_PROTECTED which protects everything. We can, probably, get rid of it leaving KVM_HC_MEM_SHARE/KVM_HC_MEM_UNSHARE only shifting responsibility to define what can be cleaned up on the guest kernel (stating in the doc that all protected memory will get whiped out on reboot). -- Vitaly