All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-ppc-devel] [PATCH] [1/4] Add per guest pvr
@ 2008-01-30 12:31 ehrhardt
  2008-01-30 21:18 ` Hollis Blanchard
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ehrhardt @ 2008-01-30 12:31 UTC (permalink / raw)
  To: kvm-ppc

This adds get/set pvr to differ wanted guest cpu on runtiome.
The intention to bring it up so early at the vm ioctl is that our kernel code
can not know if which guest type we want to create on vcpu_create. Vcpu_create
itself do not transport any structure and and is called before our hooks in
the machine initialization.
We want to have our implementation ready to run different guest types at the
same time, therefore we can't set this globally at the /dev/kvm ioctl.
Currently this sets the pvr per machine while in the architecture itself it
is a per processor attribute (this binds us to one processor type per virtual
machine). If needed we might change this so that vcpu_create uses the last set
vm pvr as pvr for a new cpu e.g create generic followed by coprocesser
sequentially - comments?
Additionally this may later be extended to select the real pvr that e.g. 
will be presented to what a guest sees on a read to that spr. here the patch
as it is atm folowed by the tlb patch that uses the function to select the
right tlb layout.

Subject: [PATCH] [1/4] Add per guest pvr
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

This adds a per VM variable called pvr in imitation of the hardware spr. It
also adds a interface to get/set this variable to the vm ioctl. Atm it uses
non-real pvr values to allow us to differ on runtime e.g. between ppc440 and
e500 guests.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---

 arch/powerpc/kvm/powerpc.c     |   15 +++++++++++++++
 include/asm-powerpc/kvm.h      |    9 +++++++++
 include/asm-powerpc/kvm_host.h |    1 +
 include/linux/kvm.h            |    3 +++
 4 files changed, 28 insertions(+)

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -798,6 +798,21 @@ long kvm_arch_vm_ioctl(struct file *filp
 	long r;
 
 	switch (ioctl) {
+	case KVM_SET_GUEST_PVR: {
+		struct kvm *kvm = filp->private_data;
+		struct kvm_pvr __user *upvr = (struct kvm_pvr __user *)arg;
+		r = copy_from_user(&(kvm->arch.pvr), &(upvr->pvr),
+					sizeof(uint32_t));
+		break;
+	}
+	case KVM_GET_GUEST_PVR: {
+		struct kvm *kvm = filp->private_data;
+		struct kvm_pvr __user *upvr = (struct kvm_pvr __user *)arg;
+		struct kvm_pvr kpvr;
+		kpvr.pvr = kvm->arch.pvr;
+		r = copy_to_user(upvr, &kpvr, sizeof(struct kvm_pvr));
+		break;
+	}
 	default:
 		r = -EINVAL;
 	}
diff --git a/include/asm-powerpc/kvm.h b/include/asm-powerpc/kvm.h
--- a/include/asm-powerpc/kvm.h
+++ b/include/asm-powerpc/kvm.h
@@ -53,4 +53,13 @@ struct kvm_fpu {
 struct kvm_fpu {
 };
 
+/*
+ * guest ident based on virtual pvr's to differ between cpu types
+ *  this may later on be extended to appear and behave as real pvr's
+*/
+#define KVM_PPC_PVR_PPC44X 1
+
+struct kvm_pvr {
+	int pvr;
+};
 #endif /* __POWERPC_KVM_H__ */
diff --git a/include/asm-powerpc/kvm_host.h b/include/asm-powerpc/kvm_host.h
--- a/include/asm-powerpc/kvm_host.h
+++ b/include/asm-powerpc/kvm_host.h
@@ -49,6 +49,7 @@ struct tlbe {
 };
 
 struct kvm_arch {
+	uint32_t pvr;
 };
 
 struct kvm_vcpu_arch {
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -249,6 +249,9 @@ struct kvm_vapic_addr {
 #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\
 					struct kvm_userspace_memory_region)
 #define KVM_SET_TSS_ADDR          _IO(KVMIO, 0x47)
+#define KVM_SET_GUEST_PVR         _IOW(KVMIO, 0x97, struct kvm_pvr)
+#define KVM_GET_GUEST_PVR         _IOR(KVMIO, 0x98, struct kvm_pvr)
+
 /*
  * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
  * a vcpu fd.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-01 13:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-30 12:31 [kvm-ppc-devel] [PATCH] [1/4] Add per guest pvr ehrhardt
2008-01-30 21:18 ` Hollis Blanchard
2008-01-30 21:40 ` Hollis Blanchard
2008-01-31  8:37 ` Christian Ehrhardt
2008-01-31 14:56 ` ehrhardt
2008-02-01 13:31 ` Zhang Wei

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.