From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, zealot351@gmail.com,
maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru
Subject: [Qemu-devel] [PATCH 06/12] kvmvapic: fixing loading vmstate
Date: Tue, 26 Aug 2014 11:15:03 +0400 [thread overview]
Message-ID: <20140826071503.1672.32964.stgit@PASHA-ISP> (raw)
In-Reply-To: <20140826071427.1672.48119.stgit@PASHA-ISP>
vapic state should not be synchronized with APIC while loading,
because APIC state could be not loaded yet at that moment.
We just save vapic_paddr in APIC VMState instead of synchronization.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
hw/i386/kvmvapic.c | 22 +++++++++++++++++++-
hw/intc/apic_common.c | 44 +++++++++++++++++++++++++++++++++++++++
include/hw/i386/apic_internal.h | 2 +-
3 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index ee95963..3c403c5 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -351,6 +351,24 @@ static int get_kpcr_number(X86CPU *cpu)
return kpcr.number;
}
+static int vapic_enable_post_load(VAPICROMState *s, X86CPU *cpu)
+{
+ int cpu_number = get_kpcr_number(cpu);
+ hwaddr vapic_paddr;
+ static const uint8_t enabled = 1;
+
+ if (cpu_number < 0) {
+ return -1;
+ }
+ vapic_paddr = s->vapic_paddr +
+ (((hwaddr)cpu_number) << VAPIC_CPU_SHIFT);
+ cpu_physical_memory_rw(vapic_paddr + offsetof(VAPICState, enabled),
+ (void *)&enabled, sizeof(enabled), 1);
+ s->state = VAPIC_ACTIVE;
+
+ return 0;
+}
+
static int vapic_enable(VAPICROMState *s, X86CPU *cpu)
{
int cpu_number = get_kpcr_number(cpu);
@@ -731,7 +749,9 @@ static void do_vapic_enable(void *data)
VAPICROMState *s = data;
X86CPU *cpu = X86_CPU(first_cpu);
- vapic_enable(s, cpu);
+ /* Do not synchronize with APIC, because it was not loaded yet.
+ Just call the enable function which does not have synchronization. */
+ vapic_enable_post_load(s, cpu);
}
static int vapic_post_load(void *opaque, int version_id)
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index ce3d903..8d672bd 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -345,6 +345,39 @@ static int apic_dispatch_post_load(void *opaque, int version_id)
return 0;
}
+static bool apic_common_sipi_needed(void *opaque)
+{
+ APICCommonState *s = APIC_COMMON(opaque);
+ return s->wait_for_sipi != 0;
+}
+
+static const VMStateDescription vmstate_apic_common_sipi = {
+ .name = "apic_sipi",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_INT32(sipi_vector, APICCommonState),
+ VMSTATE_INT32(wait_for_sipi, APICCommonState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static bool apic_common_vapic_paddr_needed(void *opaque)
+{
+ APICCommonState *s = APIC_COMMON(opaque);
+ return s->vapic_paddr != 0;
+}
+
+static const VMStateDescription vmstate_apic_common_vapic_paddr = {
+ .name = "apic_vapic_paddr",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64(vapic_paddr, APICCommonState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_apic_common = {
.name = "apic",
.version_id = 3,
@@ -375,6 +408,17 @@ static const VMStateDescription vmstate_apic_common = {
VMSTATE_INT64(timer_expiry,
APICCommonState), /* open-coded timer state */
VMSTATE_END_OF_LIST()
+ },
+ .subsections = (VMStateSubsection[]) {
+ {
+ .vmsd = &vmstate_apic_common_sipi,
+ .needed = apic_common_sipi_needed,
+ },
+ {
+ .vmsd = &vmstate_apic_common_vapic_paddr,
+ .needed = apic_common_vapic_paddr_needed,
+ },
+ VMSTATE_END_OF_LIST()
}
};
diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h
index 83e2a42..df4381c 100644
--- a/include/hw/i386/apic_internal.h
+++ b/include/hw/i386/apic_internal.h
@@ -124,7 +124,7 @@ struct APICCommonState {
uint32_t vapic_control;
DeviceState *vapic;
- hwaddr vapic_paddr; /* note: persistence via kvmvapic */
+ hwaddr vapic_paddr;
};
typedef struct VAPICState {
next prev parent reply other threads:[~2014-08-26 7:15 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 7:14 [Qemu-devel] [PATCH 00/12] Fixing hardware migration issues Pavel Dovgalyuk
2014-08-26 7:14 ` [Qemu-devel] [PATCH 01/12] integratorcp: adding vmstate for save/restore Pavel Dovgalyuk
2014-08-26 7:14 ` [Qemu-devel] [PATCH 02/12] pcspk: " Pavel Dovgalyuk
2014-08-26 9:10 ` Paolo Bonzini
2014-08-26 7:14 ` [Qemu-devel] [PATCH 03/12] fdc: " Pavel Dovgalyuk
2014-08-26 9:10 ` Paolo Bonzini
2014-08-26 7:14 ` [Qemu-devel] [PATCH 04/12] parallel: " Pavel Dovgalyuk
2014-08-26 9:10 ` Paolo Bonzini
2014-08-26 7:14 ` [Qemu-devel] [PATCH 05/12] serial: fixing " Pavel Dovgalyuk
2014-08-26 10:09 ` Paolo Bonzini
2014-08-26 7:15 ` Pavel Dovgalyuk [this message]
2014-08-26 10:01 ` [Qemu-devel] [PATCH 06/12] kvmvapic: fixing loading vmstate Paolo Bonzini
2014-08-27 12:16 ` Pavel Dovgaluk
2014-08-27 12:35 ` Paolo Bonzini
2014-08-27 13:03 ` Pavel Dovgaluk
2014-08-27 13:22 ` Paolo Bonzini
2014-09-09 10:30 ` Pavel Dovgaluk
2014-09-09 12:14 ` Paolo Bonzini
2014-08-26 7:15 ` [Qemu-devel] [PATCH 07/12] hpet: fixing saving and loading process Pavel Dovgalyuk
2014-08-26 7:15 ` [Qemu-devel] [PATCH 08/12] pckbd: adding new fields to vmstate Pavel Dovgalyuk
2014-08-26 9:12 ` Paolo Bonzini
2014-08-26 7:15 ` [Qemu-devel] [PATCH 09/12] rtl8139: " Pavel Dovgalyuk
2014-08-26 8:53 ` Paolo Bonzini
2014-08-27 10:15 ` Pavel Dovgaluk
2014-08-27 10:23 ` Paolo Bonzini
2014-08-27 10:30 ` Pavel Dovgaluk
2014-08-27 10:42 ` Paolo Bonzini
2014-08-27 10:48 ` Pavel Dovgaluk
[not found] ` <30591.5658282631$1409136551@news.gmane.org>
2014-08-27 15:50 ` Paolo Bonzini
2014-08-28 8:31 ` Pavel Dovgaluk
2014-08-28 11:02 ` Paolo Bonzini
2014-08-26 7:15 ` [Qemu-devel] [PATCH 10/12] piix: do not raise irq while loading vmstate Pavel Dovgalyuk
2014-08-26 9:21 ` Paolo Bonzini
2014-08-26 7:15 ` [Qemu-devel] [PATCH 11/12] mc146818rtc: add missed field to vmstate Pavel Dovgalyuk
2014-08-26 8:58 ` Paolo Bonzini
2014-08-26 7:15 ` [Qemu-devel] [PATCH 12/12] pl031: " Pavel Dovgalyuk
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=20140826071503.1672.32964.stgit@PASHA-ISP \
--to=pavel.dovgaluk@ispras.ru \
--cc=maria.klimushenkova@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zealot351@gmail.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;
as well as URLs for NNTP newsgroup(s).