Kernel KVM-PPC virtualization development
 help / color / mirror / Atom feed
From: ehrhardt@linux.vnet.ibm.com
To: kvm-ppc@vger.kernel.org
Subject: [kvm-ppc-devel] [PATCH] [2/4] Add per guest pvr (userspace)
Date: Thu, 31 Jan 2008 14:56:34 +0000	[thread overview]
Message-ID: <1201791398431-git-send-email-ehrhardt@linux.vnet.ibm.com> (raw)
In-Reply-To: <12016963192977-git-send-email-ehrhardt@linux.vnet.ibm.com>

From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

This adds a per vcpu interface to get/set the the pvr.
The current patch sets the pvr for a PPC440EP when the selected guest type
is a bamboo machine.

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

 libkvm/libkvm-powerpc.c |   21 +++++++++++++++++++++
 libkvm/libkvm.h         |    4 ++++
 qemu/hw/ppc440_bamboo.c |    1 +
 qemu/qemu-kvm-powerpc.c |    5 +++++
 qemu/qemu-kvm.h         |    1 +
 qemu/vl.c               |    1 +
 6 files changed, 33 insertions(+)

diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -25,6 +25,7 @@
 #include "kvm-powerpc.h"
 #include <errno.h>
 #include <stdio.h>
+#include <sys/ioctl.h>
 
 int handle_dcr(struct kvm_run *run,  kvm_context_t kvm, int vcpu)
 {
@@ -85,6 +86,30 @@ void kvm_show_regs(kvm_context_t kvm, in
 	fflush(stdout);
 }
 
+int kvm_get_guest_pvr(kvm_context_t kvm, int vcpu)
+{
+	int r = 0;
+	struct kvm_pvr kvm_guest_pvr;
+
+	r = ioctl(kvm->vcpu_fd[vcpu], KVM_GET_GUEST_PVR, &kvm_guest_pvr);
+	if (r)
+		fprintf(stderr, "%s failed (r='%d')\n", __func__, r);
+
+
+	return kvm_guest_pvr.pvr;
+}
+
+void kvm_set_guest_pvr(kvm_context_t kvm, uint32_t guest_pvr, int vcpu)
+{
+	int r = 0;
+	struct kvm_pvr kvm_guest_pvr;
+	kvm_guest_pvr.pvr = guest_pvr;
+
+	r = ioctl(kvm->vcpu_fd[vcpu], KVM_SET_GUEST_PVR, &kvm_guest_pvr);
+	if (r)
+		fprintf(stderr, "%s failed (r='%d')\n", __func__, r);
+}
+
 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
 			 void **vm_mem)
 {
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -556,4 +556,8 @@ int kvm_enable_vapic(kvm_context_t kvm, 
 
 #endif
 
+#if defined(__powerpc__)
+void kvm_set_guest_pvr(kvm_context_t kvm, uint32_t guest_pvr, int vcpu);
 #endif
+
+#endif
diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -102,6 +102,7 @@ void bamboo_init(ram_addr_t ram_size, in
 	}
 
 #if USE_KVM
+	set_guest_pvr(KVM_PPC_PVR_PPC440EP, env);
 	/* XXX insert TLB entries */
 	env->gpr[1] = (16<<20) - 8;
 	env->gpr[4] = initrd_base;
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -194,4 +194,9 @@ int handle_powerpc_dcr_write(int vcpu, u
     return 0; /* XXX ignore failed DCR ops */
 }
 
+void set_guest_pvr(uint32_t guest_pvr, CPUState *env)
+{
+	kvm_set_guest_pvr(kvm_context, guest_pvr, env->cpu_index);
+}
+
 #endif
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -57,6 +57,7 @@ int handle_tpr_access(void *opaque, int 
 #ifdef TARGET_PPC
 int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data);
 int handle_powerpc_dcr_write(int vcpu,uint32_t dcrn, uint32_t data);
+void set_guest_pvr(uint32_t guest_pvr, CPUState *env);
 #endif
 
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))

-------------------------------------------------------------------------
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

      reply	other threads:[~2008-01-31 14:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-30 12:31 [kvm-ppc-devel] [PATCH] [2/4] Add per guest pvr (userspace) ehrhardt
2008-01-31 14:56 ` ehrhardt [this message]

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=1201791398431-git-send-email-ehrhardt@linux.vnet.ibm.com \
    --to=ehrhardt@linux.vnet.ibm.com \
    --cc=kvm-ppc@vger.kernel.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