Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: SVM: Add AP_JUMP_TABLE support in prep for AP booting

The GHCB specification requires the hypervisor to save the address of an
AP Jump Table so that, for example, vCPUs that have been parked by UEFI
can be started by the OS. Provide support for the AP Jump Table set/get
exit code.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Tom Lendacky and committed by
Paolo Bonzini
8640ca58 ad73109a

+29
+28
arch/x86/kvm/svm/sev.c
··· 18 18 #include <linux/trace_events.h> 19 19 #include <asm/fpu/internal.h> 20 20 21 + #include <asm/trapnr.h> 22 + 21 23 #include "x86.h" 22 24 #include "svm.h" 23 25 #include "cpuid.h" ··· 1561 1559 goto vmgexit_err; 1562 1560 break; 1563 1561 case SVM_VMGEXIT_NMI_COMPLETE: 1562 + case SVM_VMGEXIT_AP_JUMP_TABLE: 1564 1563 case SVM_VMGEXIT_UNSUPPORTED_EVENT: 1565 1564 break; 1566 1565 default: ··· 1886 1883 case SVM_VMGEXIT_NMI_COMPLETE: 1887 1884 ret = svm_invoke_exit_handler(svm, SVM_EXIT_IRET); 1888 1885 break; 1886 + case SVM_VMGEXIT_AP_JUMP_TABLE: { 1887 + struct kvm_sev_info *sev = &to_kvm_svm(svm->vcpu.kvm)->sev_info; 1888 + 1889 + switch (control->exit_info_1) { 1890 + case 0: 1891 + /* Set AP jump table address */ 1892 + sev->ap_jump_table = control->exit_info_2; 1893 + break; 1894 + case 1: 1895 + /* Get AP jump table address */ 1896 + ghcb_set_sw_exit_info_2(ghcb, sev->ap_jump_table); 1897 + break; 1898 + default: 1899 + pr_err("svm: vmgexit: unsupported AP jump table request - exit_info_1=%#llx\n", 1900 + control->exit_info_1); 1901 + ghcb_set_sw_exit_info_1(ghcb, 1); 1902 + ghcb_set_sw_exit_info_2(ghcb, 1903 + X86_TRAP_UD | 1904 + SVM_EVTINJ_TYPE_EXEPT | 1905 + SVM_EVTINJ_VALID); 1906 + } 1907 + 1908 + ret = 1; 1909 + break; 1910 + } 1889 1911 case SVM_VMGEXIT_UNSUPPORTED_EVENT: 1890 1912 vcpu_unimpl(&svm->vcpu, 1891 1913 "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",
+1
arch/x86/kvm/svm/svm.h
··· 78 78 int fd; /* SEV device fd */ 79 79 unsigned long pages_locked; /* Number of pages locked */ 80 80 struct list_head regions_list; /* List of registered regions */ 81 + u64 ap_jump_table; /* SEV-ES AP Jump Table address */ 81 82 }; 82 83 83 84 struct kvm_svm {