Re: [PATCH v5 4/6] KVM: SVM: Add support to handle AP reset MSR protocol

From: Tom Lendacky
Date: Wed Oct 20 2021 - 14:36:25 EST


On 10/20/21 12:40 PM, Sean Christopherson wrote:
On Wed, Oct 20, 2021, Joerg Roedel wrote:

Tying into above, handling this in SIPI is flawed. For example, if the guest
does INIT-SIPI-SIPI without a reset hold, KVM would incorrect set sw_exit_info_2
on the SIPI. Because this mess requires an INIT, KVM has lost track of whether
the guest was in KVM_MP_STATE_AP_RESET_HOLD and thus can't know if the SIPI
arrived after a reset hold. Looking at KVM, IIUC, this bug is why the hack
"received_first_sipi" exists.

The received_first_sipi is because the APs have to be started the very first time in the traditional way. The AP can't issue an AP reset hold if it hasn't started to begin with in which case there would be no GHCB mapped.

After the check to see if the GHCB is mapped was added to sev_vcpu_deliver_sipi_vector(), the "received_first_sipi" could probably have been deleted at that point.

Thanks,
Tom