Re: [PATCH v3 8/8] KVM: nSVM: implement ondemand allocation of the nested state

From: Paolo Bonzini
Date: Sat Sep 12 2020 - 12:33:25 EST


On 27/08/20 19:11, Maxim Levitsky wrote:
> + hsave_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
> + if (!hsave_page)
> + goto error;
> +

I think an error here should be just an internal error userspace exit,
or a -ENOMEM from KVM_RUN; not a #GP in the guest[1]. However, that's
difficult to plug into KVM. Can you instead allocate nested state if
KVM_SET_CPUID2 sets the SVM bit? Returning -ENOMEM from KVM_SET_CPUID2
is more likely to be something that userspace copes with.

I queued patches 1-5, and 7 for 5.9-rc.

Paolo

[1] Though in practice an order 0 allocation will never fail