Re: [PATCH 4/8] KVM: SEV-ES: clean up kvm_sev_es_ins/outs

Paolo Bonzini
2021-10-22T16:31:15Z

On 22/10/21 01:14, Maxim Levitsky wrote:
>>
>> vcpu->arch.pio.count = 0;
> ^^^
> I wonder what the rules are for clearing vcpu->arch.pio.count for userspace PIO vm exits.
> Looks like complete_fast_pio_out clears it, but otherwise the only other place
> that clears it in this case is x86_emulate_instruction when it restarts the instuction.
> Do I miss something?

For IN, it is cleared by the completion callback.

For OUT, it can be cleared either by the completion callback or before
calling it, because the completion callback will not need it. I would
like to standardize towards clearing it in the callback for out, too,
even if sometimes it's unnecessary to have a callback in the first
place; this is what patch 8 does for example. This way
vcpu->arch.pio.count > 0 tells you whether the other fields have a
recent value.

Paolo