Commit 229725a
committed
KVM: SVM: Clean up preemption toggling related to MSR_AMD64_TSC_RATIO
Explicitly disable preemption when writing MSR_AMD64_TSC_RATIO only in the
"outer" helper, as all direct callers of the "inner" helper now run with
preemption already disabled. And that isn't a coincidence, as the outer
helper requires a vCPU and is intended to be used when modifying guest
state and/or emulating guest instructions, which are typically done with
preemption enabled.
Direct use of the inner helper should be extremely limited, as the only
time KVM should modify MSR_AMD64_TSC_RATIO without a vCPU is when
sanitizing the MSR for a specific pCPU (currently done when {en,dis}abling
disabling SVM). The other direct caller is svm_prepare_switch_to_guest(),
which does have a vCPU, but is a one-off special case: KVM is about to
enter the guest on a specific pCPU and thus must have preemption disabled.
Link: https://lore.kernel.org/r/20230729011608.1065019-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent c0dc39b commit 229725a
1 file changed
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
572 | | - | |
573 | | - | |
574 | 572 | | |
575 | | - | |
| 573 | + | |
576 | 574 | | |
577 | 575 | | |
578 | 576 | | |
579 | | - | |
580 | | - | |
581 | 577 | | |
582 | 578 | | |
583 | 579 | | |
| |||
1152 | 1148 | | |
1153 | 1149 | | |
1154 | 1150 | | |
| 1151 | + | |
1155 | 1152 | | |
| 1153 | + | |
1156 | 1154 | | |
1157 | 1155 | | |
1158 | 1156 | | |
| |||
0 commit comments