/arch/x86/kvm/svm.c. In Linux 4.20 it's a 7209-line file and reading it can be a pain in the ass.
static int nested_svm_vmexit(struct vcpu_svm *svm). Looking at this function you can see that the function copies and saves the state of the CPU into VMCB, then deal with exceptions and interrupts, unmap the memory, then it's done. Pretty simple, right?
nested_svm_vmexitsaves the real VMCB of the CPU to a place in the memory and unload that VM.
cpuid. Obviously as a hypervisor, to really implement the
cpuid, you have to know
eax, and you have to change other registers. Now they are encrypted, you are screwed. Don't worry, AMD got you covered - Introducing GHCB, Guest Hypervisor Communication Block.