All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chenyi Qiang <chenyi.qiang@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Eduardo Habkost <eduardo@habkost.net>,
	Peter Xu <peterx@redhat.com>, Xiaoyao Li <xiaoyao.li@intel.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [PATCH v7 1/2] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault
Date: Wed, 28 Sep 2022 09:06:03 +0800	[thread overview]
Message-ID: <01bc053e-2809-c585-ef75-3b9acdd09974@intel.com> (raw)
In-Reply-To: <c773b5aa-19b0-20de-5818-67360307abd9@redhat.com>



On 9/27/2022 9:14 PM, Paolo Bonzini wrote:
> On 9/23/22 09:33, Chenyi Qiang wrote:
>> For the direct triple faults, i.e. hardware detected and KVM morphed
>> to VM-Exit, KVM will never lose them. But for triple faults sythesized
>> by KVM, e.g. the RSM path, if KVM exits to userspace before the request
>> is serviced, userspace could migrate the VM and lose the triple fault.
>>
>> A new flag KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that
>> the event.triple_fault_pending field contains a valid state if the
>> KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled.
> 
> Note that you are not transmitting the field on migration.  You need
> this on top:
> 
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index b97d182e28..d4124973ce 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1739,7 +1739,7 @@ typedef struct CPUArchState {
>       uint8_t has_error_code;
>       uint8_t exception_has_payload;
>       uint64_t exception_payload;
> -    bool triple_fault_pending;
> +    uint8_t triple_fault_pending;
>       uint32_t ins_len;
>       uint32_t sipi_vector;
>       bool tsc_valid;
> diff --git a/target/i386/machine.c b/target/i386/machine.c
> index cecd476e98..310b125235 100644
> --- a/target/i386/machine.c
> +++ b/target/i386/machine.c
> @@ -1562,6 +1562,25 @@ static const VMStateDescription vmstate_arch_lbr = {
>       }
>   };
> 
> +static bool triple_fault_needed(void *opaque)
> +{
> +    X86CPU *cpu = opaque;
> +    CPUX86State *env = &cpu->env;
> +
> +    return env->triple_fault_pending;
> +}
> +
> +static const VMStateDescription vmstate_triple_fault = {
> +    .name = "cpu/triple_fault",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .needed = triple_fault_needed,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_UINT8(env.triple_fault_pending, X86CPU),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
>   const VMStateDescription vmstate_x86_cpu = {
>       .name = "cpu",
>       .version_id = 12,
> @@ -1706,6 +1725,7 @@ const VMStateDescription vmstate_x86_cpu = {
>           &vmstate_amx_xtile,
>   #endif
>           &vmstate_arch_lbr,
> +        &vmstate_triple_fault,
>           NULL
>       }
>   };

Thanks Paolo for your review!

I'll add this in next version.

> 

  reply	other threads:[~2022-09-28  1:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23  7:33 [PATCH v7 0/2] Enable notify VM exit Chenyi Qiang
2022-09-23  7:33 ` [PATCH v7 1/2] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault Chenyi Qiang
2022-09-27 13:14   ` Paolo Bonzini
2022-09-28  1:06     ` Chenyi Qiang [this message]
2022-09-23  7:33 ` [PATCH v7 2/2] i386: Add notify VM exit support Chenyi Qiang
2022-09-27 13:43   ` Paolo Bonzini
2022-09-28  2:20     ` Chenyi Qiang
2022-09-28  5:29       ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01bc053e-2809-c585-ef75-3b9acdd09974@intel.com \
    --to=chenyi.qiang@intel.com \
    --cc=eduardo@habkost.net \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.