From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: quintela@redhat.com, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 3/3] uqmaster: save/restore PIO page
Date: Thu, 28 Jan 2010 17:03:03 -0200 [thread overview]
Message-ID: <20100128190411.624005970@redhat.com> (raw)
In-Reply-To: 20100128190300.414710338@redhat.com
[-- Attachment #1: kvm-save-pio-page --]
[-- Type: text/plain, Size: 3217 bytes --]
KVM uses a page mapped by userspace as a buffer for PIO.
Save/restore it.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: qemu-kvm/target-i386/cpu.h
===================================================================
--- qemu-kvm.orig/target-i386/cpu.h
+++ qemu-kvm/target-i386/cpu.h
@@ -716,6 +716,7 @@ typedef struct CPUX86State {
uint32_t cpuid_kvm_features;
KVMPIOState kvm_pio;
+ uint8_t kvm_pio_page[4096];
/* in order to simplify APIC support, we leave this pointer to the
user */
Index: qemu-kvm/target-i386/machine.c
===================================================================
--- qemu-kvm.orig/target-i386/machine.c
+++ qemu-kvm/target-i386/machine.c
@@ -350,6 +350,8 @@ static void cpu_pre_save(void *opaque)
int i;
cpu_synchronize_state(env);
+ if (kvm_enabled())
+ kvm_get_pio_page(env);
/* FPU */
env->fpus_vmstate = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;
@@ -378,6 +380,9 @@ static int cpu_post_load(void *opaque, i
CPUState *env = opaque;
int i;
+ if (kvm_enabled())
+ kvm_put_pio_page(env);
+
/* XXX: restore FPU round state */
env->fpstt = (env->fpus_vmstate >> 11) & 7;
env->fpus = env->fpus_vmstate & ~0x3800;
@@ -494,6 +499,7 @@ static const VMStateDescription vmstate_
VMSTATE_UINT64_V(wall_clock_msr, CPUState, 11),
VMSTATE_KVM_PIO(kvm_pio, CPUState, 11),
+ VMSTATE_UINT8_ARRAY_V(kvm_pio_page, CPUState, TARGET_PAGE_SIZE, 11),
VMSTATE_END_OF_LIST()
/* The above list is not sorted /wrt version numbers, watch out! */
Index: qemu-kvm/kvm.h
===================================================================
--- qemu-kvm.orig/kvm.h
+++ qemu-kvm/kvm.h
@@ -132,6 +132,9 @@ uint32_t kvm_arch_get_supported_cpuid(CP
int reg);
void kvm_cpu_synchronize_state(CPUState *env);
+void kvm_put_pio_page(CPUState *env);
+void kvm_get_pio_page(CPUState *env);
+
/* generic hooks - to be moved/refactored once there are more users */
static inline void cpu_synchronize_state(CPUState *env)
Index: qemu-kvm/target-i386/kvm.c
===================================================================
--- qemu-kvm.orig/target-i386/kvm.c
+++ qemu-kvm/target-i386/kvm.c
@@ -889,6 +889,39 @@ static int kvm_get_pio(CPUState *env)
return 0;
}
+static int kvm_pio_page_offset(CPUState *env)
+{
+ int ret = 0;
+
+#ifdef KVM_CAP_PIO
+ ret = kvm_check_extension(env->kvm_state, KVM_CAP_PIO);
+#endif
+
+ return ret;
+}
+
+void kvm_put_pio_page(CPUState *env)
+{
+ uint8_t *pio_page;
+ int pio_page_off = kvm_pio_page_offset(env);
+
+ if (pio_page_off) {
+ pio_page = (uint8_t *)env->kvm_run + (pio_page_off * TARGET_PAGE_SIZE);
+ memcpy(pio_page, env->kvm_pio_page, TARGET_PAGE_SIZE);
+ }
+}
+
+void kvm_get_pio_page(CPUState *env)
+{
+ uint8_t *pio_page;
+ int pio_page_off = kvm_pio_page_offset(env);
+
+ if (pio_page_off) {
+ pio_page = (uint8_t *)env->kvm_run + (pio_page_off * TARGET_PAGE_SIZE);
+ memcpy(env->kvm_pio_page, pio_page, TARGET_PAGE_SIZE);
+ }
+}
+
int kvm_arch_put_registers(CPUState *env)
{
int ret;
next prev parent reply other threads:[~2010-01-28 19:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-28 19:03 [patch 0/3] save/restore in-progress PIO Marcelo Tosatti
2010-01-28 19:03 ` [patch 1/3] KVM: x86: add ioctls to get/set PIO state Marcelo Tosatti
2010-02-04 19:16 ` Avi Kivity
2010-02-04 21:36 ` Marcelo Tosatti
2010-02-04 21:46 ` Avi Kivity
2010-02-04 22:12 ` Marcelo Tosatti
2010-02-04 22:45 ` Marcelo Tosatti
2010-02-08 22:41 ` Marcelo Tosatti
2010-02-09 6:38 ` Avi Kivity
2010-02-09 18:23 ` Marcelo Tosatti
2010-02-09 20:58 ` qemu-kvm: do not allow vcpu stop with in progress PIO Marcelo Tosatti
2010-02-10 7:02 ` Avi Kivity
2010-02-10 16:25 ` Marcelo Tosatti
2010-02-10 16:40 ` Avi Kivity
2010-02-10 16:52 ` Alexander Graf
2010-02-10 17:01 ` Avi Kivity
2010-02-10 17:03 ` Alexander Graf
2010-02-10 17:08 ` Avi Kivity
2010-02-10 17:07 ` Gleb Natapov
2010-02-10 17:08 ` Avi Kivity
2010-02-13 18:10 ` KVM: add doc note about PIO/MMIO completion API Marcelo Tosatti
2010-02-14 8:17 ` Avi Kivity
2010-02-17 9:22 ` Avi Kivity
2010-02-18 13:24 ` qemu-kvm: do not allow vcpu stop with in progress PIO Avi Kivity
2010-01-28 19:03 ` [patch 2/3] uqmaster: save/restore pio state Marcelo Tosatti
2010-01-28 19:03 ` Marcelo Tosatti [this message]
2010-01-28 20:24 ` [patch 3/3] uqmaster: save/restore PIO page Anthony Liguori
2010-01-28 21:10 ` Marcelo Tosatti
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=20100128190411.624005970@redhat.com \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=quintela@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.