Skip to contentSkip to conversation

KVM: x86: Unconditionally call x86 ops that are always implemented

PATCH Superseded Sean Christopherson 2 participants 4 messages Aug 1, 2019 – Aug 2, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86: Unconditionally call x86 ops that are always implemented

Remove two stale checks for non-NULL ops now that they're implemented by both VMX and SVM.

Fixes 74f169090b6f ("kvm/svm: Setup MCG_CAP on AMD properly")
Fixes b31c114b82b2 ("KVM: X86: Provide a capability to disable PAUSE intercepts")
---
 arch/x86/kvm/x86.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/kvm/x86.c +2 -6
index 01e18caac825..2c25a19d436f 100644
@@ -3506,8 +3506,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
 	for (bank = 0; bank < bank_num; bank++)
 		vcpu->arch.mce_banks[bank*4] = ~(u64)0;
 
-	if (kvm_x86_ops->setup_mce)
-		kvm_x86_ops->setup_mce(vcpu);
+	kvm_x86_ops->setup_mce(vcpu);
 out:
 	return r;
 }
@@ -9313,10 +9312,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	kvm_page_track_init(kvm);
 	kvm_mmu_init_vm(kvm);
 
-	if (kvm_x86_ops->vm_init)
-		return kvm_x86_ops->vm_init(kvm);
-
-	return 0;
+	return kvm_x86_ops->vm_init(kvm);
 }
 
 static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
Signature · 1 line
2.22.0
#1 lore raw
Quoted 26 lines · Sean Christopherson

Remove two stale checks for non-NULL ops now that they're implemented by both VMX and SVM.

Fixes 74f169090b6f ("kvm/svm: Setup MCG_CAP on AMD properly")
Fixes b31c114b82b2 ("KVM: X86: Provide a capability to disable PAUSE intercepts")
---
  arch/x86/kvm/x86.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/kvm/x86.c +1 -2
index 01e18caac825..2c25a19d436f 100644
@@ -3506,8 +3506,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
  	for (bank = 0; bank < bank_num; bank++)
  		vcpu->arch.mce_banks[bank*4] = ~(u64)0;
 
-	if (kvm_x86_ops->setup_mce)
-		kvm_x86_ops->setup_mce(vcpu);
+	kvm_x86_ops->setup_mce(vcpu);
  out:
  	return r;
  }
@@ -9313,10 +9312,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
  	kvm_page_track_init(kvm);

arch/x86/kvm/x86.c int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) · line 9318

Quoted 10 lines
arch/x86/kvm/x86.c +1 -4
  	kvm_mmu_init_vm(kvm);
 
-	if (kvm_x86_ops->vm_init)
-		return kvm_x86_ops->vm_init(kvm);
-
-	return 0;
+	return kvm_x86_ops->vm_init(kvm);
  }
 
  static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)

The following two ops are also implemented by both VMX and SVM:

        update_cr8_intercept
        update_pi_irte

#2 lore raw
Quoted 39 lines · Krish Sadhukhan
Quoted 24 lines · Sean Christopherson

Remove two stale checks for non-NULL ops now that they're implemented by both VMX and SVM.

Fixes 74f169090b6f ("kvm/svm: Setup MCG_CAP on AMD properly")
Fixes b31c114b82b2 ("KVM: X86: Provide a capability to disable PAUSE intercepts")
---
 arch/x86/kvm/x86.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/kvm/x86.c +1 -2
index 01e18caac825..2c25a19d436f 100644
@@ -3506,8 +3506,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
 	for (bank = 0; bank < bank_num; bank++)
 		vcpu->arch.mce_banks[bank*4] = ~(u64)0;
-	if (kvm_x86_ops->setup_mce)
-		kvm_x86_ops->setup_mce(vcpu);
+	kvm_x86_ops->setup_mce(vcpu);
 out:
 	return r;
 }

arch/x86/kvm/x86.c int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) · line 9316

Quoted 9 lines
arch/x86/kvm/x86.c +1 -4
@@ -9313,10 +9312,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	kvm_page_track_init(kvm);
 	kvm_mmu_init_vm(kvm);
-	if (kvm_x86_ops->vm_init)
-		return kvm_x86_ops->vm_init(kvm);
-
-	return 0;
+	return kvm_x86_ops->vm_init(kvm);
 }
 static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)

The following two ops are also implemented by both VMX and SVM:

Quoted 2 lines

        update_cr8_intercept
        update_pi_irte

Drat, I didn't think to grep for !kvm_x86_ops. I'll spin a v2. Thanks!

#3 lore raw
Quoted 40 lines · Sean Christopherson
Quoted 39 lines · Krish Sadhukhan
Quoted 24 lines · Sean Christopherson

Remove two stale checks for non-NULL ops now that they're implemented by both VMX and SVM.

Fixes 74f169090b6f ("kvm/svm: Setup MCG_CAP on AMD properly")
Fixes b31c114b82b2 ("KVM: X86: Provide a capability to disable PAUSE intercepts")
---
 arch/x86/kvm/x86.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/kvm/x86.c +1 -2
index 01e18caac825..2c25a19d436f 100644
@@ -3506,8 +3506,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
 	for (bank = 0; bank < bank_num; bank++)
 		vcpu->arch.mce_banks[bank*4] = ~(u64)0;
-	if (kvm_x86_ops->setup_mce)
-		kvm_x86_ops->setup_mce(vcpu);
+	kvm_x86_ops->setup_mce(vcpu);
 out:
 	return r;
 }

arch/x86/kvm/x86.c int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) · line 9316

Quoted 9 lines
arch/x86/kvm/x86.c +1 -4
@@ -9313,10 +9312,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	kvm_page_track_init(kvm);
 	kvm_mmu_init_vm(kvm);
-	if (kvm_x86_ops->vm_init)
-		return kvm_x86_ops->vm_init(kvm);
-
-	return 0;
+	return kvm_x86_ops->vm_init(kvm);
 }
 static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)

The following two ops are also implemented by both VMX and SVM:

Quoted 4 lines
Quoted 2 lines

        update_cr8_intercept
        update_pi_irte

Drat, I didn't think to grep for !kvm_x86_ops. I'll spin a v2. Thanks!

Ah, but update_cr8_intercept is zapped by VMX if hardware doesn't support the TPR shadow.

P.S. I meant to send this before posting v2, but I got distracted...