linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	KVM list <kvm@vger.kernel.org>
Subject: [PATCH 16/26] KVM: PPC: Put segment registers in shared page
Date: Tue, 17 Aug 2010 15:57:51 +0200	[thread overview]
Message-ID: <1282053481-18787-17-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1282053481-18787-1-git-send-email-agraf@suse.de>

Now that the actual mtsr doesn't do anything anymore, we can move the sr
contents over to the shared page, so a guest can directly read and write
its sr contents from guest context.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/include/asm/kvm_book3s.h |    1 -
 arch/powerpc/include/asm/kvm_para.h   |    1 +
 arch/powerpc/kvm/book3s.c             |    7 +++----
 arch/powerpc/kvm/book3s_32_mmu.c      |   12 ++++++------
 arch/powerpc/kvm/powerpc.c            |    2 +-
 5 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 0884652..be8aac2 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -70,7 +70,6 @@ struct kvmppc_vcpu_book3s {
 		u64 vsid;
 	} slb_shadow[64];
 	u8 slb_shadow_max;
-	u32 sr[16];
 	struct kvmppc_bat ibat[8];
 	struct kvmppc_bat dbat[8];
 	u64 hid[6];
diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 43c1b22..d79fd09 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -38,6 +38,7 @@ struct kvm_vcpu_arch_shared {
 	__u64 msr;
 	__u32 dsisr;
 	__u32 int_pending;	/* Tells the guest if we have an interrupt */
+	__u32 sr[16];
 };
 
 #define KVM_SC_MAGIC_R0		0x4b564d21 /* "KVM!" */
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 082ec62..5fbe949 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -1159,10 +1159,9 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
 			sregs->u.s.ppc64.slb[i].slbv = vcpu3s->slb[i].origv;
 		}
 	} else {
-		for (i = 0; i < 16; i++) {
-			sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i];
-			sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i];
-		}
+		for (i = 0; i < 16; i++)
+			sregs->u.s.ppc32.sr[i] = vcpu->arch.shared->sr[i];
+
 		for (i = 0; i < 8; i++) {
 			sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw;
 			sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw;
diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c
index d4ff76f..c8cefdd 100644
--- a/arch/powerpc/kvm/book3s_32_mmu.c
+++ b/arch/powerpc/kvm/book3s_32_mmu.c
@@ -88,9 +88,9 @@ static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
 static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
 					     u64 *vsid);
 
-static u32 find_sr(struct kvmppc_vcpu_book3s *vcpu_book3s, gva_t eaddr)
+static u32 find_sr(struct kvm_vcpu *vcpu, gva_t eaddr)
 {
-	return vcpu_book3s->sr[(eaddr >> 28) & 0xf];
+	return vcpu->arch.shared->sr[(eaddr >> 28) & 0xf];
 }
 
 static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr,
@@ -211,7 +211,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,
 	int i;
 	int found = 0;
 
-	sre = find_sr(vcpu_book3s, eaddr);
+	sre = find_sr(vcpu, eaddr);
 
 	dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28,
 		    sr_vsid(sre), sre);
@@ -335,13 +335,13 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
 
 static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum)
 {
-	return to_book3s(vcpu)->sr[srnum];
+	return vcpu->arch.shared->sr[srnum];
 }
 
 static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
 					ulong value)
 {
-	to_book3s(vcpu)->sr[srnum] = value;
+	vcpu->arch.shared->sr[srnum] = value;
 	kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT);
 }
 
@@ -358,7 +358,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
 	u64 gvsid = esid;
 
 	if (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
-		sr = find_sr(to_book3s(vcpu), ea);
+		sr = find_sr(vcpu, ea);
 		if (sr_valid(sr))
 			gvsid = sr_vsid(sr);
 	}
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 496d7a5..028891c 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -66,7 +66,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 		vcpu->arch.magic_page_pa = param1;
 		vcpu->arch.magic_page_ea = param2;
 
-		r2 = 0;
+		r2 = KVM_MAGIC_FEAT_SR;
 
 		r = HC_EV_SUCCESS;
 		break;
-- 
1.6.0.2

  parent reply	other threads:[~2010-08-17 13:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-17 13:57 [PATCH 00/26] KVM: PPC: Mid-August patch queue Alexander Graf
2010-08-17 13:57 ` [PATCH 01/26] KVM: PPC: Move EXIT_DEBUG partially to tracepoints Alexander Graf
2010-08-17 13:57 ` [PATCH 02/26] KVM: PPC: Move book3s_64 mmu map debug print to trace point Alexander Graf
2010-08-17 13:57 ` [PATCH 03/26] KVM: PPC: Add tracepoint for generic mmu map Alexander Graf
2010-08-17 13:57 ` [PATCH 04/26] KVM: PPC: Move pte invalidate debug code to tracepoint Alexander Graf
2010-08-17 13:57 ` [PATCH 05/26] KVM: PPC: Fix sid map search after flush Alexander Graf
2010-08-17 13:57 ` [PATCH 06/26] KVM: PPC: Add tracepoints for generic spte flushes Alexander Graf
2010-08-17 13:57 ` [PATCH 07/26] KVM: PPC: Preload magic page when in kernel mode Alexander Graf
2010-08-17 13:57 ` [PATCH 08/26] KVM: PPC: Don't flush PTEs on NX/RO hit Alexander Graf
2010-08-17 13:57 ` [PATCH 09/26] KVM: PPC: Make invalidation code more reliable Alexander Graf
2010-08-17 13:57 ` [PATCH 10/26] KVM: PPC: Move slb debugging to tracepoints Alexander Graf
2010-08-17 13:57 ` [PATCH 11/26] KVM: PPC: Revert "KVM: PPC: Use kernel hash function" Alexander Graf
2010-08-17 13:57 ` [PATCH 12/26] KVM: PPC: Remove unused define Alexander Graf
2010-08-17 13:57 ` [PATCH 13/26] KVM: PPC: Add feature bitmap for magic page Alexander Graf
2010-08-22 16:42   ` Avi Kivity
2010-08-31  0:56     ` Alexander Graf
2010-08-31  6:28       ` Avi Kivity
2010-08-17 13:57 ` [PATCH 14/26] KVM: PPC: Move BAT handling code into spr handler Alexander Graf
2010-08-17 13:57 ` [PATCH 15/26] KVM: PPC: Interpret SR registers on demand Alexander Graf
2010-08-17 13:57 ` Alexander Graf [this message]
2010-08-17 13:57 ` [PATCH 17/26] KVM: PPC: Add mtsrin PV code Alexander Graf
2010-08-17 13:57 ` [PATCH 18/26] KVM: PPC: Make PV mtmsr work with r30 and r31 Alexander Graf
2010-08-17 13:57 ` [PATCH 19/26] KVM: PPC: Update int_pending also on dequeue Alexander Graf
2010-08-17 13:57 ` [PATCH 20/26] KVM: PPC: Make PV mtmsrd L=1 work with r30 and r31 Alexander Graf
2010-08-17 13:57 ` [PATCH 21/26] KVM: PPC: Force enable nap on KVM Alexander Graf
2010-08-17 18:28   ` Scott Wood
2010-08-17 20:07     ` Alexander Graf
2010-08-17 13:57 ` [PATCH 22/26] KVM: PPC: Implement correct SID mapping on Book3s_32 Alexander Graf
2010-08-17 13:57 ` [PATCH 23/26] KVM: PPC: Don't put MSR_POW in MSR Alexander Graf
2010-08-17 13:57 ` [PATCH 24/26] KVM: PPC: initialize IVORs in addition to IVPR Alexander Graf
2010-08-17 13:58 ` [PATCH 25/26] KVM: PPC: fix compilation of "dump tlbs" debug function Alexander Graf
2010-08-17 13:58 ` [PATCH 26/26] KVM: PPC: allow ppc440gp to pass the compatibility check Alexander Graf
2010-08-22 16:46 ` [PATCH 00/26] KVM: PPC: Mid-August patch queue Avi Kivity

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=1282053481-18787-17-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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).