Re: [PATCH] KVM: nSVM: prepare guest save area while is_guest_mode is true

From: Paolo Bonzini
Date: Thu Feb 18 2021 - 14:20:11 EST


On 18/02/21 18:42, Sean Christopherson wrote:
The bug is present since commit 06fc7772690d ("KVM: SVM: Activate nested
state only when guest state is complete", 2010-04-25). Unfortunately,
it is not clear from the commit message what issue exactly led to the
change back then. It was probably related to svm_set_cr0 however because
the patch series cover letter[1] mentioned lazy FPU switching.

Aha! It was indeed related to svm_set_cr0(). Specifically, the next patch,
commit 66a562f7e257 ("KVM: SVM: Make lazy FPU switching work with nested svm"),
added is_nested() checks in update_cr0_intercept() to merge L1's intercepts with
L0's intercepts.

Yeah, the problem is I don't understand why 06fc7772690d fixed things in 11 year old KVM instead of breaking them, because effectively this patch is reverting it.

I don't care _that_ much because so much has changed since then; the world switch logic is abstracted better nowadays, and it is easier to review the change. But it is weird, nevertheless.

Paolo