Skip to content

Commit 59a217c

Browse files
committed
KVM: SVM: Initialize per-CPU svm_data at the end of hardware setup
Setup the per-CPU SVM data structures at the very end of hardware setup so that svm_hardware_unsetup() can be used in svm_hardware_setup() to unwind AVIC setup (for the GALog notifier). Alternatively, the error path could do an explicit, manual unwind, e.g. by adding a helper to free the per-CPU structures. But the per-CPU allocations have no interactions or dependencies, i.e. can comfortably live at the end, and so converting to a manual unwind would introduce churn and code without providing any immediate advantage. Link: https://patch.msgid.link/20251016190643.80529-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent cab4098 commit 59a217c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5386,12 +5386,6 @@ static __init int svm_hardware_setup(void)
53865386

53875387
svm_hv_hardware_setup();
53885388

5389-
for_each_possible_cpu(cpu) {
5390-
r = svm_cpu_init(cpu);
5391-
if (r)
5392-
goto err;
5393-
}
5394-
53955389
enable_apicv = avic_hardware_setup();
53965390
if (!enable_apicv) {
53975391
enable_ipiv = false;
@@ -5435,6 +5429,13 @@ static __init int svm_hardware_setup(void)
54355429
svm_set_cpu_caps();
54365430

54375431
kvm_caps.inapplicable_quirks &= ~KVM_X86_QUIRK_CD_NW_CLEARED;
5432+
5433+
for_each_possible_cpu(cpu) {
5434+
r = svm_cpu_init(cpu);
5435+
if (r)
5436+
goto err;
5437+
}
5438+
54385439
return 0;
54395440

54405441
err:

0 commit comments

Comments
 (0)