Re: [PATCH 3/4] KVM: nVMX: Introduce __nested_vmx_handle_enlightened_vmptrld()
From: Maxim Levitsky
Date: Wed May 05 2021 - 04:24:48 EST
On Mon, 2021-05-03 at 17:08 +0200, Vitaly Kuznetsov wrote:
> As a preparation to mapping eVMCS from vmx_set_nested_state() split
> the actual eVMCS mappign from aquiring eVMCS GPA.
>
> No functional change intended.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
> ---
> arch/x86/kvm/vmx/nested.c | 26 +++++++++++++++++---------
> 1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 2febb1dd68e8..37fdc34f7afc 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -1972,18 +1972,11 @@ static int copy_vmcs12_to_enlightened(struct vcpu_vmx *vmx)
> * This is an equivalent of the nested hypervisor executing the vmptrld
> * instruction.
> */
> -static enum nested_evmptrld_status nested_vmx_handle_enlightened_vmptrld(
> - struct kvm_vcpu *vcpu, bool from_launch)
> +static enum nested_evmptrld_status __nested_vmx_handle_enlightened_vmptrld(
> + struct kvm_vcpu *vcpu, u64 evmcs_gpa, bool from_launch)
> {
> struct vcpu_vmx *vmx = to_vmx(vcpu);
> bool evmcs_gpa_changed = false;
> - u64 evmcs_gpa;
> -
> - if (likely(!vmx->nested.enlightened_vmcs_enabled))
> - return EVMPTRLD_DISABLED;
> -
> - if (!nested_enlightened_vmentry(vcpu, &evmcs_gpa))
> - return EVMPTRLD_DISABLED;
>
> if (unlikely(!vmx->nested.hv_evmcs ||
> evmcs_gpa != vmx->nested.hv_evmcs_vmptr)) {
> @@ -2055,6 +2048,21 @@ static enum nested_evmptrld_status nested_vmx_handle_enlightened_vmptrld(
> return EVMPTRLD_SUCCEEDED;
> }
>
> +static enum nested_evmptrld_status nested_vmx_handle_enlightened_vmptrld(
> + struct kvm_vcpu *vcpu, bool from_launch)
> +{
> + struct vcpu_vmx *vmx = to_vmx(vcpu);
> + u64 evmcs_gpa;
> +
> + if (likely(!vmx->nested.enlightened_vmcs_enabled))
> + return EVMPTRLD_DISABLED;
> +
> + if (!nested_enlightened_vmentry(vcpu, &evmcs_gpa))
> + return EVMPTRLD_DISABLED;
> +
> + return __nested_vmx_handle_enlightened_vmptrld(vcpu, evmcs_gpa, from_launch);
> +}
> +
> void nested_sync_vmcs12_to_shadow(struct kvm_vcpu *vcpu)
> {
> struct vcpu_vmx *vmx = to_vmx(vcpu);
Reviewed-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
Best regards,
Maxim Levitsky