From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] PPC: Get MMU state on register sync
Date: Tue, 24 Nov 2009 09:01:52 +0100 [thread overview]
Message-ID: <1259049712-8165-2-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1259049712-8165-1-git-send-email-agraf@suse.de>
While x86 only needs to sync cr0-4 to know all about its MMU state and enable
qemu to resolve virtual to physical addresses, we need to sync all of the
segment registers on PPC to know which mapping we're in.
So let's grab the segment register contents to be able to use the "x" monitor
command and also enable the gdbstub to resolve virtual addresses.
I sent the corresponding KVM patch to the KVM ML some minutes ago.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-ppc/kvm.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 4e1c65f..566513f 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -98,12 +98,17 @@ int kvm_arch_put_registers(CPUState *env)
int kvm_arch_get_registers(CPUState *env)
{
struct kvm_regs regs;
+ struct kvm_sregs sregs;
uint32_t i, ret;
ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, ®s);
if (ret < 0)
return ret;
+ ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);
+ if (ret < 0)
+ return ret;
+
env->ctr = regs.ctr;
env->lr = regs.lr;
env->xer = regs.xer;
@@ -125,6 +130,31 @@ int kvm_arch_get_registers(CPUState *env)
for (i = 0;i < 32; i++)
env->gpr[i] = regs.gpr[i];
+#ifdef KVM_CAP_PPC_SEGSTATE
+ if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_SEGSTATE)) {
+ env->sdr1 = sregs.sdr1;
+
+ /* Sync SLB */
+ for (i = 0; i < 64; i++) {
+ ppc_store_slb(env, sregs.ppc64.slb[i].slbe,
+ sregs.ppc64.slb[i].slbv);
+ }
+
+ /* Sync SRs */
+ for (i = 0; i < 16; i++) {
+ env->sr[i] = sregs.ppc32.sr[i];
+ }
+
+ /* Sync BATs */
+ for (i = 0; i < 8; i++) {
+ env->DBAT[0][i] = sregs.ppc32.dbat[i] & 0xffffffff;
+ env->DBAT[1][i] = sregs.ppc32.dbat[i] >> 32;
+ env->IBAT[0][i] = sregs.ppc32.ibat[i] & 0xffffffff;
+ env->IBAT[1][i] = sregs.ppc32.ibat[i] >> 32;
+ }
+ }
+#endif
+
return 0;
}
--
1.6.0.2
next prev parent reply other threads:[~2009-11-24 8:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-24 8:01 [Qemu-devel] [PATCH] PPC: Sync CPU state for KVM Alexander Graf
2009-11-24 8:01 ` Alexander Graf [this message]
2009-11-24 18:01 ` [Qemu-devel] Re: [PATCH] PPC: Get MMU state on register sync Jan Kiszka
2009-11-24 18:04 ` Alexander Graf
2009-11-24 18:12 ` Jan Kiszka
2009-11-24 18:14 ` Alexander Graf
2009-11-24 18:33 ` Jan Kiszka
2009-11-24 18:46 ` Alexander Graf
2009-11-24 18:49 ` Jan Kiszka
2009-11-24 18:53 ` Alexander Graf
2009-11-24 19:03 ` Jan Kiszka
2009-11-24 19:10 ` Alexander Graf
-- strict thread matches above, loose matches on Subject: below --
2009-12-02 22:19 [Qemu-devel] " Alexander Graf
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=1259049712-8165-2-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=qemu-devel@nongnu.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).