> On 11/08/2016 04:13, Xulei (Stone) wrote:
> > Following your suggestion, I found this problem may be caused by the
> > flag of HF_SMM_MASK. I'm now sure QEMU is sending the KVM_SMI ioctl,
> > and kmod already handles this ioctl.
> >
> > I add printk in inject_pending_event(), like this:
> >
> > /* try to inject new event if pending */
> > + if(get_smi)
> > + printk(KERN_INFO "is_smm:%d\n", is_smm(vcpu));
> > +
> > if (vcpu->arch.smi_pending && !is_smm(vcpu)) {
> > vcpu->arch.smi_pending = false;
> > process_smi(vcpu);
> > }
> >
> > Then I found that the normal output is (is_smm is 0):
> > 2016-08-11T09:44:45.090078+08:00|info|kernel[-]|[1269634.151054get smi
> > ioctl from qemu
> > 2016-08-11T09:44:45.090097+08:00|info|kernel[-]|[1269634.151056in
> > process_smi_request
> > 2016-08-11T09:44:45.090114+08:00|info|kernel[-]|[1269634.151057is_smm:
> > 0
> > 2016-08-11T09:44:45.090131+08:00|info|kernel[-]|[1269634.151058process
> > smi 2016-08-11T09:44:45.090914+08:00|info|kernel[-]|[1269634.151575get
> > smi ioctl from qemu
> > 2016-08-11T09:44:45.090947+08:00|info|kernel[-]|[1269634.151578in
> > process_smi_request
> > 2016-08-11T09:44:45.090972+08:00|info|kernel[-]|[1269634.151579is_smm:
> > 0
> >
> > When problem occurs the output is (is_smm is 1):
> > 2016-08-11T10:07:11.755982+08:00|info|kernel[-]|[1270981.916056get smi
> > ioctl from qemu
> > 2016-08-11T10:07:11.756035+08:00|info|kernel[-]|[1270981.916062in
> > process_smi_request
> > 2016-08-11T10:07:11.756078+08:00|info|kernel[-]|[1270981.916064is_smm:
> > 1 2016-08-11T10:07:13.896977+08:00|info|kernel[-]|[1270984.058117get
> > smi ioctl from qemu
> > 2016-08-11T10:07:13.897063+08:00|info|kernel[-]|[1270984.058121in
> > process_smi_request
> > 2016-08-11T10:07:13.897091+08:00|info|kernel[-]|[1270984.058123is_smm:
> > 1
> >
> > So, it seems kvm cannot set HF_SMM_MASK flag correctly when we
> continuously reset VM.
> > Any futher suggestion? Paolo :)
>
> I guess a KVM_SET_VCPU_EVENTS is missing at reset time.
This maybe a kvm bug of SMM supporting feature:
assuming kvm SMI injection process is interrupted at the point
between process_smi() and bios executing RSM. Then bios runs from
the beginning again because of resetting and kvm keeps is_smm() =1.
When bios writes 0xb2 to raise a SMI, kvm thinks is_smm() = 1, and
will not process this request, and also will not call kvm_vcpu_reset()
to clear HF_SMM_MASK flag any more. Bios will not executing RSM
because of it does not get this SMI injecting from kvm. This condition
cannot break until we destroy this VM.
After testing 2 days, following patch can solve this problem, but obviously
it is not a suitable solution:
static int kvm_vcpu_ioctl_smi(struct kvm_vcpu *vcpu)
{
+ if (is_smm(vcpu)) {
+ vcpu->arch.hflags &= ~HF_SMM_MASK;
+ vcpu->arch.smi_pending = 0;
+ }
kvm_make_request(KVM_REQ_SMI, vcpu);
return 0;
}
Paolo, could you post a suitable patch to solve this problem based on
the information I mentioned above?
> Paolo