From: Anthony PERARD <anthony.perard@citrix.com>
To: Xen Devel <xen-devel@lists.xen.org>
Cc: Ian Campbell <ian.campbell@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Jan Beulich <JBeulich@suse.com>,
Anthony PERARD <anthony.perard@citrix.com>
Subject: [PATCH V2] firmware: Change level-triggered GPE event to a edge one for qemu-xen
Date: Thu, 12 Dec 2013 15:30:05 +0000 [thread overview]
Message-ID: <1386862205-17863-1-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1386613837-27399-1-git-send-email-anthony.perard@citrix.com>
This should help to reduce a CPU hotplug race window where a cpu hotplug
event while not be seen by the OS.
When hotplugging more than one vcpu, some of those vcpus might not be
seen as plugged by the guest.
This is what is currently happenning:
1. hw adds cpu, sets GPE.2 bit and sends SCI
2. OSPM gets SCI, reads GPE00.sts and masks GPE.2 bit in GPE00.en
3. OSPM executes _L02 (level-triggered event associate to cpu hotplug)
4. hw adds second cpu and sets GPE.2 bit but SCI is not asserted
since GPE00.en masks event
5. OSPM resets GPE.2 bit in GPE00.sts and umasks it in GPE00.en
as result event for step 4 is lost because step 5 clears it and OS
will not see added second cpu.
ACPI 50 spec: 5.6.4 General-Purpose Event Handling
defines GPE event handling as following:
1. Disables the interrupt source (GPEx_BLK EN bit).
2. If an edge event, clears the status bit.
3. Performs one of the following:
* Dispatches to an ACPI-aware device driver.
* Queues the matching control method for execution.
* Manages a wake event using device _PRW objects.
4. If a level event, clears the status bit.
5. Enables the interrupt source.
So, by using edge-triggered General-Purpose Event instead of a
level-triggered GPE, OSPM is less likely to clear the status bit of the
addition of the second CPU. On step 5, QEMU will resend an interrupt if
the status bit is set.
This description apply also for PCI hotplug since the same step are
follow by QEMU, so we also change the GPE event type for PCI hotplug.
Patch and description inspired by SeaBIOS's commit:
Replace level gpe event with edge gpe event for hot-plug handlers
9c6635bd48d39a1d17d0a73df6e577ef6bd0037c
from Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
Change in V2:
- better patch comment:
patch those not fix race, but reduce the window
include patch description of the quoted commit
- change also apply to pci hotplug.
---
tools/firmware/hvmloader/acpi/mk_dsdt.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c b/tools/firmware/hvmloader/acpi/mk_dsdt.c
index 996f30b..a4b693b 100644
--- a/tools/firmware/hvmloader/acpi/mk_dsdt.c
+++ b/tools/firmware/hvmloader/acpi/mk_dsdt.c
@@ -220,9 +220,13 @@ int main(int argc, char **argv)
pop_block();
- /* Define GPE control method '_L02'. */
+ /* Define GPE control method. */
push_block("Scope", "\\_GPE");
- push_block("Method", "_L02");
+ if (dm_version == QEMU_XEN_TRADITIONAL) {
+ push_block("Method", "_L02");
+ } else {
+ push_block("Method", "_E02");
+ }
stmt("Return", "\\_SB.PRSC()");
pop_block();
pop_block();
@@ -428,7 +432,7 @@ int main(int argc, char **argv)
decision_tree(0x00, 0x100, "SLT", pci_hotplug_notify);
pop_block();
} else {
- push_block("Method", "_L01");
+ push_block("Method", "_E01");
for (slot = 1; slot <= 31; slot++) {
push_block("If", "And(PCIU, ShiftLeft(1, %i))", slot);
stmt("Notify", "\\_SB.PCI0.S%i, 1", slot);
--
Anthony PERARD
next prev parent reply other threads:[~2013-12-12 15:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-09 18:30 [PATCH] firmware: Fix vcpu hotplug race with qemu-xen Anthony PERARD
2013-12-10 8:43 ` Jan Beulich
2013-12-11 16:12 ` Anthony PERARD
2013-12-12 15:30 ` Anthony PERARD [this message]
2013-12-13 11:51 ` [PATCH V2] firmware: Change level-triggered GPE event to a edge one for qemu-xen Jan Beulich
2013-12-13 17:11 ` Anthony PERARD
2013-12-13 17:32 ` Ian Jackson
2013-12-13 17:44 ` Konrad Rzeszutek Wilk
2013-12-13 18:17 ` Anthony PERARD
2013-12-16 7:51 ` Jan Beulich
2013-12-13 19:17 ` [PATCH V3] " Anthony PERARD
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=1386862205-17863-1-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@citrix.com \
--cc=xen-devel@lists.xen.org \
/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;
as well as URLs for NNTP newsgroup(s).