Re: [PATCH 2/2] KVM: SVM: Refresh vcpu->arch.cr{0,3} prior to invoking fastpath handler

From: Nikunj A. Dadhania

Date: Fri Apr 24 2026 - 04:46:22 EST




On 4/23/2026 9:56 PM, Sean Christopherson wrote:
> Refresh KVM's copies of CR0 and CR3 from the VMCB prior to (potentially)
> invoking a fastpath handler to ensure that KVM doesn't consume stale
> state. While it's unlikely KVM will ever consume CR3 or CR0.{TS,MP} in
> the fastpath, grabbing the values from the VMCB is inexpensive, i.e. the
> risk of subtle bugs far outweighs the reward of deferring reads for a
> small subset of VM-Exits.

This also keeps CR0/CR3 current during the fast-reenter loop in
vcpu_enter_guest(), which previously skipped svm_handle_exit() entirely.

>
> Note, KVM doesn't currently consume CR3 or CR0.{TS,MP} in the fastpath,
> as KVM requires next_rip to be valid (i.e. KVM doesn't read CR3 to decode
> the instruction), CR0.MP is never consumed, and CR0.TS is only consumed by
> the full emulator.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Reviewed-by: Nikunj A. Dadhania <nikunj@xxxxxxx>