Skip to content

Commit b2ec042

Browse files
tlendackybonzini
authored andcommitted
KVM: SVM: Remove the need to trigger an UNBLOCK event on AP creation
All SNP APs are initially started using the APIC INIT/SIPI sequence in the guest. This sequence moves the AP MP state from KVM_MP_STATE_UNINITIALIZED to KVM_MP_STATE_RUNNABLE, so there is no need to attempt the UNBLOCK. As it is, the UNBLOCK support in SVM is only enabled when AVIC is enabled. When AVIC is disabled, AP creation is still successful. Remove the KVM_REQ_UNBLOCK request from the AP creation code and revert the changes to the vcpu_unblocking() kvm_x86_ops path. Signed-off-by: Tom Lendacky <[email protected]> Signed-off-by: Michael Roth <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 73137f5 commit b2ec042

File tree

3 files changed

+1
-23
lines changed

3 files changed

+1
-23
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,10 +3909,6 @@ static int sev_snp_ap_creation(struct vcpu_svm *svm)
39093909
out:
39103910
if (kick) {
39113911
kvm_make_request(KVM_REQ_UPDATE_PROTECTED_GUEST_STATE, target_vcpu);
3912-
3913-
if (target_vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)
3914-
kvm_make_request(KVM_REQ_UNBLOCK, target_vcpu);
3915-
39163912
kvm_vcpu_kick(target_vcpu);
39173913
}
39183914

@@ -4478,16 +4474,6 @@ struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu)
44784474
return p;
44794475
}
44804476

4481-
void sev_vcpu_unblocking(struct kvm_vcpu *vcpu)
4482-
{
4483-
if (!sev_snp_guest(vcpu->kvm))
4484-
return;
4485-
4486-
if (kvm_test_request(KVM_REQ_UPDATE_PROTECTED_GUEST_STATE, vcpu) &&
4487-
vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)
4488-
vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
4489-
}
4490-
44914477
void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code)
44924478
{
44934479
struct kvm_memory_slot *slot;

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4943,12 +4943,6 @@ static void *svm_alloc_apic_backing_page(struct kvm_vcpu *vcpu)
49434943
return page_address(page);
49444944
}
49454945

4946-
static void svm_vcpu_unblocking(struct kvm_vcpu *vcpu)
4947-
{
4948-
sev_vcpu_unblocking(vcpu);
4949-
avic_vcpu_unblocking(vcpu);
4950-
}
4951-
49524946
static struct kvm_x86_ops svm_x86_ops __initdata = {
49534947
.name = KBUILD_MODNAME,
49544948

@@ -4971,7 +4965,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
49714965
.vcpu_load = svm_vcpu_load,
49724966
.vcpu_put = svm_vcpu_put,
49734967
.vcpu_blocking = avic_vcpu_blocking,
4974-
.vcpu_unblocking = svm_vcpu_unblocking,
4968+
.vcpu_unblocking = avic_vcpu_unblocking,
49754969

49764970
.update_exception_bitmap = svm_update_exception_bitmap,
49774971
.get_msr_feature = svm_get_msr_feature,

arch/x86/kvm/svm/svm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ int sev_cpu_init(struct svm_cpu_data *sd);
734734
int sev_dev_get_attr(u32 group, u64 attr, u64 *val);
735735
extern unsigned int max_sev_asid;
736736
void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code);
737-
void sev_vcpu_unblocking(struct kvm_vcpu *vcpu);
738737
void sev_snp_init_protected_guest_state(struct kvm_vcpu *vcpu);
739738
int sev_gmem_prepare(struct kvm *kvm, kvm_pfn_t pfn, gfn_t gfn, int max_order);
740739
void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end);
@@ -753,7 +752,6 @@ static inline int sev_cpu_init(struct svm_cpu_data *sd) { return 0; }
753752
static inline int sev_dev_get_attr(u32 group, u64 attr, u64 *val) { return -ENXIO; }
754753
#define max_sev_asid 0
755754
static inline void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code) {}
756-
static inline void sev_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
757755
static inline void sev_snp_init_protected_guest_state(struct kvm_vcpu *vcpu) {}
758756
static inline int sev_gmem_prepare(struct kvm *kvm, kvm_pfn_t pfn, gfn_t gfn, int max_order)
759757
{

0 commit comments

Comments
 (0)