Skip to content

Commit 74905e3

Browse files
committed
KVM: nSVM: clarify recalc_intercepts() wrt CR8
The mysterious comment "We only want the cr8 intercept bits of L1" dates back to basically the introduction of nested SVM, back when the handling of "less typical" hypervisors was very haphazard. With the development of kvm-unit-tests for interrupt handling, the same code grew another vmcb_clr_intercept for the interrupt window (VINTR) vmexit, this time with a comment that is at least decent. It turns out however that the same comment applies to the CR8 write intercept, which is also a "recheck if an interrupt should be injected" intercept. The CR8 read intercept instead has not been used by KVM for 14 years (commit 649d686, "KVM: SVM: sync TPR value to V_TPR field in the VMCB"), so do not bother clearing it and let one comment describe both CR8 write and VINTR handling. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent b7bfaa7 commit 74905e3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,13 @@ void recalc_intercepts(struct vcpu_svm *svm)
138138
c->intercepts[i] = h->intercepts[i];
139139

140140
if (g->int_ctl & V_INTR_MASKING_MASK) {
141-
/* We only want the cr8 intercept bits of L1 */
142-
vmcb_clr_intercept(c, INTERCEPT_CR8_READ);
143-
vmcb_clr_intercept(c, INTERCEPT_CR8_WRITE);
144-
145141
/*
146-
* Once running L2 with HF_VINTR_MASK, EFLAGS.IF does not
147-
* affect any interrupt we may want to inject; therefore,
148-
* interrupt window vmexits are irrelevant to L0.
142+
* Once running L2 with HF_VINTR_MASK, EFLAGS.IF and CR8
143+
* does not affect any interrupt we may want to inject;
144+
* therefore, writes to CR8 are irrelevant to L0, as are
145+
* interrupt window vmexits.
149146
*/
147+
vmcb_clr_intercept(c, INTERCEPT_CR8_WRITE);
150148
vmcb_clr_intercept(c, INTERCEPT_VINTR);
151149
}
152150

0 commit comments

Comments
 (0)