Skip to content

Commit a9095e4

Browse files
committed
KVM: SVM: Update "APICv in x2APIC without x2AVIC" in avic.c, not svm.c
Set the "allow_apicv_in_x2apic_without_x2apic_virtualization" flag as part of avic_hardware_setup() instead of handling in svm_hardware_setup(), and make x2avic_enabled local to avic.c (setting the flag was the only use in svm.c). Tag avic_hardware_setup() with __init as necessary (it should have been tagged __init long ago). No functional change intended (aside from the side effects of tagging avic_hardware_setup() with __init). Acked-by: Naveen N Rao (AMD) <[email protected]> Tested-by: Naveen N Rao (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent eb44ea6 commit a9095e4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static DEFINE_HASHTABLE(svm_vm_data_hash, SVM_VM_DATA_HASH_BITS);
7777
static u32 next_vm_id = 0;
7878
static bool next_vm_id_wrapped = 0;
7979
static DEFINE_SPINLOCK(svm_vm_data_hash_lock);
80-
bool x2avic_enabled;
80+
static bool x2avic_enabled;
8181

8282

8383
static void avic_set_x2apic_msr_interception(struct vcpu_svm *svm,
@@ -1147,7 +1147,7 @@ void avic_vcpu_unblocking(struct kvm_vcpu *vcpu)
11471147
* - Hypervisor can support both xAVIC and x2AVIC in the same guest.
11481148
* - The mode can be switched at run-time.
11491149
*/
1150-
bool avic_hardware_setup(void)
1150+
bool __init avic_hardware_setup(void)
11511151
{
11521152
if (!npt_enabled)
11531153
return false;
@@ -1182,6 +1182,8 @@ bool avic_hardware_setup(void)
11821182
x2avic_enabled = boot_cpu_has(X86_FEATURE_X2AVIC);
11831183
if (x2avic_enabled)
11841184
pr_info("x2AVIC enabled\n");
1185+
else
1186+
svm_x86_ops.allow_apicv_in_x2apic_without_x2apic_virtualization = true;
11851187

11861188
/*
11871189
* Disable IPI virtualization for AMD Family 17h CPUs (Zen1 and Zen2)

arch/x86/kvm/svm/svm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,8 +5337,6 @@ static __init int svm_hardware_setup(void)
53375337
svm_x86_ops.vcpu_blocking = NULL;
53385338
svm_x86_ops.vcpu_unblocking = NULL;
53395339
svm_x86_ops.vcpu_get_apicv_inhibit_reasons = NULL;
5340-
} else if (!x2avic_enabled) {
5341-
svm_x86_ops.allow_apicv_in_x2apic_without_x2apic_virtualization = true;
53425340
}
53435341

53445342
if (vls) {

arch/x86/kvm/svm/svm.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ extern bool npt_enabled;
4848
extern int nrips;
4949
extern int vgif;
5050
extern bool intercept_smi;
51-
extern bool x2avic_enabled;
5251
extern bool vnmi;
5352
extern int lbrv;
5453

@@ -804,7 +803,7 @@ extern struct kvm_x86_nested_ops svm_nested_ops;
804803
BIT(APICV_INHIBIT_REASON_PHYSICAL_ID_TOO_BIG) \
805804
)
806805

807-
bool avic_hardware_setup(void);
806+
bool __init avic_hardware_setup(void);
808807
int avic_ga_log_notifier(u32 ga_tag);
809808
void avic_vm_destroy(struct kvm *kvm);
810809
int avic_vm_init(struct kvm *kvm);

0 commit comments

Comments
 (0)