* [PATCH] KVM: x86: get smi pending status correctly
@ 2021-01-18 8:47 Jay Zhou
2021-01-18 17:57 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Jay Zhou @ 2021-01-18 8:47 UTC (permalink / raw)
To: kvm, pbonzini
Cc: linux-kernel, seanjc, vkuznets, weidong.huang, wangxinxin.wang,
jianjay.zhou, zhuangshengen
The injection process of smi has two steps:
Qemu KVM
Step1:
cpu->interrupt_request &= \
~CPU_INTERRUPT_SMI;
kvm_vcpu_ioctl(cpu, KVM_SMI)
call kvm_vcpu_ioctl_smi() and
kvm_make_request(KVM_REQ_SMI, vcpu);
Step2:
kvm_vcpu_ioctl(cpu, KVM_RUN, 0)
call process_smi() if
kvm_check_request(KVM_REQ_SMI, vcpu) is
true, mark vcpu->arch.smi_pending = true;
The vcpu->arch.smi_pending will be set true in step2, unfortunately if
vcpu paused between step1 and step2, the kvm_run->immediate_exit will be
set and vcpu has to exit to Qemu immediately during step2 before mark
vcpu->arch.smi_pending true.
During VM migration, Qemu will get the smi pending status from KVM using
KVM_GET_VCPU_EVENTS ioctl at the downtime, then the smi pending status
will be lost.
Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
Signed-off-by: Shengen Zhuang <zhuangshengen@huawei.com>
---
arch/x86/kvm/x86.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9a8969a..9025c76 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -105,6 +105,7 @@
static void update_cr8_intercept(struct kvm_vcpu *vcpu);
static void process_nmi(struct kvm_vcpu *vcpu);
+static void process_smi(struct kvm_vcpu *vcpu);
static void enter_smm(struct kvm_vcpu *vcpu);
static void __kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags);
static void store_regs(struct kvm_vcpu *vcpu);
@@ -4230,6 +4231,9 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
{
process_nmi(vcpu);
+ if (kvm_check_request(KVM_REQ_SMI, vcpu))
+ process_smi(vcpu);
+
/*
* In guest mode, payload delivery should be deferred,
* so that the L1 hypervisor can intercept #PF before
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86: get smi pending status correctly
2021-01-18 8:47 [PATCH] KVM: x86: get smi pending status correctly Jay Zhou
@ 2021-01-18 17:57 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2021-01-18 17:57 UTC (permalink / raw)
To: Jay Zhou, kvm
Cc: linux-kernel, seanjc, vkuznets, weidong.huang, wangxinxin.wang,
zhuangshengen
On 18/01/21 09:47, Jay Zhou wrote:
> The injection process of smi has two steps:
>
> Qemu KVM
> Step1:
> cpu->interrupt_request &= \
> ~CPU_INTERRUPT_SMI;
> kvm_vcpu_ioctl(cpu, KVM_SMI)
>
> call kvm_vcpu_ioctl_smi() and
> kvm_make_request(KVM_REQ_SMI, vcpu);
>
> Step2:
> kvm_vcpu_ioctl(cpu, KVM_RUN, 0)
>
> call process_smi() if
> kvm_check_request(KVM_REQ_SMI, vcpu) is
> true, mark vcpu->arch.smi_pending = true;
>
> The vcpu->arch.smi_pending will be set true in step2, unfortunately if
> vcpu paused between step1 and step2, the kvm_run->immediate_exit will be
> set and vcpu has to exit to Qemu immediately during step2 before mark
> vcpu->arch.smi_pending true.
> During VM migration, Qemu will get the smi pending status from KVM using
> KVM_GET_VCPU_EVENTS ioctl at the downtime, then the smi pending status
> will be lost.
>
> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> Signed-off-by: Shengen Zhuang <zhuangshengen@huawei.com>
> ---
> arch/x86/kvm/x86.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 9a8969a..9025c76 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -105,6 +105,7 @@
>
> static void update_cr8_intercept(struct kvm_vcpu *vcpu);
> static void process_nmi(struct kvm_vcpu *vcpu);
> +static void process_smi(struct kvm_vcpu *vcpu);
> static void enter_smm(struct kvm_vcpu *vcpu);
> static void __kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags);
> static void store_regs(struct kvm_vcpu *vcpu);
> @@ -4230,6 +4231,9 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
> {
> process_nmi(vcpu);
>
> + if (kvm_check_request(KVM_REQ_SMI, vcpu))
> + process_smi(vcpu);
> +
> /*
> * In guest mode, payload delivery should be deferred,
> * so that the L1 hypervisor can intercept #PF before
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-18 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 8:47 [PATCH] KVM: x86: get smi pending status correctly Jay Zhou
2021-01-18 17:57 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).