• Paolo Bonzini's avatar
    KVM: SVM: move guest vmsave/vmload back to assembly · e61ab42d
    Paolo Bonzini authored
    It is error-prone that code after vmexit cannot access percpu data
    because GSBASE has not been restored yet.  It forces MSR_IA32_SPEC_CTRL
    save/restore to happen very late, after the predictor untraining
    sequence, and it gets in the way of return stack depth tracking
    (a retbleed mitigation that is in linux-next as of 2022-11-09).
    
    As a first step towards fixing that, move the VMCB VMSAVE/VMLOAD to
    assembly, essentially undoing commit fb0c4a4f ("KVM: SVM: move
    VMLOAD/VMSAVE to C code", 2021-03-15).  The reason for that commit was
    that it made it simpler to use a different VMCB for VMLOAD/VMSAVE versus
    VMRUN; but that is not a big hassle anymore thanks to the kvm-asm-offsets
    machinery and other related cleanups.
    
    The idea on how to number the exception tables is stolen from
    a prototype patch by Peter Zijlstra.
    
    Cc: stable@vger.kernel.org
    Fixes: a149180f ("x86: Add magic AMD return-thunk")
    Link: <https://lore.kernel.org/all/f571e404-e625-bae1-10e9-449b2eb4cbd8@citrix.com/>
    Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    e61ab42d
kvm-asm-offsets.c 677 Bytes