hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/x86/kvm/svm/svm.c
....@@ -1392,7 +1392,9 @@
13921392
13931393 if (sd->current_vmcb != svm->vmcb) {
13941394 sd->current_vmcb = svm->vmcb;
1395
- indirect_branch_prediction_barrier();
1395
+
1396
+ if (!cpu_feature_enabled(X86_FEATURE_IBPB_ON_VMEXIT))
1397
+ indirect_branch_prediction_barrier();
13961398 }
13971399 avic_vcpu_load(vcpu, cpu);
13981400 }
....@@ -3374,6 +3376,7 @@
33743376
33753377 static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu)
33763378 {
3379
+ amd_clear_divider();
33773380 }
33783381
33793382 static inline void sync_cr8_to_lapic(struct kvm_vcpu *vcpu)
....@@ -3480,8 +3483,14 @@
34803483
34813484 static fastpath_t svm_exit_handlers_fastpath(struct kvm_vcpu *vcpu)
34823485 {
3483
- if (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR &&
3484
- to_svm(vcpu)->vmcb->control.exit_info_1)
3486
+ struct vmcb_control_area *control = &to_svm(vcpu)->vmcb->control;
3487
+
3488
+ /*
3489
+ * Note, the next RIP must be provided as SRCU isn't held, i.e. KVM
3490
+ * can't read guest memory (dereference memslots) to decode the WRMSR.
3491
+ */
3492
+ if (control->exit_code == SVM_EXIT_MSR && control->exit_info_1 &&
3493
+ nrips && control->next_rip)
34853494 return handle_fastpath_set_msr_irqoff(vcpu);
34863495
34873496 return EXIT_FASTPATH_NONE;
....@@ -3977,6 +3986,8 @@
39773986
39783987 static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
39793988 {
3989
+ if (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_INTR)
3990
+ vcpu->arch.at_instruction_boundary = true;
39803991 }
39813992
39823993 static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)