From: Paolo Bonzini <pbonzini@redhat.com>
To: Liran Alon <LIRAN.ALON@ORACLE.COM>,
Gonglei <arei.gonglei@huawei.com>,
rkrcmar@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
weidong.huang@huawei.com
Subject: Re: [PATCH] KVM: x86: ioapic: Clear IRR for rtc bit when rtc EOI gotten
Date: Thu, 14 Dec 2017 14:18:32 +0100 [thread overview]
Message-ID: <c717aa9a-390c-4f8b-76f0-6754a02a7176@redhat.com> (raw)
In-Reply-To: <5A327636.3050307@ORACLE.COM>
On 14/12/2017 14:01, Liran Alon wrote:
>> But in our test, we found that there is a possible situation that Vcpu
>> fails to read
>> RTC_REG_C to clear irq, This could happens while two VCpus are
>> writing/reading
>> registers at the same time, for example, vcpu 0 is trying to read
>> RTC_REG_C,
>> so it write RTC_REG_C first, where the s->cmos_index will be RTC_REG_C,
>> but before it tries to read register C, another vcpu1 is going to read
>> RTC_YEAR,
>> it changes s->cmos_index to RTC_YEAR by a writing action.
>> The next operation of vcpu0 will be lead to read RTC_YEAR, In this
>> case, we will miss
>> calling qemu_irq_lower(s->irq) to clear the irq. After this, kvm will
>> never inject RTC irq,
>> and Windows VM will hang.
>
> If I understood correctly, this looks to me like a race-condition bug in
> the Windows guest kernel. In real-hardware this race-condition will also
> cause the RTC_YEAR to be read instead of RTC_REG_C.
> Guest kernel should make sure that 2 CPUs does not attempt to read a
> CMOS register in parallel as they can override each other's cmos_index.
>
> See for example how Linux kernel makes sure to avoid such kind of issues
> in rtc_cmos_read() (arch/x86/kernel/rtc.c) by grabbing a cmos_lock.
Lei and I looked at it further, and the root cause is not the missed EOI
in QEMU. Rather it's a bug in ioapic.c's tracking of RTC interrupts.
Paolo
next prev parent reply other threads:[~2017-12-14 13:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 12:23 Gonglei
2017-12-14 13:01 ` Liran Alon
2017-12-14 13:15 ` Gonglei (Arei)
2017-12-14 14:26 ` Quan Xu
2017-12-14 13:18 ` Paolo Bonzini [this message]
2017-12-25 7:29 ` Wanpeng Li
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=c717aa9a-390c-4f8b-76f0-6754a02a7176@redhat.com \
--to=pbonzini@redhat.com \
--cc=LIRAN.ALON@ORACLE.COM \
--cc=arei.gonglei@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=weidong.huang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®