Skip to content

Commit f8d808e

Browse files
committed
KVM: SVM: Rewrite sev_es_prepare_switch_to_guest()'s comment about swap types
Rewrite the comment(s) in sev_es_prepare_switch_to_guest() to explain the swap types employed by the CPU for SEV-ES guests, i.e. to explain why KVM needs to save a seemingly random subset of host state, and to provide a decoder for the APM's Type-A/B/C terminology. Signed-off-by: Alexey Kardashevskiy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 29de732 commit f8d808e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,19 +3023,24 @@ void sev_es_vcpu_reset(struct vcpu_svm *svm)
30233023
void sev_es_prepare_switch_to_guest(struct sev_es_save_area *hostsa)
30243024
{
30253025
/*
3026-
* As an SEV-ES guest, hardware will restore the host state on VMEXIT,
3027-
* of which one step is to perform a VMLOAD. KVM performs the
3028-
* corresponding VMSAVE in svm_prepare_guest_switch for both
3029-
* traditional and SEV-ES guests.
3026+
* All host state for SEV-ES guests is categorized into three swap types
3027+
* based on how it is handled by hardware during a world switch:
3028+
*
3029+
* A: VMRUN: Host state saved in host save area
3030+
* VMEXIT: Host state loaded from host save area
3031+
*
3032+
* B: VMRUN: Host state _NOT_ saved in host save area
3033+
* VMEXIT: Host state loaded from host save area
3034+
*
3035+
* C: VMRUN: Host state _NOT_ saved in host save area
3036+
* VMEXIT: Host state initialized to default(reset) values
3037+
*
3038+
* Manually save type-B state, i.e. state that is loaded by VMEXIT but
3039+
* isn't saved by VMRUN, that isn't already saved by VMSAVE (performed
3040+
* by common SVM code).
30303041
*/
3031-
3032-
/* XCR0 is restored on VMEXIT, save the current host value */
30333042
hostsa->xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
3034-
3035-
/* PKRU is restored on VMEXIT, save the current host value */
30363043
hostsa->pkru = read_pkru();
3037-
3038-
/* MSR_IA32_XSS is restored on VMEXIT, save the currnet host value */
30393044
hostsa->xss = host_xss;
30403045
}
30413046

0 commit comments

Comments
 (0)