2022-11-08 16:44:53 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Generate definitions needed by assembly language modules.
|
|
|
|
* This code generates raw asm output which is post-processed to extract
|
|
|
|
* and format the required data.
|
|
|
|
*/
|
|
|
|
#define COMPILE_OFFSETS
|
|
|
|
|
|
|
|
#include <linux/kbuild.h>
|
|
|
|
#include "vmx/vmx.h"
|
2022-10-01 02:14:44 +08:00
|
|
|
#include "svm/svm.h"
|
2022-11-08 16:44:53 +08:00
|
|
|
|
|
|
|
static void __used common(void)
|
|
|
|
{
|
2022-10-01 02:14:44 +08:00
|
|
|
if (IS_ENABLED(CONFIG_KVM_AMD)) {
|
|
|
|
BLANK();
|
|
|
|
OFFSET(SVM_vcpu_arch_regs, vcpu_svm, vcpu.arch.regs);
|
2022-11-07 17:17:29 +08:00
|
|
|
OFFSET(SVM_current_vmcb, vcpu_svm, current_vmcb);
|
KVM: SVM: move MSR_IA32_SPEC_CTRL save/restore to assembly
Restoration of the host IA32_SPEC_CTRL value is probably too late
with respect to the return thunk training sequence.
With respect to the user/kernel boundary, AMD says, "If software chooses
to toggle STIBP (e.g., set STIBP on kernel entry, and clear it on kernel
exit), software should set STIBP to 1 before executing the return thunk
training sequence." I assume the same requirements apply to the guest/host
boundary. The return thunk training sequence is in vmenter.S, quite close
to the VM-exit. On hosts without V_SPEC_CTRL, however, the host's
IA32_SPEC_CTRL value is not restored until much later.
To avoid this, move the restoration of host SPEC_CTRL to assembly and,
for consistency, move the restoration of the guest SPEC_CTRL as well.
This is not particularly difficult, apart from some care to cover both
32- and 64-bit, and to share code between SEV-ES and normal vmentry.
Cc: stable@vger.kernel.org
Fixes: a149180fbcf3 ("x86: Add magic AMD return-thunk")
Suggested-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-10-01 02:24:40 +08:00
|
|
|
OFFSET(SVM_spec_ctrl, vcpu_svm, spec_ctrl);
|
2022-11-07 18:14:27 +08:00
|
|
|
OFFSET(SVM_vmcb01, vcpu_svm, vmcb01);
|
2022-11-07 17:17:29 +08:00
|
|
|
OFFSET(KVM_VMCB_pa, kvm_vmcb_info, pa);
|
2022-11-07 16:49:59 +08:00
|
|
|
OFFSET(SD_save_area_pa, svm_cpu_data, save_area_pa);
|
2022-10-01 02:14:44 +08:00
|
|
|
}
|
|
|
|
|
2022-11-08 16:44:53 +08:00
|
|
|
if (IS_ENABLED(CONFIG_KVM_INTEL)) {
|
|
|
|
BLANK();
|
|
|
|
OFFSET(VMX_spec_ctrl, vcpu_vmx, spec_ctrl);
|
|
|
|
}
|
|
|
|
}
|