All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2]: KVM: i386: Add support for save and restore nested state
@ 2018-09-14  0:38 ` Liran Alon
  0 siblings, 0 replies; 15+ messages in thread
From: Liran Alon @ 2018-09-14  0:38 UTC (permalink / raw)
  To: qemu-devel, rth, ehabkost; +Cc: pbonzini, idan.brown, mtosatti, kvm, jmattson

Hi,

This series aims to add support for QEMU to be able to migrate VMs that
are running nested hypervisors. In order to do so, it utilizes the new
IOCTLs introduced in KVM commit 8fcc4b5923af ("kvm: nVMX: Introduce
KVM_CAP_NESTED_STATE") which were created for this purpose.

1st patch is not really related to the goal of the patch series. It just
makes CPUX86State->xsave_buf to be compiled only when needed (When
compiling with KVM or HVF CPU accelerator).

2nd patch adds the support to migrate VMs that are running nested
hypervisors.

Regards,
-Liran

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] KVM: i386: Add support for save and restore nested state
@ 2018-09-14  9:54 Liran Alon
  2018-09-14 10:59 ` Paolo Bonzini
  0 siblings, 1 reply; 15+ messages in thread
From: Liran Alon @ 2018-09-14  9:54 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Idan Brown, ehabkost, kvm list, mtosatti, qemu-devel, rth, Jim Mattson

>On 14/09/2018 09:16, Paolo Bonzini wrote:
>Heh, I was going to send a similar patch.  However, things are a bit
>more complex for two reason.
>
>First, I'd prefer to reuse the hflags and hflags2 fields that we already
>have, and only store the VMCS blob in the subsection.  For example,
>HF_SVMI_MASK is really the same as HF_GUEST_MASK in KVM source code and
>KVM_STATE_NESTED_GUEST_MODE in the nested virt state.
>

Do you mean you intend to only save/restore the “vmx” field in struct kvm_nested_state?
(That is, struct kvm_vmx_nested_state)
If yes, that is problematic as kvm_nested_state.flags also hold other flags besides KVM_STATE_NESTED_GUEST_MODE.
How do you expect to save/restore for example the vmx->nested.nested_run_pending flag that is specified in KVM_STATE_NESTED_RUN_PENDING?

In addition, why is it important to avoid save/restore the entire kvm_nested_state struct?
It seems to simplify things to just save/restore the entire struct.

>More important, this:
>
>>
>> +static int nested_state_post_load(void *opaque, int version_id)
>> +{
>> +    X86CPU *cpu = opaque;
>> +    CPUX86State *env = &cpu->env;
>> +
>> +    /*
>> +     * Verify that the size specified in given struct is set
>> +     * to no more than the size that our kernel support
>> +     */
>> +    if (env->nested_state->size > env->nested_state_len) {
>> +        return -EINVAL;
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +static bool nested_state_needed(void *opaque)
>
>doesn't work if nested_state_len differs between source and destination,
>and could overflow the nested_state buffer if nested_state_len is larger
>on the source.

This is not accurate.
I have actually given a lot of thought to this aspect in the patch.

The above post_load() method actually prevents an overflow to happen on dest.
Note that env->nested_state_len is not passed as part of migration stream.
It is only set by local kernel KVM_CAP_NESTED_STATE.

Therefore, we allow the following migrations to execute successfully:
1) Migration from a source with smaller KVM_CAP_NESTED_STATE to dest with a bigger one.
The above post_load() check will succeed as size specified in migrated nested_state->size
is smaller than dest KVM_CAP_NESTED_STATE (stored in env->nested_state_len).
2) Migration from source to dest when they both have same KVM_CAP_NESTED_STATE size.
Obvious.
3) Migration from source to dest when source have a bigger KVM_CAP_NESTED_STATE than dest.
This will only succeed in case size specified in nested_state->size is smaller than dest KVM_CAP_NESTED_STATE.

-Liran

>
>I'll send my version today or next Monday.
>
>Thanks,
>
>Paolo
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-09-17 14:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14  0:38 [PATCH 0/2]: KVM: i386: Add support for save and restore nested state Liran Alon
2018-09-14  0:38 ` [Qemu-devel] " Liran Alon
2018-09-14  0:38 ` [PATCH 1/2] i386: Compile CPUX86State xsave_buf only when support KVM or HVF Liran Alon
2018-09-14  0:38   ` [Qemu-devel] " Liran Alon
2018-09-14  0:38 ` [PATCH 2/2] KVM: i386: Add support for save and restore nested state Liran Alon
2018-09-14  0:38   ` [Qemu-devel] " Liran Alon
2018-09-14  7:16   ` Paolo Bonzini
2018-09-14  7:16     ` [Qemu-devel] " Paolo Bonzini
2018-09-14  9:54 Liran Alon
2018-09-14 10:59 ` Paolo Bonzini
2018-09-14 14:31   ` Liran Alon
2018-09-14 15:08     ` Paolo Bonzini
2018-09-15 20:48       ` Liran Alon
2018-09-15 20:57         ` Liran Alon
2018-09-17 14:35         ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.