History

KVM: SVM: Add support for booting APs in an SEV-ES guest

Typically under KVM, an AP is booted using the INIT-SIPI-SIPI sequence, where the guest vCPU register state is updated and then the vCPU is VMRUN to begin execution of the AP. For an SEV-ES guest, this won't work because the guest register state is encrypted. Following the GHCB specification, the hypervisor must not alter the guest register state, so KVM must track an AP/vCPU boot. Should the guest want to park the AP, it must use the AP Reset Hold exit event in place of, for example, a HLT loop. First AP boot (first INIT-SIPI-SIPI sequence): Execute the AP (vCPU) as it was initialized and measured by the SEV-ES support. It is up to the guest to transfer control of the AP to the proper location. Subsequent AP boot: KVM will expect to receive an AP Reset Hold exit event indicating that the vCPU is being parked and will require an INIT-SIPI-SIPI sequence to awaken it. When the AP Reset Hold exit event is received, KVM will place the vCPU into a simulated HLT mode. Upon receiving the INIT-SIPI-SIPI sequence, KVM will make the vCPU runnable. It is again up to the guest to then transfer control of the AP to the proper location. To differentiate between an actual HLT and an AP Reset Hold, a new MP state is introduced, KVM_MP_STATE_AP_RESET_HOLD, which the vCPU is placed in upon receiving the AP Reset Hold exit event. Additionally, to communicate the AP Reset Hold exit event up to userspace (if needed), a new exit reason is introduced, KVM_EXIT_AP_RESET_HOLD. A new x86 ops function is introduced, vcpu_deliver_sipi_vector, in order to accomplish AP booting. For VMX, vcpu_deliver_sipi_vector is set to the original SIPI delivery function, kvm_vcpu_deliver_sipi_vector(). SVM adds a new function that, for non SEV-ES guests, invokes the original SIPI delivery function, kvm_vcpu_deliver_sipi_vector(), but for SEV-ES guests, implements the logic above.

Tom Lendacky committed 5 years ago

Commit 647daca1 parent f2c7ef38 files · +63 −6Browse files

Showing the changes to include/uapi/linux (1 of 8 files). Show all

Unified · Split

include/uapi/linux/kvm.h+2−0
@@ -251,6 +251,7 @@ struct kvm_hyperv_exit { · 250 unmodified lines
251#define KVM_EXIT_X86_RDMSR 29251#define KVM_EXIT_X86_RDMSR 29
252#define KVM_EXIT_X86_WRMSR 30252#define KVM_EXIT_X86_WRMSR 30
253#define KVM_EXIT_DIRTY_RING_FULL 31253#define KVM_EXIT_DIRTY_RING_FULL 31
254#define KVM_EXIT_AP_RESET_HOLD 32
254 255
255/* For KVM_EXIT_INTERNAL_ERROR */256/* For KVM_EXIT_INTERNAL_ERROR */
256/* Emulate instruction failed. */257/* Emulate instruction failed. */
@@ -573,6 +574,7 @@ struct kvm_vapic_addr { · 316 unmodified lines
573#define KVM_MP_STATE_CHECK_STOP 6574#define KVM_MP_STATE_CHECK_STOP 6
574#define KVM_MP_STATE_OPERATING 7575#define KVM_MP_STATE_OPERATING 7
575#define KVM_MP_STATE_LOAD 8576#define KVM_MP_STATE_LOAD 8
577#define KVM_MP_STATE_AP_RESET_HOLD 9
576 578
577struct kvm_mp_state {579struct kvm_mp_state {
578 __u32 mp_state;580 __u32 mp_state;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t